From c26f171dbf226abc4d7ee01d83c8b31460f06eef Mon Sep 17 00:00:00 2001 From: egagofur Date: Tue, 24 Nov 2026 20:27:38 +0700 Subject: [PATCH] feat(studio): rewrite the Studio UI in Svelte 5; smoother 3D kitchen Studio's browser UI moves from hand-written DOM code to Svelte 5 components compiled by Vite into studio/app/ (committed and shipped). Svelte and Vite are devDependencies; the CLI keeps no runtime deps. - Projects snapshots patch only the rows, labels and chips that changed instead of rebuilding panels with innerHTML, so focus, typed names and running animations survive refreshes. - 3D kitchen: overlay labels read sizes from a ResizeObserver cache instead of forcing a layout per label per frame; pixel ratio capped at 1.5 and dropped to 1x when frames run slow. - Server serves the built app; hashed assets are cached immutably and a rebuild is picked up without restarting Studio. - npm run build:studio / check:studio (drift check in CI and prepublish); CI and publish run npm ci. - Tests render components through Svelte SSR; new tests cover the 3D layout fix, asset caching, rebuild pickup and sketch frame state. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 3 + .github/workflows/publish.yml | 2 + AGENTS.md | 10 +- CHANGELOG.md | 5 + THIRD_PARTY_NOTICES.md | 13 +- core/local-workflow-studio.md | 6 +- lib/doctor.js | 2 +- lib/studio-server.js | 60 +- package-lock.json | 1199 ++++++ package.json | 14 +- scripts/build-studio.js | 77 + studio/app/assets/index-DJi-HckC.js | 5 + studio/app/assets/index-DRPjBiGr.css | 1 + studio/app/assets/restaurant-DuFRqeba.js | 4091 +++++++++++++++++++++ studio/app/index.html | 12 + studio/app/licenses/svelte.LICENSE | 7 + studio/app/licenses/three.LICENSE | 21 + studio/index.html | 79 - studio/js/detail.js | 139 +- studio/js/list.js | 82 +- studio/js/main.js | 885 ----- studio/js/orders.js | 44 +- studio/js/restaurant.js | 60 +- studio/js/ring2d.js | 86 +- studio/js/sheet.js | 84 +- studio/src/App.svelte | 534 +++ studio/src/components/FreezeButton.svelte | 13 + studio/src/components/OrderBook.svelte | 46 + studio/src/components/Overview.svelte | 22 + studio/src/components/ProjectList.svelte | 40 + studio/src/components/Ring.svelte | 201 + studio/src/components/Room.svelte | 60 + studio/src/components/RunDetail.svelte | 62 + studio/src/components/RunHead.svelte | 30 + studio/src/components/Sheet.svelte | 95 + studio/src/components/Sketch.svelte | 47 + studio/src/index.html | 11 + studio/src/main.js | 8 + studio/src/package.json | 1 + studio/src/tabs.js | 13 + studio/vite.config.mjs | 21 + tests/helpers/svelte-hooks.mjs | 13 + tests/helpers/svelte.js | 31 + tests/studio-design-tokens.test.js | 2 +- tests/studio-diners.test.js | 17 +- tests/studio-goal-header-bot.test.js | 62 +- tests/studio-kitchen.test.js | 46 +- tests/studio-orders.test.js | 17 +- tests/studio-ring.test.js | 65 +- tests/studio-rooms-moods.test.js | 55 +- tests/studio-server.test.js | 76 +- tests/studio-sketch.test.js | 45 +- tests/studio-ui-render.test.js | 163 +- tests/v110-first-run.test.js | 7 +- 54 files changed, 7165 insertions(+), 1625 deletions(-) create mode 100644 package-lock.json create mode 100644 scripts/build-studio.js create mode 100644 studio/app/assets/index-DJi-HckC.js create mode 100644 studio/app/assets/index-DRPjBiGr.css create mode 100644 studio/app/assets/restaurant-DuFRqeba.js create mode 100644 studio/app/index.html create mode 100644 studio/app/licenses/svelte.LICENSE create mode 100644 studio/app/licenses/three.LICENSE delete mode 100644 studio/index.html delete mode 100644 studio/js/main.js create mode 100644 studio/src/App.svelte create mode 100644 studio/src/components/FreezeButton.svelte create mode 100644 studio/src/components/OrderBook.svelte create mode 100644 studio/src/components/Overview.svelte create mode 100644 studio/src/components/ProjectList.svelte create mode 100644 studio/src/components/Ring.svelte create mode 100644 studio/src/components/Room.svelte create mode 100644 studio/src/components/RunDetail.svelte create mode 100644 studio/src/components/RunHead.svelte create mode 100644 studio/src/components/Sheet.svelte create mode 100644 studio/src/components/Sketch.svelte create mode 100644 studio/src/index.html create mode 100644 studio/src/main.js create mode 100644 studio/src/package.json create mode 100644 studio/src/tabs.js create mode 100644 studio/vite.config.mjs create mode 100644 tests/helpers/svelte-hooks.mjs create mode 100644 tests/helpers/svelte.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 100b77f..0e50a98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} + - run: npm ci - run: npm test - run: node bin/ai-engineering-loop.js doctor --package - run: node bin/ai-engineering-loop.js eval @@ -32,7 +33,9 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 22 + - run: npm ci - run: npm run check:skills + - run: npm run check:studio - run: npm run audit:package - run: npm run measure - run: npm pack --dry-run diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 89948cf..a154e4a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -29,6 +29,8 @@ jobs: run: npm install --global npm@11.6.2 - name: Verify release identity run: node scripts/verify-release.js "${{ inputs.tag }}" + - name: Install build tools + run: npm ci - name: Validate package run: npm run prepublishOnly - name: Publish with provenance diff --git a/AGENTS.md b/AGENTS.md index b3dc57e..5b49b5a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ # AGENTS.md: ai-engineering-loop -AEL is an npm CLI (`bin/ai-engineering-loop.js`, alias `ael`) plus host skills that run a gated engineering loop: Goal Contract -> Maker -> verification -> Devil's Advocate -> Judge -> delivery. Plain Node.js (CommonJS, Node >= 18), no build step, no runtime dependencies. +AEL is an npm CLI (`bin/ai-engineering-loop.js`, alias `ael`) plus host skills that run a gated engineering loop: Goal Contract -> Maker -> verification -> Devil's Advocate -> Judge -> delivery. Plain Node.js (CommonJS, Node >= 18), no runtime dependencies. The CLI has no build step; only Studio's browser UI is compiled (Svelte + Vite, devDependencies) into the committed `studio/app/`. ## Start here @@ -18,12 +18,13 @@ AEL is an npm CLI (`bin/ai-engineering-loop.js`, alias `ael`) plus host skills t | `npm run eval` | when touching `evals/` or Judge/DA policy | | `npm run audit:package` | when touching `package.json` `files` or adding files | | `npm run measure` | after any skill text change (T1 context budget) | +| `npm run build:studio` / `npm run check:studio` | after editing `studio/src/`, `studio/js/` or `studio/*.css` (rebuild, then check `studio/app/` matches) | -Full pre-publish gate: `npm run check:skills && npm test && npm run doctor && npm run eval && npm run audit:package`. +Full pre-publish gate: `npm run check:skills && npm run check:studio && npm test && npm run doctor && npm run eval && npm run audit:package`. ## Hard rules -- **Generated files.** `.claude/skills/ael/**` and `.agents/skills/ael/**` are built from `skill-src/` by `npm run build:skills`. Never edit them by hand; `check:skills` fails on drift. +- **Generated files.** `.claude/skills/ael/**` and `.agents/skills/ael/**` are built from `skill-src/` by `npm run build:skills`. `studio/app/**` is built from `studio/src/`, `studio/js/` and the CSS by `npm run build:studio`. Never edit them by hand; `check:skills` and `check:studio` fail on drift. - **Agent prompts.** The Devil's Advocate and Judge prompts live in `agents/shared/*.body.md`. `.claude/agents/*.md` and `.grok/agents/*.md` must carry the same body under their own frontmatter (tested in `tests/skill-host-compat.test.js`). - **Skill context budget.** T1 parent context (SKILL.md plus the references a T1 run reads) must stay at or under 50% of the baseline in `scripts/measure.js` (tested). Put detail in `core/*.md` (served by `ael docs `) or in references that T1 does not read (`loop-commands`, `loop-report`, `loop-hosts`, `loop-risky`). `ael doctor --harness` shows the headroom. - **Gate errors.** Every `gateError(...)` in `lib/gates.js` passes `{ why, fix }` (tested). Fixes name the exact next command. @@ -42,6 +43,9 @@ Full pre-publish gate: `npm run check:skills && npm test && npm run doctor && np | `lib/claimed-vs-reality.js` | claimed-vs-reality parsing and the L1/L2/L3 rules | | `lib/cli-args.js` | flag allowlist for commands that write files | | `skill-src/ael/` | skill template and stage references (source of truth) | +| `studio/src/` | Studio UI: Svelte components (`App.svelte`, `components/`), Vite entry | +| `studio/js/` | Studio pure helpers and the three.js kitchen scene (imported by the components and by tests) | +| `studio/app/` | built Studio served by `lib/studio-server.js` (generated, shipped) | | `agents/` | DA, Judge, Maker specs; `agents/shared/` = runtime prompt bodies | | `core/`, `policies/` | specs served by `ael docs ` | | `schemas/` | JSON Schemas for Run artifacts | diff --git a/CHANGELOG.md b/CHANGELOG.md index 406ddcf..f18e862 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project are documented here. Versions follow [Semant ## Unreleased +- **Changed:** Studio's interface is rewritten in Svelte 5, compiled with Vite into `studio/app/` (committed and shipped; Svelte and Vite are devDependencies, the CLI still has no runtime dependencies). A projects snapshot now patches only the rows, labels and chips that changed instead of rebuilding the list, the Run header, the details and the ring with `innerHTML`, so focus and typed names survive refreshes and animations no longer stutter on every update. +- **Changed:** smoother kitchen: the 3D scene renders at most 1.5x device pixel ratio and drops to 1x when frames run slow, and the overlay labels read cached sizes instead of forcing a layout per label on every frame. +- **Changed:** Studio's hashed JS/CSS assets are cached by the browser for a year; the page itself still revalidates on every load. Old `/js/*.js`, `/vendor/*` and `/styles.css` URLs are gone. +- **Added:** `npm run build:studio` and `npm run check:studio` (drift check in CI and before publish). + ## 3.1.0 - 2026-11-24 A busy Studio kitchen with an order book, delivery approval recorded at once, and AEL never delivers code the Judge did not see (#179, #180). diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index be4fbfc..fd1d845 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -11,11 +11,18 @@ The vendored skill text remains authored by the original project. See the upstre ## three.js -Studio's loop ring renders with a vendored, unmodified copy of three.js. It is a shipped static file, not an npm dependency. +Studio's kitchen scene renders with a vendored, unmodified copy of three.js. The vendored files are build input: Vite bundles the parts the scene uses into the shipped Studio chunk. - Source: https://github.com/mrdoob/three.js (npm package `three`, version 0.185.1, fetched with `npm pack three@0.185.1`) -- License: MIT, shipped as `studio/vendor/three.LICENSE` -- AEL files shipped: `studio/vendor/three.module.min.js` and the `studio/vendor/three.core.min.js` it imports, both copied from the package `build/` folder. +- License: MIT, kept as `studio/vendor/three.LICENSE` and shipped as `studio/app/licenses/three.LICENSE` +- Vendored files: `studio/vendor/three.module.min.js` and the `studio/vendor/three.core.min.js` it imports, both copied from the package `build/` folder. + +## Svelte + +Studio's interface is written in Svelte and compiled at build time; the small Svelte runtime is bundled into `studio/app/assets/`. Svelte is a devDependency, not a runtime dependency of the CLI. + +- Source: https://github.com/sveltejs/svelte (npm package `svelte`, version 5.59.1) +- License: MIT, shipped as `studio/app/licenses/svelte.LICENSE` ## google/elephant-goldfish-model (Elephant-Goldfish Model, EGM) diff --git a/core/local-workflow-studio.md b/core/local-workflow-studio.md index 0e44666..b1afa28 100644 --- a/core/local-workflow-studio.md +++ b/core/local-workflow-studio.md @@ -24,7 +24,7 @@ There is one Studio per machine. It writes its pid, port and URL to `~/.ai-engin - Binds `127.0.0.1` only and rejects a non-local `Host` header. - A random per-process token is printed once in the URL on the terminal that started Studio (with `--background` the detached process hands it to that terminal over an IPC channel); the server exchanges it for an `HttpOnly; SameSite=Strict` cookie and removes it from the address bar. The token is never written to disk: not to `studio.json`, not to `studio.log`. A request target that is not a valid URL gets `400 Bad request`. -- CSP `default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'`. Static files come from an explicit allowlist bundled in the package: no CDN, analytics or remote fonts. three.js 0.185.1 (MIT) is vendored in `studio/vendor/`. +- CSP `default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'`. Static files come only from the built app bundled in the package (`studio/app/`: the page, its hashed `assets/` and `diners.json`): no CDN, analytics or remote fonts. The interface is Svelte 5 compiled at build time; three.js 0.185.1 (MIT) is vendored in `studio/vendor/` and bundled into the lazily loaded kitchen chunk. - Read scope: each project in the registry (`~/.ai-engineering-loop/projects.json`, `ael projects list`) and each worktree listed in its `.ai-engineering-loop/worktrees.json`, and only the `.ai-engineering-loop/` folder inside them. Symlinks out of that folder are refused. The browser never sends a path: projects are addressed by an opaque id (a hash of the real path). ## What you see @@ -52,7 +52,9 @@ The named diners are a nod to people who inspired AEL, relaxing over dinner whil Each entry needs a `name` (at most 40 characters) and may have a `note` (at most 60); Studio keeps the first 6 valid entries, drops the rest, and shows names as escaped text. When no entry is valid it falls back to `studio/diners.json`. `GET /api/me` returns the list as `diners`; there is no endpoint that writes it. -Studio polls the registered projects every 2 s and pushes a `projects` snapshot over server-sent events only when something changed. Each poll walks a Run's directory once to refuse symlinks that leave `.ai-engineering-loop/`. Studio's own page files (HTML, CSS, JS, three.js) are sent with an `ETag` and `cache-control: no-cache`, so a reload revalidates and gets `304 Not Modified` instead of the files again; files of 1 KiB or more are brotli- or gzip-compressed when the browser accepts it. API responses stay `no-store`. The kitchen's three.js module starts loading as soon as the page boots, in parallel with the first API calls. +Studio updates only what changed: each snapshot patches the affected rows, labels and chips in place instead of redrawing panels, so focus, typed text and running animations survive a refresh. The kitchen scene draws at most 1.5 device pixels per CSS pixel and drops to 1x when frames run slow; the 2D labels over it read their sizes from a `ResizeObserver` cache, so the render loop never forces a layout. + +Studio polls the registered projects every 2 s and pushes a `projects` snapshot over server-sent events only when something changed. Each poll walks a Run's directory once to refuse symlinks that leave `.ai-engineering-loop/`. Studio's page is sent with an `ETag` and `cache-control: no-cache`, so a reload revalidates and picks up a new build; its content-hashed `assets/` files (JS, CSS, the three.js kitchen chunk) are cached for a year (`private, max-age=31536000, immutable`) and also answer `304 Not Modified` to a matching `ETag`; files of 1 KiB or more are brotli- or gzip-compressed when the browser accepts it. API responses stay `no-store`. The kitchen's three.js module starts loading as soon as the page boots, in parallel with the first API calls. ## Freeze diff --git a/lib/doctor.js b/lib/doctor.js index 5b2fd80..e0dc546 100644 --- a/lib/doctor.js +++ b/lib/doctor.js @@ -148,7 +148,7 @@ function runDoctor(rootDir = path.join(__dirname, '..'), { projectDir = null, ru } const packageFiles = new Set(pkg.files || []); - const requiredPackageEntries = ['bin/', 'lib/', 'core/', 'policies/', 'recipes/', 'schemas/', 'evals/', 'studio/']; + const requiredPackageEntries = ['bin/', 'lib/', 'core/', 'policies/', 'recipes/', 'schemas/', 'evals/', 'studio/app/', 'studio/diners.json']; const missingPackageEntries = requiredPackageEntries.filter((entry) => !packageFiles.has(entry)); checks.push(check( 'package-assets', diff --git a/lib/studio-server.js b/lib/studio-server.js index 19cd86e..1bb652c 100644 --- a/lib/studio-server.js +++ b/lib/studio-server.js @@ -47,32 +47,29 @@ function recordStudioFreeze(root, runId, actor) { } const PING_MS = 15_000; const ASSET_DIR = path.join(__dirname, '..', 'studio'); -const STATIC_ASSETS = new Map([ - ['/', 'index.html'], - ['/index.html', 'index.html'], - ['/tokens.css', 'tokens.css'], - ['/styles.css', 'styles.css'], - ['/diners.json', 'diners.json'], - ['/js/main.js', 'js/main.js'], - ['/js/api.js', 'js/api.js'], - ['/js/list.js', 'js/list.js'], - ['/js/orders.js', 'js/orders.js'], - ['/js/workstation.js', 'js/workstation.js'], - ['/js/detail.js', 'js/detail.js'], - ['/js/markdown.js', 'js/markdown.js'], - ['/js/sheet.js', 'js/sheet.js'], - ['/js/bot.js', 'js/bot.js'], - ['/js/mood.js', 'js/mood.js'], - ['/js/kitchen.js', 'js/kitchen.js'], - ['/js/forms.js', 'js/forms.js'], - ['/js/stations.js', 'js/stations.js'], - ['/js/diners.js', 'js/diners.js'], - ['/js/carriers.js', 'js/carriers.js'], - ['/js/restaurant.js', 'js/restaurant.js'], - ['/js/ring2d.js', 'js/ring2d.js'], - ['/vendor/three.module.min.js', 'vendor/three.module.min.js'], - ['/vendor/three.core.min.js', 'vendor/three.core.min.js'] -]); +const APP_DIR = 'app'; +const HASHED_ASSET = /^\/assets\/[A-Za-z0-9_.-]+-[A-Za-z0-9_-]{8}\.(?:js|css)$/; + +function appAssets(dir = path.join(ASSET_DIR, APP_DIR)) { + const assets = new Map([ + ['/', `${APP_DIR}/index.html`], + ['/index.html', `${APP_DIR}/index.html`], + ['/diners.json', 'diners.json'] + ]); + let files = []; + try { + files = fs.readdirSync(path.join(dir, 'assets'), { withFileTypes: true }); + } catch { + return assets; + } + for (const file of files) { + const route = `/assets/${file.name}`; + if (file.isFile() && HASHED_ASSET.test(route)) assets.set(route, `${APP_DIR}${route}`); + } + return assets; +} + +let STATIC_ASSETS = appAssets(); const CONTENT_TYPES = { html: 'text/html', js: 'text/javascript', css: 'text/css', json: 'application/json' }; const CONTENT_SECURITY_POLICY = "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'"; const DIAGRAM_POLICY = ["default-src 'none'", "img-src data:", "base-uri 'none'", "form-action 'none'", "frame-ancestors 'self'", 'sandbox']; @@ -283,7 +280,11 @@ function etagMatches(header, etag) { } function serveAsset(request, response, pathname) { - const asset = STATIC_ASSETS.get(pathname); + let asset = STATIC_ASSETS.get(pathname); + if (!asset && HASHED_ASSET.test(pathname)) { + STATIC_ASSETS = appAssets(); + asset = STATIC_ASSETS.get(pathname); + } let entry; try { entry = asset && loadAsset(asset); @@ -294,7 +295,8 @@ function serveAsset(request, response, pathname) { response.writeHead(404, { 'cache-control': 'no-store' }).end('Not found'); return; } - const headers = { 'cache-control': 'no-cache', etag: entry.etag, vary: 'accept-encoding' }; + const cacheControl = HASHED_ASSET.test(pathname) ? 'private, max-age=31536000, immutable' : 'no-cache'; + const headers = { 'cache-control': cacheControl, etag: entry.etag, vary: 'accept-encoding' }; if (etagMatches(request.headers['if-none-match'], entry.etag)) { response.writeHead(304, headers).end(); return; @@ -558,4 +560,4 @@ function createStudioServer({ return { server, token, close }; } -module.exports = { createStudioServer }; +module.exports = { createStudioServer, appAssets }; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..201afe3 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1199 @@ +{ + "name": "ai-engineering-loop", + "version": "3.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ai-engineering-loop", + "version": "3.1.0", + "license": "MIT", + "bin": { + "ael": "bin/ai-engineering-loop.js", + "ai-engineering-loop": "bin/ai-engineering-loop.js" + }, + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "7.3.2", + "svelte": "5.59.1", + "vite": "8.3.8" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@emnapi/core": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-2.0.0-beta.2.tgz", + "integrity": "sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "2.2.0", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-2.0.0-beta.2.tgz", + "integrity": "sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-2.2.0.tgz", + "integrity": "sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.3.tgz", + "integrity": "sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.6.tgz", + "integrity": "sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.3" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1 || 2.0.0-beta.2", + "@emnapi/runtime": "^1.7.1 || 2.0.0-beta.2" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.156.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.156.0.tgz", + "integrity": "sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/oxc-project" + } + }, + "node_modules/@rolldown/binding-android-arm-eabi": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.19.tgz", + "integrity": "sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.19.tgz", + "integrity": "sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.19.tgz", + "integrity": "sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.19.tgz", + "integrity": "sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.19.tgz", + "integrity": "sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.19.tgz", + "integrity": "sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.19.tgz", + "integrity": "sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.19.tgz", + "integrity": "sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.19.tgz", + "integrity": "sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.19.tgz", + "integrity": "sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.19.tgz", + "integrity": "sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.19.tgz", + "integrity": "sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.19.tgz", + "integrity": "sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.2.19.tgz", + "integrity": "sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "2.0.0-beta.2", + "@emnapi/runtime": "2.0.0-beta.2", + "@napi-rs/wasm-runtime": "1.2.6" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.19.tgz", + "integrity": "sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.19.tgz", + "integrity": "sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.1.1.tgz", + "integrity": "sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@sveltejs/acorn-typescript": { + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/@sveltejs/acorn-typescript/-/acorn-typescript-1.0.13.tgz", + "integrity": "sha512-wgKggnhZVL9Bfx1OaKKTrYY9BFRk6C8UAkQNUcIv1+llzYrIqy+RZm5HPKzn0NpEBvTVhTqB4kQyllZywsRBRQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^8.9.0" + } + }, + "node_modules/@sveltejs/vite-plugin-svelte": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-7.3.2.tgz", + "integrity": "sha512-86J4nBLeTqYYIx/paBIRqYJMFYlpTS2sepUdQ6tUyU1jxqRV72ejOrIV2wsqlOsKlkM+h0G1SgwoHI30N+n9CA==", + "dev": true, + "license": "MIT", + "dependencies": { + "deepmerge": "^4.3.1", + "obug": "^3.0.0", + "vitefu": "^1.1.2" + }, + "engines": { + "node": "^20.19 || ^22.12 || >=24" + }, + "peerDependencies": { + "svelte": "^5.46.4", + "vite": "^8.0.0-beta.7 || ^8.0.0" + } + }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.5", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.5.tgz", + "integrity": "sha512-dOGOPxlaNV+G046mZzN+9C0dAcQZeSKcXiVaM0TYy/LM4ttTmgSBDxYfovcYI8Em3+eAbiAYpvWLOv8+ZVRJKA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@types/estree": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz", + "integrity": "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==", + "dev": true, + "license": "MIT" + }, + "node_modules/acorn": { + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz", + "integrity": "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/aria-query": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.1.tgz", + "integrity": "sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/axobject-query": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz", + "integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/devalue": { + "version": "5.9.4", + "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.9.4.tgz", + "integrity": "sha512-sPAT4pztbu6586/hrhOnMKS17IJrvg12mXiSPSS3W5qDeN2RGgvZ0diZCm31dBbnevfVmujNO3IM2wrS4Y2Rhg==", + "dev": true, + "license": "MIT" + }, + "node_modules/esm-env": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/esm-env/-/esm-env-1.2.2.tgz", + "integrity": "sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/esrap": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/esrap/-/esrap-2.4.2.tgz", + "integrity": "sha512-WpVZsWnSheHBy+fGrO/0duwnbe6ODZH1QyBbjupreSCJGojaBWRncrq+HVeIJ8eHQjEwSJg9hC4yPJyNVOrpqg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15" + }, + "peerDependencies": { + "@typescript-eslint/types": "^8.2.0" + }, + "peerDependenciesMeta": { + "@typescript-eslint/types": { + "optional": true + } + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/is-reference": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz", + "integrity": "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.6" + } + }, + "node_modules/lightningcss": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", + "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.33.0", + "lightningcss-darwin-arm64": "1.33.0", + "lightningcss-darwin-x64": "1.33.0", + "lightningcss-freebsd-x64": "1.33.0", + "lightningcss-linux-arm-gnueabihf": "1.33.0", + "lightningcss-linux-arm64-gnu": "1.33.0", + "lightningcss-linux-arm64-musl": "1.33.0", + "lightningcss-linux-x64-gnu": "1.33.0", + "lightningcss-linux-x64-musl": "1.33.0", + "lightningcss-win32-arm64-msvc": "1.33.0", + "lightningcss-win32-x64-msvc": "1.33.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", + "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", + "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", + "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", + "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", + "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", + "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", + "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", + "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", + "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", + "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", + "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/locate-character": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz", + "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==", + "dev": true, + "license": "MIT" + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/obug": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/obug/-/obug-3.0.0.tgz", + "integrity": "sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.33", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.33.tgz", + "integrity": "sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.20", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/rolldown": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.19.tgz", + "integrity": "sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.156.0", + "@rolldown/pluginutils": "^1.0.0" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm-eabi": "1.2.19", + "@rolldown/binding-android-arm64": "1.2.19", + "@rolldown/binding-darwin-arm64": "1.2.19", + "@rolldown/binding-darwin-x64": "1.2.19", + "@rolldown/binding-freebsd-x64": "1.2.19", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.19", + "@rolldown/binding-linux-arm64-gnu": "1.2.19", + "@rolldown/binding-linux-arm64-musl": "1.2.19", + "@rolldown/binding-linux-ppc64-gnu": "1.2.19", + "@rolldown/binding-linux-s390x-gnu": "1.2.19", + "@rolldown/binding-linux-x64-gnu": "1.2.19", + "@rolldown/binding-linux-x64-musl": "1.2.19", + "@rolldown/binding-openharmony-arm64": "1.2.19", + "@rolldown/binding-wasm32-wasi": "1.2.19", + "@rolldown/binding-win32-arm64-msvc": "1.2.19", + "@rolldown/binding-win32-x64-msvc": "1.2.19" + } + }, + "node_modules/source-map-js": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.4.tgz", + "integrity": "sha512-J7ZjMvHd9O1fcT/5V09QWaaSl2BbWx3F6O08spde82Namf9UB0GxRVIPiNbVsdKkoizHiSpTodo3vp2bAy91MA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/svelte": { + "version": "5.59.1", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.59.1.tgz", + "integrity": "sha512-ADG20W/jYSQut/79AavRRfbXQYebFKMVWT/xAbjVVZfZA4XzIoFfcpanEfYTyN+uWQUaPP+nstFx4qVKwEVnQQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/remapping": "^2.3.5", + "@jridgewell/sourcemap-codec": "^1.6.0", + "@sveltejs/acorn-typescript": "^1.0.13", + "@types/estree": "^1.0.9", + "acorn": "^8.18.0", + "aria-query": "5.3.1", + "axobject-query": "^4.1.0", + "clsx": "^2.1.1", + "devalue": "^5.9.2", + "esm-env": "^1.2.1", + "esrap": "^2.4.2", + "is-reference": "^3.0.3", + "locate-character": "^3.0.0", + "magic-string": "^0.30.11", + "zimmerframe": "^1.1.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tslib": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "dev": true, + "license": "0BSD", + "optional": true + }, + "node_modules/vite": { + "version": "8.3.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.8.tgz", + "integrity": "sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==", + "dev": true, + "license": "MIT", + "dependencies": { + "lightningcss": "^1.33.0", + "picomatch": "^4.0.7", + "postcss": "^8.5.32", + "rolldown": "~1.2.18", + "tinyglobby": "^0.2.17" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "@vitejs/devtools": "^0.7.1 || ^0.8.0", + "esbuild": "^0.27.0 || ^0.28.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vitefu": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.1.4.tgz", + "integrity": "sha512-qbEIDswfXH3x3IYRMScl/bf1AVW0dn7Z8qkr7g7nohkusfuC7tcFa7t5EoTOz60AunosLM9sDrDjHxsX+Up+CQ==", + "dev": true, + "license": "MIT", + "workspaces": [ + "tests/deps/*", + "tests/projects/*", + "tests/projects/workspace/packages/*" + ], + "peerDependencies": { + "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "vite": { + "optional": true + } + } + }, + "node_modules/zimmerframe": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.5.tgz", + "integrity": "sha512-msJxIvYDYcoNL+PJsu+7qmpDWsYmAxTY+2TNYXXF0hzBzBk0BMecOqDOG/EckUoKCuKwObfbugIl8QpqHDXeFA==", + "dev": true, + "license": "MIT" + } + } +} diff --git a/package.json b/package.json index d0d0d08..72be2cc 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "adapters/", "recipes/", "schemas/", - "studio/", + "studio/app/", + "studio/diners.json", "docs/images/", "evals/", ".agents/", @@ -38,9 +39,11 @@ "eval": "node bin/ai-engineering-loop.js eval", "audit:package": "node scripts/audit-package.js", "verify:release": "node scripts/verify-release.js", - "prepublishOnly": "npm run check:skills && npm test && npm run doctor && npm run eval && npm run audit:package", + "prepublishOnly": "npm run check:skills && npm run check:studio && npm test && npm run doctor && npm run eval && npm run audit:package", "build:skills": "node scripts/build-host-skills.js", "check:skills": "node scripts/build-host-skills.js --check", + "build:studio": "node scripts/build-studio.js", + "check:studio": "node scripts/build-studio.js --check", "build:hosts-table": "node scripts/build-host-table.js", "measure": "node scripts/measure.js" }, @@ -68,5 +71,10 @@ "bugs": { "url": "https://github.com/egagofur/ai-engineering-loop/issues" }, - "homepage": "https://github.com/egagofur/ai-engineering-loop#readme" + "homepage": "https://github.com/egagofur/ai-engineering-loop#readme", + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "7.3.2", + "svelte": "5.59.1", + "vite": "8.3.8" + } } diff --git a/scripts/build-studio.js b/scripts/build-studio.js new file mode 100644 index 0000000..6075981 --- /dev/null +++ b/scripts/build-studio.js @@ -0,0 +1,77 @@ +#!/usr/bin/env node +'use strict'; + +// Usage: node scripts/build-studio.js [--check] +// Builds the Svelte Studio from studio/src into studio/app (committed and shipped). +// --check rebuilds into a temp folder and fails if studio/app drifted from the sources. +const fs = require('fs'); +const os = require('os'); +const path = require('path'); + +const ROOT = path.join(__dirname, '..'); +const APP = path.join(ROOT, 'studio', 'app'); +const CONFIG = path.join(ROOT, 'studio', 'vite.config.mjs'); +const LICENSES = [ + ['three.LICENSE', path.join(ROOT, 'studio', 'vendor', 'three.LICENSE')], + ['svelte.LICENSE', path.join(ROOT, 'node_modules', 'svelte', 'LICENSE.md')] +]; + +async function build(outDir) { + let vite; + try { + vite = await import('vite'); + } catch { + throw new Error('Vite is not installed. Run `npm ci` first, then `npm run build:studio`.'); + } + process.env.AEL_STUDIO_OUT = outDir; + await vite.build({ configFile: CONFIG, logLevel: 'warn' }); + const licenses = path.join(outDir, 'licenses'); + fs.mkdirSync(licenses, { recursive: true }); + for (const [name, source] of LICENSES) fs.copyFileSync(source, path.join(licenses, name)); +} + +function listFiles(dir, base = dir) { + if (!fs.existsSync(dir)) return []; + return fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => { + const full = path.join(dir, entry.name); + return entry.isDirectory() ? listFiles(full, base) : [path.relative(base, full).split(path.sep).join('/')]; + }).sort(); +} + +function drift(expectedDir, actualDir) { + const expected = listFiles(expectedDir); + const actual = listFiles(actualDir); + const problems = []; + for (const file of expected) { + if (!actual.includes(file)) problems.push(`missing studio/app/${file}`); + else if (!fs.readFileSync(path.join(expectedDir, file)).equals(fs.readFileSync(path.join(actualDir, file)))) problems.push(`stale studio/app/${file}`); + } + for (const file of actual) if (!expected.includes(file)) problems.push(`extra studio/app/${file}`); + return problems; +} + +async function main() { + if (!process.argv.includes('--check')) { + await build(APP); + console.log(`Built Studio into studio/app (${listFiles(APP).length} files).`); + return; + } + const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'ael-studio-')); + try { + await build(temp); + const problems = drift(temp, APP); + if (problems.length) { + console.error(`Studio build drifts from studio/src (run npm run build:studio):\n${problems.map((item) => `- ${item}`).join('\n')}`); + process.exitCode = 1; + return; + } + console.log('Studio build matches studio/src.'); + } finally { + fs.rmSync(temp, { recursive: true, force: true }); + } +} + +main().catch((error) => { + console.error(error.message); + process.exitCode = 1; +}); diff --git a/studio/app/assets/index-DJi-HckC.js b/studio/app/assets/index-DJi-HckC.js new file mode 100644 index 0000000..d2fb5f1 --- /dev/null +++ b/studio/app/assets/index-DJi-HckC.js @@ -0,0 +1,5 @@ +var e=Array.isArray,t=Array.prototype.indexOf,n=Array.prototype.includes,r=Array.from,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyDescriptors,s=Object.prototype,c=Array.prototype,l=Object.getPrototypeOf,u=Object.isExtensible,d=()=>{};function f(e){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}var m=1<<24,h=1024,g=2048,_=4096,v=8192,y=16384,b=32768,x=1<<25,S=65536,C=1<<19,w=1<<20,ee=1<<25,te=1<<21,ne=1<<22,re=1<<23,ie=1<<27,ae=1<<26,oe=Symbol(`$state`),se=Symbol(`component`),ce=Symbol(`legacy props`),le=Symbol(``),ue=Symbol(`attributes`),de=Symbol(`class`),fe=Symbol(`style`),pe=Symbol(`text`),me=Symbol(`form reset`),he=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},T=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`),ge={},E=Symbol(`uninitialized`),_e=`http://www.w3.org/2000/svg`,ve=`http://www.w3.org/1998/Math/MathML`;function ye(){console.warn(`https://svelte.dev/e/derived_inert`)}function be(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function xe(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function Se(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var D=!1;function Ce(e){D=e}var O;function we(e){if(e===null)throw be(),ge;return O=e}function Te(){return we(hn(O))}function k(e){if(D){if(hn(O)!==null)throw be(),ge;O=e}}function Ee(e=1){if(D){for(var t=e,n=O;t--;)n=hn(n);O=n}}function De(e=!0){for(var t=0,n=O;;){if(wn(n)===8){var r=Pn(n)??``;if(r===`]`){if(t===0)return n;--t}else(r===`[`||r===`[!`||r.startsWith(`[?`)||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=hn(n);e&&jn(n),n=i}}function Oe(e){if(!e||wn(e)!==8)throw be(),ge;return Pn(e)??``}function ke(e){return e===this.v}function Ae(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function je(e){return!Ae(e,this.v)}function Me(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function Ne(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function Pe(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Fe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Ie(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Le(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Re(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function ze(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Be(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Ve(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function He(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var Ue=[];function We(e,t=!1,n=!1){return Ge(e,new Map,``,Ue,null,n)}function Ge(t,n,r,i,a=null,o=!1){if(typeof t==`object`&&t){var c=n.get(t);if(c!==void 0)return c;if(t instanceof Map)return new Map(t);if(t instanceof Set)return new Set(t);if(e(t)){var u=Array(t.length);n.set(t,u),a!==null&&n.set(a,u);for(var d=0;d{t===Ke&&qe()})}Ke.push(e)}function Ye(){for(;Ke.length>0;)qe()}var Xe=~(g|_|h);function Ze(e,t){e.f=e.f&Xe|t}function Qe(e){e.f&512||e.edges===null?Ze(e,h):Ze(e,_)}var A=null;function $e(e){A=e}function et(e,t=!1,n){A={p:A,i:!1,c:null,e:null,s:e,x:null,r:W,l:null}}function tt(e){var t=A,n=t.e;if(n!==null){t.e=null;for(var r of n)or(r)}return e!==void 0&&(t.x=e),t.i=!0,A=t.p,nt(e)}function nt(e={}){return i(e,se,{value:!0}),e}function rt(){return!0}var it=null;function at(e,t,n,r){var i=W,a=t.map(rt()?dt:ht),o=e.filter(e=>!e.settled);if(o.length>0){var s=ot(),c=lt();(o.length===1?o[0].promise:Promise.all(o.map(e=>e.promise))).then(()=>{if(!(i.f&16384)){s(o[0].run.get_batch());try{l()}catch(e){$n(e,i)}st()}}).finally(c)}else l();function l(){if(!e.some(e=>e.failed)){if(n.length===0)r(a);else{var t=n.map(e=>pt(e)),o=null;dr(()=>{for(var e of t)if(mt(e)){K(e);return}o===null?o=pr(()=>{try{r([...a,...t])}catch(e){$n(e,i)}}):M.revalidate_branch(o)},S)}}}}function ot(){var e=W,t=U,n=A,r=M;return function(i=r){Lr(e),Ir(t),$e(n),i!==null&&!(e.f&16384)&&ut(i).activate()}}function st(e=!0){Lr(null),Ir(null),$e(null),e&&M?.deactivate()}var ct=null;function lt(){for(var e=W,t=e.b,n=ut(M),r=t;r&&!r.is_pending;)r=r.parent;return n.increment(e),r?.increment(e,n),t?.update_effect_pending(1),()=>{ut(n).decrement(e),r?.decrement(e,n),t?.update_effect_pending(-1)}}function ut(e){for(;e.merged!==null;)e=e.merged;return e}function dt(e){var t=2|g;return W!==null&&(W.f|=C),{ctx:A,deps:null,dv:null,edges:null,effects:null,equals:ke,f:t,fn:e,reactions:null,rv:0,v:E,wv:0,parent:W,ac:null}}var ft=Symbol(`obsolete`);function pt(e,t,n,r){var i=Qt(E);i.f|=ne;var a=new Set,o=ct,s=o&&M,c=o&&[];function l(e=!1){var t=c;c=e?null:[],e&&(s=null);for(let e of t)e()}return lr(()=>{var t=W,n=p();try{var u=e();if(u===E)return;var d=Promise.resolve(u),f=ei?.signal;d.then(e=>{f?.aborted||n.resolve(e)},e=>{f?.aborted||e===he&&o===null||n.reject(e===he?ft:e)}).finally(st)}catch(e){n.reject(e)}var m=M,h=lt();m.async_deriveds.get(t)?.reject(ft),a.add(n),m.async_deriveds.set(t,n);let g=(e,u=void 0)=>{if(c!==null&&u!==ft&&(s??=m,ut(m)!==ut(s)))c.push(()=>{var r=!!(t.f&16384)||(m.linked?m.async_deriveds.get(t)!==n:!ut(m).linked);g(e,r?ft:u)});else{if(h(),a.delete(n),u){if(c!==null&&s!==null&&(a.size>0||u===ft)&&ut(s)===ut(m)&&ut(m).async_deriveds.get(t)===n){s=null,l();return}if(u===ft)return}var d=i.equals(e)&&!u&&!(i.f&8388608);ut(m).capture(i,u??e,d,!!u),o!==null&&(o.switch(m),o.continued.push(()=>l(!0)),o=null),r?.(u),r=void 0}};n.promise.then(g,e=>g(null,e||`unknown`))}),ir(()=>{for(let e of a)e.reject(ft)}),i}function mt(e){return(P?.get(e)??e).v===E}function j(e){let t=dt(e);return zr(t),t}function ht(e){let t=dt(e);return t.equals=je,t}function gt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;nt.#o.has(e))))&&this.revalidate_branch(e),this.#s.add(e)}unskip_new_effect(e){this.#s.add(e)}revalidate_branch(e){for(var t=e.first;t!==null;t=t.next){var n=t.f;!(n&24576)&&!this.#u(t)&&(!(n&131168)&&t.fn!==null&&this.schedule(t,_),this.revalidate_branch(t))}}#d(){var e=[];for(let i of this.#a)if(!(i.f&16384||!(i.f&6144))){for(var t=i,n=!1;t.parent!==null;){t=t.parent;var r=t.f;if(r&96){if(!(r&1024)){n=!0;break}t.f^=h}}n||e.push(t)}return this.#a=[],e}#f(){if(M=wt=this,N?.derived_cache.clear(),this.started=!0,Rt=this.id,this.#i.size>0){for(let[e,t]of this.#i)this.#S(e,t);this.#i.clear()}this.activate();for(var t=Mt=[],n=[],r=[],i=Nt=[];this.#a.length>0;){Pt++>1e3&&(this.#T(),Vt());for(let e of this.#d())try{this.#m(e,t,n,r)}catch(t){throw Yt(e,!0),this.#l()||this.discard(),t}if(this.#a.length>0){for(let e of n)this.#a.push(e);for(let e of t)this.#a.push(e);n.length=0,t.length=0}}if(M=null,i.length>0){var a=e.ensure();for(let e of i)e.f&1024||a.schedule(e,_)}if(Mt=null,Nt=null,this.merge_requests.size>0){let e=Array.from(this.merge_requests,ut).filter(e=>e!==this&&e.linked&&!e.is_fork).sort((e,t)=>e.id-t.id);if(this.merge_requests.clear(),e.length>0){this.#y(n),this.#y(t);for(var o=this,s=e.length;s--;){var c=e[s];c!==o&&(c.#_(o),o=c)}o.#f();return}}if(this.#l()){this.#y(n),this.#y(t);for(let e of this.#o)Yt(e);i.length>0&&M.#f();return}let l=this.#h();if(l)this.#y(n),this.#y(t),l.#_(this),l.#f();else{for(let e of r)e.is_pending&&e.is_ready(this)&&e.reveal(t);this.#C(!0),this.#x(this.#e),Gt(t,Gt(n)),this.#r?.resolve();var u=M;if(this.#n.size===0&&(this.#a.length===0||u!==null)&&this.#T(),u!==null){if(N!==null)for(let[e,t]of N.reverted_values)u.previous.get(e)?.wv!==t.wv&&N.reverted_values.delete(e);u.#f()}}}#p(e){var t=new Set(e),n=new Set;for(let e of t){var r=e.reactions;if(r!==null)for(let e of r){var i=e.f;if(i&2)i&1024&&Ze(e,_),t.add(e);else{var a=e;n.has(a)||(n.add(a),!(i&155648)&&!this.is_skipped(a)&&this.schedule(a,_))}}}}#m(e,t,n,r){e.f^=h;for(var i=e.first;i!==null;){var a=i.f,o=!!(a&96);if(!(o&&a&1024||a&139264||this.#u(i))&&i.fn!==null){o?i.f^=h:a&4?t.push(i):Qr(i)&&Si(i);var s=i.first;if(s!==null){i=s;continue}}for(;i!==null;){if((i.f&16512)==128){var c=i.b;c.is_pending&&c.is_ready(this)&&r.push(c)}var l=i.next;if(l!==null){i=l;break}i=i.parent}}}#h(){for(var e=this.prev;e!==null;e=e.prev)if(!e.is_fork&&this.#g(e))return e;return null}#g(e){for(let t of this.current.keys())if(e.current.has(t))return!0;return!1}#_(e){for(let t of e.merge_requests)this.merge_requests.add(t);e.merge_requests.clear();for(let[t,n]of e.current){if(!this.previous.has(t)){let n=e.previous.get(t);n&&this.previous.set(t,n)}this.current.set(t,n)}for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&e!==n&&n.promise.then(e.resolve,e.reject),this.async_deriveds.set(t,n)}for(let[n,r]of e.records??[])if(!(n.f&16)){var t=this.records?.get(n);(this.records??=new Map).set(n,r),e.records?.delete(n),ni(n,t)}if(e.async_deriveds.clear(),e.#n.size>0){for(let[t,n]of e.#n)this.#n.set(t,(this.#n.get(t)??0)+n);e.#n.clear()}if(e.#i.size>0){for(let[t,n]of e.#i)this.#v(t,n);e.#i.clear()}let n=()=>e.discard();this.oncommit(n),this.ondiscard(n),e.merged=this,e.#T()}#v(e,t){(t===2048||this.#i.get(e)!==2048)&&this.#i.set(e,t)}#y(e){for(var t=0;t0&&!Zt&&tn())}deactivate(){M=wt=P=Ot=F=null}flush(){var e=Et(this.previous);try{if(this.#f(),At.size>0)for(let e of At)At.delete(e),e.linked&&!e.#c&&e.#f()}finally{Pt=0,kt=null,Mt=null,Nt=null,N=e.parent,this.deactivate()}}discard(){this.#x(this.#t);for(let e of this.async_deriveds.values())e.reject(ft);this.#T(),this.#r?.resolve()}#b(){for(let i=St;i!==null;i=i.next)if(i!==this){var e=i.id0&&(i.#p(t),At.add(i))}}this.current.clear(),this.previous.clear()}commit_writes(){this.#b(),this.linked&&this.prev!==null&&this.#w()}increment(e){var t=this.#n.get(e)??0;this.#n.set(e,t+1)}decrement(e){var t=this.#n.get(e)??0;t===1?this.#n.delete(e):this.#n.set(e,t-1),this.#c||(this.#c=!0,Je(()=>{this.#c=!1,this.linked&&this.flush()}))}oncommit(e){this.#e.set(e,Ut?.size?Ut:null)}ondiscard(e){this.#t.set(e,Ut?.size?Ut:null)}#x(e){Oi(()=>{for(let[n,r]of e)if(r===null)n(this);else{var t=Et();for(let[e,n]of r)t.reverted_values.has(e)&&t.reverted_values.set(e,n);try{n(this)}finally{N=t.parent}}}),e.clear()}settled(){return(this.#r??=p()).promise}static ensure(){if(M===null){let t=M=new e;wt===null&&!jt&&Je(()=>{t.started||t.flush()})}return M}activate(){M=this,F=this,Rt!==this.id&&(Rt=null),P=Ot=null}get_record(e){for(var t=this.records?.get(e),n=this.folded.length;t===void 0&&n--;)t=this.folded[n].records?.get(e);return t}mark(e,t,n=null){var r=e.reactions;if(r!==null){var i=rt(),a=r.length;if(It+=a,It>1e5&&Ft===null&&(Ft=new Set),Ft!==null){if(Ft.has(e))return;Ft.add(e)}for(var o=0;o0){var o=N;t!==null&&Et(t);var s=Ut;Ut=new Map(t);try{for(let e of Ht){if(e.f&24576||M?.is_skipped(e))continue;let t=[e],n=e.parent;for(;n!==null;)Ht.has(n)&&(Ht.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||M?.is_skipped(n)||Si(n)}}}finally{Ut=s,Ht?.clear(),N=o}}if(Ur!==a&&M!==null)for(let[e,n]of M.current)n.wv>a&&(t??=new Map).set(e,n)}}return Ht=null,t}function Kt(e,t){for(var n=e.next;n!==null&&(n.is_fork||!n.current.has(t));)n=n.next;return n}function qt(e,t){e.v=t.v,e.wv=t.wv,e.f=t.e?e.f|re:e.f&~re,e.f&2&&(e.f|=ae,Qe(e))}function Jt(e){var t=P,n=Ot,r=F;P=Ot=F=null;try{e()}finally{P=t,Ot=n,F=r}}function Yt(e,t=!1){if(!(!t&&e.f&32&&e.f&1024)){Ze(e,h);for(var n=e.first;n!==null;)Yt(n,t),n=n.next}}var Xt=new Set,Zt=!1;function Qt(e,t){return{f:0,v:e,reactions:null,equals:ke,rv:0,wv:0}}function I(e,t){let n=Qt(e,t);return zr(n),n}function $t(e,t=!1,n=!0){let r=Qt(e);return t||(r.equals=je),r}function L(e,t,n=!1){return U!==null&&(!Fr||U.f&131072)&&rt()&&U.f&4325394&&(Rr===null||!Rr.has(e))&&Ve(),en(e,n?an(t):t,Nt)}function en(e,t,n=null){var r=e.equals(t)&&!(e.f&8388608),i=P?.get(e);if(!r||i!==void 0&&(i.e||!e.equals.call(i,t))){var a=zt.ensure();(e.f&67110914)==2050&&_t(e),a.capture(e,t,r,!1,n),rt()&&W!==null&&W.f&1024&&!(W.f&96)&&(Vr===null?Hr([e]):Vr.push(e))}else jr&&Dt(e);return t}function tn(){Zt=!1,Jt(nn)}function nn(){for(let e of Xt){e.f&1024&&Ze(e,_);let t;try{t=Qr(e)}catch{t=!0}t&&Si(e)}Xt.clear()}function rn(e){L(e,e.v+1)}function an(t){if(typeof t!=`object`||!t||oe in t||se in t)return t;let n=l(t);if(n!==s&&n!==c)return t;var r=new Map,i=e(t),o=I(0),u=null,d=Gr,f=e=>{if(Gr===d)return e();var t=U,n=Gr;Ir(null),Kr(d);var r=e();return Ir(t),Kr(n),r};return i&&r.set(`length`,I(t.length,u)),new Proxy(t,{defineProperty(e,t,n){`value`in n&&n.configurable!==!1&&n.enumerable!==!1&&n.writable!==!1||ze();var i=r.get(t);return i===void 0?f(()=>{var e=I(n.value,u);return r.set(t,e),e}):L(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>I(E,u));r.set(t,e),rn(o)}}else L(n,E),rn(o);return!0},get(e,n,i){if(n===oe)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>I(an(s?e[n]:E),u)),r.set(n,o)),o!==void 0){var c=K(o);return c===E?void 0:c}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){this.has?.(e,t);var n=Reflect.getOwnPropertyDescriptor(e,t),i=r.get(t);if(i!==void 0){var a=K(i);if(a===E)return;if(n&&`value`in n)n.value=a;else return{enumerable:!0,configurable:!0,value:a,writable:!0}}return n},has(e,t){if(t===oe)return!0;var n=r.get(t),i=n!==void 0&&n.v!==E||Reflect.has(e,t);return(n!==void 0||(W!==null||U!==null)&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>I(i?an(e[t]):E,u)),r.set(t,n)),K(n)===E)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dI(E,u)),r.set(d+``,p)):L(p,E)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>I(void 0,u)),L(c,an(n)),r.set(t,c));else{l=c.v!==E;var m=f(()=>an(n));L(c,m)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(s,n),!l){if(i&&typeof t==`string`){var g=r.get(`length`),_=Number(t);Number.isInteger(_)&&_>=g.v&&L(g,_+1)}rn(o)}return!0},ownKeys(e){K(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==E});for(var[n,i]of r)i.v!==E&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Be()}})}function on(e){try{if(typeof e==`object`&&e&&oe in e)return e[oe]}catch{}return e}function sn(e,t){return Object.is(on(e),on(t))}var cn,ln,un,dn;function fn(){if(cn===void 0){cn=window,ln=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;un=a(t,`firstChild`).get,dn=a(t,`nextSibling`).get,u(e)&&(e[de]=void 0,e[ue]=null,e[fe]=void 0,e.__e=void 0),u(n)&&(n[pe]=void 0)}}function pn(e=``){return document.createTextNode(e)}function mn(e){return un.call(e)}function hn(e){return dn.call(e)}function R(e,t){if(!D)return mn(e);var n=mn(O);if(n===null)n=On(O,pn());else if(t&&wn(n)!==3){var r=pn();return kn(n,r),we(r),r}return t&&Sn(n),we(n),n}function z(e,t=!1){if(!D){var n=mn(e);return Cn(n)&&Pn(n)===``?hn(n):n}if(t){if(wn(O)!==3){var r=pn();return O&&kn(O,r),we(r),r}Sn(O)}return O}function B(e,t=!1){if(!D)return mn(e);var n=R(e,t);return k(e),n}function V(e,t=1,n=!1){let r=D?O:e;for(var i;t--;)i=r,r=hn(r);if(!D)return r;if(n){if(wn(r)!==3){var a=pn();return r===null?i&&An(i,a):kn(r,a),we(a),a}Sn(r)}return we(r),r}function gn(e){e.textContent=``}function _n(){return Ut!==null&&(W.f&b)!==0}function vn(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function yn(){return document.createDocumentFragment()}function bn(e=``){return document.createComment(e)}function xn(e,t,n=``){if(t.startsWith(`xlink:`))e.setAttributeNS(`http://www.w3.org/1999/xlink`,t,n);else return e.setAttribute(t,n)}function Sn(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&wn(t)===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function Cn(e){return e instanceof Comment}function wn(e){if(e!=null)return e.nodeType}function Tn(e){return e.nodeName}function En(e){return e.lastChild}function Dn(e){return e.parentNode}function On(e,t){return e.appendChild(t)}function kn(e,t){e.before(t)}function An(e,t){e.after(t)}function jn(e){e.remove()}function Mn(e,t){return e.removeChild(t)}function Nn(e,t){e.nodeValue=t}function Pn(e){return e.nodeValue}function Fn(e,t){e.value=t??``}function In(e,t){e.checked=t}function Ln(e,t){let n=e.value;e.defaultValue=t,e.value=n}function Rn(e,t){let n=e.checked;e.defaultChecked=t,e.checked=n}function zn(e,t){return e.getAttribute(t)}function Bn(e,t){e.removeAttribute(t)}function Vn(e,t){return e.hasAttribute(t)}function Hn(e,t){e.innerHTML=t}function Un(e,t){return e.cloneNode(t)}function Wn(e,t){return document.importNode(e,t)}function Gn(e,t,n,r){e.addEventListener(t,n,r)}function Kn(e,t,n,r){e.removeEventListener(t,n,r)}function qn(e,t){return e.dispatchEvent(t)}function Jn(e,t,n,r){e.style.setProperty(t,n,r)}function Yn(e,t){e.style.removeProperty(t)}function Xn(e,t){e.style.cssText=t}function Zn(e,t,n){e.classList.toggle(t,n)}function Qn(e){var t=W;if(t===null)return e;if(!(t.f&32768)&&!(t.f&4))throw e;$n(e,t)}function $n(e,t){if(e===ge)throw e;if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128&&!(t.f&33570816)){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}function er(e){W===null&&(U===null&&Ie(e),Fe()),jr&&Pe(e)}function tr(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function nr(e,t){var n=W;n!==null&&n.f&8192&&(e|=v);var r={ctx:A,deps:null,dv:null,edges:null,nodes:null,f:e|g|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null,r:it},i=r;if(e&4)Mt===null?zt.ensure().schedule(r,g):Mt.push(r);else if(t!==null){try{Si(r)}catch(e){throw _r(r),e}i.edges===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=S))}if(i!==null&&(i.parent=n,n!==null&&tr(i,n),U!==null&&U.f&2&&!(e&64))){var a=U;(a.effects??=[]).push(i)}return r}function rr(){return U!==null&&!Fr}function ir(e){let t=nr(8,null);return Ze(t,h),t.teardown=e,t}function ar(e){er(`$effect`);var t=W.f;if(!U&&t&32&&A!==null&&!A.i){var n=A;(n.e??=[]).push(e)}else return or(e)}function or(e){return nr(4|w,e)}function sr(e){zt.ensure();let t=nr(64|C,e);return(e={})=>new Promise(n=>{e.outro?br(t,()=>{_r(t),n(void 0)}):(_r(t),n(void 0))})}function cr(e){return nr(4,e)}function lr(e){return nr(ne|C,e)}function ur(e,t=0){return nr(8|t,e)}function H(e,t=[],n=[],r=[]){at(r,t,n,t=>{nr(8,()=>{e(...t.map(K))})})}function dr(e,t=0){return nr(16|t,e)}function fr(e,t=0){return nr(m|t,e)}function pr(e){return nr(32|C,e)}function mr(e){var t=e.teardown;if(t!==null){let n=jr,r=Mr,i=N,a=U;Nr(!0),Ir(null);try{t.call(null)}catch(t){$n(t,e.parent)}finally{Nr(n,r),Tt(i),Ir(a)}}}function hr(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){si(n);var r=n.next;n.f&64?n.parent=null:_r(n,t),n=r}}function gr(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||_r(t),t=n}}function _r(e,t=!0){var n=!1;try{(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(vr(e.nodes.start,e.nodes.end),n=!0),e.f|=x,hr(e,t&&!n),xi(e);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();mr(e)}finally{}e.f^=x,e.f|=y;var i=e.parent;i!==null&&i.first!==null&&yr(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.dv=e.edges=e.fn=e.nodes=e.ac=e.b=e.r=null}function vr(e,t){for(;e!==null;){var n=e===t?null:hn(e);jn(e),e=n}}function yr(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function br(e,t,n=!0){var r=[];e.f|=256,xr(e,r,!0);var i=()=>{n&&_r(e),t&&t()},a=r.length;if(a>0){var o=N,s=()=>{if(!--a){var e=N;try{o&&(o.derived_cache.clear(),Tt(o)),i()}finally{o&&Tt(e)}}};for(var c of r)c.out(s)}else i()}function xr(e,t,n){if(!(e.f&8192)){e.f^=v;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=!!(i.f&65536)||!!(i.f&32)&&!!(e.f&16);xr(i,t,o?n:!1)}i=a}}}function Sr(e){e.f&=-257,Cr(e,!0)}function Cr(e,t){if(!(e.f&256)&&e.f&8192){e.f^=v,e.f&1024||zt.ensure().schedule(e,_);for(var n=e.first;n!==null;){var r=n.next,i=!!(n.f&65536)||!!(n.f&32);Cr(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function wr(e,t){if(e.nodes)try{for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:hn(n);On(t,n),n=i}}finally{}}var Tr=null;function Er(e,t){if(t){let t=document.body;e.autofocus=!0,Je(()=>{document.activeElement===t&&e.focus()})}}var Dr=!1;function Or(){Dr||(Dr=!0,Gn(document,`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[me]?.()})},{capture:!0}))}function kr(e){var t=U,n=W;Ir(null),Lr(null);try{return e()}finally{Ir(t),Lr(n)}}function Ar(e,t,n,r=n){e.addEventListener(t,()=>kr(n));let i=e[me];e[me]=i?()=>{i(),r(!0)}:()=>r(!0),Or()}var jr=!1,Mr=0;function Nr(e,t=Ur){jr=e,Mr=t}var Pr={v:void 0,wv:0,e:!1,assigned:!1},U=null,Fr=!1;function Ir(e){U=e}var W=null;function Lr(e){W=e}var Rr=null;function zr(e){U!==null&&(U.f&2097152||U.f&2)&&(Rr??=new Set).add(e)}var G=null,Br=0,Vr=null;function Hr(e){Vr=e}var Ur=1,Wr=0,Gr=Wr;function Kr(e){Gr=e}function qr(){return++Ur}function Jr(e){return P===null?(vt(e),e.wv):e.f&2?yt(e).wv:(P.get(e)??e).wv}function Yr(e,t){if(e!==null){for(var n=0;nt){if(a===i?i.f&67108864:!(`dv`in a))return!0;if(n===null)n=new Set;else if(n.has(a))continue;if(Xr(a.deps,t,n))return!0;n.add(a)}}else if(Jr(i)>t)return!0}return!1}function Zr(e){return!!(e.f&4194320)&&F?.get_record(e)||e}function Qr(e){var t=e.f;if(!(t&6144))return!1;if(t&67108864){if(Xr(e.deps,e.wv))return!0}else if(t&2048)return!0;else{var n=Zr(e),r=n.deps,i=n.dv;if(i===null)return!0;if(P===null)for(var a=0,o=i.length;ae.abort(he))}function ni(e,t,n=!1){if(t?.ac){for(var r=St;r!==null;r=r.next)if(r.records?.get(e)===t&&(!n||r!==F&&!oi(M,r)))return;ti(t.ac),t.ac=null}}function ri(e,t){var n=M,r=!!(t&2);if(!(r&&jr)){var i=n===null||!n.is_fork;ni(e,F?.records?.get(e),!0),(r?P===null||i&&ai(e):i)&&ti(e.ac);for(var a=St;a!==null;a=a.next)oi(n,a)&&ni(e,a.records?.get(e),!0)}}function ii(e){ti(e.ac),e.ac=ei}function ai({deps:e,dv:t}){return t===null||t.some((t,n)=>e[n].wv!==t)}function oi(e,t){return e!==null&&!e.is_fork&&!t.is_fork&&t.id0)&&!(e.f&6146))for(var m=0;m{if(M!==null){let e=ut(t);e!==M&&e.linked&&!e.is_fork&&M.merge_requests.add(e)}}),e.f^=te,G=n,Br=r,Vr=i,U=a,Rr=o,$e(s),Fr=c,Gr=l,ei=d}}function ui(e,t,n,r){var i=e.deps,a=Br+(G===null?0:G.length),o=e.dv;if(e.f&16384)ti(ei);else if(ei!==null&&!(e.f&134217728)&&(ti(ei),ei=null),t&2&&jr){for(var s=0,c=0;cMr?void 0:N?.reverted_values.get(e);if(!(e.f&2))return t;var n=e,r=(N??Et()).derived_cache,i=r.get(n);if(i!==void 0)return i;var a=t??P?.get(n),o=a===void 0?(n.f&ae)!==0:a.assigned,s=a===void 0&&!o?n.dv:null,c=n.deps??[],l=o||s!==null,u=s?.length??c.length;a??={v:n.v,wv:n.wv,e:(n.f&re)!==0,assigned:(n.f&ae)!==0};for(var d=0;l&&d{e.isConnected&&qn(e,t)}))}function Hi(e,t,n,r={}){var i=it!=null;function a(...e){if(i)return kr(()=>n?.apply(this,e));var a=e[0];if(r.capture||Yi.call(t,a),r.capture||a[Ri]!==t)return kr(()=>n?.call(this,a))}return!i&&(e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`)?(a.__removed=!1,Je(()=>{a.__removed||Gn(t,e,a,r)})):Gn(t,e,a,r),a}function Ui(e,t,n,r,i){var a={capture:r,passive:i},o=Hi(e,t,n,a);it==null&&(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&ir(()=>{o.__removed=!0,Kn(t,e,o,a)})}function q(e,t,n){(t[Li]??={})[e]=n}function Wi(e){for(var t=0;t{for(var r=0;r{for(var r of t)for(let t of[e,document]){var i=Gi.get(t),a=i.get(r);--a==0?(t.removeEventListener(r,Yi),i.delete(r),i.size===0&&Gi.delete(t)):i.set(r,a)}Bi.delete(n)}}var qi=null,Ji=!1;function Yi(e){var t=this,n=e.cancelBubble;if(!(n&&e[Ri]===t)){n||delete e[Ri];var r=t.ownerDocument,a=e.type,o=e.composedPath?.()||[],s=o[0]||e.target;qi=e,Ji||(Ji=!0,setTimeout(()=>{Ji=!1,qi=null}));var c=0,l=qi===e&&e[Li];if(l){var u=o.indexOf(l);if(u!==-1&&(t===document||t===window)){e[Li]=t;return}var d=o.indexOf(t);if(d===-1)return;u<=d&&(c=u)}if(s=o[c]||e.target,s!==t){i(e,`currentTarget`,{configurable:!0,get(){return s||r}});var f=U,p=W;Ir(null),Lr(null);try{for(var m,h=[];s!==null&&s!==t;){try{var g=s[Li]?.[a];g==null||s.disabled&&e.target!==s||g.call(s,e)}catch(e){m?h.push(e):m=e}if(e.cancelBubble){n||(e[Ri]=t);break}c++,s=c{throw e});throw m}}finally{e[Li]=t,delete e.currentTarget,Ir(f),Lr(p)}}}}var Xi=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Zi(e){return Xi?.createHTML(e)??e}function Qi(e){var t=vn(`template`);return Hn(t,Zi(e.replaceAll(``,``))),t.content}function $i(e,t){var n=W;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function J(e,t){var n=!!(t&1),r=!!(t&2),i,a=!e.startsWith(``);return()=>{if(D)return $i(O,null),O;i===void 0&&(i=Qi(a?e:``+e),n||(i=mn(i)));var t=r||ln?Wn(i,!0):Un(i,!0);return n?$i(mn(t),En(t)):$i(t,t),t}}function ea(e=``){if(!D){var t=pn(e+``);return $i(t,t),t}var n=O;return wn(n)===3?Sn(n):(kn(n,n=pn()),we(n)),$i(n,n),n}function ta(){if(D)return $i(O,null),O;var e=yn(),t=bn(``),n=pn();return On(e,t),On(e,n),$i(t,n),e}function Y(e,t){if(D){var n=W;n.f&32768&&n.nodes.end!==null||(n.nodes.end=O),Te()}else e!==null&&kn(e,t)}function na(e){let t=0,n=Qt(0),r;return()=>{rr()&&(K(n),ur(()=>(t===0&&(r=Oi(()=>e(()=>rn(n)))),t+=1,()=>{Je(()=>{--t,t===0&&(r?.(),r=void 0,rn(n))})})))}}var ra=S|C;function ia(e,t,n,r){new aa(e,t,n,r)}var aa=class{parent;is_pending=!1;transform_error;#e;#t=D?O:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=!1;#d=[];#f=new Map;#p=null;#m=na(()=>(this.#p=Qt(this.#l),()=>{this.#p=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=W;t.b=this,t.f|=128,n(e)},this.parent=W.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=dr(()=>{if(D){let e=Oe(this.#t);Te();let t=e===`[!`;if(e.startsWith(`[?`)){let t=JSON.parse(e.slice(2));this.#g(t)}else t?this.#y():this.#h()}else this.#b()},ra),D&&(this.#e=O)}#h(){try{this.#a=pr(()=>this.#r(this.#e))}catch(e){this.error(e)}}#g(e){let t=this.#n.failed,{reset:n,invoke_onerror:r}=this.#_(e);Je(r),t&&(this.#s=pr(()=>{t(this.#e,()=>e,()=>n)}))}#_(e){var t=!1,n=!1;let r=()=>{this.#v()||(t?Se():(t=!0,n&&He(),this.#s!==null&&br(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#b()})))};return{reset:r,invoke_onerror:()=>{if(!this.#v())try{n=!0,this.#n.onerror?.(e,r),n=!1}catch(e){$n(e,this.#i&&this.#i.parent)}}}}#v(){return(this.#i.f&(y|x))!==0}#y(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=pr(()=>e(this.#e)),Je(()=>{if(!this.#v())try{var e=this.#c=yn(),t=pn();On(e,t),this.#a=this.#x(()=>{try{return pr(()=>this.#r(t))}catch(e){try{this.error(e)}catch(e){$n(e,this.#i.parent)}return null}}),this.#a!==null&&this.#f.size===0&&(this.is_pending=!1,kn(this.#e,e),this.#c=null,br(this.#o,()=>{this.#o=null}))}finally{}}))}#b(){try{if(this.is_pending=this.has_pending_snippet(),this.#l=0,this.#a=pr(()=>{this.#r(this.#e)}),this.#f.size===0)this.is_pending=!1;else{let t=this.#n.pending;if(t){var e=this.#c=yn();wr(this.#a,e),this.#o=pr(()=>t(this.#e))}}}catch(e){this.error(e)}}defer_effect(e){this.#d.push(e)}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=W,n=U,r=A;Lr(this.#i),Ir(this.#i),$e(this.#i.ctx);try{return zt.ensure(),e()}finally{Lr(t),Ir(n),$e(r)}}is_ready(e){if(e.is_fork&&this.#f.size>0)return!1;for(let[t,n]of this.#f)if(!t.is_fork){for(let t of n.keys())if(e.is_blocked_by(t,this.#a))return!1}return!0}reveal(e){this.is_pending=!1;for(let t of this.#d)Ze(t,g),e.push(t);if(this.#d.length=0,this.#o&&br(this.#o,()=>{this.#o=null}),this.#c)try{kn(this.#e,this.#c),this.#c=null}finally{}}increment(e,t){var n=this.#f.get(t);n===void 0&&this.#f.set(t,n=new Map);var r=n.get(e)??0;n.set(e,r+1)}decrement(e,t){var n=this.#f.get(t),r=n.get(e);r===1?(n.delete(e),n.size===0&&this.#f.delete(t),Je(()=>{this.is_pending&&!this.#v()&&zt.ensure().schedule(this.#i,_)})):n.set(e,r-1)}update_effect_pending(e){this.#l+=e,!this.#p||this.#u||(this.#u=!0,Je(()=>{this.#u=!1,this.#p&&en(this.#p,this.#l)}))}get_effect_pending(){return this.#m(),K(this.#p)}error(e){if(e===ge||!this.#n.onerror&&!this.#n.failed)throw e;M?.is_fork?(this.#a&&M.skip_effect(this.#a),this.#o&&M.skip_effect(this.#o),this.#s&&M.skip_effect(this.#s),M.oncommit(()=>{this.#v()||this.#S(e)})):this.#S(e)}#S(e){this.#a&&=(_r(this.#a),null),this.#o&&=(_r(this.#o),null),this.#s&&=(_r(this.#s),null),D&&(we(this.#t),Ee(),we(De()));let t=this.#n.failed,n=e=>{if(this.#v())return;let{reset:n,invoke_onerror:r}=this.#_(e);r(),t&&!this.#v()&&(this.#s=this.#x(()=>{try{return pr(()=>{var r=W;r.b=this,r.f|=128,t(this.#e,()=>e,()=>n)})}catch(e){return $n(e,this.#i.parent),null}}))};Je(()=>{if(!this.#v()){var t;try{t=this.transform_error(e)}catch(e){$n(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(n,e=>$n(e,this.#i&&this.#i.parent)):n(t)}})}};function X(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[pe]??=Pn(e))&&(e[pe]=n,Nn(e,`${n}`))}function oa(e,t){return sa(e,t)}function sa(e,t){return ca(e,t)}function ca(e,{target:t,anchor:n,props:r={},events:i,context:a,intro:o=!0,transformError:s,renderer:c}){var l=void 0,u=sr(()=>{var o=n??On(t,pn());ia(o,{pending:()=>{}},t=>{et({});var n=A;if(a&&(n.c=a),i&&(r.$$events=i),D&&$i(t,null),l=e(t,r)||nt(),D&&(W.nodes.end=O,O===null||wn(O)!==8||Pn(O)!==`]`))throw be(),ge;tt()},s);var u=c?null:Ki(t);return()=>{if(u?.(),o!==n){var e=Dn(o);e&&Mn(e,o)}}});return la.set(l,u),l}var la=new WeakMap,ua=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;#a=null;constructor(e,t=!0){this.anchor=e,this.#i=t,this.#a=it}#o=e=>{if(this.#e.has(e))try{var t=this.#e.get(e),n=this.#t.get(t);if(n)Sr(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Sr(r.effect),this.#t.set(t,r.effect),this.#n.delete(t),jn(En(r.fragment)),kn(this.anchor,r.fragment),n=r.effect,n.f&=~ee)}this.#s(e);for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=yn();wr(r,t),On(t,pn()),this.#n.set(e,{effect:r,fragment:t})}else _r(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),br(r,i,!1)):i()}}finally{}};#s=e=>{for(let t of this.#e.keys())t!==e&&t.linked||this.#e.delete(t);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(_r(n.effect),this.#n.delete(e))};ensure(e,t){var n=M,r=_n();if(t&&!this.#t.has(e)&&!this.#n.has(e)){if(r){var i=yn(),a=pn();On(i,a);var o=pr(()=>t(a));o.f|=ee,n.unskip_new_effect(o),this.#n.set(e,{effect:o,fragment:i})}else this.#t.set(e,pr(()=>t(this.anchor)))}if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#o),n.ondiscard(this.#s)}else D&&(this.anchor=O),this.#o(n)}};function Z(e,t,n=!1){var r;D&&(r=O,Te());var i=new ua(e),a=n?S:0;function o(e,t){if(D){var n=Oe(r);if(e!==parseInt(n.substring(1))){var a=De();we(a),i.anchor=a,Ce(!1),i.ensure(e,t),Ce(!0);return}}i.ensure(e,t)}dr(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}function da(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t=0;){var s=o+a;(o===0||ma.includes(r[o-1]))&&(s===r.length||ma.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function ga(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function _a(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function va(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\/\*.*?\*\//g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(_a)),i&&c.push(...Object.keys(i).map(_a));var l=0,u=-1;let t=e.length;for(var d=0;d{if(o){if(o.pending.delete(n),o.done.add(n),o.pending.size===0){var t=e.outrogroups;Sa(e,r(o.done)),t.delete(o),t.size===0&&(e.outrogroups=null)}}else--s},!1)}if(s===0){var l=i.length===0&&n!==null&&e.pending.size===0;if(l){var u=n,d=Dn(u);gn(d),On(d,u),e.items.clear()}Sa(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function xa(e){var t=new Set;for(let n of e.pending.values())for(let r of n)t.add(e.items.get(r).e);return t}function Sa(e,t,n=!0){for(var r=e.pending.size>0?xa(e):void 0,i=0;i{var t=i();return e(t)?t:t==null?[]:r(t)}),p=new Map,m=!0;function h(e){if(!(v.effect.f&16384)){try{v.pending.delete(e);var t=K(f);v.fallback=d,ka(v,t,c,n,a),d!==null&&(t.length===0?d.f&33554432?(d.f^=ee,ja(d,null,c)):Sr(d):br(d,()=>{d=null}))}finally{}_()}}function g(e){v.pending.delete(e),v.effect.f&16384||_()}function _(){for(var e,t=v.effect.last;t!==null;){var n=t.prev;if(t.f&32&&t!==d){if(!(t.f&33554432))break;e??=xa(v),!e.has(t)&&!Ca(v,t)&&_r(t)}t=n}}var v={effect:dr(()=>{var e=K(f),t=e.length;let r=!1;D&&Oe(c)===`[!`!=(t===0)&&(c=De(),we(c),Ce(!1),r=!0);for(var u=new Set,_=M,v=_n(),y=0;ys(c)):(d=pr(()=>s(Ea())),d.f|=ee,v&&_.unskip_new_effect(d))),v&&d!==null&&(t===0?_.unskip_effect(d):_.skip_effect(d)),t>u.size&&Ne(``,``,``),D&&t>0&&we(De()),!m){if(p.set(_,u),v){for(let[e,t]of l)u.has(e)||_.skip_effect(t.e);_.oncommit(h),_.ondiscard(g)}else h(_)}r&&Ce(!0),K(f)}),flags:n,items:l,pending:p,outrogroups:null,fallback:d};m=!1,D&&(c=O)}function Oa(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function ka(e,t,n,i,a){var o=!!(i&8),s=t.length,c=e.items,l=Oa(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v0){var ne=i&4&&s===0?n:null;if(o){for(v=0;v{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function Aa(e,t,n,r,i,a,o,s){var c=o&1?o&16?Qt(n):$t(n,!1,!1):null,l=o&2?Qt(i):null;return{v:c,i:l,e:pr(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function ja(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=hn(r);if(kn(a,r),r===i)return;r=o}}function Ma(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function Na(e,t,n=!1,r=!1,i=!1,a=!1,o){var s=e,c=``;if(n){var l=e;D&&(s=we(mn(l)))}H(()=>{var e=W;if(c===(c=t()??``))D&&Te();else if(n&&!D)e.nodes=null,Hn(l,c),c!==``&&$i(mn(l),En(l));else if(e.nodes!==null&&(vr(e.nodes.start,e.nodes.end),e.nodes=null),c!==``){if(D){for(var a=Pn(O),o=Te(),u=o;o!==null&&(wn(o)!==8||Pn(o)!==``);)u=o,o=hn(o);if(o===null)throw be(),ge;$i(O,u),s=we(o)}else{var d=vn(r?`svg`:i?`math`:`template`,r?_e:i?ve:void 0);Hn(d,c);var f=r||i?d:d.content;if($i(mn(f),En(f)),r||i)for(;mn(f);)kn(s,mn(f));else kn(s,f)}}})}function Pa(e,t,...n){var r=new ua(e);dr(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},S)}function Fa(e,t){var n=void 0,r;fr(()=>{n!==(n=t())&&(r&&=(_r(r),null),n&&(r=pr(()=>{cr(()=>n(e))})))})}function Ia(e,t,n,r,i,a){var o=e[de];if(D||o!==n||o===void 0){var s=ha(n,r,a);D&&s===zn(e,`class`)||(s==null?Bn(e,`class`):t?e.className=s:xn(e,`class`,s)),e[de]=n}else if(a&&i!==a)for(var c in a){var l=!!a[c];(i==null||l!==!!i[c])&&Zn(e,c,l)}return a}function La(e,t={},n,r){for(var i in n){var a=n[i];t[i]!==a&&(n[i]==null?Yn(e,i):Jn(e,i,a,r))}}function Ra(e,t,n,r){var i=e[fe];if(D||i!==t){var a=va(t,r);D&&a===zn(e,`style`)||(a==null?Bn(e,`style`):Xn(e,a)),e[fe]=t}else r&&(Array.isArray(r)?(La(e,n?.[0],r[0]),La(e,n?.[1],r[1],`important`)):La(e,n,r));return r}function za(e,t){t?Vn(e,`selected`)||xn(e,`selected`,``):Bn(e,`selected`)}function Ba(e,t){var n=!(`__defaultValue`in e);(n||e.__defaultValue!==t)&&(e.__defaultValue=t,Va(e,!n||`__value`in e))}function Va(t,n){var r=t.__defaultValue,i=t.multiple,a=i?r??[]:null;if(!i||e(a)){var o=t.selectedIndex,s=n&&i?new Set(t.selectedOptions):null;for(var c of t.options){var l=Wa(c);za(c,i?a.includes(l):sn(l,r))}if(n){if(s!==null)for(c of t.options){var u=s.has(c);c.selected!==u&&(c.selected=u)}else t.selectedIndex!==o&&(t.selectedIndex=o)}}}function Ha(t,n,r=!1){if(t.multiple){if(n==null)return;if(!e(n))return xe();for(var i of t.options)i.selected=n.includes(Wa(i))}else{for(i of t.options)if(sn(Wa(i),n)){i.selected=!0;return}r&&n===void 0||(t.selectedIndex=-1)}}function Ua(e){var t=new MutationObserver(t=>{t.every(Ga)||(`__defaultValue`in e&&Va(e,!1),`__value`in e&&Ha(e,e.__value))});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),ir(()=>{t.disconnect()})}function Wa(e){return`__value`in e?e.__value:e.value}function Ga(e){if(e.target.closest(`selectedcontent`)!==null)return!0;if(e.type===`childList`){var t=[...e.addedNodes,...e.removedNodes];return t.length>0&&t.every(e=>e.nodeName===`SELECTEDCONTENT`)}return!1}var Ka=Symbol(`class`),qa=Symbol(`style`),Ja=Symbol(`is custom element`),Ya=Symbol(`is html`),Xa=T?`link`:`LINK`,Za=T?`input`:`INPUT`,Qa=T?`option`:`OPTION`,$a=T?`select`:`SELECT`,eo=T?`progress`:`PROGRESS`;function to(e){if(D){var t=!1,n=()=>{if(!t){if(t=!0,Vn(e,`value`)){var n=e.value;Q(e,`value`,null),e.value=n}if(Vn(e,`checked`)){var r=e.checked;Q(e,`checked`,null),e.checked=r}}};e[me]=n,Je(n),Or()}}function Q(e,t,n,r){var i=io(e);if(!(D&&(i[t]=zn(e,t),t===`src`||t===`srcset`||t===`href`&&Tn(e)===Xa))){var a=i[t];a!==(i[t]=n)&&(t===`loading`&&(e[le]=n),n==null?Bn(e,t):typeof n!=`string`&&oo(e).has(t)?e[t]=n:(!D||typeof n!=`number`&&typeof n!=`boolean`||a!==String(n))&&xn(e,t,n))}}function no(e,t,n,r,i=!1,a=!1){D&&i&&Tn(e)===Za&&(`defaultValue`in n||`defaultChecked`in n||to(e));var o=io(e),s=o[Ja],c=!o[Ya];let l=D&&s;l&&Ce(!1);var u=t||{},d=Tn(e)===Qa,f=Tn(e)===$a;try{for(var p in t)!(p in n)&&p[0]+p[1]!==`$$`&&(n[p]=null);n.class?n.class=pa(n.class):(r||n[Ka])&&(n.class=null),n[qa]&&(n.style??=null);var m=oo(e);if(it==null&&Tn(e)===Za&&`type`in n&&(`value`in n||`__value`in n)){var h=n.type;(h!==u.type||h===void 0&&e.hasAttribute(`type`))&&(u.type=h,Q(e,`type`,h,a))}for(let i in n){let l=n[i];if(d&&i===`value`&&l==null)e.value=e.__value=``,u[i]=l;else if(i===`class`)Ia(e,it==null&&e.namespaceURI===`http://www.w3.org/1999/xhtml`,l,r,t?.[Ka],n[Ka]),u[i]=l,u[Ka]=n[Ka];else if(i===`style`)Ra(e,l,t?.[qa],n[qa]),u[i]=l,u[qa]=n[qa];else{var g=u[i];if(l!==g||l===void 0&&Vn(e,i)){u[i]=l;var _=i[0]+i[1];if(_!==`$$`){if(_===`on`){let t={},n=`$$`+i,r=i.slice(2);var v=it==null&&ji(r);if(ki(r)&&(r=r.slice(0,-7),t.capture=!0),!v&&g){if(l!=null)continue;Kn(e,r,u[n],t),u[n]=null}if(v)q(r,e,l),Wi([r]);else if(l!=null){function a(...e){u[i].apply(this,e)}u[n]=Hi(r,e,a,t)}}else if(i===`style`)Q(e,i,l);else if(i===`autofocus`)it==null?Er(e,!!l):l?xn(e,i,l):Bn(e,i);else if(!s&&(i===`__value`||i===`value`&&l!=null))e.__value=l,(g==null||e.value!==l||l===0&&e.nodeName===eo)&&Fn(e,l);else if(i===`selected`&&d)za(e,l);else{var y=i;c||(y=Pi(y));var b=y===`defaultValue`||y===`defaultChecked`;if(f&&y===`defaultValue`)continue;if(l==null&&!s&&!b){if(o[i]=null,(y===`value`||y===`checked`)&&it==null){let n=e,r=t===void 0;if(y===`value`){let e=n.defaultValue;Bn(n,y),Ln(n,e),Fn(n,n.__value=r?e:null)}else{let e=n.defaultChecked;Bn(n,y),Rn(n,e),In(n,r?e:!1)}}else Bn(e,i),y===`value`&&(e.__value=null)}else b&&it!=null?(y===`defaultValue`?Ln(e,l):Rn(e,l),y in o&&(o[y]=E)):b||(s||typeof l!=`string`)&&m.has(y)?(e[y]=l,y in o&&(o[y]=E)):typeof l!=`function`&&Q(e,y,l,a)}}}}}}finally{l&&Ce(!0)}return u}function ro(e,t,n=[],r=[],i=[],a,o=!1,s=!1){at(i,n,r,n=>{var r=void 0,i={},c=Tn(e)===$a,l=!1;if(fr(()=>{var u=t(...n.map(K)),d=no(e,r,u,a,o,s);if(l&&c){var f=e;`defaultValue`in u&&Ba(f,u.defaultValue),`value`in u&&Ha(f,u.value)}for(let e of Object.getOwnPropertySymbols(i))u[e]||_r(i[e]);for(let t of Object.getOwnPropertySymbols(u)){var p=u[t];t.description!==`@attach`||r&&p===r[t]||(i[t]&&_r(i[t]),i[t]=pr(()=>Fa(e,()=>p))),d[t]=p}r=d}),c){var u=e;cr(()=>{var e=r;`defaultValue`in e&&Ba(u,e.defaultValue),Ha(u,e.value,!0),Ua(u)})}l=!0})}function io(e){return e[ue]??={[Ja]:Tn(e).includes(`-`),[Ya]:it==null&&e.namespaceURI===`http://www.w3.org/1999/xhtml`}}var ao=new Map;function oo(e){var t=zn(e,`is`)||Tn(e),n=ao.get(t);if(n)return n;ao.set(t,n=new Set);for(var r,i=e,a=Element.prototype;a!==i;){for(var s in r=o(i),r)r[s].set&&s!==`innerHTML`&&s!==`textContent`&&s!==`innerText`&&n.add(s);i=l(i)}return n}function so(e,t,n=t){var r=new WeakSet;Ar(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=co(e)?lo(a):a,n(a),M!==null&&r.add(M),await Ci(),a!==(a=t())){var o=e.selectionStart,s=e.selectionEnd,c=e.value.length;if(e.value=a??``,s!==null){var l=e.value.length;o===s&&s===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(s,l))}}}),(D&&e.defaultValue!==e.value||Oi(t)==null&&e.value)&&(n(co(e)?lo(e.value):e.value),M!==null&&r.add(M)),ur(()=>{var n=t();e===document.activeElement&&r.has(F)||co(e)&&n===lo(e.value)||(e.type!==`date`||n||e.value)&&n!==e.value&&(e.value=n??``)})}function co(e){var t=e.type;return t===`number`||t===`range`}function lo(e){return e===``?null:+e}function uo(e,t){return e===t||e?.[oe]===t}function fo(e=nt(),t,n,r){var i=A.r,a=W;return cr(()=>{var o,s;return ur(()=>{o=s,s=r?.()||[],Oi(()=>{uo(n(...s),e)||(t(e,...s),o&&uo(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&uo(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}var po=!1;function mo(e){var t=po;try{return po=!1,[e(),po]}finally{po=t}}function $(e,t,n,r){var i=!0,o=!!(n&8),s=!!(n&16),c=r,l=!0,u=void 0,d=()=>s&&i?(u??=dt(r),K(u)):(l&&(l=!1,c=s?Oi(r):r),c);let f;if(o){var p=oe in e||ce in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=mo(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&Re(t),f(m)));var g=i?()=>{var n=e[t];return n===void 0?d():(l=!0,n)}:()=>{var n=e[t];return n!==void 0&&(c=void 0),n===void 0?c:n};if(i&&!(n&4))return g;if(f){var _=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||_||h)&&f(t?g():e),e):g()})}var v=!1,y=(n&1?dt:ht)(()=>(v=!1,g()));o&&K(y);var b=W;return(function(e,t){if(arguments.length>0){let n=t?K(y):i&&o?an(e):e;return L(y,n),v=!0,c!==void 0&&(c=n),e}return jr&&v||b.f&16384?y.v:K(y)})}function ho(e){A===null&&Me(`onMount`),ar(()=>{let t=Oi(e);if(typeof t==`function`)return t})}fn(),typeof window<`u`&&((globalThis.__svelte??={}).v??=new Set).add(`5`);var go=[`goal`,`maker`,`verify`,`review`,`judge`,`deliver`],_o={waiting:0,working:1,idle:2,missing:3},vo={goal:`Goal`,maker:`Maker`,verify:`Verify`,review:`Review`,judge:`Judge`,deliver:`Deliver`},yo={freeze:`Freeze?`,approval:`Approve delivery?`,question:`Agent asks you`},bo={waiting:`Waiting for you`,working:`Working`,idle:`Idle`,missing:`Folder missing`};function xo(e){return String(e??``).replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}function So(e){return vo[e]||(e?String(e):``)}function Co(e){return e?yo[e.kind]||`Waiting for you`:``}function wo(e){let t=Math.floor(Math.max(0,Number(e)||0)/6e4);if(t<1)return`just now`;if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function To(e){let t=e=>_o[e.state]??_o.idle;return[...e||[]].sort((e,n)=>t(e)-t(n)||String(e.name).localeCompare(String(n.name)))}function Eo(e){return!!(e&&e.waiting&&e.waiting.kind===`freeze`)}function Do(e){return e?[(Eo(e)?``:Co(e.waiting))||So(e.stage),e.tier,wo(e.elapsedMs)].filter(Boolean).join(` · `):``}var Oo=new Set([`REPORTED`,`DELIVERED`,`CANCELLED`,`ESCALATED`]);function ko(e){return e.waiting?`waiting`:Oo.has(e.state)?`idle`:`working`}function Ao(e){return Object.hasOwn(_o,e&&e.state)?e.state:`idle`}function jo(e){return bo[e]||bo.idle}function Mo(e){return e.run?Do(e.run):Ao(e)===`missing`?bo.missing:`No active Run`}function No(e){return(e.worktreeRuns||[]).filter(e=>e.worktreeId)}function Po(e,t){return t?`Freeze ${e} as ${t}`:`Freeze ${e}`}function Fo(e){let t=e||[],n=t.filter(e=>e.state===`working`).length,r=t.filter(e=>e.state===`waiting`).length,i=[{kind:`count`,text:`${t.length} ${t.length===1?`kitchen`:`kitchens`}`}];return i.push({kind:n?`working`:`count`,text:`${n} ${n===1?`chef`:`chefs`} cooking`}),r&&i.push({kind:`waiting`,text:`${r} ${r===1?`order needs`:`orders need`} you`}),i}var Io=J(`
  • Loading projects…
  • `),Lo=J(`
  • `),Ro=J(`
  • `),zo=J(`
  • `),Bo=J(`
    `);function Vo(e,t){et(t,!0);let n=$(t,`projects`,19,()=>[]),r=$(t,`loaded`,3,!1),i=j(()=>Fo(n()));var a=Bo(),o=R(a),s=e=>{Y(e,Io())},c=e=>{var t=ta();Da(z(t),17,()=>K(i),ya,(e,t)=>{var n=ta(),r=z(n),i=e=>{var n=Lo(),r=V(R(n),1,!0);k(n),H(()=>X(r,K(t).text)),Y(e,n)},a=e=>{var n=Ro(),r=B(n,!0);H(()=>X(r,K(t).text)),Y(e,n)},o=e=>{var n=zo(),r=B(n,!0);H(()=>X(r,K(t).text)),Y(e,n)};Z(r,e=>{K(t).kind===`working`?e(i):K(t).kind===`waiting`?e(a,1):e(o,-1)}),Y(e,n)}),Y(e,t)};Z(o,e=>{r()?e(c,-1):e(s)}),k(a),Y(e,a),tt()}var Ho=J(``);function Uo(e,t){et(t,!0);let n=$(t,`actor`,3,null),r=$(t,`action`,3,null),i=$(t,`className`,3,`primary`),a=$(t,`label`,3,null),o=$(t,`ariaLabel`,3,void 0),s=$(t,`extra`,19,()=>({})),c=j(()=>t.freeze&&t.freeze.source===t.source),l=j(()=>K(c)&&t.freeze.phase===`busy`?`Freezing…`:K(c)&&t.freeze.phase===`done`?`Frozen`:a()||(n()?`Freeze as ${n()}`:`Freeze…`));function u(){n()?t.onfreeze(t.source):t.onname(t.source)}var d=Ho();ro(d,()=>({type:`button`,class:i(),"data-action":r()||(n()?`freeze`:t.nameAction),...s(),"aria-label":o(),disabled:K(c)&&t.freeze.phase===`busy`,"data-done":K(c)&&t.freeze.phase===`done`?`true`:void 0,onclick:u}));var f=B(d,!0);H(()=>X(f,K(l))),Y(e,d),tt()}var Wo=J(``),Go=J(``,1),Ko=J(`

    No projects yet. AEL lists a project here once you run ael init or ael run in it.

    `),qo=J(` `,1),Jo=J(`
  • `),Yo=J(`
      `),Xo=J(`
    • `),Zo=J(`
        `),Qo=J(`
        `);function $o(e,t){et(t,!0);let n=(e,n=d,r=d,i=d)=>{var a=ta(),c=z(a),l=e=>{var a=Go(),c=z(a);{let e=j(()=>`list:${n()}`),a=j(()=>({"data-project-id":n(),"data-run-id":r().runId,"data-goal-hash":r().waiting.goalHash??``})),l=j(()=>Po(i(),o()));Uo(c,{get actor(){return o()},action:`list-freeze`,get source(){return K(e)},get freeze(){return s()},className:`primary list-freeze`,get extra(){return K(a)},get ariaLabel(){return K(l)},onfreeze:()=>t.onfreeze(n(),r()),onname:()=>t.onfreezename(n())})}var l=V(c),u=e=>{var r=Wo();H(()=>{Q(r,`data-project-id`,n()),Q(r,`aria-label`,`Look at the order sketch for ${i()}`)}),q(`click`,r,e=>t.onsketch(n(),e.currentTarget)),Y(e,r)};Z(l,e=>{r().waiting.sketch&&e(u)}),Y(e,a)},u=j(()=>Eo(r()));Z(c,e=>{K(u)&&e(l)}),Y(e,a)},r=$(t,`projects`,19,()=>[]),i=$(t,`loaded`,3,!1),a=$(t,`selectedId`,3,null),o=$(t,`actor`,3,null),s=$(t,`freeze`,3,null),c=j(()=>To(r())),l=Co({kind:`freeze`});var u=Qo(),f=R(u),p=e=>{var r=ta(),i=z(r),o=e=>{Y(e,Ko())},s=e=>{var r=Zo();Da(r,21,()=>K(c),e=>e.id,(e,r)=>{let i=j(()=>Ao(K(r))),o=j(()=>No(K(r)));var s=Xo(),c=R(s),u=R(c),d=V(u),f=R(d,!0),p=V(f),m=e=>{var t=qo(),n=z(t,!0);n.nodeValue=` `;var r=B(V(n));H(()=>X(r,`· ${l??``}`)),Y(e,t)},h=j(()=>Eo(K(r).run));Z(p,e=>{K(h)&&e(m)}),k(d);var g=B(V(d),!0);k(c);var _=V(c);n(_,()=>K(r).id,()=>K(r).run,()=>K(r).name);var v=V(_),y=e=>{var r=Yo();Da(r,21,()=>K(o),e=>e.worktreeId,(e,r)=>{let i=j(()=>ko(K(r)));var o=Jo(),s=R(o),c=R(s),u=V(c),d=R(u,!0),f=V(d),p=e=>{var t=qo(),n=z(t,!0);n.nodeValue=` `;var r=B(V(n));H(()=>X(r,`· ${l??``}`)),Y(e,t)},m=j(()=>Eo(K(r)));Z(f,e=>{K(m)&&e(p)}),k(u);var h=B(V(u),!0);k(s);var g=V(s);n(g,()=>K(r).worktreeId,()=>K(r),()=>K(r).task||K(r).runId),k(o),H(e=>{Q(o,`data-state`,K(i)),Q(s,`data-project-id`,K(r).worktreeId),Q(s,`aria-current`,K(r).worktreeId===a()?`true`:void 0),Ia(c,1,`bot bot-${K(i)??``}`),X(d,K(r).task||K(r).runId),X(h,e)},[()=>Do(K(r))]),q(`click`,s,()=>t.onselect(K(r).worktreeId)),Y(e,o)}),k(r),Y(e,r)};Z(v,e=>{K(o).length&&e(y)}),k(s),H((e,t)=>{Q(s,`data-state`,K(i)),Q(c,`data-project-id`,K(r).id),Q(c,`aria-current`,K(r).id===a()?`true`:void 0),Ia(u,1,`bot bot-${K(i)??``}`),Q(u,`aria-label`,e),X(f,K(r).name),X(g,t)},[()=>jo(K(i)),()=>Mo(K(r))]),q(`click`,c,()=>t.onselect(K(r).id)),Y(e,s)}),k(r),Y(e,r)};Z(i,e=>{K(c).length?e(s,-1):e(o)}),Y(e,r)};Z(f,e=>{i()&&e(p)}),k(u),Y(e,u),tt()}Wi([`click`]);var es=go,ts=[`done`,`now`,`pending`,`skipped`],ns=360/es.length,rs={done:`done`,now:`in progress`,pending:`not started`,skipped:`skipped`},is={goal:`Goal Contract`,maker:`Maker`,verify:`Verification`,review:`Devil's Advocate`,judge:`Judge`,deliver:`Delivery`},as={freeze:`Waiting for Freeze`,approval:`Waiting for approval`,question:`Agent asks you`},os={DELIVERED:`Delivered`,REPORTED:`Reported`,CANCELLED:`Cancelled`,ESCALATED:`Escalated`},ss={goal:`Writing the order`,maker:`On the stove`,verify:`Tasting`,review:`The critic tastes`,judge:`Head chef's call`,deliver:`Plating up`},cs={freeze:`Confirm your order`,approval:`Ready at the pass`,question:`The chef has a question`},ls={DELIVERED:`Served`,REPORTED:`Order noted`,CANCELLED:`Order cancelled`,ESCALATED:`Sent to the manager`};function us(e,{iteration:t=1,maxIterations:n=1,waiting:r=null}={}){let i=new Map((Array.isArray(e)?e:[]).map(e=>[e&&e.stage,e&&e.status])),a=es.map((e,t)=>{let n=i.get(e);return{stage:e,angle:t*ns,status:ts.includes(n)?n:`pending`}}),o=a.find(e=>e.status===`now`),s=a.filter(e=>e.status===`done`).at(-1),c=o||s||a[0],l=o?`working`:`settled`;return r&&(l=`waiting`),{stages:a,mode:l,waitingKind:r&&r.kind||null,botStage:c.stage,botAngle:c.angle,iteration:Number(t)||1,maxIterations:Number(n)||1}}function ds(e,t){return`${e} ${t}${e===1?``:`s`}`}function fs(e,t=null){let n=us(e&&e.ring,e||{}),r=n.stages.find(e=>e.status===`now`),i=e&&e.waiting,a=e&&os[e.state],o=n.stages.find(e=>e.stage===n.botStage),s;s=i&&as[i.kind]?as[i.kind]:a&&!r?a:is[n.botStage]||So(n.botStage);let c;return c=t&&Number.isFinite(t.total)?`${ds(t.total,`finding`)} · ${Number(t.blocking)||0} blocking`:i?`waiting for you`:a&&!r?`done`:rs[(r||o).status],{title:s,note:c}}function ps(e,t=null){let{title:n,note:r}=fs(e,t),i=us(e&&e.ring,e||{}),a=i.stages.find(e=>e.status===`now`),o=e&&e.waiting,s;return s=o&&cs[o.kind]?cs[o.kind]:e&&ls[e.state]&&!a?ls[e.state]:ss[i.botStage]||n,{board:s,title:n,note:r}}var ms={goal:`planning`,maker:`building`,verify:`checking`,review:`reviewing`,judge:`judging`,deliver:`delivering`};function hs(e,t=null){let n=us(e&&e.ring,e||{}),{title:r,note:i}=fs(e,t);return n.mode===`waiting`?`Bot is waiting for you: ${r}`:n.mode===`settled`?`Bot is done: ${r}`:`Bot is ${ms[n.botStage]}: ${r}, ${i}`}function gs(e,t=``){let n=`iteration ${Number(e&&e.iteration)||1} of ${Number(e&&e.maxIterations)||1}`;return[`Order`,t,e&&e.tier,n].filter(Boolean).join(` · `)}var _s=rs,vs=`Eating while their workflow cooks`;function ys(e){return(Array.isArray(e)?e:[]).slice(0,6).filter(e=>e&&e.name)}function bs({webgl:e=!1,threeFailed:t=!1}={}){return e&&!t?`3d`:`flat`}var xs=[`formatted`,`markdown`],Ss={formatted:`Formatted`,markdown:`Markdown`},Cs={freeze:`Confirm the order?`,approval:`Bring it out?`,question:`Chef asks you`},ws={freeze:`The Goal draft is waiting for you to freeze it. You can also answer in the agent host; whichever comes first wins.`,approval:`Delivery is waiting for your approval in the agent host.`,question:`The agent asked you a question in the agent host.`};function Ts(e,t){return`${e} ${t}${e===1?``:`s`}`}var Es=`Look at the order sketch`,Ds={state:`State`,storyboard:`Storyboard`,lanes:`Lanes`},Os=`To change the Goal, answer Revise in your agent host.`;function ks(e){if(!e)return``;let t=(e,t,n)=>`${Number(e)||0} ${Number(e)===1?t:n}`;return[t(e.undecided,`undecided`,`undecided`),t(e.hotspots,`hotspot`,`hotspots`),t(e.sideEffects,`side effect`,`side effects`)].join(`, `)}function As(e){return e&&Array.isArray(e.diagramOptions)?e.diagramOptions.filter(e=>Ds[e.view]):[]}function js(e){let t=As(e),n=t.find(e=>e.recommended)||t[0];return n?n.view:null}function Ms(e){return`${Ds[e]} sketch of the Goal`}function Ns(e){return!!(e&&e.waiting&&e.waiting.kind===`freeze`)}function Ps(e){return e?Cs[e.kind]||Co(e):``}function Fs(e){return e&&ws[e.kind]||``}function Is(e){let t=wo(e);return t===`just now`?`Ordered just now`:`Ordered ${t} ago`}function Ls(e){return e?`${Ts(e.total,`finding`)}, ${e.blocking} blocking`:`No review yet`}function Rs(e){return typeof e==`string`&&/^https?:\/\//i.test(e)?e:null}function zs(e){let t=us(e&&e.ring,e||{}),n=`Iteration ${Number(e&&e.iteration)||1} of ${Number(e&&e.maxIterations)||1}`;return[So(t.botStage),e&&e.tier,n].filter(Boolean)}var Bs=J(`
        `),Vs=J(``),Hs=J(``,1),Us=J(`
        `),Ws=J(`

        `,1),Gs=J(`
        `);function Ks(e,t){et(t,!0);let n=$(t,`summary`,3,null),r=$(t,`actor`,3,null),i=$(t,`projectName`,3,``),a=$(t,`freeze`,3,null),o=$(t,`actorInput`,15,null),s=I(``),c=j(()=>n()?n().task||n().runId:``),l=j(()=>a()&&a().source===`head`&&a().phase===`busy`),u=j(()=>a()&&a().source===`head`&&a().phase===`done`);function d(e){e.preventDefault();let n=K(s).trim();n&&t.onfreeze(`head`,n)}var f=Gs(),p=R(f),m=e=>{var f=Ws(),p=z(f),m=B(p,!0),h=V(p,2),g=B(h,!0),_=V(h,2),v=B(_,!0),y=V(_,2),b=e=>{var i=Us(),c=R(i),f=B(c,!0),p=V(c),m=B(p,!0),h=V(p),g=e=>{var i=Hs(),c=z(i),f=e=>{Uo(e,{get actor(){return r()},source:`head`,get freeze(){return a()},get onfreeze(){return t.onfreeze},onname:()=>{}})},p=e=>{var t=Bs(),n=V(R(t));to(n),fo(n,e=>o(e),()=>o());var r=V(n),i=B(r,!0);k(t),H(()=>{r.disabled=K(l),Q(r,`data-done`,K(u)?`true`:void 0),X(i,K(l)?`Freezing…`:K(u)?`Frozen`:`Freeze`)}),Ui(`submit`,t,d),so(n,()=>K(s),e=>L(s,e)),Y(e,t)};Z(c,e=>{r()?e(f):e(p,-1)});var m=V(c),h=e=>{var n=Vs(),r=B(n,!0);H(()=>X(r,Es)),q(`click`,n,e=>t.onsketch(e.currentTarget)),Y(e,n)};Z(m,e=>{n().waiting.sketch&&e(h)}),Y(e,i)},_=j(()=>Ns(n()));Z(h,e=>{K(_)&&e(g)}),k(i),H((e,t,r)=>{Q(i,`data-kind`,n().waiting.kind),Q(c,`title`,e),X(f,t),X(m,r)},[()=>Co(n().waiting),()=>Ps(n().waiting),()=>Fs(n().waiting)]),Y(e,i)};Z(y,e=>{n().waiting&&e(b)}),H((e,t)=>{X(m,e),Q(h,`title`,K(c)),X(g,K(c)),X(v,t)},[()=>gs(n(),i()),()=>Is(n().elapsedMs)]),Y(e,f)};Z(p,e=>{n()&&e(m)}),k(f),Y(e,f),tt()}Wi([`click`]);var qs=[`h4`,`h5`,`h6`,`h6`,`h6`,`h6`],Js=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,Ys=/^(#{1,6})\s+(.*?)\s*#*\s*$/,Xs=/^\s*(```|~~~)/,Zs=/^https?:\/\/[^\s]+$/i;function Qs(e){return e.replaceAll(`&`,`&`)}function $s(e,t){return e.replace(/`([^`]+)`/g,(e,n)=>(t.push(`${n}`),`\u0000${t.length-1}\u0000`))}function ec(e,t){return e.replace(/\[([^\]]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/g,(e,n,r)=>{let i=Qs(r);return Zs.test(i)?(t.push(`${n}`),`\u0000${t.length-1}\u0000`):n})}function tc(e){return e.replace(/\*\*(?=\S)([^*]*?\S)\*\*/g,`$1`).replace(/__(?=\S)([^_]*?\S)__/g,`$1`).replace(/(^|[^*\w])\*(?=\S)([^*]*?\S)\*(?!\*)/g,`$1$2`).replace(/(^|[^_\w])_(?=\S)([^_]*?\S)_(?![_\w])/g,`$1$2`)}function nc(e){let t=[],n=xo(e);return n=$s(n,t),n=ec(n,t),n=tc(n),n.replace(/\u0000(\d+)\u0000/g,(e,n)=>t[Number(n)])}function rc(e){return e.replaceAll(` `,` `).length}function ic(e,t){let n=e[t].match(Js),r=rc(n[1]),i=/\d/.test(n[2])?`ol`:`ul`,a=[],o=t;for(;or&&a.length){let t=ic(e,o);a[a.length-1]+=t.html,o=t.next}else a.push(nc(t[3])),o+=1}return{html:`<${i}>${a.map(e=>`
      • ${e}
      • `).join(``)}`,next:o}}function ac(e){let t=String(e??``).replace(/\r\n?/g,` +`).split(` +`),n=[],r=[],i=()=>{r.length&&n.push(`

        ${r.map(nc).join(`
        `)}

        `),r=[]},a=0;for(;a${xo(o.join(` +`))}`),a+=1;continue}if(!e.trim()){i(),a+=1;continue}let o=e.match(Ys);if(o){i();let e=qs[o[1].length-1];n.push(`<${e}>${nc(o[2])}`),a+=1}else if(Js.test(e)){i();let e=ic(t,a);n.push(e.html),a=e.next}else r.push(e.trim()),a+=1}return i(),n.join(``)}var oc={ArrowRight:(e,t)=>(e+1)%t,ArrowLeft:(e,t)=>(e-1+t)%t,Home:()=>0,End:(e,t)=>t-1};function sc(e,t,n){let r=oc[e.key];return r?(e.preventDefault(),t[r(t.indexOf(n),t.length)]):null}var cc=(e,t=d)=>{var n=ta(),r=z(n),i=e=>{Y(e,lc())},a=e=>{var n=dc();Da(n,21,t,ya,(e,t)=>{var n=uc(),r=B(n,!0);H(()=>X(r,K(t))),Y(e,n)}),k(n),Y(e,n)};Z(r,e=>{!t()||!t().length?e(i):e(a,-1)}),Y(e,n)},lc=J(`

        None

        `),uc=J(`
      • `),dc=J(`
          `),fc=J(` open`,1),pc=J(` `,1),mc=J(`

          Goal

          No Goal draft yet.

          `,1),hc=J(``),gc=J(`

          Goal

           
          `,1),_c=J(`

          Other steps

          `),vc=J(`
          Findings
          Pull request
          Receipt

          Unconfirmed assumptions

          `,1),yc=J(`
          `);function bc(e,t){et(t,!0);let n=$(t,`detail`,3,null),r=$(t,`goalView`,3,`formatted`),i=j(()=>xs.includes(r())?r():`formatted`),a=j(()=>n()&&n().goalMarkdown?ac(n().goalMarkdown):``),o=j(()=>n()&&n().pr?Rs(n().pr.url):null),s={};function c(e,n){let r=sc(e,xs,n);r&&(t.onview(r),s[r].focus())}var l=yc(),u=R(l),d=e=>{var r=vc(),l=z(r),u=R(l),d=B(V(R(u)),!0);k(u);var f=V(u,2),p=V(R(f)),m=R(p),h=e=>{var t=pc(),r=z(t),i=B(r,!0),a=V(r),s=V(a),c=e=>{var t=fc(),n=z(t,!0);n.nodeValue=` `;var r=V(n);H(()=>Q(r,`href`,K(o))),Y(e,t)};Z(s,e=>{K(o)&&e(c)}),H(()=>{X(i,n().pr.branch||`unknown branch`),X(a,` · ${n().pr.merged?`merged`:`not merged`}`)}),Y(e,t)},g=e=>{Y(e,ea(`No branch yet`))};Z(m,e=>{n().pr?e(h):e(g,-1)}),k(p),k(f);var _=V(f,2),v=B(V(R(_)),!0);k(_),k(l);var y=V(l,2),b=R(y),x=e=>{var t=mc();Ee(2),Y(e,t)},S=e=>{var r=gc(),o=z(r),l=V(R(o),2);Da(l,21,()=>xs,ya,(e,n)=>{var r=hc(),a=B(r,!0);fo(r,(e,t)=>s[t]=e,e=>s?.[e],()=>[K(n)]),H(()=>{Q(r,`id`,`goal-tab-${K(n)??``}`),Q(r,`aria-controls`,`goal-panel-${K(n)??``}`),Q(r,`aria-selected`,K(n)===K(i)?`true`:`false`),Q(r,`tabindex`,K(n)===K(i)?0:-1),Q(r,`data-goal-view`,K(n)),X(a,Ss[K(n)])}),q(`click`,r,()=>t.onview(K(n))),q(`keydown`,r,e=>c(e,K(n))),Y(e,r)}),k(l),k(o);var u=V(o,2);Na(u,()=>K(a),!0),k(u);var d=V(u,2),f=B(R(d),!0);k(d),H(()=>{Q(u,`hidden`,K(i)!==`formatted`),Q(d,`hidden`,K(i)!==`markdown`),X(f,n().goalMarkdown)}),Y(e,r)};Z(b,e=>{n().goalMarkdown?e(S,-1):e(x)}),k(y);var C=V(y,2);cc(V(R(C)),()=>n().unconfirmed),k(C);var w=V(C,2),ee=e=>{var t=_c();cc(V(R(t)),()=>n().extraNodes),k(t),Y(e,t)};Z(w,e=>{n().extraNodes&&n().extraNodes.length&&e(ee)}),H(e=>{X(d,e),X(v,n().receipt===`written`?`Receipt written`:`No receipt yet`)},[()=>Ls(n().findings)]),Y(e,r)};Z(u,e=>{n()&&e(d)}),k(l),Y(e,l),tt()}Wi([`click`,`keydown`]);var xc=2.1,Sc=2e3,Cc=1.7,wc={x:-1.4,z:5.3},Tc=`Sent back to the kitchen`,Ec=[{x:-4.1,z:4.4},{x:2.8,z:5.3},{x:4.4,z:3.9}],Dc=[`fork`,`sip`,`chat`];function Oc(e){return Math.min(6,Math.max(4,Math.trunc(Number(e)||0)))}var kc={goal:{label:`Order`,props:[`lectern`,`notepad`,`quill`],costume:`philosopher`,mood:`bright`},maker:{label:`Cook`,props:[`stove`,`pan`,`flame`,`steam`],costume:`chef`,mood:`bright`},verify:{label:`Taste`,props:[`bowl`,`spoon`],costume:`chef`,mood:`bright`},review:{label:`Critic`,props:[`plate`,`magnifier`],costume:`devil`,mood:`dim`},judge:{label:`Head chef`,props:[`plate`,`spoon`,`bell`],costume:`chef`,mood:`bright`},deliver:{label:`Serve`,props:[`tray`,`cloche`,`plate`],costume:`chef`,mood:`bright`}};function Ac(e){return kc[e]||kc.goal}function jc(e){return Math.max(0,go.indexOf(e))}function Mc(e){return Number(((jc(e)-(go.length-1)/2)*xc).toFixed(3))}var Nc={done:{lamp:`--ok-fill`,glow:.9,tone:1,saturation:1,spot:0,pulse:0},now:{lamp:`--brand`,glow:1.3,tone:1,saturation:1,spot:1,pulse:.35},pending:{lamp:`--line-strong`,glow:0,tone:.78,saturation:.8,spot:0,pulse:0},skipped:{lamp:`--faint`,glow:0,tone:.82,saturation:.08,spot:0,pulse:0}};function Pc(e){return Nc[e]||Nc.pending}function Fc(e,t=0,{reducedMotion:n=!1}={}){let r=Pc(e);return!r.pulse||n?r.glow:Number((r.glow*(1-r.pulse/2+r.pulse/2*Math.sin(t*Math.PI*1.25))).toFixed(4))}function Ic(e){let t=e&&go.includes(e.botStage)?e.botStage:`goal`;return{stage:t,x:Mc(t)}}function Lc(e){let t=Number(e&&e.iteration)||1,n=Math.max(t,Number(e&&e.maxIterations)||1);return t>1?`Iteration ${t} of ${n}`:`Your order`}function Rc(e){return!e||(Number(e.iteration)||1)<=1?null:{from:`judge`,to:`maker`,fromX:Mc(`judge`),toX:Mc(`maker`),label:Tc}}function zc(e,t,{reducedMotion:n=!1}={}){let r=t-e,i=Math.round(Math.abs(r)/xc);if(Math.abs(r)<.001)return{from:e,to:t,steps:0,hops:0,ms:0,fade:!1};if(n)return{from:e,to:t,steps:i,hops:0,ms:0,fade:!0};let a=Math.max(1,i);return{from:e,to:t,steps:a,hops:a*2,ms:Math.min(Sc,a*650+250),fade:!1}}function Bc(e,t){return t?Math.abs(Math.sin(Math.PI*Math.min(1,Math.max(0,e))*t)):0}function Vc(e,t,n){return{x:(e.x+1)*t/2,y:(1-e.y)*n/2,visible:e.z>-1&&e.z<1}}var Hc={goal:`focus`,maker:`stern`,verify:`focus`,review:`squint`,judge:`focus`,deliver:`happy`},Uc=[`question`,`open`,`annoyed`,`angry`];function Wc(e,{reacting:t=!1}={}){return t?`happy`:e?e.mode===`waiting`?Uc[Math.min(Uc.length,Math.max(1,e.waitLevel||1))-1]:e.mode===`settled`?`happy`:Hc[e.botStage]||`open`:`open`}function Gc(e){if(e==null)return 0;let t=((e-.42)%1+1.5)%1-.5,n=Math.max(0,1-Math.abs(t)/.22);return Number((n*n*(3-2*n)).toFixed(4))}function Kc(e,t){return!e||!t||e.judge!==`now`?null:t.judge===`done`?`pass`:t.judge!==`now`&&t.judge!==`skipped`?`iterate`:null}var qc={rest:{position:[0,4.7,11.4],target:[0,1.25,.7],fov:36},station:{position:[0,2.2,4],target:[0,.95,-.35],fov:30}},Jc=5.6,Yc=-.55,Xc=Mc(`deliver`)-xc/2,Zc={wide:{top:.06,bottom:.12},compact:{top:.24,bottom:.14}},Qc=e=>e*Math.PI/180,$c=e=>{let t=Math.hypot(...e)||1;return e.map(e=>e/t)},el=(e,t,n)=>e.map((e,r)=>Number((e+t[r]*n).toFixed(4))),tl=e=>$c(e.position.map((t,n)=>t-e.target[n]));function nl(e){return Math.min(Xc,Math.max(-Xc,Number(e)||0))}function rl(e,t=0){let n=e>0?e:1,r=Math.tan(Qc(20))*n,i=Jc/2/r,a=qc.rest,o=[nl(t),a.target[1]+Yc,a.target[2]];return{position:el(o,tl(a),i),target:o,fov:40}}function il(e,t,{compact:n=!1,fov:r=qc.station.fov}={}){let i=e>0?e:1,a=n?Zc.compact:Zc.wide,o=1-a.top-a.bottom,s=Math.tan(Qc(r/2)),c=(t.top-t.bottom)/2*1.3/o,l=t.half*1.3,u=Math.max(c/s,l/(s*i)),d=u*s,f=(t.top+t.bottom)/2+(a.top-a.bottom)*d,p=[t.x,Number(f.toFixed(4)),t.z];return{position:el(p,tl(qc.station),u),target:p,fov:r}}function al(e,t,n=0,{compact:r=!1,restX:i=n,bot:a=null}={}){let o=Math.min(1,Math.max(0,e)),s=a?il(t,{...a,x:n},{compact:r}):{position:[n+qc.station.position[0],...qc.station.position.slice(1)],target:[n+qc.station.target[0],...qc.station.target.slice(1)],fov:qc.station.fov},c=(e,t)=>e.map((e,n)=>e+(t[n]-e)*o);if(r){let e=rl(t,i);return{position:c(e.position,s.position),target:c(e.target,s.target),fov:e.fov+(s.fov-e.fov)*o}}let l=c(qc.rest.target,s.target),u=c(qc.rest.position,s.position),d=qc.rest.fov+(s.fov-qc.rest.fov)*o;if(t>0&&t<1.7){let e=1+(Cc/t-1)*(1-(a?1:.6)*o);u=u.map((t,n)=>l[n]+(t-l[n])*e)}return{position:u,target:l,fov:d}}function ol(e,t,n=8){let r=Math.max(n,t.width-e.w-n),i=Math.max(n,t.height-e.h-n);return{...e,x:Math.min(r,Math.max(n,e.x)),y:Math.min(i,Math.max(n,e.y))}}function sl(e,t,n){return e.xe.x>=i&&e.y>=i&&e.x+e.w<=n.width-i&&e.y+e.h<=n.height-i,s=a.find(e=>o(e)&&!sl(e,t,r-1e-6));return s?{...s,hidden:!1}:{...e,hidden:!0}}function ll(e,t){let n=Math.min(1,Math.max(0,t));return e?{outX:-e*16*n,inX:e*16*(1-n),outY:0,inY:0,outScale:1,inScale:1}:{outX:0,inX:0,outY:-1.2*n,inY:1.2*(1-n),outScale:1-.15*n,inScale:.85+.15*n}}function ul(e){let t=Math.min(6,Math.max(0,Math.trunc(Number(e)||0)));return Array.from({length:t},(e,n)=>{let r=Ec[n%Ec.length],i=Math.floor(n/Ec.length),a=t>Ec.length+n%Ec.length?i?.42:-.42:0;return{index:n,table:n%Ec.length,x:Number((r.x+a).toFixed(3)),z:Number((r.z-.62).toFixed(3)),loop:Dc[n%Dc.length],phase:Number((n*.37%1).toFixed(2))}})}function dl(e,t,n=0,{reducedMotion:r=!1}={}){if(r)return{armR:-.5,armL:-.3,head:.12,tilt:0,sway:0};let i=((t/(e===`chat`?2.4:e===`sip`?3.6:2.8)+n)%1+1)%1,a=Math.max(0,Math.sin(i*Math.PI*2));return e===`fork`?{armR:-.5-a*1.5,armL:-.3,head:.12-a*.18,tilt:0,sway:0}:e===`sip`?{armR:-.5,armL:-.3-a*1.7,head:.1-a*.25,tilt:0,sway:0}:{armR:-.6-a*.4,armL:-.3,head:Math.sin(i*Math.PI*4)*.08,tilt:Math.sin(i*Math.PI*2)*.14,sway:Math.sin(i*Math.PI*2)*.04}}var fl=8.5,pl=1.4;function ml(e,t=0){let n=((e/fl+t)%1+1)%1*fl;if(n>=1.4)return 0;let r=Math.min(1,n/(pl*.2),(pl-n)/(pl*.2));return Number((r*r*(3-2*r)).toFixed(4))}var hl=.12,gl=.1;function _l(e,t){if(!t)return{y:1,xz:1};let n=Math.min(1,Math.max(0,e)),r=1+n*gl-Math.max(0,1-n*3)*hl;return{y:Number(r.toFixed(4)),xz:Number((1/Math.sqrt(r)).toFixed(4))}}var vl=[-.7,.7,0,-.35,.35];function yl(e){let t=new Map;return e.slice(0,5).map(e=>{let n=t.get(e)||0;return t.set(e,n+1),{stage:e,x:Mc(e)+vl[n%vl.length]}})}function bl(e,t){let n={};return[e,...t].filter(Boolean).forEach(e=>{n[e]=(n[e]||0)+1}),n}var xl=[30,120,300],Sl={freeze:[[`Your order, please?`],[`…`,`Ready to order?`],[`The kitchen is waiting…`,`Hmph.`,`Any time now…`],[`Confirm the order!`,`I've been waiting ages!`,`The kitchen is idle!`,`Hello?!`]],approval:[[`Bring it out?`],[`…`,`Shall I serve?`],[`The food's getting cold!`,`Hmph.`,`Still on the pass…`],[`The food's getting cold!`,`I've been waiting ages!`,`Serve it already!`,`Hello?!`]],question:[[`A quick question?`],[`…`,`Excuse me?`],[`The waiter asked you!`,`Hmph.`,`Still here…`],[`Answer the waiter!`,`I've been waiting ages!`,`Any day now!`,`Hello?!`]]},Cl={freeze:{ask:`Confirm the order?`,note:`Freeze the Goal here or answer in your agent host.`},approval:{ask:`Bring it out?`,note:`Approve the delivery in your agent host.`},question:{ask:`The waiter asks you something.`,note:`Answer in your agent host.`}};function wl(e){return e?Cl[e.kind]||Cl.question:null}function Tl(e,t=Date.now()){let n=Date.parse(e&&e.since);return Number.isFinite(n)?Math.max(0,(t-n)/1e3):0}function El(e){return 1+xl.filter(t=>e>=t).length}function Dl(e,t,n=0,{reducedMotion:r=!1}={}){let i=El(t),a=(Sl[e]||Sl.question)[i-1],o=!r&&a.length>1&&i>=3;return{level:i,text:a[o?Math.abs(Math.trunc(n))%a.length:0],rotates:o}}var Ol=[.23,1,.32,1];function kl(e,t,n,r){let i=(e,t,n)=>((1-3*t+3*e)*n+(3*t-6*e))*n*n+3*e*n,a=(e,t,n)=>3*(1-3*t+3*e)*n*n+2*(3*t-6*e)*n+3*e;return o=>{if(o<=0)return 0;if(o>=1)return 1;let s=o;for(let t=0;t<8;t+=1){let t=i(e,n,s)-o;if(Math.abs(t)<1e-6)break;let r=a(e,n,s);if(Math.abs(r)<1e-6)break;s-=t/r}return s=Math.min(1,Math.max(0,s)),i(t,r,s)}}function Al(e){return To(e).flatMap(e=>[...e.run&&!Oo.has(e.run.state)?[e.id]:[],...(e.worktreeRuns||[]).filter(e=>e.worktreeId&&!Oo.has(e.state)).map(e=>e.worktreeId)])}function jl(e,t,n){if(!e.length)return null;let r=e.indexOf(t);return r===-1?e[0]:e[(r+n+e.length)%e.length]}var Ml=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),Nl=function(e){return`/`+e},Pl={},Fl=function(e){return e.pathname.endsWith(`.css`)},Il=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},Ll=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Nl(t,n);let r=s(t),i=Fl(r);return Il(Pl,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:Ml,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Rl=J(`
        • `),zl=J(`

          `),Bl=J(``),Vl=J(`
          `),Hl=J(`

          `,1),Ul=J(`
        • `),Wl=J(`
            `),Gl=J(`

              You, the guest

              `,1),Kl=J(`

              `);function ql(e,t){et(t,!0);let n=typeof window<`u`&&typeof window.WebGL2RenderingContext==`function`,r=$(t,`summary`,3,null),i=$(t,`findings`,3,null),a=$(t,`runKey`,3,null),o=$(t,`direction`,3,0),s=$(t,`actor`,3,null),c=$(t,`diners`,19,()=>[]),l=$(t,`crew`,19,()=>[]),u=$(t,`freeze`,3,null),d=$(t,`reducedMotion`,3,!1),f=I(void 0),p=I(void 0),m=I(void 0),h=I(void 0),g=null,_=I(!1),v=I(`flat`),y=I(!1),b=I(0),x=I(``),S=j(()=>!!r()),C=j(()=>us(r()&&r().ring,r()||{})),w=j(()=>r()&&r().waiting?Dl(r().waiting.kind,Tl(r().waiting),K(b),{reducedMotion:d()}):null),ee=j(()=>K(w)?K(w).level:0),te=j(()=>({...K(C),waitLevel:K(ee)})),ne=j(()=>ps(r(),i())),re=j(()=>Rc(K(C))),ie=j(()=>wl(r()&&r().waiting)),ae=j(()=>ys(c())),oe=j(()=>K(S)&&bs({webgl:n,threeFailed:K(y)})===`3d`);ar(()=>{if(!K(S))return;let e=window.setInterval(()=>{document.visibilityState===`visible`&&L(b,K(b)+1)},3e3);return()=>window.clearInterval(e)}),ar(()=>{let e=K(ee);Oi(()=>{L(x,e&&K(w)?`The bot says: ${K(w).text}`:``,!0)})});let se=``;ar(()=>{let e=K(w)?K(w).text:``;Oi(()=>{e!==se&&(se=e,e&&!d()&&K(m)&&(delete K(m).dataset.pop,K(m).offsetWidth,K(m).dataset.pop=``))})}),ar(()=>{if(!K(oe))return;let e=d(),n=!1,r=null;return Ll(async()=>{let{mountKitchen:e}=await import(`./restaurant-DuFRqeba.js`);return{mountKitchen:e}},[]).then(({mountKitchen:i})=>{if(!n)try{L(v,`3d`),r=i(K(p),Oi(()=>We(K(te))),{root:K(f),reducedMotion:e,diners:Oi(()=>K(ae).length),onOpen:()=>t.onopen(),onBook:()=>t.onbook(),onCrew:e=>t.oncrew(e)}),r.setCrew(Oi(()=>We(l()))),g=r,L(_,!0)}catch{r&&r.dispose(),r=null,L(v,`flat`),L(y,!0)}}).catch(()=>{n||(L(v,`flat`),L(y,!0))}),()=>{n=!0,r&&r.dispose(),g=null,L(_,!1),L(v,`flat`)}});let ce=null;ar(()=>{let e=We(K(te)),t=We(l()),n=a(),r=K(_);Oi(()=>{let i=ce!==null&&ce!==n;ce=n,g&&r&&(g.update(e,{swap:i,direction:i?o():0}),g.setCrew(t))})});function le(e){return g?g.zoom(e):Promise.resolve()}function ue(){g&&g.react()}function de(){return!!g}function fe(){K(h)&&K(h).focus()}function pe(){ue(),t.onopen()}var me={zoom:le,react:ue,hasGl:de,focusBot:fe},he=Kl(),T=R(he),ge=e=>{var n=Gl(),a=z(n),o=R(a),c=R(o);Da(c,21,()=>K(C).stages,e=>e.stage,(e,t)=>{var n=Rl(),r=V(R(n)),i=B(r,!0),a=V(r,2),o=B(a,!0),s=B(V(a));k(n),H((e,r)=>{Ia(n,1,`stage ${K(t).status??``}`),Q(n,`data-stage`,K(t).stage),Q(n,`data-status`,K(t).status),Q(n,`data-angle`,K(t).angle),X(i,e),X(o,r),X(s,`, ${_s[K(t).status]??``}`)},[()=>Ac(K(t).stage).label,()=>So(K(t).stage)]),Y(e,n)}),k(c);var l=V(c,2),d=R(l),f=B(d,!0),p=V(d),g=B(p,!0),_=B(V(p),!0);k(l);var v=V(l,2),y=B(v,!0),b=V(v,2),x=e=>{var t=zl(),n=B(t);H((e,t)=>X(n,`${K(re).label??``}: ${e??``} → ${t??``}`),[()=>Ac(K(re).from).label,()=>Ac(K(re).to).label]),Y(e,t)};Z(b,e=>{K(re)&&e(x)}),k(o);var S=V(o,2),ee=V(R(S),2),te=e=>{var n=Hl(),i=z(n),a=R(i),o=B(a,!0),c=B(V(a,2),!0);k(i);var l=V(i,2),d=e=>{var n=Vl(),i=R(n),a=e=>{var n=Bl(),r=B(n,!0);H(()=>X(r,Es)),q(`click`,n,e=>t.onsketch(e.currentTarget)),Y(e,n)};Z(i,e=>{r().waiting.sketch&&e(a)}),Uo(V(i,2),{get actor(){return s()},source:`guest`,get freeze(){return u()},nameAction:`guest-freeze-name`,get onfreeze(){return t.onfreeze},get onname(){return t.onfreezename}}),k(n),Y(e,n)};Z(l,e=>{r().waiting.kind===`freeze`&&e(d)}),H(()=>{X(o,K(ie).ask),X(c,K(ie).note)}),Y(e,n)};Z(ee,e=>{K(ie)&&e(te)}),k(S);var oe=V(S,2),se=e=>{var t=Wl();Da(t,21,()=>K(ae),ya,(e,t)=>{var n=Ul(),r=B(n);H(()=>X(r,`${K(t).name??``}${K(t).note?`, ${K(t).note}`:``}`)),Y(e,n)}),k(t),H(e=>Q(t,`aria-label`,e),[()=>`Diners, ${vs.toLowerCase()}`]),Y(e,t)};Z(oe,e=>{K(ae).length&&e(se)}),k(a);var ce=V(a,2),le=R(ce);fo(le,e=>L(h,e),()=>K(h));var ue=V(le),de=B(ue,!0);fo(ue,e=>L(m,e),()=>K(m)),k(ce),H((e,t,n)=>{X(f,K(ne).board),X(g,K(ne).title),X(_,K(ne).note),Q(v,`data-back`,K(re)?`true`:`false`),X(y,e),Q(S,`data-asking`,K(ie)?`true`:`false`),Q(ce,`data-at`,K(C).botStage),Q(le,`aria-label`,t),Q(ue,`hidden`,!K(w)),Q(ue,`data-level`,n),X(de,K(w)?K(w).text:``)},[()=>Lc(K(C)),()=>hs(r(),i()),()=>K(w)?String(K(w).level):void 0]),q(`click`,le,pe),Y(e,n)};Z(T,e=>{K(S)&&e(ge)});var E=V(T,2);fo(E,e=>L(p,e),()=>K(p));var _e=B(V(E,2),!0);return k(he),fo(he,e=>L(f,e),()=>K(f)),H(()=>{Q(he,`hidden`,!K(S)),Q(he,`data-bot`,K(_)?`3d`:`css`),Q(he,`data-ring`,K(v)),X(_e,K(x))}),Y(e,he),tt(me)}Wi([`click`]);var Jl=`a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`;function Yl(e,t,n){return e<=0?!1:t>.5||e>n*.25}function Xl(e){return e>=0?e:-Math.sqrt(-e)*2}function Zl(e,t){if(e.key!==`Tab`)return!1;let n=[...t.querySelectorAll(Jl)].filter(e=>!e.closest(`[hidden]`));if(!n.length)return!1;let r=n[0],i=n[n.length-1],a=t.ownerDocument.activeElement;return e.shiftKey&&(a===r||!t.contains(a))?(i.focus(),e.preventDefault(),!0):!e.shiftKey&&a===i&&(r.focus(),e.preventDefault(),!0)}var Ql=J(` `),$l=J(`
              `),eu=J(`

              `,1),tu=J(``);function nu(e,t){et(t,!0);let n=$(t,`visible`,3,!1),r=$(t,`opened`,3,!1),i=$(t,`summary`,3,null),a=$(t,`findings`,3,null),o=$(t,`projectName`,3,``),s=$(t,`actor`,3,null),c=$(t,`freeze`,3,null),l=$(t,`closeButton`,15,null),u,d=j(()=>i()?fs(i(),a()):null);function f(e){e.key===`Escape`?(e.preventDefault(),t.onclose()):e.key===`ArrowRight`?(e.preventDefault(),t.onstep(1)):e.key===`ArrowLeft`?(e.preventDefault(),t.onstep(-1)):Zl(e,u)}function p(e){!e.target.closest(`[data-action]`)&&!e.target.closest(`.room-card`)&&t.onreact()}var m=tu(),h=R(m),g=R(h),_=e=>{var n=eu(),r=z(n),a=B(r,!0),l=V(r,2),u=B(l,!0),f=V(l,2),p=R(f),m=B(p,!0),h=V(p);k(f);var g=V(f,2);Da(g,21,()=>zs(i()),ya,(e,t)=>{var n=Ql(),r=B(n,!0);H(()=>X(r,K(t))),Y(e,n)}),k(g);var _=V(g,2),v=e=>{var n=$l(),r=R(n),a=B(r,!0),o=V(r,2),l=e=>{Uo(e,{get actor(){return s()},source:`room`,get freeze(){return c()},nameAction:`room-freeze-name`,get onfreeze(){return t.onfreeze},get onname(){return t.onfreezename}})};Z(o,e=>{i().waiting.kind===`freeze`&&e(l)}),k(n),H(e=>X(a,e),[()=>Co(i().waiting)]),Y(e,n)};Z(_,e=>{i().waiting&&e(v)}),H(()=>{X(a,o()),X(u,i().task||i().runId),X(m,K(d).title),X(h,` · ${K(d).note??``}`)}),Y(e,n)};Z(g,e=>{n()&&i()&&e(_)}),k(h);var v=V(h,2),y=R(v),b=V(y,2);fo(b,e=>l(e),()=>l());var x=V(b,2);k(v),k(m),fo(m,e=>u=e,()=>u),H(e=>{Q(m,`hidden`,!n()),Q(m,`data-open`,e)},[()=>n()?String(r()):void 0]),q(`keydown`,m,f),q(`click`,m,p),q(`click`,y,()=>t.onstep(-1)),q(`click`,b,function(...e){t.onclose?.apply(this,e)}),q(`click`,x,()=>t.onstep(1)),Y(e,m),tt()}Wi([`keydown`,`click`]);var ru=J(`

              `);function iu(e,t){et(t,!0);let n=$(t,`className`,3,`sheet`),r=$(t,`open`,3,!1),i=$(t,`opener`,3,null),a,o=I(!1),s=I(void 0),c=I(!1),l=null,u=0;ar(()=>{let e=r();Oi(()=>e?d():f())});function d(){window.clearTimeout(u),L(o,!0),requestAnimationFrame(()=>{r()&&(a.offsetHeight,L(s,`true`),a.focus())})}function f(){if(K(s)!==`true`){L(o,!1);return}L(s,`false`),a.style.removeProperty(`transform`);let e=()=>{window.clearTimeout(u),r()||L(o,!1)};u=window.setTimeout(e,600),a.addEventListener(`transitionend`,e,{once:!0}),i()&&i().isConnected&&i().focus()}function p(e){e.key===`Escape`?(e.preventDefault(),t.onclose()):Zl(e,a)}function m(e){e.pointerType!==`mouse`&&(l={startY:e.clientY,lastY:e.clientY,lastTime:e.timeStamp,velocity:0},L(c,!0),e.currentTarget.setPointerCapture(e.pointerId))}function h(e){if(!l)return;let t=Math.max(1,e.timeStamp-l.lastTime);l.velocity=(e.clientY-l.lastY)/t,l.lastY=e.clientY,l.lastTime=e.timeStamp,a.style.transform=`translateY(${Xl(e.clientY-l.startY).toFixed(1)}px)`}function g(){if(!l)return;let e=Yl(l.lastY-l.startY,l.velocity,a.offsetHeight);l=null,L(c,!1),e?t.onclose():a.style.removeProperty(`transform`)}var _=ru(),v=R(_),y=V(v,2),b=R(y),x=V(R(b),2),S=B(x,!0),C=V(x,2);k(b),Pa(V(b,2),()=>t.children),k(y),fo(y,e=>a=e,()=>a),k(_),H(()=>{Q(_,`id`,t.id),Ia(_,1,pa(n())),Q(_,`aria-labelledby`,t.titleId),Q(_,`hidden`,!K(o)),Q(_,`data-open`,K(s)),Q(_,`data-dragging`,K(c)?`true`:void 0),Q(x,`id`,t.titleId),X(S,t.title),Q(C,`aria-label`,t.closeLabel)}),q(`keydown`,_,p),q(`click`,v,function(...e){t.onclose?.apply(this,e)}),q(`pointerdown`,b,m),q(`pointermove`,b,h),q(`pointerup`,b,g),Ui(`pointercancel`,b,g),q(`click`,C,function(...e){t.onclose?.apply(this,e)}),Y(e,_),tt()}Wi([`keydown`,`click`,`pointerdown`,`pointermove`,`pointerup`]);var au=J(`

              There is no order sketch for this Goal.

              `),ou=J(` Recommended`,1),su=J(``),cu=J(``),lu=J(`

              `,1),uu=J(`
              `);function du(e,t){et(t,!0);let n=$(t,`detail`,3,null),r=$(t,`sketchKey`,3,null),i=$(t,`view`,3,null),a=$(t,`frames`,19,()=>[]),o=$(t,`actor`,3,null),s=$(t,`freeze`,3,null),c=j(()=>As(n())),l=j(()=>K(c).some(e=>e.view===i())?i():js(n())),u=I(an({})),d={};ar(()=>{r(),L(u,{},!0)});function f(e,n){let r=sc(e,K(c).map(e=>e.view),n);r&&(t.onview(r),d[r].focus())}var p=uu(),m=R(p),h=e=>{Y(e,au())},g=e=>{var r=lu(),i=z(r),p=B(i,!0),m=V(i,2);Da(m,21,()=>K(c),e=>e.view,(e,n)=>{var r=su(),i=R(r,!0),a=V(i),o=e=>{var t=ou(),n=z(t,!0);n.nodeValue=` `,Ee(),Y(e,t)};Z(a,e=>{K(n).recommended&&e(o)}),k(r),fo(r,(e,t)=>d[t.view]=e,e=>d?.[e.view],()=>[K(n)]),H(()=>{Q(r,`id`,`sketch-tab-${K(n).view??``}`),Q(r,`aria-selected`,K(n).view===K(l)?`true`:`false`),Q(r,`tabindex`,K(n).view===K(l)?0:-1),Q(r,`data-sketch-view`,K(n).view),Q(r,`title`,K(n).reason||``),X(i,Ds[K(n).view])}),q(`click`,r,()=>t.onview(K(n).view)),q(`keydown`,r,e=>f(e,K(n).view)),Y(e,r)}),k(m);var h=V(m,2);Da(V(R(h),2),16,a,e=>e,(e,n)=>{var r=cu();H((e,t)=>{Q(r,`title`,e),Q(r,`data-view`,n),Q(r,`data-loaded`,K(u)[n]?`true`:void 0),Q(r,`src`,t),Q(r,`hidden`,n!==K(l))},[()=>Ms(n),()=>t.urlFor(n)]),Ui(`load`,r,()=>L(u,{...K(u),[n]:!0},!0)),Vi(r),Y(e,r)}),k(h);var g=V(h,2),_=R(g),v=B(_,!0);Uo(V(_,2),{get actor(){return o()},source:`sketch`,get freeze(){return s()},nameAction:`sketch-freeze-name`,get onfreeze(){return t.onfreeze},get onname(){return t.onfreezename}}),k(g),H(e=>{X(p,e),Q(h,`aria-labelledby`,`sketch-tab-${K(l)??``}`),Q(h,`aria-busy`,K(u)[K(l)]?void 0:`true`),Q(h,`data-loaded`,K(u)[K(l)]?`true`:`false`),X(v,Os)},[()=>ks(n().flowCounts)]),Y(e,r)};Z(m,e=>{K(c).length?e(g,-1):e(h)}),k(p),Y(e,p),tt()}Wi([`click`,`keydown`]);var fu={passed:`Passed`,done:`Served`,back:`Sent back`,cooking:`Cooking`,escalated:`Escalated`,cancelled:`Cancelled`},pu=[`cooking`,`back`,`passed`,`done`,`escalated`,`cancelled`];function mu(e){return e?e.state===`CANCELLED`?`cancelled`:e.state===`ESCALATED`||e.verdict===`ESCALATE`?`escalated`:e.verdict===`PASS`?`passed`:e.state===`REPORTED`||e.state===`DELIVERED`?`done`:e.verdict===`ITERATE`?`back`:`cooking`:`cooking`}function hu(e){let t={};for(let n of e||[]){let e=mu(n);t[e]=(t[e]||0)+1}return pu.filter(e=>t[e]).map(e=>`${t[e]} ${fu[e].toLowerCase()}`).join(` · `)}var gu={passed:`Passed`,done:`Served`,back:`Sent back`,cooking:`Cooking`,escalated:`Escalated`,cancelled:`Void`};function _u(e){let t=wo(e.elapsedMs);return[e.worktree?`worktree`:``,e.iteration>1?`iteration ${e.iteration}`:``,t===`just now`?t:`${t} ago`].filter(Boolean).join(` · `)}function vu(e){let t={};for(let n of e||[])t[mu(n)]=(t[mu(n)]||0)+1;return pu.filter(e=>t[e]).map(e=>({outcome:e,count:t[e],label:fu[e].toLowerCase()}))}function yu(e){let t=e&&e.waiting?Co(e.waiting):So(e&&e.stage)||`Between stations`;return`${e&&e.task||`Another order`} · ${t}`}function bu(e,t){let n=(e||[]).find(e=>e.id===t||(e.worktreeRuns||[]).some(e=>e.worktreeId===t));return n?[n.run?{id:n.id,run:n.run}:null,...(n.worktreeRuns||[]).filter(e=>e.worktreeId).map(e=>({id:e.worktreeId,run:e}))].filter(Boolean).filter(e=>e.id!==t&&!Oo.has(e.run.state)):[]}function xu(e,t){let n=Array.isArray(e)?e:[];return[...(t||[]).filter(({run:e})=>e&&!n.some(t=>t.runId===e.runId)).map(({run:e})=>({runId:e.runId,task:e.task,state:e.state,iteration:e.iteration||1,verdict:null,current:!1,worktree:!!e.worktreeId,elapsedMs:e.elapsedMs||0})),...n]}var Su=J(`

              `),Cu=J(`
            1. `),wu=J(`

              `,1),Tu=J(`

              Leafing through the pages…

              `),Eu=J(`

              `),Du=J(`

              No orders written yet.

              `),Ou=J(`On the pass now `,1),ku=J(`
            2. `),Au=J(`
                `),ju=J(`

                The kitchen's

                Order book

                Newest orders first

                `);function Mu(e,t){et(t,!0);let n=$(t,`runs`,19,()=>[]),r=$(t,`projectName`,3,``),i=$(t,`loading`,3,!1),a=$(t,`error`,3,null),o=j(()=>Array.isArray(n())?n():[]),s=j(()=>!i()&&!a()&&K(o).length>0);var c=ju(),l=R(c),u=R(l),d=V(R(u),3),f=e=>{var t=Su(),n=B(t,!0);H(()=>X(n,r())),Y(e,t)};Z(d,e=>{r()&&e(f)});var p=V(d,2),m=e=>{var t=wu(),n=z(t),r=B(n,!0),i=V(n,2);Da(i,21,()=>vu(K(o)),e=>e.outcome,(e,t)=>{var n=Cu(),r=R(n),i=B(r,!0),a=V(r);k(n),H(()=>{Q(n,`data-outcome`,K(t).outcome),X(i,K(t).count),X(a,` ${K(t).label??``}`)}),Y(e,n)}),k(i),H(e=>X(r,e),[()=>hu(K(o))]),Y(e,t)};Z(p,e=>{K(s)&&e(m)}),Ee(2),k(u);var h=V(u,2),g=R(h),_=e=>{Y(e,Tu())},v=e=>{var t=Eu(),n=B(t);H(()=>X(n,`Could not read the order book: ${a()??``}`)),Y(e,t)},y=e=>{Y(e,Du())},b=e=>{var t=Au();Da(t,21,()=>K(o),ya,(e,t,n)=>{let r=j(()=>mu(K(t)));var i=ku(),a=R(i),s=B(a),c=V(a,2),l=R(c),u=B(l,!0),d=V(l),f=R(d),p=e=>{var t=Ou(),n=V(z(t),1,!0);n.nodeValue=` · `,Y(e,t)};Z(f,e=>{K(t).current&&e(p)});var m=V(f,1,!0);k(d),k(c);var h=V(c,2),g=B(h,!0);k(i),H(e=>{Q(i,`data-outcome`,K(r)),Q(i,`aria-current`,K(t).current?`true`:void 0),X(s,`No. ${K(o).length-n}`),X(u,K(t).task||`Untitled order`),X(m,e),Q(h,`title`,fu[K(r)]),X(g,gu[K(r)])},[()=>_u(K(t))]),Y(e,i)}),k(t),Y(e,t)};Z(g,e=>{i()?e(_):a()?e(v,1):K(o).length?e(b,-1):e(y,2)}),k(h),k(l),k(c),Y(e,c),tt()}var Nu=class extends Error{constructor(e,{status:t=0,code:n=null,fix:r=null}={}){super(e),this.name=`StudioApiError`,this.status=t,this.code=n,this.fix=r}};async function Pu(e,{method:t=`GET`,body:n}={}){let r={method:t,credentials:`same-origin`,headers:{accept:`application/json`}};n!==void 0&&(r.headers[`content-type`]=`application/json`,r.body=JSON.stringify(n));let i;try{i=await fetch(e,r)}catch{throw new Nu("Studio is not reachable. Is `ael studio` still running?")}let a=null;try{a=await i.json()}catch{a=null}if(!i.ok||!a||a.ok===!1)throw new Nu(a&&a.error||`Studio answered ${i.status}`,{status:i.status,code:a&&a.code,fix:a&&a.fix});return a}var Fu=e=>encodeURIComponent(String(e));async function Iu(){return(await Pu(`/api/projects`)).projects}async function Lu(e,t){return(await Pu(`/api/projects/${Fu(e)}/runs/${Fu(t)}`)).detail}function Ru(e,t,n,r=null){let i=`/api/projects/${Fu(e)}/runs/${Fu(t)}/goal/diagram?view=${encodeURIComponent(n)}`;return r?`${i}&rev=${encodeURIComponent(r)}`:i}async function zu(){let{actor:e,actorValid:t,diners:n=[]}=await Pu(`/api/me`);return{actor:e,actorValid:t,diners:Array.isArray(n)?n:[]}}async function Bu(e){let{actor:t,actorValid:n,diners:r=[]}=await Pu(`/api/me`,{method:`PUT`,body:{actor:e}});return{actor:t,actorValid:n,diners:Array.isArray(r)?r:[]}}async function Vu(e,t,n){return Pu(`/api/projects/${Fu(e)}/runs/${Fu(t)}/goal/freeze`,{method:`POST`,body:{expectedHash:n}})}async function Hu(e){return(await Pu(`/api/projects/${Fu(e)}/runs`)).runs}var Uu=J(`

                AEL Studio

                `,1);function Wu(e,t){et(t,!0);let n={connecting:`Connecting…`,live:`Live`,reconnecting:`Reconnecting…`,offline:`Offline`},r=I([]),i=I(!1),a=I(null),o=I(null),s=I(null),c=I({actor:null,actorValid:!1,diners:[]}),l=I(`formatted`),u=I(``),d=I(``),f=I(`connecting`),p=I(!1),m=I(!1),h=I({source:null,phase:`idle`}),g=I(null),_=I(null),v=I({runs:[],loading:!1,error:null}),y=I({key:null,view:null,frames:[],ids:null}),b=an({visible:!1,opened:!1}),x=I(void 0),S=I(0),C=I(null),w=null,ee=0,te=0,ne=null,re=null,ie=!1,ae=!1,oe=null,se,ce,le=I(null),ue=I(null),de=I(null),fe,pe=I(null),me=j(()=>K(c).actorValid?K(c).actor:null),he=j(()=>K(r).flatMap(e=>[e,...(e.worktreeRuns||[]).filter(e=>e.worktreeId).map(t=>({id:t.worktreeId,name:`${e.name} · worktree`,state:ko(t),run:t}))])),T=j(()=>K(he).find(e=>e.id===K(a))||null),ge=j(()=>K(T)&&K(T).run&&K(o)?{project:K(T),detail:K(o)}:null),E=j(()=>K(ge)||(K(T)&&K(T).run&&!K(o)&&!K(s)?K(C):null)),_e=j(()=>K(E)?bu(K(r),K(a)).map(({id:e,run:t})=>({id:e,label:yu(t),model:ye(t)})):[]),ve=j(()=>K(y).ids?e=>Ru(K(y).ids.projectId,K(y).ids.runId,e,K(y).ids.goalHash):()=>``);ar(()=>{K(ge)?L(C,K(ge)):K(T)&&K(T).run&&!K(s)||L(C,null)}),ar(()=>{K(E)||L(g,null)}),ar(()=>{document.body.dataset.sheet=K(g)?`open`:`closed`}),ar(()=>{K(o),K(T),Oi(Le)});function ye(e){let t=us(e.ring,e);return t.waitLevel=e.waiting?El(Tl(e.waiting)):0,t}function be(e){let t=e&&e.run;return t?[e.id,t.runId,t.state,t.updatedAt,t.stage,t.waiting&&t.waiting.kind].join(`|`):null}function xe(){return K(i)?K(T)?K(T).state===`missing`?`This project folder is missing.`:K(T).run?K(s)?`Could not load this Run: ${K(s)}`:`Loading Run…`:`No active Run in this project.`:K(r).length?`Pick a project to see its Run.`:`No projects yet.`:`Loading projects…`}function Se(e){return new Promise(t=>window.setTimeout(t,e))}function D(e,t){L(_,t||null),L(g,e,!0)}function Ce(){L(g,null)}function O(){se&&(delete se.dataset.enter,se.offsetWidth,se.dataset.enter=``)}async function we({enter:e=!1}={}){let t=K(T);w=be(t);let n=++ee;if(!t||!t.run)L(o,null),L(s,null);else{try{let e=await Lu(t.id,t.run.runId);if(n!==ee)return;L(o,e),L(s,null)}catch(e){if(n!==ee)return;L(o,null),L(s,e.message,!0)}await Ci(),e&&!ce.hasGl()&&O(),ne&&ne===K(a)&&K(o)&&(ne=null,Be(null))}}function Te(e){L(r,Array.isArray(e)?e:[]),L(i,!0);let t=K(a);if(!K(T)){let e=To(K(r))[0];L(a,e?e.id:null,!0)}let n=t!==K(a);(n||be(K(T))!==w)&&(n&&L(o,null),we({enter:n||!K(o)}))}function Ee(e,{direction:t=0}={}){if(!e||e===K(a))return;L(S,t,!0),L(a,e,!0),L(o,null),L(s,null),L(u,``);let n=new URL(window.location.href);n.searchParams.set(`project`,e),window.history.replaceState(null,``,n),we({enter:!0})}async function De(){try{Te(await Iu())}catch(e){L(d,e.message,!0)}}function Oe(e){return e.code===`GOAL_DRAFT_CONFLICT`?`The Goal changed since you opened it. The new draft is shown; read it and freeze again.`:e.fix?`${e.message}. ${e.fix}`:e.message}async function ke(e,t,n){let r=await Vu(e,t,n);L(u,r.alreadyFrozen?`This Goal was already frozen in the agent host.`:`Goal frozen as ${K(c).actor}.`,!0)}async function Ae(e,t){if(K(h).phase===`idle`){L(h,{source:e,phase:`busy`});try{await t(),L(h,{source:e,phase:`done`}),await Se(K(m)?0:650)}catch(e){L(h,{source:null,phase:`idle`}),L(u,Oe(e),!0)}await De(),await we(),L(h,{source:null,phase:`idle`})}}async function je(e,t){let n=K(T),r=K(o);!n||!r||!r.goalHash?L(u,`There is no Goal draft to freeze. Reload the page.`):await Ae(e,async()=>{t!==void 0&&L(c,await Bu(t)),await ke(n.id,r.summary.runId,r.goalHash)})}async function Me(e,t){if(Ee(e),!K(me)){L(u,`Type your name under the Goal to freeze it.`);return}let n=t.waiting&&t.waiting.goalHash;n?await Ae(`list:${e}`,()=>ke(e,t.runId,n)):L(u,`There is no Goal draft to freeze. Reload the page.`)}function Ne(e){Ee(e),L(u,`Type your name under the Goal to freeze it.`)}function Pe(){K(le)&&K(le).focus()}function Fe(){return!K(T)||!K(o)||!As(K(o)).length?null:{project:K(T),detail:K(o),key:[K(T).id,K(o).summary.runId,K(o).goalHash].join(`|`)}}function Ie(){let e=Fe();if(!e)return!1;if(e.key!==K(y).key){let t=js(e.detail);L(y,{key:e.key,view:t,frames:[t],ids:{projectId:e.project.id,runId:e.detail.summary.runId,goalHash:e.detail.goalHash}})}else K(y).frames.includes(K(y).view)||L(y,{...K(y),frames:[...K(y).frames,K(y).view]});return!0}function Le(){let e=Fe();e?(K(g)===`sketch`||Ns(e.detail.summary)||e.key===K(y).key)&&Ie():K(g)===`sketch`&&Ce()}function Re(){let e=Fe();e&&re!==e.key&&(re=e.key,(window.requestIdleCallback||(e=>window.setTimeout(e,200)))(()=>{if(K(y).key!==e.key)return;let t=As(e.detail).map(e=>e.view);L(y,{...K(y),frames:[...K(y).frames,...t.filter(e=>!K(y).frames.includes(e))]})}))}function ze(e){Fe()&&L(y,{...K(y),view:e,frames:K(y).frames.includes(e)?K(y).frames:[...K(y).frames,e]})}function Be(e){!K(o)||!As(K(o)).length?L(u,`There is no order sketch for this Goal right now.`):ie||(Ie(),D(`sketch`,e),Re())}function Ve(e,t){e===K(a)&&K(o)?Be(t):(ne=e,Ee(e))}function He(){Ce(),Pe()}async function Ue(e){let t=K(T);if(!t||K(g))return;let n=++te;L(v,{runs:[],loading:!0,error:null}),D(`orders`,e);try{let e=await Hu(t.id);n===te&&L(v,{runs:xu(e,bu(K(r),K(a))),loading:!1,error:null})}catch(e){n===te&&L(v,{runs:[],loading:!1,error:e.message})}}async function We(){ie||ae||!K(E)||(ae=!0,ie=!0,L(x,`in`),b.visible=!0,await Ci(),K(pe)&&K(pe).offsetWidth,b.opened=!0,K(pe)&&K(pe).focus(),await ce.zoom(`in`),ae=!1)}async function Ge(){if(!ie||ae)return;ae=!0,b.opened=!1;let e=ce.zoom(`out`);await Se(K(m)?0:260),b.visible=!1,L(x,void 0),ie=!1,ce.focusBot(),await e,ae=!1}function Ke(e){if(ae)return;let t=jl(Al(K(r)),K(a),e);t&&t!==K(a)&&Ee(t,{direction:e})}function qe(){Ge().then(Pe)}function Je(e){Ee(e),oe&&oe.matches&&L(p,!1)}function Ye(e){return!!(e&&e.closest&&e.closest(`input, textarea, select, [contenteditable="true"]`))}function Xe(e){e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey||Ye(e.target)||(e.key===`Escape`&&K(p)?(L(p,!1),fe.focus()):ie||K(g)||!K(E)||(e.key===`o`||e.key===`O`?(e.preventDefault(),Ue(K(de))):(e.key===`d`||e.key===`D`)&&(e.preventDefault(),D(`details`,K(ue)))))}function Ze(){let e=new EventSource(`/api/events`);return e.addEventListener(`open`,()=>{L(f,`live`)}),e.addEventListener(`projects`,e=>{L(d,``),L(f,`live`);let t;try{t=JSON.parse(e.data)}catch{return}Te(t.projects)}),e.addEventListener(`error`,()=>{let t=e.readyState===EventSource.CLOSED;L(f,t?`offline`:`reconnecting`,!0),L(d,t?"Lost the Studio connection. Start `ael studio` again, then reload this page.":`Reconnecting to Studio…`,!0)}),e}ho(()=>{L(a,new URLSearchParams(window.location.search).get(`project`),!0),oe=window.matchMedia(`(max-width: 899px)`);let e=window.matchMedia(`(prefers-reduced-motion: reduce)`);L(m,e.matches,!0);let t=()=>{L(m,e.matches,!0)};e.addEventListener(`change`,t);let n=window.setInterval(()=>{document.visibilityState===`visible`&&De()},6e4),r=null,i=!1;return(async()=>{try{L(c,await zu())}catch{L(c,{actor:null,actorValid:!1,diners:[]})}await De(),i||(r=Ze())})(),()=>{i=!0,window.clearInterval(n),e.removeEventListener(`change`,t),r&&r.close()}});var Qe=Uu();Ui(`keydown`,cn,Xe);var A=z(Qe),$e=V(R(A),2);fo($e,e=>fe=e,()=>fe);var nt=V($e,2);Vo(nt,{get projects(){return K(r)},get loaded(){return K(i)}});var rt=V(nt,2),it=B(V(R(rt)),!0);k(rt);var at=V(rt,2),ot=B(at,!0);k(A);var st=V(A,2),ct=R(st);$o(V(R(ct),2),{get projects(){return K(r)},get loaded(){return K(i)},get selectedId(){return K(a)},get actor(){return K(me)},get freeze(){return K(h)},onselect:Je,onsketch:Ve,onfreeze:Me,onfreezename:Ne}),k(ct);var lt=V(ct,2),ut=R(lt),dt=B(ut,!0),ft=V(ut,2);{let e=j(()=>K(E)?K(E).detail.summary:null),t=j(()=>K(E)?K(E).detail.findings:null),n=j(()=>K(E)?`${K(E).project.id}|${K(E).detail.summary.runId}`:null),r=j(()=>K(c).diners||[]);fo(ql(ft,{get summary(){return K(e)},get findings(){return K(t)},get runKey(){return K(n)},get direction(){return K(S)},get actor(){return K(me)},get diners(){return K(r)},get crew(){return K(_e)},get freeze(){return K(h)},get reducedMotion(){return K(m)},onopen:We,onbook:()=>Ue(null),oncrew:e=>Ee(e),onfreeze:e=>je(e),onfreezename:Pe,onsketch:Be}),e=>ce=e,()=>ce)}var pt=V(ft,2);{let e=j(()=>K(E)?K(E).detail.summary:null),t=j(()=>K(E)?K(E).project.name:``);Ks(pt,{get summary(){return K(e)},get actor(){return K(me)},get projectName(){return K(t)},get freeze(){return K(h)},onfreeze:(e,t)=>je(e,t),onsketch:Be,get actorInput(){return K(le)},set actorInput(e){L(le,e,!0)}})}var mt=V(pt,2),ht=B(mt,!0),gt=V(mt,2);fo(gt,e=>L(de,e),()=>K(de));var _t=V(gt,2);fo(_t,e=>L(ue,e),()=>K(ue));var vt=V(_t,2);{let e=j(()=>K(E)?K(E).detail.summary:null),t=j(()=>K(E)?K(E).detail.findings:null),n=j(()=>K(E)?K(E).project.name:``);nu(vt,{get visible(){return b.visible},get opened(){return b.opened},get summary(){return K(e)},get findings(){return K(t)},get projectName(){return K(n)},get actor(){return K(me)},get freeze(){return K(h)},onclose:Ge,onstep:Ke,onfreeze:e=>je(e),onfreezename:qe,onreact:()=>ce.react(),get closeButton(){return K(pe)},set closeButton(e){L(pe,e,!0)}})}k(lt),fo(lt,e=>se=e,()=>se),k(st);var yt=V(st,2);{let e=j(()=>K(g)===`sketch`);iu(yt,{id:`sketch-sheet`,className:`sheet sketch-sheet`,titleId:`sketch-title`,title:`Order sketch`,closeLabel:`Close order sketch`,get open(){return K(e)},get opener(){return K(_)},onclose:Ce,children:(e,t)=>{{let t=j(()=>K(E)?K(E).detail:null);du(e,{get detail(){return K(t)},get sketchKey(){return K(y).key},get view(){return K(y).view},get frames(){return K(y).frames},get urlFor(){return K(ve)},get actor(){return K(me)},get freeze(){return K(h)},onview:ze,onfreeze:e=>je(e),onfreezename:He})}},$$slots:{default:!0}})}var bt=V(yt,2);{let e=j(()=>K(g)===`orders`);iu(bt,{id:`orders-sheet`,className:`sheet orders-sheet`,titleId:`orders-title`,title:`Order book`,closeLabel:`Close order book`,get open(){return K(e)},get opener(){return K(_)},onclose:Ce,children:(e,t)=>{{let t=j(()=>K(T)?K(T).name:``);Mu(e,{get runs(){return K(v).runs},get projectName(){return K(t)},get loading(){return K(v).loading},get error(){return K(v).error}})}},$$slots:{default:!0}})}var xt=V(bt,2);{let e=j(()=>K(g)===`details`);iu(xt,{id:`details-sheet`,className:`sheet`,titleId:`details-title`,title:`Run details`,closeLabel:`Close details`,get open(){return K(e)},get opener(){return K(_)},onclose:Ce,children:(e,t)=>{{let t=j(()=>K(E)?K(E).detail:null);bc(e,{get detail(){return K(t)},get goalView(){return K(l)},onview:e=>L(l,e,!0)})}},$$slots:{default:!0}})}H((e,t)=>{Q($e,`aria-expanded`,K(p)?`true`:`false`),Q(rt,`data-state`,K(f)),X(it,n[K(f)]),Q(at,`hidden`,!K(d)),X(ot,K(d)),Q(ct,`data-open`,K(p)?`true`:`false`),Q(lt,`data-showing`,K(E)?`true`:`false`),Q(lt,`data-zoom`,K(x)),Q(ut,`hidden`,e),X(dt,t),X(ht,K(u)),Q(gt,`aria-expanded`,K(g)===`orders`?`true`:`false`),Q(gt,`hidden`,!K(E)),Q(_t,`aria-expanded`,K(g)===`details`?`true`:`false`),Q(_t,`hidden`,!K(E))},[()=>!!K(E),()=>K(E)?``:xe()]),q(`click`,$e,()=>L(p,!K(p))),q(`click`,gt,()=>Ue(K(de))),q(`click`,_t,()=>D(`details`,K(ue))),Y(e,Qe),tt()}Wi([`click`]),typeof window.WebGL2RenderingContext==`function`&&Ll(()=>import(`./restaurant-DuFRqeba.js`),[]).catch(()=>{}),oa(Wu,{target:document.body});export{go as A,Pc as C,Ic as D,ll as E,zc as O,bl as S,_l as T,Kc as _,Wc as a,Vc as b,nl as c,ul as d,dl as f,Bc as g,Gc as h,wc as i,es as k,yl as l,cl as m,kl as n,al as o,Oc as p,Ec as r,ol as s,Ol as t,ml as u,Fc as v,Mc as w,Ac as x,Rc as y}; \ No newline at end of file diff --git a/studio/app/assets/index-DRPjBiGr.css b/studio/app/assets/index-DRPjBiGr.css new file mode 100644 index 0000000..f37c85f --- /dev/null +++ b/studio/app/assets/index-DRPjBiGr.css @@ -0,0 +1 @@ +:root{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--brand:#fc6404;--brand-hover:#e75c04;--brand-deep:#833301;--brand-highlight:#fcaa72;--brand-text:#b94a00;--brand-soft:#fff0e5;--on-brand:#16171a;--surface-0:#ebe9e4;--surface-1:#f4f3f0;--surface-2:#fff;--surface-3:#f7f6f3;--line:#e3e1dc;--line-strong:#cfccc6;--faint:#a19f99;--muted:#6f6e6a;--text-2:#3c3d42;--text:#16171a;--ok:#1d7a00;--ok-fill:#29ab00;--ok-soft:#e8f5e2;--idle-highlight:#d9d7d2;--idle:#b9b7b1;--idle-deep:#8b8a86;--prop-paper:#fbfaf7;--prop-wood:#a8703c;--prop-metal:#8b8a86;--prop-box:#d6a66a;--prop-pencil:#f2b632;--plinth:#f3efe8;--plinth-base:#2a2b30;--bot-trim:#f6f3ee;--bot-visor:#121318;--bot-eye:#fff4e8;--bot-leaf:#6f8f3a;--bot-devil:#1b1a1e;--bot-devil-trim:#4a1d1f;--bot-devil-eye:#e2463c;--room-marble:#efeae2;--room-terracotta:#c0643a;--room-velvet:#6e1a1f;--room-velvet-sheen:#9c3a32;--chalk-board:#1f2a25;--chalk-frame:#7a5132;--chalk-frame-deep:#4f3320;--chalk-ink:#f2efe6;--chalk-soft:#b7c1b6;--chalk-accent:#f3b37c;--book-leather:#5b1d1f;--book-leather-deep:#3a1012;--book-stitch:#c9a46a;--book-gilt:#e6cc93;--book-paper:#f7f0df;--book-paper-edge:#e4d8bd;--book-gutter:#b8a684;--book-ink:#2a2017;--book-ink-soft:#6d5c49;--book-rule:#cfdbe8;--book-margin:#d97770;--book-stamp-pass:#2f7a35;--book-stamp-cook:#c2470f;--book-stamp-back:#a86400;--book-stamp-stop:#a8261e;--book-stamp-void:#7a6a58;--room-brass:#c9a35a;--kitchen-floor:#d39a6e;--kitchen-floor-back:#9c958c;--kitchen-wall:#efe3d2;--kitchen-tile:#f6efe4;--kitchen-trim:#6b4a32;--kitchen-counter:#8a5d3c;--kitchen-steel:#c3c5c9;--kitchen-iron:#2e2f34;--kitchen-mat:#ebe6dd;--backroom-tile:#eef1f3;--backroom-floor:#c9ced2;--light-backroom:#eaf2ff;--kitchen-flame:#ff7a2e;--kitchen-flame-core:#ffd36a;--kitchen-soup:#d98a3a;--kitchen-food:#b5532f;--diner-1:#4f7cc9;--diner-2:#3f9f8a;--diner-3:#8a63c7;--diner-4:#d1a33a;--diner-5:#c75b7a;--diner-6:#6b8f3a;--light-sky:#fff1df;--light-ground:#a8876a;--light-key:bisque;--light-fill:#dfe7f7;--light-now:#ffb070;--light-pendant:#ffc98a;--env-room:#eadccb;--env-light:#fff6ea;--env-warm:#ffcf9f;--kitchen-exposure:1;--kitchen-ambient:.6;--stage-top:#fbfaf8;--stage-bottom:#efede8;--warn:#9a6200;--warn-soft:#fbf1dc;--danger:#c4282d;--danger-text:#b4262b;--danger-soft:#fde9e9;--shadow:#16171a;--focus:#fc6404;--font:"Geist", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;--mono:"Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;--radius-control:6px;--radius-panel:12px;--radius-card:16px;--shadow-raised:0 6px 16px color-mix(in srgb, var(--shadow) 5%, transparent);--shadow-bot:0 3px 6px color-mix(in srgb, var(--brand) 22%, transparent);--halo-now:0 0 0 5px color-mix(in srgb, var(--brand) 15%, transparent);--shadow-panel:0 1px 2px color-mix(in srgb, var(--shadow) 6%, transparent), 0 12px 32px color-mix(in srgb, var(--shadow) 10%, transparent);--ease-out:cubic-bezier(.23, 1, .32, 1);--ease-in-out:cubic-bezier(.77, 0, .175, 1);--press:.16s;--enter:.22s;--exit:.18s}:root[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--brand-text:#ff9a4d;--brand-soft:#2a1a10;--surface-0:#0f1012;--surface-1:#16171a;--surface-2:#1d1e22;--surface-3:#26272c;--line:#33343a;--line-strong:#45464d;--faint:#6b6c73;--muted:#9a9aa2;--text-2:#c9c9cf;--text:#f2f1ee;--ok:#4ade80;--ok-fill:#3fbf5f;--idle-highlight:#7a7b82;--idle:#55565d;--idle-deep:#3a3b41;--prop-paper:#e9e7e2;--prop-wood:#9a6a3a;--prop-metal:#a3a3aa;--prop-box:#c4955c;--prop-pencil:#e0a92e;--plinth:#2b2c31;--plinth-base:#0e0f12;--kitchen-floor:#6e4a36;--kitchen-floor-back:#3a3632;--kitchen-wall:#54443a;--kitchen-tile:#8c7a68;--kitchen-trim:#3a271b;--kitchen-counter:#5a3a26;--kitchen-mat:#3a3a3e;--backroom-tile:#5e6368;--backroom-floor:#3b3f43;--light-backroom:#cfdcf0;--light-sky:#d8c3a8;--light-ground:#3a2c22;--light-pendant:#ffb463;--env-room:#2e2620;--kitchen-exposure:.95;--kitchen-ambient:.32;--stage-top:#1f2024;--stage-bottom:#141518;--ok-soft:#14261a;--warn:#e4a853;--warn-soft:#3a3018;--danger:#e5484d;--danger-text:#ff8f92;--danger-soft:#2e1a1b;--shadow:#000}@media (prefers-color-scheme:dark){:root:not([data-theme=light]){--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--brand-text:#ff9a4d;--brand-soft:#2a1a10;--surface-0:#0f1012;--surface-1:#16171a;--surface-2:#1d1e22;--surface-3:#26272c;--line:#33343a;--line-strong:#45464d;--faint:#6b6c73;--muted:#9a9aa2;--text-2:#c9c9cf;--text:#f2f1ee;--ok:#4ade80;--ok-fill:#3fbf5f;--idle-highlight:#7a7b82;--idle:#55565d;--idle-deep:#3a3b41;--prop-paper:#e9e7e2;--prop-wood:#9a6a3a;--prop-metal:#a3a3aa;--prop-box:#c4955c;--prop-pencil:#e0a92e;--plinth:#2b2c31;--plinth-base:#0e0f12;--kitchen-floor:#6e4a36;--kitchen-floor-back:#3a3632;--kitchen-wall:#54443a;--kitchen-tile:#8c7a68;--kitchen-trim:#3a271b;--kitchen-counter:#5a3a26;--kitchen-mat:#3a3a3e;--backroom-tile:#5e6368;--backroom-floor:#3b3f43;--light-backroom:#cfdcf0;--light-sky:#d8c3a8;--light-ground:#3a2c22;--light-pendant:#ffb463;--env-room:#2e2620;--kitchen-exposure:.95;--kitchen-ambient:.32;--stage-top:#1f2024;--stage-bottom:#141518;--ok-soft:#14261a;--warn:#e4a853;--warn-soft:#3a3018;--danger:#e5484d;--danger-text:#ff8f92;--danger-soft:#2e1a1b;--shadow:#000}}*,:before,:after{box-sizing:border-box}html{-webkit-text-size-adjust:100%;-moz-text-size-adjust:100%;text-size-adjust:100%}body{height:100vh;background:var(--surface-1);height:100dvh;color:var(--text);font:14px/1.5 var(--font);-webkit-font-smoothing:antialiased;flex-direction:column;margin:0;display:flex;overflow:hidden}h1,h2,h3,p,ul,ol,dl,dd,pre{margin:0}ul,ol{padding:0;list-style:none}code,pre{font-family:var(--mono);font-size:12.5px}a{color:var(--brand-text);text-underline-offset:2px}button,input{font:inherit;color:inherit}[hidden]{display:none!important}.visually-hidden{clip-path:inset(50%);white-space:nowrap;width:1px;height:1px;margin:-1px;position:absolute;overflow:hidden}.eyebrow{color:var(--muted);font:10.5px/1.2 var(--mono);letter-spacing:.12em;text-transform:uppercase}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}.appbar{z-index:10;border-bottom:1px solid var(--line);background:color-mix(in srgb,var(--surface-1) 78%,transparent);-webkit-backdrop-filter:blur(14px)saturate(1.4);backdrop-filter:blur(14px)saturate(1.4);flex-wrap:wrap;align-items:center;gap:10px 14px;min-height:56px;padding:10px 24px;display:flex;position:sticky;top:0}.brand{align-items:center;gap:10px;display:flex}.mark{background:radial-gradient(circle at 32% 28%,var(--brand-highlight) 0%,var(--brand) 45%,var(--brand-hover) 100%);width:30px;height:30px;box-shadow:var(--shadow-bot);border-radius:9px;justify-content:center;align-items:center;gap:4px;display:flex}.mark-eye{background:var(--on-brand);border-radius:2px;width:3.5px;height:9px}.title{letter-spacing:-.01em;white-space:nowrap;font-size:15px;font-weight:650}.title-sub{color:var(--muted);font-weight:500}.chips{flex-wrap:wrap;gap:6px;margin-left:auto;display:flex}.chip{border:1px solid var(--line);background:var(--surface-2);height:24px;color:var(--text-2);font-variant-numeric:tabular-nums;white-space:nowrap;transition:background-color var(--enter) var(--ease-out),border-color var(--enter) var(--ease-out),color var(--enter) var(--ease-out);border-radius:999px;align-items:center;gap:6px;padding:0 10px;font-size:12px;font-weight:550;display:inline-flex}.chip-working{background:var(--brand-soft);color:var(--brand-text);border-color:#0000}.chip-dot{background:radial-gradient(circle at 32% 28%,var(--brand-highlight) 0%,var(--brand) 60%);border-radius:50%;width:8px;height:8px}.chip-waiting{border-color:var(--brand);color:var(--brand-text);background:0 0}.live{color:var(--muted);font:500 10.5px/1 var(--mono);letter-spacing:.1em;text-transform:uppercase;white-space:nowrap;align-items:center;gap:6px;display:inline-flex}.live-dot{background:var(--faint);width:7px;height:7px;transition:background-color var(--enter) var(--ease-out);border-radius:50%}.live[data-state=live] .live-dot{background:var(--ok-fill)}.live[data-state=reconnecting] .live-dot{background:var(--warn)}.live[data-state=offline] .live-dot{background:var(--danger)}.connection{border-radius:var(--radius-control);background:var(--warn-soft);color:var(--warn);flex-basis:100%;padding:4px 10px;font-size:12.5px}.layout{flex:1;grid-template-columns:minmax(240px,300px) minmax(0,1fr);gap:16px;width:100%;max-width:1680px;min-height:0;margin:0 auto;padding:16px 20px 20px;display:grid;position:relative}.section-title{color:var(--muted);font:500 10.5px/1.2 var(--mono);letter-spacing:.12em;text-transform:uppercase;margin:0 0 8px 9px}.projects{min-height:0;padding-right:4px;overflow:auto}.projects-toggle{border:1px solid var(--line);background:var(--surface-2);cursor:pointer;height:30px;transition:background-color var(--press) ease,transform var(--press) var(--ease-out);border-radius:999px;align-items:center;padding:0 12px;font-size:12.5px;font-weight:600;display:none}.projects-toggle:active{transform:scale(.97)}.project-list{flex-direction:column;gap:2px;display:flex}.project-row{-webkit-tap-highlight-color:transparent;border-radius:var(--radius-panel);text-align:left;cursor:pointer;width:100%;transition:background-color var(--press) ease,border-color var(--press) ease,transform var(--press) var(--ease-out);background:0 0;border:1px solid #0000;grid-template-columns:auto minmax(0,1fr);grid-template-areas:"bot name""bot meta";align-items:center;column-gap:10px;padding:8px 9px;display:grid}.project-row[aria-current=true]{background:var(--surface-2);border-color:var(--line);box-shadow:var(--shadow-raised)}.project-row:active:not(:disabled){transform:scale(.97)}.row-name{text-overflow:ellipsis;white-space:nowrap;grid-area:name;font-weight:550;overflow:hidden}.project-row .row-meta{grid-area:meta}.row-meta{color:var(--muted);font-variant-numeric:tabular-nums;font-size:12.5px}.project[data-state=waiting] .row-meta{color:var(--brand-text);font-weight:550}.project[data-state=missing] .row-name{color:var(--faint)}.worktree-runs{border-left:1px solid var(--line);flex-direction:column;gap:2px;margin:2px 0 6px 30px;padding-left:10px;display:flex}.worktree-run{flex-direction:column;align-items:flex-start;display:flex}.worktree-row{-webkit-tap-highlight-color:transparent;border-radius:var(--radius-control);text-align:left;cursor:pointer;width:100%;transition:background-color var(--press) ease,border-color var(--press) ease,transform var(--press) var(--ease-out);background:0 0;border:1px solid #0000;grid-template-columns:auto minmax(0,1fr);align-items:center;column-gap:8px;padding:4px 8px;font-size:12.5px;display:grid}.worktree-row[aria-current=true]{background:var(--surface-2);border-color:var(--line)}.worktree-row:active:not(:disabled){transform:scale(.97)}.worktree-row .bot{grid-area:auto}.worktree-row .row-meta{grid-column:2}.list-freeze{height:28px;margin:2px 0 6px 32px;padding:0 10px;font-size:12.5px}.worktree-run .list-freeze{margin-left:24px}.worktree-task{color:var(--text-2);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.bot{background:radial-gradient(circle at 32% 28%,var(--brand-highlight) 0%,var(--brand) 38%,var(--brand-hover) 72%,var(--brand-deep) 100%);width:26px;height:26px;box-shadow:var(--shadow-bot);border-radius:50%;flex:none;grid-area:bot;display:inline-block;position:relative}.bot:before,.bot:after{content:"";background:var(--on-brand);border-radius:2px;width:11.5%;height:27%;position:absolute;top:34.6%}.bot:before{left:38.5%}.bot:after{left:57.7%}.bot-waiting{outline:2px solid var(--brand);outline-offset:3px}.bot-idle,.bot-missing{background:radial-gradient(circle at 32% 28%,var(--idle-highlight) 0%,var(--idle) 60%,var(--idle-deep) 100%);box-shadow:none}.bot-missing{opacity:.45}.worktree-row .bot{width:18px;height:18px}.worktree-row .bot-waiting{outline-offset:2px}.run{border:1px solid var(--line);border-radius:var(--radius-card);background:radial-gradient(120% 90% at 50% 45%,var(--stage-top) 0%,var(--stage-bottom) 100%);transform-origin:50% 100%;min-width:0;min-height:0;transition:transform .45s cubic-bezier(.32,.72,0,1);position:relative;overflow:hidden}body[data-sheet=open] .run{transform:scale(.985)}.run[data-enter]{animation:detail-in var(--enter) var(--ease-out)}.run[data-showing=false]{place-items:center;display:grid}.empty{color:var(--muted);text-align:center}.empty code{background:var(--surface-3);border-radius:4px;padding:1px 5px}.projects .empty{text-align:left;padding:16px 12px}.stage-head{z-index:3;border:1px solid color-mix(in srgb,var(--line) 70%,transparent);border-radius:var(--radius-panel);background:color-mix(in srgb,var(--surface-2) 70%,transparent);-webkit-backdrop-filter:blur(14px)saturate(1.3);backdrop-filter:blur(14px)saturate(1.3);max-width:min(460px,100% - 32px);box-shadow:var(--shadow-raised);flex-direction:column;gap:3px;padding:12px 14px;display:flex;position:absolute;top:16px;left:16px}.stage-head:empty{display:none}.stage-head .eyebrow{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.run-meta{color:var(--muted);font-variant-numeric:tabular-nums;font-size:12.5px}.run-task{letter-spacing:-.015em;overflow-wrap:anywhere;-webkit-line-clamp:2;-webkit-box-orient:vertical;font-size:16px;font-weight:650;line-height:1.3;display:-webkit-box;overflow:hidden}.stage-wait{flex-wrap:wrap;align-items:center;gap:8px;margin-top:6px;display:flex}.run-status{z-index:3;border-radius:var(--radius-panel);background:color-mix(in srgb,var(--surface-2) 80%,transparent);max-width:min(460px,100% - 160px);color:var(--text-2);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);padding:8px 12px;font-size:13px;position:absolute;bottom:16px;left:16px}.details-button{z-index:3;border:1px solid color-mix(in srgb,var(--line) 70%,transparent);background:color-mix(in srgb,var(--surface-2) 72%,transparent);cursor:pointer;-webkit-backdrop-filter:blur(14px)saturate(1.3);backdrop-filter:blur(14px)saturate(1.3);height:36px;box-shadow:var(--shadow-raised);transition:background-color var(--press) ease,transform var(--press) var(--ease-out);border-radius:999px;align-items:center;gap:8px;padding:0 8px 0 14px;font-weight:600;display:inline-flex;position:absolute;bottom:16px;right:16px}.details-button:active{transform:scale(.97)}.orders-button{left:16px;right:auto}.orders-sheet .sheet-panel{border-color:var(--book-leather-deep);background:var(--book-leather);width:min(980px,100%);box-shadow:inset 0 0 0 6px var(--book-leather),inset 0 0 0 7px var(--book-stitch),var(--shadow-panel)}.orders-sheet .sheet-handle{background:var(--book-stitch)}.orders-sheet .sheet-title{color:var(--book-gilt);letter-spacing:.02em;font-family:Iowan Old Style,Palatino Linotype,Palatino,Georgia,serif;font-size:17px;font-weight:600}.orders-sheet .sheet-close{border-color:var(--book-stitch);background:var(--book-leather-deep);color:var(--book-gilt)}.orders-body{overscroll-behavior:contain;min-height:0;padding:0 18px 22px;overflow:auto}.book{background:var(--book-paper);min-height:min(520px,70dvh);box-shadow:0 1px 0 var(--book-paper-edge),0 3px 0 var(--book-paper-edge),0 5px 0 var(--book-gutter);color:var(--book-ink);border-radius:6px;grid-template-columns:minmax(200px,.8fr) minmax(0,1.6fr);display:grid}.page{min-width:0;padding:26px 28px 30px;position:relative}.page-left{background:linear-gradient(to left,var(--book-gutter),transparent 9%),var(--book-paper);border-radius:6px 0 0 6px;flex-direction:column;gap:6px;display:flex}.page-right{background:linear-gradient(to right,var(--book-gutter),transparent 7%),linear-gradient(to right,transparent 58px,var(--book-margin) 58px 59px,transparent 59px),repeating-linear-gradient(to bottom,transparent 0 31px,var(--book-rule) 31px 32px),var(--book-paper);background-attachment:local;border-radius:0 6px 6px 0}.book-kicker{color:var(--book-ink-soft);margin:0;font:italic 15px/1.2 Iowan Old Style,Palatino Linotype,Palatino,Georgia,serif}.book-name{letter-spacing:-.01em;margin:0;font:600 34px/1.05 Iowan Old Style,Palatino Linotype,Palatino,Georgia,serif}.book-project{color:var(--book-ink-soft);font:500 11px/1.4 var(--mono);letter-spacing:.08em;text-transform:uppercase;margin:4px 0 14px}.tally{border-top:1px dashed var(--book-gutter);gap:6px;margin:8px 0 0;padding:14px 0 0;font:15px/1.3 Iowan Old Style,Palatino Linotype,Palatino,Georgia,serif;list-style:none;display:grid}.tally-count{min-width:28px;font-weight:700;display:inline-block}.tally [data-outcome=passed] .tally-count,.tally [data-outcome=done] .tally-count{color:var(--book-stamp-pass)}.tally [data-outcome=cooking] .tally-count{color:var(--book-stamp-cook)}.tally [data-outcome=back] .tally-count{color:var(--book-stamp-back)}.tally [data-outcome=escalated] .tally-count{color:var(--book-stamp-stop)}.book-foot{color:var(--book-ink-soft);margin:auto 0 0;font:italic 13px/1.3 Iowan Old Style,Palatino Linotype,Palatino,Georgia,serif}.order-empty{color:var(--book-ink-soft);margin:0;padding-left:72px;font:italic 16px/32px Iowan Old Style,Palatino Linotype,Palatino,Georgia,serif}.orders{margin:0;padding:0;list-style:none}.order{grid-template-columns:58px minmax(0,1fr) auto;align-items:start;gap:14px;min-height:64px;padding:0;display:grid}.order-no{color:var(--book-ink-soft);font:500 10.5px/20px var(--mono);letter-spacing:.04em;padding-top:6px}.order-main{min-width:0;display:grid}.order-task{overflow-wrap:anywhere;font:600 17px/32px Iowan Old Style,Palatino Linotype,Palatino,Georgia,serif}.order-meta{color:var(--book-ink-soft);font:italic 13px/32px Iowan Old Style,Palatino Linotype,Palatino,Georgia,serif}.order-now{color:var(--book-stamp-cook);font-style:normal;font-weight:700}.order-stamp{--stamp:var(--book-stamp-void);border:2px solid var(--stamp);color:var(--stamp);font:800 11px/1.2 var(--mono);letter-spacing:.12em;text-transform:uppercase;opacity:.82;mix-blend-mode:multiply;border-radius:5px;margin-top:12px;padding:3px 9px;rotate:-7deg}.order:nth-child(2n) .order-stamp{rotate:5deg}.order[data-outcome=passed] .order-stamp,.order[data-outcome=done] .order-stamp{--stamp:var(--book-stamp-pass)}.order[data-outcome=cooking] .order-stamp{--stamp:var(--book-stamp-cook);border-style:dashed}.order[data-outcome=back] .order-stamp{--stamp:var(--book-stamp-back)}.order[data-outcome=escalated] .order-stamp{--stamp:var(--book-stamp-stop)}.order[aria-current=true] .order-task{-webkit-text-decoration:underline 2px var(--book-stamp-cook);text-decoration:underline 2px var(--book-stamp-cook);text-underline-offset:6px}.stage-head{background:var(--book-paper);color:var(--book-ink);box-shadow:0 1px 0 var(--book-paper-edge),var(--shadow-raised);-webkit-backdrop-filter:none;backdrop-filter:none;border:0;border-radius:4px;rotate:-.6deg}.stage-head:before{content:"";background:var(--chalk-accent);width:12px;height:12px;box-shadow:0 1px 2px var(--book-gutter);border-radius:50%;margin-left:-6px;position:absolute;top:-5px;left:50%}.stage-head .eyebrow{border-bottom:1px dashed var(--book-gutter);color:var(--book-ink-soft);padding-bottom:6px}.stage-head .run-task{color:var(--book-ink);font-family:Iowan Old Style,Palatino Linotype,Palatino,Georgia,serif;font-weight:700}.stage-head .run-meta{color:var(--book-ink-soft);font-style:italic}.ring-board{display:none}#ring[data-ring="3d"] .ring-centre{border:6px solid var(--chalk-frame);background:var(--chalk-board);color:var(--chalk-ink);box-shadow:inset 0 0 0 1px var(--chalk-frame-deep),var(--shadow-raised);-webkit-backdrop-filter:none;backdrop-filter:none;border-radius:6px}#ring[data-ring="3d"] .ring-board{color:var(--chalk-ink);letter-spacing:.01em;font:400 22px/1.2 Chalkboard SE,Marker Felt,Segoe Print,Bradley Hand,cursive;display:block}#ring[data-ring="3d"] .ring-activity{color:var(--chalk-accent);font:600 10.5px/1.4 var(--mono);letter-spacing:.08em;text-transform:uppercase}#ring[data-ring="3d"] .ring-note{color:var(--chalk-soft)}.crew-tip{z-index:3;border:1px solid color-mix(in srgb,var(--line) 70%,transparent);background:color-mix(in srgb,var(--surface-2) 88%,transparent);max-width:260px;box-shadow:var(--shadow-raised);pointer-events:none;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-radius:10px;margin:0;padding:5px 10px;font-size:12.5px;font-weight:600;line-height:1.35;position:absolute;top:0;left:0}.details-button kbd{border:1px solid var(--line);background:var(--surface-1);min-width:20px;height:20px;color:var(--muted);font:500 11px/1 var(--mono);border-radius:5px;place-items:center;padding:0 5px;display:inline-grid}.run-status:empty{display:none}.primary{border-radius:var(--radius-control);background:var(--brand);height:34px;color:var(--on-brand);cursor:pointer;transition:background-color var(--press) ease,transform var(--press) var(--ease-out);border:0;align-items:center;gap:6px;padding:0 14px;font-weight:600;display:inline-flex}.primary:active:not(:disabled){transform:scale(.97)}.primary:disabled{cursor:progress;opacity:.6}.primary[data-done=true]{background:var(--ok-fill);color:var(--on-brand);opacity:1;cursor:default;animation:freeze-done .42s var(--ease-out)}.primary[data-done=true]:before{content:"";border-bottom:2px solid;border-left:2px solid;width:12px;height:7px;margin:-3px 2px 0 0;transform:rotate(-45deg)}.ghost{border:1px solid var(--line-strong);border-radius:var(--radius-control);background:var(--surface-2);height:34px;color:var(--text);cursor:pointer;transition:background-color var(--press) ease,transform var(--press) var(--ease-out);align-items:center;gap:6px;padding:0 12px;font-weight:600;display:inline-flex}.ghost:active:not(:disabled){transform:scale(.97)}.list-sketch{height:28px;margin:2px 0 6px 6px;padding:0 10px;font-size:12.5px}.sketch{flex-direction:column;gap:12px;min-height:0;padding:0 20px 20px;display:flex}.sketch-counts{color:var(--text-2);font-variant-numeric:tabular-nums}.tab-note{color:var(--brand-text);margin-left:4px;font-size:11px;font-weight:600}.sketch-panel{border:1px solid var(--line);border-radius:var(--radius-panel);background:var(--surface-2);min-height:min(56dvh,560px);position:relative;overflow:hidden}.sketch-frame{opacity:1;width:100%;height:min(56dvh,560px);transition:opacity var(--enter) var(--ease-out);border:0;display:block}.sketch-panel[data-loaded=false] .sketch-frame{opacity:0}.sketch-skeleton{pointer-events:none;transition:opacity var(--enter) var(--ease-out);grid-template-columns:repeat(3,minmax(0,1fr));align-items:center;gap:28px;padding:48px;display:grid;position:absolute;inset:0}.sketch-skeleton span{border-radius:var(--radius-panel);background:var(--surface-3);height:84px}.sketch-skeleton span:nth-child(2){height:120px}.sketch-panel[data-loaded=true] .sketch-skeleton{opacity:0}.sketch-foot{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:10px;display:flex}.sketch-sheet .sheet-panel{width:min(1100px,100%)}.freeze-form{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.freeze-form label{color:var(--text-2);font-size:12.5px}.freeze-form input{border:1px solid var(--line-strong);border-radius:var(--radius-control);background:var(--surface-2);width:180px;height:34px;transition:border-color var(--press) ease;padding:0 10px}.freeze-form input:focus-visible{border-color:var(--focus);outline-offset:0}.ringbox{--loop:clamp(220px,48vh,420px);position:absolute;inset:0;overflow:hidden}.loop,.ring-orbit,.ring-gl{width:var(--loop);height:var(--loop);margin:calc(var(--loop) / -2) 0 0 calc(var(--loop) / -2);position:absolute;top:52%;left:50%}.loop:before{content:"";border:2px solid var(--line);border-radius:50%;position:absolute;inset:0}.stages{position:absolute;inset:0}.stage{color:var(--muted);font:10px/1.2 var(--mono);letter-spacing:.08em;text-align:center;text-transform:uppercase;white-space:nowrap;position:absolute;transform:translate(-50%,-50%)}.stage i{border:2px solid var(--line-strong);background:var(--surface-2);border-radius:50%;width:12px;height:12px;margin:0 auto 4px;display:block}.stage.done i{border-color:var(--ok-fill);background:var(--ok-fill)}.stage.now{color:var(--text)}.stage.now i{border-color:var(--brand);box-shadow:var(--halo-now)}.stage.skipped{opacity:.5}.stage.skipped i{border-style:dashed}.stage-agent{color:var(--faint);display:block}.kitchen-ticket{background:var(--brand-soft);color:var(--brand-text);font:600 11px/1.4 var(--mono);white-space:nowrap;border-radius:4px;padding:2px 8px;position:absolute;top:66%;left:50%;transform:translate(-50%)}.kitchen-return{color:var(--brand-text);white-space:nowrap;font-size:12px;font-weight:600;position:absolute;top:75%;left:50%;transform:translate(-50%)}.guest{z-index:3;border:1px solid color-mix(in srgb,var(--line) 70%,transparent);background:color-mix(in srgb,var(--surface-2) 82%,transparent);text-align:center;max-width:min(250px,100% - 32px);box-shadow:var(--shadow-raised);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border-radius:14px;flex-direction:column;align-items:center;gap:6px;padding:8px 12px;display:flex;position:absolute;bottom:72px;left:50%;transform:translate(-50%)}.guest[data-asking=false]{border-radius:999px;padding:3px 10px}.guest[data-asking=true]{border-color:var(--brand)}.guest-ask b{letter-spacing:-.01em;font-size:14px;display:block}.guest-note{color:var(--muted);font-size:12px;line-height:1.35}.guest-actions{flex-wrap:wrap;justify-content:center;gap:8px;display:flex}.stage[data-stage=goal]{top:0%;left:50%}.stage[data-stage=maker]{top:25%;left:93.3%}.stage[data-stage=verify]{top:75%;left:93.3%}.stage[data-stage=review]{top:100%;left:50%}.stage[data-stage=judge]{top:75%;left:6.7%}.stage[data-stage=deliver]{top:25%;left:6.7%}.ring-centre{width:calc(var(--loop) * .8);text-align:center;flex-direction:column;align-items:center;gap:4px;display:flex;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.ring-note{letter-spacing:.08em;white-space:nowrap}.ring-activity{letter-spacing:-.01em;font-size:15px;font-weight:650;line-height:1.25}.ring-orbit{pointer-events:none;transition:transform .52s var(--ease-out),opacity var(--enter) var(--ease-out)}.ring-bot{-webkit-tap-highlight-color:transparent;cursor:pointer;pointer-events:auto;width:calc(var(--loop) * .108);height:calc(var(--loop) * .108);transition:transform .52s var(--ease-out);border:0;padding:0;position:absolute;top:13%;left:50%;transform:translate(-50%,-50%)}.ring-orbit[data-at=goal]{transform:rotate(0)}.ring-orbit[data-at=goal] .ring-bot{transform:translate(-50%,-50%)rotate(0)}.ring-orbit[data-at=maker]{transform:rotate(60deg)}.ring-orbit[data-at=maker] .ring-bot{transform:translate(-50%,-50%)rotate(-60deg)}.ring-orbit[data-at=verify]{transform:rotate(120deg)}.ring-orbit[data-at=verify] .ring-bot{transform:translate(-50%,-50%)rotate(-120deg)}.ring-orbit[data-at=review]{transform:rotate(180deg)}.ring-orbit[data-at=review] .ring-bot{transform:translate(-50%,-50%)rotate(-180deg)}.ring-orbit[data-at=judge]{transform:rotate(240deg)}.ring-orbit[data-at=judge] .ring-bot{transform:translate(-50%,-50%)rotate(-240deg)}.ring-orbit[data-at=deliver]{transform:rotate(300deg)}.ring-orbit[data-at=deliver] .ring-bot{transform:translate(-50%,-50%)rotate(-300deg)}.ring-bot:focus-visible{outline-offset:4px}.ring-gl{width:calc(var(--loop) * 1.2);height:calc(var(--loop) * 1.2);margin:calc(var(--loop) * -.6) 0 0 calc(var(--loop) * -.6);pointer-events:none;opacity:0;transition:opacity var(--enter) var(--ease-out)}.ring-gl canvas{display:block}#ring[data-bot="3d"] .ring-gl{opacity:1}#ring[data-bot="3d"] .ring-bot{box-shadow:none;background:0 0}#ring[data-bot="3d"] .ring-bot:before,#ring[data-bot="3d"] .ring-bot:after{visibility:hidden}.bot-bubble{z-index:4;border:1px solid var(--line);background:var(--surface-2);max-width:180px;color:var(--text);white-space:nowrap;box-shadow:var(--shadow-raised);pointer-events:none;transform-origin:0 100%;transition:opacity var(--enter) var(--ease-out),scale var(--enter) var(--ease-out);border-radius:12px 12px 12px 4px;padding:6px 10px;font-size:12.5px;font-weight:600;line-height:1.25;position:absolute;top:0;left:0}.bot-bubble[data-level="3"]{border-color:var(--brand);color:var(--brand-text)}.bot-bubble[data-level="4"]{border-color:var(--danger);background:var(--danger-soft);color:var(--danger-text)}.bot-bubble[data-pop]{animation:bubble-pop var(--enter) var(--ease-out)}#ring:not([data-ring="3d"]) .bot-bubble{top:calc(50% - 50% * .74 - var(--loop) * .2);left:calc(50% + var(--loop) * .05)}#ring[data-ring="3d"] .bot-bubble{transition:opacity var(--enter) var(--ease-out)}.run[data-zoom=in] .loop,.run[data-zoom=in] .guest,.run[data-zoom=in] .stage-head,.run[data-zoom=in] .details-button,.run[data-zoom=in] .run-status{opacity:0;pointer-events:none;scale:1.06}.run[data-zoom=in] .ring-bot{visibility:hidden}.loop,.guest,.stage-head,.details-button{transition:opacity .6s var(--ease-out),scale .6s var(--ease-out)}.room{z-index:5;opacity:0;transition:opacity .26s var(--ease-out);position:absolute;inset:0}.room[data-open=true]{opacity:1}.room-card{z-index:1;border:1px solid color-mix(in srgb,var(--line) 70%,transparent);border-radius:var(--radius-card);background:color-mix(in srgb,var(--surface-2) 70%,transparent);-webkit-backdrop-filter:blur(16px)saturate(1.3);backdrop-filter:blur(16px)saturate(1.3);width:min(380px,100% - 40px);box-shadow:var(--shadow-panel);flex-direction:column;gap:4px;padding:16px 18px;display:flex;position:absolute;top:20px;left:20px}.room-title{letter-spacing:-.015em;overflow-wrap:anywhere;font-size:20px;font-weight:650}.room-activity{color:var(--text-2)}.room-activity strong{color:var(--text)}.room-facts{flex-wrap:wrap;gap:6px;margin-top:4px;display:flex}.room-nav{z-index:1;justify-content:center;align-items:center;gap:10px;display:flex;position:absolute;bottom:20px;left:20px;right:20px}.room-nav button{border:1px solid color-mix(in srgb,var(--line) 70%,transparent);background:color-mix(in srgb,var(--surface-2) 72%,transparent);cursor:pointer;-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);min-width:44px;height:40px;box-shadow:var(--shadow-raised);transition:background-color var(--press) ease,transform var(--press) var(--ease-out);border-radius:999px;justify-content:center;align-items:center;gap:6px;padding:0 14px;font-weight:600;display:inline-flex}.room-nav button:active{transform:scale(.97)}.room-nav button:disabled{cursor:default;opacity:.45}.run-detail{overscroll-behavior:contain;flex-direction:column;gap:16px;min-height:0;padding:4px 20px 28px;display:flex;overflow:auto}.sheet{z-index:40;position:fixed;inset:0}.sheet-backdrop{background:color-mix(in srgb,var(--shadow) 38%,transparent);opacity:0;transition:opacity .45s cubic-bezier(.32,.72,0,1);position:absolute;inset:0}.sheet-panel{border:1px solid var(--line);background:var(--surface-1);width:min(900px,100%);max-height:86dvh;box-shadow:var(--shadow-panel);border-bottom:0;border-radius:18px 18px 0 0;outline:0;flex-direction:column;margin:0 auto;transition:transform .45s cubic-bezier(.32,.72,0,1);display:flex;position:absolute;bottom:0;left:0;right:0;transform:translateY(100%)}.sheet[data-open=true] .sheet-backdrop{opacity:1}.sheet[data-open=true] .sheet-panel{transform:translateY(0)}.sheet[data-dragging] .sheet-panel{transition:none}.sheet-grab{cursor:grab;touch-action:none;-webkit-user-select:none;user-select:none;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:4px 12px;padding:8px 20px 12px;display:grid}.sheet-handle{background:var(--line-strong);border-radius:2px;grid-column:1/-1;justify-self:center;width:40px;height:4px;margin-bottom:6px}.sheet-title{font-size:15px;font-weight:650}.sheet-close{border:1px solid var(--line);background:var(--surface-2);cursor:pointer;height:30px;transition:background-color var(--press) ease,transform var(--press) var(--ease-out);border-radius:999px;padding:0 12px;font-size:12.5px;font-weight:600}.sheet-close:active{transform:scale(.97)}#ring[data-ring="3d"] .loop{z-index:1;pointer-events:none;width:auto;height:auto;margin:0;inset:0}#ring[data-ring="3d"] .loop:before{display:none}#ring[data-ring="3d"] .stage{border:1px solid color-mix(in srgb,var(--line) 70%,transparent);background:color-mix(in srgb,var(--surface-2) 78%,transparent);color:var(--text-2);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);box-shadow:var(--shadow-raised);border-radius:10px;padding:4px 10px 5px;top:0;left:0;transform:none}#ring[data-ring="3d"] .stage[data-crowd]:after{content:"×" attr(data-crowd);background:var(--brand);min-width:20px;color:var(--on-brand);font:700 10.5px/1.2 var(--mono);text-align:center;border-radius:999px;padding:2px 5px;position:absolute;top:-8px;right:-8px}#ring[data-ring="3d"] .stage-station{font:600 12.5px/1.3 var(--font);letter-spacing:-.005em;text-transform:none}#ring[data-ring="3d"] .stage-agent{color:var(--muted);margin-top:1px;font-size:9.5px}#ring[data-ring="3d"] .stage i{vertical-align:middle;background:var(--line-strong);border-width:0;width:7px;height:7px;margin:0 6px 1px 0;display:inline-block}#ring[data-ring="3d"] .stage.done i{background:var(--ok-fill)}#ring[data-ring="3d"] .stage.now{border-color:color-mix(in srgb,var(--brand) 45%,transparent);color:var(--text)}#ring[data-ring="3d"] .stage.now i{background:var(--brand);box-shadow:none}#ring[data-ring="3d"] .stage.skipped{opacity:.55}#ring[data-ring="3d"] .stage{transition:border-color var(--press) ease,color var(--press) ease,background-color var(--press) ease,translate var(--press) var(--ease-out)}#ring[data-ring="3d"] .stage[data-hover=true]{border-color:color-mix(in srgb,var(--brand) 55%,transparent);background:color-mix(in srgb,var(--surface-2) 94%,transparent);color:var(--text);translate:0 -2px}#ring[data-ring="3d"] .kitchen-ticket,#ring[data-ring="3d"] .kitchen-return{top:0;left:0;transform:none}#ring[data-ring="3d"] .kitchen-return{background:color-mix(in srgb,var(--surface-2) 80%,transparent);border-radius:999px;padding:2px 8px}#ring[data-ring="3d"] .guest{top:0;bottom:auto;left:0;transform:none}#ring[data-ring="3d"] .ring-centre{z-index:1;border:1px solid color-mix(in srgb,var(--line) 70%,transparent);border-radius:var(--radius-panel);background:color-mix(in srgb,var(--surface-2) 70%,transparent);text-align:right;-webkit-backdrop-filter:blur(14px)saturate(1.3);backdrop-filter:blur(14px)saturate(1.3);width:auto;max-width:min(300px,34%);box-shadow:var(--shadow-raised);align-items:flex-end;padding:12px 14px;top:16px;left:auto;right:16px;transform:none}.run[data-showing=true] .stage-head{max-width:min(460px,66% - 48px)}#ring[data-ring="3d"] .ring-gl{pointer-events:auto;width:auto;height:auto;margin:0;inset:0}.ring-gl canvas{transition:opacity .16s var(--ease-out)}.ring-gl[data-cut=out] canvas{opacity:0}.ring-gl[data-hover=room]{cursor:pointer}#ring[data-ring="3d"] .ring-orbit{width:auto;height:auto;margin:0;transition:none;inset:0;transform:none}#ring[data-ring="3d"] .ring-bot{z-index:2;border-radius:50%;transition:none;top:0;left:0}.facts{grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;display:grid}.facts div{border:1px solid var(--line);border-radius:var(--radius-panel);background:var(--surface-2);padding:12px 14px}.facts dt{color:var(--muted);letter-spacing:.04em;text-transform:uppercase;margin-bottom:2px;font-size:11.5px;font-weight:600}.facts dd{overflow-wrap:anywhere}.detail-card{border:1px solid var(--line);border-radius:var(--radius-panel);background:var(--surface-2);padding:14px 16px}.detail-card h3{margin-bottom:8px;font-size:13px;font-weight:600}.detail-card ul{color:var(--text-2);flex-direction:column;gap:4px;padding-left:18px;list-style:outside;display:flex}.goal-head{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px 12px;margin-bottom:10px;display:flex}.detail-card .goal-head h3{margin:0}.tabs{border:1px solid var(--line);background:var(--surface-1);border-radius:8px;padding:2px;display:inline-flex}.tabs [role=tab]{-webkit-tap-highlight-color:transparent;height:26px;color:var(--muted);cursor:pointer;transition:background-color var(--press) ease,color var(--press) ease,box-shadow var(--press) ease,transform var(--press) var(--ease-out);background:0 0;border:0;border-radius:6px;padding:0 10px;font-size:12.5px;font-weight:550}.tabs [role=tab]:active{transform:scale(.97)}.tabs [role=tab][aria-selected=true]{background:var(--surface-2);color:var(--text);box-shadow:var(--shadow-raised)}.goal-formatted{max-height:420px;color:var(--text-2);overflow-wrap:anywhere;line-height:1.6;overflow:auto}.goal-formatted h4{color:var(--text);margin:0 0 8px;font-size:15px;font-weight:650}.goal-formatted h5,.goal-formatted h6{color:var(--muted);font:600 10.5px/1.2 var(--mono);letter-spacing:.1em;text-transform:uppercase;margin:14px 0 6px}.goal-formatted p{margin:0 0 6px}.goal-formatted ul{margin:0 0 8px}.goal-formatted ol{flex-direction:column;gap:4px;margin:0 0 8px;padding-left:20px;list-style:decimal;display:flex}.goal-formatted code{background:var(--surface-3);border-radius:4px;padding:1px 5px}.goal-formatted pre{border-radius:var(--radius-control);background:var(--surface-3);margin:0 0 8px;padding:10px 12px;overflow:auto}.goal-formatted pre code{background:0 0;padding:0}.goal-text{max-height:420px;color:var(--text-2);white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.6;overflow:auto}.quiet-text{color:var(--muted)}@media (max-width:899px){.appbar{padding:10px 16px}.projects-toggle{display:inline-flex}.live{margin-left:auto}.chips{flex-basis:100%;order:3;margin-left:0}.layout{grid-template-columns:minmax(0,1fr);padding:10px 12px 12px}.projects{z-index:20;border:1px solid var(--line);border-radius:var(--radius-panel);background:var(--surface-1);max-height:70dvh;box-shadow:var(--shadow-panel);padding:12px 8px;display:none;position:absolute;top:8px;left:12px;right:12px}.projects[data-open=true]{display:block}.ringbox{--loop:min(220px,62vw)}#ring[data-ring="3d"] .ring-centre{max-width:60%;top:auto;bottom:56px;right:10px}#ring[data-ring="3d"] .ring-board{font-size:18px}.stage-head,.run[data-showing=true] .stage-head{max-width:none;padding:10px 12px;top:10px;left:10px;right:10px}.run-task{-webkit-line-clamp:1;font-size:14.5px}.details-button{bottom:10px;right:10px}.orders-button{left:10px;right:auto}.run-status{max-width:calc(100% - 20px);bottom:56px;left:10px}.facts{grid-template-columns:minmax(0,1fr)}.room-card{width:calc(100% - 24px);padding:12px 14px;top:12px;left:12px}.room-title{font-size:17px}.room-nav{gap:8px;bottom:12px;left:12px;right:12px}.room-nav button{flex:1;padding:0 10px}}@media (max-width:600px){.layout{padding:8px}.projects-toggle,.details-button,.sheet-close,.primary,.ghost,.room-nav button,.freeze-form input,.tabs [role=tab]{min-height:44px}.stage-head,.run[data-showing=true] .stage-head{gap:2px;padding:8px 12px;top:8px;left:8px;right:8px}.stage-head .run-meta{display:none}.run-task{-webkit-line-clamp:2;font-size:14.5px}.stage-wait{gap:6px;margin-top:4px}.freeze-form input{flex:1;width:auto;min-width:0}.run:has(#ring[data-ring="3d"] .guest[data-asking=true] .guest-actions) .stage-wait>button{display:none}.details-button{padding:0 10px 0 14px;bottom:8px;right:8px}.orders-button{left:8px;right:auto}.orders-body{padding:0 10px 14px}.book{grid-template-columns:1fr}.page{padding:20px 16px 22px}.page-left{background:var(--book-paper);border-bottom:1px dashed var(--book-gutter);border-radius:6px 6px 0 0;gap:4px}.page-right{background:linear-gradient(to right,transparent 40px,var(--book-margin) 40px 41px,transparent 41px),repeating-linear-gradient(to bottom,transparent 0 31px,var(--book-rule) 31px 32px),var(--book-paper);border-radius:0 0 6px 6px}.book-name{font-size:26px}.book-foot{display:none}.order{grid-template-columns:40px minmax(0,1fr);gap:8px}.order-stamp{grid-column:2;justify-self:start;margin:0 0 10px}.order-empty{padding-left:52px}.run-status{max-width:calc(100% - 130px);bottom:8px;left:8px}#ring[data-ring="3d"] .ring-centre{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}#ring[data-ring="3d"] .guest{max-width:none;padding:10px 12px;inset:auto 8px 68px}#ring[data-ring="3d"] .guest[data-asking=false]{display:none}#ring[data-ring="3d"] .guest-actions{width:100%}#ring[data-ring="3d"] .guest-actions>*{flex:1;justify-content:center}#ring[data-ring="3d"] .stages{pointer-events:auto;scrollbar-width:none;overscroll-behavior-x:contain;gap:6px;padding:2px;display:flex;inset:auto 8px 60px;overflow-x:auto}#ring[data-ring="3d"] .stages::-webkit-scrollbar{display:none}#ring[data-ring="3d"]:has(.guest[data-asking=true]) .stages{bottom:calc(76px + var(--guest-h,0px))}#ring[data-ring="3d"] .stage{flex:none;align-items:center;min-height:32px;padding:4px 10px;display:flex;position:static}#ring[data-ring="3d"] .stage-agent{display:none}#ring[data-ring="3d"] .stage.now .stage-agent{margin:0 0 0 6px;display:inline}.room-card{width:calc(100% - 16px);top:8px;left:8px}.room-nav{bottom:8px;left:8px;right:8px}.room-nav button{min-height:44px}}@media (hover:hover) and (pointer:fine){.project-row:hover{background:var(--surface-1)}.project-row[aria-current=true]:hover{background:var(--surface-2)}.worktree-row:hover{background:var(--surface-1)}.worktree-row[aria-current=true]:hover{background:var(--surface-2)}.tabs [role=tab]:hover{color:var(--text)}.primary:hover:not(:disabled){background:var(--brand-hover)}.ghost:hover:not(:disabled){background:var(--surface-1)}.details-button:hover,.sheet-close:hover,.projects-toggle:hover,.room-nav button:hover:not(:disabled){background:var(--surface-2)}}@keyframes bubble-pop{0%{opacity:0;scale:.85}}@keyframes detail-in{0%{opacity:0;transform:translateY(4px)}}@keyframes freeze-done{40%{scale:1.04}}@keyframes detail-fade{0%{opacity:0}}@media (prefers-reduced-motion:reduce){.ring-orbit,.ring-bot{transition-property:opacity}.run[data-enter]{animation-name:detail-fade}.run,body[data-sheet=open] .run{transition:none;transform:none}.sheet-panel{opacity:0;transition:opacity .2s var(--ease-out);transform:none}.sheet[data-open=true] .sheet-panel{opacity:1;transform:none}.bot-bubble[data-pop]{animation:none}.primary[data-done=true]{animation:detail-fade .2s var(--ease-out)}.loop,.stage-head,.details-button{transition-property:opacity}.run[data-zoom=in] .loop,.run[data-zoom=in] .ring-orbit,.run[data-zoom=in] .stage-head,.run[data-zoom=in] .details-button,.run[data-zoom=in] .run-status{scale:1}.project-row,.worktree-row,.primary{transition-property:background-color,border-color}} diff --git a/studio/app/assets/restaurant-DuFRqeba.js b/studio/app/assets/restaurant-DuFRqeba.js new file mode 100644 index 0000000..b4bcc4b --- /dev/null +++ b/studio/app/assets/restaurant-DuFRqeba.js @@ -0,0 +1,4091 @@ +import{A as e,C as t,D as n,E as r,O as i,S as a,T as o,_ as s,a as c,b as l,c as u,d,f,g as p,h as m,i as h,k as g,l as _,m as v,n as y,o as b,p as x,r as S,s as C,t as w,u as T,v as E,w as D,x as O,y as k}from"./index-DJi-HckC.js";var A=1e3,ee=1001,j=1002,M=1003,N=1004,te=1005,P=1006,ne=1007,re=1008,ie=1009,ae=1010,oe=1011,se=1012,F=1013,ce=1014,I=1015,le=1016,ue=1017,de=1018,fe=1020,pe=35902,me=35899,he=1023,L=1026,ge=1027,_e=1028,ve=1029,ye=1030,be=1031,xe=1033,Se=2200,Ce=2300,we=2301,Te=2302,Ee=2303,De=2400,Oe=2401,ke=2402,Ae=`srgb`,je=`srgb-linear`,Me=`linear`,Ne=`srgb`,R=7680,Pe=35044,z=2e3;function B(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Fe(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function Ie(){let e=Fe(`canvas`);return e.style.display=`block`,e}var Le={};function Re(...e){let t=`THREE.`+e.shift();console.log(t,...e)}function ze(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function V(...e){let t=`THREE.`+(e=ze(e)).shift();{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function H(...e){let t=`THREE.`+(e=ze(e)).shift();{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function Be(...e){let t=e.join(` `);t in Le||(Le[t]=!0,V(...e))}function Ve(e,t,n){return new Promise(function(r,i){setTimeout(function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}},n)})}var He={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},Ue=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n!==void 0&&n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n>8&255]+We[e>>16&255]+We[e>>24&255]+`-`+We[255&t]+We[t>>8&255]+`-`+We[t>>16&15|64]+We[t>>24&255]+`-`+We[63&n|128]+We[n>>8&255]+`-`+We[n>>16&255]+We[n>>24&255]+We[255&r]+We[r>>8&255]+We[r>>16&255]+We[r>>24&255]).toLowerCase()}function U(e,t,n){return Math.max(t,Math.min(n,e))}function Je(e,t){return(e%t+t)%t}function Ye(e,t,n){return(1-n)*e+n*t}function Xe(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`THREE.MathUtils: Invalid component type.`)}}function Ze(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw Error(`THREE.MathUtils: Invalid component type.`)}}var W=class e{static{e.prototype.isVector2=!0}constructor(e=0,t=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 Error(`THREE.Vector2: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`THREE.Vector2: 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){let 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=U(this.x,e.x,t.x),this.y=U(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=U(this.x,e,t),this.y=U(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(U(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){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(U(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let 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){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*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}},Qe=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,s=s*t+d*(o=Math.sin(o*n)/r),c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,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){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:V(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let 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){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.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(U(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let 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*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*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}},G=class e{static{e.prototype.isVector3=!0}constructor(e=0,t=0,n=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 Error(`THREE.Vector3: 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 Error(`THREE.Vector3: 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($e.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion($e.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[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=U(this.x,e.x,t.x),this.y=U(this.y,e.y,t.y),this.z=U(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=U(this.x,e,t),this.y=U(this.y,e,t),this.z=U(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(U(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){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return K.copy(this).projectOnVector(e),this.sub(K)}reflect(e){return this.sub(K.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(U(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let 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){let 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){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let 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,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}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(){let e=Math.random()*Math.PI*2,t=2*Math.random()-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}},K=new G,$e=new Qe,q=class e{static{e.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let 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){let 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){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,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){let 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,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return Be(`Matrix3: .scale() is deprecated. Use .makeScale() instead.`),this.premultiply(et.makeScale(e,t)),this}rotate(e){return Be(`Matrix3: .rotate() is deprecated. Use .makeRotation() instead.`),this.premultiply(et.makeRotation(-e)),this}translate(e,t){return Be(`Matrix3: .translate() is deprecated. Use .makeTranslation() instead.`),this.premultiply(et.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){let 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){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])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){let 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)}},et=new q,tt=new q().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),nt=new q().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function rt(){let e={enabled:!0,workingColorSpace:je,spaces:{},convert:function(e,t,n){return!1!==this.enabled&&t!==n&&t&&n&&(this.spaces[t].transfer===`srgb`&&(e.r=at(e.r),e.g=at(e.g),e.b=at(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=ot(e.r),e.g=ot(e.g),e.b=ot(e.b))),e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?Me:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return Be(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return Be(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[je]:{primaries:t,whitePoint:r,transfer:Me,toXYZ:tt,fromXYZ:nt,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Ae},outputColorSpaceConfig:{drawingBufferColorSpace:Ae}},[Ae]:{primaries:t,whitePoint:r,transfer:Ne,toXYZ:tt,fromXYZ:nt,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Ae}}}),e}var it=rt();function at(e){return e<.04045?.0773993808*e:(.9478672986*e+.0521327014)**2.4}function ot(e){return e<.0031308?12.92*e:1.055*e**.41666-.055}var st,ct=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{st===void 0&&(st=Fe(`canvas`)),st.width=e.width,st.height=e.height;let t=st.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=st}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=Fe(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(pt).x}get height(){return this.source.getSize(pt).y}get depth(){return this.source.getSize(pt).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){V(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?V(`Texture.setValues(): property '${t}' does not exist.`):r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case A:e.x-=Math.floor(e.x);break;case ee:e.x=e.x<0?0:1;break;case j:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case A:e.y-=Math.floor(e.y);break;case ee:e.y=e.y<0?0:1;break;case j:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){!0===e&&this.pmremVersion++}};mt.DEFAULT_IMAGE=null,mt.DEFAULT_MAPPING=300,mt.DEFAULT_ANISOTROPY=1;var ht=class e{static{e.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){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 Error(`THREE.Vector4: 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 Error(`THREE.Vector4: 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?1:e.w,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){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,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);let 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,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)s&&e>_?e_?s1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),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.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON())),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&&!0!==this.environment.isRenderTargetTexture&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}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.pivot=e.pivot===null?null:e.pivot.clone(),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.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(qt)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Y;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Yt={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},Xt={h:0,s:0,l:0},Zt={h:0,s:0,l:0};function Qt(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}var X=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){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ae){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,it.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=it.workingColorSpace){return this.r=e,this.g=t,this.b=n,it.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=it.workingColorSpace){if(e=Je(e,1),t=U(t,0,1),n=U(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Qt(i,r,e+1/3),this.g=Qt(i,r,e),this.b=Qt(i,r,e-1/3)}return it.colorSpaceToWorking(this,r),this}setStyle(e,t=Ae){function n(t){t!==void 0&&parseFloat(t)<1&&V(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:V(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);V(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ae){let n=Yt[e.toLowerCase()];return n===void 0?V(`Color: Unknown color `+e):this.setHex(n,t),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=at(e.r),this.g=at(e.g),this.b=at(e.b),this}copyLinearToSRGB(e){return this.r=ot(e.r),this.g=ot(e.g),this.b=ot(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ae){return it.workingToColorSpace($t.copy(this),e),65536*Math.round(U(255*$t.r,0,255))+256*Math.round(U(255*$t.g,0,255))+Math.round(U(255*$t.b,0,255))}getHexString(e=Ae){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace($t.copy(this),t);let n=$t.r,r=$t.g,i=$t.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r0&&(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}},tn=new G,nn=new G,rn=new G,an=new G,on=new G,sn=new G,cn=new G,ln=new G,un=new G,dn=new G,fn=new ht,pn=new ht,mn=new ht,hn=class e{constructor(e=new G,t=new G,n=new G){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),tn.subVectors(e,t),r.cross(tn);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){tn.subVectors(r,t),nn.subVectors(n,t),rn.subVectors(e,t);let a=tn.dot(tn),o=tn.dot(nn),s=tn.dot(rn),c=nn.dot(nn),l=nn.dot(rn),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,an)!==null&&an.x>=0&&an.y>=0&&an.x+an.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,an)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,an.x),s.addScaledVector(a,an.y),s.addScaledVector(o,an.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return fn.setScalar(0),pn.setScalar(0),mn.setScalar(0),fn.fromBufferAttribute(e,t),pn.fromBufferAttribute(e,n),mn.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(fn,i.x),a.addScaledVector(pn,i.y),a.addScaledVector(mn,i.z),a}static isFrontFacing(e,t,n,r){return tn.subVectors(n,t),nn.subVectors(e,t),tn.cross(nn).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 tn.subVectors(this.c,this.b),nn.subVectors(this.a,this.b),.5*tn.cross(nn).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;on.subVectors(r,n),sn.subVectors(i,n),ln.subVectors(e,n);let s=on.dot(ln),c=sn.dot(ln);if(s<=0&&c<=0)return t.copy(n);un.subVectors(e,r);let l=on.dot(un),u=sn.dot(un);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(on,a);dn.subVectors(e,i);let f=on.dot(dn),p=sn.dot(dn);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(sn,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return cn.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(cn,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(on,a).addScaledVector(sn,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},gn=class{constructor(e=new G(1/0,1/0,1/0),t=new G(-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,vn),vn.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(En),Dn.subVectors(this.max,En),bn.subVectors(e.a,En),xn.subVectors(e.b,En),Sn.subVectors(e.c,En),Cn.subVectors(xn,bn),wn.subVectors(Sn,xn),Tn.subVectors(bn,Sn);let t=[0,-Cn.z,Cn.y,0,-wn.z,wn.y,0,-Tn.z,Tn.y,Cn.z,0,-Cn.x,wn.z,0,-wn.x,Tn.z,0,-Tn.x,-Cn.y,Cn.x,0,-wn.y,wn.x,0,-Tn.y,Tn.x,0];return!!An(t,bn,xn,Sn,Dn)&&(t=[1,0,0,0,1,0,0,0,1],!!An(t,bn,xn,Sn,Dn)&&(On.crossVectors(Cn,wn),t=[On.x,On.y,On.z],An(t,bn,xn,Sn,Dn)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,vn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(vn).length()),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()||(_n[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),_n[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),_n[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),_n[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),_n[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),_n[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),_n[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),_n[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(_n)),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},_n=[new G,new G,new G,new G,new G,new G,new G,new G],vn=new G,yn=new gn,bn=new G,xn=new G,Sn=new G,Cn=new G,wn=new G,Tn=new G,En=new G,Dn=new G,On=new G,kn=new G;function An(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){kn.fromArray(e,a);let o=i.x*Math.abs(kn.x)+i.y*Math.abs(kn.y)+i.z*Math.abs(kn.z),s=t.dot(kn),c=n.dot(kn),l=r.dot(kn);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}jn();function jn(){let e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=new Uint32Array(512),i=new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(r[e]=0,r[256|e]=32768,i[e]=24,i[256|e]=24):t<-14?(r[e]=1024>>-t-14,r[256|e]=1024>>-t-14|32768,i[e]=-t-1,i[256|e]=-t-1):t<=15?(r[e]=t+15<<10,r[256|e]=t+15<<10|32768,i[e]=13,i[256|e]=13):t<128?(r[e]=31744,r[256|e]=64512,i[e]=24,i[256|e]=24):(r[e]=31744,r[256|e]=64512,i[e]=13,i[256|e]=13)}let a=new Uint32Array(2048),o=new Uint32Array(64),s=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;!(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)e!==32&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:a,exponentTable:o,offsetTable:s}}var Mn=new G,Nn=new W,Pn=0,Fn=class extends Ue{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Pn++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=Pe,this.updateRanges=[],this.gpuType=I,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&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,i=this.itemSize;rthis.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*=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;zn.subVectors(e,this.center);let t=zn.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(zn,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(Bn.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(zn.copy(e.center).add(Bn)),this.expandByPoint(zn.copy(e.center).sub(Bn))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Hn=0,Un=new J,Wn=new Kt,Gn=new G,Kn=new gn,qn=new gn,Jn=new G,Yn=class e extends Ue{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Hn++}),this.uuid=qe(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return this.index=Array.isArray(e)?new(function(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}(e)?Ln:In)(e,1):e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new q().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Un.makeRotationFromQuaternion(e),this.applyMatrix4(Un),this}rotateX(e){return Un.makeRotationX(e),this.applyMatrix4(Un),this}rotateY(e){return Un.makeRotationY(e),this.applyMatrix4(Un),this}rotateZ(e){return Un.makeRotationZ(e),this.applyMatrix4(Un),this}translate(e,t,n){return Un.makeTranslation(e,t,n),this.applyMatrix4(Un),this}scale(e,t,n){return Un.makeScale(e,t,n),this.applyMatrix4(Un),this}lookAt(e){return Wn.lookAt(e),Wn.updateMatrix(),this.applyMatrix4(Wn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Gn).negate(),this.translate(Gn.x,Gn.y,Gn.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;nt.count&&V(`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 gn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return H(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),void this.boundingBox.set(new G(-1/0,-1/0,-1/0),new G(1/0,1/0,1/0));if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e0&&(e.userData=this.userData),this.parameters!==void 0&&!0!==this._transformed){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),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;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){V(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?V(`Material: '${t}' is not a property of THREE.${this.type}.`):r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(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.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),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!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(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!==3&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),!0===this.polygonOffset&&(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),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!1===this.allowOverride&&(n.allowOverride=!1),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new X().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(this.vertexColors=typeof e.vertexColors==`number`?e.vertexColors>0:e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),this.normalScale=new W().fromArray(t)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new W().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}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;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].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.allowOverride=e.allowOverride,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){!0===e&&this.version++}};new G,new G,new G,new W,new W,new J,new G,new G,new G,new W,new W,new W,new G,new G;var Qn=new G,$n=new G,er=new G,tr=new G,nr=new G,rr=new G,ir=new G,ar=class{constructor(e=new G,t=new G(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,Qn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let 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){let t=Qn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Qn.copy(this.origin).addScaledVector(this.direction,t),Qn.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){$n.copy(e).add(t).multiplyScalar(.5),er.copy(t).sub(e).normalize(),tr.copy(this.origin).sub($n);let i=.5*e.distanceTo(t),a=-this.direction.dot(er),o=tr.dot(this.direction),s=-tr.dot(er),c=tr.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0){if(u=a*s-o,d=a*o-s,p=i*l,u>=0){if(d>=-p){if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c)}else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy($n).addScaledVector(er,d),f}intersectSphere(e,t){Qn.subVectors(e.center,this.origin);let n=Qn.dot(this.direction),r=Qn.dot(Qn)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return!(e.radius<0)&&this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r?null:((i>n||isNaN(n))&&(n=i),(a=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r?null:((o>n||n!=n)&&(n=o),(s=0?n:r,t)))}intersectsBox(e){return this.intersectBox(e,Qn)!==null}intersectTriangle(e,t,n,r,i){nr.subVectors(t,e),rr.subVectors(n,e),ir.crossVectors(nr,rr);let a,o=this.direction.dot(ir);if(o>0){if(r)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}tr.subVectors(this.origin,e);let s=a*this.direction.dot(rr.crossVectors(tr,rr));if(s<0)return null;let c=a*this.direction.dot(nr.cross(tr));if(c<0||s+c>o)return null;let l=-a*tr.dot(ir);return l<0?null:this.at(l/o,i)}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)}},or=class extends Zn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new X(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 kt,this.combine=0,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}},sr=new J,cr=new ar,lr=new Vn,ur=new G,dr=new G,fr=new G,pr=new G,mr=new G,hr=new G,gr=new G,_r=new G,vr=class extends Kt{constructor(e=new Yn,t=new or){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2))return;sr.copy(i).invert(),cr.copy(e.ray).applyMatrix4(sr),n.boundingBox!==null&&!1===cr.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,cr)}}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null){if(Array.isArray(a))for(let i=0,s=d.length;in.far?null:{distance:l,point:_r.clone(),object:e}}(e,t,n,r,dr,fr,pr,gr);if(u){let e=new G;hn.getBarycoord(gr,dr,fr,pr,e),i&&(u.uv=hn.getInterpolatedAttribute(i,s,c,l,e,new W)),a&&(u.uv1=hn.getInterpolatedAttribute(a,s,c,l,e,new W)),o&&(u.normal=hn.getInterpolatedAttribute(o,s,c,l,e,new G),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new G,materialIndex:0};hn.getNormal(dr,fr,pr,t.normal),u.face=t,u.barycoord=e}return u}new ht,new ht,new ht,new ht,new J,new G,new Vn,new J,new ar;var br=class extends mt{constructor(e=null,t=1,n=1,r,i,a,o,s,c=1003,l=1003,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};new J,new J;var xr=class extends Fn{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Sr=new J,Cr=new J,wr=[],Tr=new gn,Er=new J,Dr=new vr,Or=new Vn,kr=class extends vr{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new xr(new Float32Array(16*n),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let 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){let n=t||Mr.getNormalMatrix(e),r=this.coplanarPoint(Ar).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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)}},Pr=new Vn,Fr=new W(.5,.5),Ir=new G,Lr=class{constructor(e=new Nr,t=new Nr,n=new Nr,r=new Nr,i=new Nr,a=new Nr){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else{if(t!==2001)throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);r[5].setComponents(s,d,h,y).normalize()}return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Pr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Pr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Pr)}intersectsSprite(e){return Pr.center.set(0,0,0),Pr.radius=.7071067811865476+Fr.distanceTo(e.center),Pr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Pr)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,Ir.y=r.normal.y>0?e.max.y:e.min.y,Ir.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Ir)<0)return!1}return!0}containsPoint(e){let 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)}},Rr=new J,zr=class e{constructor(){this.coordinateSystem=z,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,n=this._frustums;for(let e=0;e=i.length&&i.push({start:-1,count:-1,z:-1,index:-1});let o=i[this.index];a.push(o),this.index++,o.start=e,o.count=t,o.z=n,o.index=r}reset(){this.list.length=0,this.index=0}};new J,new X(1,1,1),new Lr,new zr,new gn,new Vn,new G,new G,new G,new Br,new vr,new G,new G,new J,new ar,new Vn,new G,new G,new G,new G,new J,new ar,new Vn,new G;var Vr=class extends mt{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Hr=class extends mt{constructor(e,t,n=1014,r,i,a,o=1003,s=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error(`THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ut(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Ur=class extends Hr{constructor(e,t=1014,n=301,r,i,a=1003,o=1003,s,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},Wr=class extends mt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Gr=class e extends Yn{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new G;for(let a=0;a0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e0){let e=(_-1)*m;for(let t=0;t0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v})(),!1===a&&(e>0&&_(!0),t>0&&_(!1)),this.setIndex(l),this.setAttribute(`position`,new Z(u,3)),this.setAttribute(`normal`,new Z(d,3)),this.setAttribute(`uv`,new Z(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Yr=class e extends Jr{constructor(e=1,t=1,n=32,r=1,i=!1,a=0,o=2*Math.PI){super(0,e,t,n,r,i,a,o),this.type=`ConeGeometry`,this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}static fromJSON(t){return new e(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Xr=class e extends Yn{constructor(e=[],t=[],n=1,r=0){super(),this.type=`PolyhedronGeometry`,this.parameters={vertices:e,indices:t,radius:n,detail:r};let i=[],a=[];function o(e,t,n,r){let i=r+1,a=[];for(let r=0;r<=i;r++){a[r]=[];let o=e.clone().lerp(n,r/i),s=t.clone().lerp(n,r/i),c=i-r;for(let e=0;e<=c;e++)a[r][e]=e===0&&r===i?o:o.clone().lerp(s,e/c)}for(let e=0;e.9&&Math.min(t,n,r)<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),r<.2&&(a[e+4]+=1))}}()}(),this.setAttribute(`position`,new Z(i,3)),this.setAttribute(`normal`,new Z(i.slice(),3)),this.setAttribute(`uv`,new Z(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.vertices,t.indices,t.radius,t.detail)}},Zr=class e extends Xr{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,r=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type=`DodecahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},Qr=new G,$r=new G,ei=new G,ti=new hn,ni=class extends Yn{constructor(e=null,t=1){if(super(),this.type=`EdgesGeometry`,this.parameters={geometry:e,thresholdAngle:t},e!==null){let n=1e4,r=Math.cos(Ge*t),i=e.getIndex(),a=e.getAttribute(`position`),o=i?i.count:a.count,s=[0,0,0],c=[`a`,`b`,`c`],l=[,,,],u={},d=[];for(let e=0;e0)){c=r;break}c=r-1}if(r=c,n[r]===a)return r/(i-1);let l=n[r];return(r+(a-l)/(n[r+1]-l))/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new W:new G);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new G,r=[],i=[],a=[],o=new G,s=new J;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new G)}i[0]=new G,a[0]=new G;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(U(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(!0===t){let t=Math.acos(U(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},ii=class extends ri{constructor(e=0,t=0,n=1,r=1,i=0,a=2*Math.PI,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type=`EllipseCurve`,this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t=new W){let n=t,r=2*Math.PI,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),!0!==this.aClockwise||a||(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},ai=class extends ii{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}};function oi(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i;return e+t*i+n*a+a*i*r}}}var si=new G,ci=new G,li=new oi,ui=new oi,di=new oi,fi=class extends ri{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new G){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o,s,c=Math.floor(a),l=a-c;this.closed?c+=c>0?0:(Math.floor(Math.abs(c)/i)+1)*i:l===0&&c===i-1&&(c=i-2,l=1),this.closed||c>0?o=r[(c-1)%i]:(ci.subVectors(r[0],r[1]).add(r[0]),o=ci);let u=r[c%i],d=r[(c+1)%i];if(this.closed||c+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(pi(o,s.x,c.x,l.x,u.x),pi(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){let e=r[i]-n,a=this.curves[i],o=a.getLength(),s=o===0?0:1-e/o;return a.getPointAt(s,t)}i++}return null}getLength(){let 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;let e=[],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){let e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);let l=c.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},Ei=class extends Ti{constructor(e){super(e),this.uuid=qe(),this.type=`Shape`,this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,r=this.holes.length;n80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;at&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return Ai(a,o,n,s,c,l,0),o}function Oi(e,t,n,r,i){let a;if(i===function(e,t,n,r){let i=0;for(let a=t,o=n-r;a0)for(let i=t;i=t;i-=r)a=Xi(i/r|0,e[i],e[i+1],a);return a&&Wi(a,a.next)&&(Zi(a),a=a.next),a}function ki(e,t){if(!e)return e;t||=e;let n,r=e;do if(n=!1,r.steiner||!Wi(r,r.next)&&Ui(r.prev,r,r.next)!==0)r=r.next;else{if(Zi(r),r=t=r.prev,r===r.next)break;n=!0}while(n||r!==t);return t}function Ai(e,t,n,r,i,a,o){if(!e)return;!o&&a&&function(e,t,n,r){let i=e;do i.z===0&&(i.z=Ri(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,n=1;do{let r,i=e;e=null;let a=null;for(t=0;i;){t++;let o=i,s=0;for(let e=0;e0||c>0&&o;)s!==0&&(c===0||!o||i.z<=o.z)?(r=i,i=i.nextZ,s--):(r=o,o=o.nextZ,c--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;i=o}a.nextZ=null,n*=2}while(t>1)}(i)}(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?Mi(e,r,i,a):ji(e))t.push(c.i,e.i,l.i),Zi(e),e=l.next,s=l.next;else if((e=l)===s){o?o===1?Ai(e=Ni(ki(e),t),t,n,r,i,a,2):o===2&&Pi(e,t,n,r,i,a):Ai(ki(e),t,n,r,i,a,1);break}}}function ji(e){let t=e.prev,n=e,r=e.next;if(Ui(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&Vi(i,s,a,c,o,l,m.x,m.y)&&Ui(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Mi(e,t,n,r){let i=e.prev,a=e,o=e.next;if(Ui(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=Ri(p,m,t,n,r),v=Ri(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Vi(s,u,c,d,l,f,y.x,y.y)&&Ui(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Vi(s,u,c,d,l,f,b.x,b.y)&&Ui(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Vi(s,u,c,d,l,f,y.x,y.y)&&Ui(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Vi(s,u,c,d,l,f,b.x,b.y)&&Ui(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Ni(e,t){let n=e;do{let r=n.prev,i=n.next.next;!Wi(r,i)&&Gi(r,n,n.next,i)&&Ji(r,i)&&Ji(i,r)&&(t.push(r.i,n.i,i.i),Zi(n),Zi(n.next),n=e=i),n=n.next}while(n!==e);return ki(n)}function Pi(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Hi(o,e)){let s=Yi(o,e);o=ki(o,o.next),s=ki(s,s.next),Ai(o,t,n,r,i,a,0),Ai(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function Fi(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0)&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),n}function Ii(e,t){let n=function(e,t){let n=t,r=e.x,i=e.y,a,o=-1/0;if(Wi(e,n))return n;do{if(Wi(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>o&&(o=e,a=n.x=n.x&&n.x>=c&&r!==n.x&&Bi(ia.x||n.x===a.x&&Li(a,n)))&&(a=n,u=t)}n=n.next}while(n!==s);return a}(e,t);if(!n)return t;let r=Yi(n,e);return ki(r,r.next),ki(n,n.next)}function Li(e,t){return Ui(e.prev,e,t.prev)<0&&Ui(t.next,e,e.next)<0}function Ri(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function zi(e){let t=e,n=e;do(t.x=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function Vi(e,t,n,r,i,a,o,s){return(e!==o||t!==s)&&Bi(e,t,n,r,i,a,o,s)}function Hi(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Gi(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(Ji(e,t)&&Ji(t,e)&&function(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}(e,t)&&(Ui(e.prev,e,t.prev)||Ui(e,t.prev,t))||Wi(e,t)&&Ui(e.prev,e,e.next)>0&&Ui(t.prev,t,t.next)>0)}function Ui(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Wi(e,t){return e.x===t.x&&e.y===t.y}function Gi(e,t,n,r){let i=qi(Ui(e,t,n)),a=qi(Ui(e,t,r)),o=qi(Ui(n,r,e)),s=qi(Ui(n,r,t));return i!==a&&o!==s||!(i!==0||!Ki(e,n,t))||!(a!==0||!Ki(e,r,t))||!(o!==0||!Ki(n,e,r))||!(s!==0||!Ki(n,t,r))}function Ki(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function qi(e){return e>0?1:e<0?-1:0}function Ji(e,t){return Ui(e.prev,e,e.next)<0?Ui(e,t,e.next)>=0&&Ui(e,e.prev,t)>=0:Ui(e,t,e.prev)<0||Ui(e,e.next,t)<0}function Yi(e,t){let n=Qi(e.i,e.x,e.y),r=Qi(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Xi(e,t,n,r){let i=Qi(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Zi(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Qi(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}var $i=class{static triangulate(e,t,n=2){return Di(e,t,n)}},ea=class e{static area(e){let t=e.length,n=0;for(let r=t-1,i=0;i2&&e[t-1].equals(e[0])&&e.pop()}function na(e,t){for(let n=0;n2**-52){let d=Math.sqrt(u),f=Math.sqrt(c*c+l*l),p=t.x-s/d,m=t.y+o/d,h=((n.x-l/f-p)*l-(n.y+c/f-m)*c)/(o*l-s*c);r=p+o*h-e.x,i=m+s*h-e.y;let g=r*r+i*i;if(g<=2)return new W(r,i);a=Math.sqrt(g/2)}else{let e=!1;o>2**-52?c>2**-52&&(e=!0):o<-(2**-52)?c<-(2**-52)&&(e=!0):Math.sign(s)===Math.sign(l)&&(e=!0),e?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new W(r/a,i/a)}let ee=[];for(let e=0,t=D.length,n=t-1,r=e+1;e=0;e--){let t=e/p,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=D.length;e=0;){let r=n,i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+2*p;e0)&&f.push(t,i,c),(e!==n-1||s0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let r=e.uniforms[n];switch(this.uniforms[n]={},r.type){case`t`:this.uniforms[n].value=t[r.value]||null;break;case`c`:this.uniforms[n].value=new X().setHex(r.value);break;case`v2`:this.uniforms[n].value=new W().fromArray(r.value);break;case`v3`:this.uniforms[n].value=new G().fromArray(r.value);break;case`v4`:this.uniforms[n].value=new ht().fromArray(r.value);break;case`m3`:this.uniforms[n].value=new q().fromArray(r.value);break;case`m4`:this.uniforms[n].value=new J().fromArray(r.value);break;default:this.uniforms[n].value=r.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let t in e.extensions)this.extensions[t]=e.extensions[t];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},wa=class extends Ca{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type=`RawShaderMaterial`}},Ta=class extends Zn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type=`MeshStandardMaterial`,this.defines={STANDARD:``},this.color=new X(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new X(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new W(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new kt,this.envMapIntensity=1,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.defines={STANDARD:``},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,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.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,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}},Ea=class extends Ta{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:``,PHYSICAL:``},this.type=`MeshPhysicalMaterial`,this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new W(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return U(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new X(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new X(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new X(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=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}},Da=class extends Zn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=3200,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}},Oa=class extends Zn{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}};function ka(e,t){return e&&e.constructor!==t?typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e):e}function Aa(e){let t=e.length,n=Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort(function(t,n){return e[t]-e[n]}),n}function ja(e,t,n){let r=e.length,i=new e.constructor(r);for(let a=0,o=0;o!==r;++a){let r=n[a]*t;for(let n=0;n!==t;++n)i[o++]=e[r+n]}return i}function Ma(e,t,n,r){let i=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[i++];if(a===void 0)return;let o=a[r];if(o!==void 0){if(Array.isArray(o))do o=a[r],o!==void 0&&(t.push(a.time),n.push(...o)),a=e[i++];while(a!==void 0);else if(o.toArray!==void 0)do o=a[r],o!==void 0&&(t.push(a.time),o.toArray(n,n.length)),a=e[i++];while(a!==void 0);else do o=a[r],o!==void 0&&(t.push(a.time),n.push(o)),a=e[i++];while(a!==void 0)}}var Na=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];t:{e:{let a;s:{i:if(!(e=i)){let o=t[1];e=i)break e}a=n,n=0;break s}break t}for(;n>>1;et;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(H(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(H(`KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){H(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){H(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&B(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){H(`KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===Te,i=e.length-1,a=1;for(let o=1;o0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=new this.constructor(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}};Ra.prototype.ValueTypeName=``,Ra.prototype.TimeBufferType=Float32Array,Ra.prototype.ValueBufferType=Float32Array,Ra.prototype.DefaultInterpolation=we;var za=class extends Ra{constructor(e,t,n){super(e,t,n)}};za.prototype.ValueTypeName=`bool`,za.prototype.ValueBufferType=Array,za.prototype.DefaultInterpolation=Ce,za.prototype.InterpolantFactoryMethodLinear=void 0,za.prototype.InterpolantFactoryMethodSmooth=void 0;var Ba=class extends Ra{constructor(e,t,n,r){super(e,t,n,r)}};Ba.prototype.ValueTypeName=`color`;var Va=class extends Ra{constructor(e,t,n,r){super(e,t,n,r)}};Va.prototype.ValueTypeName=`number`;var Ha=class extends Na{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)Qe.slerpFlat(i,0,a,c-o,a,c,s);return i}},Ua=class extends Ra{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new Ha(this.times,this.values,this.getValueSize(),e)}};Ua.prototype.ValueTypeName=`quaternion`,Ua.prototype.InterpolantFactoryMethodSmooth=void 0;var Wa=class extends Ra{constructor(e,t,n){super(e,t,n)}};Wa.prototype.ValueTypeName=`string`,Wa.prototype.ValueBufferType=Array,Wa.prototype.DefaultInterpolation=Ce,Wa.prototype.InterpolantFactoryMethodLinear=void 0,Wa.prototype.InterpolantFactoryMethodSmooth=void 0;var Ga=class extends Ra{constructor(e,t,n,r){super(e,t,n,r)}};Ga.prototype.ValueTypeName=`vector`;var Ka=class{constructor(e=``,t=-1,n=[],r=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=qe(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let e=0,i=n.length;e!==i;++e)t.push(qa(n[e]).scale(r));let i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i.userData=JSON.parse(e.userData||`{}`),i}static toJSON(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let e=0,r=n.length;e!==r;++e)t.push(Ra.toJSON(n[e]));return r}static CreateFromMorphTargetSequence(e,t,n,r){let i=t.length,a=[];for(let e=0;e1){let e=a[1],t=r[e];t||(r[e]=t=[]),t.push(n)}}let a=[];for(let e in r)a.push(this.CreateFromMorphTargetSequence(e,r[e],t,n));return a}resetDuration(){let e=0;for(let t=0,n=this.tracks.length;t!==n;++t){let n=this.tracks[t];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let e=t,i=t+t;e!==i;++e)if(n[e]!==n[e+t]){o.setValue(n,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let e=n,i=r;e!==i;++e)t[e]=t[r+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let r=0;r!==i;++r)e[t+r]=e[n+r]}_slerp(e,t,n,r){Qe.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,i){let a=this._workIndex*i;Qe.multiplyQuaternionsFlat(e,a,e,t,e,n),Qe.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,i){let a=1-r;for(let o=0;o!==i;++o){let i=t+o;e[i]=e[i]*a+e[n+o]*r}}_lerpAdditive(e,t,n,r,i){for(let a=0;a!==i;++a){let i=t+a;e[i]=e[i]+e[n+a]*r}}},bo=`\\[\\]\\.:\\/`,xo=RegExp(`[`+bo+`]`,`g`),So=`[^`+bo+`]`,Co=`[^`+bo.replace(`\\.`,``)+`]`,wo=RegExp(`^`+`((?:WC+[\\/:])*)`.replace(`WC`,So)+`(WCOD+)?`.replace(`WCOD`,Co)+`(?:\\.(WC+)(?:\\[(.+)\\])?)?`.replace(`WC`,So)+`\\.(WC+)(?:\\[(.+)\\])?`.replace(`WC`,So)+`$`),To=[`material`,`materials`,`bones`,`map`],Eo=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(xo,``)}static parseTrackName(e){let t=wo.exec(e);if(t===null)throw Error(`THREE.PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);To.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`THREE.PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r0){let e=this._interpolants,t=this._propertyBindings;if(this.blendMode===2501)for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulateAdditive(o);else for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulate(r,o)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;n!==null&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(t===0?this.paused=!0:(this._restoreTimeScale!==null&&(t=this._restoreTimeScale),this.timeScale=t),this.stopWarping()))}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,r=this.time+e,i=this._loopCount,a=n===2202;if(e===0)return i===-1||!a||1&~i?r:t-r;if(n===2200){i===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(r>=t)r=t;else{if(!(r<0)){this.time=r;break t}r=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:`finished`,action:this,direction:e<0?-1:1})}}else{if(i===-1&&(e>=0?(i=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,i+=Math.abs(n);let o=this.repetitions-i;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:`finished`,action:this,direction:e>0?1:-1});else{if(o===1){let t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:`loop`,action:this,loopDelta:n})}}else this._loopCount=i,this.time=r;if(a&&!(1&~i))return t-r}return r}_setEndings(e,t,n){let r=this._interpolantSettings;n?(r.endingStart=Oe,r.endingEnd=Oe):(r.endingStart=e?this.zeroSlopeAtStart?Oe:De:ke,r.endingEnd=t?this.zeroSlopeAtEnd?Oe:De:ke)}_scheduleFading(e,t,n){let r=this._mixer,i=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=t,o[1]=i+e,s[1]=n,this}},Oo=new Float32Array(1),ko=class extends Ue{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,r=e._clip.tracks,i=r.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];l===void 0&&(l={},c[s]=l);for(let e=0;e!==i;++e){let i=r[e],c=i.name,u=l[c];if(u!==void 0)++u.referenceCount,a[e]=u;else{if(u=a[e],u!==void 0){u._cacheIndex===null&&(++u.referenceCount,this._addInactiveBinding(u,s,c));continue}let r=t&&t._propertyBindings[e].binding.parsedPath;u=new yo(Eo.create(n,c,r),i.ValueTypeName,i.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,s,c),a[e]=u}o[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];n.useCount++===0&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];--n.useCount===0&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,r=this.time+=e,i=Math.sign(e),a=this._accuIndex^=1;for(let o=0;o!==n;++o)t[o]._update(r,e,i,a);let o=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)o[e].apply(a);return this}setTime(e){this.time=0;for(let e=0;ee.start-t.start);let t=0;for(let e=1;e 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`,clipping_planes_pars_fragment:`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,clipping_planes_pars_vertex:`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,clipping_planes_vertex:`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,color_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,color_pars_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,color_pars_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,color_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec4( 1.0 ); +#endif +#ifdef USE_COLOR_ALPHA + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,common:`#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 ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +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`,cube_uv_reflection_fragment:`#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`,defaultnormal_vertex:`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; +#endif`,displacementmap_pars_vertex:`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,displacementmap_vertex:`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,emissivemap_fragment:`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,emissivemap_pars_fragment:`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,colorspace_fragment:`gl_FragColor = linearToOutputTexel( gl_FragColor );`,colorspace_pars_fragment:`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 ); +}`,envmap_fragment:`#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 = transformNormalByInverseViewMatrix( 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 * reflectVec ); + #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 +#endif`,envmap_common_pars_fragment:`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,envmap_pars_fragment:`#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`,envmap_pars_vertex:`#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`,envmap_physical_pars_fragment:`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = transformNormalByInverseViewMatrix( 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, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( 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`,envmap_vertex:`#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 = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,fog_vertex:`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,fog_pars_vertex:`#ifdef USE_FOG + varying float vFogDepth; +#endif`,fog_fragment:`#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`,fog_pars_fragment:`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,gradientmap_pars_fragment:`#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 +}`,lightmap_pars_fragment:`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,lights_lambert_fragment:`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,lights_lambert_pars_fragment:`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`,lights_pars_begin:`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 = transformNormalByInverseViewMatrix( 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 +#include `,lights_toon_fragment:`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,lights_toon_pars_fragment:`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`,lights_phong_fragment:`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,lights_phong_pars_fragment:`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`,lights_physical_fragment:`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = 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 = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, 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.0001, 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`,lights_physical_pars_fragment:`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + 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; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #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 ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + 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.specularColorBlended; + 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 * transpose( 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 rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + 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 + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #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; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#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.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#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 ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +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 ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +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 ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#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 ); +}`,lights_fragment_begin:` +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.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + 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 ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + 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 + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,lights_fragment_maps:`#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( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #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`,lights_fragment_end:`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + 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`,lightprobes_pars_fragment:`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,logdepthbuf_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,logdepthbuf_pars_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,logdepthbuf_pars_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,logdepthbuf_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,map_fragment:`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,map_pars_fragment:`#ifdef USE_MAP + uniform sampler2D map; +#endif`,map_particle_fragment:`#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`,map_particle_pars_fragment:`#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`,metalnessmap_fragment:`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,metalnessmap_pars_fragment:`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,morphinstance_vertex:`#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`,morphcolor_vertex:`#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`,morphnormal_vertex:`#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`,morphtarget_pars_vertex:`#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`,morphtarget_vertex:`#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`,normal_fragment_begin:`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 + #ifdef DOUBLE_SIDED + 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 + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,normal_fragment_maps:`#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; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,normal_pars_fragment:`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,normal_pars_vertex:`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,normal_vertex:`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #endif +#endif`,normalmap_pars_fragment:`#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`,clearcoat_normal_fragment_begin:`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,clearcoat_normal_fragment_maps:`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,clearcoat_pars_fragment:`#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`,iridescence_pars_fragment:`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,opaque_fragment:`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,packing:`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 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +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 ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,premultiplied_alpha_fragment:`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,project_vertex:`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;`,dithering_fragment:`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,dithering_pars_fragment:`#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`,roughnessmap_fragment:`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,roughnessmap_pars_fragment:`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,shadowmap_pars_fragment:`#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 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + 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 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + 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 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + 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 + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow 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 ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + 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 ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + 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 ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,shadowmap_pars_vertex:`#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`,shadowmap_vertex:`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + 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`,shadowmask_pars_fragment:`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 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + 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; +}`,skinbase_vertex:`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,skinning_pars_vertex:`#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`,skinning_vertex:`#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`,skinnormal_vertex:`#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`,specularmap_fragment:`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,specularmap_pars_fragment:`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,tonemapping_fragment:`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,tonemapping_pars_fragment:`#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; }`,transmission_fragment:`#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 = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, 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`,transmission_pars_fragment:`#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`,uv_pars_fragment:`#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`,uv_pars_vertex:`#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`,uv_vertex:`#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`,worldpos_vertex:`#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`,background_vert:`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,background_frag:`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 +}`,backgroundCube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #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 +}`,cube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,cube_frag:`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 +}`,depth_vert:`#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; +}`,depth_frag:`#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 + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #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 +}`,distance_vert:`#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; +}`,distance_frag:`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#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 = vec4( dist, 0.0, 0.0, 1.0 ); +}`,equirect_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,equirect_frag:`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,linedashed_vert:`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 +}`,linedashed_frag:`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 +}`,meshbasic_vert:`#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 +}`,meshbasic_frag:`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 +}`,meshlambert_vert:`#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 +}`,meshlambert_frag:`#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 +#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 +}`,meshmatcap_vert:`#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; +}`,meshmatcap_frag:`#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 +}`,meshnormal_vert:`#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 +}`,meshnormal_frag:`#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 +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,meshphong_vert:`#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 +}`,meshphong_frag:`#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 +#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 +}`,meshphysical_vert:`#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 +}`,meshphysical_frag:`#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 +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 + + outgoingLight = outgoingLight + 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 +}`,meshtoon_vert:`#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 +}`,meshtoon_frag:`#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 +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 +}`,points_vert:`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 +}`,points_frag:`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 +}`,shadow_vert:`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,shadow_frag:`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,sprite_vert:`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 +}`,sprite_frag:`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 +}`},$={common:{diffuse:{value:new X(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new q},alphaMap:{value:null},alphaMapTransform:{value:new q},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new q}},envmap:{envMap:{value:null},envMapRotation:{value:new q},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new q}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new q}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new q},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new q},normalScale:{value:new W(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new q},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new q}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new q}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new q}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new X(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new G},probesMax:{value:new G},probesResolution:{value:new G}},points:{diffuse:{value:new X(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new q},alphaTest:{value:0},uvTransform:{value:new q}},sprite:{diffuse:{value:new X(16777215)},opacity:{value:1},center:{value:new W(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new q},alphaMap:{value:null},alphaMapTransform:{value:new q},alphaTest:{value:0}}},Lo={basic:{uniforms:ya([$.common,$.specularmap,$.envmap,$.aomap,$.lightmap,$.fog]),vertexShader:Q.meshbasic_vert,fragmentShader:Q.meshbasic_frag},lambert:{uniforms:ya([$.common,$.specularmap,$.envmap,$.aomap,$.lightmap,$.emissivemap,$.bumpmap,$.normalmap,$.displacementmap,$.fog,$.lights,{emissive:{value:new X(0)},envMapIntensity:{value:1}}]),vertexShader:Q.meshlambert_vert,fragmentShader:Q.meshlambert_frag},phong:{uniforms:ya([$.common,$.specularmap,$.envmap,$.aomap,$.lightmap,$.emissivemap,$.bumpmap,$.normalmap,$.displacementmap,$.fog,$.lights,{emissive:{value:new X(0)},specular:{value:new X(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Q.meshphong_vert,fragmentShader:Q.meshphong_frag},standard:{uniforms:ya([$.common,$.envmap,$.aomap,$.lightmap,$.emissivemap,$.bumpmap,$.normalmap,$.displacementmap,$.roughnessmap,$.metalnessmap,$.fog,$.lights,{emissive:{value:new X(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Q.meshphysical_vert,fragmentShader:Q.meshphysical_frag},toon:{uniforms:ya([$.common,$.aomap,$.lightmap,$.emissivemap,$.bumpmap,$.normalmap,$.displacementmap,$.gradientmap,$.fog,$.lights,{emissive:{value:new X(0)}}]),vertexShader:Q.meshtoon_vert,fragmentShader:Q.meshtoon_frag},matcap:{uniforms:ya([$.common,$.bumpmap,$.normalmap,$.displacementmap,$.fog,{matcap:{value:null}}]),vertexShader:Q.meshmatcap_vert,fragmentShader:Q.meshmatcap_frag},points:{uniforms:ya([$.points,$.fog]),vertexShader:Q.points_vert,fragmentShader:Q.points_frag},dashed:{uniforms:ya([$.common,$.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Q.linedashed_vert,fragmentShader:Q.linedashed_frag},depth:{uniforms:ya([$.common,$.displacementmap]),vertexShader:Q.depth_vert,fragmentShader:Q.depth_frag},normal:{uniforms:ya([$.common,$.bumpmap,$.normalmap,$.displacementmap,{opacity:{value:1}}]),vertexShader:Q.meshnormal_vert,fragmentShader:Q.meshnormal_frag},sprite:{uniforms:ya([$.sprite,$.fog]),vertexShader:Q.sprite_vert,fragmentShader:Q.sprite_frag},background:{uniforms:{uvTransform:{value:new q},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Q.background_vert,fragmentShader:Q.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new q}},vertexShader:Q.backgroundCube_vert,fragmentShader:Q.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Q.cube_vert,fragmentShader:Q.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Q.equirect_vert,fragmentShader:Q.equirect_frag},distance:{uniforms:ya([$.common,$.displacementmap,{referencePosition:{value:new G},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Q.distance_vert,fragmentShader:Q.distance_frag},shadow:{uniforms:ya([$.lights,$.fog,{color:{value:new X(0)},opacity:{value:1}}]),vertexShader:Q.shadow_vert,fragmentShader:Q.shadow_frag}};Lo.physical={uniforms:ya([Lo.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new q},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new q},clearcoatNormalScale:{value:new W(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new q},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new q},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new q},sheen:{value:0},sheenColor:{value:new X(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new q},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new q},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new q},transmissionSamplerSize:{value:new W},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new q},attenuationDistance:{value:0},attenuationColor:{value:new X(0)},specularColor:{value:new X(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new q},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new q},anisotropyVector:{value:new W},anisotropyMap:{value:null},anisotropyMapTransform:{value:new q}}]),vertexShader:Q.meshphysical_vert,fragmentShader:Q.meshphysical_frag};var Ro={r:0,b:0,g:0},zo=new J,Bo=new q;function Vo(e,t,n,r,i,a){let o=new X(0),s,c,l=!0===i?0:1,u=null,d=0,f=null;function p(e){let n=!0===e.isScene?e.background:null;if(n&&n.isTexture){let r=e.backgroundBlurriness>0;n=t.get(n,r)}return n}function m(t,r){t.getRGB(Ro,xa(e)),n.buffers.color.setClear(Ro.r,Ro.g,Ro.b,r,a)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),l=t,m(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(e){l=e,m(o,l)},render:function(t){let r=!1,i=p(t);i===null?m(o,l):i&&i.isColor&&(m(i,1),r=!0);let s=e.xr.getEnvironmentBlendMode();s===`additive`?n.buffers.color.setClear(0,0,0,1,a):s===`alpha-blend`&&n.buffers.color.setClear(0,0,0,0,a),(e.autoClear||r)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){let i=p(n);i&&(i.isCubeTexture||i.mapping===306)?(c===void 0&&(c=new vr(new Gr(1,1,1),new Ca({name:`BackgroundCubeMaterial`,uniforms:va(Lo.backgroundCube.uniforms),vertexShader:Lo.backgroundCube.vertexShader,fragmentShader:Lo.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute(`normal`),c.geometry.deleteAttribute(`uv`),c.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),c.material.uniforms.envMap.value=i,c.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(zo.makeRotationFromEuler(n.backgroundRotation)).transpose(),i.isCubeTexture&&!1===i.isRenderTargetTexture&&c.material.uniforms.backgroundRotation.value.premultiply(Bo),c.material.toneMapped=it.getTransfer(i.colorSpace)!==Ne,u===i&&d===i.version&&f===e.toneMapping||(c.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),c.layers.enableAll(),t.unshift(c,c.geometry,c.material,0,0,null)):i&&i.isTexture&&(s===void 0&&(s=new vr(new ca(2,2),new Ca({name:`BackgroundMaterial`,uniforms:va(Lo.background.uniforms),vertexShader:Lo.background.vertexShader,fragmentShader:Lo.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),s.geometry.deleteAttribute(`normal`),Object.defineProperty(s.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(s)),s.material.uniforms.t2D.value=i,s.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,s.material.toneMapped=it.getTransfer(i.colorSpace)!==`srgb`,!0===i.matrixAutoUpdate&&i.updateMatrix(),s.material.uniforms.uvTransform.value.copy(i.matrix),u===i&&d===i.version&&f===e.toneMapping||(s.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),s.layers.enableAll(),t.unshift(s,s.geometry,s.material,0,0,null))},dispose:function(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),s!==void 0&&(s.geometry.dispose(),s.material.dispose(),s=void 0)}}}function Ho(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=l(null),a=i,o=!1;function s(t){return e.bindVertexArray(t)}function c(t){return e.deleteVertexArray(t)}function l(e){let t=[],r=[],i=[];for(let e=0;e=0){let n=i[t],r=o[t];if(r===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(r=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(r=e.instanceColor)),n===void 0||n.attribute!==r||r&&n.data!==r.data)return!0;s++}return a.attributesNum!==s||a.index!==r}(n,h,c,g),_&&function(e,t,n,r){let i={},o=t.attributes,s=0,c=n.getAttributes();for(let t in c)if(c[t].location>=0){let n=o[t];n===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(n=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(n=e.instanceColor));let r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,s++}a.attributes=i,a.attributesNum=s,a.index=r}(n,h,c,g),g!==null&&t.update(g,e.ELEMENT_ARRAY_BUFFER),(_||o)&&(o=!1,function(n,r,i,a){u();let o=a.attributes,s=i.getAttributes(),c=r.defaultAttributeValues;for(let r in s){let i=s[r];if(i.location>=0){let s=o[r];if(s===void 0&&(r===`instanceMatrix`&&n.instanceMatrix&&(s=n.instanceMatrix),r===`instanceColor`&&n.instanceColor&&(s=n.instanceColor)),s!==void 0){let r=s.normalized,o=s.itemSize,c=t.get(s);if(c===void 0)continue;let l=c.buffer,u=c.type,p=c.bytesPerElement,h=u===e.INT||u===e.UNSIGNED_INT||s.gpuType===1013;if(s.isInterleavedBufferAttribute){let t=s.data,c=t.stride,g=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return`highp`;t=`mediump`}return t===`mediump`&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?`mediump`:`lowp`}let o=n.precision===void 0?`highp`:n.precision,s=a(o);s!==o&&(V(`WebGLRenderer:`,o,`not supported, using`,s,`instead.`),o=s);let c=!0===n.logarithmicDepthBuffer,l=!0===n.reversedDepthBuffer&&t.has(`EXT_clip_control`);return!0===n.reversedDepthBuffer&&!1===l&&V(`WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.`),{isWebGL2:!0,getMaxAnisotropy:function(){if(i!==void 0)return i;if(!0===t.has(`EXT_texture_filter_anisotropic`)){let n=t.get(`EXT_texture_filter_anisotropic`);i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:a,textureFormatReadable:function(t){return t===1023||r.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){let i=n===1016&&(t.has(`EXT_color_buffer_half_float`)||t.has(`EXT_color_buffer_float`));return!(n!==1009&&r.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==1015&&!i)},precision:o,logarithmicDepthBuffer:c,reversedDepthBuffer:l,maxTextures:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:e.getParameter(e.MAX_SAMPLES),samples:e.getParameter(e.SAMPLES)}}function Go(e){let t=this,n=null,r=0,i=!1,a=!1,o=new Nr,s=new q,c={value:null,needsUpdate:!1};function l(e,n,r,i){let a=e===null?0:e.length,l=null;if(a!==0){if(l=c.value,!0!==i||l===null){let t=r+4*a,i=n.matrixWorldInverse;s.getNormalMatrix(i),(l===null||l.length0),t.numPlanes=r,t.numIntersection=0}();else{let e=a?0:r,t=4*e,i=m.clippingState||null;c.value=i,i=l(d,s,t,u);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}}}Bo.set(-1,0,0,0,1,0,0,0,1);var Ko=[.125,.215,.35,.446,.526,.582],qo=20,Jo=new po,Yo=new X,Xo=null,Zo=0,Qo=0,$o=!1,es=new G,ts=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,r=100,i={}){let{size:a=256,position:o=es}=i;Xo=this._renderer.getRenderTarget(),Zo=this._renderer.getActiveCubeFace(),Qo=this._renderer.getActiveMipmapLevel(),$o=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,r,s,o),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=as(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=is(),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())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?s=Ko[o-e+4-1]:o===0&&(s=0),n.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];f.set(r,18*e),p.set(d,12*e);let i=[e,e,e,e,e,e];m.set(i,6*e)}let h=new Yn;h.setAttribute(`position`,new Fn(f,3)),h.setAttribute(`uv`,new Fn(p,2)),h.setAttribute(`faceIndex`,new Fn(m,1)),r.push(new vr(h,null)),i>4&&i--}return{lodMeshes:r,sizeLods:t,sigmas:n}}(r)),this._blurMaterial=function(e,t,n){let r=new Float32Array(qo),i=new G(0,1,0);return new Ca({name:`SphericalGaussianBlur`,defines:{n:qo,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:os(),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:0,depthTest:!1,depthWrite:!1})}(r,e,t),this._ggxMaterial=function(e,t,n){return new Ca({name:`PMREMGGXConvolution`,defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:os(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:0,depthTest:!1,depthWrite:!1})}(r,e,t)}return r}_compileMaterial(e){let t=new vr(new Yn,e);this._renderer.compile(t,Jo)}_sceneToCubeUV(e,t,n,r,i){let a=new so(90,1,t,n),o=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],c=this._renderer,l=c.autoClear,u=c.toneMapping;c.getClearColor(Yo),c.toneMapping=0,c.autoClear=!1,c.state.buffers.depth.getReversed()&&(c.setRenderTarget(r),c.clearDepth(),c.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new vr(new Gr,new or({name:`PMREM.Background`,side:1,depthWrite:!1,depthTest:!1})));let d=this._backgroundBox,f=d.material,p=!1,m=e.background;m?m.isColor&&(f.color.copy(m),e.background=null,p=!0):(f.color.copy(Yo),p=!0);for(let t=0;t<6;t++){let n=t%3;n===0?(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x+s[t],i.y,i.z)):n===1?(a.up.set(0,0,o[t]),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y+s[t],i.z)):(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y,i.z+s[t]));let l=this._cubeSize;rs(r,n*l,t>2?l:0,l,l),c.setRenderTarget(r),p&&c.render(d,a),c.render(e,a)}c.toneMapping=u,c.autoClear=l,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=as()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=is());let i=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=i,i.uniforms.envMap.value=e;let o=this._cubeSize;rs(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,Jo)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;td-4?n-d+4:0),m=4*(this._cubeSize-f);s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,rs(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,Jo),s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,rs(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,Jo)}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&H(`blur direction must be either latitudinal or longitudinal!`);let l=this._lodMeshes[r];l.material=c;let u=c.uniforms,d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/39,p=i/f,m=isFinite(i)?1+Math.floor(3*p):qo;m>qo&&V(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);let h=[],g=0;for(let e=0;e_-4?r-_+4:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,Jo)}};function ns(e,t,n){let r=new _t(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.scissorTest=!0,r}function rs(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function is(){return new Ca({name:`EquirectangularToCubeUV`,uniforms:{envMap:{value:null}},vertexShader:os(),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:0,depthTest:!1,depthWrite:!1})}function as(){return new Ca({name:`CubemapToCubeUV`,uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:os(),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:0,depthTest:!1,depthWrite:!1})}function os(){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 ); + + } + `}var ss=class extends _t{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new Vr(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}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;let 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 Gr(5,5,5),i=new Ca({name:`CubemapFromEquirect`,uniforms:va(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;let a=new vr(r,i),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=1006),new _o(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}};function cs(e){let t=new WeakMap,n=new WeakMap,r=null;function i(e,t){return t===303?e.mapping=301:t===304&&(e.mapping=302),e}function a(e){let n=e.target;n.removeEventListener(`dispose`,a);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function o(e){let t=e.target;t.removeEventListener(`dispose`,o);let r=n.get(t);r!==void 0&&(n.delete(t),r.dispose())}return{get:function(s,c=!1){return s==null?null:c?function(t){if(t&&t.isTexture){let i=t.mapping,a=i===303||i===304,s=i===301||i===302;if(a||s){let i=n.get(t),c=i===void 0?0:i.texture.pmremVersion;if(t.isRenderTargetTexture&&t.pmremVersion!==c)return r===null&&(r=new ts(e)),i=a?r.fromEquirectangular(t,i):r.fromCubemap(t,i),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),i.texture;if(i!==void 0)return i.texture;{let c=t.image;return a&&c&&c.height>0||s&&c&&function(e){let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}(c)?(r===null&&(r=new ts(e)),i=a?r.fromEquirectangular(t):r.fromCubemap(t),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),t.addEventListener(`dispose`,o),i.texture):null}}}return t}(s):function(n){if(n&&n.isTexture){let r=n.mapping;if(r===303||r===304){if(t.has(n))return i(t.get(n).texture,n.mapping);{let r=n.image;if(r&&r.height>0){let o=new ss(r.height);return o.fromEquirectangularTexture(e,n),t.set(n,o),n.addEventListener(`dispose`,a),i(o.texture,n.mapping)}return null}}}return n}(s)},dispose:function(){t=new WeakMap,n=new WeakMap,r!==null&&(r.dispose(),r=null)}}}function ls(e){let t={};function n(n){if(t[n]!==void 0)return t[n];let r=e.getExtension(n);return t[n]=r,r}return{has:function(e){return n(e)!==null},init:function(){n(`EXT_color_buffer_float`),n(`WEBGL_clip_cull_distance`),n(`OES_texture_float_linear`),n(`EXT_color_buffer_half_float`),n(`WEBGL_multisampled_render_to_texture`),n(`WEBGL_render_shared_exponent`)},get:function(e){let t=n(e);return t===null&&Be(`WebGLRenderer: `+e+` extension not supported.`),t}}}function us(e,t,n,r){let i={},a=new WeakMap;function o(e){let s=e.target;s.index!==null&&t.remove(s.index);for(let e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener(`dispose`,o),delete i[s.id];let c=a.get(s);c&&(t.remove(c),a.delete(s)),r.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){let n=[],r=e.index,i=e.attributes.position,o=0;if(i===void 0)return;if(r!==null){let e=r.array;o=r.version;for(let t=0,r=e.length;t=65535?Ln:In)(n,1);s.version=o;let c=a.get(e);c&&t.remove(c),a.set(e,s)}return{get:function(e,t){return!0===i[t.id]||(t.addEventListener(`dispose`,o),i[t.id]=!0,n.memory.geometries++),t},update:function(n){let r=n.attributes;for(let n in r)t.update(r[n],e.ARRAY_BUFFER)},getWireframeAttribute:function(e){let t=a.get(e);if(t){let n=e.index;n!==null&&t.versiont.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let h=new Float32Array(p*m*4*u),g=new vt(h,p,m,u);g.type=I,g.needsUpdate=!0;let _=4*f;for(let t=0;t + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),u=new vr(c,l),d=new po(-1,1,1,-1,0,1),f,p=null,m=null,h=!1,g=null,_=[],v=!1;this.setSize=function(e,t){o.setSize(e,t),s.setSize(e,t);for(let n=0;n<_.length;n++){let r=_[n];r.setSize&&r.setSize(e,t)}},this.setEffects=function(e){_=e,v=_.length>0&&!0===_[0].isRenderPass;let t=o.width,n=o.height;for(let e=0;e<_.length;e++){let r=_[e];r.setSize&&r.setSize(t,n)}},this.begin=function(e,t){if(h||e.toneMapping===0&&_.length===0)return!1;if(g=t,t!==null){let e=t.width,n=t.height;o.width===e&&o.height===n||this.setSize(e,n)}return!1===v&&e.setRenderTarget(o),f=e.toneMapping,e.toneMapping=0,!0},this.hasRenderPass=function(){return v},this.end=function(e,t){e.toneMapping=f,h=!0;let n=o,r=s;for(let i=0;i<_.length;i++){let a=_[i];if(!1!==a.enabled&&(a.render(e,r,n,t),!1!==a.needsSwap)){let e=n;n=r,r=e}}if(p!==e.outputColorSpace||m!==e.toneMapping){p=e.outputColorSpace,m=e.toneMapping,l.defines={},it.getTransfer(p)===`srgb`&&(l.defines.SRGB_TRANSFER=``);let t=hs[m];t&&(l.defines[t]=``),l.needsUpdate=!0}l.uniforms.tDiffuse.value=n.texture,e.setRenderTarget(g),e.render(u,d),g=null,h=!1},this.isCompositing=function(){return h},this.dispose=function(){o.depthTexture&&o.depthTexture.dispose(),o.dispose(),s.dispose(),c.dispose(),l.dispose()}}var _s=new mt,vs=new Hr(1,1),ys=new vt,bs=new yt,xs=new Vr,Ss=[],Cs=[],ws=new Float32Array(16),Ts=new Float32Array(9),Es=new Float32Array(4);function Ds(e,t,n){let r=e[0];if(r<=0||r>0)return e;let i=t*n,a=Ss[i];if(a===void 0&&(a=new Float32Array(i),Ss[i]=a),t!==0){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function Os(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n0&&(this.seq=r.concat(i))}setValue(e,t,n,r){let i=this.map[t];i!==void 0&&i.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){let a=t[i],o=n[a.id];!1!==o.needsUpdate&&a.setValue(e,o.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,i=e.length;r!==i;++r){let i=e[r];i.id in t&&n.push(i)}return n}};function Sc(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}var Cc=0,wc=new q;function Tc(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||``).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+` + +`+i+` + +`+function(e,t){let n=e.split(` +`),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e`:` `} ${i}: ${n[e]}`)}return r.join(` +`)}(e.getShaderSource(t),r)}return i}function Ec(e,t){let n=function(e){it._getMatrix(wc,it.workingColorSpace,e);let t=`mat3( ${wc.elements.map(e=>e.toFixed(4))} )`;switch(it.getTransfer(e)){case Me:return[t,`LinearTransferOETF`];case Ne:return[t,`sRGBTransferOETF`];default:return V(`WebGLProgram: Unsupported color space: `,e),[t,`LinearTransferOETF`]}}(t);return[`vec4 ${e}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,`}`].join(` +`)}var Dc={1:`Linear`,2:`Reinhard`,3:`Cineon`,4:`ACESFilmic`,6:`AgX`,7:`Neutral`,5:`Custom`};function Oc(e,t){let n=Dc[t];return n===void 0?(V(`WebGLProgram: Unsupported toneMapping:`,t),`vec3 `+e+`( vec3 color ) { return LinearToneMapping( color ); }`):`vec3 `+e+`( vec3 color ) { return `+n+`ToneMapping( color ); }`}var kc=new G;function Ac(){return it.getLuminanceCoefficients(kc),[`float luminance( const in vec3 rgb ) {`,`\tconst vec3 weights = vec3( ${kc.x.toFixed(4)}, ${kc.y.toFixed(4)}, ${kc.z.toFixed(4)} );`,` return dot( weights, rgb );`,`}`].join(` +`)}function jc(e){return e!==``}function Mc(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Nc(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var Pc=/^[ \t]*#include +<([\w\d./]+)>/gm;function Fc(e){return e.replace(Pc,Lc)}var Ic=new Map;function Lc(e,t){let n=Q[t];if(n===void 0){let e=Ic.get(t);if(e===void 0)throw Error(`THREE.WebGLProgram: Can not resolve #include <`+t+`>`);n=Q[e],V(`WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.`,t,e)}return Fc(n)}var Rc=/#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 zc(e){return e.replace(Rc,Bc)}function Bc(e,t,n,r){let i=``;for(let e=parseInt(t);e0&&(g+=` +`),_=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(jc).join(` +`),_.length>0&&(_+=` +`)):(g=[Vc(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.extensionClipCullDistance?`#define USE_CLIP_DISTANCE`:``,n.batching?`#define USE_BATCHING`:``,n.batchingColor?`#define USE_BATCHING_COLOR`:``,n.instancing?`#define USE_INSTANCING`:``,n.instancingColor?`#define USE_INSTANCING_COLOR`:``,n.instancingMorph?`#define USE_INSTANCING_MORPH`:``,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.map?`#define USE_MAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+u:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.displacementMap?`#define USE_DISPLACEMENTMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.mapUv?`#define MAP_UV `+n.mapUv:``,n.alphaMapUv?`#define ALPHAMAP_UV `+n.alphaMapUv:``,n.lightMapUv?`#define LIGHTMAP_UV `+n.lightMapUv:``,n.aoMapUv?`#define AOMAP_UV `+n.aoMapUv:``,n.emissiveMapUv?`#define EMISSIVEMAP_UV `+n.emissiveMapUv:``,n.bumpMapUv?`#define BUMPMAP_UV `+n.bumpMapUv:``,n.normalMapUv?`#define NORMALMAP_UV `+n.normalMapUv:``,n.displacementMapUv?`#define DISPLACEMENTMAP_UV `+n.displacementMapUv:``,n.metalnessMapUv?`#define METALNESSMAP_UV `+n.metalnessMapUv:``,n.roughnessMapUv?`#define ROUGHNESSMAP_UV `+n.roughnessMapUv:``,n.anisotropyMapUv?`#define ANISOTROPYMAP_UV `+n.anisotropyMapUv:``,n.clearcoatMapUv?`#define CLEARCOATMAP_UV `+n.clearcoatMapUv:``,n.clearcoatNormalMapUv?`#define CLEARCOAT_NORMALMAP_UV `+n.clearcoatNormalMapUv:``,n.clearcoatRoughnessMapUv?`#define CLEARCOAT_ROUGHNESSMAP_UV `+n.clearcoatRoughnessMapUv:``,n.iridescenceMapUv?`#define IRIDESCENCEMAP_UV `+n.iridescenceMapUv:``,n.iridescenceThicknessMapUv?`#define IRIDESCENCE_THICKNESSMAP_UV `+n.iridescenceThicknessMapUv:``,n.sheenColorMapUv?`#define SHEEN_COLORMAP_UV `+n.sheenColorMapUv:``,n.sheenRoughnessMapUv?`#define SHEEN_ROUGHNESSMAP_UV `+n.sheenRoughnessMapUv:``,n.specularMapUv?`#define SPECULARMAP_UV `+n.specularMapUv:``,n.specularColorMapUv?`#define SPECULAR_COLORMAP_UV `+n.specularColorMapUv:``,n.specularIntensityMapUv?`#define SPECULAR_INTENSITYMAP_UV `+n.specularIntensityMapUv:``,n.transmissionMapUv?`#define TRANSMISSIONMAP_UV `+n.transmissionMapUv:``,n.thicknessMapUv?`#define THICKNESSMAP_UV `+n.thicknessMapUv:``,n.vertexTangents&&!1===n.flatShading?`#define USE_TANGENT`:``,n.vertexNormals?`#define HAS_NORMAL`:``,n.vertexColors?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.flatShading?`#define FLAT_SHADED`:``,n.skinning?`#define USE_SKINNING`:``,n.morphTargets?`#define USE_MORPHTARGETS`:``,n.morphNormals&&!1===n.flatShading?`#define USE_MORPHNORMALS`:``,n.morphColors?`#define USE_MORPHCOLORS`:``,n.morphTargetsCount>0?`#define MORPHTARGETS_TEXTURE_STRIDE `+n.morphTextureStride:``,n.morphTargetsCount>0?`#define MORPHTARGETS_COUNT `+n.morphTargetsCount:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.sizeAttenuation?`#define USE_SIZEATTENUATION`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`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(jc).join(` +`),_=[Vc(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.alphaToCoverage?`#define ALPHA_TO_COVERAGE`:``,n.map?`#define USE_MAP`:``,n.matcap?`#define USE_MATCAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+l:``,n.envMap?`#define `+u:``,n.envMap?`#define `+d:``,f?`#define CUBEUV_TEXEL_WIDTH `+f.texelWidth:``,f?`#define CUBEUV_TEXEL_HEIGHT `+f.texelHeight:``,f?`#define CUBEUV_MAX_MIP `+f.maxMip+`.0`:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.packedNormalMap?`#define USE_PACKED_NORMALMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoat?`#define USE_CLEARCOAT`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.dispersion?`#define USE_DISPERSION`:``,n.iridescence?`#define USE_IRIDESCENCE`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaTest?`#define USE_ALPHATEST`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.sheen?`#define USE_SHEEN`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.vertexTangents&&!1===n.flatShading?`#define USE_TANGENT`:``,n.vertexColors||n.instancingColor?`#define USE_COLOR`:``,n.vertexAlphas||n.batchingColor?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.gradientMap?`#define USE_GRADIENTMAP`:``,n.flatShading?`#define FLAT_SHADED`:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.premultipliedAlpha?`#define PREMULTIPLIED_ALPHA`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.numLightProbeGrids>0?`#define USE_LIGHT_PROBES_GRID`:``,n.decodeVideoTexture?`#define DECODE_VIDEO_TEXTURE`:``,n.decodeVideoTextureEmissive?`#define DECODE_VIDEO_TEXTURE_EMISSIVE`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`uniform mat4 viewMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,n.toneMapping===0?``:`#define TONE_MAPPING`,n.toneMapping===0?``:Q.tonemapping_pars_fragment,n.toneMapping===0?``:Oc(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,Q.colorspace_pars_fragment,Ec(`linearToOutputTexel`,n.outputColorSpace),Ac(),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,` +`].filter(jc).join(` +`)),o=Fc(o),o=Mc(o,n),o=Nc(o,n),s=Fc(s),s=Mc(s,n),s=Nc(s,n),o=zc(o),s=zc(s),!0!==n.isRawShaderMaterial&&(v=`#version 300 es +`,g=[p,`#define attribute in`,`#define varying out`,`#define texture2D texture`].join(` +`)+` +`+g,_=[`#define varying in`,n.glslVersion===`300 es`?``:`layout(location = 0) out highp vec4 pc_fragColor;`,n.glslVersion===`300 es`?``:`#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(` +`)+` +`+_);let y=v+g+o,b=v+_+s,x=Sc(i,i.VERTEX_SHADER,y),S=Sc(i,i.FRAGMENT_SHADER,b);function C(t){if(e.debug.checkShaderErrors){let n=i.getProgramInfoLog(h)||``,r=i.getShaderInfoLog(x)||``,a=i.getShaderInfoLog(S)||``,o=n.trim(),s=r.trim(),c=a.trim(),l=!0,u=!0;if(!1===i.getProgramParameter(h,i.LINK_STATUS)){if(l=!1,typeof e.debug.onShaderError==`function`)e.debug.onShaderError(i,h,x,S);else{let e=Tc(i,x,`vertex`),n=Tc(i,S,`fragment`);H(`WebGLProgram: Shader Error `+i.getError()+` - VALIDATE_STATUS `+i.getProgramParameter(h,i.VALIDATE_STATUS)+` + +Material Name: `+t.name+` +Material Type: `+t.type+` + +Program Info Log: `+o+` +`+e+` +`+n)}}else o===``?s!==``&&c!==``||(u=!1):V(`WebGLProgram: Program Info Log:`,o);u&&(t.diagnostics={runnable:l,programLog:o,vertexShader:{log:s,prefix:g},fragmentShader:{log:c,prefix:_}})}i.deleteShader(x),i.deleteShader(S),w=new xc(i,h),T=function(e,t){let n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i0,ue=i.clearcoat>0,de=i.dispersion>0,fe=i.iridescence>0,pe=i.sheen>0,me=i.transmission>0,he=le&&!!i.anisotropyMap,L=ue&&!!i.clearcoatMap,ge=ue&&!!i.clearcoatNormalMap,_e=ue&&!!i.clearcoatRoughnessMap,ve=fe&&!!i.iridescenceMap,ye=fe&&!!i.iridescenceThicknessMap,be=pe&&!!i.sheenColorMap,xe=pe&&!!i.sheenRoughnessMap,Se=!!i.specularMap,Ce=!!i.specularColorMap,we=!!i.specularIntensityMap,Te=me&&!!i.transmissionMap,Ee=me&&!!i.thicknessMap,De=!!i.gradientMap,Oe=!!i.alphaMap,ke=i.alphaTest>0,Ae=!!i.alphaHash,je=!!i.extensions,Me=0;i.toneMapped&&(ee!==null&&!0!==ee.isXRRenderTarget||(Me=e.toneMapping));let Ne={shaderID:C,shaderType:i.type,shaderName:i.name,vertexShader:E,fragmentShader:D,defines:i.defines,customVertexShaderID:O,customFragmentShaderID:k,isRawShaderMaterial:!0===i.isRawShaderMaterial,glslVersion:i.glslVersion,precision:f,batching:N,batchingColor:N&&h._colorsTexture!==null,instancing:M,instancingColor:M&&h.instanceColor!==null,instancingMorph:M&&h.morphTexture!==null,outputColorSpace:ee===null?e.outputColorSpace:!0===ee.isXRRenderTarget?ee.texture.colorSpace:it.workingColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:te,matcap:P,envMap:ne,envMapMode:ne&&x.mapping,envMapCubeUVHeight:S,aoMap:re,lightMap:ie,bumpMap:ae,normalMap:oe,displacementMap:se,emissiveMap:F,normalMapObjectSpace:oe&&i.normalMapType===1,normalMapTangentSpace:oe&&i.normalMapType===0,packedNormalMap:oe&&i.normalMapType===0&&(R=i.normalMap.format,R===1030||R===37490||R===36285),metalnessMap:ce,roughnessMap:I,anisotropy:le,anisotropyMap:he,clearcoat:ue,clearcoatMap:L,clearcoatNormalMap:ge,clearcoatRoughnessMap:_e,dispersion:de,iridescence:fe,iridescenceMap:ve,iridescenceThicknessMap:ye,sheen:pe,sheenColorMap:be,sheenRoughnessMap:xe,specularMap:Se,specularColorMap:Ce,specularIntensityMap:we,transmission:me,transmissionMap:Te,thicknessMap:Ee,gradientMap:De,opaque:!1===i.transparent&&i.blending===1&&!1===i.alphaToCoverage,alphaMap:Oe,alphaTest:ke,alphaHash:Ae,combine:i.combine,mapUv:te&&m(i.map.channel),aoMapUv:re&&m(i.aoMap.channel),lightMapUv:ie&&m(i.lightMap.channel),bumpMapUv:ae&&m(i.bumpMap.channel),normalMapUv:oe&&m(i.normalMap.channel),displacementMapUv:se&&m(i.displacementMap.channel),emissiveMapUv:F&&m(i.emissiveMap.channel),metalnessMapUv:ce&&m(i.metalnessMap.channel),roughnessMapUv:I&&m(i.roughnessMap.channel),anisotropyMapUv:he&&m(i.anisotropyMap.channel),clearcoatMapUv:L&&m(i.clearcoatMap.channel),clearcoatNormalMapUv:ge&&m(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:_e&&m(i.clearcoatRoughnessMap.channel),iridescenceMapUv:ve&&m(i.iridescenceMap.channel),iridescenceThicknessMapUv:ye&&m(i.iridescenceThicknessMap.channel),sheenColorMapUv:be&&m(i.sheenColorMap.channel),sheenRoughnessMapUv:xe&&m(i.sheenRoughnessMap.channel),specularMapUv:Se&&m(i.specularMap.channel),specularColorMapUv:Ce&&m(i.specularColorMap.channel),specularIntensityMapUv:we&&m(i.specularIntensityMap.channel),transmissionMapUv:Te&&m(i.transmissionMap.channel),thicknessMapUv:Ee&&m(i.thicknessMap.channel),alphaMapUv:Oe&&m(i.alphaMap.channel),vertexTangents:!!v.attributes.tangent&&(oe||le),vertexNormals:!!v.attributes.normal,vertexColors:i.vertexColors,vertexAlphas:!0===i.vertexColors&&!!v.attributes.color&&v.attributes.color.itemSize===4,pointsUvs:!0===h.isPoints&&!!v.attributes.uv&&(te||Oe),fog:!!_,useFog:!0===i.fog,fogExp2:!!_&&_.isFogExp2,flatShading:!1===i.wireframe&&(!0===i.flatShading||v.attributes.normal===void 0&&!1===oe&&(i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial)),sizeAttenuation:!0===i.sizeAttenuation,logarithmicDepthBuffer:d,reversedDepthBuffer:j,skinning:!0===h.isSkinnedMesh,hasPositionAttribute:v.attributes.position!==void 0,morphTargets:v.morphAttributes.position!==void 0,morphNormals:v.morphAttributes.normal!==void 0,morphColors:v.morphAttributes.color!==void 0,morphTargetsCount:T,morphTextureStride:A,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numLightProbeGrids:g.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:Me,decodeVideoTexture:te&&!0===i.map.isVideoTexture&&it.getTransfer(i.map.colorSpace)===`srgb`,decodeVideoTextureEmissive:F&&!0===i.emissiveMap.isVideoTexture&&it.getTransfer(i.emissiveMap.colorSpace)===`srgb`,premultipliedAlpha:i.premultipliedAlpha,doubleSided:i.side===2,flipSided:i.side===1,useDepthPacking:i.depthPacking>=0,depthPacking:i.depthPacking||0,index0AttributeName:i.index0AttributeName,extensionClipCullDistance:je&&!0===i.extensions.clipCullDistance&&n.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:(je&&!0===i.extensions.multiDraw||N)&&n.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:n.has(`KHR_parallel_shader_compile`),customProgramCacheKey:i.customProgramCacheKey()};var R;return Ne.vertexUv1s=c.has(1),Ne.vertexUv2s=c.has(2),Ne.vertexUv3s=c.has(3),c.clear(),Ne},getProgramCacheKey:function(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.instancing&&o.enable(0),t.instancingColor&&o.enable(1),t.instancingMorph&&o.enable(2),t.matcap&&o.enable(3),t.envMap&&o.enable(4),t.normalMapObjectSpace&&o.enable(5),t.normalMapTangentSpace&&o.enable(6),t.clearcoat&&o.enable(7),t.iridescence&&o.enable(8),t.alphaTest&&o.enable(9),t.vertexColors&&o.enable(10),t.vertexAlphas&&o.enable(11),t.vertexUv1s&&o.enable(12),t.vertexUv2s&&o.enable(13),t.vertexUv3s&&o.enable(14),t.vertexTangents&&o.enable(15),t.anisotropy&&o.enable(16),t.alphaHash&&o.enable(17),t.batching&&o.enable(18),t.dispersion&&o.enable(19),t.batchingColor&&o.enable(20),t.gradientMap&&o.enable(21),t.packedNormalMap&&o.enable(22),t.vertexNormals&&o.enable(23),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.reversedDepthBuffer&&o.enable(4),t.skinning&&o.enable(5),t.morphTargets&&o.enable(6),t.morphNormals&&o.enable(7),t.morphColors&&o.enable(8),t.premultipliedAlpha&&o.enable(9),t.shadowMapEnabled&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),t.decodeVideoTextureEmissive&&o.enable(20),t.alphaToCoverage&&o.enable(21),t.numLightProbeGrids>0&&o.enable(22),t.hasPositionAttribute&&o.enable(23),e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){let t=p[e.type],n;if(t){let e=Lo[t];n=Sa.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let r=u.get(n);return r===void 0?(r=new Kc(e,n,t,i),l.push(r),u.set(n,r)):++r.usedTimes,r},releaseProgram:function(e){if(--e.usedTimes===0){let t=l.indexOf(e);l[t]=l[l.length-1],l.pop(),u.delete(e.cacheKey),e.destroy()}},releaseShaderCache:function(e){s.remove(e)},programs:l,dispose:function(){s.dispose()}}}function Zc(){let e=new WeakMap;return{has:function(t){return e.has(t)},get:function(t){let n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,r){e.get(t)[n]=r},dispose:function(){e=new WeakMap}}}function Qc(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.material.id===t.material.id?e.materialVariant===t.materialVariant?e.z===t.z?e.id-t.id:e.z-t.z:e.materialVariant-t.materialVariant:e.material.id-t.material.id:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function $c(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function el(){let e=[],t=0,n=[],r=[],i=[];function a(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function o(n,r,i,o,s,c){let l=e[t];return l===void 0?(l={id:n.id,object:n,geometry:r,material:i,materialVariant:a(n),groupOrder:o,renderOrder:n.renderOrder,z:s,group:c},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.materialVariant=a(n),l.groupOrder=o,l.renderOrder=n.renderOrder,l.z=s,l.group=c),t++,l}return{opaque:n,transmissive:r,transparent:i,init:function(){t=0,n.length=0,r.length=0,i.length=0},push:function(e,t,a,s,c,l){let u=o(e,t,a,s,c,l);a.transmission>0?r.push(u):!0===a.transparent?i.push(u):n.push(u)},unshift:function(e,t,a,s,c,l){let u=o(e,t,a,s,c,l);a.transmission>0?r.unshift(u):!0===a.transparent?i.unshift(u):n.unshift(u)},finish:function(){for(let n=t,r=e.length;n1&&n.sort(e||Qc),r.length>1&&r.sort(t||$c),i.length>1&&i.sort(t||$c),a&&(n.reverse(),r.reverse(),i.reverse())}}}function tl(){let e=new WeakMap;return{get:function(t,n){let r=e.get(t),i;return r===void 0?(i=new el,e.set(t,[i])):n>=r.length?(i=new el,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function nl(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={direction:new G,color:new X};break;case`SpotLight`:n={position:new G,direction:new G,color:new X,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new G,color:new X,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new G,skyColor:new X,groundColor:new X};break;case`RectAreaLight`:n={color:new X,position:new G,halfWidth:new G,halfHeight:new G}}return e[t.id]=n,n}}}var rl=0;function il(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function al(e){let t=new nl,n=function(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:case`SpotLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new W};break;case`PointLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new W,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),r={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 e=0;e<9;e++)r.probe.push(new G);let i=new G,a=new J,o=new J;return{setup:function(i){let a=0,o=0,s=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;i.sort(il);for(let e=0,y=i.length;e0&&(!0===e.has(`OES_texture_float_linear`)?(r.rectAreaLTC1=$.LTC_FLOAT_1,r.rectAreaLTC2=$.LTC_FLOAT_2):(r.rectAreaLTC1=$.LTC_HALF_1,r.rectAreaLTC2=$.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=o,r.ambient[2]=s;let y=r.hash;y.directionalLength===c&&y.pointLength===l&&y.spotLength===u&&y.rectAreaLength===d&&y.hemiLength===f&&y.numDirectionalShadows===p&&y.numPointShadows===m&&y.numSpotShadows===h&&y.numSpotMaps===g&&y.numLightProbes===v||(r.directional.length=c,r.spot.length=u,r.rectArea.length=d,r.point.length=l,r.hemi.length=f,r.directionalShadow.length=p,r.directionalShadowMap.length=p,r.pointShadow.length=m,r.pointShadowMap.length=m,r.spotShadow.length=h,r.spotShadowMap.length=h,r.directionalShadowMatrix.length=p,r.pointShadowMatrix.length=m,r.spotLightMatrix.length=h+g-_,r.spotLightMap.length=g,r.numSpotLightShadowsWithMaps=_,r.numLightProbes=v,y.directionalLength=c,y.pointLength=l,y.spotLength=u,y.rectAreaLength=d,y.hemiLength=f,y.numDirectionalShadows=p,y.numPointShadows=m,y.numSpotShadows=h,y.numSpotMaps=g,y.numLightProbes=v,r.version=rl++)},setupView:function(e,t){let n=0,s=0,c=0,l=0,u=0,d=t.matrixWorldInverse;for(let t=0,f=e.length;t=i.length?(a=new ol(e),i.push(a)):a=i[r],a},dispose:function(){t=new WeakMap}}}var cl=[new G(1,0,0),new G(-1,0,0),new G(0,1,0),new G(0,-1,0),new G(0,0,1),new G(0,0,-1)],ll=[new G(0,-1,0),new G(0,-1,0),new G(0,0,1),new G(0,0,-1),new G(0,-1,0),new G(0,-1,0)],ul=new J,dl=new G,fl=new G;function pl(e,t,n){let r=new Lr,i=new W,a=new W,o=new ht,s=new Da,c=new Oa,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new Ca({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new W},radius:{value:4}},vertexShader:`void main() { + gl_Position = vec4( position, 1.0 ); +}`,fragmentShader:`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +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 = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); + gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); +}`}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new Yn;m.setAttribute(`position`,new Fn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new vr(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;function v(n,r){let a=t.update(h);f.defines.VSM_SAMPLES!==n.blurSamples&&(f.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),n.mapPass===null&&(n.mapPass=new _t(i.x,i.y,{format:1030,type:1016})),f.uniforms.shadow_pass.value=n.map.depthTexture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,a,f,h,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,a,p,h,null)}function y(t,n,r,i){let a=null,o=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(o!==void 0)a=o;else if(a=!0===r.isPointLight?c:s,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&n.clippingPlanes.length!==0||n.displacementMap&&n.displacementScale!==0||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){let e=a.uuid,t=n.uuid,r=l[e];r===void 0&&(r={},l[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i,n.addEventListener(`dispose`,x)),a=i}return a.visible=n.visible,a.wireframe=n.wireframe,a.side=i===3?n.shadowSide===null?n.side:n.shadowSide:n.shadowSide===null?d[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===r.isPointLight&&!0===a.isMeshDistanceMaterial&&(e.properties.get(a).light=r),a}function b(n,i,a,o,s){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===3)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),c=n.material;if(Array.isArray(c)){let t=r.groups;for(let l=0,u=t.length;le.needsUpdate=!0):e.material.needsUpdate=!0)});for(let c=0,l=t.length;cu||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/m.x),i.x=a.x*m.x,d.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/m.y),i.y=a.y*m.y,d.mapSize.y=a.y));let h=e.state.buffers.depth.getReversed();if(d.camera._reversedDepth=h,d.map===null||!0===p){if(d.map!==null&&(d.map.depthTexture!==null&&(d.map.depthTexture.dispose(),d.map.depthTexture=null),d.map.dispose()),this.type===3){if(l.isPointLight){V(`WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.`);continue}d.map=new _t(i.x,i.y,{format:ye,type:le,minFilter:P,magFilter:P,generateMipmaps:!1}),d.map.texture.name=l.name+`.shadowMap`,d.map.depthTexture=new Hr(i.x,i.y,I),d.map.depthTexture.name=l.name+`.shadowMapDepth`,d.map.depthTexture.format=L,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=M,d.map.depthTexture.magFilter=M}else l.isPointLight?(d.map=new ss(i.x),d.map.depthTexture=new Ur(i.x,ce)):(d.map=new _t(i.x,i.y),d.map.depthTexture=new Hr(i.x,i.y,ce)),d.map.depthTexture.name=l.name+`.shadowMap`,d.map.depthTexture.format=L,this.type===1?(d.map.depthTexture.compareFunction=h?518:515,d.map.depthTexture.minFilter=P,d.map.depthTexture.magFilter=P):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=M,d.map.depthTexture.magFilter=M);d.camera.updateProjectionMatrix()}let g=d.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t=2):(ee=parseFloat(/^WebGL (\d)/.exec(j)[1]),A=ee>=1);let M=null,N={},te=e.getParameter(e.SCISSOR_BOX),P=e.getParameter(e.VIEWPORT),ne=new ht().fromArray(te),re=new ht().fromArray(P);function ie(t,n,r,i){let a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;on||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof VideoFrame<`u`&&e instanceof VideoFrame){let n=Math.floor(r*i.width),a=Math.floor(r*i.height);f===void 0&&(f=h(n,a));let o=t?h(n,a):f;return o.width=n,o.height=a,o.getContext(`2d`).drawImage(e,0,0,n,a),V(`WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}return`data`in e&&V(`WebGLRenderer: Image in DataTexture is too big (`+i.width+`x`+i.height+`).`),e}return e}function _(e){return e.generateMipmaps}function v(t){e.generateMipmap(t)}function y(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function b(n,r,i,a,o,s=!1){if(n!==null){if(e[n]!==void 0)return e[n];V(`WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let c;a&&(c=t.get(`EXT_texture_norm16`),c||V(`WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension`));let l=r;if(r===e.RED&&(i===e.FLOAT&&(l=e.R32F),i===e.HALF_FLOAT&&(l=e.R16F),i===e.UNSIGNED_BYTE&&(l=e.R8),i===e.UNSIGNED_SHORT&&c&&(l=c.R16_EXT),i===e.SHORT&&c&&(l=c.R16_SNORM_EXT)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.R8UI),i===e.UNSIGNED_SHORT&&(l=e.R16UI),i===e.UNSIGNED_INT&&(l=e.R32UI),i===e.BYTE&&(l=e.R8I),i===e.SHORT&&(l=e.R16I),i===e.INT&&(l=e.R32I)),r===e.RG&&(i===e.FLOAT&&(l=e.RG32F),i===e.HALF_FLOAT&&(l=e.RG16F),i===e.UNSIGNED_BYTE&&(l=e.RG8),i===e.UNSIGNED_SHORT&&c&&(l=c.RG16_EXT),i===e.SHORT&&c&&(l=c.RG16_SNORM_EXT)),r===e.RG_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RG8UI),i===e.UNSIGNED_SHORT&&(l=e.RG16UI),i===e.UNSIGNED_INT&&(l=e.RG32UI),i===e.BYTE&&(l=e.RG8I),i===e.SHORT&&(l=e.RG16I),i===e.INT&&(l=e.RG32I)),r===e.RGB_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGB8UI),i===e.UNSIGNED_SHORT&&(l=e.RGB16UI),i===e.UNSIGNED_INT&&(l=e.RGB32UI),i===e.BYTE&&(l=e.RGB8I),i===e.SHORT&&(l=e.RGB16I),i===e.INT&&(l=e.RGB32I)),r===e.RGBA_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGBA8UI),i===e.UNSIGNED_SHORT&&(l=e.RGBA16UI),i===e.UNSIGNED_INT&&(l=e.RGBA32UI),i===e.BYTE&&(l=e.RGBA8I),i===e.SHORT&&(l=e.RGBA16I),i===e.INT&&(l=e.RGBA32I)),r===e.RGB&&(i===e.UNSIGNED_SHORT&&c&&(l=c.RGB16_EXT),i===e.SHORT&&c&&(l=c.RGB16_SNORM_EXT),i===e.UNSIGNED_INT_5_9_9_9_REV&&(l=e.RGB9_E5),i===e.UNSIGNED_INT_10F_11F_11F_REV&&(l=e.R11F_G11F_B10F)),r===e.RGBA){let t=s?Me:it.getTransfer(o);i===e.FLOAT&&(l=e.RGBA32F),i===e.HALF_FLOAT&&(l=e.RGBA16F),i===e.UNSIGNED_BYTE&&(l=t===`srgb`?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT&&c&&(l=c.RGBA16_EXT),i===e.SHORT&&c&&(l=c.RGBA16_SNORM_EXT),i===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return l!==e.R16F&&l!==e.R32F&&l!==e.RG16F&&l!==e.RG32F&&l!==e.RGBA16F&&l!==e.RGBA32F||t.get(`EXT_color_buffer_float`),l}function x(t,n){let r;return t?n===null||n===1014||n===1020?r=e.DEPTH24_STENCIL8:n===1015?r=e.DEPTH32F_STENCIL8:n===1012&&(r=e.DEPTH24_STENCIL8,V(`DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.`)):n===null||n===1014||n===1020?r=e.DEPTH_COMPONENT24:n===1015?r=e.DEPTH_COMPONENT32F:n===1012&&(r=e.DEPTH_COMPONENT16),r}function S(e,t){return!0===_(e)||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps!==void 0&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function C(e){let t=e.target;t.removeEventListener(`dispose`,C),function(e){let t=r.get(e);if(t.__webglInit===void 0)return;let n=e.source,i=p.get(n);if(i){let r=i[t.__cacheKey];r.usedTimes--,r.usedTimes===0&&T(e),Object.keys(i).length===0&&p.delete(n)}r.remove(e)}(t),t.isVideoTexture&&u.delete(t),t.isHTMLTexture&&d.delete(t)}function w(t){let n=t.target;n.removeEventListener(`dispose`,w),function(t){let n=r.get(t);if(t.depthTexture&&(t.depthTexture.dispose(),r.remove(t.depthTexture)),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let r=0;r0&&a.__version!==t.version){let e=t.image;if(e===null)V(`WebGLRenderer: Texture marked for update but no image data found.`);else{if(!1!==e.complete)return void F(a,t,i);V(`WebGLRenderer: Texture marked for update but image is incomplete`)}}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+i)}let O={[A]:e.REPEAT,[ee]:e.CLAMP_TO_EDGE,[j]:e.MIRRORED_REPEAT},k={[M]:e.NEAREST,[N]:e.NEAREST_MIPMAP_NEAREST,[te]:e.NEAREST_MIPMAP_LINEAR,[P]:e.LINEAR,[ne]:e.LINEAR_MIPMAP_NEAREST,[re]:e.LINEAR_MIPMAP_LINEAR},ie={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function ae(n,a){if(a.type!==1015||!1!==t.has(`OES_texture_float_linear`)||a.magFilter!==1006&&a.magFilter!==1007&&a.magFilter!==1005&&a.magFilter!==1008&&a.minFilter!==1006&&a.minFilter!==1007&&a.minFilter!==1005&&a.minFilter!==1008||V(`WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.`),e.texParameteri(n,e.TEXTURE_WRAP_S,O[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,O[a.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,O[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,k[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,k[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,ie[a.compareFunction])),!0===t.has(`EXT_texture_filter_anisotropic`)){if(a.magFilter===1003||a.minFilter!==1005&&a.minFilter!==1008||a.type===1015&&!1===t.has(`OES_texture_float_linear`))return;if(a.anisotropy>1||r.get(a).__currentAnisotropy){let o=t.get(`EXT_texture_filter_anisotropic`);e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy}}}function oe(t,n){let r=!1;t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,C));let i=n.source,a=p.get(i);a===void 0&&(a={},p.set(i,a));let s=function(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(s!==t.__cacheKey){a[s]===void 0&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;let i=a[t.__cacheKey];i!==void 0&&(a[t.__cacheKey].usedTimes--,i.usedTimes===0&&T(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function se(e,t,n){return Math.floor(Math.floor(e/n)/t)}function F(t,o,s){let c=e.TEXTURE_2D;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(c=e.TEXTURE_2D_ARRAY),o.isData3DTexture&&(c=e.TEXTURE_3D);let l=oe(t,o),u=o.source;n.bindTexture(c,t.__webglTexture,e.TEXTURE0+s);let f=r.get(u);if(u.version!==f.__version||!0===l){if(n.activeTexture(e.TEXTURE0+s),(typeof ImageBitmap<`u`&&o.image instanceof ImageBitmap)==0){let t=it.getPrimaries(it.workingColorSpace),r=o.colorSpace===``?null:it.getPrimaries(o.colorSpace),i=o.colorSpace===``||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,i)}n.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment);let t=g(o.image,!1,i.maxTextureSize);t=he(o,t);let r=a.convert(o.format,o.colorSpace),p=a.convert(o.type),m,h=b(o.internalFormat,r,p,o.normalized,o.colorSpace,o.isVideoTexture);ae(c,o);let y=o.mipmaps,C=!0!==o.isVideoTexture,w=f.__version===void 0||!0===l,T=u.dataReady,E=S(o,t);if(o.isDepthTexture)h=x(o.format===ge,o.type),w&&(C?n.texStorage2D(e.TEXTURE_2D,1,h,t.width,t.height):n.texImage2D(e.TEXTURE_2D,0,h,t.width,t.height,0,r,p,null));else if(o.isDataTexture){if(y.length>0){C&&w&&n.texStorage2D(e.TEXTURE_2D,E,h,y[0].width,y[0].height);for(let t=0,i=y.length;te.start-t.start);let s=0;for(let e=1;e0){let t=Po(m.width,m.height,o.format,o.type);for(let a of o.layerUpdates){let o=m.data.subarray(a*t/m.data.BYTES_PER_ELEMENT,(a+1)*t/m.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,a,m.width,m.height,1,r,o)}o.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,m.width,m.height,t.depth,r,m.data)}}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,i,h,m.width,m.height,t.depth,0,m.data,0,0)}else V(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`)}else C?T&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,m.width,m.height,t.depth,r,p,m.data):n.texImage3D(e.TEXTURE_2D_ARRAY,i,h,m.width,m.height,t.depth,0,r,p,m.data)}else{C&&w&&n.texStorage2D(e.TEXTURE_2D,E,h,y[0].width,y[0].height);for(let t=0,i=y.length;t0){let i=Po(t.width,t.height,o.format,o.type);for(let a of o.layerUpdates){let o=t.data.subarray(a*i/t.data.BYTES_PER_ELEMENT,(a+1)*i/t.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,a,t.width,t.height,1,r,p,o)}o.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)}}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,h,t.width,t.height,t.depth,0,r,p,t.data)}else if(o.isData3DTexture)C?(w&&n.texStorage3D(e.TEXTURE_3D,E,h,t.width,t.height,t.depth),T&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)):n.texImage3D(e.TEXTURE_3D,0,h,t.width,t.height,t.depth,0,r,p,t.data);else if(o.isFramebufferTexture){if(w){if(C)n.texStorage2D(e.TEXTURE_2D,E,h,t.width,t.height);else{let i=t.width,a=t.height;for(let t=0;t>=1,a>>=1}}}else if(o.isHTMLTexture){if(`texElementImage2D`in e){let n=e.canvas;if(n.hasAttribute(`layoutsubtree`)||n.setAttribute(`layoutsubtree`,`true`),t.parentNode!==n)return n.appendChild(t),d.add(o),n.onpaint=e=>{let t=e.changedElements;for(let e of d)t.includes(e.image)&&(e.needsUpdate=!0)},void n.requestPaint();if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,t);else{let n=e.RGBA,r=e.RGBA,i=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,0,n,r,i,t)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(y.length>0){if(C&&w){let t=L(y[0]);n.texStorage2D(e.TEXTURE_2D,E,h,t.width,t.height)}for(let t=0,i=y.length;t>u),r=Math.max(1,i.height>>u);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,u,p,t,r,i.depth,0,d,f,null):n.texImage2D(l,u,p,t,r,0,d,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),me(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,c,l,h.__webglTexture,0,pe(i)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,c,l,h.__webglTexture,u),n.bindFramebuffer(e.FRAMEBUFFER,null)}function I(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,o=x(n.stencilBuffer,a),c=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;me(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,pe(n),o,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,pe(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,t)}else{let t=n.textures;for(let i=0;i{delete i.__boundDepthTexture,delete i.__depthDisposeCallback,e.removeEventListener(`dispose`,t)};e.addEventListener(`dispose`,t),i.__depthDisposeCallback=t}i.__boundDepthTexture=e}if(t.depthTexture&&!i.__autoAllocateDepthBuffer){if(a)for(let e=0;e<6;e++)le(i.__webglFramebuffer[e],t,e);else{let e=t.texture.mipmaps;e&&e.length>0?le(i.__webglFramebuffer[0],t,0):le(i.__webglFramebuffer,t,0)}}else if(a){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)if(n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]===void 0)i.__webglDepthbuffer[r]=e.createRenderbuffer(),I(i.__webglDepthbuffer[r],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=i.__webglDepthbuffer[r];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else{let r=t.texture.mipmaps;if(r&&r.length>0?n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer===void 0)i.__webglDepthbuffer=e.createRenderbuffer(),I(i.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=i.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,r)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}let de=[],fe=[];function pe(e){return Math.min(i.maxSamples,e.samples)}function me(e){let n=r.get(e);return e.samples>0&&!0===t.has(`WEBGL_multisampled_render_to_texture`)&&!1!==n.__useRenderToTexture}function he(e,t){let n=e.colorSpace,r=e.format,i=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==`srgb-linear`&&n!==``&&(it.getTransfer(n)===`srgb`?r===1023&&i===1009||V(`WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):H(`WebGLTextures: Unsupported texture color space:`,n)),t}function L(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement?(l.width=e.naturalWidth||e.width,l.height=e.naturalHeight||e.height):typeof VideoFrame<`u`&&e instanceof VideoFrame?(l.width=e.displayWidth,l.height=e.displayHeight):(l.width=e.width,l.height=e.height),l}this.allocateTextureUnit=function(){let e=E;return e>=i.maxTextures&&V(`WebGLTextures: Trying to use `+e+` texture units while this GPU supports only `+i.maxTextures),E+=1,e},this.resetTextureUnits=function(){E=0},this.getTextureUnits=function(){return E},this.setTextureUnits=function(e){E=e},this.setTexture2D=D,this.setTexture2DArray=function(t,i){let a=r.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?F(a,t,i):(t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+i))},this.setTexture3D=function(t,i){let a=r.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?F(a,t,i):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)},this.setTextureCube=function(t,o){let s=r.get(t);!0!==t.isCubeDepthTexture&&t.version>0&&s.__version!==t.version?function(t,o,s){if(o.image.length!==6)return;let c=oe(t,o),l=o.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);let u=r.get(l);if(l.version!==u.__version||!0===c){n.activeTexture(e.TEXTURE0+s);let t=it.getPrimaries(it.workingColorSpace),r=o.colorSpace===``?null:it.getPrimaries(o.colorSpace),d=o.colorSpace===``||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let f=o.isCompressedTexture||o.image[0].isCompressedTexture,p=o.image[0]&&o.image[0].isDataTexture,m=[];for(let e=0;e<6;e++)m[e]=f||p?p?o.image[e].image:o.image[e]:g(o.image[e],!0,i.maxCubemapSize),m[e]=he(o,m[e]);let h=m[0],y=a.convert(o.format,o.colorSpace),x=a.convert(o.type),C=b(o.internalFormat,y,x,o.normalized,o.colorSpace),w=!0!==o.isVideoTexture,T=u.__version===void 0||!0===c,E=l.dataReady,D,O=S(o,h);if(ae(e.TEXTURE_CUBE_MAP,o),f){w&&T&&n.texStorage2D(e.TEXTURE_CUBE_MAP,O,C,h.width,h.height);for(let t=0;t<6;t++){D=m[t].mipmaps;for(let r=0;r0&&O++;let t=L(m[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,O,C,t.width,t.height)}for(let t=0;t<6;t++)if(p){w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m[t].width,m[t].height,y,x,m[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,C,m[t].width,m[t].height,0,y,x,m[t].data);for(let r=0;r1;if(d||(c.__webglTexture===void 0&&(c.__webglTexture=e.createTexture()),c.__version=i.version,o.memory.textures++),u){s.__webglFramebuffer=[];for(let t=0;t<6;t++)if(i.mipmaps&&i.mipmaps.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n0){s.__webglFramebuffer=[];for(let t=0;t0&&!1===me(t)){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n0)for(let r=0;r0)for(let n=0;n0){if(!1===me(t)){let i=t.textures,a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=r.get(t),d=i.length>1;if(d)for(let t=0;t0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n= 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; + + } + +}`,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new vr(new ca(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},vl=class extends Ue{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=typeof XRWebGLBinding<`u`,h=new _l,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new W,C=null,w=new so;w.viewport=new ht;let T=new so;T.viewport=new ht;let E=[w,T],D=new vo,O=null,k=null;function A(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function ee(){r.removeEventListener(`select`,A),r.removeEventListener(`selectstart`,A),r.removeEventListener(`selectend`,A),r.removeEventListener(`squeeze`,A),r.removeEventListener(`squeezestart`,A),r.removeEventListener(`squeezeend`,A),r.removeEventListener(`end`,ee),r.removeEventListener(`inputsourceschange`,j);for(let e=0;e=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t=x.length){x.push(n),r=e;break}if(x[e]===null){x[e]=n,r=e;break}}if(r===-1)break}let i=b[r];i&&i.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new Jt,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new Jt,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new Jt,b[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){i=e,!0===n.isPresenting&&V(`WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,!0===n.isPresenting&&V(`WebXRManager: Cannot change reference space type while presenting.`)},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(e){c=e},this.getBaseLayer=function(){return d===null?f:d},this.getBinding=function(){return u===null&&m&&(u=new XRWebGLBinding(r,t)),u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,r!==null){if(v=e.getRenderTarget(),r.addEventListener(`select`,A),r.addEventListener(`selectstart`,A),r.addEventListener(`selectend`,A),r.addEventListener(`squeeze`,A),r.addEventListener(`squeezestart`,A),r.addEventListener(`squeezeend`,A),r.addEventListener(`end`,ee),r.addEventListener(`inputsourceschange`,j),!0!==_.xrCompatible&&await t.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(S),m&&`createProjectionLayer`in XRWebGLBinding.prototype){let n=null,a=null,o=null;_.depth&&(o=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=_.stencil?1027:1026,a=_.stencil?1020:1014);let s={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:i};u=this.getBinding(),d=u.createProjectionLayer(s),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),y=new _t(d.textureWidth,d.textureHeight,{format:he,type:ie,depthTexture:new Hr(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}else{let n={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new _t(f.framebufferWidth,f.framebufferHeight,{format:he,type:ie,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:!1===f.ignoreDepthValues,resolveStencilBuffer:!1===f.ignoreDepthValues})}y.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),ne.setContext(r),ne.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return h.getDepthTexture()};let M=new G,N=new G;function te(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),D.near=T.near=w.near=t,D.far=T.far=w.far=n,O===D.near&&k===D.far||(r.updateRenderState({depthNear:D.near,depthFar:D.far}),O=D.near,k=D.far),D.layers.mask=6|e.layers.mask,w.layers.mask=-5&D.layers.mask,T.layers.mask=-3&D.layers.mask;let i=e.parent,a=D.cameras;te(D,i);for(let e=0;e0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,e.envMapRotation.value.setFromMatrix4(yl.makeRotationFromEuler(o)).transpose(),a.isCubeTexture&&!1===a.isRenderTargetTexture&&e.envMapRotation.value.premultiply(bl),e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,xa(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,i,a,o,s){i.isNodeMaterial?i.uniformsNeedUpdate=!1:i.isMeshBasicMaterial?r(e,i):i.isMeshLambertMaterial?(r(e,i),i.envMap&&(e.envMapIntensity.value=i.envMapIntensity)):i.isMeshToonMaterial?(r(e,i),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,i)):i.isMeshPhongMaterial?(r(e,i),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,i),i.envMap&&(e.envMapIntensity.value=i.envMapIntensity)):i.isMeshStandardMaterial?(r(e,i),function(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}(e,i),i.isMeshPhysicalMaterial&&function(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,i,s)):i.isMeshMatcapMaterial?(r(e,i),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,i)):i.isMeshDepthMaterial?r(e,i):i.isMeshDistanceMaterial?(r(e,i),function(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}(e,i)):i.isMeshNormalMaterial?r(e,i):i.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,i),i.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,i)):i.isPointsMaterial?function(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=.5*i,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,i,a,o):i.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,i):i.isShadowMaterial?(e.color.value.copy(i.color),e.opacity.value=i.opacity):i.isShaderMaterial&&(i.uniformsNeedUpdate=!1)}}}function Sl(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(t,n,r,i){if(!0===function(e,t,n,r){let i=e.value,a=t+`_`+n;if(r[a]===void 0)return r[a]=typeof i==`number`||typeof i==`boolean`?i:ArrayBuffer.isView(i)?i.slice():i.clone(),!0;{let e=r[a];if(typeof i==`number`||typeof i==`boolean`){if(e!==i)return r[a]=i,!0}else{if(ArrayBuffer.isView(i))return!0;if(!1===e.equals(i))return e.copy(i),!0}}return!1}(t,n,r,i)){let n=t.__offset,r=t.value;if(Array.isArray(r)){let e=0;for(let n=0;n0&&(n+=16-r),e.__size=n,e.__cache={}}(n),f=function(t){let n=function(){for(let e=0;e0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(M!==null&&!0!==M.isXRRenderTarget||(h=T.toneMapping));let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=z.get(r),b=x.state.lights;if(!0===Ce&&(!0===we||e!==te)){let t=e===te&&r.id===N;Ke.setState(r,e,t)}let S=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==b.state.version||v.outputColorSpace!==s||i.isBatchedMesh&&!1===v.batching?S=!0:i.isBatchedMesh||!0!==v.batching?i.isBatchedMesh&&!0===v.batchingColor&&i.colorTexture===null||i.isBatchedMesh&&!1===v.batchingColor&&i.colorTexture!==null||i.isInstancedMesh&&!1===v.instancing?S=!0:i.isInstancedMesh||!0!==v.instancing?i.isSkinnedMesh&&!1===v.skinning?S=!0:i.isSkinnedMesh||!0!==v.skinning?i.isInstancedMesh&&!0===v.instancingColor&&i.instanceColor===null||i.isInstancedMesh&&!1===v.instancingColor&&i.instanceColor!==null||i.isInstancedMesh&&!0===v.instancingMorph&&i.morphTexture===null||i.isInstancedMesh&&!1===v.instancingMorph&&i.morphTexture!==null||v.envMap!==l||!0===r.fog&&v.fog!==a?S=!0:v.numClippingPlanes===void 0||v.numClippingPlanes===Ke.numPlanes&&v.numIntersection===Ke.numIntersection?(v.vertexAlphas!==u||v.vertexTangents!==d||v.morphTargets!==f||v.morphNormals!==p||v.morphColors!==m||v.toneMapping!==h||v.morphTargetsCount!==_||!!v.lightProbeGrid!=x.state.lightProbeGridArray.length>0)&&(S=!0):S=!0:S=!0:S=!0:S=!0:(S=!0,v.__version=r.version);let C=v.currentProgram;!0===S&&(C=vt(r,t,i),D&&r.isNodeMaterial&&D.onUpdateProgram(r,C,v));let w=!1,E=!1,O=!1,k=C.getUniforms(),A=v.uniforms;if(R.useProgram(C.program)&&(w=!0,E=!0,O=!0),r.id!==N&&(N=r.id,E=!0),v.needsLights){let e=function(e,t){if(e.length===0)return null;if(e.length===1)return e[0].texture===null?null:e[0];y.setFromMatrixPosition(t.matrixWorld);for(let t=0,n=e.length;t0&&k.setValue(K,`directionalShadowMap`,b.state.directionalShadowMap,B),b.state.spotShadowMap.length>0&&k.setValue(K,`spotShadowMap`,b.state.spotShadowMap,B),b.state.pointShadowMap.length>0&&k.setValue(K,`pointShadowMap`,b.state.pointShadowMap,B)),i.isSkinnedMesh){k.setOptional(K,i,`bindMatrix`),k.setOptional(K,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),k.setValue(K,`boneTexture`,e.boneTexture,B))}i.isBatchedMesh&&(k.setOptional(K,i,`batchingTexture`),k.setValue(K,`batchingTexture`,i._matricesTexture,B),k.setOptional(K,i,`batchingIdTexture`),k.setValue(K,`batchingIdTexture`,i._indirectTexture,B),k.setOptional(K,i,`batchingColorTexture`),i._colorsTexture!==null&&k.setValue(K,`batchingColorTexture`,i._colorsTexture,B));let ee=n.morphAttributes;if(ee.position===void 0&&ee.normal===void 0&&ee.color===void 0||Je.update(i,n,C),(E||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,k.setValue(K,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(A.envMapIntensity.value=t.environmentIntensity),A.dfgLUT!==void 0&&(A.dfgLUT.value=(wl===null&&(wl=new br(Cl,16,16,1030,1016),wl.name=`DFG_LUT`,wl.minFilter=1006,wl.magFilter=1006,wl.wrapS=1001,wl.wrapT=1001,wl.generateMipmaps=!1,wl.needsUpdate=!0),wl)),E){if(k.setValue(K,`toneMappingExposure`,T.toneMappingExposure),v.needsLights&&(P=O,(j=A).ambientLightColor.needsUpdate=P,j.lightProbe.needsUpdate=P,j.directionalLights.needsUpdate=P,j.directionalLightShadows.needsUpdate=P,j.pointLights.needsUpdate=P,j.pointLightShadows.needsUpdate=P,j.spotLights.needsUpdate=P,j.spotLightShadows.needsUpdate=P,j.rectAreaLights.needsUpdate=P,j.hemisphereLights.needsUpdate=P),a&&!0===r.fog&&Ue.refreshFogUniforms(A,a),Ue.refreshMaterialUniforms(A,r,me,pe,x.state.transmissionRenderTarget[e.id]),v.needsLights&&v.lightProbeGrid){let e=v.lightProbeGrid;A.probesSH.value=e.texture,A.probesMin.value.copy(e.boundingBox.min),A.probesMax.value.copy(e.boundingBox.max),A.probesResolution.value.copy(e.resolution)}xc.upload(K,yt(v),A,B)}var j,P;if(r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(xc.upload(K,yt(v),A,B),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&k.setValue(K,`center`,i.center),k.setValue(K,`modelViewMatrix`,i.modelViewMatrix),k.setValue(K,`normalMatrix`,i.normalMatrix),k.setValue(K,`modelMatrix`,i.matrixWorld),r.uniformsGroups!==void 0){let e=r.uniformsGroups;for(let t=0,n=e.length;t{function n(){r.forEach(function(e){z.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0?t(e):setTimeout(n,10)}Me.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let st=null;function ct(){ut.stop()}function lt(){ut.start()}let ut=new Fo;function dt(e,t,n,r){if(!1===e.visible)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLightProbeGrid)x.pushLightProbeGrid(e);else if(e.isLight)x.pushLight(e),e.castShadow&&x.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||Se.intersectsSprite(e)){r&&De.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Te);let t=Be.update(e),i=e.material;i.visible&&b.push(e,t,i,n,De.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||Se.intersectsObject(e))){let t=Be.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),De.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),De.copy(e.boundingSphere.center)),De.applyMatrix4(e.matrixWorld).applyMatrix4(Te)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a0&&mt(i,t,n),a.length>0&&mt(a,t,n),o.length>0&&mt(o,t,n),R.buffers.depth.setTest(!0),R.buffers.depth.setMask(!0),R.buffers.color.setMask(!0),R.setPolygonOffset(!1)}function pt(e,t,n,r){if((!0===n.isScene?n.overrideMaterial:null)!==null)return;if(x.state.transmissionRenderTarget[r.id]===void 0){let e=Me.has(`EXT_color_buffer_half_float`)||Me.has(`EXT_color_buffer_float`);x.state.transmissionRenderTarget[r.id]=new _t(1,1,{generateMipmaps:!0,type:e?le:ie,minFilter:re,samples:Math.max(4,Ne.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:it.workingColorSpace})}let a=x.state.transmissionRenderTarget[r.id],o=r.viewport||P;a.setSize(o.z*T.transmissionResolutionScale,o.w*T.transmissionResolutionScale);let s=T.getRenderTarget(),c=T.getActiveCubeFace(),l=T.getActiveMipmapLevel();T.setRenderTarget(a),T.getClearColor(oe),F=T.getClearAlpha(),F<1&&T.setClearColor(16777215,.5),T.clear(),ke&&U.render(n);let u=T.toneMapping;T.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),x.setupLightsView(r),!0===Ce&&Ke.setGlobalState(T.clippingPlanes,r),mt(e,n,r),B.updateMultisampleRenderTarget(a),B.updateRenderTargetMipmap(a),!1===Me.has(`WEBGL_multisampled_render_to_texture`)){let e=!1;for(let i=0,a=t.length;i0,r.currentProgram=d,r.uniformsList=null,d}function yt(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=xc.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function bt(e,t){let n=z.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}ut.setAnimationLoop(function(e){st&&st(e)}),typeof self<`u`&&ut.setContext(self),this.setAnimationLoop=function(e){st=e,et.setAnimationLoop(e),e===null?ut.stop():ut.start()},et.addEventListener(`sessionstart`,ct),et.addEventListener(`sessionend`,lt),this.render=function(e,t){if(t!==void 0&&!0!==t.isCamera)return void H(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);if(!0===E)return;D!==null&&D.renderStart(e,t);let n=!0===et.enabled&&!0===et.isPresenting,r=w!==null&&(M===null||n)&&w.begin(T,M);if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),t.parent===null&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0!==et.enabled||!0!==et.isPresenting||w!==null&&!1!==w.isCompositing()||(!0===et.cameraAutoUpdate&&et.updateCamera(t),t=et.getCamera()),!0===e.isScene&&e.onBeforeRender(T,e,t,M),x=Ge.get(e,C.length),x.init(t),x.state.textureUnits=B.getTextureUnits(),C.push(x),Te.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),Se.setFromProjectionMatrix(Te,2e3,t.reversedDepth),we=this.localClippingEnabled,Ce=Ke.init(this.clippingPlanes,we),b=We.get(e,S.length),b.init(),S.push(b),!0===et.enabled&&!0===et.isPresenting){let e=T.xr.getDepthSensingMesh();e!==null&&dt(e,t,-1/0,T.sortObjects)}dt(e,t,0,T.sortObjects),b.finish(),!0===T.sortObjects&&b.sort(he,L,t.reversedDepth),ke=!1===et.enabled||!1===et.isPresenting||!1===et.hasDepthSensing(),ke&&U.addToRenderList(b,e),this.info.render.frame++,!0===this.info.autoReset&&this.info.reset(),!0===Ce&&Ke.beginShadows();let i=x.state.shadowsArray;if(qe.render(i,e,t),!0===Ce&&Ke.endShadows(),!1===(r&&w.hasRenderPass())){let n=b.opaque,r=b.transmissive;if(x.setupLights(),t.isArrayCamera){let i=t.cameras;if(r.length>0)for(let t=0,a=i.length;t0&&pt(n,r,e,t),ke&&U.render(e),ft(b,e,t)}M!==null&&j===0&&(B.updateMultisampleRenderTarget(M),B.updateRenderTargetMipmap(M)),r&&w.end(T),!0===e.isScene&&e.onAfterRender(T,e,t),W.resetDefaultState(),N=-1,te=null,C.pop(),C.length>0?(x=C[C.length-1],B.setTextureUnits(x.state.textureUnits),!0===Ce&&Ke.setGlobalState(T.clippingPlanes,x.state.camera)):x=null,S.pop(),b=S.length>0?S[S.length-1]:null,D!==null&&D.renderEnd()},this.getActiveCubeFace=function(){return ee},this.getActiveMipmapLevel=function(){return j},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(e,t,n){let r=z.get(e);r.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,!1===r.__autoAllocateDepthBuffer&&(r.__useRenderToTexture=!1),z.get(e.texture).__webglTexture=t,z.get(e.depthTexture).__webglTexture=r.__autoAllocateDepthBuffer?void 0:n,r.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=z.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=t===void 0},this.setRenderTarget=function(e,t=0,n=0){M=e,ee=t,j=n;let r=null,i=!1,a=!1;if(e){let o=z.get(e);if(o.__useDefaultFramebuffer!==void 0)return R.bindFramebuffer(K.FRAMEBUFFER,o.__webglFramebuffer),P.copy(e.viewport),ne.copy(e.scissor),ae=e.scissorTest,R.viewport(P),R.scissor(ne),R.setScissorTest(ae),void(N=-1);if(o.__webglFramebuffer===void 0)B.setupRenderTarget(e);else if(o.__hasExternalTextures)B.rebindTextures(e,z.get(e.texture).__webglTexture,z.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(o.__boundDepthTexture!==t){if(t!==null&&z.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error(`THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.`);B.setupDepthRenderbuffer(e)}}let s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(a=!0);let c=z.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],i=!0):r=e.samples>0&&!1===B.useMultisampledRTT(e)?z.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,P.copy(e.viewport),ne.copy(e.scissor),ae=e.scissorTest}else P.copy(ge).multiplyScalar(me).floor(),ne.copy(_e).multiplyScalar(me).floor(),ae=ye;if(n!==0&&(r=O),R.bindFramebuffer(K.FRAMEBUFFER,r)&&R.drawBuffers(e,r),R.viewport(P),R.scissor(ne),R.setScissorTest(ae),i){let r=z.get(e.texture);K.framebufferTexture2D(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t1&&K.readBuffer(K.COLOR_ATTACHMENT0+s),!Ne.textureFormatReadable(c))return void H(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);if(!Ne.textureTypeReadable(l))return void H(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&K.readPixels(t,n,r,i,Ze.convert(c),Ze.convert(l),a)}finally{let e=M===null?null:z.get(M).__webglFramebuffer;R.bindFramebuffer(K.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!e||!e.isWebGLRenderTarget)throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=z.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c){if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){R.bindFramebuffer(K.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&K.readBuffer(K.COLOR_ATTACHMENT0+s),!Ne.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!Ne.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=K.createBuffer();K.bindBuffer(K.PIXEL_PACK_BUFFER,d),K.bufferData(K.PIXEL_PACK_BUFFER,a.byteLength,K.STREAM_READ),K.readPixels(t,n,r,i,Ze.convert(l),Ze.convert(u),0);let f=M===null?null:z.get(M).__webglFramebuffer;R.bindFramebuffer(K.FRAMEBUFFER,f);let p=K.fenceSync(K.SYNC_GPU_COMMANDS_COMPLETE,0);return K.flush(),await Ve(K,p,4),K.bindBuffer(K.PIXEL_PACK_BUFFER,d),K.getBufferSubData(K.PIXEL_PACK_BUFFER,0,a),K.deleteBuffer(d),K.deleteSync(p),a}throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)}},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;B.setTexture2D(e,0),K.copyTexSubImage2D(K.TEXTURE_2D,n,0,0,o,s,i,a),R.unbindTexture()},this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=Ze.convert(t.format),_=Ze.convert(t.type),v;t.isData3DTexture?(B.setTexture3D(t,0),v=K.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(B.setTexture2DArray(t,0),v=K.TEXTURE_2D_ARRAY):(B.setTexture2D(t,0),v=K.TEXTURE_2D),R.activeTexture(K.TEXTURE0),R.pixelStorei(K.UNPACK_FLIP_Y_WEBGL,t.flipY),R.pixelStorei(K.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),R.pixelStorei(K.UNPACK_ALIGNMENT,t.unpackAlignment);let y=R.getParameter(K.UNPACK_ROW_LENGTH),b=R.getParameter(K.UNPACK_IMAGE_HEIGHT),x=R.getParameter(K.UNPACK_SKIP_PIXELS),S=R.getParameter(K.UNPACK_SKIP_ROWS),C=R.getParameter(K.UNPACK_SKIP_IMAGES);R.pixelStorei(K.UNPACK_ROW_LENGTH,h.width),R.pixelStorei(K.UNPACK_IMAGE_HEIGHT,h.height),R.pixelStorei(K.UNPACK_SKIP_PIXELS,l),R.pixelStorei(K.UNPACK_SKIP_ROWS,u),R.pixelStorei(K.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=z.get(e),r=z.get(t),h=z.get(n.__renderTarget),g=z.get(r.__renderTarget);R.bindFramebuffer(K.READ_FRAMEBUFFER,h.__webglFramebuffer),R.bindFramebuffer(K.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n{let[a,o]=e[(i+1)%e.length];return t+n*o-a*r},0)/2}function Al(e,t=40,{open:n=!1}={}){return new oa((n||kl(e)>=0?e:[...e].reverse()).map(([e,t])=>new W(e,t)),t)}function jl(e,t,n){let r=e.attributes.position;for(let e=0;ee.index?e.toNonIndexed():e),n=t.reduce((e,t)=>e+t.attributes.position.count,0),r=new Float32Array(n*3),i=new Float32Array(n*3),a=new Float32Array(n*2),o=0;t.forEach(e=>{let t=e.attributes.position.count;r.set(e.attributes.position.array.subarray(0,t*3),o*3),e.attributes.normal&&i.set(e.attributes.normal.array.subarray(0,t*3),o*3),e.attributes.uv&&a.set(e.attributes.uv.array.subarray(0,t*2),o*2),o+=t});let s=new Yn;return s.setAttribute(`position`,new Fn(r,3)),s.setAttribute(`normal`,new Fn(i,3)),s.setAttribute(`uv`,new Fn(a,2)),s.computeBoundingSphere(),s}var Pl=new J;function Fl(e,{castShadow:t=!0,receiveShadow:n=!0}={}){e.updateMatrixWorld(!0);let r=new J().copy(e.matrixWorld).invert(),i=new Map,a=[];e.traverse(t=>{if(!t.isMesh||t.isInstancedMesh||t.userData.dynamic)return;let n=t.parent;for(;n&&n!==e;){if(n.userData.dynamic)return;n=n.parent}Pl.multiplyMatrices(r,t.matrixWorld);let o=`${t.material.uuid}|${+!!t.castShadow}`;i.has(o)||i.set(o,{material:t.material,cast:t.castShadow,parts:[]}),i.get(o).parts.push(Ml(t.geometry,Pl)),a.push(t)});let o=new Set(a.map(e=>e.geometry));a.forEach(e=>e.removeFromParent()),o.forEach(e=>e.dispose());let s=[];for(let{material:r,cast:a,parts:o}of i.values()){let i=Nl(o);o.forEach(e=>e.dispose());let c=new vr(i,r);c.castShadow=t&&a,c.receiveShadow=n,e.add(c),s.push(c)}return s}function Il(e,t,n){let r=e*374761393+t*668265263+n*2147483647|0;return r=Math.imul(r^r>>>13,1274126177),((r^r>>>16)>>>0)/4294967295}function Ll(e){return e*e*(3-2*e)}function Rl(e,t){return(e%t+t)%t}function zl(e,t,n,r){let i=Math.floor(e),a=Math.floor(t),o=Ll(e-i),s=Ll(t-a),c=Rl(i,r),l=Rl(i+1,r),u=Rl(a,r),d=Rl(a+1,r),f=Il(c,u,n),p=Il(l,u,n),m=Il(c,d,n),h=Il(l,d,n);return f+(p-f)*o+(m-f)*s+(f-p-m+h)*o*s}function Bl(e,t,n,r,i=4){let a=0,o=.5,s=1,c=0;for(let l=0;l{let l=new or({side:2});l.color.setStyle(t(e)),l.color.multiplyScalar(a);let u=new ca(o[0],o[1]),d=new vr(u,l);d.position.set(...s),d.lookAt(...c),r.push(u),i.push(l),n.add(d)},o=new or({side:1});o.color.setStyle(t(`--env-room`)||t(`--stage-bottom`));let s=new Gr(20,12,20),c=new vr(s,o);c.position.y=4,n.add(c),r.push(s),i.push(o),a(`--env-light`,6,[8,8],[0,9.5,0],[0,0,0]),a(`--env-light`,4,[3,6],[-8,4,3],[0,1,0]),a(`--env-light`,2.2,[3,5],[8,3,-2],[0,1,0]),a(`--env-warm`,1.6,[10,2],[0,1.5,9],[0,1,0]);let l=new ts(e),u=l.fromScene(n,.04);return l.dispose(),r.forEach(e=>e.dispose()),i.forEach(e=>e.dispose()),u}var Jl=.7,Yl=.5;Yl*2;var Xl=.14,Zl=.3,Ql=.27,$l=.26,eu=.026,tu=.062,nu=.004,ru=48,iu=.0085,au=.47,ou=.03,su=1.35,cu={goal:[-.42,.21,.7],maker:[-.47,.3,.69],verify:[-.2,.42,.66],review:[-.12,.2,.8],judge:[.06,.3,.7],deliver:[0,.24,.76]},lu=.45,uu=[`sx`,`sy`,`rz`,`dy`,`lid`,`slope`],du=.12,fu=.07,pu=.3,mu=5e-4,hu=18,gu=.001,_u=(e,t,n)=>new Va(e,t,n),vu=(e,t,n)=>new Ga(e,t,n),yu=(e,t)=>vu(`${e}.scale`,[0,t],[1,1,1,1,1,1]);function bu(e,t=.025){let n=e/2;return[_u(`body.position[y]`,[0,n,e],[0,t,0]),vu(`body.scale`,[0,n,e],[1,1,1,1.012,.985,1.012,1,1,1])]}function xu(){let e=2.4,t=[0,.3,.6,.9,1.2,1.5,1.8,2.1,e],[n,r,i]=cu.goal,a=t.flatMap((e,t)=>[n+(t%2?.025:-.02)+e*.012,r+(t%2?.012:0),i]);return new Ka(`goal`,e,[yu(`prop_goal`,e),...bu(e),_u(`prop_goal.rotation[z]`,t,[-.35,-.22,-.4,-.24,-.36,-.2,-.38,-.23,-.35]),vu(`prop_goal.position`,t,[...a.slice(0,-3),n,r,i]),_u(`face.rotation[x]`,[0,e/2,e],[.2,.26,.2]),_u(`face.rotation[y]`,[0,e/2,e],[-.18,-.12,-.18])])}var Su=1.3,Cu=.3;function wu(e,t,n=8){let r=[],i=[];for(let a=0;a<=n;a+=1){let o=a/n;r.push(Number((e+(t-e)*o).toFixed(4))),i.push(Number((ou+4*Cu*o*(1-o)).toFixed(4)))}return{times:r,heights:i}}function Tu(){let e=Su,[t,n,r]=cu.maker,i=[0,.3,.45,.6,.95,1.05,1.15,e],a=wu(.42,.95);return new Ka(`maker`,e,[yu(`prop_maker`,e),...bu(e,.015),vu(`prop_maker.position`,i,[t,n,r,t,n-.02,r-.07,t,n+.07,r+.05,t,n+.02,r,t,n-.03,r,t+.03,n,r,t-.03,n,r,t,n,r]),_u(`prop_maker.rotation[x]`,i,[0,.12,-.38,-.12,.06,0,0,0]),_u(`pan_food.position[y]`,[0,...a.times,1.02,e],[ou,...a.heights,.038,ou]),_u(`pan_food.rotation[x]`,[0,.42,.95,e],[0,0,-Math.PI*2,-Math.PI*2]),_u(`face.rotation[x]`,[0,.45,.7,.95,e],[.16,.08,.02,.18,.16]),_u(`face.rotation[y]`,[0,e],[-.3,-.3]),_u(`body.rotation[z]`,[0,.45,.95,e],[.04,-.02,.05,.04])])}function Eu(){let e=2.6,[t,n,r]=cu.verify,i=[0,.5,.8,1.3,1.8,2.2,e];return new Ka(`verify`,e,[yu(`prop_verify`,e),...bu(e),vu(`prop_verify.position`,i,[t,n,r,-.28,.24,.74,-.28,.2,.74,-.02,.44,.6,-.02,.44,.6,t,n,r,t,n,r]),_u(`face.rotation[x]`,i,[.1,.24,.26,.04,.04,.1,.1]),_u(`face.rotation[y]`,[0,1.8,2,2.2,e],[-.15,-.15,.08,-.12,-.15])])}function Du(){let e=3.2,[t,n,r]=cu.review;return new Ka(`review`,e,[yu(`prop_review`,e),...bu(e,.015),vu(`prop_review.position`,[0,e/2,e],[t-.07,n,r,t+.07,n+.02,r+.03,t-.07,n,r]),_u(`prop_review.rotation[z]`,[0,e/2,e],[.15,-.1,.15]),_u(`face.rotation[z]`,[0,e*.4,e*.7,e],[.08,.14,.03,.08]),_u(`face.rotation[x]`,[0,e],[.2,.2]),_u(`body.rotation[z]`,[0,e/2,e],[.05,-.04,.05])])}function Ou(){let e=3.4,[t,n,r]=cu.judge,i=[0,.6,.9,1.1,1.6,2,2.3,2.55,2.8,e];return new Ka(`judge`,e,[yu(`prop_judge`,e),...bu(e,.015),_u(`body.rotation[x]`,i,[.04,.2,.22,.2,.1,.08,.08,.08,.06,.04]),vu(`prop_judge.position`,i,[t,n,r,.05,.16,.74,.05,.11,.76,.05,.14,.74,.12,.44,.58,.12,.44,.58,t,n,r,t,n,r,t,n,r,t,n,r]),_u(`face.rotation[x]`,i,[.12,.3,.32,.3,.05,.05,.28,.06,.24,.12]),vu(`hop.scale`,[0,2.3,2.38,2.5,e],[1,1,1,1,1,1,1.04,.95,1.04,1,1,1,1,1,1])])}function ku(){let e=1.2;return new Ka(`deliver`,e,[yu(`prop_deliver`,e),_u(`body.position[y]`,[0,e/4,e/2,e*3/4,e],[0,.06,0,.06,0]),_u(`body.rotation[z]`,[0,e/4,e*3/4,e],[0,.06,-.06,0])])}function Au(e,t,n){let r=Math.min(n,t+.6);return[_u(`${e}.position[y]`,[0,t,r,n],[1.05,1.05,1.5,1.5]),vu(`${e}.scale`,[0,t,t+.1,r,n],[gu,gu,gu,gu,gu,gu,1,1,1,gu,gu,gu,gu,gu,gu])]}function ju(){let e=1.2,t=1.8,n=.9;return[new Ka(`waiting-1`,4,[...bu(4),_u(`face.rotation[y]`,[0,1.2,2.2,3.4,4],[0,.32,.32,-.26,0]),_u(`body.rotation[z]`,[0,1.2,3.4,4],[0,.06,-.05,0])]),new Ka(`waiting-2`,e,[_u(`body.position[y]`,[0,.15,.3,.6,.75,.9,e],[0,.05,0,0,.05,0,0]),_u(`body.rotation[z]`,[0,.3,.6,.9,e],[0,.05,0,-.05,0])]),new Ka(`waiting-3`,t,[...bu(t),_u(`face.rotation[y]`,[0,.2,.4,.6,t],[0,.12,-.12,.08,0]),_u(`body.rotation[z]`,[0,t/2,t],[.03,-.03,.03])]),new Ka(`waiting-4`,n,[_u(`body.position[y]`,[0,n*.25,n*.5,n*.75,n],[0,.32,0,.26,0]),vu(`body.scale`,[0,n*.45,n*.5,n*.6,n],[1,1,1,.95,1.06,.95,1.1,.88,1.1,1,1,1,1,1,1]),yu(`steam`,n),...Au(`puff1`,0,n),...Au(`puff2`,.3,n),...Au(`puff3`,.55,n)])]}function Mu(){let e=Jl;return new Ka(`reaction`,e,[_u(`hop.position[y]`,[0,e*.12,e*.45,e*.8,e],[0,0,.55,0,0]),_u(`hop.rotation[y]`,[0,e*.12,e*.8,e],[0,0,Math.PI*2,Math.PI*2]),vu(`hop.scale`,[0,e*.12,e*.24,e*.8,e*.9,e],[1,1,1,1.1,.86,1.1,.93,1.1,.93,1.12,.85,1.12,1,1,1,1,1,1])])}function Nu(){return{stages:{goal:xu(),maker:Tu(),verify:Eu(),review:Du(),judge:Ou(),deliver:ku()},waiting:ju(),reaction:Mu()}}var Pu={open:{},focus:{sx:1.04,sy:.9,lid:.55,slope:.18},wide:{sx:1.12,sy:1.15},squint:{sx:1.15,sy:.42,rz:.06,wink:.22},stern:{sx:1.06,sy:.86,lid:.36,slope:.22},happy:{arcs:!0},question:{sx:1.05,sy:1.1,lid:.5,slope:-.55,mark:!0},annoyed:{sx:1.1,sy:.95,lid:-.05,slope:.08,lift:-.008},angry:{sx:1.1,sy:.88,lid:.02,slope:1.1,lift:-.004}};function Fu(e,t=1){let n={sx:1,sy:1,rz:0,lift:0,lid:1,slope:0,wink:0,...Pu[e]||Pu.open},r=Math.min(1,Math.max(.06,t)),i=e=>({sx:n.sx,sy:n.sy*(1+e*n.wink)*r,rz:e*n.rz,dy:n.lift,lid:n.lid,slope:n.slope});return{left:i(-1),right:i(1),arcs:!!n.arcs&&r>.5,mark:!!n.mark}}function Iu({sx:e,sy:t,rz:n,dy:r,lid:i,slope:a},o,s=ru){let c=eu*e,l=Math.max(tu*t,.003),u=Math.min(c,l),d=e=>l*i+o*a*e,f=Math.cos(n),p=Math.sin(n),m=[];for(let e=0;e{i+=e/t.length,a+=n/t.length}),Ru(r,0,i,a,n),t.forEach(([e,t],i)=>Ru(r,(i+1)*3,e,t,n)),e.attributes.position.needsUpdate=!0,e.computeBoundingSphere()}function Vu(e,t=Yl){let n=zu(ru),r=t/Yl,i=(i=1,a=`open`)=>{let o=Fu(a,i)[e<0?`left`:`right`];Bu(n,Iu(o,e).map(([e,t])=>[e*r,t*r]),t)};return i(),{geometry:n,shape:i}}function Hu(e){return e<0||e>=.14?1:Math.abs(1-2*e/Xl)}function Uu(){let e=new Float32Array(114),t=[];for(let n=0;n<=18;n+=1){let r=Math.PI*(.12+n/18*.76),i=Math.cos(r),a=Math.sin(r),o=eu*1.35*i,s=tu*.55*a-tu*.2;if(Ru(e,n*6,o+i*iu,s+a*iu),Ru(e,n*6+3,o-i*iu,s-a*iu),n<18){let e=n*2;t.push(e,e+2,e+1,e+1,e+2,e+3)}}let n=new Yn;return n.setAttribute(`position`,new Fn(e,3)),n.setIndex(t),n.computeBoundingSphere(),n}function Wu(e,t){let n=new vr(e(new Jr(.008,.011,.24,12)),t);n.position.y=.15;let r=new vr(e(new da(1,20,12)),t);return r.scale.set(.034,.05,.014),r.position.y=-.005,[n,r]}function Gu(){let e=[],t=[],n=[],r=e=>t=>(e.push(t),t),i=r(e),a=r(t),o=(e,t=[],n=[0,0,0])=>{let r=new Y;return r.name=e,r.position.set(...n),t.forEach(e=>r.add(e)),r},s=(e,t,n=[0,0,0],r=[0,0,0],i=``)=>{let a=new vr(e,t);return a.position.set(...n),a.rotation.set(...r),a.name=i,a.castShadow=!0,a},c=e=>(e.scale.setScalar(gu),e),l=a(new Ea({roughness:.32,metalness:0,clearcoat:1,clearcoatRoughness:.06,sheen:0})),u=a(new or),d=a(new Ea({roughness:.88,sheen:.7,sheenRoughness:.55})),f=a(new Ea({roughness:.8,sheen:.6,sheenRoughness:.5})),p=a(new Ta({roughness:.55})),m=a(new Ea({roughness:.24,metalness:.85,clearcoat:1,clearcoatRoughness:.06,envMapIntensity:1.5})),h=a(new Ea({roughness:.38,metalness:.7,clearcoat:.3})),g=a(new Ea({roughness:.2,metalness:1,clearcoat:.5})),_=a(new Ta({roughness:.55})),v=a(new Ea({roughness:.6,sheen:.5})),y=a(new Ea({roughness:.45,clearcoat:.4})),b=a(new Ea({roughness:.02,transparent:!0,opacity:.25,clearcoat:1,depthWrite:!1})),x=a(new Ta({roughness:1,transparent:!0,opacity:.55,depthWrite:!1})),S=Yl,C=s(i(new da(S,64,48)),l,[0,0,0],[0,0,0],`shell`),w=i(Uu()),T=e=>{let t=i(zu(ru));Bu(t,Iu(Fu(`open`).left,e));let n=s(t,u);n.castShadow=!1;let r=s(w,u);r.castShadow=!1,r.visible=!1;let a=o(e<0?`eyeL`:`eyeR`,[n,r]);return a.rotation.set(-.26,Zl+e*Ql/2,0),{pivot:a,pupil:n,arc:r,shape:t,side:e}},E=T(-1),D=T(1),O=c(o(`mark`,[s(i(new pa(.07,.02,10,28,Math.PI*1.4)),u,[0,.09,0],[0,0,-Math.PI*.4]),s(i(new Kr(.02,.05,4,10)),u,[0,-.02,0]),s(i(new da(.024,16,12)),u,[0,-.11,0])],[.42,.9199999999999999,.12])),k=o(`gaze`,[E.pivot,D.pivot]),A=o(`face`,[k]),ee=s(i(new Jr(.2,.2,.09,56)),d,[0,au,0]),j=s(i(jl(new Jr(.235,.2,.27,56,6,!0),12,.045)),d,[0,.64,0]),M=jl(new da(1,56,24),8,.07);M.scale(.29,.15,.29);let N=s(i(M),d,[0,.8,0]),te=new kr(i(new da(1,12,8)),p,hu),P=new Kt;for(let e=0;e{let r=o(e,t,cu[e.replace(`prop_`,``)]);return r.rotation.set(...n),c(r)},I=ce(`prop_goal`,[s(i(new Jr(.006,.002,.26,10)),m,[0,-.02,0]),(()=>{let e=s(i(new da(1,20,12)),v,[0,.08,0]);return e.scale.set(.04,.15,.012),e})()],[.35,0,-.35]),le=o(`pan_food`,[],[0,ou,0]);for(let[e,t,n]of[[-.05,.03,1],[.06,-.04,.8],[.02,.07,.7],[-.02,-.07,.75]]){let r=s(i(new da(1,14,10)),y,[e,0,t]);r.scale.set(.045*n,.022*n,.04*n),le.add(r)}let ue=s(i(new da(1,10,8)),p,[0,.015,0],[.3,.6,0]);ue.scale.set(.026,.007,.014),le.add(ue);let de=o(`pan_body`,[s(i(Al([[0,0],[.17,0],[.19,.01],[.205,.055],[.192,.06],[.176,.016],[0,.016]],48)),h,[0,0,0]),s(i(new Jr(.016,.02,.26,12)),_,[.33,.06,0],[0,0,Math.PI/2+.2]),s(i(new Jr(.012,.012,.06,10)),h,[.21,.045,0],[0,0,Math.PI/2+.2]),le]);de.scale.setScalar(su);let fe=ce(`prop_maker`,[de],[0,.55,0]),pe=ce(`prop_verify`,Wu(i,m),[-.6,0,-.2]),me=ce(`prop_review`,[s(i(new Jr(.016,.02,.18,12)),_,[0,-.19,0]),s(i(new pa(.1,.016,12,40)),g,[0,0,0]),(()=>{let e=s(i(new Jr(.092,.092,.006,32)),b,[0,0,0],[Math.PI/2,0,0]);return e.castShadow=!1,e})()],[.75,0,.15]),he=ce(`prop_judge`,Wu(i,m),[-.6,0,.15]),L=ce(`prop_deliver`,[s(i(Al([[0,0],[.25,0],[.265,.012],[.26,.022],[0,.016]],48)),m,[0,0,0]),s(i(Al([[0,.02],[.17,.02],[.175,.03],[.165,.08],[.13,.14],[.07,.175],[0,.18]],48)),m,[0,0,0]),s(i(new da(.022,16,12)),m,[0,.195,0])],[.12,0,-.04]),ge=i(new da(.1,18,12)),_e=c(o(`steam`,[-.32,.32,0].map((e,t)=>{let n=s(ge,x,[e,1.05,0],[0,0,0],`puff${t+1}`);return n.castShadow=!1,c(n)}))),ve=o(`body`,[o(`head`,[C,A,F,re,ae,O],[0,S,0]),I,fe,pe,me,he,L,_e]),ye=o(`hop`,[ve]),be=o(`stride`,[ye]),xe=Gl(1.7);n.push(xe);let Se=Kl(1.05,1.05,{opacity:.42,texture:xe});return Se.position.y=.004,e.push(Se.geometry),t.push(Se.material),{root:o(`root`,[Se,be]),stride:be,hop:ye,body:ve,face:A,gaze:k,eyes:{left:E,right:D},mark:O,shadow:Se,costumes:{philosopher:[ne],devil:[F,ae],chef:[re]},materials:{shell:l,eye:u,hat:d,beret:f,leaf:p,metal:m,iron:h,brass:g,wood:_,feather:v,food:y,glass:b,steam:x},geometries:e,allMaterials:t,textures:n}}var Ku={hat:`--prop-paper`,beret:`--bot-devil-trim`,iron:`--kitchen-iron`,food:`--kitchen-food`,leaf:`--bot-leaf`,metal:`--prop-metal`,brass:`--room-brass`,wood:`--prop-wood`,feather:`--prop-paper`,glass:`--prop-paper`,steam:`--prop-paper`};function qu(e,t,n,r){let i=e+(t-e)*(1-Math.exp(-n/r));return Math.abs(i-t)[e,a.clipAction(i.stages[e])])),l=i.waiting.map(e=>a.clipAction(e)),u=a.clipAction(i.reaction);u.setLoop(Se,1);let d=new Set,f={x:0,y:0,toX:0,toY:0},p={devil:0,philosopher:0,chef:1,anger:0},m={devil:0,philosopher:0,chef:1,anger:0},h={left:{...Fu(`open`).left},right:{...Fu(`open`).right}},_={},v=null,y=null,b=`open`,x=()=>performance.now()/1e3,S=0,C={at:x()+Lu(),until:0};function w(e){e.action===u&&u.stop()}a.addEventListener(`finished`,w);function T(e){return e.mode===`working`?s[e.botStage]:e.mode===`waiting`?l[Math.min(Math.max((e.waitLevel||1)-1,0),l.length-1)]:null}function E(){let{shell:e,eye:t}=r.materials;if(!_.shell)return;e.color.copy(_.shell).lerp(_.devilShell,p.devil),p.anger>0&&e.color.lerp(_.danger,p.anger*.35),e.roughness=.32+p.devil*.2,t.color.copy(_.eye).lerp(_.devilEye,p.devil*.85);let n=(e,t)=>e.forEach(e=>e.scale.setScalar(Math.max(gu,t)));n(r.costumes.philosopher,p.philosopher),n(r.costumes.devil,p.devil),n(r.costumes.chef,p.chef)}function D(e){g.forEach(t=>{let n=r.root.getObjectByName(`prop_${t}`);n&&n.scale.setScalar(e.mode===`working`&&t===e.botStage?1:gu)})}function k(){for(let e of d)e.getEffectiveWeight()===0&&(e.stop(),d.delete(e))}function A(t){let n=!1;for(let r of Object.keys(p)){let i=e?m[r]:qu(p[r],m[r],t,pu);i!==m[r]&&(n=!0),p[r]=i}return E(),n}function ee(e){if(e>=C.until)return 1;let t=(C.until-e)/Xl;return Math.abs(t*2-1)}function j(t){return e?!1:t=C.until&&(C={at:t+Lu(),until:0}),t>=C.at&&(C.until=t+Xl,!0))}function M(t,n){let i=Fu(ne.dispose()),r.allMaterials.forEach(e=>e.dispose()),r.textures.forEach(e=>e.dispose())}}}var Yu=.62,Xu=.42,Zu=.56,Qu=.34;function $u(e){return{register:(t,n,r={})=>(e.push({material:t,token:n,stage:null,...r}),t),mesh:(e,t,n=[0,0,0],r=[0,0,0],i=!0)=>{let a=new vr(e,t);return a.position.set(...n),a.rotation.set(...r),a.castShadow=i,a.receiveShadow=!0,a}}}function ed(e,t,n){let r=new Y;r.add(e.mesh(Al([[0,Zu],[.55,Zu],[.58,.54],[.59,.41000000000000003],[.55,.41000000000000003],[.54,.53],[0,.53]],56),t.cloth),e.mesh(Al([[0,0],[.22,0],[.22,.02],[.05,.05],[.04,.53],[0,.53]],28),t.wood));let i=new ca(1.6,1.6);i.rotateX(-Math.PI/2);let a=e.mesh(i,t.blob,[0,.003,-.2],[0,0,0],!1);return a.receiveShadow=!1,a.renderOrder=1,r.add(a),r}function td(e,t){let n=new Y;return n.add(e.mesh(Ol(.4,.04,.38,.014),t.wood,[0,.32,0]),e.mesh(Ol(.4,.42,.04,.014),t.wood,[0,.54,-.18]),...[[-.17,-.16],[.17,-.16],[-.17,.16],[.17,.16]].map(([n,r])=>e.mesh(Ol(.035,.30000000000000004,.035,.01),t.wood,[n,.30000000000000004/2,r]))),n}function nd(e,t,n){let r=e.register(new Ea({roughness:.3,clearcoat:1,clearcoatRoughness:.08}),n),i=new Y,a=new Y,o=e.mesh(new da(Xu,40,28),r,[0,.54,0]),s=new Y;s.position.y=.54;let c=new Y,l=[],u=[-1,1].map(n=>{let r=new Y,i=Vu(n,Xu);return l.push(i),r.add(e.mesh(i.geometry,t.eye,[0,0,0],[0,0,0],!1)),r.rotation.set(-$l,n*Ql/2,0),r});c.add(...u),s.add(c);let d=e=>{let t=new Y;return t.position.set(e*.48,Xu*.7,.1),t},f=d(-1),p=d(1),m=new Y;m.add(e.mesh(new Jr(.012,.014,.24,8),t.metal,[0,.06,0]),e.mesh(Ol(.06,.08,.012,.004),t.metal,[0,.2,0])),m.position.set(0,-.16,.1),m.rotation.x=-1.2,p.add(m);let h=e.mesh(Al([[0,0],[.06,0],[.07,.13],[.064,.13],[.055,.012],[0,.012]],24),t.paper,[0,-.2,.1]);return f.add(h),a.add(o,s,f,p),i.add(a),{root:i,body:a,head:s,gaze:c,armL:f,armR:p,decals:l,open:1,blinkAt:null}}function rd({registry:e,textures:t,count:n}){let r=$u(e),i={cloth:r.register(new Ea({roughness:.85,sheen:.6,sheenRoughness:.5,map:t.fabric}),`--prop-paper`),wood:r.register(new Ta({roughness:.5,map:t.planks}),`--prop-wood`),paper:r.register(new Ea({roughness:.3,clearcoat:.7}),`--prop-paper`),metal:r.register(new Ta({roughness:.25,metalness:1}),`--prop-metal`),eye:r.register(new or,`--bot-visor`),food:r.register(new Ea({roughness:.45,clearcoat:.5}),`--kitchen-food`),blob:r.register(new or({transparent:!0,opacity:.28,depthWrite:!1,alphaMap:t.blob,polygonOffset:!0,polygonOffsetFactor:-2}),`--shadow`,{flat:!0})},a=new Y;a.name=`dining`;let o=d(x(n)),s=new Set(o.map(e=>e.table));S.forEach((e,n)=>{if(!s.has(n))return;let o=ed(r,i,t);o.position.set(e.x,0,e.z),a.add(o)});let c=o.map(e=>{let t=td(r,i);t.position.set(e.x,0,e.z-.05);let n=new Y,o=r.mesh(new da(1,20,12,0,Math.PI*2,0,Math.PI/2),i.food,[0,.012,0]);o.scale.set(.07,.04,.06),n.add(r.mesh(Al([[0,0],[.12,0],[.17,.012],[.18,.018],[.11,.01],[0,.01]],36),i.paper),o),n.position.set(e.x,Zu,e.z+.46),a.add(t,n);let s=nd(r,i,`--diner-${e.index%6+1}`);return s.root.position.set(e.x,Qu,e.z+.02),s.root.scale.setScalar(Yu),s.root.userData.dynamic=!0,a.add(s.root),{...s,...e}});return Fl(a),{group:a,figures:c}}function id(e,t,{reducedMotion:n=!1,bot:r=null}={}){for(let i of e){let e=f(i.loop,t,i.phase,{reducedMotion:n});i.armR.rotation.x=e.armR+.5,i.armL.rotation.x=e.armL+.3,i.head.rotation.x=e.head,i.head.rotation.z=e.tilt,i.body.rotation.z=e.sway;let a=r&&!n?T(t,i.phase):0,o=r?Math.max(-1.3,Math.min(1.3,Math.atan2(r.x-i.x,Math.abs(r.z-i.z))*1.6)):0;i.gaze.rotation.set(-a*.25,a*o,0),ad(i,t,n)}}function ad(e,t,n=!1,r=Math.random){let i=1;return n||((e.blinkAt===null||t-e.blinkAt>30)&&(e.blinkAt=t+Lu(r)),t-e.blinkAt>=.14&&(e.blinkAt=t+Lu(r)),i=Hu(t-e.blinkAt)),i!==e.open&&(e.open=i,e.decals.forEach(e=>e.shape(i)),!0)}var od={width:.66,depth:.5,top:.7,z:-3.9};function sd(e){return e===`maker`?`hob`:`board`}function cd(e){let{width:t,depth:n,top:r}=od,i=new Ta({roughness:.3,metalness:1}),a=new Ta({roughness:sd(e)===`hob`?.18:.6}),o=[{material:i,token:`--kitchen-steel`},{material:a,token:sd(e)===`hob`?`--kitchen-iron`:`--prop-wood`}],s=new Y,c=(e,t,n,r,i)=>{let a=new vr(e,t);return a.position.set(n,r,i),a.castShadow=!0,a.receiveShadow=!0,s.add(a),a};c(Ol(t,.035,n,.008),i,0,r-.018,0),c(Ol(t-.06,.02,n-.06,.006),i,0,.16,0);let l=new Jr(.016,.016,r-.02,10);return[[-1,-1],[1,-1],[-1,1],[1,1]].forEach(([e,a])=>c(l,i,e*(t/2-.03),(r-.02)/2,a*(n/2-.03))),sd(e)===`hob`?c(new Jr(.1,.1,.012,32),a,t/2-.13,r+.006,n/2-.12):c(Ol(.2,.016,.14,.005),a,t/2-.13,r+.009,n/2-.1),{group:s,paint(e){o.forEach(({material:t,token:n})=>{let r=e(n);r&&t.color.setStyle(r)})},dispose(){s.removeFromParent();let e=new Set;s.traverse(t=>{t.geometry&&e.add(t.geometry)}),e.forEach(e=>e.dispose()),o.forEach(({material:e})=>e.dispose())}}}function ld(e,{reducedMotion:t=!1,mounted:n=!0}={}){return n?!e||t?`reuse`:`slide`:`mount`}function ud(e,{build:t,dispose:n}){let r=null,i=null;function a(){i&&n(i),i=null}return{get current(){return r},get outgoing(){return i},mount(i){return a(),r&&n(r),r=t(i),e.add(r.carrier),r},slide(n){a();let o=t(n);return e.add(o.carrier),i=r,r=o,o},finish:a,dispose(){a(),r&&n(r),r=null}}}var dd=.45,fd=1.36/2,pd=13.6,md=-.38,hd=dd,gd=-1.15,_d=1.77,vd=.44,yd=vd*1.3,bd=-2.5,xd=2.62,Sd=[-4.2,-1.4,1.4,4.2],Cd=2.72,wd=.05,Td=-2.08,Ed=.62,Dd={left:-6.3,right:6.3,bottom:.95,top:2},Od=-5.6,kd=22,Ad=5,jd=11,Md=1.5,Nd=1.3,Pd=.32;function Fd(e,t,n=null){let r=(t,r,i={})=>(e.push({material:t,token:r,stage:n,...i}),t),i=(e,t={},n={})=>r(new Ta({roughness:.6,...t}),e,n),a=(e,t={},n={})=>r(new Ea({roughness:.5,...t}),e,n),o=(e,t,n=[0,0,0],r=[0,0,0],{cast:i=!0}={})=>{let a=new vr(e,t);return a.position.set(...n),a.rotation.set(...r),a.castShadow=i,a.receiveShadow=!0,a},s=(e,t,n,r,i)=>o(Ol(e[0],e[1],e[2],e[3]??Math.min(e[0],e[1],e[2])*.2),t,n,r,i),c=r(new or({transparent:!0,opacity:.34,depthWrite:!1,alphaMap:t.blob,polygonOffset:!0,polygonOffsetFactor:-2}),`--shadow`,{flat:!0});return{register:r,standard:i,physical:a,mesh:o,box:s,blob:(e,t,n,r,i,a=0)=>{let s=new ca(e,t);s.rotateX(-Math.PI/2),s.rotateY(a);let l=o(s,c,[n,r+.003,i],[0,0,0],{cast:!1});return l.receiveShadow=!1,l.renderOrder=1,l}}}function Id(e,t,n={}){e.standard(`--prop-wood`,{roughness:.45,map:t.grain});let r=e.standard(`--prop-paper`,{roughness:.85,map:t.paper}),i=e.physical(`--on-brand`,{roughness:.12,clearcoat:1}),a=e.physical(`--prop-paper`,{roughness:.6,sheen:.5}),o=e.physical(`--room-brass`,{roughness:.28,metalness:1,clearcoat:.4}),s=e.physical(`--room-velvet`,{roughness:.55,sheen:.4,sheenRoughness:.5},{sheen:`--room-velvet-sheen`}),c=new Y;c.add(e.box([.5,.03,.36,.01],s,[0,.015,0]),e.box([.23,.025,.33,.006],r,[-.12,.04,0],[0,0,.06]),e.box([.23,.025,.33,.006],r,[.12,.04,0],[0,0,-.06])),c.position.set(-.42,0,Pd),c.rotation.y=.25,c.name=`orderBook`,c.userData.dynamic=!0,n.book=c;let l=new Y;l.add(e.mesh(Al([[0,0],[.05,0],[.056,.03],[.04,.07],[.026,.08],[0,.08]],24),i,[0,0,0]));let u=new Y,d=e.mesh(new da(1,20,12),a,[0,.16,0]);d.scale.set(.045,.17,.012),u.add(d,e.mesh(new Jr(.005,.007,.28,8),o,[0,.05,0])),u.position.set(0,.05,0),u.rotation.set(.1,0,-.3),l.add(u),l.position.set(-.08,0,.37);let f=new Y;return f.add(e.mesh(new Jr(.07,.08,.03,24),o,[0,.015,0]),e.mesh(new Jr(.006,.006,.3,8),o,[0,.18,0])),[.08,.12,.16,.2].forEach((t,n)=>f.add(e.box([.16,.004,.2,.002],r,[0,t,0],[.05*(n%2?1:-1),n*.4,.04]))),f.position.set(.48,0,.3),[c,l,f,e.blob(.8,.55,-.3,0,Pd),e.blob(.35,.35,.48,0,Pd)]}function Ld(e,t,n){let r=e.physical(`--kitchen-steel`,{roughness:.32,metalness:.9,map:t.brushed}),i=e.physical(`--kitchen-iron`,{roughness:.3,clearcoat:.8,clearcoatRoughness:.1}),a=e.physical(`--kitchen-iron`,{roughness:.42,metalness:.6,clearcoat:.3}),o=e.standard(`--prop-wood`,{roughness:.5,map:t.grain}),s=e.physical(`--kitchen-food`,{roughness:.45,clearcoat:.4}),c=e.standard(`--bot-leaf`,{roughness:.5}),l=e.register(new Ta({roughness:.4,metalness:.3,emissiveIntensity:0}),`--kitchen-iron`,{burner:!0}),u=e.register(new Ta({roughness:1,transparent:!0,opacity:.26,depthWrite:!1}),`--prop-paper`,{steam:!0}),d=new Y;d.add(e.box([1.32,.09,.62,.03],r,[0,.045,0]),e.box([1.26,.014,.56,.006],i,[0,.094,0]));for(let t of[-.56,.56])d.add(e.mesh(new Jr(.025,.025,.03,16),a,[t,.045,.32],[Math.PI/2,0,0]));let f=[-.34,.34].map(t=>{let n=e.mesh(new pa(.14,.014,10,40),l,[t,.104,0],[Math.PI/2,0,0],{cast:!1});return n.userData.dynamic=!0,n});d.add(...f);let p=new Y;p.add(e.mesh(Al([[0,0],[.2,0],[.22,.01],[.24,.06],[.225,.066],[.205,.016],[0,.016]],40),a,[0,0,0]),e.mesh(new Jr(.018,.022,.32,12),o,[-.36,.05,0],[0,0,Math.PI/2-.12]));for(let[t,n,r]of[[-.06,.03,1],[.07,-.05,.8],[.03,.08,.7]]){let i=e.mesh(new da(1,14,10),s,[t,.03,n]);i.scale.set(.055*r,.025*r,.045*r),p.add(i)}let m=e.mesh(new da(1,10,8),c,[-.02,.05,-.02]);m.scale.set(.03,.008,.016),p.add(m),p.position.set(-.34,.1,0),p.userData.dynamic=!0;let h=Rd(e);h.position.set(-.34,.108,0);let g=new Y;g.add(e.mesh(Al([[0,0],[.15,0],[.16,.02],[.16,.22],[.17,.23],[.15,.23],[.145,.02],[0,.02]],40),r,[0,0,0]),e.mesh(Al([[0,.25],[.06,.245],[.15,.225],[.165,.215],[0,.215]],40),r,[0,0,0]),e.mesh(new da(.024,14,10),a,[0,.262,0]));for(let t of[-1,1])g.add(e.mesh(new pa(.035,.009,8,20,Math.PI),a,[t*.17,.19,0],[0,t>0?0:Math.PI,Math.PI/2]));g.position.set(.36,.1,0),d.add(p,g,h);let _=new Y;_.userData.dynamic=!0;for(let t=0;te.register(new or({transparent:!0,opacity:.85,depthWrite:!1,blending:2,toneMapped:!1}),t,{flat:!0}),n=t(`--kitchen-flame`),r=t(`--kitchen-flame-core`),i=(e,t)=>{let n=new Yr(e,t,18,1,!0);return n.translate(0,t/2,0),n},a=new Y;a.name=`flame`;let o=[];for(let t=0;t{let s=e.mesh(new da(1,12,8),r,[t,n,i],[.3,o,.5]);s.scale.set(.036,.008,.016),a.add(s)}),a}function Hd(e,t,n){let r=e.physical(`--kitchen-steel`,{roughness:.22,metalness:1,map:t.brushed}),i=e.physical(`--room-brass`,{roughness:.24,metalness:.88,clearcoat:1,clearcoatRoughness:.06,envMapIntensity:1.5}),a=e.physical(`--prop-wood`,{roughness:.35,clearcoat:.7,clearcoatRoughness:.15,map:t.grain}),o=e.standard(`--prop-paper`,{roughness:.85,map:t.paper}),s=e.physical(`--prop-paper`,{roughness:.22,clearcoat:.9}),c=e.physical(`--kitchen-food`,{roughness:.45,clearcoat:.5}),l=e.physical(`--kitchen-soup`,{roughness:.2,clearcoat:.8}),u=e.standard(`--bot-leaf`,{roughness:.5}),d=new Y;d.add(e.box([.3,.016,.22,.006],r,[.42,.008,.3],[0,-.2,0])),[0,1,2].forEach(t=>d.add(e.box([.18,.004,.2,.002],o,[.42+t*.012,.02+t*.004,.3],[0,-.2+(t-1)*.1,0])));let f=new Y;f.add(e.mesh(Al([[0,0],[.112,0],[.12,.008],[.12,.022],[.112,.03],[0,.03]],40),a,[0,0,0]),e.mesh(Al([[0,.033],[.104,.033],[.106,.04],[.1,.06],[.088,.085],[.066,.11],[.036,.127],[0,.131]],48),i,[0,0,0]),e.mesh(new Jr(.008,.008,.032,12),i,[0,.145,0]),e.mesh(new da(.02,20,14),i,[0,.166,0])),f.position.set(-.42,0,Pd),f.userData.dynamic=!0,n.bell=f;let p=Vd(e,{ceramic:s,food:c,leaf:u,sauce:l});return p.position.set(.02,0,.36),p.userData.dynamic=!0,p.userData.home=p.position.x,n.pass=p,d.add(f,p),[d,e.blob(1.5,.7,0,0,.1)]}function Ud(e){let t=e.physical(`--prop-paper`,{roughness:.22,clearcoat:.9}),n=e.physical(`--kitchen-steel`,{roughness:.24,metalness:.85,clearcoat:1,clearcoatRoughness:.05,envMapIntensity:1.6}),r=e.physical(`--brand-soft`,{roughness:.85,sheen:.5}),i=e.physical(`--kitchen-food`,{roughness:.45,clearcoat:.5}),a=e.physical(`--kitchen-soup`,{roughness:.2,clearcoat:.8}),o=e.standard(`--bot-leaf`,{roughness:.5}),s=new Y,c=new Y;c.add(e.mesh(Al([[0,0],[.22,0],[.32,.02],[.33,.028],[.19,.016],[0,.016]],48),t,[0,0,0]),e.mesh(Al([[0,.025],[.255,.025],[.262,.031],[.258,.046],[.25,.1],[.21,.2],[.14,.27],[.06,.296],[0,.3]],64),n,[0,0,0]),e.mesh(new Jr(.009,.009,.03,12),n,[0,.312,0]),e.mesh(new da(.032,24,16),n,[0,.338,0])),c.position.set(-.44,0,Pd);let l=Vd(e,{ceramic:t,food:i,leaf:o,sauce:a});l.position.set(.08,0,.38),s.add(c,l);for(let n=0;n<4;n+=1)s.add(e.mesh(Al([[0,0],[.13,0],[.19,.016],[.19,.022],[0,.02]],40),t,[.56,n*.024,.22]));return s.add(e.box([.22,.03,.16,.01],r,[.42,.015,.48],[0,.4,0])),[s,e.blob(1.5,.7,0,0,Pd)]}var Wd={goal:Id,maker:Ld,verify:zd,review:Bd,judge:Hd,deliver:Ud};function Gd(e,{registry:t,textures:n}){let r=Fd(t,n,e),i={},a=new Y;a.name=`station_${e}`,a.userData.stage=e;let o=new Y;Wd[e](r,n,i).forEach(e=>o.add(e)),o.scale.setScalar(Md),o.position.set(0,dd,0),o.scale.z=Md*.82,a.add(o);let s=r.register(new Ta({roughness:.2,emissiveIntensity:1}),`--line-strong`,{lamp:!0}),c=r.physical(`--prop-metal`,{roughness:.25,metalness:1}),l=new Y;return l.add(r.mesh(new Jr(.075,.075,.02,32),c,[0,0,0],[Math.PI/2,0,0],{cast:!1}),r.mesh(new da(.052,24,16,0,Math.PI*2,0,Math.PI/2),s,[0,0,.008],[Math.PI/2,0,0],{cast:!1})),l.position.set(0,.24,.7100000000000001),l.userData.dynamic=!0,a.add(l),a.position.x=D(e),Fl(a),{group:a,dynamic:i,lamp:s,mood:O(e).mood}}function Kd(e,t,n){return[e.box([.05,.42,.05,.012],t,[n,2.42,-2.46]),e.box([.05,.05,.36,.012],t,[n,2.58,-2.3]),e.box([.04,.4,.04,.01],t,[n,2.42,-2.3],[.72,0,0])]}function qd(e,t,n){let{left:r,right:i,bottom:a,top:o}=Dd,s=13-i,c=(a+o)/2;return[e.box([26,a,.12,.02],t,[0,a/2,bd]),e.box([26,2.3-o,.12,.02],t,[0,(2.3+o)/2,bd]),e.box([s,o-a,.12,.02],t,[r-s/2,c,bd]),e.box([s,o-a,.12,.02],t,[i+s/2,c,bd]),e.box([i-r+.12,.05,.2,.01],n,[0,a,-2.48]),e.box([i-r+.12,.05,.16,.01],n,[0,o,-2.48]),e.box([.05,o-a,.16,.01],n,[r,c,-2.48]),e.box([.05,o-a,.16,.01],n,[i,c,-2.48])]}function Jd(e){let t=e.standard(`--backroom-floor`,{roughness:.35}),n=e.physical(`--backroom-tile`,{roughness:.2,clearcoat:.6}),r=e.physical(`--kitchen-steel`,{roughness:.28,metalness:.95}),i=e.physical(`--kitchen-iron`,{roughness:.4,metalness:.6}),a=new Y;a.name=`backroom`;let o=3.0999999999999996,s=new ca(15,o);s.rotateX(-Math.PI/2),a.add(e.mesh(s,t,[0,0,-8.1/2],[0,0,0],{cast:!1}),e.box([15,2.6,.1,.02],n,[0,1.3,Od]),e.box([.1,2.6,o,.02],n,[-7.4,1.3,-8.1/2]),e.box([.1,2.6,o,.02],n,[7.4,1.3,-8.1/2]),e.box([10,.82,.55,.01],r,[0,.41,-5.27]),e.box([10,.03,.6,.008],r,[0,.83,-5.27]),e.box([10,.03,.26,.008],r,[0,1.42,-5.4399999999999995]),e.box([.9,2.1,.7,.03],r,[-6.4,1.05,-5.18]),e.box([.02,1.6,.04,.01],i,[-6.02,1.15,-4.819999999999999]),e.box([.9,2.1,.7,.03],r,[6.4,1.05,-5.18]),e.box([.02,1.6,.04,.01],i,[6.02,1.15,-4.819999999999999]));let c=new fo(void 0,26,0,1.2);return c.position.set(0,2.3,-8.1/2),e.register(c,`--light-backroom`),a.add(c),a}function Yd(e,t){let n=e.physical(`--kitchen-floor`,{roughness:.5,clearcoat:.25,clearcoatRoughness:.35,map:t.checker}),r=e.physical(`--kitchen-floor-back`,{roughness:.55,map:t.tiles}),i=e.physical(`--kitchen-tile`,{roughness:.16,clearcoat:.8,clearcoatRoughness:.12,map:t.subway}),a=e.standard(`--kitchen-wall`,{roughness:.9,map:t.plaster}),o=e.physical(`--kitchen-counter`,{roughness:.48,clearcoat:.25,map:t.grain}),s=e.physical(`--room-marble`,{roughness:.16,clearcoat:.7,clearcoatRoughness:.12,map:t.marble}),c=e.physical(`--kitchen-steel`,{roughness:.3,metalness:.95,map:t.brushed}),l=e.physical(`--plinth-base`,{roughness:.4,clearcoat:.4}),u=e.standard(`--prop-wood`,{roughness:.45,map:t.grain}),d=e.physical(`--kitchen-iron`,{roughness:.38,metalness:.7,clearcoat:.3}),f=e.physical(`--kitchen-trim`,{roughness:.35,clearcoat:.6}),p=new Y,m=new ca(40,14);m.rotateX(-Math.PI/2);let h=new ca(40,4.4);h.rotateX(-Math.PI/2),p.add(e.mesh(m,n,[0,0,7.6],[0,0,0],{cast:!1}),e.mesh(h,r,[0,.001,-1],[0,0,0],{cast:!1}),...qd(e,i,c),e.box([26,4.2,.12,.02],a,[0,4.4,-2.51]),e.box([26,.06,.08,.02],f,[0,2.31,-2.44]),e.box([pd,.35,1.26,.03],o,[0,.235,0]),e.box([13.84,.05,1.4400000000000002,.02],s,[0,.425,0]),e.box([13.4,.06,1.2000000000000002,.01],l,[0,.03,0],[0,0,0],{cast:!1}),e.box([22,.56,.62,.02],c,[0,.56/2,Td]),e.box([22.1,.04,.68,.01],c,[0,.6,Td]),e.box([14.6,.06,.34,.015],u,[0,xd,-2.28]),e.blob(15.2,2.4,0,0,.1),e.blob(24,.9,0,0,-1.9),e.blob(22,.5,0,Ed,Td));for(let t=0;t<8;t+=1)p.add(e.box([.012,.42,.02,.004],d,[-7+t*2,.32,-1.76]));for(let t of[-6.4,-3.2,0,3.2,6.4])p.add(...Kd(e,d,t));let g=new Y,_=new Jr(.62,1.05,.7,4,1,!0);_.rotateY(Math.PI/4),g.add(e.mesh(_,c,[0,0,0]),e.box([1.52,.08,1,.02],c,[0,-.38,0]),e.box([.62,1.6,.5,.02],c,[0,1.15,-.12])),g.scale.set(1,1,.62),g.position.set(D(`maker`),3.3,-2),p.add(g);let v=new Y;v.add(e.box([1.3,.05,.56,.01],d,[0,.025,0]),e.mesh(Al([[0,0],[.14,0],[.15,.02],[.15,.2],[.16,.21],[.14,.21],[.135,.02],[0,.02]],32),c,[-.3,.05,0]),e.mesh(Al([[0,0],[.18,0],[.2,.05],[.18,.055],[0,.015]],32),d,[.32,.05,.02])),v.position.set(D(`maker`),Ed,Td),p.add(v);let y=[[D(`goal`),[[.18,.3,.14],[.16,.22,.12]]],[D(`verify`),[[.32,.05,.24],[.3,.05,.22]]],[D(`review`),[[.22,.34,.16]]],[D(`deliver`),[[.4,.04,.28],[.38,.04,.26],[.36,.04,.24]]]];for(let[t,n]of y){let r=Ed;n.forEach(([n,i,a],o)=>{p.add(e.box([n,i,a,.012],o%2?c:f,[t+.3,r+i/2,Td])),r+=i})}let b=[];for(let e=0;e<13;e+=1){let t=-7.2+e*1.12;Math.abs(t-D(`maker`))<1||b.push(t,t+.26)}let x=new kr(Al([[0,0],[.1,0],[.105,.02],[.105,.2],[.085,.23],[.07,.25],[.072,.29],[0,.29]],20),e.physical(`--prop-paper`,{roughness:.18,clearcoat:1}),b.length);x.userData.colors=[`--room-terracotta`,`--prop-box`,`--bot-leaf`,`--prop-paper`,`--prop-pencil`,`--kitchen-soup`,`--room-velvet`];let S=new Kt;for(let e=0;e{p.add(e.box([.2,.28,.008,.004],C,[t,1.79,-1.1199999999999999],[.05,0,(n-1)*.06]),e.box([.05,.04,.04,.01],c,[t,1.97,gd]))}),p}function Xd(e){let t=e.physical(`--kitchen-iron`,{roughness:.35,metalness:.5,clearcoat:.6}),n=e.register(new Ta({roughness:.6,emissiveIntensity:.9}),`--light-pendant`,{emissive:`--light-pendant`}),r=e.register(new or({toneMapped:!1}),`--light-pendant`,{flat:!0}),i=e.standard(`--kitchen-iron`,{roughness:.6}),a=new Y;a.name=`pendants`;for(let o of Sd)a.add(e.mesh(Al([[.04,.32],[.06,.3],[.12,.2],[.24,.04],[.26,0],[.25,0],[.23,.035],[.11,.19],[.05,.29],[.03,.31]],40),t,[o,Cd,wd],[0,0,0],{cast:!1}),e.mesh(Al([[0,.28],[.045,.27],[.1,.18],[.22,.035],[.235,.005]],32,{open:!0}),n,[o,Cd,wd],[0,0,0],{cast:!1}),e.mesh(new da(.06,16,12),r,[o,2.8000000000000003,wd],[0,0,0],{cast:!1}),e.mesh(new Jr(.008,.008,3,6),i,[o,4.5200000000000005,wd],[0,0,0],{cast:!1}));return a}function Zd(e,t){let n=e.physical(`--prop-paper`,{roughness:.85,sheen:.6,sheenRoughness:.5,map:t.fabric}),r=e.standard(`--prop-wood`,{roughness:.5,map:t.grain}),i=e.physical(`--prop-paper`,{roughness:.25,clearcoat:.8}),a=e.physical(`--prop-paper`,{roughness:.03,transparent:!0,opacity:.35,clearcoat:1,depthWrite:!1}),o=e.physical(`--brand`,{roughness:.4,clearcoat:.6}),s=e.standard(`--bot-leaf`,{roughness:.5}),c=new Y;c.name=`guest`,c.add(e.mesh(Al([[0,vd],[.6,vd],[.63,.42],[.64,.28],[.6,.28],[.59,.41000000000000003],[0,.41000000000000003]],64),n,[0,0,0]),e.mesh(Al([[0,0],[.24,0],[.24,.02],[.06,.05],[.04,.4],[0,.4]],32),r,[0,0,0]),e.mesh(Al([[0,0],[.13,0],[.19,.012],[.2,.018],[.12,.01],[0,.01]],40),i,[0,vd,.18]),e.mesh(Al([[0,0],[.035,0],[.035,.004],[.006,.01],[.006,.07],[.045,.1],[.05,.16],[.046,.16],[.04,.105],[0,.1]],28),a,[.24,vd,.08],[0,0,0],{cast:!1}),e.mesh(Al([[0,0],[.04,0],[.05,.05],[.03,.1],[.022,.13],[0,.13]],24),o,[-.22,vd,-.12]),e.mesh(new da(.045,16,12),s,[-.22,.6,-.12]));let l=new Y;return l.add(e.box([.42,.04,.4,.015],r,[0,.3,0]),e.box([.42,.42,.04,.015],r,[0,.52,.19]),...[[-.18,-.17],[.18,-.17],[-.18,.17],[.18,.17]].map(([t,n])=>e.box([.035,.3,.035,.01],r,[t,.15,n]))),l.position.set(0,0,.72),c.add(l,e.blob(1.7,1.9,0,0,.3)),c.scale.setScalar(Nd),c.position.set(h.x,0,h.z),Fl(c),c}function Qd(e){let t=e.physical(`--brand`,{roughness:.7,emissiveIntensity:.15},{emissive:`--brand`}),n=e.physical(`--prop-metal`,{roughness:.22,metalness:1}),r=new Y;return r.add(e.box([.24,.32,.01,.005],t,[0,_d,-1.115]),e.box([.06,.045,.045,.01],n,[0,1.97,gd])),r}function $d(e){let t=e.register(new Ta({roughness:.4,emissiveIntensity:.5}),`--brand`,{emissive:`--brand`}),n=D(`judge`),r=D(`maker`),i=new fi([new G(n,1.25,.45000000000000007),new G((n+r)/2,2,.75),new G(r,1.25,.45000000000000007)]),a=new kr(new Jr(.018,.018,.16,10),t,kd),o=new Kt,s=new G(0,1,0);for(let e=0;e{let r=Gd(e,{registry:t,textures:n});o[e]=r.group,s[e]=r.lamp,Object.assign(c,r.dynamic),i.add(r.group)});let l=Qd(r),u=$d(r);return i.add(a,Zd(r,n),l,u),{carrier:i,stations:o,lamps:s,ticket:l,arc:u,burners:c.burners||[],steam:c.steam||null,bell:c.bell||null,pan:c.pan||null,flame:c.flame||null,pass:c.pass||null,book:c.book||null}}var tf=1.05,nf=.6,rf={top:1.6,half:.9},af=.32,of=8,sf=.55,cf=.14,lf=.1,uf=1.5,df=1/40,ff=45,pf=8,mf=9,hf=7,gf=7,_f=.35,vf=.28,yf=.16,bf=1.8,xf=.85,Sf=.035,Cf=.09,wf=.9,Tf=1.4,Ef=.28,Df=1.6,Of=5;function kf(e,{tone:t,saturation:n}){if(n!==1){let t={};e.getHSL(t),e.setHSL(t.h,t.s*n,t.l)}return t!==1&&e.multiplyScalar(t),e}function Af(){let e={planks:Wl(`planks`,{repeat:.9}),marble:Wl(`marble`,{size:512,repeat:.3}),tiles:Wl(`tiles`,{repeat:1}),checker:Wl(`checker`,{size:512,repeat:1}),subway:Wl(`subway`,{size:512,repeat:.5}),brushed:Wl(`brushed`,{repeat:1.5}),grain:Wl(`grain`,{size:512,repeat:.6}),plaster:Wl(`plaster`,{repeat:.25}),paper:Wl(`paper`,{repeat:1}),panels:Wl(`panels`,{repeat:2}),fabric:Wl(`fabric`,{repeat:2}),blob:Gl(1.8)};return e.checker.repeat.set(10,3.5),e.tiles.repeat.set(20,2.2),e}function jf(e){let t=new Set,n=new Set;e.traverse(e=>{e.geometry&&t.add(e.geometry),e.material&&[].concat(e.material).forEach(e=>n.add(e))}),e.removeFromParent(),t.forEach(e=>e.dispose()),n.forEach(e=>e.dispose())}function Mf(e,t,n,r){let i=e+(t-e)*(1-Math.exp(-n/r));return Math.abs(i-t)<.002?t:i}function Nf(o,c,{root:d,reducedMotion:f=!1,onOpen:g=null,onBook:x=null,onCrew:S=null,diners:T=0}={}){let O=new Tl({antialias:!0,alpha:!0,powerPreference:`high-performance`}),A=Math.min(window.devicePixelRatio||1,uf);O.setPixelRatio(A),O.outputColorSpace=Ae,O.toneMapping=4,O.toneMappingExposure=1.05,O.shadowMap.enabled=!0,O.shadowMap.type=1,O.debug.checkShaderErrors=!1,o.appendChild(O.domElement);let ee=new en,j=new so(36,1,.1,80),M=new Ya(void 0,void 0,.6),N=new ho(void 0,2.2);N.position.set(-5.5,9,7),N.target.position.set(0,.4,-.4),N.castShadow=!0,N.shadow.mapSize.set(2048,2048),Object.assign(N.shadow.camera,{left:-10,right:10,top:7,bottom:-6,near:3,far:26}),N.shadow.camera.updateProjectionMatrix(),N.shadow.bias=-4e-4,N.shadow.normalBias=.02,N.shadow.radius=6,N.shadow.blurSamples=16;let te=new ho(void 0,.35);te.position.set(7,3,5);let P=new ho(void 0,1.1);P.position.set(3,6,-6);let ne=Sd.map(e=>{let t=new lo(void 0,hf,0,.62,1,1.6);return t.position.set(e,Cd,wd),t.target.position.set(e,dd,wd+.2),t}),re=new lo(void 0,0,0,.42,.8,2);re.position.set(0,3.4,1.6);let ie=new fo(void 0,0,3.2,2);ie.position.set(D(`maker`)-.5,dd+.35,.34);let ae=new lo(void 0,0,0,.32,.7,2);ae.position.set(D(`review`),3.1,.9),ae.target.position.set(D(`review`),.45,.04),ee.add(M,N,N.target,te,P,re,re.target,ae,ae.target,ie),ne.forEach(e=>ee.add(e,e.target));let oe=Af(),se=new Y;ee.add(se);let F=El,ce=null,I=Ju({reducedMotion:f,size:tf,read:F});se.add(I.root);let le=[],ue=document.createElement(`p`);ue.className=`crew-tip`,ue.hidden=!0,d.appendChild(ue);let de=null,fe=y(...w),pe=new jo,me=new W,he=new G,L=null,ge=null,_e=1,ve=1,ye=0,be=0,xe=0,Se=null,Ce=null,we=null,Te=0,Ee=0,De=0,Oe=null,ke=[],je=0,Me=0,Ne=null,R=-1,Pe=-1,z=null,B=null,Fe=window.matchMedia(`(max-width: 600px)`),Ie=``,Le=[],Re=new WeakMap,ze=typeof ResizeObserver==`function`?new ResizeObserver(e=>{for(let t of e){let e=t.borderBoxSize&&t.borderBoxSize[0];Re.set(t.target,e?{w:e.inlineSize,h:e.blockSize}:{w:t.target.offsetWidth,h:t.target.offsetHeight})}mt()}):null;function V(e){let t=Re.get(e);return t||(t={w:e.offsetWidth,h:e.offsetHeight},Re.set(e,t),ze&&ze.observe(e)),t}function H(e){return Object.fromEntries(e.stages.map(e=>[e.stage,e.status]))}function Be(e){let t=[],r=ef({registry:t,textures:oe}),i=rd({registry:t,textures:oe,count:T});r.carrier.add(i.group),id(i.figures,0,{reducedMotion:!0});let a=n(e);return r.ticket.position.x=a.x,r.arc.visible=!!k(e),{...r,figures:i.figures,registry:t,statuses:H(e),botStage:a.stage,botX:a.x,ticketX:a.x,ticketTo:a.x,model:e}}function Ve(e,t){let r=n(t);e.statuses=H(t),e.model=t,e.arc.visible=!!k(t),e.botStage=r.stage,e.botX=r.x,e.ticketX=r.x,e.ticketTo=r.x,e.ticket.position.x=r.x,We(e)}let He=ud(se,{build:Be,dispose:e=>jf(e.carrier)});function Ue(){L=He.current,ge=He.outgoing}function We(e){for(let n of e.registry){let r=n.stage?e.statuses[n.stage]:null,i=t(r),a=n.material;if(n.lamp){let e=F(i.lamp);a.color.setStyle(e),a.emissive.setStyle(e),a.emissiveIntensity=E(r,Ee,{reducedMotion:f})*1.6,i.glow||a.color.multiplyScalar(.7);continue}let o=F(n.token);o&&(a.color.setStyle(o),n.emissive&&a.emissive.setStyle(F(n.emissive)),n.burner&&a.emissive.setStyle(F(`--kitchen-flame`)),n.sheen&&a.sheenColor&&a.sheenColor.setStyle(F(n.sheen)),n.stage&&!n.flat&&kf(a.color,i),n.stage===`review`&&!n.flat&&(a.color.multiplyScalar(sf),a.envMapIntensity=sf))}e.carrier.traverse(e=>{if(!e.isInstancedMesh||!e.userData.colors)return;let t=new X;for(let n=0;ne.color.setStyle(F(`--light-pendant`))),O.toneMappingExposure=Number(F(`--kitchen-exposure`))||1,M.intensity=Number(F(`--kitchen-ambient`))||.6,ae.color.setStyle(F(`--bot-devil-eye`)),ie.color.setStyle(F(`--kitchen-flame`)),ce&&ce.dispose(),ce=ql(O,F),ee.environment=ce.texture,ee.environmentIntensity=.7,I.paint(F),le.forEach(e=>{e.bot.paint(F),e.station.paint(F)}),L&&We(L),ge&&We(ge)}function Ke(){return L?L.carrier.position:he.set(0,0,0)}function qe(){let e=L?L.carrier.scale.x:1,t=hd*e+(L?L.carrier.position.y:0);return{bottom:t,top:t+rf.top*tf*e,half:rf.half*tf*e,z:md}}function U(e){let t=L?u(L.botX):0;return z=z===null||f||!Fe.matches?t:Mf(z,t,e,af),z!==t}function Je(){let e=L?L.botX+L.carrier.position.x:0,t=Fe.matches,n=b(xe,_e/ve,e,{compact:t,restX:z===null?e:z,bot:qe()});j.position.set(...n.position),j.fov=n.fov,j.aspect=_e/ve,j.updateProjectionMatrix(),j.lookAt(...n.target)}function Ye(e){return he.copy(e).project(j),l(he,_e,ve)}function Xe(e,t,{anchor:n=`top`,gap:r=0}={}){if(!e)return;let i=Ye(t),{w:a,h:o}=V(e);if(n===`side`){e.style.transform=`translate(${(i.x+r).toFixed(1)}px, ${(i.y-o/2).toFixed(1)}px)`;return}let s=n===`top`?i.y+r:i.y-o-r;e.style.transform=`translate(${(i.x-a/2).toFixed(1)}px, ${s.toFixed(1)}px)`}function Ze(e){let t=d.querySelectorAll(`.stage[data-stage]`);if(!e)return B=null,!1;t.forEach(e=>e.style.removeProperty(`transform`));let n=d.querySelector(`.stages`),r=d.querySelector(`.stage.now`)||d.querySelector(`.stage[data-stage="${L.botStage}"]`);return n&&r&&B!==r.dataset.stage&&(B=r.dataset.stage,n.scrollLeft=Math.max(0,r.offsetLeft-(n.clientWidth-r.offsetWidth)/2)),!0}function Qe(e,t){let n=d.querySelector(`.guest`);if(!n)return;if(!e){Xe(n,new G(h.x+xf+t.x,yd+t.y,h.z+t.z),{anchor:`side`,gap:14});return}n.style.removeProperty(`transform`);let r=`${V(n).h}px`;r!==Ie&&(Ie=r,d.style.setProperty(`--guest-h`,r))}function K(e,t){let n=d.querySelector(`.bot-bubble`);if(!n||n.hidden)return null;let{w:r,h:i}=V(n);if(!r)return null;let a=C({x:e.x+t*.2,y:e.y-(i||28)-4,w:r,h:i},{width:_e,height:ve},of);return n.style.transform=`translate(${a.x.toFixed(1)}px, ${a.y.toFixed(1)}px)`,a}function $e(e,t){let n=d.querySelector(`.kitchen-ticket`);if(!n)return;let r=Ye(new G(L.ticketX+e.x,_d+.2+e.y,gd+e.z)),{w:i,h:a}=V(n),o=v({x:r.x-i/2,y:r.y-a-4,w:i,h:a},t,{width:_e,height:ve},{pad:of});n.style.transform=`translate(${o.x.toFixed(1)}px, ${o.y.toFixed(1)}px)`,n.style.visibility=o.hidden?`hidden`:``}function q(){if(!L)return;let e=L.carrier.position,t=Fe.matches;Ze(t)||d.querySelectorAll(`.stage[data-stage]`).forEach(t=>{Xe(t,new G(D(t.dataset.stage)+e.x,.12+e.y,fd+.02+e.z),{gap:pf})}),L.arc.visible&&Xe(d.querySelector(`.kitchen-return`),L.arc.userData.apex.clone().add(e),{anchor:`bottom`,gap:10}),Qe(t,e);let n=d.querySelector(`.ring-bot`);if(!n){$e(e,null);return}I.root.getWorldPosition(he);let r=he.clone(),i=Ye(r.clone().setY(r.y+I.height*.55)),a=Ye(r.clone().setY(r.y+I.height)),o=Math.max(44,(i.y-a.y)*2.4);n.style.width=`${o.toFixed(1)}px`,n.style.height=`${o.toFixed(1)}px`,n.style.transform=`translate(${(i.x-o/2).toFixed(1)}px, ${(i.y-o/2).toFixed(1)}px)`,$e(e,K(a,o))}function et(e=0){let t=Ke(),n=L?L.carrier.scale.x:1,r=L?L.botX:0;I.root.position.set(t.x+r*n,t.y+(hd+e)*n,t.z+md*n),I.root.scale.setScalar(tf*n),I.root.rotation.y=je}function tt(e,t){return e.start===null&&(e.start=t),Math.min(1,(t-e.start)/e.duration)}function nt(e,t){let n=Ce?Math.sign(Ce.to-Ce.from)*Math.PI/2:0;if(je=f?0:Mf(je,n,t,yf),!Ce||!L)return et(0),je!==0;let r=tt(Ce,e),i=fe(r),a=p(r,Ce.hops);return L.botX=Ce.from+(Ce.to-Ce.from)*i,et(a*cf),I.stride(a,r<1),r>=1&&(Ce=null,I.stride(0,!1),et(0)),!0}function rt(e){return L?(L.ticketX=f?L.ticketTo:Mf(L.ticketX,L.ticketTo,e,vf),L.ticket.position.x=L.ticketX,L.ticketX!==L.ticketTo):!1}function it(e){if(!Se)return!1;let t=tt(Se,e);if(xe=Se.from+(Se.to-Se.from)*fe(t),t>=1){let e=Se.resolve;return Se=null,e(),!1}return!0}function at(){if(!we)return;let e=we.resolve;we=null,He.finish(),Ue(),L.carrier.position.set(0,0,0),L.carrier.scale.setScalar(1),et(0),e()}function ot(e){if(!we)return!1;let t=tt(we,e),n=r(we.direction,fe(t));return ge&&(ge.carrier.position.set(n.outX,n.outY,0),ge.carrier.scale.setScalar(n.outScale)),L.carrier.position.set(n.inX,n.inY,0),L.carrier.scale.setScalar(n.inScale),et(0),t>=1?(at(),!1):!0}function st(t){if(!L)return!1;Ee+=t;let n=L.statuses,r=e.find(e=>n[e]===`now`),i=!1;if(r&&!f){let e=L.lamps[r];e.emissiveIntensity=E(`now`,Ee)*1.6,i=!0}L.figures.length&&!f&&L.model.mode!==`settled`&&(id(L.figures,Ee,{bot:{x:L.botX,z:md}}),i=!0);let a=n.maker===`now`;if(L.burners.forEach(e=>{e.material.emissiveIntensity=a?1.1:0}),L.steam&&(L.steam.children.forEach((e,t)=>{if(!a||f){e.scale.setScalar(a?.8:.001),e.position.y=.4;return}let n=(Ee/bf+t/L.steam.children.length)%1;e.position.y=.36+n*.62,e.position.x=.36+Math.sin((n+t)*Math.PI*2)*.05*(.4+n),e.scale.setScalar(Math.max(.001,Math.sin(Math.PI*n)*(.7+n*.9)))}),i||=a&&!f),ct(a),L.pan&&(L.pan.visible=L.model.mode!==`working`||L.model.botStage!==`maker`),L.pass&&Pe>=0){let e=Ee-Pe,t=L.pass.userData.home;if(e>=Tf)Pe=-1,L.pass.position.x=t;else{let n=Math.min(1,e/(Tf*.4)),r=Math.max(0,(e-Tf*.55)/(Tf*.45));L.pass.position.x=t-Ef*Math.sin(n*Math.PI/2)*(1-r*r*(3-2*r)),i=!0}}if(e.forEach(e=>{let n=L.stations[e],r=Ne===e?Sf:0,a=f?r:Mf(n.position.y,r,t,Cf);n.position.y=Math.abs(a-r)<5e-4?r:a,n.position.y!==r&&(i=!0)}),L.bell&&R>=0){let e=Ee-R;if(e>=wf)R=-1,L.bell.rotation.z=0,L.bell.scale.setScalar(1);else{let t=1-e/wf;L.bell.rotation.z=Math.sin(e*38)*.22*t*t,L.bell.scale.setScalar(1+Math.max(0,.08-e*.4)),i=!0}}let o=n[L.botStage]===`now`?mf:0;Te=f?o:Mf(Te,o,t,_f),re.intensity=Te;let s=L.botX+L.carrier.position.x;re.position.x=s,re.target.position.set(s,dd,md);let c=n.review!==`skipped`;return ae.intensity=c?gf*(n.review===`now`?1.6:1):0,ae.position.x=D(`review`)+L.carrier.position.x,ae.target.position.x=ae.position.x,i||Te!==o}function ct(e){let t=L.flame;if(!t)return;if(t.visible=e,ie.position.x=D(`maker`)-.5+L.carrier.position.x,!e){ie.intensity=0;return}let n=f?0:m(I.cookPhase());t.userData.tongues.forEach(e=>{let t=f?0:Math.sin(Ee*17+e.userData.phase)*.12+Math.sin(Ee*29+e.userData.phase*2)*.08;e.scale.set(1+n*.5,.55+n*2.1+t,1+n*.5)});let r=f?0:Math.sin(Ee*23)*.18+Math.sin(Ee*41)*.1;t.userData.materials.forEach(e=>{e.opacity=Math.min(1,.45+n*.35+r*.2)}),ie.intensity=Df*(1+r)+Of*n}function lt(){if(!L)return;let e=L.carrier.position,t=L.carrier.scale.x,n=_(le.map(e=>e.stage));le.forEach((r,i)=>{let a=e.x+n[i].x*t,o=e.z+od.z*t;r.bot.root.position.set(a,e.y+od.top*t,o-.06*t),r.station.group.position.set(a,e.y,o),r.station.group.scale.setScalar(t),r.bot.root.scale.setScalar(tf*nf*t)}),de&&!ue.hidden&&(de.bot.root.getWorldPosition(he),he.y+=de.bot.height*t*1.45,Xe(ue,he,{anchor:`bottom`,gap:6}))}function ut(){Je(),lt(),q(),Ft(),O.render(ee,j)}function dt(e){ye=0;let t=be?Math.min((e-be)/1e3,lf):1/60;be&&ft(t),be=e;let n=ot(e),r=it(e),i=nt(e,t),a=rt(t),o=U(t),s=I.step(t),c=le.reduce((e,n)=>n.bot.step(t)||e,!1),l=st(t);ut(),n||r||i||a||o||s||c||l?mt():(be=0,pt())}function ft(e){if(A<=1||(Le.push(e),Le.lengthe+t,0)/Le.length;Le.length=0,t<=df||(A=1,O.setPixelRatio(A),O.setSize(_e,ve))}function pt(){window.clearTimeout(Me);let e=Math.min(I.wakeIn(),...le.map(e=>e.bot.wakeIn()));Number.isFinite(e)&&!document.hidden&&(Me=window.setTimeout(mt,e*1e3+16))}function mt(){ye||document.hidden||(ye=requestAnimationFrame(dt))}function ht(){window.clearTimeout(Me),ye&&cancelAnimationFrame(ye),ye=0,be=0}function gt(){_e=o.clientWidth||1,ve=o.clientHeight||1,O.setSize(_e,ve),ut(),mt()}function _t(e){return Oe=e,new Promise(e=>{ke.push(e),o.dataset.cut!==`out`&&(window.clearTimeout(De),o.dataset.cut=`out`,De=window.setTimeout(()=>{let e=Oe;Oe=null,e&&e(),ut(),o.dataset.cut=`in`,ke.splice(0).forEach(e=>e()),De=window.setTimeout(()=>delete o.dataset.cut,160)},160))})}function vt(e){let t=n(e);L.botStage=t.stage,L.ticketTo=t.x;let r=i(L.botX,t.x,{reducedMotion:f});(r.steps||r.fade)&&(r.fade?(Ce=null,_t(()=>{L.botX=t.x,et(0)})):Ce={start:null,duration:r.ms,from:L.botX,to:t.x,hops:r.hops})}function yt(e,t){at(),Ce=null;let n=ld(t,{reducedMotion:f,mounted:!!L});return n===`mount`?(He.mount(e),Ue(),We(L),et(0),Promise.resolve()):n===`reuse`?_t(()=>{Ve(L,e),et(0)}):(He.slide(e),Ue(),We(L),I.react()&&mt(),new Promise(e=>{we={start:null,duration:780,direction:t,resolve:e},ot(performance.now()),mt()}))}function J(){document.hidden?ht():mt()}function bt(){z=null,B=null,d.querySelectorAll(`.stage[data-stage], .guest`).forEach(e=>e.style.removeProperty(`transform`)),ut(),mt()}function xt(){Ge(),ut(),mt()}let St=window.matchMedia(`(prefers-color-scheme: dark)`),Ct=window.matchMedia(`(hover: hover) and (pointer: fine)`).matches&&!f;function wt(e){let t=o.getBoundingClientRect();me.set((e.clientX-t.left)/t.width*2-1,-((e.clientY-t.top)/t.height)*2+1),pe.setFromCamera(me,j)}function Tt(e){return!L||xe>.01?!1:(wt(e),pe.intersectObjects([L.stations[L.botStage],I.root],!0).length>0)}function Et(t){if(!L||xe>.01)return null;wt(t);let n=pe.intersectObjects(e.map(e=>L.stations[e]),!0)[0],r=n&&n.object;for(;r&&!r.userData.stage;)r=r.parent;return r?r.userData.stage:null}function Dt(e){if(!le.length||!L||xe>.01)return null;wt(e);let t=pe.intersectObjects(le.map(e=>e.bot.root),!0)[0];return t&&le.find(e=>{let n=t.object;for(;n&&n!==e.bot.root;)n=n.parent;return!!n})||null}function Ot(e){return!L||!L.book||xe>.01?!1:(wt(e),pe.intersectObject(L.book,!0).length>0)}function kt(e){e!==de&&(de=e,ue.hidden=!e,e&&(ue.textContent=e.label))}function At(e){e!==Ne&&(Ne=e,d.querySelectorAll(`.stage[data-stage]`).forEach(e=>{e.dataset.stage===Ne?e.dataset.hover=`true`:delete e.dataset.hover}))}function jt(e){if(Ct){I.root.getWorldPosition(he),he.y+=I.height*.5;let t=Ye(he),n=o.getBoundingClientRect(),r=e.clientX-n.left-t.x,i=e.clientY-n.top-t.y,a=Math.hypot(r,i)||1,s=Math.min(1,a/160);I.lookAt(r/a*s,-i/a*s)}Ct&&At(Et(e));let t=Dt(e);kt(t),t||Ot(e)||Tt(e)?o.dataset.hover=`room`:delete o.dataset.hover,mt()}function Mt(){I.lookAt(0,0),At(null),kt(null),delete o.dataset.hover,mt()}function Nt(e){let t=Dt(e);t?S&&S(t.id):x&&Ot(e)?x():g&&Tt(e)&&g()}function Pt(e){let t=(Array.isArray(e)?e:[]).slice(0,5);for(let e=le.length-1;e>=0;--e){if(t.some(t=>t.id===le[e].id))continue;let[n]=le.splice(e,1);n===de&&kt(null),n.bot.root.removeFromParent(),n.bot.dispose(),n.station.dispose()}t.forEach((e,t)=>{let r=le.find(t=>t.id===e.id);if(!r){let n=Ju({reducedMotion:f,size:tf*nf,read:F});n.paint(F),se.add(n.root),r={id:e.id,bot:n},le.splice(t,0,r)}r.label=e.label;let i=n(e.model).stage;r.station&&r.stage===i||(r.station&&r.station.dispose(),r.station=cd(i),r.station.paint(F),se.add(r.station.group)),r.stage=i,r.bot.update(e.model)}),le.sort((e,n)=>t.findIndex(t=>t.id===e.id)-t.findIndex(e=>e.id===n.id)),de&&(ue.textContent=de.label),Ft()}function Ft(){let e=L?a(L.botStage,le.map(e=>e.stage)):{};d.querySelectorAll(`.stage[data-stage]`).forEach(t=>{let n=e[t.dataset.stage]||0;n>1?t.dataset.crowd=String(n):delete t.dataset.crowd})}let It=new ResizeObserver(gt);return It.observe(o),document.addEventListener(`visibilitychange`,J),St.addEventListener(`change`,xt),Fe.addEventListener(`change`,bt),o.addEventListener(`pointermove`,jt),o.addEventListener(`pointerleave`,Mt),o.addEventListener(`click`,Nt),He.mount(c),Ue(),Ge(),I.update(c),et(0),_e=o.clientWidth||1,ve=o.clientHeight||1,O.setSize(_e,ve),ut(),mt(),{update(e,{swap:t=!1,direction:r=0}={}){let i=Promise.resolve();if(t)i=yt(e,r);else if(L){let t=L.statuses;L.statuses=H(e);let r=f?null:s(t,L.statuses);r===`pass`&&(R=Ee),r===`iterate`&&(Pe=Ee),L.model=e,L.arc.visible=!!k(e),We(L),n(e).stage!==L.botStage&&vt(e)}return I.update(e),ut(),mt(),i},react(){I.react()&&mt()},setCrew(e){Pt(e),ut(),mt()},zoom(e){let t=+(e===`in`);return Se&&Se.resolve(),Se=null,f?(xe=t,ut(),Promise.resolve()):new Promise(n=>{Se={start:null,duration:e===`in`?750:600,from:xe,to:t,resolve:n},mt()})},dispose(){ht(),At(null),window.clearTimeout(De),at(),Se&&Se.resolve(),It.disconnect(),ze&&ze.disconnect(),document.removeEventListener(`visibilitychange`,J),St.removeEventListener(`change`,xt),Fe.removeEventListener(`change`,bt),d.style.removeProperty(`--guest-h`),o.removeEventListener(`pointermove`,jt),o.removeEventListener(`pointerleave`,Mt),o.removeEventListener(`click`,Nt),delete o.dataset.hover,delete o.dataset.cut,d.querySelectorAll(`.stage[data-stage], .ring-bot, .ring-centre, .bot-bubble, .kitchen-ticket, .kitchen-return, .guest`).forEach(e=>e.removeAttribute(`style`)),ke.splice(0).forEach(e=>e()),I.dispose(),le.splice(0).forEach(e=>{e.bot.dispose(),e.station.dispose()}),ue.remove(),He.dispose(),Object.values(oe).forEach(e=>e.dispose()),ce&&ce.dispose(),N.shadow.map?.dispose(),re.shadow.map?.dispose(),ne.forEach(e=>e.dispose()),ie.dispose(),ae.shadow.map?.dispose(),O.dispose(),O.forceContextLoss(),O.domElement.remove()}}}export{Nf as mountKitchen}; \ No newline at end of file diff --git a/studio/app/index.html b/studio/app/index.html new file mode 100644 index 0000000..a5ba2d5 --- /dev/null +++ b/studio/app/index.html @@ -0,0 +1,12 @@ + + + + + + + AEL Studio + + + + + diff --git a/studio/app/licenses/svelte.LICENSE b/studio/app/licenses/svelte.LICENSE new file mode 100644 index 0000000..f872adf --- /dev/null +++ b/studio/app/licenses/svelte.LICENSE @@ -0,0 +1,7 @@ +Copyright (c) 2016-2025 [Svelte Contributors](https://github.com/sveltejs/svelte/graphs/contributors) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/studio/app/licenses/three.LICENSE b/studio/app/licenses/three.LICENSE new file mode 100644 index 0000000..8ada2a5 --- /dev/null +++ b/studio/app/licenses/three.LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright © 2010-2026 three.js authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/studio/index.html b/studio/index.html deleted file mode 100644 index 9c22c40..0000000 --- a/studio/index.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - AEL Studio - - - - - -
                -
                - -

                AEL Studio

                -
                - -
                  -

                  Connecting…

                  - -
                  -
                  - -
                  -

                  Pick a project to see its Run.

                  - -
                  -

                  - - - -
                  -
                  - - - - - diff --git a/studio/js/detail.js b/studio/js/detail.js index da08fbf..625389e 100644 --- a/studio/js/detail.js +++ b/studio/js/detail.js @@ -1,9 +1,8 @@ -import { escapeHtml, formatElapsed, stageLabel, waitingLabel } from './list.js'; -import { renderMarkdown } from './markdown.js'; -import { ringActivity, ringEyebrow, ringModel } from './ring2d.js'; +import { formatElapsed, stageLabel, waitingLabel } from './list.js'; +import { ringModel } from './ring2d.js'; export const GOAL_VIEWS = ['formatted', 'markdown']; -const GOAL_VIEW_LABELS = { formatted: 'Formatted', markdown: 'Markdown' }; +export const GOAL_VIEW_LABELS = { formatted: 'Formatted', markdown: 'Markdown' }; const KITCHEN_ASK = { freeze: 'Confirm the order?', @@ -25,10 +24,6 @@ export const SKETCH_LABEL = 'Look at the order sketch'; export const SKETCH_VIEWS = { state: 'State', storyboard: 'Storyboard', lanes: 'Lanes' }; export const REVISE_HINT = 'To change the Goal, answer Revise in your agent host.'; -export function sketchButton(attributes = '') { - return ``; -} - export function sketchCounts(counts) { if (!counts) return ''; const part = (n, one, many) => `${Number(n) || 0} ${Number(n) === 1 ? one : many}`; @@ -45,134 +40,38 @@ export function recommendedView(detail) { return pick ? pick.view : null; } -export function sketchTab(option, selected) { - const on = option.view === selected; - const note = option.recommended ? ' Recommended' : ''; - return ``; -} - -export function sketchFrame(view, url) { - return ``; +export function sketchFrameTitle(view) { + return `${SKETCH_VIEWS[view]} sketch of the Goal`; } -export function renderSketchFoot(actor = null) { - const freeze = actor - ? `` - : ''; - return `

                  ${REVISE_HINT}

                  ${freeze}`; +export function waitsForFreeze(summary) { + return Boolean(summary && summary.waiting && summary.waiting.kind === 'freeze'); } -export function renderSketch(detail, { view = null, actor = null } = {}) { - const options = sketchOptions(detail); - if (!options.length) return '

                  There is no order sketch for this Goal.

                  '; - const selected = options.some((option) => option.view === view) ? view : recommendedView(detail); - return `

                  ${escapeHtml(sketchCounts(detail.flowCounts))}

                  ` - + `
                  ${options.map((option) => sketchTab(option, selected)).join('')}
                  ` - + `
                  ` - + '
                  ' - + `
                  ${renderSketchFoot(actor)}
                  `; +export function waitAsk(waiting) { + return waiting ? KITCHEN_ASK[waiting.kind] || waitingLabel(waiting) : ''; } -export function renderFreezeButton(summary, actor) { - if (!summary || !summary.waiting || summary.waiting.kind !== 'freeze') return ''; - if (!actor) { - return '
                  ' - + '' - + '' - + '' - + '
                  '; - } - return ``; +export function waitText(waiting) { + return waiting ? WAITING_TEXT[waiting.kind] || '' : ''; } -function startedText(elapsedMs) { +export function startedText(elapsedMs) { const elapsed = formatElapsed(elapsedMs); return elapsed === 'just now' ? 'Ordered just now' : `Ordered ${elapsed} ago`; } -export function renderRunHead(summary, { actor = null, projectName = '' } = {}) { - if (!summary) return ''; - const title = summary.task || summary.runId; - const wait = summary.waiting - ? `
                  ${escapeHtml(KITCHEN_ASK[summary.waiting.kind] || waitingLabel(summary.waiting))}` - + `${escapeHtml(WAITING_TEXT[summary.waiting.kind] || '')}` - + `${renderFreezeButton(summary, actor)}${summary.waiting.kind === 'freeze' && summary.waiting.sketch ? sketchButton() : ''}
                  ` - : ''; - return `

                  ${escapeHtml(ringEyebrow(summary, projectName))}

                  ` - + `

                  ${escapeHtml(title)}

                  ` - + `

                  ${escapeHtml(startedText(summary.elapsedMs))}

                  ${wait}`; -} - -function goalTab(view, selected) { - return ``; -} - -function goalSection(markdown, goalView) { - if (!markdown) { - return '

                  Goal

                  No Goal draft yet.

                  '; - } - const view = GOAL_VIEWS.includes(goalView) ? goalView : 'formatted'; - const hidden = (name) => (name === view ? '' : ' hidden'); - return '
                  ' - + '

                  Goal

                  ' - + `
                  ${GOAL_VIEWS.map((name) => goalTab(name, name === view)).join('')}
                  ` - + `
                  ${renderMarkdown(markdown)}
                  ` - + `
                  ${escapeHtml(markdown)}
                  ` - + '
                  '; -} - -function findingsText(findings) { +export function findingsText(findings) { if (!findings) return 'No review yet'; return `${plural(findings.total, 'finding')}, ${findings.blocking} blocking`; } -function prText(pr) { - if (!pr) return 'No branch yet'; - const link = pr.url && /^https?:\/\//i.test(pr.url) - ? ` open` - : ''; - return `${escapeHtml(pr.branch || 'unknown branch')} · ${pr.merged ? 'merged' : 'not merged'}${link}`; -} - -function listOrNone(items) { - if (!items || !items.length) return '

                  None

                  '; - return `
                    ${items.map((item) => `
                  • ${escapeHtml(item)}
                  • `).join('')}
                  `; -} - -export function renderDetail(detail, { goalView = 'formatted' } = {}) { - if (!detail) return ''; - const facts = '
                  ' - + `
                  Findings
                  ${escapeHtml(findingsText(detail.findings))}
                  ` - + `
                  Pull request
                  ${prText(detail.pr)}
                  ` - + `
                  Receipt
                  ${detail.receipt === 'written' ? 'Receipt written' : 'No receipt yet'}
                  ` - + '
                  '; - const extra = detail.extraNodes && detail.extraNodes.length - ? `

                  Other steps

                  ${listOrNone(detail.extraNodes)}
                  ` - : ''; - return facts - + goalSection(detail.goalMarkdown, goalView) - + `

                  Unconfirmed assumptions

                  ${listOrNone(detail.unconfirmed)}
                  ` - + extra; +export function safeLink(url) { + return typeof url === 'string' && /^https?:\/\//i.test(url) ? url : null; } -export function renderRoomCard(summary, { findings = null, projectName = '', actor = null } = {}) { - if (!summary) return ''; - const model = ringModel(summary.ring, summary); - const activity = ringActivity(summary, findings); - const iteration = `Iteration ${Number(summary.iteration) || 1} of ${Number(summary.maxIterations) || 1}`; - const facts = [stageLabel(model.botStage), summary.tier, iteration].filter(Boolean) - .map((fact) => `${escapeHtml(fact)}`).join(''); - let wait = ''; - if (summary.waiting) { - const action = summary.waiting.kind !== 'freeze' - ? '' - : actor - ? `` - : ''; - wait = `
                  ${escapeHtml(waitingLabel(summary.waiting))}${action}
                  `; - } - return `

                  ${escapeHtml(projectName)}

                  ` - + `

                  ${escapeHtml(summary.task || summary.runId)}

                  ` - + `

                  ${escapeHtml(activity.title)} · ${escapeHtml(activity.note)}

                  ` - + `
                  ${facts}
                  ${wait}`; +export function roomFacts(summary) { + const model = ringModel(summary && summary.ring, summary || {}); + const iteration = `Iteration ${Number(summary && summary.iteration) || 1} of ${Number(summary && summary.maxIterations) || 1}`; + return [stageLabel(model.botStage), summary && summary.tier, iteration].filter(Boolean); } diff --git a/studio/js/list.js b/studio/js/list.js index 25861ae..d764499 100644 --- a/studio/js/list.js +++ b/studio/js/list.js @@ -55,19 +55,14 @@ export function sortProjects(projects) { return [...(projects || [])].sort((a, b) => rank(a) - rank(b) || String(a.name).localeCompare(String(b.name))); } -function freezeWait(run) { +export function freezeWait(run) { return Boolean(run && run.waiting && run.waiting.kind === 'freeze'); } -function nameSuffix(run) { - return freezeWait(run) ? ` · ${WAITING_LABELS.freeze}` : ''; -} - -function runMeta(run) { +export function runMeta(run) { if (!run) return ''; const waiting = freezeWait(run) ? '' : waitingLabel(run.waiting); - const parts = [waiting || stageLabel(run.stage), run.tier, formatElapsed(run.elapsedMs)].filter(Boolean); - return parts.map(escapeHtml).join(' · '); + return [waiting || stageLabel(run.stage), run.tier, formatElapsed(run.elapsedMs)].filter(Boolean).join(' · '); } export const FINISHED_RUN_STATES = new Set(['REPORTED', 'DELIVERED', 'CANCELLED', 'ESCALATED']); @@ -77,68 +72,37 @@ export function worktreeState(run) { return FINISHED_RUN_STATES.has(run.state) ? 'idle' : 'working'; } -function listSketchButton(targetId, run, targetName) { - if (!freezeWait(run) || !run.waiting.sketch) return ''; - return ``; +export function projectState(project) { + return Object.hasOwn(STATE_ORDER, project && project.state) ? project.state : 'idle'; +} + +export function stateLabel(state) { + return STATE_LABELS[state] || STATE_LABELS.idle; } -function listFreezeButton(targetId, run, actor, targetName) { - if (!freezeWait(run)) return ''; - const label = actor ? `Freeze as ${escapeHtml(actor)}` : 'Freeze…'; - const accessibleName = actor ? `Freeze ${targetName} as ${actor}` : `Freeze ${targetName}`; - return ``; +export function projectMeta(project) { + if (project.run) return runMeta(project.run); + return projectState(project) === 'missing' ? STATE_LABELS.missing : 'No active Run'; } -function worktreeRow(run, selectedId, actor) { - const selected = run.worktreeId === selectedId; - const state = worktreeState(run); - return `
                • ` - + `` - + listFreezeButton(run.worktreeId, run, actor, run.task || run.runId) - + listSketchButton(run.worktreeId, run, run.task || run.runId) - + '
                • '; +export function worktreeRows(project) { + return (project.worktreeRuns || []).filter((run) => run.worktreeId); } -function projectRow(project, selectedId, actor) { - const selected = project.id === selectedId; - const state = Object.hasOwn(STATE_ORDER, project.state) ? project.state : 'idle'; - const meta = project.run ? runMeta(project.run) : escapeHtml(state === 'missing' ? STATE_LABELS.missing : 'No active Run'); - const worktrees = (project.worktreeRuns || []) - .filter((run) => run.worktreeId) - .map((run) => worktreeRow(run, selectedId, actor)) - .join(''); - return `
                • ` - + `' - + listFreezeButton(project.id, project.run, actor, project.name) - + listSketchButton(project.id, project.run, project.name) - + (worktrees ? `
                    ${worktrees}
                  ` : '') - + '
                • '; +export function listFreezeLabel(actor) { + return actor ? `Freeze as ${actor}` : 'Freeze…'; } -export function renderProjectList(projects, { selectedId = null, actor = null } = {}) { - const sorted = sortProjects(projects); - if (!sorted.length) { - return '

                  No projects yet. AEL lists a project here once you run ael init or ael run in it.

                  '; - } - return `
                    ${sorted.map((project) => projectRow(project, selectedId, actor)).join('')}
                  `; +export function listFreezeName(targetName, actor) { + return actor ? `Freeze ${targetName} as ${actor}` : `Freeze ${targetName}`; } -export function renderOverview(projects) { +export function overviewChips(projects) { const list = projects || []; const working = list.filter((project) => project.state === 'working').length; const waiting = list.filter((project) => project.state === 'waiting').length; - const chips = [`
                • ${list.length} ${list.length === 1 ? 'kitchen' : 'kitchens'}
                • `]; - const workingText = `${working} ${working === 1 ? 'chef' : 'chefs'} cooking`; - chips.push(working - ? `
                • ${workingText}
                • ` - : `
                • ${workingText}
                • `); - if (waiting) chips.push(`
                • ${waiting} ${waiting === 1 ? 'order needs' : 'orders need'} you
                • `); - return chips.join(''); + const chips = [{ kind: 'count', text: `${list.length} ${list.length === 1 ? 'kitchen' : 'kitchens'}` }]; + chips.push({ kind: working ? 'working' : 'count', text: `${working} ${working === 1 ? 'chef' : 'chefs'} cooking` }); + if (waiting) chips.push({ kind: 'waiting', text: `${waiting} ${waiting === 1 ? 'order needs' : 'orders need'} you` }); + return chips; } diff --git a/studio/js/main.js b/studio/js/main.js deleted file mode 100644 index 12df626..0000000 --- a/studio/js/main.js +++ /dev/null @@ -1,885 +0,0 @@ -import { diagramUrl, fetchDetail, fetchMe, fetchProjects, fetchRuns, freezeGoal, saveActor } from './api.js'; -import { crewLabel, crewRuns, renderOrders, withLiveOrders } from './orders.js'; -import { renderOverview, renderProjectList, sortProjects, worktreeState } from './list.js'; -import { recommendedView, renderDetail, renderRoomCard, renderRunHead, renderSketch, renderSketchFoot, sketchFrame, sketchOptions } from './detail.js'; -import { mountRing2d, ringMode, ringModel } from './ring2d.js'; -import { createSheet, trapFocus } from './sheet.js'; -import { roomTargets, stepTarget, waitBubble, waitLevel, waitSeconds } from './mood.js'; - -const ELAPSED_REFRESH_MS = 60_000; - -const elements = { - overview: document.getElementById('overview'), - live: document.getElementById('live'), - connection: document.getElementById('connection'), - list: document.getElementById('project-list'), - run: document.getElementById('run'), - empty: document.getElementById('run-empty'), - head: document.getElementById('run-head'), - status: document.getElementById('run-status'), - detail: document.getElementById('run-detail'), - ring: document.getElementById('ring'), - detailsButton: document.getElementById('details-open'), - ordersButton: document.getElementById('orders-open'), - ordersSheet: document.getElementById('orders-sheet'), - orders: document.getElementById('orders'), - sheet: document.getElementById('details-sheet'), - projects: document.getElementById('projects'), - projectsToggle: document.getElementById('projects-toggle'), - room: document.getElementById('room'), - sketchSheet: document.getElementById('sketch-sheet'), - sketch: document.getElementById('sketch'), - roomCard: document.querySelector('#room .room-card') -}; - -const MOOD_TURN_MS = 3000; -const ROOM_FADE_MS = 260; -const moodView = { level: 0, turn: 0 }; -const roomView = { open: false, busy: false, direction: 0 }; - -const reducedMotionQuery = window.matchMedia('(prefers-reduced-motion: reduce)'); -const HAS_WEBGL = webglAvailable(); -const ringView = { key: null, handle: null, gl: null, model: null, ticket: 0, loading: false, threeFailed: false }; -let kitchenModule = null; - -function loadKitchen() { - if (!kitchenModule) kitchenModule = import('./restaurant.js'); - return kitchenModule; -} - -if (HAS_WEBGL) loadKitchen().catch(() => {}); - -const state = { - projects: [], - loaded: false, - selectedId: new URLSearchParams(window.location.search).get('project'), - detail: null, - detailKey: null, - detailError: null, - me: { actor: null, actorValid: false }, - freezing: false, - goalView: 'formatted', - sketchView: null, - sketchKey: null, - sketchActor: null, - sketchWarm: null, - pendingSketch: null -}; - -let detailTicket = 0; - -function webglAvailable() { - return typeof window.WebGL2RenderingContext === 'function'; -} - -function wantsGl() { - return ringMode({ webgl: HAS_WEBGL, threeFailed: ringView.threeFailed }) === '3d'; -} - -function disposeGl() { - ringView.ticket += 1; - ringView.loading = false; - if (ringView.gl) ringView.gl.dispose(); - ringView.gl = null; - elements.ring.dataset.bot = 'css'; - elements.ring.dataset.ring = 'flat'; -} - -function clearRing() { - disposeGl(); - if (ringView.handle) ringView.handle.dispose(); - ringView.handle = null; - ringView.key = null; - moodView.level = 0; - elements.ring.hidden = true; -} - -function currentModel(summary) { - const model = ringModel(summary.ring, summary); - model.waitLevel = summary.waiting ? waitLevel(waitSeconds(summary.waiting)) : 0; - return model; -} - -function popBubble(bubble) { - delete bubble.dataset.pop; - void bubble.offsetWidth; - bubble.dataset.pop = ''; -} - -function updateMood() { - const handle = ringView.handle; - const summary = state.detail && state.detail.summary; - if (!handle || !handle.bubble) return; - if (!summary || !summary.waiting) { - handle.bubble.hidden = true; - moodView.level = 0; - return; - } - const bubble = waitBubble(summary.waiting.kind, waitSeconds(summary.waiting), moodView.turn, { reducedMotion: reducedMotionQuery.matches }); - handle.bubble.hidden = false; - handle.bubble.dataset.level = String(bubble.level); - if (handle.bubble.textContent !== bubble.text) { - handle.bubble.textContent = bubble.text; - if (!reducedMotionQuery.matches) popBubble(handle.bubble); - } - if (bubble.level !== moodView.level) { - moodView.level = bubble.level; - handle.mood.textContent = `The bot says: ${bubble.text}`; - if (ringView.model) { - ringView.model.waitLevel = bubble.level; - if (ringView.gl) ringView.gl.update(ringView.model); - } - } -} - -function crewModels() { - return crewRuns(state.projects, state.selectedId).map(({ id, run }) => ({ id, label: crewLabel(run), model: currentModel(run) })); -} - -function syncGl(swap) { - if (!wantsGl()) { - disposeGl(); - return; - } - if (ringView.gl) { - ringView.gl.update(ringView.model, { swap, direction: swap ? roomView.direction : 0 }); - ringView.gl.setCrew(crewModels()); - roomView.direction = 0; - return; - } - if (ringView.loading) return; - ringView.loading = true; - const ticket = ringView.ticket; - const failed = () => { - ringView.threeFailed = true; - if (ticket === ringView.ticket) disposeGl(); - }; - loadKitchen().then(({ mountKitchen }) => { - if (ticket !== ringView.ticket || !ringView.handle) return; - ringView.loading = false; - try { - elements.ring.dataset.ring = '3d'; - ringView.gl = mountKitchen(ringView.handle.gl, ringView.model, { - root: elements.ring, - reducedMotion: reducedMotionQuery.matches, - diners: (state.me.diners || []).length, - onOpen: () => openRoom(), - onBook: () => openOrders(null), - onCrew: (id) => select(id) - }); - ringView.gl.setCrew(crewModels()); - elements.ring.dataset.bot = '3d'; - } catch { - failed(); - } - }).catch(failed); -} - -function syncRing() { - const project = selectedProject(); - const summary = state.detail && state.detail.summary; - if (!project || !project.run || !summary) { - clearRing(); - return; - } - const key = `${project.id}|${summary.runId}`; - const view = { summary, findings: state.detail.findings, projectName: project.name, actor: validActor(), diners: state.me.diners || [] }; - const swap = ringView.key !== null && ringView.key !== key; - ringView.model = currentModel(summary); - elements.ring.hidden = false; - if (!ringView.handle) ringView.handle = mountRing2d(elements.ring, view); - else ringView.handle.update(view); - if (ringView.key !== key) moodView.level = 0; - ringView.key = key; - syncGl(swap); - updateMood(); -} - -function selectableTargets() { - return state.projects.flatMap((project) => [ - project, - ...(project.worktreeRuns || []).filter((run) => run.worktreeId).map((run) => ({ - id: run.worktreeId, - name: `${project.name} · worktree`, - state: worktreeState(run), - run - })) - ]); -} - -function selectedProject() { - return selectableTargets().find((target) => target.id === state.selectedId) || null; -} - -function runKey(project) { - const run = project && project.run; - return run ? [project.id, run.runId, run.state, run.updatedAt, run.stage, run.waiting && run.waiting.kind].join('|') : null; -} - -function validActor() { - return state.me.actorValid ? state.me.actor : null; -} - -function focusedListButton() { - const active = document.activeElement; - const button = active && elements.list.contains(active) && active.closest('[data-project-id]'); - return button ? { id: button.dataset.projectId, action: button.dataset.action || 'select' } : null; -} - -function renderList() { - const focused = focusedListButton(); - elements.list.innerHTML = state.loaded ? renderProjectList(state.projects, { selectedId: state.selectedId, actor: validActor() }) : ''; - elements.overview.innerHTML = state.loaded ? renderOverview(state.projects) : '
                • Loading projects…
                • '; - if (!focused) return; - const match = [...elements.list.querySelectorAll('[data-project-id]')] - .find((button) => button.dataset.projectId === focused.id && (button.dataset.action || 'select') === focused.action); - if (match) match.focus(); -} - -function emptyMessage(project) { - if (!state.loaded) return 'Loading projects…'; - if (!project) return state.projects.length ? 'Pick a project to see its Run.' : 'No projects yet.'; - if (project.state === 'missing') return 'This project folder is missing.'; - if (!project.run) return 'No active Run in this project.'; - if (state.detailError) return `Could not load this Run: ${state.detailError}`; - return 'Loading Run…'; -} - -function renderRun() { - const project = selectedProject(); - if (project && project.run && !state.detail && !state.detailError && ringView.handle) return; - const showing = Boolean(project && project.run && state.detail); - elements.empty.hidden = showing; - elements.empty.textContent = showing ? '' : emptyMessage(project); - elements.run.dataset.showing = String(showing); - elements.detailsButton.hidden = !showing; - elements.ordersButton.hidden = !showing; - syncRing(); - if (!showing) { - if (sheet.isOpen()) sheet.close(); - if (sketchSheet.isOpen()) sketchSheet.close(); - if (ordersSheet.isOpen()) ordersSheet.close(); - elements.head.innerHTML = ''; - elements.detail.innerHTML = ''; - return; - } - const input = elements.head.querySelector('#freeze-actor'); - const typed = input ? input.value : ''; - const typing = input && document.activeElement === input; - syncSketch(); - elements.head.innerHTML = renderRunHead(state.detail.summary, { actor: validActor(), projectName: project.name }); - const focusedTab = document.activeElement && elements.detail.contains(document.activeElement) ? document.activeElement.dataset.goalView : null; - elements.detail.innerHTML = renderDetail(state.detail, { goalView: state.goalView }); - if (focusedTab) { - const tab = elements.detail.querySelector(`[data-goal-view="${focusedTab}"]`); - if (tab) tab.focus(); - } - const next = elements.head.querySelector('#freeze-actor'); - if (next && typed) next.value = typed; - if (next && typing) next.focus(); - syncRoom(); -} - -const sheet = createSheet(elements.sheet, { - onOpenChange(open) { - document.body.dataset.sheet = open ? 'open' : 'closed'; - elements.detailsButton.setAttribute('aria-expanded', String(open)); - } -}); - -const sketchSheet = createSheet(elements.sketchSheet, { - onOpenChange(open) { - document.body.dataset.sheet = open ? 'open' : 'closed'; - } -}); - -const ordersSheet = createSheet(elements.ordersSheet, { - onOpenChange(open) { - document.body.dataset.sheet = open ? 'open' : 'closed'; - elements.ordersButton.setAttribute('aria-expanded', String(open)); - } -}); -let ordersTicket = 0; - -async function openOrders(opener) { - const project = selectedProject(); - if (!project || ordersSheet.isOpen() || sheet.isOpen() || sketchSheet.isOpen()) return; - const ticket = ++ordersTicket; - elements.orders.innerHTML = renderOrders([], { projectName: project.name, loading: true }); - ordersSheet.open(opener || null); - try { - const runs = await fetchRuns(project.id); - if (ticket === ordersTicket) elements.orders.innerHTML = renderOrders(withLiveOrders(runs, crewRuns(state.projects, state.selectedId)), { projectName: project.name }); - } catch (error) { - if (ticket === ordersTicket) elements.orders.innerHTML = renderOrders([], { projectName: project.name, error: error.message }); - } -} - -function hasSketch(detail) { - return sketchOptions(detail).length > 0; -} - -function sketchTarget() { - const project = selectedProject(); - const detail = state.detail; - if (!project || !hasSketch(detail)) return null; - return { project, detail, key: [project.id, detail.summary.runId, detail.goalHash].join('|') }; -} - -function sketchPanel() { - return elements.sketch.querySelector('#sketch-panel'); -} - -function markFrame(frame) { - frame.dataset.loaded = 'true'; - const panel = sketchPanel(); - if (panel && !frame.hidden) { - panel.dataset.loaded = 'true'; - panel.removeAttribute('aria-busy'); - } -} - -function addFrame(target, view) { - const panel = sketchPanel(); - if (!panel) return null; - const existing = panel.querySelector(`iframe[data-view="${view}"]`); - if (existing) return existing; - panel.insertAdjacentHTML('beforeend', sketchFrame(view, diagramUrl(target.project.id, target.detail.summary.runId, view, target.detail.goalHash))); - const frame = panel.lastElementChild; - frame.hidden = view !== state.sketchView; - frame.addEventListener('load', () => markFrame(frame), { once: true }); - return frame; -} - -function showFrame(target, view) { - const panel = sketchPanel(); - const frame = addFrame(target, view); - if (!panel || !frame) return; - for (const other of panel.querySelectorAll('iframe[data-view]')) other.hidden = other !== frame; - const loaded = frame.dataset.loaded === 'true'; - panel.dataset.loaded = String(loaded); - if (loaded) panel.removeAttribute('aria-busy'); - else panel.setAttribute('aria-busy', 'true'); - panel.setAttribute('aria-labelledby', `sketch-tab-${view}`); - for (const tab of elements.sketch.querySelectorAll('[role="tab"][data-sketch-view]')) { - const on = tab.dataset.sketchView === view; - tab.setAttribute('aria-selected', String(on)); - tab.tabIndex = on ? 0 : -1; - } -} - -function prepareSketch() { - const target = sketchTarget(); - if (!target) return false; - const actor = validActor(); - if (target.key !== state.sketchKey) { - state.sketchKey = target.key; - state.sketchActor = actor; - state.sketchView = recommendedView(target.detail); - elements.sketch.innerHTML = renderSketch(target.detail, { view: state.sketchView, actor }); - } else if (actor !== state.sketchActor) { - state.sketchActor = actor; - const foot = elements.sketch.querySelector('.sketch-foot'); - if (foot) foot.innerHTML = renderSketchFoot(actor); - } - showFrame(target, state.sketchView); - return true; -} - -function waitsForFreeze(detail) { - return Boolean(detail && detail.summary && detail.summary.waiting && detail.summary.waiting.kind === 'freeze'); -} - -function syncSketch() { - const target = sketchTarget(); - if (!target) { - if (sketchSheet.isOpen()) sketchSheet.close(); - return; - } - if (sketchSheet.isOpen() || waitsForFreeze(target.detail) || target.key === state.sketchKey) prepareSketch(); -} - -function warmSketchTabs() { - const target = sketchTarget(); - if (!target || state.sketchWarm === target.key) return; - state.sketchWarm = target.key; - const idle = window.requestIdleCallback || ((run) => window.setTimeout(run, 200)); - idle(() => { - const live = sketchTarget(); - if (!live || live.key !== target.key) return; - for (const option of sketchOptions(target.detail)) addFrame(target, option.view); - }); -} - -function openSketch(opener) { - if (!hasSketch(state.detail)) { - setStatus('There is no order sketch for this Goal right now.'); - return; - } - if (roomView.open) return; - if (sheet.isOpen()) sheet.close(); - prepareSketch(); - sketchSheet.open(opener || null); - warmSketchTabs(); -} - -const narrowQuery = window.matchMedia('(max-width: 899px)'); - -function setProjectsOpen(open) { - elements.projectsToggle.setAttribute('aria-expanded', String(open)); - elements.projects.dataset.open = String(open); -} - -function typingTarget(target) { - return Boolean(target && target.closest && target.closest('input, textarea, select, [contenteditable="true"]')); -} - -function setStatus(message) { - elements.status.textContent = message || ''; -} - -function playEnter() { - delete elements.run.dataset.enter; - void elements.run.offsetWidth; - elements.run.dataset.enter = ''; -} - -async function loadDetail({ enter = false } = {}) { - const project = selectedProject(); - state.detailKey = runKey(project); - const ticket = ++detailTicket; - if (!project || !project.run) { - state.detail = null; - state.detailError = null; - renderRun(); - return; - } - try { - const detail = await fetchDetail(project.id, project.run.runId); - if (ticket !== detailTicket) return; - state.detail = detail; - state.detailError = null; - } catch (error) { - if (ticket !== detailTicket) return; - state.detail = null; - state.detailError = error.message; - } - renderRun(); - if (enter && !ringView.gl) playEnter(); - if (state.pendingSketch && state.pendingSketch === state.selectedId && state.detail) { - state.pendingSketch = null; - openSketch(null); - } -} - -function fallbackSelection() { - if (selectedProject()) return state.selectedId; - const first = sortProjects(state.projects)[0]; - return first ? first.id : null; -} - -function applyProjects(projects) { - state.projects = Array.isArray(projects) ? projects : []; - state.loaded = true; - const previous = state.selectedId; - state.selectedId = fallbackSelection(); - renderList(); - const changed = previous !== state.selectedId; - if (changed || runKey(selectedProject()) !== state.detailKey) { - if (changed) state.detail = null; - loadDetail({ enter: changed || !state.detail }); - } else { - renderRun(); - } -} - -function select(projectId) { - if (!projectId || projectId === state.selectedId) return; - state.selectedId = projectId; - state.detail = null; - state.detailError = null; - setStatus(''); - const url = new URL(window.location.href); - url.searchParams.set('project', projectId); - window.history.replaceState(null, '', url); - renderList(); - renderRun(); - loadDetail({ enter: true }); -} - -async function refreshProjects() { - try { - applyProjects(await fetchProjects()); - } catch (error) { - setConnection(error.message); - } -} - -function setBusy(button, busy) { - if (!button || !button.isConnected) return; - button.disabled = busy; - if (busy) button.textContent = 'Freezing…'; -} - -function freezeFailure(error) { - if (error.code === 'GOAL_DRAFT_CONFLICT') return 'The Goal changed since you opened it. The new draft is shown; read it and freeze again.'; - return error.fix ? `${error.message}. ${error.fix}` : error.message; -} - -async function submitFreeze(targetId, runId, expectedHash) { - const result = await freezeGoal(targetId, runId, expectedHash); - setStatus(result.alreadyFrozen ? 'This Goal was already frozen in the agent host.' : `Goal frozen as ${state.me.actor}.`); -} - -const FREEZE_DONE_MS = 650; - -function showFrozen(button) { - if (!button || !button.isConnected) return Promise.resolve(); - button.dataset.done = 'true'; - button.textContent = 'Frozen'; - return wait(reducedMotionQuery.matches ? 0 : FREEZE_DONE_MS); -} - -async function withFreezeLock(button, operation) { - if (state.freezing) return; - state.freezing = true; - setBusy(button, true); - try { - await operation(); - await showFrozen(button); - } catch (error) { - setStatus(freezeFailure(error)); - } finally { - state.freezing = false; - } - await refreshProjects(); - await loadDetail(); -} - -async function freeze(name, button = elements.head.querySelector('button[data-action="freeze"]')) { - const project = selectedProject(); - const detail = state.detail; - if (!project || !detail || !detail.goalHash) { - setStatus('There is no Goal draft to freeze. Reload the page.'); - return; - } - await withFreezeLock(button, async () => { - if (name !== undefined) state.me = await saveActor(name); - await submitFreeze(project.id, detail.summary.runId, detail.goalHash); - }); -} - -async function freezeFromList(button) { - const targetId = button.dataset.projectId; - const runId = button.dataset.runId; - select(targetId); - if (!validActor()) { - setStatus('Type your name under the Goal to freeze it.'); - return; - } - const liveButton = [...elements.list.querySelectorAll('button[data-action="list-freeze"]')] - .find((candidate) => candidate.dataset.projectId === targetId) || button; - const goalHash = button.dataset.goalHash; - if (!goalHash) { - setStatus('There is no Goal draft to freeze. Reload the page.'); - return; - } - await withFreezeLock(liveButton, () => submitFreeze(targetId, runId, goalHash)); -} - -const LIVE_TEXT = { connecting: 'Connecting…', live: 'Live', reconnecting: 'Reconnecting…', offline: 'Offline' }; - -function setLive(next) { - if (elements.live.dataset.state === next) return; - elements.live.dataset.state = next; - elements.live.querySelector('.live-text').textContent = LIVE_TEXT[next]; -} - -function showGoalView(view, { focus = false } = {}) { - state.goalView = view; - for (const tab of elements.detail.querySelectorAll('[role="tab"][data-goal-view]')) { - const selected = tab.dataset.goalView === view; - tab.setAttribute('aria-selected', String(selected)); - tab.tabIndex = selected ? 0 : -1; - const panel = document.getElementById(tab.getAttribute('aria-controls')); - if (panel) panel.hidden = !selected; - if (selected && focus) tab.focus(); - } -} - -const TAB_KEYS = { - 'ArrowRight': (index, count) => (index + 1) % count, - 'ArrowLeft': (index, count) => (index - 1 + count) % count, - 'Home': () => 0, - 'End': (index, count) => count - 1 -}; - -function setConnection(message) { - elements.connection.hidden = !message; - elements.connection.textContent = message || ''; -} - -function connect() { - const source = new EventSource('/api/events'); - source.addEventListener('open', () => setLive('live')); - source.addEventListener('projects', (event) => { - setConnection(null); - setLive('live'); - let payload; - try { - payload = JSON.parse(event.data); - } catch { - return; - } - applyProjects(payload.projects); - }); - source.addEventListener('error', () => { - setLive(source.readyState === EventSource.CLOSED ? 'offline' : 'reconnecting'); - setConnection(source.readyState === EventSource.CLOSED - ? 'Lost the Studio connection. Start `ael studio` again, then reload this page.' - : 'Reconnecting to Studio…'); - }); -} - -elements.list.addEventListener('click', (event) => { - const sketchButton = event.target.closest('button[data-action="list-sketch"]'); - if (sketchButton) { - const id = sketchButton.dataset.projectId; - if (id === state.selectedId && state.detail) openSketch(sketchButton); - else { - state.pendingSketch = id; - select(id); - } - return; - } - const freezeButton = event.target.closest('button[data-action="list-freeze"]'); - if (freezeButton) { - freezeFromList(freezeButton); - return; - } - const row = event.target.closest('[data-project-id]'); - if (row) { - select(row.dataset.projectId); - if (narrowQuery.matches) setProjectsOpen(false); - } -}); - -elements.detailsButton.addEventListener('click', () => sheet.open(elements.detailsButton)); -elements.ordersButton.addEventListener('click', () => openOrders(elements.ordersButton)); - -elements.projectsToggle.addEventListener('click', () => { - setProjectsOpen(elements.projectsToggle.getAttribute('aria-expanded') !== 'true'); -}); - -document.addEventListener('keydown', (event) => { - if (event.defaultPrevented || event.metaKey || event.ctrlKey || event.altKey || typingTarget(event.target)) return; - if (event.key === 'Escape' && elements.projects.dataset.open === 'true') { - setProjectsOpen(false); - elements.projectsToggle.focus(); - return; - } - if (roomView.open) return; - if ((event.key === 'o' || event.key === 'O') && !sheet.isOpen() && !sketchSheet.isOpen() && !ordersSheet.isOpen() && !elements.ordersButton.hidden) { - event.preventDefault(); - openOrders(elements.ordersButton); - return; - } - if ((event.key === 'd' || event.key === 'D') && !sheet.isOpen() && !sketchSheet.isOpen() && !ordersSheet.isOpen() && !elements.detailsButton.hidden) { - event.preventDefault(); - sheet.open(elements.detailsButton); - } -}); - -function showSketchView(view, { focus = false } = {}) { - const target = sketchTarget(); - if (!target) return; - state.sketchView = view; - showFrame(target, view); - if (focus) { - const tab = elements.sketch.querySelector(`[data-sketch-view="${view}"]`); - if (tab) tab.focus(); - } -} - -elements.sketch.addEventListener('click', (event) => { - const tab = event.target.closest('[role="tab"][data-sketch-view]'); - if (tab) { - showSketchView(tab.dataset.sketchView); - return; - } - const action = event.target.closest('button[data-action]'); - if (!action) return; - if (action.dataset.action === 'freeze') freeze(undefined, action); - else if (action.dataset.action === 'sketch-freeze-name') { - sketchSheet.close(); - focusActorInput(); - } -}); - -elements.sketch.addEventListener('keydown', (event) => { - const tab = event.target.closest('[role="tab"][data-sketch-view]'); - const move = TAB_KEYS[event.key]; - if (!tab || !move) return; - event.preventDefault(); - const tabs = [...tab.parentElement.querySelectorAll('[role="tab"]')]; - showSketchView(tabs[move(tabs.indexOf(tab), tabs.length)].dataset.sketchView, { focus: true }); -}); - -elements.detail.addEventListener('click', (event) => { - const tab = event.target.closest('[role="tab"][data-goal-view]'); - if (tab) showGoalView(tab.dataset.goalView); -}); - -elements.detail.addEventListener('keydown', (event) => { - const tab = event.target.closest('[role="tab"][data-goal-view]'); - const move = TAB_KEYS[event.key]; - if (!tab || !move) return; - event.preventDefault(); - const tabs = [...tab.parentElement.querySelectorAll('[role="tab"]')]; - showGoalView(tabs[move(tabs.indexOf(tab), tabs.length)].dataset.goalView, { focus: true }); -}); - -function focusActorInput() { - const input = elements.head.querySelector('#freeze-actor'); - if (input) input.focus(); -} - -function wait(ms) { - return new Promise((resolve) => window.setTimeout(resolve, ms)); -} - -function syncRoom() { - if (!roomView.open || !state.detail) return; - const project = selectedProject(); - if (!project) return; - elements.roomCard.innerHTML = renderRoomCard(state.detail.summary, { findings: state.detail.findings, projectName: project.name, actor: validActor() }); -} - -async function openRoom() { - if (roomView.open || roomView.busy || !ringView.handle || !state.detail) return; - roomView.busy = true; - roomView.open = true; - elements.run.dataset.zoom = 'in'; - syncRoom(); - elements.room.hidden = false; - void elements.room.offsetWidth; - elements.room.dataset.open = 'true'; - elements.room.querySelector('[data-action="room-close"]').focus(); - if (ringView.gl) await ringView.gl.zoom('in'); - roomView.busy = false; -} - -async function closeRoom() { - if (!roomView.open || roomView.busy) return; - roomView.busy = true; - elements.room.dataset.open = 'false'; - const zoomOut = ringView.gl ? ringView.gl.zoom('out') : Promise.resolve(); - await wait(reducedMotionQuery.matches ? 0 : ROOM_FADE_MS); - elements.room.hidden = true; - delete elements.run.dataset.zoom; - roomView.open = false; - const bot = elements.ring.querySelector('.ring-bot'); - if (bot) bot.focus(); - await zoomOut; - roomView.busy = false; -} - -function roomStep(direction) { - if (roomView.busy) return; - const id = stepTarget(roomTargets(state.projects), state.selectedId, direction); - if (!id || id === state.selectedId) return; - roomView.direction = direction; - select(id); -} - -elements.ring.addEventListener('click', (event) => { - const action = event.target.closest('.guest [data-action]'); - if (action) { - if (action.dataset.action === 'freeze') freeze(undefined, action); - else if (action.dataset.action === 'guest-freeze-name') focusActorInput(); - else if (action.dataset.action === 'open-sketch') openSketch(action); - return; - } - if (!event.target.closest('.ring-bot')) return; - if (ringView.gl) ringView.gl.react(); - openRoom(); -}); - -elements.room.addEventListener('click', (event) => { - const action = event.target.closest('[data-action]'); - if (!action) { - if (!event.target.closest('.room-card') && ringView.gl) ringView.gl.react(); - return; - } - const name = action.dataset.action; - if (name === 'room-close') closeRoom(); - else if (name === 'room-next') roomStep(1); - else if (name === 'room-prev') roomStep(-1); - else if (name === 'freeze') freeze(undefined, action); - else if (name === 'room-freeze-name') { - closeRoom().then(focusActorInput); - } -}); - -elements.room.addEventListener('keydown', (event) => { - if (event.key === 'Escape') { - event.preventDefault(); - closeRoom(); - } else if (event.key === 'ArrowRight') { - event.preventDefault(); - roomStep(1); - } else if (event.key === 'ArrowLeft') { - event.preventDefault(); - roomStep(-1); - } else { - trapFocus(event, elements.room); - } -}); - -window.setInterval(() => { - if (document.visibilityState !== 'visible') return; - moodView.turn += 1; - updateMood(); -}, MOOD_TURN_MS); - -elements.head.addEventListener('click', (event) => { - const sketch = event.target.closest('button[data-action="open-sketch"]'); - if (sketch) { - openSketch(sketch); - return; - } - const button = event.target.closest('button[data-action="freeze"]'); - if (!button || button.type === 'submit') return; - freeze(); -}); - -elements.head.addEventListener('submit', (event) => { - const form = event.target.closest('form[data-action="freeze"]'); - if (!form) return; - event.preventDefault(); - const name = form.elements.actor.value.trim(); - if (name) freeze(name); -}); - -reducedMotionQuery.addEventListener('change', () => { - disposeGl(); - syncRing(); -}); - -setInterval(() => { - if (document.visibilityState === 'visible') refreshProjects(); -}, ELAPSED_REFRESH_MS); - -async function start() { - renderList(); - renderRun(); - try { - state.me = await fetchMe(); - } catch { - state.me = { actor: null, actorValid: false }; - } - await refreshProjects(); - connect(); -} - -start(); diff --git a/studio/js/orders.js b/studio/js/orders.js index 47adedb..e80ff23 100644 --- a/studio/js/orders.js +++ b/studio/js/orders.js @@ -1,6 +1,6 @@ -import { escapeHtml, formatElapsed, FINISHED_RUN_STATES, stageLabel, waitingLabel } from './list.js'; +import { formatElapsed, FINISHED_RUN_STATES, stageLabel, waitingLabel } from './list.js'; -const OUTCOMES = { +export const OUTCOMES = { passed: 'Passed', done: 'Served', back: 'Sent back', @@ -30,7 +30,7 @@ export function orderSummary(runs) { return SUMMARY_ORDER.filter((outcome) => counts[outcome]).map((outcome) => `${counts[outcome]} ${OUTCOMES[outcome].toLowerCase()}`).join(' · '); } -const STAMPS = { +export const STAMPS = { passed: 'Passed', done: 'Served', back: 'Sent back', @@ -39,43 +39,15 @@ const STAMPS = { cancelled: 'Void' }; -function orderRow(run, index, total) { - const outcome = orderOutcome(run); +export function orderMeta(run) { const ago = formatElapsed(run.elapsedMs); - const meta = [run.worktree ? 'worktree' : '', run.iteration > 1 ? `iteration ${run.iteration}` : '', ago === 'just now' ? ago : `${ago} ago`].filter(Boolean).join(' · '); - return `
                • ` - + `` - + `${escapeHtml(run.task || 'Untitled order')}` - + `${run.current ? 'On the pass now · ' : ''}${escapeHtml(meta)}` - + `${STAMPS[outcome]}
                • `; + return [run.worktree ? 'worktree' : '', run.iteration > 1 ? `iteration ${run.iteration}` : '', ago === 'just now' ? ago : `${ago} ago`].filter(Boolean).join(' · '); } -function tally(list) { +export function orderTally(runs) { const counts = {}; - for (const run of list) counts[orderOutcome(run)] = (counts[orderOutcome(run)] || 0) + 1; - return SUMMARY_ORDER.filter((outcome) => counts[outcome]) - .map((outcome) => `
                • ${counts[outcome]} ${OUTCOMES[outcome].toLowerCase()}
                • `).join(''); -} - -export function renderOrders(runs, { projectName = '', loading = false, error = null } = {}) { - const list = Array.isArray(runs) ? runs : []; - let right; - if (loading) right = '

                  Leafing through the pages…

                  '; - else if (error) right = `

                  Could not read the order book: ${escapeHtml(error)}

                  `; - else if (!list.length) right = '

                  No orders written yet.

                  '; - else right = `
                    ${list.map((run, index) => orderRow(run, index, list.length)).join('')}
                  `; - const summary = !loading && !error && list.length - ? `

                  ${escapeHtml(orderSummary(list))}

                  ` - : ''; - return '
                  ' - + '
                  ' - + '

                  The kitchen\'s

                  Order book

                  ' - + (projectName ? `

                  ${escapeHtml(projectName)}

                  ` : '') - + summary - + '

                  Newest orders first

                  ' - + '
                  ' - + `
                  ${right}
                  ` - + '
                  '; + for (const run of runs || []) counts[orderOutcome(run)] = (counts[orderOutcome(run)] || 0) + 1; + return SUMMARY_ORDER.filter((outcome) => counts[outcome]).map((outcome) => ({ outcome, count: counts[outcome], label: OUTCOMES[outcome].toLowerCase() })); } export function crewLabel(run) { diff --git a/studio/js/restaurant.js b/studio/js/restaurant.js index 2a1445c..a21be1e 100644 --- a/studio/js/restaurant.js +++ b/studio/js/restaurant.js @@ -55,6 +55,9 @@ const OVERLAY_PAD = 8; const DIM_STATION = 0.55; const HOP = 0.14; const MAX_FRAME_SECONDS = 0.1; +const MAX_PIXEL_RATIO = 1.5; +const SLOW_FRAME_SECONDS = 1 / 40; +const SLOW_FRAME_SAMPLES = 45; const LABEL_GAP = 8; const SPOT_ON = 9; const PENDANT_POWER = 7; @@ -121,7 +124,8 @@ function settle(current, target, seconds, constant) { export function mountKitchen(el, model, { root, reducedMotion = false, onOpen = null, onBook = null, onCrew = null, diners = 0 } = {}) { const renderer = new WebGLRenderer({ antialias: true, alpha: true, powerPreference: 'high-performance' }); - renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2)); + let pixelRatio = Math.min(window.devicePixelRatio || 1, MAX_PIXEL_RATIO); + renderer.setPixelRatio(pixelRatio); renderer.outputColorSpace = SRGBColorSpace; renderer.toneMapping = ACESFilmicToneMapping; renderer.toneMappingExposure = 1.05; @@ -206,6 +210,28 @@ export function mountKitchen(el, model, { root, reducedMotion = false, onOpen = let cameraX = null; let stripStage = null; const compactQuery = window.matchMedia('(max-width: 600px)'); + let lastGuestHeight = ''; + const frameSamples = []; + const sizes = new WeakMap(); + const sizeWatch = typeof ResizeObserver === 'function' + ? new ResizeObserver((entries) => { + for (const entry of entries) { + const box = entry.borderBoxSize && entry.borderBoxSize[0]; + sizes.set(entry.target, box ? { w: box.inlineSize, h: box.blockSize } : { w: entry.target.offsetWidth, h: entry.target.offsetHeight }); + } + schedule(); + }) + : null; + + function sizeOf(node) { + let size = sizes.get(node); + if (!size) { + size = { w: node.offsetWidth, h: node.offsetHeight }; + sizes.set(node, size); + if (sizeWatch) sizeWatch.observe(node); + } + return size; + } function statusMap(next) { return Object.fromEntries(next.stages.map((item) => [item.stage, item.status])); @@ -343,8 +369,7 @@ export function mountKitchen(el, model, { root, reducedMotion = false, onOpen = function place(node, point, { anchor = 'top', gap = 0 } = {}) { if (!node) return; const screen = project(point); - const w = node.offsetWidth; - const h = node.offsetHeight; + const { w, h } = sizeOf(node); if (anchor === 'side') { node.style.transform = `translate(${(screen.x + gap).toFixed(1)}px, ${(screen.y - h / 2).toFixed(1)}px)`; return; @@ -377,13 +402,19 @@ export function mountKitchen(el, model, { root, reducedMotion = false, onOpen = return; } guest.style.removeProperty('transform'); - root.style.setProperty('--guest-h', `${guest.offsetHeight}px`); + const guestHeight = `${sizeOf(guest).h}px`; + if (guestHeight !== lastGuestHeight) { + lastGuestHeight = guestHeight; + root.style.setProperty('--guest-h', guestHeight); + } } function placeBubble(top, size) { const bubble = root.querySelector('.bot-bubble'); - if (!bubble || bubble.hidden || !bubble.offsetWidth) return null; - const box = clampBox({ x: top.x + size * 0.2, y: top.y - (bubble.offsetHeight || 28) - 4, w: bubble.offsetWidth, h: bubble.offsetHeight }, { width, height }, OVERLAY_PAD); + if (!bubble || bubble.hidden) return null; + const { w, h } = sizeOf(bubble); + if (!w) return null; + const box = clampBox({ x: top.x + size * 0.2, y: top.y - (h || 28) - 4, w, h }, { width, height }, OVERLAY_PAD); bubble.style.transform = `translate(${box.x.toFixed(1)}px, ${box.y.toFixed(1)}px)`; return box; } @@ -392,8 +423,7 @@ export function mountKitchen(el, model, { root, reducedMotion = false, onOpen = const ticket = root.querySelector('.kitchen-ticket'); if (!ticket) return; const screen = project(new Vector3(current.ticketX + base.x, TICKET_Y + 0.2 + base.y, RAIL_Z + base.z)); - const w = ticket.offsetWidth; - const h = ticket.offsetHeight; + const { w, h } = sizeOf(ticket); const spot = dodgeLabel({ x: screen.x - w / 2, y: screen.y - h - 4, w, h }, bubbleBox, { width, height }, { pad: OVERLAY_PAD }); ticket.style.transform = `translate(${spot.x.toFixed(1)}px, ${spot.y.toFixed(1)}px)`; ticket.style.visibility = spot.hidden ? 'hidden' : ''; @@ -643,6 +673,7 @@ export function mountKitchen(el, model, { root, reducedMotion = false, onOpen = function tick(time) { frame = 0; const seconds = lastTime ? Math.min((time - lastTime) / 1000, MAX_FRAME_SECONDS) : 1 / 60; + if (lastTime) watchFrameRate(seconds); lastTime = time; const swapping = stepSwap(time); const zooming = stepZoom(time); @@ -660,6 +691,18 @@ export function mountKitchen(el, model, { root, reducedMotion = false, onOpen = } } + function watchFrameRate(seconds) { + if (pixelRatio <= 1) return; + frameSamples.push(seconds); + if (frameSamples.length < SLOW_FRAME_SAMPLES) return; + const average = frameSamples.reduce((sum, value) => sum + value, 0) / frameSamples.length; + frameSamples.length = 0; + if (average <= SLOW_FRAME_SECONDS) return; + pixelRatio = 1; + renderer.setPixelRatio(pixelRatio); + renderer.setSize(width, height); + } + function sleepUntilBlink() { window.clearTimeout(wakeTimer); const wait = Math.min(bot.wakeIn(), ...crew.map((member) => member.bot.wakeIn())); @@ -983,6 +1026,7 @@ export function mountKitchen(el, model, { root, reducedMotion = false, onOpen = finishSwap(); if (zoomTween) zoomTween.resolve(); resizeObserver.disconnect(); + if (sizeWatch) sizeWatch.disconnect(); document.removeEventListener('visibilitychange', onVisibility); darkScheme.removeEventListener('change', onTheme); compactQuery.removeEventListener('change', onCompact); diff --git a/studio/js/ring2d.js b/studio/js/ring2d.js index 9df2694..35c3eef 100644 --- a/studio/js/ring2d.js +++ b/studio/js/ring2d.js @@ -1,6 +1,4 @@ -import { STAGES, escapeHtml, stageLabel } from './list.js'; -import { returnPath, stationConfig, ticketLabel } from './kitchen.js'; -import { guestPrompt } from './mood.js'; +import { STAGES, stageLabel } from './list.js'; export const RING_STAGES = STAGES; export const RING_STATUSES = ['done', 'now', 'pending', 'skipped']; @@ -141,88 +139,12 @@ export function ringEyebrow(summary, projectName = '') { return ['Order', projectName, summary && summary.tier, iteration].filter(Boolean).join(' · '); } -function stageItem({ stage, angle, status }) { - return `
                • ` - + `${escapeHtml(stationConfig(stage).label)} ${escapeHtml(stageLabel(stage))}` - + `, ${STATUS_TEXT[status]}
                • `; -} - -function guestActions(summary, actor) { - if (!summary.waiting || summary.waiting.kind !== 'freeze') return ''; - const sketch = summary.waiting.sketch ? '' : ''; - const freeze = actor - ? `` - : ''; - return `
                  ${sketch}${freeze}
                  `; -} - -export function renderGuest({ summary, actor = null }) { - const prompt = guestPrompt(summary && summary.waiting); - const ask = prompt - ? `

                  ${escapeHtml(prompt.ask)} ${escapeHtml(prompt.note)}

                  ${guestActions(summary, actor)}` - : ''; - return `

                  You, the guest

                  ${ask}
                  `; -} +export const STATUS_LABELS = STATUS_TEXT; export const DINER_SUBTITLE = 'Eating while their workflow cooks'; -export function renderDiners(diners) { - const list = (Array.isArray(diners) ? diners : []).slice(0, 6).filter((diner) => diner && diner.name); - if (!list.length) return ''; - const item = (diner) => `
                • ${escapeHtml(diner.name)}${diner.note ? `, ${escapeHtml(diner.note)}` : ''}
                • `; - return `
                    ${list.map(item).join('')}
                  `; -} - -export function renderRingFace({ summary, findings = null, actor = null, diners = [] }) { - const model = ringModel(summary && summary.ring, summary || {}); - const activity = kitchenActivity(summary, findings); - const back = returnPath(model); - return '
                  ' - + `
                    ${model.stages.map(stageItem).join('')}
                  ` - + `
                  ${escapeHtml(activity.title)}` - + `${escapeHtml(activity.note)}
                  ` - + `

                  ${escapeHtml(ticketLabel(model))}

                  ` - + (back ? `

                  ${escapeHtml(back.label)}: ${escapeHtml(stationConfig(back.from).label)} → ${escapeHtml(stationConfig(back.to).label)}

                  ` : '') - + '
                  ' - + renderGuest({ summary: summary || {}, actor }) - + renderDiners(diners); -} - -export function renderRingBot(model, label) { - return `
                  `; -} - -export function renderRing(view) { - const model = ringModel(view.summary && view.summary.ring, view.summary || {}); - return `
                  ${renderRingFace(view)}
                  ` - + renderRingBot(model, botLabel(view.summary, view.findings)) - + '' - + '

                  '; -} - -export function mountRing2d(el, view) { - el.innerHTML = renderRing(view); - const face = el.querySelector('.ring-face'); - const orbit = el.querySelector('.ring-orbit'); - const button = el.querySelector('.ring-bot'); - let faceHtml = renderRingFace(view); - return { - gl: el.querySelector('.ring-gl'), - bubble: el.querySelector('.bot-bubble'), - mood: el.querySelector('.bot-mood'), - update(next) { - const html = renderRingFace(next); - if (html !== faceHtml) { - face.innerHTML = html; - faceHtml = html; - } - orbit.dataset.at = ringModel(next.summary && next.summary.ring, next.summary || {}).botStage; - button.setAttribute('aria-label', botLabel(next.summary, next.findings)); - }, - dispose() { - el.innerHTML = ''; - } - }; +export function dinerList(diners) { + return (Array.isArray(diners) ? diners : []).slice(0, 6).filter((diner) => diner && diner.name); } export function ringMode({ webgl = false, threeFailed = false } = {}) { diff --git a/studio/js/sheet.js b/studio/js/sheet.js index bacb8f7..3a87727 100644 --- a/studio/js/sheet.js +++ b/studio/js/sheet.js @@ -1,7 +1,7 @@ export const SHEET_DISMISS_FRACTION = 0.25; export const SHEET_DISMISS_VELOCITY = 0.5; -const FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'; +export const FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'; export function shouldDismiss(distance, velocity, height) { if (distance <= 0) return false; @@ -31,85 +31,3 @@ export function trapFocus(event, container) { } return false; } - -export function createSheet(root, { onOpenChange = () => {} } = {}) { - const panel = root.querySelector('.sheet-panel'); - const handle = root.querySelector('.sheet-grab'); - let opener = null; - let drag = null; - - function finishClose() { - if (root.dataset.open === 'true') return; - root.hidden = true; - panel.style.removeProperty('transform'); - } - - function open(from) { - if (root.dataset.open === 'true') return; - opener = from || null; - root.hidden = false; - void panel.offsetHeight; - root.dataset.open = 'true'; - onOpenChange(true); - panel.focus(); - } - - function close() { - if (root.dataset.open !== 'true') return; - root.dataset.open = 'false'; - panel.style.removeProperty('transform'); - onOpenChange(false); - const fallback = window.setTimeout(finishClose, 600); - panel.addEventListener('transitionend', () => { - window.clearTimeout(fallback); - finishClose(); - }, { once: true }); - if (opener && opener.isConnected) opener.focus(); - } - - function onKeydown(event) { - if (event.key === 'Escape') { - event.preventDefault(); - close(); - return; - } - trapFocus(event, panel); - } - - function onPointerDown(event) { - if (event.pointerType === 'mouse') return; - drag = { startY: event.clientY, lastY: event.clientY, lastTime: event.timeStamp, velocity: 0 }; - root.dataset.dragging = 'true'; - handle.setPointerCapture(event.pointerId); - } - - function onPointerMove(event) { - if (!drag) return; - const elapsed = Math.max(1, event.timeStamp - drag.lastTime); - drag.velocity = (event.clientY - drag.lastY) / elapsed; - drag.lastY = event.clientY; - drag.lastTime = event.timeStamp; - panel.style.transform = `translateY(${dragOffset(event.clientY - drag.startY).toFixed(1)}px)`; - } - - function onPointerUp() { - if (!drag) return; - const distance = drag.lastY - drag.startY; - const dismiss = shouldDismiss(distance, drag.velocity, panel.offsetHeight); - drag = null; - delete root.dataset.dragging; - if (dismiss) close(); - else panel.style.removeProperty('transform'); - } - - root.addEventListener('keydown', onKeydown); - root.addEventListener('click', (event) => { - if (event.target.closest('[data-action="close-details"]')) close(); - }); - handle.addEventListener('pointerdown', onPointerDown); - handle.addEventListener('pointermove', onPointerMove); - handle.addEventListener('pointerup', onPointerUp); - handle.addEventListener('pointercancel', onPointerUp); - - return { open, close, isOpen: () => root.dataset.open === 'true' }; -} diff --git a/studio/src/App.svelte b/studio/src/App.svelte new file mode 100644 index 0000000..fcb6f47 --- /dev/null +++ b/studio/src/App.svelte @@ -0,0 +1,534 @@ + + + + +
                  +
                  + +

                  AEL Studio

                  +
                  + + +

                  {LIVE_TEXT[live]}

                  + +
                  +
                  + +
                  + + openOrders(null)} + oncrew={(id) => select(id)} + onfreeze={(source) => freezeGoalDraft(source)} + onfreezename={focusActorInput} + onsketch={openSketch} + /> + freezeGoalDraft(source, name)} onsketch={openSketch} /> +

                  {status}

                  + + + freezeGoalDraft(source)} + onfreezename={roomName} + onreact={() => ring.react()} + /> +
                  +
                  + + freezeGoalDraft(source)} onfreezename={sketchName} /> + + + + + + (goalView = name)} /> + diff --git a/studio/src/components/FreezeButton.svelte b/studio/src/components/FreezeButton.svelte new file mode 100644 index 0000000..db3c266 --- /dev/null +++ b/studio/src/components/FreezeButton.svelte @@ -0,0 +1,13 @@ + + + diff --git a/studio/src/components/OrderBook.svelte b/studio/src/components/OrderBook.svelte new file mode 100644 index 0000000..a017d1d --- /dev/null +++ b/studio/src/components/OrderBook.svelte @@ -0,0 +1,46 @@ + + +
                  +
                  +
                  +

                  The kitchen's

                  Order book

                  + {#if projectName}

                  {projectName}

                  {/if} + {#if showSummary} +

                  {orderSummary(list)}

                  + + {/if} +

                  Newest orders first

                  +
                  +
                  + {#if loading} +

                  Leafing through the pages…

                  + {:else if error} +

                  Could not read the order book: {error}

                  + {:else if !list.length} +

                  No orders written yet.

                  + {:else} +
                    + {#each list as run, index} + {@const outcome = orderOutcome(run)} +
                  1. + + {run.task || 'Untitled order'}{#if run.current}On the pass now{' · '}{/if}{orderMeta(run)} + {STAMPS[outcome]} +
                  2. + {/each} +
                  + {/if} +
                  +
                  +
                  diff --git a/studio/src/components/Overview.svelte b/studio/src/components/Overview.svelte new file mode 100644 index 0000000..5de43b5 --- /dev/null +++ b/studio/src/components/Overview.svelte @@ -0,0 +1,22 @@ + + +
                    + {#if !loaded} +
                  • Loading projects…
                  • + {:else} + {#each chips as chip} + {#if chip.kind === 'working'} +
                  • {chip.text}
                  • + {:else if chip.kind === 'waiting'} +
                  • {chip.text}
                  • + {:else} +
                  • {chip.text}
                  • + {/if} + {/each} + {/if} +
                  diff --git a/studio/src/components/ProjectList.svelte b/studio/src/components/ProjectList.svelte new file mode 100644 index 0000000..25ff276 --- /dev/null +++ b/studio/src/components/ProjectList.svelte @@ -0,0 +1,40 @@ + + +{#snippet actions(targetId, run, targetName)} + {#if freezeWait(run)} onfreeze(targetId, run)} onname={() => onfreezename(targetId)} />{#if run.waiting.sketch}{/if}{/if} +{/snippet} + +
                  + {#if loaded} + {#if !sorted.length} +

                  No projects yet. AEL lists a project here once you run ael init or ael run in it.

                  + {:else} +
                    + {#each sorted as project (project.id)} + {@const state = projectState(project)} + {@const worktrees = worktreeRows(project)} +
                  • + {@render actions(project.id, project.run, project.name)}{#if worktrees.length} +
                      + {#each worktrees as run (run.worktreeId)} + {@const wstate = worktreeState(run)} +
                    • + {@render actions(run.worktreeId, run, run.task || run.runId)} +
                    • + {/each} +
                    + {/if} +
                  • + {/each} +
                  + {/if} + {/if} +
                  diff --git a/studio/src/components/Ring.svelte b/studio/src/components/Ring.svelte new file mode 100644 index 0000000..3116cf3 --- /dev/null +++ b/studio/src/components/Ring.svelte @@ -0,0 +1,201 @@ + + + diff --git a/studio/src/components/Room.svelte b/studio/src/components/Room.svelte new file mode 100644 index 0000000..90a707f --- /dev/null +++ b/studio/src/components/Room.svelte @@ -0,0 +1,60 @@ + + + + diff --git a/studio/src/components/RunDetail.svelte b/studio/src/components/RunDetail.svelte new file mode 100644 index 0000000..70d4470 --- /dev/null +++ b/studio/src/components/RunDetail.svelte @@ -0,0 +1,62 @@ + + +{#snippet listOrNone(items)} + {#if !items || !items.length} +

                  None

                  + {:else} +
                    + {#each items as item} +
                  • {item}
                  • + {/each} +
                  + {/if} +{/snippet} + +
                  + {#if detail} +
                  +
                  Findings
                  {findingsText(detail.findings)}
                  +
                  Pull request
                  {#if detail.pr}{detail.pr.branch || 'unknown branch'} · {detail.pr.merged ? 'merged' : 'not merged'}{#if prUrl}{' '}open{/if}{:else}No branch yet{/if}
                  +
                  Receipt
                  {detail.receipt === 'written' ? 'Receipt written' : 'No receipt yet'}
                  +
                  +
                  + {#if !detail.goalMarkdown} +

                  Goal

                  +

                  No Goal draft yet.

                  + {:else} +
                  +

                  Goal

                  +
                  + {#each GOAL_VIEWS as name} + + {/each} +
                  +
                  + + + {/if} +
                  +

                  Unconfirmed assumptions

                  {@render listOrNone(detail.unconfirmed)}
                  + {#if detail.extraNodes && detail.extraNodes.length} +

                  Other steps

                  {@render listOrNone(detail.extraNodes)}
                  + {/if} + {/if} +
                  diff --git a/studio/src/components/RunHead.svelte b/studio/src/components/RunHead.svelte new file mode 100644 index 0000000..fb02f8f --- /dev/null +++ b/studio/src/components/RunHead.svelte @@ -0,0 +1,30 @@ + + +
                  + {#if summary} +

                  {ringEyebrow(summary, projectName)}

                  +

                  {title}

                  +

                  {startedText(summary.elapsedMs)}

                  + {#if summary.waiting} +
                  {waitAsk(summary.waiting)}{waitText(summary.waiting)}{#if waitsForFreeze(summary)}{#if actor} {}} />{:else}
                  {/if}{#if summary.waiting.sketch}{/if}{/if}
                  + {/if} + {/if} +
                  diff --git a/studio/src/components/Sheet.svelte b/studio/src/components/Sheet.svelte new file mode 100644 index 0000000..b73d19f --- /dev/null +++ b/studio/src/components/Sheet.svelte @@ -0,0 +1,95 @@ + + + + diff --git a/studio/src/components/Sketch.svelte b/studio/src/components/Sketch.svelte new file mode 100644 index 0000000..72c3794 --- /dev/null +++ b/studio/src/components/Sketch.svelte @@ -0,0 +1,47 @@ + + +
                  + {#if !options.length} +

                  There is no order sketch for this Goal.

                  + {:else} +

                  {sketchCounts(detail.flowCounts)}

                  +
                  + {#each options as option (option.view)} + + {/each} +
                  +
                  + + {#each frames as frame (frame)} + + {/each} +
                  +
                  +

                  {REVISE_HINT}

                  + +
                  + {/if} +
                  diff --git a/studio/src/index.html b/studio/src/index.html new file mode 100644 index 0000000..79be0e4 --- /dev/null +++ b/studio/src/index.html @@ -0,0 +1,11 @@ + + + + + + + AEL Studio + + + + diff --git a/studio/src/main.js b/studio/src/main.js new file mode 100644 index 0000000..228327d --- /dev/null +++ b/studio/src/main.js @@ -0,0 +1,8 @@ +import '../tokens.css'; +import '../styles.css'; +import { mount } from 'svelte'; +import App from './App.svelte'; + +if (typeof window.WebGL2RenderingContext === 'function') import('../js/restaurant.js').catch(() => {}); + +mount(App, { target: document.body }); diff --git a/studio/src/package.json b/studio/src/package.json new file mode 100644 index 0000000..089153b --- /dev/null +++ b/studio/src/package.json @@ -0,0 +1 @@ +{"type":"module"} diff --git a/studio/src/tabs.js b/studio/src/tabs.js new file mode 100644 index 0000000..65b6a8a --- /dev/null +++ b/studio/src/tabs.js @@ -0,0 +1,13 @@ +const TAB_KEYS = { + ArrowRight: (index, count) => (index + 1) % count, + ArrowLeft: (index, count) => (index - 1 + count) % count, + Home: () => 0, + End: (index, count) => count - 1 +}; + +export function tabKeys(event, names, current) { + const move = TAB_KEYS[event.key]; + if (!move) return null; + event.preventDefault(); + return names[move(names.indexOf(current), names.length)]; +} diff --git a/studio/vite.config.mjs b/studio/vite.config.mjs new file mode 100644 index 0000000..8424f85 --- /dev/null +++ b/studio/vite.config.mjs @@ -0,0 +1,21 @@ +import { fileURLToPath } from 'node:url'; +import { defineConfig } from 'vite'; +import { svelte } from '@sveltejs/vite-plugin-svelte'; + +const here = (file) => fileURLToPath(new URL(file, import.meta.url)); + +export default defineConfig(({ mode }) => ({ + root: here('./src'), + base: '/', + plugins: [svelte()], + logLevel: 'warn', + build: { + outDir: process.env.AEL_STUDIO_OUT || here('./app'), + emptyOutDir: true, + target: 'es2022', + modulePreload: { polyfill: false }, + sourcemap: false, + reportCompressedSize: false, + chunkSizeWarningLimit: 1200 + } +})); diff --git a/tests/helpers/svelte-hooks.mjs b/tests/helpers/svelte-hooks.mjs new file mode 100644 index 0000000..ad4a9ab --- /dev/null +++ b/tests/helpers/svelte-hooks.mjs @@ -0,0 +1,13 @@ +import { readFile } from 'node:fs/promises'; +import { fileURLToPath } from 'node:url'; + +let compiler = null; + +export async function load(url, context, next) { + if (!url.startsWith('file:') || !url.endsWith('.svelte')) return next(url, context); + compiler ??= await import('svelte/compiler'); + const filename = fileURLToPath(url); + const source = await readFile(filename, 'utf8'); + const { js } = compiler.compile(source, { filename, generate: 'server' }); + return { format: 'module', source: js.code, shortCircuit: true }; +} diff --git a/tests/helpers/svelte.js b/tests/helpers/svelte.js new file mode 100644 index 0000000..761b747 --- /dev/null +++ b/tests/helpers/svelte.js @@ -0,0 +1,31 @@ +'use strict'; + +// Server-renders Studio components in Node so tests can read their markup. +// Svelte's hydration comments are stripped; everything else is the real output. +const { register } = require('node:module'); +const path = require('node:path'); +const { pathToFileURL } = require('node:url'); + +const STUDIO = path.join(__dirname, '..', '..', 'studio'); +let registered = false; + +function ensureHooks() { + if (registered) return; + register('./svelte-hooks.mjs', pathToFileURL(__filename)); + registered = true; +} + +function clean(html) { + return html.replace(//g, ''); +} + +async function renderComponent(file, props = {}) { + ensureHooks(); + const { render } = await import('svelte/server'); + const component = await import(pathToFileURL(path.join(STUDIO, 'src', file)).href); + return clean(render(component.default, { props }).body); +} + +const noop = () => {}; + +module.exports = { STUDIO, clean, noop, renderComponent }; diff --git a/tests/studio-design-tokens.test.js b/tests/studio-design-tokens.test.js index 84a84ef..a195276 100644 --- a/tests/studio-design-tokens.test.js +++ b/tests/studio-design-tokens.test.js @@ -24,7 +24,7 @@ test('styles.css has no raw colours; tokens.css defines the brand, light and dar const used = new Set([...css.matchAll(/var\(--([a-z0-9-]+)\)/g)].map((match) => match[1])); const defined = new Set([...tokens.matchAll(/--([a-z0-9-]+):/g), ...css.matchAll(/--([a-z0-9-]+):/g)].map((match) => match[1])); assert.deepStrictEqual([...used].filter((name) => !defined.has(name)), []); - assert.match(read('index.html'), /href="\/tokens\.css"[\s\S]*href="\/styles\.css"/); + assert.match(read('src/main.js'), /import '\.\.\/tokens\.css';\nimport '\.\.\/styles\.css';/, 'tokens load before the styles that use them'); }); test('option C colours: done green, now orange with a halo, pending paper, bots from tokens in both themes', () => { diff --git a/tests/studio-diners.test.js b/tests/studio-diners.test.js index ed5f45c..1c308f3 100644 --- a/tests/studio-diners.test.js +++ b/tests/studio-diners.test.js @@ -18,7 +18,8 @@ test('the shipped diners file holds the valid default diners and is an allowlist assert.deepStrictEqual(defaultDiners(), shipped); const server = fs.readFileSync(path.join(__dirname, '..', 'lib', 'studio-server.js'), 'utf8'); assert.ok(server.includes("['/diners.json', 'diners.json']")); - assert.ok(server.includes("['/js/diners.js', 'js/diners.js']")); + const { appAssets } = require('../lib/studio-server.js'); + assert.equal(appAssets().get('/diners.json'), 'diners.json'); }); test('a missing or invalid diners file leaves only generic, unnamed seats', () => { @@ -60,13 +61,19 @@ test('studio.diners in the local config overrides the defaults after validation' }); test('diner names are a visually hidden list with the fixed subtitle and no hover card; the layout seats at most six', async () => { - const { renderDiners, DINER_SUBTITLE } = await import(pathToFileURL(path.join(studio, 'js', 'ring2d.js')).href); + const { DINER_SUBTITLE } = await import(pathToFileURL(path.join(studio, 'js', 'ring2d.js')).href); assert.equal(DINER_SUBTITLE, 'Eating while their workflow cooks'); - const html = renderDiners([{ name: 'Linus', note: 'Reads "diffs"' }, { name: 'Ada' }]); + const { renderComponent } = require('./helpers/svelte.js'); + const renderDiners = async (diners) => { + const html = await renderComponent('components/Ring.svelte', { summary: { ring: [] }, diners, freeze: { source: null, phase: 'idle' } }); + const list = html.match(/
                    /); + return list ? list[0] : ''; + }; + const html = await renderDiners([{ name: 'Linus', note: 'Reads "diffs"' }, { name: 'Ada' }]); assert.match(html, /
                      /); - assert.match(html, /
                    • <b>Linus<\/b>, Reads "diffs"<\/li>
                    • Ada<\/li>/); + assert.match(html, /
                    • <b>Linus<\/b>, Reads "diffs"<\/li>
                    • Ada<\/li>/); assert.doesNotMatch(html, /button|diner-card/); - assert.equal(renderDiners([]), ''); + assert.equal(await renderDiners([]), ''); const { dinerLayout, dinerPose, DINER_LOOPS } = await import(pathToFileURL(path.join(studio, 'js', 'kitchen.js')).href); assert.equal(dinerLayout(9).length, 6); const { dinerSeats, GENERIC_SEATS } = await import(pathToFileURL(path.join(studio, 'js', 'kitchen.js')).href); diff --git a/tests/studio-goal-header-bot.test.js b/tests/studio-goal-header-bot.test.js index abb04c2..4989ab2 100644 --- a/tests/studio-goal-header-bot.test.js +++ b/tests/studio-goal-header-bot.test.js @@ -9,6 +9,10 @@ const { pathToFileURL } = require('url'); const studio = path.join(__dirname, '..', 'studio'); const load = (file) => import(pathToFileURL(path.join(studio, 'js', file)).href); const read = (file) => fs.readFileSync(path.join(studio, file), 'utf8'); +const { renderComponent } = require('./helpers/svelte.js'); +const renderDetail = (detail, { goalView = 'formatted' } = {}) => renderComponent('components/RunDetail.svelte', { detail, goalView }); +const renderRing = ({ summary = null, findings = null } = {}) => renderComponent('components/Ring.svelte', { summary, findings, freeze: { source: null, phase: 'idle' } }); +const stripOverview = (html) => html.replace(/^
                        ]*>/, '').replace(/<\/ul>$/, ''); const STAGES = ['goal', 'maker', 'verify', 'review', 'judge', 'deliver']; test('markdown renders headings, paragraphs, nested lists, emphasis, code and http links', async () => { @@ -53,42 +57,44 @@ test('markdown escapes all text and drops unsafe links to plain text', async () }); test('the Goal card has Formatted (default) and Markdown tabs with tab roles', async () => { - const { renderDetail } = await load('detail.js'); const detail = { summary: { ring: [] }, goalMarkdown: '# Goal\n\n- **keep** this', findings: null, pr: null, receipt: 'none', unconfirmed: [], extraNodes: [] }; - const html = renderDetail(detail); + const html = await renderDetail(detail); assert.match(html, /
                        /); assert.match(html, /