diff --git a/CHANGELOG.md b/CHANGELOG.md index d0a5a39..908940f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,70 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed — Auto-consolidation merge: opt-out lever + protected pins honored (#142) + +The background consolidation cycle's auto-dedup pass silently concat-merges +near-duplicate memories (cosine ≥ 0.85): it keeps the strongest node, folds the +weaker ones in as `[MERGED]` blocks, and **hard-deletes** the originals — with no +reflog and no way to turn it off. Two fixes. First, it is now disableable: set +`VESTIGE_AUTO_CONSOLIDATE_MERGE=0` (or `false`/`off`/`no`) to suppress it. It +remains **on by default** (behavior unchanged), and the `dedup` MCP tool stays +available for on-demand, previewable, reversible merges regardless. Second, +**protected (pinned) memories are now excluded from this pass** — previously +`dedup protect` did nothing here, so a pinned memory could be absorbed or deleted +unattended, contradicting the interactive contract that a protected node may only +survive a merge, never be absorbed. A protected node is now never an anchor, never +a cluster member, and thus never merged into or deleted, whether the lever is on +or off. + +## [2.2.1] - 2026-07-02 — "Windows embeddings + backfill safety" + +A focused patch release. Two fixes plus a first-run guide. + +### Fixed — Windows embeddings never initialized (#101) + +The `x86_64-pc-windows-msvc` v2.2.0 binary was built without the `vector-search` +feature, so the storage layer's `#[cfg(feature = "vector-search")]` paths compiled +out. On Windows this meant new memories got no embedding, semantic search returned +nothing, `vestige health` reported "Embedding Service: Not Ready" (0% coverage), +and no model download was ever attempted — while v2.1.23 worked on the same machine. +The release build now includes `vector-search` on Windows (it compiles cleanly on +MSVC because `usearch` is pinned with `features = ["fp16lib"]`). npm and direct +downloads are fixed by the same rebuilt release asset. Thanks @Vrakoss for the +precise report. + +### Fixed — Retroactive Salience Backfill: bounded promote + opt-out lever (#103) + +The consolidation-pass backfill promoted root-cause memories with an **uncapped** +`stability * 1.5` FSRS multiply, and a code comment wrongly claimed it was capped. +On a chronically-recurring failure this could inflate a cause's stability without +bound, distorting its review schedule. Backfill promotion is now bounded to +`MIN(stability * 1.5, stability + 365.0)` (the additive +365-day ceiling the +backfill module already computed but never applied), on both the auto-fire and the +manual `backfill` tool paths. Auto-fire remains **on by default** (it shipped and +was documented in v2.2.0) but is now disableable: set `VESTIGE_BACKFILL_AUTOFIRE=0` +(or `false`/`off`/`no`) to turn it off; the manual `backfill` tool + CLI remain +available regardless. Thanks @randomnimbus for the report and the initial patch. + +### Added — First-run guide (#83) + +A single `docs/GETTING-STARTED.md` that consolidates install, "what gets saved", +how to inspect your memory, and project scoping into one 30-minute first-run path, +linked from the README. + +### Credits + +This release was driven by the community: + +- **@Vrakoss** reported the Windows embeddings regression (#101) with a clean, + precise repro that pinned the failure immediately. +- **@randomnimbus** (Peter Lauzon) reported the backfill safety issue (#103) and + contributed the fix — the bounded `promote_memory_backfill` and the + `VESTIGE_BACKFILL_AUTOFIRE` lever shipped as they proposed them + (co-authored in `f7530af`). + +Thank you both. + ## [2.2.0] - 2026-06-29 — "Retroactive Salience + Tool Consolidation" Three independent value streams land together as a coherent release. diff --git a/Cargo.lock b/Cargo.lock index 9574b25..90d70a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4897,7 +4897,7 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vestige-core" -version = "2.2.0" +version = "2.2.1" dependencies = [ "argon2", "blake3", @@ -4938,7 +4938,7 @@ dependencies = [ [[package]] name = "vestige-mcp" -version = "2.2.0" +version = "2.2.1" dependencies = [ "anyhow", "axum", diff --git a/Cargo.toml b/Cargo.toml index 3fa7b4f..9dffd26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ exclude = [ ] [workspace.package] -version = "2.2.0" +version = "2.2.1" edition = "2024" license = "AGPL-3.0-only" repository = "https://github.com/samvallad33/vestige" diff --git a/README.md b/README.md index 625f944..bca1ffc 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ vestige-mcp --version # prints the installed version vestige stats # prints your memory count (0 on a fresh install) ``` -That's the whole install. Per-agent guides (Cursor, VS Code, Windsurf, JetBrains, Xcode, OpenCode, Codex, Claude Desktop) are [here ↓](#-works-with-every-ai-agent). +That's the whole install. New here? The [**30-minute first-run guide**](docs/GETTING-STARTED.md) walks you from install to your first backward-reach: what gets saved (and what doesn't), how to inspect your own memory, and how to scope it per project. Per-agent guides (Cursor, VS Code, Windsurf, JetBrains, Xcode, OpenCode, Codex, Claude Desktop) are [here ↓](#-works-with-every-ai-agent). Now talk to your agent like it has a memory, because now it does: @@ -287,6 +287,7 @@ Registering the server exposes the tools; a short instruction tells the agent *w | | | |---|---| +| [**Getting Started**](docs/GETTING-STARTED.md) | Your first 30 minutes, start to finish | | [**FAQ**](docs/FAQ.md) | 30+ real questions answered | | [**The Science**](docs/SCIENCE.md) | Every feature, every paper | | [**Storage Modes**](docs/STORAGE.md) | Global · per-project · multi-instance | diff --git a/apps/dashboard/build/_app/env.js b/apps/dashboard/build/_app/env.js deleted file mode 100644 index f5427da..0000000 --- a/apps/dashboard/build/_app/env.js +++ /dev/null @@ -1 +0,0 @@ -export const env={} \ No newline at end of file diff --git a/apps/dashboard/build/_app/env.js.br b/apps/dashboard/build/_app/env.js.br deleted file mode 100644 index 30f17bb..0000000 --- a/apps/dashboard/build/_app/env.js.br +++ /dev/null @@ -1 +0,0 @@ - export const env={} \ No newline at end of file diff --git a/apps/dashboard/build/_app/env.js.gz b/apps/dashboard/build/_app/env.js.gz deleted file mode 100644 index e95cbd5..0000000 Binary files a/apps/dashboard/build/_app/env.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/0.CLR80qKm.css b/apps/dashboard/build/_app/immutable/assets/0.CLR80qKm.css deleted file mode 100644 index 87ee11f..0000000 --- a/apps/dashboard/build/_app/immutable/assets/0.CLR80qKm.css +++ /dev/null @@ -1 +0,0 @@ -/*! tailwindcss v4.2.0 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--angle:0deg;--shine:0%}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:"JetBrains Mono", "Fira Code", "SF Mono", monospace;--color-red-400:oklch(70.4% .191 22.216);--color-red-900:oklch(39.6% .141 25.723);--color-red-950:oklch(25.8% .092 26.042);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-xl:36rem;--container-2xl:42rem;--container-5xl:64rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-wider:.05em;--tracking-widest:.1em;--leading-tight:1.25;--leading-snug:1.375;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--ease-in:cubic-bezier(.4, 0, 1, 1);--ease-out:cubic-bezier(0, 0, .2, 1);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-spin:spin 1s linear infinite;--animate-ping:ping 1s cubic-bezier(0, 0, .2, 1) infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--blur-sm:8px;--blur-md:12px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-void:#050510;--color-abyss:#0a0a1a;--color-deep:#10102a;--color-surface:#161638;--color-elevated:#1e1e4a;--color-subtle:#2a2a5e;--color-muted:#4a4a7a;--color-dim:#7a7aaa;--color-text:#e0e0ff;--color-bright:#fff;--color-synapse:#6366f1;--color-synapse-glow:#818cf8;--color-dream:#a855f7;--color-dream-glow:#c084fc;--color-recall:#10b981;--color-decay:#ef4444;--color-warning:#f59e0b;--color-node-pattern:#ec4899}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.visible\!{visibility:visible!important}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing) * 0)}.inset-x-0{inset-inline:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.start\!{inset-inline-start:var(--spacing)!important}.end{inset-inline-end:var(--spacing)}.end\!{inset-inline-end:var(--spacing)!important}.top-0{top:calc(var(--spacing) * 0)}.top-0\.5{top:calc(var(--spacing) * .5)}.top-10{top:calc(var(--spacing) * 10)}.top-20{top:calc(var(--spacing) * 20)}.right-0{right:calc(var(--spacing) * 0)}.right-4{right:calc(var(--spacing) * 4)}.bottom-0{bottom:calc(var(--spacing) * 0)}.bottom-4{bottom:calc(var(--spacing) * 4)}.-left-\[29px\]{left:-29px}.left-0{left:calc(var(--spacing) * 0)}.left-1\/2{left:50%}.left-4{left:calc(var(--spacing) * 4)}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-40{z-index:40}.z-50{z-index:50}.z-\[1\]{z-index:1}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.mx-2{margin-inline:calc(var(--spacing) * 2)}.mx-auto{margin-inline:auto}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-\[-12px\]{margin-top:-12px}.mr-1{margin-right:calc(var(--spacing) * 1)}.mb-0\.5{margin-bottom:calc(var(--spacing) * .5)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.ml-3{margin-left:calc(var(--spacing) * 3)}.ml-auto{margin-left:auto}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-4{-webkit-line-clamp:4;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-flex{display:inline-flex}.table{display:table}.aspect-square{aspect-ratio:1}.h-0\.5{height:calc(var(--spacing) * .5)}.h-1{height:calc(var(--spacing) * 1)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3{height:calc(var(--spacing) * 3)}.h-4{height:calc(var(--spacing) * 4)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-9{height:calc(var(--spacing) * 9)}.h-10{height:calc(var(--spacing) * 10)}.h-11{height:calc(var(--spacing) * 11)}.h-12{height:calc(var(--spacing) * 12)}.h-14{height:calc(var(--spacing) * 14)}.h-16{height:calc(var(--spacing) * 16)}.h-20{height:calc(var(--spacing) * 20)}.h-40{height:calc(var(--spacing) * 40)}.h-\[100dvh\]{height:100dvh}.h-\[520px\]{height:520px}.h-full{height:100%}.h-px{height:1px}.h-screen{height:100vh}.max-h-64{max-height:calc(var(--spacing) * 64)}.max-h-72{max-height:calc(var(--spacing) * 72)}.max-h-96{max-height:calc(var(--spacing) * 96)}.max-h-\[620px\]{max-height:620px}.max-h-dvh{max-height:100dvh}.min-h-0{min-height:calc(var(--spacing) * 0)}.min-h-9{min-height:calc(var(--spacing) * 9)}.min-h-10{min-height:calc(var(--spacing) * 10)}.min-h-\[520px\]{min-height:520px}.min-h-full{min-height:100%}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-2\.5{width:calc(var(--spacing) * 2.5)}.w-3{width:calc(var(--spacing) * 3)}.w-4{width:calc(var(--spacing) * 4)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-9{width:calc(var(--spacing) * 9)}.w-11{width:calc(var(--spacing) * 11)}.w-12{width:calc(var(--spacing) * 12)}.w-14{width:calc(var(--spacing) * 14)}.w-16{width:calc(var(--spacing) * 16)}.w-20{width:calc(var(--spacing) * 20)}.w-24{width:calc(var(--spacing) * 24)}.w-32{width:calc(var(--spacing) * 32)}.w-40{width:calc(var(--spacing) * 40)}.w-96{width:calc(var(--spacing) * 96)}.w-\[3px\]{width:3px}.w-\[6ch\]{width:6ch}.w-\[90\%\]{width:90%}.w-fit{width:fit-content}.w-full{width:100%}.w-px{width:1px}.max-w-2xl{max-width:var(--container-2xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-20{max-width:calc(var(--spacing) * 20)}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-sm{max-width:var(--container-sm)}.max-w-xl{max-width:var(--container-xl)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-10{min-width:calc(var(--spacing) * 10)}.min-w-12{min-width:calc(var(--spacing) * 12)}.min-w-16{min-width:calc(var(--spacing) * 16)}.min-w-64{min-width:calc(var(--spacing) * 64)}.min-w-\[3\.5rem\]{min-width:3.5rem}.flex-1{flex:1}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.border-separate{border-collapse:separate}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.scale-125{--tw-scale-x:125%;--tw-scale-y:125%;--tw-scale-z:125%;scale:var(--tw-scale-x) var(--tw-scale-y)}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-crosshair{cursor:crosshair}.cursor-default{cursor:default}.cursor-none{cursor:none}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.resize{resize:both}.appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-around{justify-content:space-around}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0{gap:calc(var(--spacing) * 0)}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-3\.5{gap:calc(var(--spacing) * 3.5)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-5{gap:calc(var(--spacing) * 5)}.gap-\[2px\]{gap:2px}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-6{column-gap:calc(var(--spacing) * 6)}.gap-y-1{row-gap:calc(var(--spacing) * 1)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overscroll-contain{overscroll-behavior:contain}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-\[\#5dcaa5\]{border-color:#5dcaa5}.border-\[\#5dcaa5\]\/20{border-color:#5dcaa533}.border-\[\#5dcaa5\]\/25{border-color:#5dcaa540}.border-\[\#5dcaa5\]\/40{border-color:#5dcaa566}.border-\[\#22C7DE\]\/25{border-color:#22c7de40}.border-\[\#A33FFF\]\/40{border-color:#a33fff66}.border-\[\#F4F1D0\]\/18{border-color:#f4f1d02e}.border-\[\#FF3B30\]\/20{border-color:#ff3b3033}.border-\[\#FF3B30\]\/24{border-color:#ff3b303d}.border-\[\#FF3B30\]\/35{border-color:#ff3b3059}.border-\[\#ff2d55\]\/40{border-color:#ff2d5566}.border-dream-glow\/40{border-color:#c084fc66}@supports (color:color-mix(in lab,red,red)){.border-dream-glow\/40{border-color:color-mix(in oklab,var(--color-dream-glow) 40%,transparent)}}.border-dream\/20{border-color:#a855f733}@supports (color:color-mix(in lab,red,red)){.border-dream\/20{border-color:color-mix(in oklab,var(--color-dream) 20%,transparent)}}.border-dream\/40{border-color:#a855f766}@supports (color:color-mix(in lab,red,red)){.border-dream\/40{border-color:color-mix(in oklab,var(--color-dream) 40%,transparent)}}.border-recall\/25{border-color:#10b98140}@supports (color:color-mix(in lab,red,red)){.border-recall\/25{border-color:color-mix(in oklab,var(--color-recall) 25%,transparent)}}.border-recall\/40{border-color:#10b98166}@supports (color:color-mix(in lab,red,red)){.border-recall\/40{border-color:color-mix(in oklab,var(--color-recall) 40%,transparent)}}.border-red-900\/50{border-color:#82181a80}@supports (color:color-mix(in lab,red,red)){.border-red-900\/50{border-color:color-mix(in oklab,var(--color-red-900) 50%,transparent)}}.border-subtle\/15{border-color:#2a2a5e26}@supports (color:color-mix(in lab,red,red)){.border-subtle\/15{border-color:color-mix(in oklab,var(--color-subtle) 15%,transparent)}}.border-subtle\/20{border-color:#2a2a5e33}@supports (color:color-mix(in lab,red,red)){.border-subtle\/20{border-color:color-mix(in oklab,var(--color-subtle) 20%,transparent)}}.border-subtle\/30{border-color:#2a2a5e4d}@supports (color:color-mix(in lab,red,red)){.border-subtle\/30{border-color:color-mix(in oklab,var(--color-subtle) 30%,transparent)}}.border-synapse\/5{border-color:#6366f10d}@supports (color:color-mix(in lab,red,red)){.border-synapse\/5{border-color:color-mix(in oklab,var(--color-synapse) 5%,transparent)}}.border-synapse\/10{border-color:#6366f11a}@supports (color:color-mix(in lab,red,red)){.border-synapse\/10{border-color:color-mix(in oklab,var(--color-synapse) 10%,transparent)}}.border-synapse\/15{border-color:#6366f126}@supports (color:color-mix(in lab,red,red)){.border-synapse\/15{border-color:color-mix(in oklab,var(--color-synapse) 15%,transparent)}}.border-synapse\/20{border-color:#6366f133}@supports (color:color-mix(in lab,red,red)){.border-synapse\/20{border-color:color-mix(in oklab,var(--color-synapse) 20%,transparent)}}.border-synapse\/25{border-color:#6366f140}@supports (color:color-mix(in lab,red,red)){.border-synapse\/25{border-color:color-mix(in oklab,var(--color-synapse) 25%,transparent)}}.border-synapse\/30{border-color:#6366f14d}@supports (color:color-mix(in lab,red,red)){.border-synapse\/30{border-color:color-mix(in oklab,var(--color-synapse) 30%,transparent)}}.border-synapse\/40{border-color:#6366f166}@supports (color:color-mix(in lab,red,red)){.border-synapse\/40{border-color:color-mix(in oklab,var(--color-synapse) 40%,transparent)}}.border-transparent{border-color:#0000}.border-warning\/20{border-color:#f59e0b33}@supports (color:color-mix(in lab,red,red)){.border-warning\/20{border-color:color-mix(in oklab,var(--color-warning) 20%,transparent)}}.border-warning\/30{border-color:#f59e0b4d}@supports (color:color-mix(in lab,red,red)){.border-warning\/30{border-color:color-mix(in oklab,var(--color-warning) 30%,transparent)}}.border-warning\/50{border-color:#f59e0b80}@supports (color:color-mix(in lab,red,red)){.border-warning\/50{border-color:color-mix(in oklab,var(--color-warning) 50%,transparent)}}.border-white\/5{border-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.border-white\/5{border-color:color-mix(in oklab,var(--color-white) 5%,transparent)}}.border-t-synapse{border-top-color:var(--color-synapse)}.bg-\[\#1a0508\]\/85{background-color:#1a0508d9}.bg-\[\#5dcaa5\]{background-color:#5dcaa5}.bg-\[\#5dcaa5\]\/15{background-color:#5dcaa526}.bg-\[\#5dcaa5\]\/25{background-color:#5dcaa540}.bg-\[\#03040a\]{background-color:#03040a}.bg-\[\#05060a\]{background-color:#05060a}.bg-\[\#05060a\]\/70{background-color:#05060ab3}.bg-\[\#05060a\]\/80{background-color:#05060acc}.bg-\[\#020307\]{background-color:#020307}.bg-\[\#020307\]\/70{background-color:#020307b3}.bg-\[\#160407\]\/70{background-color:#160407b3}.bg-\[\#A33FFF\]{background-color:#a33fff}.bg-\[\#A33FFF\]\/10{background-color:#a33fff1a}.bg-black\/30{background-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.bg-black\/30{background-color:color-mix(in oklab,var(--color-black) 30%,transparent)}}.bg-black\/40{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.bg-black\/40{background-color:color-mix(in oklab,var(--color-black) 40%,transparent)}}.bg-decay{background-color:var(--color-decay)}.bg-decay\/20{background-color:#ef444433}@supports (color:color-mix(in lab,red,red)){.bg-decay\/20{background-color:color-mix(in oklab,var(--color-decay) 20%,transparent)}}.bg-deep{background-color:var(--color-deep)}.bg-deep\/60{background-color:#10102a99}@supports (color:color-mix(in lab,red,red)){.bg-deep\/60{background-color:color-mix(in oklab,var(--color-deep) 60%,transparent)}}.bg-dream{background-color:var(--color-dream)}.bg-dream\/10{background-color:#a855f71a}@supports (color:color-mix(in lab,red,red)){.bg-dream\/10{background-color:color-mix(in oklab,var(--color-dream) 10%,transparent)}}.bg-dream\/20{background-color:#a855f733}@supports (color:color-mix(in lab,red,red)){.bg-dream\/20{background-color:color-mix(in oklab,var(--color-dream) 20%,transparent)}}.bg-muted{background-color:var(--color-muted)}.bg-node-pattern{background-color:var(--color-node-pattern)}.bg-recall{background-color:var(--color-recall)}.bg-recall\/10{background-color:#10b9811a}@supports (color:color-mix(in lab,red,red)){.bg-recall\/10{background-color:color-mix(in oklab,var(--color-recall) 10%,transparent)}}.bg-recall\/15{background-color:#10b98126}@supports (color:color-mix(in lab,red,red)){.bg-recall\/15{background-color:color-mix(in oklab,var(--color-recall) 15%,transparent)}}.bg-recall\/20{background-color:#10b98133}@supports (color:color-mix(in lab,red,red)){.bg-recall\/20{background-color:color-mix(in oklab,var(--color-recall) 20%,transparent)}}.bg-red-950\/30{background-color:#4608094d}@supports (color:color-mix(in lab,red,red)){.bg-red-950\/30{background-color:color-mix(in oklab,var(--color-red-950) 30%,transparent)}}.bg-synapse-glow{background-color:var(--color-synapse-glow)}.bg-synapse\/10{background-color:#6366f11a}@supports (color:color-mix(in lab,red,red)){.bg-synapse\/10{background-color:color-mix(in oklab,var(--color-synapse) 10%,transparent)}}.bg-synapse\/15{background-color:#6366f126}@supports (color:color-mix(in lab,red,red)){.bg-synapse\/15{background-color:color-mix(in oklab,var(--color-synapse) 15%,transparent)}}.bg-synapse\/20{background-color:#6366f133}@supports (color:color-mix(in lab,red,red)){.bg-synapse\/20{background-color:color-mix(in oklab,var(--color-synapse) 20%,transparent)}}.bg-synapse\/25{background-color:#6366f140}@supports (color:color-mix(in lab,red,red)){.bg-synapse\/25{background-color:color-mix(in oklab,var(--color-synapse) 25%,transparent)}}.bg-synapse\/70{background-color:#6366f1b3}@supports (color:color-mix(in lab,red,red)){.bg-synapse\/70{background-color:color-mix(in oklab,var(--color-synapse) 70%,transparent)}}.bg-transparent{background-color:#0000}.bg-void{background-color:var(--color-void)}.bg-void\/60{background-color:#05051099}@supports (color:color-mix(in lab,red,red)){.bg-void\/60{background-color:color-mix(in oklab,var(--color-void) 60%,transparent)}}.bg-warning{background-color:var(--color-warning)}.bg-warning\/5{background-color:#f59e0b0d}@supports (color:color-mix(in lab,red,red)){.bg-warning\/5{background-color:color-mix(in oklab,var(--color-warning) 5%,transparent)}}.bg-warning\/10{background-color:#f59e0b1a}@supports (color:color-mix(in lab,red,red)){.bg-warning\/10{background-color:color-mix(in oklab,var(--color-warning) 10%,transparent)}}.bg-white\/\[0\.02\]{background-color:#ffffff05}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.02\]{background-color:color-mix(in oklab,var(--color-white) 2%,transparent)}}.bg-white\/\[0\.03\]{background-color:#ffffff08}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.03\]{background-color:color-mix(in oklab,var(--color-white) 3%,transparent)}}.bg-white\/\[0\.04\]{background-color:#ffffff0a}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.04\]{background-color:color-mix(in oklab,var(--color-white) 4%,transparent)}}.bg-white\/\[0\.06\]{background-color:#ffffff0f}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.06\]{background-color:color-mix(in oklab,var(--color-white) 6%,transparent)}}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-\[\#05060a\]\/85{--tw-gradient-from:oklab(12.2919% .000261273 -.0107539/.85);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-dream{--tw-gradient-from:var(--color-dream);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-synapse{--tw-gradient-to:var(--color-synapse);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-transparent{--tw-gradient-to:transparent;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.p-0{padding:calc(var(--spacing) * 0)}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-2{padding:calc(var(--spacing) * 2)}.p-2\.5{padding:calc(var(--spacing) * 2.5)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-5{padding:calc(var(--spacing) * 5)}.p-6{padding:calc(var(--spacing) * 6)}.p-10{padding:calc(var(--spacing) * 10)}.p-12{padding:calc(var(--spacing) * 12)}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-8{padding-inline:calc(var(--spacing) * 8)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-5{padding-block:calc(var(--spacing) * 5)}.py-6{padding-block:calc(var(--spacing) * 6)}.\[padding-top\:max\(0\.75rem\,env\(safe-area-inset-top\)\)\]{padding-top:max(.75rem,env(safe-area-inset-top))}.pt-1{padding-top:calc(var(--spacing) * 1)}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-\[10vh\]{padding-top:10vh}.\[padding-right\:max\(0\.75rem\,env\(safe-area-inset-right\)\)\]{padding-right:max(.75rem,env(safe-area-inset-right))}.pr-1{padding-right:calc(var(--spacing) * 1)}.pr-2{padding-right:calc(var(--spacing) * 2)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pb-16{padding-bottom:calc(var(--spacing) * 16)}.pb-28{padding-bottom:calc(var(--spacing) * 28)}.\[padding-left\:max\(0\.75rem\,env\(safe-area-inset-left\)\)\]{padding-left:max(.75rem,env(safe-area-inset-left))}.pl-6{padding-left:calc(var(--spacing) * 6)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.align-bottom{vertical-align:bottom}.font-mono{font-family:var(--font-mono)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[13px\]{font-size:13px}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[0\.2em\]{--tw-tracking:.2em;letter-spacing:.2em}.tracking-\[0\.12em\]{--tw-tracking:.12em;letter-spacing:.12em}.tracking-\[0\.15em\]{--tw-tracking:.15em;letter-spacing:.15em}.tracking-\[0\.18em\]{--tw-tracking:.18em;letter-spacing:.18em}.tracking-\[0\.22em\]{--tw-tracking:.22em;letter-spacing:.22em}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.text-balance{text-wrap:balance}.text-pretty{text-wrap:pretty}.text-wrap{text-wrap:wrap}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[\#5dcaa5\]{color:#5dcaa5}.text-\[\#5dcaa5\]\/60{color:#5dcaa599}.text-\[\#5dcaa5\]\/70{color:#5dcaa5b3}.text-\[\#7fe6c0\]{color:#7fe6c0}.text-\[\#22C7DE\]\/60{color:#22c7de99}.text-\[\#22C7DE\]\/80{color:#22c7decc}.text-\[\#05060a\]{color:#05060a}.text-\[\#E4C8FF\]{color:#e4c8ff}.text-\[\#F4F1D0\]{color:#f4f1d0}.text-\[\#FF3B30\]{color:#ff3b30}.text-\[\#a6dcff\]{color:#a6dcff}.text-\[\#ff5c78\]{color:#ff5c78}.text-\[\#ff5c78\]\/70{color:#ff5c78b3}.text-\[\#ffd0d8\]{color:#ffd0d8}.text-\[\#ffffff\]\/\[0\.5\]{color:#ffffff80}.text-\[\#ffffff\]\/\[0\.55\]{color:#ffffff8c}.text-bright{color:var(--color-bright)}.text-decay{color:var(--color-decay)}.text-dim{color:var(--color-dim)}.text-dream-glow{color:var(--color-dream-glow)}.text-dream\/80{color:#a855f7cc}@supports (color:color-mix(in lab,red,red)){.text-dream\/80{color:color-mix(in oklab,var(--color-dream) 80%,transparent)}}.text-muted{color:var(--color-muted)}.text-muted\/50{color:#4a4a7a80}@supports (color:color-mix(in lab,red,red)){.text-muted\/50{color:color-mix(in oklab,var(--color-muted) 50%,transparent)}}.text-muted\/60{color:#4a4a7a99}@supports (color:color-mix(in lab,red,red)){.text-muted\/60{color:color-mix(in oklab,var(--color-muted) 60%,transparent)}}.text-node-pattern{color:var(--color-node-pattern)}.text-recall{color:var(--color-recall)}.text-red-400{color:var(--color-red-400)}.text-subtle{color:var(--color-subtle)}.text-synapse{color:var(--color-synapse)}.text-synapse-glow{color:var(--color-synapse-glow)}.text-text{color:var(--color-text)}.text-text\/80{color:#e0e0ffcc}@supports (color:color-mix(in lab,red,red)){.text-text\/80{color:color-mix(in oklab,var(--color-text) 80%,transparent)}}.text-warning{color:var(--color-warning)}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.\[font-variant-numeric\:tabular-nums\]{font-variant-numeric:tabular-nums}.underline-offset-4{text-underline-offset:4px}.accent-\[\#22C7DE\]{accent-color:#22c7de}.accent-synapse{accent-color:var(--color-synapse)}.opacity-35{opacity:.35}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow\!{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a)!important;box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)!important}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_10px_rgba\(239\,68\,68\,0\.7\)\]{--tw-shadow:0 0 10px var(--tw-shadow-color,#ef4444b3);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_12px_rgba\(99\,102\,241\,0\.15\)\]{--tw-shadow:0 0 12px var(--tw-shadow-color,#6366f126);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_12px_rgba\(99\,102\,241\,0\.18\)\]{--tw-shadow:0 0 12px var(--tw-shadow-color,#6366f12e);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_12px_rgba\(163\,63\,255\,0\.15\)\]{--tw-shadow:0 0 12px var(--tw-shadow-color,#a33fff26);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_16px_rgba\(99\,102\,241\,0\.3\)\]{--tw-shadow:0 0 16px var(--tw-shadow-color,#6366f14d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_16px_rgba\(168\,85\,247\,0\.3\)\]{--tw-shadow:0 0 16px var(--tw-shadow-color,#a855f74d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_40px_rgba\(255\,59\,48\,0\.12\)\]{--tw-shadow:0 0 40px var(--tw-shadow-color,#ff3b301f);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring,.ring-1{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-synapse\/10{--tw-shadow-color:#6366f11a}@supports (color:color-mix(in lab,red,red)){.shadow-synapse\/10{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-synapse) 10%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-synapse\/20{--tw-shadow-color:#6366f133}@supports (color:color-mix(in lab,red,red)){.shadow-synapse\/20{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-synapse) 20%, transparent) var(--tw-shadow-alpha), transparent)}}.ring-dream-glow{--tw-ring-color:var(--color-dream-glow)}.ring-dream\/60{--tw-ring-color:#a855f799}@supports (color:color-mix(in lab,red,red)){.ring-dream\/60{--tw-ring-color:color-mix(in oklab, var(--color-dream) 60%, transparent)}}.ring-recall\/30{--tw-ring-color:#10b9814d}@supports (color:color-mix(in lab,red,red)){.ring-recall\/30{--tw-ring-color:color-mix(in oklab, var(--color-recall) 30%, transparent)}}.ring-synapse\/60{--tw-ring-color:#6366f199}@supports (color:color-mix(in lab,red,red)){.ring-synapse\/60{--tw-ring-color:color-mix(in oklab, var(--color-synapse) 60%, transparent)}}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.drop-shadow{--tw-drop-shadow-size:drop-shadow(0 1px 2px var(--tw-drop-shadow-color,#0000001a)) drop-shadow(0 1px 1px var(--tw-drop-shadow-color,#0000000f));--tw-drop-shadow:drop-shadow(0 1px 2px #0000001a) drop-shadow(0 1px 1px #0000000f);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.invert{--tw-invert:invert(100%);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.filter\!{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)!important}.backdrop-blur-md{--tw-backdrop-blur:blur(var(--blur-md));-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.backdrop-filter{-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-500{--tw-duration:.5s;transition-duration:.5s}.duration-700{--tw-duration:.7s;transition-duration:.7s}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.select-none{-webkit-user-select:none;user-select:none}@media(hover:hover){.group-hover\:scale-110:is(:where(.group):hover *){--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x) var(--tw-scale-y)}}.placeholder\:text-muted::placeholder{color:var(--color-muted)}@media(hover:hover){.hover\:z-10:hover{z-index:10}.hover\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x) var(--tw-scale-y)}.hover\:scale-\[1\.03\]:hover{scale:1.03}.hover\:rotate-180:hover{rotate:180deg}.hover\:border-\[\#5dcaa5\]\/50:hover{border-color:#5dcaa580}.hover\:border-\[\#5dcaa5\]\/60:hover{border-color:#5dcaa599}.hover\:border-\[\#22C7DE\]\/50:hover{border-color:#22c7de80}.hover\:border-\[\#FF3B30\]\/40:hover{border-color:#ff3b3066}.hover\:border-synapse\/20:hover{border-color:#6366f133}@supports (color:color-mix(in lab,red,red)){.hover\:border-synapse\/20:hover{border-color:color-mix(in oklab,var(--color-synapse) 20%,transparent)}}.hover\:border-synapse\/30:hover{border-color:#6366f14d}@supports (color:color-mix(in lab,red,red)){.hover\:border-synapse\/30:hover{border-color:color-mix(in oklab,var(--color-synapse) 30%,transparent)}}.hover\:bg-\[\#5dcaa5\]\/25:hover{background-color:#5dcaa540}.hover\:bg-decay\/30:hover{background-color:#ef44444d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-decay\/30:hover{background-color:color-mix(in oklab,var(--color-decay) 30%,transparent)}}.hover\:bg-dream\/20:hover{background-color:#a855f733}@supports (color:color-mix(in lab,red,red)){.hover\:bg-dream\/20:hover{background-color:color-mix(in oklab,var(--color-dream) 20%,transparent)}}.hover\:bg-dream\/30:hover{background-color:#a855f74d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-dream\/30:hover{background-color:color-mix(in oklab,var(--color-dream) 30%,transparent)}}.hover\:bg-recall\/30:hover{background-color:#10b9814d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-recall\/30:hover{background-color:color-mix(in oklab,var(--color-recall) 30%,transparent)}}.hover\:bg-synapse\/30:hover{background-color:#6366f14d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-synapse\/30:hover{background-color:color-mix(in oklab,var(--color-synapse) 30%,transparent)}}.hover\:bg-white\/\[0\.02\]:hover{background-color:#ffffff05}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.02\]:hover{background-color:color-mix(in oklab,var(--color-white) 2%,transparent)}}.hover\:bg-white\/\[0\.03\]:hover{background-color:#ffffff08}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.03\]:hover{background-color:color-mix(in oklab,var(--color-white) 3%,transparent)}}.hover\:bg-white\/\[0\.04\]:hover{background-color:#ffffff0a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.04\]:hover{background-color:color-mix(in oklab,var(--color-white) 4%,transparent)}}.hover\:bg-white\/\[0\.08\]:hover{background-color:#ffffff14}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.08\]:hover{background-color:color-mix(in oklab,var(--color-white) 8%,transparent)}}.hover\:text-\[\#5dcaa5\]:hover{color:#5dcaa5}.hover\:text-\[\#22C7DE\]:hover{color:#22c7de}.hover\:text-\[\#FF3B30\]:hover{color:#ff3b30}.hover\:text-bright:hover{color:var(--color-bright)}.hover\:text-dim:hover{color:var(--color-dim)}.hover\:text-text:hover{color:var(--color-text)}.hover\:underline:hover{text-decoration-line:underline}}.focus\:\!border-synapse\/40:focus{border-color:#6366f166!important}@supports (color:color-mix(in lab,red,red)){.focus\:\!border-synapse\/40:focus{border-color:color-mix(in oklab,var(--color-synapse) 40%,transparent)!important}}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-synapse-glow:focus{--tw-ring-color:var(--color-synapse-glow)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-dream-glow\/60:focus-visible{--tw-ring-color:#c084fc99}@supports (color:color-mix(in lab,red,red)){.focus-visible\:ring-dream-glow\/60:focus-visible{--tw-ring-color:color-mix(in oklab, var(--color-dream-glow) 60%, transparent)}}.focus-visible\:ring-synapse\/60:focus-visible{--tw-ring-color:#6366f199}@supports (color:color-mix(in lab,red,red)){.focus-visible\:ring-synapse\/60:focus-visible{--tw-ring-color:color-mix(in oklab, var(--color-synapse) 60%, transparent)}}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media(min-width:40rem){.sm\:top-4{top:calc(var(--spacing) * 4)}.sm\:right-4{right:calc(var(--spacing) * 4)}.sm\:left-4{left:calc(var(--spacing) * 4)}.sm\:ml-auto{margin-left:auto}.sm\:block{display:block}.sm\:flex{display:flex}.sm\:w-56{width:calc(var(--spacing) * 56)}.sm\:w-auto{width:auto}.sm\:max-w-md{max-width:var(--container-md)}.sm\:flex-1{flex:1}.sm\:gap-3{gap:calc(var(--spacing) * 3)}.sm\:p-0{padding:calc(var(--spacing) * 0)}.sm\:\[padding-top\:0\]{padding-top:0}.sm\:\[padding-right\:0\]{padding-right:0}.sm\:\[padding-left\:0\]{padding-left:0}.sm\:text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}}@media(min-width:48rem){.md\:block{display:block}.md\:flex{display:flex}.md\:hidden{display:none}.md\:inline{display:inline}.md\:inline-flex{display:inline-flex}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:flex-row{flex-direction:row}.md\:pt-\[15vh\]{padding-top:15vh}.md\:pb-0{padding-bottom:calc(var(--spacing) * 0)}}@media(min-width:64rem){.lg\:block{display:block}.lg\:inline{display:inline}.lg\:inline-flex{display:inline-flex}.lg\:w-56{width:calc(var(--spacing) * 56)}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-\[1fr_340px\]{grid-template-columns:1fr 340px}.lg\:grid-cols-\[minmax\(0\,0\.9fr\)_380px\]{grid-template-columns:minmax(0,.9fr) 380px}}.\[\&\:\:-webkit-slider-thumb\]\:h-3::-webkit-slider-thumb{height:calc(var(--spacing) * 3)}.\[\&\:\:-webkit-slider-thumb\]\:w-3::-webkit-slider-thumb{width:calc(var(--spacing) * 3)}.\[\&\:\:-webkit-slider-thumb\]\:appearance-none::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none}.\[\&\:\:-webkit-slider-thumb\]\:rounded-full::-webkit-slider-thumb{border-radius:3.40282e38px}.\[\&\:\:-webkit-slider-thumb\]\:bg-synapse-glow::-webkit-slider-thumb{background-color:var(--color-synapse-glow)}.\[\&\:\:-webkit-slider-thumb\]\:shadow-\[0_0_8px_rgba\(129\,140\,248\,0\.4\)\]::-webkit-slider-thumb{--tw-shadow:0 0 8px var(--tw-shadow-color,#818cf866);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}html{background:var(--color-void);color:var(--color-text);font-family:var(--font-mono)}@supports (color:oklch(0 0 0)){:root{--color-synapse:oklch(58.5% .222 277);--color-synapse-glow:oklch(68.5% .169 277);--color-dream:oklch(62.7% .265 304);--color-dream-glow:oklch(71.4% .203 305);--color-memory:oklch(62.3% .214 259);--color-recall:oklch(69.6% .17 162);--color-decay:oklch(63.7% .237 25);--color-warning:oklch(76.9% .188 70);--color-node-fact:oklch(62.3% .214 259);--color-node-concept:oklch(60.6% .25 292);--color-node-event:oklch(76.9% .188 70);--color-node-person:oklch(69.6% .17 162);--color-node-place:oklch(71.5% .143 215);--color-node-note:oklch(55.1% .027 264);--color-node-pattern:oklch(65.6% .241 354);--color-node-decision:oklch(63.7% .237 25)}}body{min-height:100vh;margin:0;overflow:hidden}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:0 0}::-webkit-scrollbar-thumb{background:var(--color-subtle);border-radius:3px}::-webkit-scrollbar-thumb:hover{background:var(--color-muted)}.glass{-webkit-backdrop-filter:blur(20px)saturate(180%);background:#16163873;border:1px solid #6366f114;box-shadow:inset 0 1px #ffffff08,0 4px 24px #0000004d}.glass-subtle{-webkit-backdrop-filter:blur(12px)saturate(150%);background:#10102a66;border:1px solid #6366f10f;box-shadow:inset 0 1px #ffffff05,0 2px 12px #0003}.glass-sidebar{-webkit-backdrop-filter:blur(24px)saturate(180%);background:#0a0a1a99;border-right:1px solid #6366f11a;box-shadow:inset -1px 0 #ffffff05,4px 0 24px #0000004d}.glass-panel{-webkit-backdrop-filter:blur(24px)saturate(180%);background:#0a0a1acc;border:1px solid #6366f11a;box-shadow:inset 0 1px #ffffff08,0 8px 32px #0006}.glow-synapse{box-shadow:0 0 20px #6366f14d,0 0 60px #6366f11a}.glow-dream{box-shadow:0 0 20px #a855f74d,0 0 60px #a855f71a}.glow-memory{box-shadow:0 0 20px #3b82f64d,0 0 60px #3b82f61a}@keyframes pulse-glow{0%,to{opacity:1}50%{opacity:.5}}.animate-pulse-glow{animation:2s ease-in-out infinite pulse-glow}@keyframes orb-float-1{0%,to{transform:translate(0)scale(1)}25%{transform:translate(60px,-40px)scale(1.1)}50%{transform:translate(-30px,-80px)scale(.95)}75%{transform:translate(-60px,-20px)scale(1.05)}}@keyframes orb-float-2{0%,to{transform:translate(0)scale(1)}25%{transform:translate(-50px,30px)scale(1.08)}50%{transform:translate(40px,60px)scale(.92)}75%{transform:translate(20px,-40px)scale(1.03)}}@keyframes orb-float-3{0%,to{transform:translate(0)scale(1)}25%{transform:translate(30px,50px)scale(1.05)}50%{transform:translate(-60px,20px)scale(.98)}75%{transform:translate(40px,-30px)scale(1.1)}}.ambient-orb{filter:blur(80px);pointer-events:none;z-index:0;opacity:.35;border-radius:50%;position:fixed}.ambient-orb-1{background:radial-gradient(circle,#a855f766,#0000 70%);width:400px;height:400px;animation:20s ease-in-out infinite orb-float-1;top:-10%;right:-5%}.ambient-orb-2{background:radial-gradient(circle,#6366f159,#0000 70%);width:350px;height:350px;animation:25s ease-in-out infinite orb-float-2;bottom:-15%;left:-5%}.ambient-orb-3{background:radial-gradient(circle,#f59e0b33,#0000 70%);width:300px;height:300px;animation:22s ease-in-out infinite orb-float-3;top:40%;left:40%}.nav-active-border{position:relative}.nav-active-border:before{content:"";background:linear-gradient(180deg,var(--color-synapse),var(--color-dream),var(--color-synapse));background-size:100% 200%;border-radius:1px;width:2px;animation:3s ease-in-out infinite gradient-shift;position:absolute;top:4px;bottom:4px;left:0}@keyframes gradient-shift{0%,to{background-position:0 0}50%{background-position:0 100%}}@keyframes float{0%,to{transform:translateY(0)translate(0)}25%{transform:translateY(-10px)translate(5px)}50%{transform:translateY(-5px)translate(-5px)}75%{transform:translateY(-15px)translate(3px)}}.retention-critical{color:var(--color-decay)}.retention-low{color:var(--color-warning)}.retention-good{color:var(--color-recall)}.retention-strong{color:var(--color-synapse)}@media not all and (prefers-reduced-motion:reduce){::view-transition-old(root){animation-duration:.18s;animation-timing-function:ease}::view-transition-new(root){animation-duration:.18s;animation-timing-function:ease}::view-transition-old(root){animation-name:vt-fade-out}::view-transition-new(root){animation-name:vt-fade-in}@keyframes vt-fade-out{0%{opacity:1}to{opacity:0}}@keyframes vt-fade-in{0%{opacity:0}to{opacity:1}}}@property --angle{syntax:"";inherits:false;initial-value:0deg}@property --shine{syntax:"";inherits:false;initial-value:0%}.reveal{opacity:0;transform:translateY(var(--reveal-y,16px));transition:opacity .55s cubic-bezier(.22,1,.36,1),transform .55s cubic-bezier(.22,1,.36,1);transition-delay:var(--reveal-delay,0s);will-change:opacity,transform}.reveal-in{opacity:1;transform:none}@media(prefers-reduced-motion:reduce){.reveal{opacity:1;transition:none;transform:none}}@media not all and (prefers-reduced-motion:reduce){.enter{transition:opacity .4s,transform .4s cubic-bezier(.22,1,.36,1)}@starting-style{.enter{opacity:0;transform:translateY(10px)}}}.live-border{isolation:isolate;position:relative}.live-border:before{content:"";border-radius:inherit;background:conic-gradient(from var(--angle),transparent 0%,var(--color-synapse) 18%,var(--color-dream) 33%,transparent 50%,transparent 100%);pointer-events:none;opacity:.6;z-index:-1;padding:1px;position:absolute;top:-1px;right:-1px;bottom:-1px;left:-1px;-webkit-mask-image:linear-gradient(#000 0 0),linear-gradient(#000 0 0);-webkit-mask-position:0 0,0 0;-webkit-mask-size:auto,auto;-webkit-mask-repeat:repeat,repeat;-webkit-mask-clip:content-box,border-box;-webkit-mask-origin:content-box,border-box;-webkit-mask-composite:xor;mask-composite:exclude;-webkit-mask-source-type:auto,auto;mask-mode:match-source,match-source}@media not all and (prefers-reduced-motion:reduce){.live-border:before{animation:6s linear infinite border-rotate}@keyframes border-rotate{to{--angle:360deg}}}.spotlight-surface{position:relative;overflow:hidden}.spotlight-surface:after{content:"";pointer-events:none;background:radial-gradient(340px circle at var(--spot-x,50%) var(--spot-y,50%),#818cf81f,transparent 60%);opacity:var(--spot-o,0);z-index:0;transition:opacity .3s;position:absolute;top:0;right:0;bottom:0;left:0}.tilt-glare{position:relative;overflow:hidden}.tilt-glare:after{content:"";pointer-events:none;background:radial-gradient(circle at var(--glare-x,50%) var(--glare-y,50%),#ffffff24,transparent 45%);opacity:var(--glare-o,0);transition:opacity .3s;position:absolute;top:0;right:0;bottom:0;left:0}.breathe{animation:3.2s ease-in-out infinite breathe}@keyframes breathe{0%,to{filter:drop-shadow(0 0 2px);opacity:.85;transform:scale(1)}50%{filter:drop-shadow(0 0 7px);opacity:1;transform:scale(1.18)}}@media(prefers-reduced-motion:reduce){.breathe{animation:none}}.ping-host{position:relative}.ping-host:before{content:"";opacity:.6;z-index:-1;background:currentColor;border-radius:50%;position:absolute;top:0;right:0;bottom:0;left:0}@media not all and (prefers-reduced-motion:reduce){.ping-host:before{animation:2.4s cubic-bezier(0,0,.2,1) infinite ping}@keyframes ping{0%{opacity:.5;transform:scale(1)}80%,to{opacity:0;transform:scale(2.6)}}}.shimmer{background:#ffffff08;position:relative;overflow:hidden}.shimmer:after{content:"";background:linear-gradient(90deg,#0000,#818cf81f,#0000);position:absolute;top:0;right:0;bottom:0;left:0;transform:translate(-100%)}@media not all and (prefers-reduced-motion:reduce){.shimmer:after{animation:1.6s ease-in-out infinite shimmer}@keyframes shimmer{to{transform:translate(100%)}}}.text-aurora{background:linear-gradient(100deg,var(--color-synapse-glow),var(--color-dream-glow),var(--color-recall),var(--color-synapse-glow));color:#0000;background-size:250% 100%;-webkit-background-clip:text;background-clip:text}@media not all and (prefers-reduced-motion:reduce){.text-aurora{animation:8s ease-in-out infinite aurora-drift}@keyframes aurora-drift{0%,to{background-position:0%}50%{background-position:100%}}}.lift{transition:transform .28s cubic-bezier(.34,1.56,.64,1),box-shadow .28s,border-color .28s}.lift:hover{transform:translateY(-3px);box-shadow:0 12px 32px #00000059,0 0 0 1px #6366f12e}@media(prefers-reduced-motion:reduce){.lift:hover{transform:none}}.tabular-nums{font-variant-numeric:tabular-nums;font-feature-settings:"tnum"}:where(button,a,input,select,[role=button],[tabindex]):focus-visible{outline:2px solid var(--color-synapse-glow);outline-offset:2px;border-radius:.4rem}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}.toast-layer.svelte-pry2ep{position:fixed;z-index:60;pointer-events:none;display:flex;flex-direction:column;gap:.5rem;right:1.25rem;bottom:1.25rem;max-width:22rem;width:calc(100vw - 2.5rem)}@media(max-width:768px){.toast-layer.svelte-pry2ep{right:.75rem;left:.75rem;bottom:auto;top:5.25rem;max-width:none;width:auto;align-items:stretch}}.toast-item.svelte-pry2ep{pointer-events:auto;position:relative;display:flex;gap:.75rem;align-items:stretch;text-align:left;font:inherit;color:inherit;background:#0c0e16b8;backdrop-filter:blur(14px) saturate(160%);-webkit-backdrop-filter:blur(14px) saturate(160%);border:1px solid rgba(255,255,255,.06);border-radius:.75rem;padding:.75rem .9rem .75rem .5rem;overflow:hidden;box-shadow:0 10px 40px -12px #000c,0 0 22px -6px var(--toast-color);cursor:pointer;animation:svelte-pry2ep-toast-in .32s cubic-bezier(.16,1,.3,1);transform-origin:right center;transition:transform .15s ease,box-shadow .15s ease}.toast-item.svelte-pry2ep:hover{transform:translateY(-1px) scale(1.015);box-shadow:0 14px 48px -12px #000000d9,0 0 32px -4px var(--toast-color)}.toast-item.svelte-pry2ep:focus-visible{outline:1px solid var(--toast-color);outline-offset:2px}.toast-accent.svelte-pry2ep{width:3px;border-radius:2px;background:var(--toast-color);box-shadow:0 0 10px var(--toast-color);flex-shrink:0}.toast-body.svelte-pry2ep{display:flex;flex-direction:column;gap:.15rem;flex:1;min-width:0}.toast-head.svelte-pry2ep{display:flex;align-items:center;gap:.5rem}.toast-icon.svelte-pry2ep{color:var(--toast-color);font-size:.95rem;text-shadow:0 0 8px var(--toast-color);line-height:1;width:1rem;display:inline-flex;justify-content:center}.toast-title.svelte-pry2ep{color:#f5f5fa;font-size:.82rem;font-weight:600;letter-spacing:.01em}.toast-sub.svelte-pry2ep{color:#b0b6c4;font-size:.74rem;line-height:1.35;padding-left:1.5rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.toast-progress.svelte-pry2ep{position:absolute;left:0;bottom:0;height:2px;width:100%;background:#ffffff0a}.toast-progress-fill.svelte-pry2ep{height:100%;background:var(--toast-color);opacity:.55;transform-origin:left center;animation:svelte-pry2ep-toast-progress var(--toast-dwell) linear forwards}.toast-item.svelte-pry2ep:hover .toast-progress-fill:where(.svelte-pry2ep),.toast-item.svelte-pry2ep:focus-visible .toast-progress-fill:where(.svelte-pry2ep){animation-play-state:paused}@keyframes svelte-pry2ep-toast-in{0%{opacity:0;transform:translate(24px) scale(.98)}to{opacity:1;transform:translate(0) scale(1)}}@media(max-width:768px){.toast-item.svelte-pry2ep{transform-origin:top center;animation:svelte-pry2ep-toast-in-mobile .3s cubic-bezier(.16,1,.3,1)}}@keyframes svelte-pry2ep-toast-in-mobile{0%{opacity:0;transform:translateY(-12px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}@keyframes svelte-pry2ep-toast-progress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}@media(prefers-reduced-motion:reduce){.toast-item.svelte-pry2ep{animation:none}.toast-progress-fill.svelte-pry2ep{animation:none;transform:scaleX(.5)}}.strip-item.svelte-1kk3799{display:inline-flex;align-items:center;gap:.4rem;padding:0 .75rem;white-space:nowrap;flex-shrink:0}.strip-divider.svelte-1kk3799{width:1px;height:14px;background:#6366f11f;flex-shrink:0}.ambient-strip.ambient-flash.svelte-1kk3799{background:linear-gradient(90deg,#ef444414,#ef444400 70%),#0006;border-bottom-color:#ef444459;transition:background .3s ease,border-color .3s ease}@keyframes svelte-1kk3799-ping-slow{0%{transform:scale(1);opacity:.8}80%,to{transform:scale(2);opacity:0}}.animate-ping-slow{animation:svelte-1kk3799-ping-slow 2.2s cubic-bezier(0,0,.2,1) infinite}@media(prefers-reduced-motion:reduce){.ambient-strip.svelte-1kk3799 .animate-ping,.ambient-strip.svelte-1kk3799 .animate-ping-slow,.ambient-strip.svelte-1kk3799 .animate-pulse{animation:none!important}}.verdict-bar.svelte-1j425e6{border-bottom:1px solid rgba(255,255,255,.06);background:#080912b8;backdrop-filter:blur(18px) saturate(160%);-webkit-backdrop-filter:blur(18px) saturate(160%);box-shadow:0 6px 24px #0000002e}.verdict-summary.svelte-1j425e6{width:100%;min-height:2.75rem;display:grid;grid-template-columns:auto auto minmax(0,1fr) auto;align-items:center;gap:.75rem;padding:.55rem 1rem;color:var(--color-text);text-align:left;font:inherit}.sr-only.svelte-1j425e6{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.label.svelte-1j425e6,.field-label.svelte-1j425e6,.appeal-row.svelte-1j425e6>span:where(.svelte-1j425e6){color:var(--color-dim);font-size:.68rem;text-transform:uppercase;letter-spacing:0}.levels.svelte-1j425e6{display:flex;align-items:center;gap:.25rem}.levels.svelte-1j425e6 span:where(.svelte-1j425e6){border:1px solid rgba(255,255,255,.08);border-radius:.35rem;padding:.18rem .38rem;color:var(--color-muted);font-size:.64rem;line-height:1}.levels.svelte-1j425e6 span.active:where(.svelte-1j425e6){color:var(--color-bright);border-color:var(--verdict-color);background:color-mix(in srgb,var(--verdict-color) 18%,transparent);box-shadow:0 0 14px color-mix(in srgb,var(--verdict-color) 28%,transparent)}.summary-text.svelte-1j425e6{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.78rem;color:var(--color-dim)}.when.svelte-1j425e6{color:var(--color-muted);font-size:.68rem}.receipt.svelte-1j425e6{margin:0 1rem .75rem;border:1px solid rgba(255,255,255,.08);border-radius:.5rem;background:#0a0a1ac7;padding:.85rem}.receipt-grid.svelte-1j425e6{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(10rem,.8fr) minmax(0,1.1fr) minmax(0,1.1fr);gap:.85rem}.receipt.svelte-1j425e6 p:where(.svelte-1j425e6),.receipt.svelte-1j425e6 li:where(.svelte-1j425e6){margin:.25rem 0 0;color:var(--color-text);font-size:.76rem;line-height:1.45;overflow-wrap:anywhere}.receipt.svelte-1j425e6 ul:where(.svelte-1j425e6){margin:.25rem 0 0;padding-left:1rem}.appeal-row.svelte-1j425e6{display:flex;align-items:center;gap:.4rem;margin-top:.85rem;flex-wrap:wrap}.appeal-row.svelte-1j425e6 button:where(.svelte-1j425e6),.appeal-row.svelte-1j425e6 p:where(.svelte-1j425e6){border:1px solid rgba(255,255,255,.1);border-radius:.4rem;padding:.35rem .6rem;color:var(--color-text);background:#ffffff0a;font-size:.72rem;margin:0}.appeal-row.svelte-1j425e6 button:where(.svelte-1j425e6):hover:not(:disabled),.verdict-summary.svelte-1j425e6:hover{background:#ffffff0d}.appeal-row.svelte-1j425e6 button:where(.svelte-1j425e6):disabled{opacity:.55;cursor:wait}.tone-pass.svelte-1j425e6,.tone-note.svelte-1j425e6{--verdict-color: #10b981}.tone-caution.svelte-1j425e6{--verdict-color: #f59e0b}.tone-veto.svelte-1j425e6{--verdict-color: #ef4444}.tone-appealed.svelte-1j425e6{--verdict-color: #818cf8}@media(max-width:900px){.verdict-summary.svelte-1j425e6{grid-template-columns:auto minmax(0,1fr) auto}.levels.svelte-1j425e6{grid-column:1 / -1;order:4;overflow-x:auto;padding-bottom:.1rem}.receipt-grid.svelte-1j425e6{grid-template-columns:1fr}}.theme-toggle.svelte-1cmi4dh{width:30px;height:30px;display:inline-flex;align-items:center;justify-content:center;padding:0;border-radius:8px;background:#6366f10f;border:1px solid rgba(99,102,241,.14);color:var(--color-text);cursor:pointer;transition:background .2s ease,border-color .2s ease,color .2s ease,transform .12s ease;-webkit-tap-highlight-color:transparent}.theme-toggle.svelte-1cmi4dh:hover{background:#6366f124;border-color:#6366f14d;color:var(--color-bright)}.theme-toggle.svelte-1cmi4dh:active{transform:scale(.94)}.theme-toggle.svelte-1cmi4dh:focus-visible{outline:1px solid var(--color-synapse);outline-offset:2px}.icon-wrap.svelte-1cmi4dh{position:relative;width:18px;height:18px;display:inline-block}.icon.svelte-1cmi4dh{position:absolute;top:0;right:0;bottom:0;left:0;width:18px;height:18px;opacity:0;transform:scale(.7) rotate(-30deg);transition:opacity .2s ease,transform .2s cubic-bezier(.16,1,.3,1);pointer-events:none}.icon.active.svelte-1cmi4dh{opacity:1;transform:scale(1) rotate(0)}.theme-toggle[data-mode=dark].svelte-1cmi4dh{color:var(--color-synapse-glow, #818cf8)}.theme-toggle[data-mode=light].svelte-1cmi4dh{color:var(--color-warning, #f59e0b)}.theme-toggle[data-mode=auto].svelte-1cmi4dh{color:var(--color-dream-glow, #c084fc)}@media(prefers-reduced-motion:reduce){.theme-toggle.svelte-1cmi4dh,.icon.svelte-1cmi4dh{transition:none}}.safe-bottom.svelte-12qhfyh{padding-bottom:env(safe-area-inset-bottom,0px)}.logo-mark.svelte-12qhfyh{transition:transform .3s cubic-bezier(.34,1.56,.64,1),box-shadow .3s ease}.logo-link.svelte-12qhfyh:hover .logo-mark:where(.svelte-12qhfyh){transform:rotate(-6deg) scale(1.08);box-shadow:0 0 0 1px #818cf866,0 0 22px #6366f180}.nav-link.text-synapse-glow.svelte-12qhfyh .nav-icon:where(.svelte-12qhfyh) svg,.nav-active-border.svelte-12qhfyh .nav-icon:where(.svelte-12qhfyh) svg{filter:drop-shadow(0 0 6px rgba(129,140,248,.55))} diff --git a/apps/dashboard/build/_app/immutable/assets/0.CLR80qKm.css.br b/apps/dashboard/build/_app/immutable/assets/0.CLR80qKm.css.br deleted file mode 100644 index a466de3..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/0.CLR80qKm.css.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/0.CLR80qKm.css.gz b/apps/dashboard/build/_app/immutable/assets/0.CLR80qKm.css.gz deleted file mode 100644 index cc7c9c8..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/0.CLR80qKm.css.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/12.BxoW8Jf1.css b/apps/dashboard/build/_app/immutable/assets/12.BxoW8Jf1.css deleted file mode 100644 index 79f5904..0000000 --- a/apps/dashboard/build/_app/immutable/assets/12.BxoW8Jf1.css +++ /dev/null @@ -1 +0,0 @@ -.cinema-overlay.svelte-1uwqs3k{position:fixed;top:0;right:0;bottom:0;left:0;z-index:200;background:radial-gradient(circle at 50% 40%,#05050f,#010108);display:flex;flex-direction:column}body.cinema-open .graph-stats-pill{display:none}.cinema-canvas.svelte-1uwqs3k{position:absolute;top:0;right:0;bottom:0;left:0;z-index:0}.cinema-top.svelte-1uwqs3k{position:relative;z-index:2;display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:max(.75rem,env(safe-area-inset-top)) 1rem .75rem;flex-wrap:wrap}.cinema-badge.svelte-1uwqs3k{font-size:.65rem;padding:.1rem .45rem;border-radius:999px;border:1px solid rgba(129,140,248,.4);color:var(--color-synapse-glow)}.cinema-badge-gpu.svelte-1uwqs3k{border-color:#14e8c680;color:#14e8c6}.cinema-act.svelte-1uwqs3k{font-size:.6rem;letter-spacing:.12em;text-transform:uppercase;color:var(--color-dream-glow);opacity:.85}.cinema-plan-card.svelte-1uwqs3k{position:absolute;z-index:3;top:50%;left:50%;transform:translate(-50%,-50%);max-width:520px;padding:1.5rem 1.75rem;border-radius:16px;text-align:center;animation:svelte-1uwqs3k-cinema-plan-in .5s ease both}@keyframes svelte-1uwqs3k-cinema-plan-in{0%{opacity:0;transform:translate(-50%,-46%)}to{opacity:1;transform:translate(-50%,-50%)}}.cinema-plan-kicker.svelte-1uwqs3k{font-size:.65rem;letter-spacing:.18em;text-transform:uppercase;color:var(--color-synapse-glow);margin-bottom:.5rem}.cinema-plan-logline.svelte-1uwqs3k{font-size:clamp(1.05rem,2.2vw,1.4rem);line-height:1.5;color:var(--color-bright);margin:0}.cinema-note.svelte-1uwqs3k{font-size:.78rem;color:var(--color-synapse-glow);opacity:.85;margin:0 0 .6rem;font-style:italic}.cinema-dot.svelte-1uwqs3k{width:8px;height:8px;border-radius:50%;background:var(--color-muted)}.cinema-dot.active.svelte-1uwqs3k{background:#14e8c6;box-shadow:0 0 10px #14e8c6}.cinema-toggle.svelte-1uwqs3k{font-size:.7rem;color:var(--color-dim);display:flex;align-items:center;gap:.3rem;cursor:pointer}.cinema-close.svelte-1uwqs3k{background:transparent;border:1px solid rgba(255,255,255,.15);color:var(--color-text);border-radius:8px;width:32px;height:32px;cursor:pointer}.cinema-caption-wrap.svelte-1uwqs3k{position:relative;z-index:2;margin-top:auto;padding:1rem 1.25rem max(1.25rem,env(safe-area-inset-bottom));max-width:720px}.cinema-chip.svelte-1uwqs3k{display:inline-block;font-size:.65rem;text-transform:uppercase;letter-spacing:.08em;color:var(--color-dream-glow);margin-bottom:.35rem}.cinema-caption.svelte-1uwqs3k{font-size:clamp(1.05rem,2.4vw,1.6rem);line-height:1.45;color:var(--color-bright);text-shadow:0 2px 24px rgba(0,0,0,.9);min-height:2.6em;margin:0 0 .75rem}.cinema-progress.svelte-1uwqs3k{height:3px;background:#ffffff1a;border-radius:3px;overflow:hidden}.cinema-progress-fill.svelte-1uwqs3k{height:100%;background:linear-gradient(90deg,var(--color-synapse),color-mix(in oklch,var(--color-dream),#ff2d55 calc(var(--tension, 0) * 100%)));transition:width .2s linear,background .4s ease}.cinema-beatcount.svelte-1uwqs3k{margin-top:.4rem;display:flex;gap:.75rem;align-items:center}.cinema-replay.svelte-1uwqs3k{background:transparent;border:1px solid rgba(129,140,248,.4);color:var(--color-synapse-glow);border-radius:999px;padding:.15rem .7rem;cursor:pointer;font-size:.75rem}.cinema-dream.svelte-1uwqs3k{color:var(--color-dream-glow);letter-spacing:.08em;animation:svelte-1uwqs3k-cinema-dream-pulse 3s ease-in-out infinite}.cinema-restore.svelte-1uwqs3k{position:absolute;bottom:.6rem;right:.8rem;z-index:95;background:#0a0a1a80;border:1px solid rgba(129,140,248,.25);color:var(--color-muted);border-radius:999px;padding:.2rem .7rem;font-size:.7rem;letter-spacing:.04em;cursor:pointer;opacity:.4;transition:opacity .2s ease}.cinema-restore.svelte-1uwqs3k:hover{opacity:1}@keyframes svelte-1uwqs3k-cinema-dream-pulse{0%,to{opacity:.55}50%{opacity:1}}@media(prefers-reduced-motion:reduce){.cinema-progress-fill.svelte-1uwqs3k{transition:none}} diff --git a/apps/dashboard/build/_app/immutable/assets/12.BxoW8Jf1.css.br b/apps/dashboard/build/_app/immutable/assets/12.BxoW8Jf1.css.br deleted file mode 100644 index 9c07b61..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/12.BxoW8Jf1.css.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/12.BxoW8Jf1.css.gz b/apps/dashboard/build/_app/immutable/assets/12.BxoW8Jf1.css.gz deleted file mode 100644 index dfc3505..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/12.BxoW8Jf1.css.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/20.Duj1vJUf.css b/apps/dashboard/build/_app/immutable/assets/20.Duj1vJUf.css deleted file mode 100644 index a7c31af..0000000 --- a/apps/dashboard/build/_app/immutable/assets/20.Duj1vJUf.css +++ /dev/null @@ -1 +0,0 @@ -.sr-only.svelte-q2v96u{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0} diff --git a/apps/dashboard/build/_app/immutable/assets/20.Duj1vJUf.css.br b/apps/dashboard/build/_app/immutable/assets/20.Duj1vJUf.css.br deleted file mode 100644 index 93e1c68..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/20.Duj1vJUf.css.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/20.Duj1vJUf.css.gz b/apps/dashboard/build/_app/immutable/assets/20.Duj1vJUf.css.gz deleted file mode 100644 index 6afc78d..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/20.Duj1vJUf.css.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/25.DKhUrxcR.css b/apps/dashboard/build/_app/immutable/assets/25.DKhUrxcR.css deleted file mode 100644 index 4017a6e..0000000 --- a/apps/dashboard/build/_app/immutable/assets/25.DKhUrxcR.css +++ /dev/null @@ -1 +0,0 @@ -body{overflow:hidden}.waitlist-shell.svelte-1375qm6{position:fixed;top:0;right:0;bottom:0;left:0;overflow-y:auto;background:#07100f;color:#edf7f2;font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.memory-field.svelte-1375qm6,.field-vignette.svelte-1375qm6{position:fixed;top:0;right:0;bottom:0;left:0;pointer-events:none}.memory-field.svelte-1375qm6{z-index:0}.field-vignette.svelte-1375qm6{z-index:1;background:linear-gradient(90deg,#07100feb,#07100f9e 48%,#07100fe0),linear-gradient(180deg,#07100f33,#07100fd1)}.topbar.svelte-1375qm6,main.svelte-1375qm6{position:relative;z-index:2}.topbar.svelte-1375qm6{display:flex;align-items:center;justify-content:space-between;gap:1rem;width:min(1180px,calc(100% - 2rem));margin:0 auto;padding:1rem 0}.brand.svelte-1375qm6,.topbar.svelte-1375qm6 nav:where(.svelte-1375qm6),.hero-actions.svelte-1375qm6,.proof-row.svelte-1375qm6,.signal-band.svelte-1375qm6,.track-grid.svelte-1375qm6,.support-bot.svelte-1375qm6,.roadmap.svelte-1375qm6,.roadmap.svelte-1375qm6 li:where(.svelte-1375qm6){display:flex}.brand.svelte-1375qm6{align-items:center;gap:.7rem;color:#fff;text-decoration:none;font-weight:800}.brand-mark.svelte-1375qm6{display:grid;place-items:center;width:2.15rem;height:2.15rem;border:1px solid rgba(34,197,94,.48);border-radius:8px;background:linear-gradient(135deg,#22c55e3d,#06b6d429);color:#bbf7d0}.topbar.svelte-1375qm6 nav:where(.svelte-1375qm6){align-items:center;gap:.4rem}.topbar.svelte-1375qm6 a:where(.svelte-1375qm6){color:#b8c7c0;text-decoration:none}.topbar.svelte-1375qm6 nav:where(.svelte-1375qm6) a:where(.svelte-1375qm6){border-radius:8px;padding:.65rem .85rem;font-size:.88rem}.topbar.svelte-1375qm6 nav:where(.svelte-1375qm6) a:where(.svelte-1375qm6):hover,.nav-cta.svelte-1375qm6{background:#ffffff12;color:#fff}main.svelte-1375qm6{width:min(1180px,calc(100% - 2rem));margin:0 auto}.hero.svelte-1375qm6{display:grid;grid-template-columns:minmax(0,1.05fr) minmax(320px,.7fr);gap:clamp(2rem,6vw,5rem);align-items:center;min-height:86vh;padding:clamp(2rem,5vw,4.8rem) 0 2rem}.hero-copy.svelte-1375qm6{max-width:720px}.eyebrow.svelte-1375qm6,.form-heading.svelte-1375qm6 p:where(.svelte-1375qm6),.section-heading.svelte-1375qm6 p:where(.svelte-1375qm6){margin:0 0 .8rem;color:#67e8f9;font-size:.78rem;font-weight:800;letter-spacing:0;text-transform:uppercase}h1.svelte-1375qm6,h2.svelte-1375qm6,h3.svelte-1375qm6,p.svelte-1375qm6{margin-top:0}h1.svelte-1375qm6{margin-bottom:1.1rem;color:#fff;font-size:clamp(3.8rem,13vw,8rem);line-height:.92;letter-spacing:0}.hero-subtitle.svelte-1375qm6{max-width:680px;margin-bottom:1.6rem;color:#d7e6df;font-size:clamp(1.05rem,2.4vw,1.45rem);line-height:1.5}.hero-actions.svelte-1375qm6{flex-wrap:wrap;gap:.8rem;margin-bottom:2rem}.primary-link.svelte-1375qm6,.secondary-link.svelte-1375qm6,.submit-button.svelte-1375qm6{border-radius:8px;font-weight:800;text-decoration:none}.primary-link.svelte-1375qm6,.submit-button.svelte-1375qm6{border:1px solid rgba(34,197,94,.86);background:#22c55e;color:#04130b;box-shadow:0 20px 42px #22c55e30}.primary-link.svelte-1375qm6,.secondary-link.svelte-1375qm6{padding:.88rem 1rem}.secondary-link.svelte-1375qm6{border:1px solid rgba(226,232,240,.2);background:#ffffff0f;color:#edf7f2}.proof-row.svelte-1375qm6{flex-wrap:wrap;gap:.7rem}.proof-item.svelte-1375qm6{width:min(100%,13rem);border:1px solid rgba(226,232,240,.12);border-radius:8px;background:#050c0b8a;padding:.9rem}.proof-item.svelte-1375qm6 strong:where(.svelte-1375qm6),.proof-item.svelte-1375qm6 span:where(.svelte-1375qm6){display:block}.proof-item.svelte-1375qm6 strong:where(.svelte-1375qm6){margin-bottom:.4rem;color:#bbf7d0;font-size:1.05rem}.proof-item.svelte-1375qm6 span:where(.svelte-1375qm6){color:#a8bbb2;font-size:.82rem;line-height:1.45}.waitlist-form.svelte-1375qm6{border:1px solid rgba(226,232,240,.16);border-radius:8px;background:#050c0bd1;box-shadow:0 28px 90px #0000005c;padding:clamp(1rem,3vw,1.35rem)}.form-heading.svelte-1375qm6 h2:where(.svelte-1375qm6),.section-heading.svelte-1375qm6 h2:where(.svelte-1375qm6),.roadmap.svelte-1375qm6 h2:where(.svelte-1375qm6){margin-bottom:1rem;color:#fff;font-size:clamp(1.6rem,4vw,2.7rem);line-height:1.05;letter-spacing:0}.form-heading.svelte-1375qm6 h2:where(.svelte-1375qm6){font-size:clamp(1.4rem,3vw,2rem)}label.svelte-1375qm6{display:block;margin-top:.85rem}label.svelte-1375qm6 span:where(.svelte-1375qm6){display:block;margin-bottom:.38rem;color:#a8bbb2;font-size:.78rem;font-weight:750}input.svelte-1375qm6,select.svelte-1375qm6,textarea.svelte-1375qm6{width:100%;border:1px solid rgba(226,232,240,.16);border-radius:8px;background:#fff1;color:#fff;font:inherit;padding:.78rem .82rem;outline:none}select.svelte-1375qm6{color-scheme:dark}textarea.svelte-1375qm6{resize:vertical;min-height:6rem}input.svelte-1375qm6:focus,select.svelte-1375qm6:focus,textarea.svelte-1375qm6:focus{border-color:#22c55ee6;box-shadow:0 0 0 3px #22c55e24}.hidden-field.svelte-1375qm6{position:absolute;left:-10000px;height:1px;overflow:hidden}.submit-button.svelte-1375qm6{width:100%;margin-top:1rem;padding:.95rem 1rem;cursor:pointer;font:inherit}.submit-button.svelte-1375qm6:disabled{cursor:wait;opacity:.72}.submit-message.svelte-1375qm6{margin:.8rem 0 0;font-size:.82rem;line-height:1.45}.submit-message.success.svelte-1375qm6{color:#86efac}.submit-message.error.svelte-1375qm6{color:#fca5a5}.signal-band.svelte-1375qm6{flex-wrap:wrap;gap:.65rem;border-top:1px solid rgba(226,232,240,.12);border-bottom:1px solid rgba(226,232,240,.12);padding:1rem 0}.signal-band.svelte-1375qm6 div:where(.svelte-1375qm6){border-radius:999px;background:#ffffff12;color:#d7e6df;padding:.55rem .75rem;font-size:.84rem}.pro-grid.svelte-1375qm6,.roadmap.svelte-1375qm6{padding:clamp(3rem,7vw,5rem) 0}.section-heading.svelte-1375qm6{max-width:760px;margin-bottom:1.7rem}.track-grid.svelte-1375qm6{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.9rem}.track.svelte-1375qm6{border:1px solid rgba(226,232,240,.13);border-radius:8px;background:#050c0ba8;padding:1.1rem}.track-line.svelte-1375qm6{width:3.5rem;height:.22rem;margin-bottom:1rem;border-radius:999px;background:var(--track-color)}.track.svelte-1375qm6 h3:where(.svelte-1375qm6){margin-bottom:.65rem;color:#fff;font-size:1.08rem}.track.svelte-1375qm6 p:where(.svelte-1375qm6),.roadmap.svelte-1375qm6 span:where(.svelte-1375qm6){color:#a8bbb2;line-height:1.55}.support-bot.svelte-1375qm6,.roadmap.svelte-1375qm6{align-items:flex-start;justify-content:space-between;gap:clamp(2rem,6vw,4rem);border-top:1px solid rgba(226,232,240,.12)}.support-bot.svelte-1375qm6{padding:clamp(2.6rem,6vw,4.5rem) 0}.support-bot.svelte-1375qm6>div:where(.svelte-1375qm6):first-child,.roadmap.svelte-1375qm6>div:where(.svelte-1375qm6){flex:0 0 min(28rem,100%)}.bot-intro.svelte-1375qm6{max-width:34rem;color:#a8bbb2;line-height:1.55}.bot-panel.svelte-1375qm6{flex:1;border:1px solid rgba(226,232,240,.13);border-radius:8px;background:#050c0b9e;padding:clamp(1rem,3vw,1.25rem)}.bot-status.svelte-1375qm6,.prompt-row.svelte-1375qm6,.bot-input.svelte-1375qm6{display:flex;align-items:center}.bot-status.svelte-1375qm6{gap:.55rem;margin-bottom:.9rem;color:#d7e6df;font-size:.86rem;font-weight:800}.bot-status.svelte-1375qm6 small:where(.svelte-1375qm6){margin-left:auto;border:1px solid rgba(34,197,94,.22);border-radius:999px;padding:.3rem .5rem;color:#86efac;font-size:.72rem}.bot-light.svelte-1375qm6{width:.42rem;height:.42rem;border-radius:999px;background:#22c55e;box-shadow:0 0 18px #22c55eb3}.bot-messages.svelte-1375qm6{display:grid;gap:.75rem;max-height:22rem;overflow-y:auto;border:1px solid rgba(226,232,240,.1);border-radius:8px;background:#ffffff09;padding:.8rem}.bot-bubble.svelte-1375qm6,.user-bubble.svelte-1375qm6{max-width:88%;border-radius:8px;padding:.75rem .82rem}.bot-bubble.svelte-1375qm6{justify-self:start;border:1px solid rgba(34,197,94,.18);background:#22c55e14;color:#d7e6df}.user-bubble.svelte-1375qm6{justify-self:end;border:1px solid rgba(6,182,212,.24);background:#06b6d41f;color:#fff}.bot-bubble.svelte-1375qm6 p:where(.svelte-1375qm6),.user-bubble.svelte-1375qm6 p:where(.svelte-1375qm6){margin:0;font-size:.86rem;line-height:1.5;white-space:pre-wrap}.bot-bubble.svelte-1375qm6 p:where(.svelte-1375qm6)+p:where(.svelte-1375qm6),.user-bubble.svelte-1375qm6 p:where(.svelte-1375qm6)+p:where(.svelte-1375qm6){margin-top:.35rem}.prompt-row.svelte-1375qm6{flex-wrap:wrap;gap:.45rem;margin:.85rem 0}.prompt-row.svelte-1375qm6 button:where(.svelte-1375qm6){border:1px solid rgba(226,232,240,.14);border-radius:999px;background:#ffffff0e;color:#d7e6df;cursor:pointer;font:inherit;font-size:.78rem;padding:.46rem .62rem}.prompt-row.svelte-1375qm6 button:where(.svelte-1375qm6):hover{border-color:#22c55e6b;color:#fff}.bot-input.svelte-1375qm6{gap:.55rem}.bot-input.svelte-1375qm6 input:where(.svelte-1375qm6){margin:0}.bot-input.svelte-1375qm6 button:where(.svelte-1375qm6){flex:0 0 auto;border:1px solid rgba(34,197,94,.86);border-radius:8px;background:#22c55e;color:#04130b;cursor:pointer;font:inherit;font-weight:800;padding:.78rem .95rem}.bot-input.svelte-1375qm6 button:where(.svelte-1375qm6):disabled{cursor:not-allowed;opacity:.45}.roadmap.svelte-1375qm6 ol:where(.svelte-1375qm6){display:grid;gap:.8rem;margin:0;padding:0;list-style:none}.roadmap.svelte-1375qm6 li:where(.svelte-1375qm6){gap:1rem;align-items:flex-start;border:1px solid rgba(226,232,240,.13);border-radius:8px;background:#050c0b94;padding:1rem}.roadmap.svelte-1375qm6 strong:where(.svelte-1375qm6){flex:0 0 4.5rem;color:#fbbf24}@media(max-width:900px){.topbar.svelte-1375qm6{align-items:flex-start;flex-direction:column}.hero.svelte-1375qm6,.track-grid.svelte-1375qm6,.support-bot.svelte-1375qm6,.roadmap.svelte-1375qm6{grid-template-columns:1fr}.hero.svelte-1375qm6{display:block;min-height:auto;padding-top:2rem}.waitlist-form.svelte-1375qm6{margin-top:2rem}.support-bot.svelte-1375qm6,.roadmap.svelte-1375qm6{display:block}.bot-panel.svelte-1375qm6{margin-top:1rem}}@media(max-width:560px){main.svelte-1375qm6,.topbar.svelte-1375qm6{width:min(100% - 1rem,1180px)}.topbar.svelte-1375qm6 nav:where(.svelte-1375qm6){width:100%;justify-content:space-between}.topbar.svelte-1375qm6 nav:where(.svelte-1375qm6) a:where(.svelte-1375qm6){padding:.58rem .62rem;font-size:.8rem}h1.svelte-1375qm6{font-size:clamp(3.35rem,18vw,4.8rem)}.hero-subtitle.svelte-1375qm6{font-size:1rem}.proof-item.svelte-1375qm6{width:100%}.roadmap.svelte-1375qm6 li:where(.svelte-1375qm6){display:block}.roadmap.svelte-1375qm6 strong:where(.svelte-1375qm6){display:block;margin-bottom:.5rem}.bot-input.svelte-1375qm6{align-items:stretch;flex-direction:column}.bot-input.svelte-1375qm6 button:where(.svelte-1375qm6){width:100%}} diff --git a/apps/dashboard/build/_app/immutable/assets/25.DKhUrxcR.css.br b/apps/dashboard/build/_app/immutable/assets/25.DKhUrxcR.css.br deleted file mode 100644 index e4292ca..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/25.DKhUrxcR.css.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/25.DKhUrxcR.css.gz b/apps/dashboard/build/_app/immutable/assets/25.DKhUrxcR.css.gz deleted file mode 100644 index f9799b6..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/25.DKhUrxcR.css.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/6.ksI6gQcB.css b/apps/dashboard/build/_app/immutable/assets/6.ksI6gQcB.css deleted file mode 100644 index ba453ce..0000000 --- a/apps/dashboard/build/_app/immutable/assets/6.ksI6gQcB.css +++ /dev/null @@ -1 +0,0 @@ -.receipt.svelte-1wdzvwu{border:1px solid color-mix(in oklab,var(--risk) 30%,transparent);border-left:3px solid var(--risk);border-radius:12px;padding:14px 16px;background:color-mix(in oklab,var(--color-void, #050510) 50%,transparent);display:flex;flex-direction:column;gap:12px}.receipt.compact.svelte-1wdzvwu{gap:10px;padding:12px 14px}.r-head.svelte-1wdzvwu{display:flex;justify-content:space-between;align-items:baseline;gap:8px}.r-id.svelte-1wdzvwu{font-size:.78rem;color:var(--color-synapse-glow, #818cf8);word-break:break-all}.r-risk.svelte-1wdzvwu{font-size:.7rem;font-weight:700;text-transform:uppercase;letter-spacing:.05em;white-space:nowrap}.r-metrics.svelte-1wdzvwu{display:flex;gap:20px}.metric.svelte-1wdzvwu{display:flex;flex-direction:column;gap:1px}.m-val.svelte-1wdzvwu{font-size:1.25rem;font-weight:800;line-height:1;font-variant-numeric:tabular-nums}.m-label.svelte-1wdzvwu{font-size:.64rem;text-transform:uppercase;letter-spacing:.07em;color:var(--color-text-dim, #8b8ba7)}.r-section.svelte-1wdzvwu{display:flex;flex-direction:column;gap:6px}.r-section-title.svelte-1wdzvwu{font-size:.66rem;text-transform:uppercase;letter-spacing:.07em;color:var(--color-text-dim, #8b8ba7)}.path.svelte-1wdzvwu{font-size:.8rem;font-family:var(--font-mono, monospace);color:var(--color-text, #e2e2f0);padding:4px 8px;border-radius:6px;background:color-mix(in oklab,var(--color-synapse) 8%,transparent)}.chips.svelte-1wdzvwu{display:flex;flex-wrap:wrap;gap:5px}.chip.svelte-1wdzvwu{font-size:.72rem;padding:2px 8px;border-radius:6px}.chip.recall.svelte-1wdzvwu{color:var(--color-recall, #10b981);background:color-mix(in oklab,var(--color-recall) 12%,transparent);border:1px solid color-mix(in oklab,var(--color-recall) 28%,transparent)}.chip.suppress.svelte-1wdzvwu{color:#a78bfa;background:color-mix(in oklab,#a78bfa 12%,transparent);border:1px solid color-mix(in oklab,#a78bfa 28%,transparent);text-decoration:line-through;text-decoration-color:color-mix(in oklab,#a78bfa 50%,transparent)}.cinema-btn.svelte-1wdzvwu{margin-top:2px;display:inline-flex;align-items:center;justify-content:center;gap:7px;padding:8px 14px;font-size:.8rem;font-weight:600;border-radius:9px;border:1px solid color-mix(in oklab,var(--color-synapse) 40%,transparent);background:color-mix(in oklab,var(--color-synapse) 12%,transparent);color:var(--color-synapse-glow, #818cf8);cursor:pointer;transition:all .18s ease}.cinema-btn.svelte-1wdzvwu:hover:not(:disabled){background:color-mix(in oklab,var(--color-synapse) 24%,transparent);transform:translateY(-1px)}.cinema-btn.svelte-1wdzvwu:disabled{opacity:.4;cursor:not-allowed}.mode-toggle.svelte-1ayqwv0,.export-btn.svelte-1ayqwv0{display:inline-flex;align-items:center;gap:6px;padding:7px 12px;font-size:.78rem;font-weight:600;border-radius:9px;border:1px solid color-mix(in oklab,var(--color-synapse) 30%,transparent);background:color-mix(in oklab,var(--color-synapse) 8%,transparent);color:var(--color-synapse-glow);cursor:pointer;transition:all .18s ease}.mode-toggle.svelte-1ayqwv0:hover,.export-btn.svelte-1ayqwv0:hover:not(:disabled){background:color-mix(in oklab,var(--color-synapse) 18%,transparent);transform:translateY(-1px)}.mode-toggle.on.svelte-1ayqwv0{background:var(--color-synapse);color:#fff}.export-btn.svelte-1ayqwv0:disabled{opacity:.4;cursor:not-allowed}.spine.svelte-1ayqwv0{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:1px;border-radius:14px;padding:14px 18px;margin-bottom:18px;overflow:hidden}.spine-item.svelte-1ayqwv0{display:flex;flex-direction:column;gap:4px;padding:2px 14px}.spine-label.svelte-1ayqwv0{font-size:.66rem;text-transform:uppercase;letter-spacing:.08em;color:var(--color-text-dim, #8b8ba7)}.spine-value.svelte-1ayqwv0{font-size:.92rem;font-weight:600;display:inline-flex;align-items:center;gap:7px}.spine-run.svelte-1ayqwv0{font-size:.82rem;color:var(--color-synapse-glow);word-break:break-all}.dot.svelte-1ayqwv0{width:8px;height:8px;border-radius:50%;background:#64748b;box-shadow:0 0 0 0 transparent}.dot.live.svelte-1ayqwv0{background:var(--color-recall, #10b981);animation:svelte-1ayqwv0-ping 2s ease-in-out infinite}.dot.big.svelte-1ayqwv0{width:12px;height:12px}@keyframes svelte-1ayqwv0-ping{0%,to{box-shadow:0 0 color-mix(in oklab,var(--color-recall) 60%,transparent)}50%{box-shadow:0 0 0 6px transparent}}.ev-chip.svelte-1ayqwv0{font-size:.74rem;font-weight:700;padding:2px 8px;border-radius:6px;color:var(--c);background:color-mix(in oklab,var(--c) 14%,transparent);border:1px solid color-mix(in oklab,var(--c) 35%,transparent)}.layout.svelte-1ayqwv0{display:grid;grid-template-columns:260px 1fr;gap:16px;align-items:start}@media(max-width:860px){.layout.svelte-1ayqwv0{grid-template-columns:1fr}}.glass.svelte-1ayqwv0{background:linear-gradient(180deg,#02030742,#00051029);border:1px solid color-mix(in oklab,var(--color-synapse) 16%,transparent);-webkit-backdrop-filter:blur(8px) saturate(122%);backdrop-filter:blur(8px) saturate(122%);border-radius:14px}.panel-title.svelte-1ayqwv0{font-size:.82rem;font-weight:700;letter-spacing:.02em;margin:0 0 12px}.text-dim.svelte-1ayqwv0{color:var(--color-text-dim, #8b8ba7);font-weight:400}.empty.svelte-1ayqwv0{font-size:.82rem;color:var(--color-text-dim, #8b8ba7);line-height:1.5}.runs.svelte-1ayqwv0{padding:16px;position:sticky;top:16px;max-height:calc(100vh - 40px);overflow-y:auto}.runs.svelte-1ayqwv0 ul:where(.svelte-1ayqwv0){list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}.run-row.svelte-1ayqwv0{width:100%;text-align:left;padding:9px 11px;border-radius:10px;border:1px solid transparent;background:color-mix(in oklab,white 3%,transparent);cursor:pointer;transition:all .16s ease}.run-row.svelte-1ayqwv0:hover{background:color-mix(in oklab,var(--color-synapse) 12%,transparent)}.run-row.active.svelte-1ayqwv0{border-color:color-mix(in oklab,var(--color-synapse) 45%,transparent);background:color-mix(in oklab,var(--color-synapse) 16%,transparent)}.run-top.svelte-1ayqwv0{display:flex;justify-content:space-between;align-items:baseline;gap:8px}.run-id.svelte-1ayqwv0{font-size:.78rem;color:var(--color-synapse-glow)}.run-tool.svelte-1ayqwv0{font-size:.7rem;color:var(--color-text-dim, #8b8ba7);white-space:nowrap}.run-stats.svelte-1ayqwv0{display:flex;gap:8px;margin-top:5px;font-size:.68rem;color:var(--color-text-dim, #8b8ba7)}.s-recall.svelte-1ayqwv0{color:var(--color-recall, #10b981)}.s-suppress.svelte-1ayqwv0{color:#b90d2b}.s-write.svelte-1ayqwv0{color:#38bdf8}.s-veto.svelte-1ayqwv0{color:#f43f5e}.replay.svelte-1ayqwv0{display:flex;flex-direction:column;gap:14px;min-width:0}.center-msg.svelte-1ayqwv0{padding:40px;text-align:center;color:var(--color-text-dim, #8b8ba7)}.center-msg.err.svelte-1ayqwv0{color:#f87171}.scrubber.svelte-1ayqwv0{padding:16px 18px}.scrub-head.svelte-1ayqwv0{display:flex;justify-content:space-between;align-items:baseline;margin-bottom:10px;font-size:.82rem}.scrub-time.svelte-1ayqwv0{color:var(--color-synapse-glow);font-variant-numeric:tabular-nums}.scrub-range.svelte-1ayqwv0{width:100%;accent-color:var(--color-synapse)}.ticks.svelte-1ayqwv0{display:flex;gap:2px;margin-top:10px;height:22px;align-items:stretch}.tick.svelte-1ayqwv0{flex:1;min-width:2px;border:none;border-radius:2px;background:color-mix(in oklab,var(--c) 22%,transparent);cursor:pointer;transition:all .16s ease;padding:0}.tick.past.svelte-1ayqwv0{background:var(--c);box-shadow:0 0 6px -1px var(--c)}.tick.svelte-1ayqwv0:hover{transform:scaleY(1.25)}.event-detail.svelte-1ayqwv0{padding:16px 18px;border-left:3px solid var(--c)}.ed-head.svelte-1ayqwv0{display:flex;align-items:center;gap:10px}.ed-glyph.svelte-1ayqwv0{font-size:1.2rem;color:var(--c)}.ed-label.svelte-1ayqwv0{font-weight:700;color:var(--c)}.ed-time.svelte-1ayqwv0{margin-left:auto;font-size:.74rem;color:var(--color-text-dim, #8b8ba7)}.ed-summary.svelte-1ayqwv0{margin:10px 0 0;font-size:.9rem;line-height:1.5}.ids-grid.svelte-1ayqwv0{display:flex;flex-wrap:wrap;gap:6px;margin-top:12px}.id-chip.svelte-1ayqwv0{display:inline-flex;align-items:center;gap:5px;padding:3px 8px;border-radius:7px;background:color-mix(in oklab,var(--color-recall) calc(var(--a, 0) * 30%),transparent);border:1px solid color-mix(in oklab,var(--color-recall) 30%,transparent);font-size:.74rem}.id-chip.svelte-1ayqwv0 small:where(.svelte-1ayqwv0){color:var(--color-recall, #10b981);font-weight:700}.contra.svelte-1ayqwv0{display:flex;align-items:center;gap:8px;margin-top:12px;font-size:.8rem}.winner.svelte-1ayqwv0{color:var(--color-recall, #10b981);font-weight:700}.vs.svelte-1ayqwv0{color:var(--color-text-dim, #8b8ba7)}.loser.svelte-1ayqwv0{color:#fb7185;text-decoration:line-through;opacity:.7}.veto-evidence.svelte-1ayqwv0{display:flex;gap:6px;margin-top:12px;flex-wrap:wrap}.veto-evidence.svelte-1ayqwv0 code:where(.svelte-1ayqwv0){padding:2px 7px;border-radius:6px;background:color-mix(in oklab,#f43f5e 12%,transparent);font-size:.74rem}.pulse.svelte-1ayqwv0{padding:16px 18px}.pulse-grid.svelte-1ayqwv0{display:flex;flex-wrap:wrap;gap:6px}.pulse-node.svelte-1ayqwv0{padding:3px 8px;border-radius:7px;background:color-mix(in oklab,var(--color-synapse) 12%,transparent);border:1px solid color-mix(in oklab,var(--color-synapse) 28%,transparent);font-size:.74rem;color:var(--color-synapse-glow);animation:svelte-1ayqwv0-pulse-in .4s ease}@keyframes svelte-1ayqwv0-pulse-in{0%{transform:scale(.85);opacity:0}to{transform:scale(1);opacity:1}}.receipts-panel.svelte-1ayqwv0{padding:16px 18px}.receipts-grid.svelte-1ayqwv0{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:12px}.producers.svelte-1ayqwv0{padding:16px 18px}.producer-list.svelte-1ayqwv0{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:7px}.producer.svelte-1ayqwv0{display:flex;align-items:center;gap:9px;font-size:.78rem;color:var(--color-text-dim, #8b8ba7)}.producer.svelte-1ayqwv0 .p-dot:where(.svelte-1ayqwv0){width:8px;height:8px;border-radius:50%;background:#475569;flex-shrink:0}.producer.ok.svelte-1ayqwv0{color:var(--color-text, #e2e2f0)}.producer.ok.svelte-1ayqwv0 .p-dot:where(.svelte-1ayqwv0){background:var(--color-recall, #10b981);box-shadow:0 0 6px -1px var(--color-recall, #10b981)}.producer.caveat.svelte-1ayqwv0:not(.ok) .p-dot:where(.svelte-1ayqwv0){background:#f59e0b;opacity:.6}.p-state.svelte-1ayqwv0{margin-left:auto;font-size:.7rem;font-style:italic;text-align:right;color:var(--color-text-dim, #8b8ba7)}.producer.caveat.svelte-1ayqwv0:not(.ok) .p-state:where(.svelte-1ayqwv0){color:#f59e0b}.log.svelte-1ayqwv0{padding:16px 18px}.log-list.svelte-1ayqwv0{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}.log-row.svelte-1ayqwv0{border-radius:8px;border-left:2px solid var(--c);transition:all .16s ease}.log-row.active.svelte-1ayqwv0{background:color-mix(in oklab,var(--c) 14%,transparent)}.log-row.dim.svelte-1ayqwv0{opacity:.4}.log-btn.svelte-1ayqwv0{width:100%;display:grid;grid-template-columns:22px 110px 1fr auto;align-items:center;gap:8px;padding:7px 10px;background:none;border:none;cursor:pointer;text-align:left;font-size:.8rem}.log-glyph.svelte-1ayqwv0{color:var(--c);text-align:center}.log-label.svelte-1ayqwv0{font-weight:600;color:var(--c)}.log-summary.svelte-1ayqwv0{color:var(--color-text-dim, #8b8ba7);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.log-t.svelte-1ayqwv0{font-size:.7rem;color:var(--color-text-dim, #8b8ba7);font-variant-numeric:tabular-nums}.proof-stage.svelte-1ayqwv0{padding:60px 40px;text-align:center;display:flex;flex-direction:column;align-items:center;gap:26px;min-height:50vh;justify-content:center}.proof-headline.svelte-1ayqwv0{display:flex;align-items:center;gap:12px}.proof-run.svelte-1ayqwv0{font-size:1.4rem;color:var(--color-synapse-glow);font-weight:700}.proof-event.svelte-1ayqwv0{display:flex;align-items:center;gap:16px;padding:18px 26px;border-radius:14px;border:1px solid color-mix(in oklab,var(--c) 40%,transparent);background:color-mix(in oklab,var(--c) 10%,transparent)}.proof-glyph.svelte-1ayqwv0{font-size:2rem;color:var(--c)}.proof-ev-label.svelte-1ayqwv0{font-size:1.1rem;font-weight:700;color:var(--c)}.proof-ev-sum.svelte-1ayqwv0{font-size:.85rem;color:var(--color-text-dim, #8b8ba7)}.proof-counter.svelte-1ayqwv0{font-size:3.4rem;font-weight:800;line-height:1;color:var(--color-synapse-glow)}.proof-counter-label.svelte-1ayqwv0{display:block;font-size:.8rem;font-weight:500;letter-spacing:.1em;text-transform:uppercase;color:var(--color-text-dim, #8b8ba7);margin-top:8px}.proof-tagline.svelte-1ayqwv0{font-size:1rem;color:var(--color-text-dim, #c0c0d8);max-width:32ch;line-height:1.5} diff --git a/apps/dashboard/build/_app/immutable/assets/6.ksI6gQcB.css.br b/apps/dashboard/build/_app/immutable/assets/6.ksI6gQcB.css.br deleted file mode 100644 index 6776564..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/6.ksI6gQcB.css.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/6.ksI6gQcB.css.gz b/apps/dashboard/build/_app/immutable/assets/6.ksI6gQcB.css.gz deleted file mode 100644 index c061327..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/6.ksI6gQcB.css.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/7.DQ_AfUnN.css b/apps/dashboard/build/_app/immutable/assets/7.DQ_AfUnN.css deleted file mode 100644 index 253943b..0000000 --- a/apps/dashboard/build/_app/immutable/assets/7.DQ_AfUnN.css +++ /dev/null @@ -1 +0,0 @@ -@keyframes svelte-1jku20k-arc-drift{0%{stroke-dashoffset:0}to{stroke-dashoffset:-32}}.arc-particle{animation-name:svelte-1jku20k-arc-drift;animation-timing-function:linear;animation-iteration-count:infinite} diff --git a/apps/dashboard/build/_app/immutable/assets/7.DQ_AfUnN.css.br b/apps/dashboard/build/_app/immutable/assets/7.DQ_AfUnN.css.br deleted file mode 100644 index 119e6b7..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/7.DQ_AfUnN.css.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/7.DQ_AfUnN.css.gz b/apps/dashboard/build/_app/immutable/assets/7.DQ_AfUnN.css.gz deleted file mode 100644 index f973c72..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/7.DQ_AfUnN.css.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/Dropdown.C2Z-7Phd.css b/apps/dashboard/build/_app/immutable/assets/Dropdown.C2Z-7Phd.css deleted file mode 100644 index 3466628..0000000 --- a/apps/dashboard/build/_app/immutable/assets/Dropdown.C2Z-7Phd.css +++ /dev/null @@ -1 +0,0 @@ -.dd.svelte-1fd3ybn{position:relative;display:inline-flex;flex-direction:column;gap:.3rem}.dd-label.svelte-1fd3ybn{font-size:.65rem;text-transform:uppercase;letter-spacing:.08em;color:var(--color-muted);padding-left:.15rem}.dd-trigger.svelte-1fd3ybn{display:inline-flex;align-items:center;gap:.5rem;padding:.55rem .7rem .55rem .8rem;min-width:9rem;background:#ffffff08;border:1px solid rgba(99,102,241,.12);border-radius:.75rem;color:var(--color-text);font-size:.8rem;font-family:inherit;cursor:pointer;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);transition:border-color .2s ease,background .2s ease,box-shadow .2s ease}.dd-trigger.svelte-1fd3ybn:hover{border-color:#6366f14d;background:#ffffff0d}.dd-trigger.svelte-1fd3ybn:focus-visible,.dd-trigger.dd-open.svelte-1fd3ybn{outline:none;border-color:#6366f180;box-shadow:0 0 0 3px #6366f11f}.dd-trigger-icon.svelte-1fd3ybn{color:var(--color-synapse-glow);display:inline-flex}.dd-value.svelte-1fd3ybn{flex:1;text-align:left;display:inline-flex;align-items:center;gap:.45rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dd-placeholder.svelte-1fd3ybn{color:var(--color-muted)}.dd-dot.svelte-1fd3ybn{width:.5rem;height:.5rem;border-radius:50%;flex-shrink:0;box-shadow:0 0 6px currentColor}.dd-chevron.svelte-1fd3ybn{color:var(--color-dim);display:inline-flex;transition:transform .25s cubic-bezier(.34,1.56,.64,1)}.dd-chevron-open.svelte-1fd3ybn{transform:rotate(180deg);color:var(--color-synapse-glow)}.dd-menu.svelte-1fd3ybn{position:absolute;top:calc(100% + .4rem);left:0;z-index:60;min-width:100%;max-height:18rem;overflow-y:auto;padding:.35rem;border-radius:.85rem;transform-origin:top center}@media not (prefers-reduced-motion:reduce){.dd-menu.svelte-1fd3ybn{animation:svelte-1fd3ybn-dd-pop .18s cubic-bezier(.34,1.56,.64,1)}@keyframes svelte-1fd3ybn-dd-pop{0%{opacity:0;transform:translateY(-6px) scale(.96)}to{opacity:1;transform:translateY(0) scale(1)}}}.dd-option.svelte-1fd3ybn{width:100%;display:flex;align-items:center;gap:.5rem;padding:.5rem .6rem;border:none;background:transparent;color:var(--color-dim);font-size:.8rem;font-family:inherit;text-align:left;border-radius:.6rem;cursor:pointer;transition:background .12s ease,color .12s ease}.dd-active.svelte-1fd3ybn{background:#6366f124;color:var(--color-text)}.dd-selected.svelte-1fd3ybn{color:var(--color-synapse-glow)}.dd-opt-icon.svelte-1fd3ybn{color:var(--color-dim);display:inline-flex}.dd-active.svelte-1fd3ybn .dd-opt-icon:where(.svelte-1fd3ybn){color:var(--color-synapse-glow)}.dd-opt-label.svelte-1fd3ybn{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dd-badge.svelte-1fd3ybn{font-size:.65rem;font-variant-numeric:tabular-nums;color:var(--color-muted);background:#ffffff0d;padding:.05rem .4rem;border-radius:.4rem}.dd-check.svelte-1fd3ybn{color:var(--color-synapse-glow);display:inline-flex} diff --git a/apps/dashboard/build/_app/immutable/assets/Dropdown.C2Z-7Phd.css.br b/apps/dashboard/build/_app/immutable/assets/Dropdown.C2Z-7Phd.css.br deleted file mode 100644 index 34f3906..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/Dropdown.C2Z-7Phd.css.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/Dropdown.C2Z-7Phd.css.gz b/apps/dashboard/build/_app/immutable/assets/Dropdown.C2Z-7Phd.css.gz deleted file mode 100644 index e21b4b8..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/Dropdown.C2Z-7Phd.css.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/Icon.tTjeJXhC.css b/apps/dashboard/build/_app/immutable/assets/Icon.tTjeJXhC.css deleted file mode 100644 index ae9f1db..0000000 --- a/apps/dashboard/build/_app/immutable/assets/Icon.tTjeJXhC.css +++ /dev/null @@ -1 +0,0 @@ -.vestige-icon.svelte-1eqehiz{display:inline-block;flex-shrink:0;vertical-align:middle;overflow:visible}@media not (prefers-reduced-motion:reduce){.vestige-icon-draw.svelte-1eqehiz path,.vestige-icon-draw.svelte-1eqehiz circle,.vestige-icon-draw.svelte-1eqehiz rect{stroke-dasharray:64;stroke-dashoffset:64;animation:svelte-1eqehiz-icon-draw .7s cubic-bezier(.65,0,.35,1) forwards}@keyframes svelte-1eqehiz-icon-draw{to{stroke-dashoffset:0}}} diff --git a/apps/dashboard/build/_app/immutable/assets/Icon.tTjeJXhC.css.br b/apps/dashboard/build/_app/immutable/assets/Icon.tTjeJXhC.css.br deleted file mode 100644 index 468287b..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/Icon.tTjeJXhC.css.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/Icon.tTjeJXhC.css.gz b/apps/dashboard/build/_app/immutable/assets/Icon.tTjeJXhC.css.gz deleted file mode 100644 index dbe4663..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/Icon.tTjeJXhC.css.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/ObservatoryStage.CKoSQgn0.css b/apps/dashboard/build/_app/immutable/assets/ObservatoryStage.CKoSQgn0.css deleted file mode 100644 index 7a14e9b..0000000 --- a/apps/dashboard/build/_app/immutable/assets/ObservatoryStage.CKoSQgn0.css +++ /dev/null @@ -1 +0,0 @@ -.spine.svelte-8n8iia{position:absolute;left:8%;right:8%;bottom:calc(2.5rem + env(safe-area-inset-bottom,0px));pointer-events:none}.active-label.svelte-8n8iia{text-align:center;margin-bottom:.6rem;font-family:SF Mono,ui-monospace,Menlo,Consolas,monospace;font-size:.72rem;letter-spacing:.08em;color:#cfe9ff;text-shadow:0 0 24px rgba(30,180,255,.35);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.track.svelte-8n8iia{position:relative;height:2px;background:#ffffff12;border-radius:1px}.tick.svelte-8n8iia{position:absolute;top:50%;width:3px;height:10px;transform:translate(-50%,-50%);border-radius:2px;background:#6ef0e6;transition:opacity .2s linear}.tick.hot.svelte-8n8iia{box-shadow:0 0 12px #6ef0e6bf}.tick.backward.svelte-8n8iia{background:#ff4070}.tick.backward.hot.svelte-8n8iia{box-shadow:0 0 12px #ff4070bf}.playhead.svelte-8n8iia{position:absolute;top:50%;width:1.5px;height:16px;transform:translate(-50%,-50%);background:#cfe9ffe6;box-shadow:0 0 10px #1eb4ff80}.verdict.svelte-ssd7yu{position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);text-align:center;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif;padding:clamp(18px,3vw,40px) clamp(28px,6vw,80px);border-radius:20px;background:radial-gradient(ellipse at center,#05070edb,#05070eb8 60%,#05070e00);pointer-events:none}.k.svelte-ssd7yu{font-size:clamp(13px,1.8vw,18px);color:#9fd0e4;letter-spacing:.16em;text-transform:uppercase}.v.svelte-ssd7yu{font-size:clamp(32px,6.4vw,72px);font-weight:600;margin-top:.12em;line-height:1.05;background:linear-gradient(90deg,#7fe6c0,#6ef0e6,#a6dcff);-webkit-background-clip:text;background-clip:text;color:transparent;filter:drop-shadow(0 0 26px rgba(110,240,220,.45))}.s.svelte-ssd7yu{font-size:clamp(11px,1.5vw,15px);color:#8fb0be;margin-top:.6em;font-family:SF Mono,ui-monospace,Menlo,Consolas,monospace;letter-spacing:.04em}.quarantine.svelte-ssd7yu .k:where(.svelte-ssd7yu){color:#ffb0a6}.quarantine.svelte-ssd7yu .v:where(.svelte-ssd7yu){background:linear-gradient(90deg,#ff6a5e,#ff9d6b,#ffd2a8);filter:drop-shadow(0 0 26px rgba(255,90,70,.45))}.quarantine.svelte-ssd7yu .s:where(.svelte-ssd7yu){color:#d9a49a} diff --git a/apps/dashboard/build/_app/immutable/assets/ObservatoryStage.CKoSQgn0.css.br b/apps/dashboard/build/_app/immutable/assets/ObservatoryStage.CKoSQgn0.css.br deleted file mode 100644 index 7042b88..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/ObservatoryStage.CKoSQgn0.css.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/ObservatoryStage.CKoSQgn0.css.gz b/apps/dashboard/build/_app/immutable/assets/ObservatoryStage.CKoSQgn0.css.gz deleted file mode 100644 index 7dc280c..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/ObservatoryStage.CKoSQgn0.css.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/cognitive-palette.BALpZUFZ.css b/apps/dashboard/build/_app/immutable/assets/cognitive-palette.BALpZUFZ.css deleted file mode 100644 index ed366b1..0000000 --- a/apps/dashboard/build/_app/immutable/assets/cognitive-palette.BALpZUFZ.css +++ /dev/null @@ -1 +0,0 @@ -.observatory-canvas.svelte-16248mg{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;display:block;background:#05060a}.fallback.svelte-16248mg{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.75rem;text-align:center;padding:0 10%;font-family:SF Mono,ui-monospace,Menlo,Consolas,monospace;pointer-events:auto}.fallback-title.svelte-16248mg{color:#5dcaa5;font-size:.95rem;letter-spacing:.28em;text-shadow:0 0 20px rgba(93,202,165,.4)}.fallback-reason.svelte-16248mg{color:#9fd0e4;font-size:.8rem;letter-spacing:.04em;opacity:.85}.fallback-hint.svelte-16248mg{color:#7c8a97;font-size:.75rem;max-width:34rem;line-height:1.6}.fallback-hint.svelte-16248mg a:where(.svelte-16248mg){color:#cfe9ff;text-decoration:underline;text-underline-offset:3px} diff --git a/apps/dashboard/build/_app/immutable/assets/cognitive-palette.BALpZUFZ.css.br b/apps/dashboard/build/_app/immutable/assets/cognitive-palette.BALpZUFZ.css.br deleted file mode 100644 index 418035c..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/cognitive-palette.BALpZUFZ.css.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/cognitive-palette.BALpZUFZ.css.gz b/apps/dashboard/build/_app/immutable/assets/cognitive-palette.BALpZUFZ.css.gz deleted file mode 100644 index c7a451a..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/cognitive-palette.BALpZUFZ.css.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/reveal.Dmxpik8H.css b/apps/dashboard/build/_app/immutable/assets/reveal.Dmxpik8H.css deleted file mode 100644 index 180e2a9..0000000 --- a/apps/dashboard/build/_app/immutable/assets/reveal.Dmxpik8H.css +++ /dev/null @@ -1 +0,0 @@ -.header-tile.svelte-162svzm:after{content:"";position:absolute;top:-1px;right:-1px;bottom:-1px;left:-1px;border-radius:inherit;box-shadow:0 0 18px -2px currentColor;opacity:.35;pointer-events:none}@media not (prefers-reduced-motion:reduce){.header-tile.svelte-162svzm:after{animation:svelte-162svzm-tile-glow 4s ease-in-out infinite}@keyframes svelte-162svzm-tile-glow{0%,to{opacity:.22}50%{opacity:.5}}}.text-balance.svelte-162svzm{text-wrap:balance}.text-pretty.svelte-162svzm{text-wrap:pretty} diff --git a/apps/dashboard/build/_app/immutable/assets/reveal.Dmxpik8H.css.br b/apps/dashboard/build/_app/immutable/assets/reveal.Dmxpik8H.css.br deleted file mode 100644 index 417d6c0..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/reveal.Dmxpik8H.css.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/assets/reveal.Dmxpik8H.css.gz b/apps/dashboard/build/_app/immutable/assets/reveal.Dmxpik8H.css.gz deleted file mode 100644 index fb7c3df..0000000 Binary files a/apps/dashboard/build/_app/immutable/assets/reveal.Dmxpik8H.css.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/B9l3DI-J.js b/apps/dashboard/build/_app/immutable/chunks/B9l3DI-J.js deleted file mode 100644 index f34fc8e..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/B9l3DI-J.js +++ /dev/null @@ -1,2 +0,0 @@ -import{h as Q,y as R,z as T,U,aQ as X,Y as L,a as A,f as k,c as f,r as l,X as F,p as Y,j as C,b as D,s as j,g as I,d as G,u as J}from"./CGq8RnJq.js";import"./Bzak7iHL.js";import{s as P}from"./DAau0uzT.js";import{s as K}from"./BbCqB9Us.js";import{i as B}from"./Ccqjq5DS.js";import{s as E}from"./uCQU803Y.js";import{p as m}from"./DV6OI5iy.js";import{I as S}from"./CKbQrCJw.js";function de(t,e,a){Q(()=>{var r=R(()=>e(t,a==null?void 0:a())||{});if(a&&(r!=null&&r.update)){var i=!1,n={};T(()=>{var s=a();U(s),i&&X(n,s)&&(n=s,r.update(s))}),i=!0}if(r!=null&&r.destroy)return()=>r.destroy()})}var V=k('

'),W=k('
'),Z=k('

');function fe(t,e){let a=m(e,"accent",3,"synapse");var r=Z(),i=f(r),n=f(i),s=f(n);S(s,{get name(){return e.icon},size:22,draw:!0}),l(n);var x=F(n,2),u=f(x),v=f(u,!0);l(u);var h=F(u,2);{var b=c=>{var d=V(),y=f(d,!0);l(d),L(()=>P(y,e.subtitle)),A(c,d)};B(h,c=>{e.subtitle&&c(b)})}l(x),l(i);var p=F(i,2);{var g=c=>{var d=W(),y=f(d);K(y,()=>e.children),l(d),A(c,d)};B(p,c=>{e.children&&c(g)})}l(r),L(()=>{E(n,1,`header-tile relative flex items-center justify-center w-11 h-11 rounded-xl shrink-0 - bg-${a()??""}/12 border border-${a()??""}/25 text-${a()??""}-glow`,"svelte-162svzm"),P(v,e.title)}),A(t,r)}var $=k(" ");function le(t,e){var q;Y(e,!0);let a=m(e,"decimals",3,0),r=m(e,"scale",3,1),i=m(e,"prefix",3,""),n=m(e,"suffix",3,""),s=m(e,"duration",3,900),x=m(e,"class",3,""),u=m(e,"group",3,!0),v=G(0),h=0,b=0,p=0,g=!1;const c=typeof window<"u"&&((q=window.matchMedia)==null?void 0:q.call(window,"(prefers-reduced-motion: reduce)").matches);function d(o){return o===1?1:1-Math.pow(2,-10*o)}function y(o){if(c){j(v,o,!0);return}cancelAnimationFrame(h),b=I(v),p=0;function w(M){p||(p=M);const _=Math.min(1,(M-p)/s());j(v,b+(o-b)*d(_)),_<1?h=requestAnimationFrame(w):j(v,o,!0)}h=requestAnimationFrame(w)}C(()=>{const o=e.value;return g||(g=!0),y(o),()=>cancelAnimationFrame(h)});let H=J(()=>(()=>{const w=(I(v)*r()).toFixed(a());if(!u())return w;const[M,_]=w.split("."),O=M.replace(/\B(?=(\d{3})+(?!\d))/g,",");return _!==void 0?`${O}.${_}`:O})());var z=$(),N=f(z);l(z),L(()=>{E(z,1,`tabular-nums ${x()??""}`),P(N,`${i()??""}${I(H)??""}${n()??""}`)}),A(t,z),D()}const ee=()=>{var t;return typeof window<"u"&&((t=window.matchMedia)==null?void 0:t.call(window,"(prefers-reduced-motion: reduce)").matches)};function me(t,e={}){const{y:a=16,delay:r=0,once:i=!0,threshold:n=.12}=e;if(ee())return t.classList.add("reveal-in"),{};t.classList.add("reveal"),t.style.setProperty("--reveal-y",`${a}px`),r&&t.style.setProperty("--reveal-delay",`${r}ms`);const s=new IntersectionObserver(x=>{for(const u of x)u.isIntersecting?(t.classList.add("reveal-in"),i&&s.unobserve(t)):i||t.classList.remove("reveal-in")},{threshold:n,rootMargin:"0px 0px -8% 0px"});return s.observe(t),{destroy(){s.disconnect()}}}export{le as A,fe as P,de as a,me as r}; diff --git a/apps/dashboard/build/_app/immutable/chunks/B9l3DI-J.js.br b/apps/dashboard/build/_app/immutable/chunks/B9l3DI-J.js.br deleted file mode 100644 index eeca7b1..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/B9l3DI-J.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/B9l3DI-J.js.gz b/apps/dashboard/build/_app/immutable/chunks/B9l3DI-J.js.gz deleted file mode 100644 index f2ebad2..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/B9l3DI-J.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/BKh9s_e0.js b/apps/dashboard/build/_app/immutable/chunks/BKh9s_e0.js deleted file mode 100644 index 1ad5ab8..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/BKh9s_e0.js +++ /dev/null @@ -1 +0,0 @@ -function m(z,a,e,t){const o=1/Math.tan(z/2),y=1/(e-t),n=new Float32Array(16);return n[0]=o/a,n[5]=o,n[10]=t*y,n[11]=-1,n[14]=t*e*y,n}function w(z,a,e){const[t,o,y]=z;let n=t-a[0],f=o-a[1],r=y-a[2],c=Math.hypot(n,f,r)||1;n/=c,f/=c,r/=c;let h=e[1]*r-e[2]*f,s=e[2]*n-e[0]*r,x=e[0]*f-e[1]*n;c=Math.hypot(h,s,x)||1,h/=c,s/=c,x/=c;const i=f*x-r*s,u=r*h-n*x,M=n*s-f*h,l=new Float32Array(16);return l[0]=h,l[1]=i,l[2]=n,l[4]=s,l[5]=u,l[6]=f,l[8]=x,l[9]=M,l[10]=r,l[12]=-(h*t+s*o+x*y),l[13]=-(i*t+u*o+M*y),l[14]=-(n*t+f*o+r*y),l[15]=1,l}function A(z,a){const e=new Float32Array(16);for(let t=0;t<4;t++)for(let o=0;o<4;o++)e[t*4+o]=z[o]*a[t*4]+z[4+o]*a[t*4+1]+z[8+o]*a[t*4+2]+z[12+o]*a[t*4+3];return e}function v(z,a,e,t=.35){const o=z*Math.PI*2,y=[Math.sin(o)*e,e*t,Math.cos(o)*e],n=m(50*Math.PI/180,a,.1,4e3),f=w(y,[0,0,0],[0,1,0]);let r=-y[0],c=-y[1],h=-y[2],s=Math.hypot(r,c,h)||1;r/=s,c/=s,h/=s;let x=c*0-h*1,i=h*0-r*0,u=r*1-c*0;s=Math.hypot(x,i,u)||1,x/=s,i/=s,u/=s;const M=i*h-u*c,l=u*r-x*h,p=x*c-i*r;return{viewProj:A(n,f),right:[x,i,u],up:[M,l,p],eye:y}}export{w as l,A as m,v as o,m as p}; diff --git a/apps/dashboard/build/_app/immutable/chunks/BKh9s_e0.js.br b/apps/dashboard/build/_app/immutable/chunks/BKh9s_e0.js.br deleted file mode 100644 index a91b1bf..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/BKh9s_e0.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/BKh9s_e0.js.gz b/apps/dashboard/build/_app/immutable/chunks/BKh9s_e0.js.gz deleted file mode 100644 index 13bd26c..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/BKh9s_e0.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/BMB5u1EX.js b/apps/dashboard/build/_app/immutable/chunks/BMB5u1EX.js deleted file mode 100644 index f783822..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/BMB5u1EX.js +++ /dev/null @@ -1,235 +0,0 @@ -var k=Object.defineProperty;var G=(a,e,t)=>e in a?k(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var s=(a,e,t)=>G(a,typeof e!="symbol"?e+"":e,t);import"./Bzak7iHL.js";import{o as V,a as U,s as z}from"./DAau0uzT.js";import{p as H,d as q,e as X,aH as W,a as T,b as Y,f as B,s as K,X as E,g as S,c as P,r as A,af as j,Y as J}from"./CGq8RnJq.js";import{b as Z,i as Q}from"./Ccqjq5DS.js";import{p as $}from"./DV6OI5iy.js";function D(a){let e=1779033703^a.length;for(let t=0;t>>19;return function(){let t=e+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function R(a){return function(){let e=a+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}class ee{constructor(e){s(this,"fps");s(this,"loopFrames");s(this,"seedStr");s(this,"_frame");s(this,"_totalFrames");s(this,"_rng");this.fps=e.fps??60,this.loopFrames=e.loopFrames??720,this.seedStr=e.seed,this._frame=0,this._totalFrames=0;const t=D(this.seedStr)();this._rng=R(Math.floor(t*2**32))}tick(){return this._frame=(this._frame+1)%this.loopFrames,this._totalFrames++,this.state}get state(){return{frame:this._frame,phase:this._frame/this.loopFrames,rng:this._rng,totalFrames:this._totalFrames}}reset(){this._frame=0,this._totalFrames=0;const e=D(this.seedStr)();this._rng=R(Math.floor(e*2**32))}get loopDuration(){return this.loopFrames/this.fps}get framesPerLoop(){return this.loopFrames}}function Fe(a,e,t,i){const r=Math.PI*(3-Math.sqrt(5)),o=1-a/(e-1||1)*2,n=Math.sqrt(1-o*o),l=r*a,h=Math.cos(l)*n,m=Math.sin(l)*n,u=(i()-.5)*.1*t,p=(i()-.5)*.1*t,c=(i()-.5)*.1*t;return[h*t+u,o*t+p,m*t+c]}const C=["recall-path","engram-birth","salience-rescue","forgetting-horizon","firewall"];function Se(a){return C.includes(a)}const Le=16,Me={posRadius:0,velRetention:4,colorFlags:8},Te={isCenter:1,suppressed:2,isAha:4,isFailure:8,isConfusion:16},Ee=2,Pe=4,Ae={recall:0,backwardCause:1,probe:2},te=20,De={none:0,firewall:1,dreamStorm:2,causalRecall:3,birth:4},y={liveKind:12,liveFrame:13,liveEnergy:14,projectionDays:15,cursorX:16,cursorY:17,cursorVx:18,cursorVy:19};function se(a){const e=C.indexOf(a);return e<0?0:e}function Re(a,e){return{id:a.id,index:e,label:a.label,type:a.type,retention:typeof a.retention=="number"?a.retention:0,tags:Array.isArray(a.tags)?a.tags:[],isCenter:!!a.isCenter,suppressed:(a.suppression_count??0)>0,stability:typeof a.stability=="number"?a.stability:void 0,lastAccessed:typeof a.lastAccessed=="string"?a.lastAccessed:void 0}}function re(a,e){const t=Math.max(1,a>>1),i=Math.max(1,e>>1),r=Math.min(6,Math.max(1,1+Math.floor(Math.log2(Math.min(t,i)/8)))),o=Array.from({length:r},(n,l)=>[Math.max(1,t>>l),Math.max(1,i>>l)]);return{baseW:t,baseH:i,mipCount:r,sizes:o}}const F=.18,ae=0,ie=2/255,oe=.85,ne=.62,le=` -// Tuning constants — interpolated from post.wgsl.ts (TS single source of truth). -const BLOOM_STRENGTH: f32 = ${F}; -const BLOOM_CHROMATIC_TEXELS: f32 = ${ae}; -const GRAIN_AMP: f32 = ${ie}; -const VIGNETTE_LIFT: f32 = ${oe}; -const VIGNETTE_TAN: f32 = ${ne}; - -// Params layout — VERBATIM from render-nodes.wgsl.ts (types.PARAMS_FLOATS). -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - _pad: f32, -}; - -// Globally unique bindings — each entry point statically uses a subset; the -// explicit bind group layouts in post-chain.ts carry exactly what each -// pipeline needs (blur: 1+2, composite: 0+2+3+4). -@group(0) @binding(0) var params: Params; // composite only -@group(0) @binding(1) var src: texture_2d; // blur chain input -@group(0) @binding(2) var samp: sampler; // shared -@group(0) @binding(3) var scene_tex: texture_2d; // composite only -@group(0) @binding(4) var bloom_tex: texture_2d; // composite only (FULL-mip view) - -struct FSOut { - @builtin(position) pos: vec4f, - @location(0) uv: vec2f, -}; - -// Fullscreen triangle from bit math — no vertex buffer, no arrays. -// vi 0/1/2 → clip (-1,-1) (3,-1) (-1,3); uv y flipped so uv(0,0) = top-left. -@vertex -fn vs_fullscreen(@builtin(vertex_index) vi: u32) -> FSOut { - let xy = vec2f(f32((vi << 1u) & 2u), f32(vi & 2u)) * 2.0 - 1.0; - var out: FSOut; - out.pos = vec4f(xy, 0.0, 1.0); - out.uv = vec2f(xy.x, -xy.y) * 0.5 + 0.5; - return out; -} - -fn luma(c: vec3f) -> f32 { - return dot(c, vec3f(0.2126, 0.7152, 0.0722)); -} - -// --------------------------------------------------------------------------- -// Bloom downsample — 13-tap Jimenez (SIGGRAPH 2014 "Next Generation Post -// Processing in Call of Duty: Advanced Warfare"), taps fully unrolled. -// -// a b c outer ring at ±2 texels -// j k inner ring at ±1 texels -// d e f e = center -// l m -// g h i -// -// Grouped as 5 overlapping 4-tap boxes: center box (the four inner taps) -// weight 0.5, four corner boxes weight 0.125 each. A flat field reproduces -// itself EXACTLY (0.5 + 4·0.125 = 1) — that exactness is what the void -// preimage in tone-reference.ts depends on. -// --------------------------------------------------------------------------- - -@fragment -fn fs_downsample_karis(in: FSOut) -> @location(0) vec4f { - let ts = 1.0 / vec2f(textureDimensions(src)); - let a = textureSampleLevel(src, samp, in.uv + vec2f(-2.0, -2.0) * ts, 0.0).rgb; - let b = textureSampleLevel(src, samp, in.uv + vec2f( 0.0, -2.0) * ts, 0.0).rgb; - let c = textureSampleLevel(src, samp, in.uv + vec2f( 2.0, -2.0) * ts, 0.0).rgb; - let d = textureSampleLevel(src, samp, in.uv + vec2f(-2.0, 0.0) * ts, 0.0).rgb; - let e = textureSampleLevel(src, samp, in.uv, 0.0).rgb; - let f = textureSampleLevel(src, samp, in.uv + vec2f( 2.0, 0.0) * ts, 0.0).rgb; - let g = textureSampleLevel(src, samp, in.uv + vec2f(-2.0, 2.0) * ts, 0.0).rgb; - let h = textureSampleLevel(src, samp, in.uv + vec2f( 0.0, 2.0) * ts, 0.0).rgb; - let i = textureSampleLevel(src, samp, in.uv + vec2f( 2.0, 2.0) * ts, 0.0).rgb; - let j = textureSampleLevel(src, samp, in.uv + vec2f(-1.0, -1.0) * ts, 0.0).rgb; - let k = textureSampleLevel(src, samp, in.uv + vec2f( 1.0, -1.0) * ts, 0.0).rgb; - let l = textureSampleLevel(src, samp, in.uv + vec2f(-1.0, 1.0) * ts, 0.0).rgb; - let m = textureSampleLevel(src, samp, in.uv + vec2f( 1.0, 1.0) * ts, 0.0).rgb; - - let box_c = (j + k + l + m) * 0.25; - let box_tl = (a + b + d + e) * 0.25; - let box_tr = (b + c + e + f) * 0.25; - let box_bl = (d + e + g + h) * 0.25; - let box_br = (e + f + h + i) * 0.25; - - // Karis average (fireflies killer) — used ONLY on the full→mip0 hop. - // Each box is additionally weighted 1/(1 + luma) and the sum RENORMALIZED: - // on a flat field every Karis factor is equal, so the result is exact. - let w_c = 0.5 / (1.0 + luma(box_c)); - let w_tl = 0.125 / (1.0 + luma(box_tl)); - let w_tr = 0.125 / (1.0 + luma(box_tr)); - let w_bl = 0.125 / (1.0 + luma(box_bl)); - let w_br = 0.125 / (1.0 + luma(box_br)); - let sum = w_c * box_c + w_tl * box_tl + w_tr * box_tr + w_bl * box_bl + w_br * box_br; - return vec4f(sum / (w_c + w_tl + w_tr + w_bl + w_br), 1.0); -} - -@fragment -fn fs_downsample(in: FSOut) -> @location(0) vec4f { - let ts = 1.0 / vec2f(textureDimensions(src)); - let a = textureSampleLevel(src, samp, in.uv + vec2f(-2.0, -2.0) * ts, 0.0).rgb; - let b = textureSampleLevel(src, samp, in.uv + vec2f( 0.0, -2.0) * ts, 0.0).rgb; - let c = textureSampleLevel(src, samp, in.uv + vec2f( 2.0, -2.0) * ts, 0.0).rgb; - let d = textureSampleLevel(src, samp, in.uv + vec2f(-2.0, 0.0) * ts, 0.0).rgb; - let e = textureSampleLevel(src, samp, in.uv, 0.0).rgb; - let f = textureSampleLevel(src, samp, in.uv + vec2f( 2.0, 0.0) * ts, 0.0).rgb; - let g = textureSampleLevel(src, samp, in.uv + vec2f(-2.0, 2.0) * ts, 0.0).rgb; - let h = textureSampleLevel(src, samp, in.uv + vec2f( 0.0, 2.0) * ts, 0.0).rgb; - let i = textureSampleLevel(src, samp, in.uv + vec2f( 2.0, 2.0) * ts, 0.0).rgb; - let j = textureSampleLevel(src, samp, in.uv + vec2f(-1.0, -1.0) * ts, 0.0).rgb; - let k = textureSampleLevel(src, samp, in.uv + vec2f( 1.0, -1.0) * ts, 0.0).rgb; - let l = textureSampleLevel(src, samp, in.uv + vec2f(-1.0, 1.0) * ts, 0.0).rgb; - let m = textureSampleLevel(src, samp, in.uv + vec2f( 1.0, 1.0) * ts, 0.0).rgb; - - let box_c = (j + k + l + m) * 0.25; - let box_tl = (a + b + d + e) * 0.25; - let box_tr = (b + c + e + f) * 0.25; - let box_bl = (d + e + g + h) * 0.25; - let box_br = (e + f + h + i) * 0.25; - return vec4f(box_c * 0.5 + (box_tl + box_tr + box_bl + box_br) * 0.125, 1.0); -} - -// --------------------------------------------------------------------------- -// Bloom upsample — 9-tap 3×3 tent, 1/16·[1 2 1; 2 4 2; 1 2 1], radius = one -// SOURCE-mip texel. Rendered with additive one/one blending onto the stored -// downsample of the destination mip (accumulate-up-the-chain). The resulting -// DC gain of exactly mipCount is normalized in fs_composite. -// --------------------------------------------------------------------------- - -@fragment -fn fs_upsample_tent(in: FSOut) -> @location(0) vec4f { - let ts = 1.0 / vec2f(textureDimensions(src)); - let a = textureSampleLevel(src, samp, in.uv + vec2f(-1.0, -1.0) * ts, 0.0).rgb; - let b = textureSampleLevel(src, samp, in.uv + vec2f( 0.0, -1.0) * ts, 0.0).rgb; - let c = textureSampleLevel(src, samp, in.uv + vec2f( 1.0, -1.0) * ts, 0.0).rgb; - let d = textureSampleLevel(src, samp, in.uv + vec2f(-1.0, 0.0) * ts, 0.0).rgb; - let e = textureSampleLevel(src, samp, in.uv, 0.0).rgb; - let f = textureSampleLevel(src, samp, in.uv + vec2f( 1.0, 0.0) * ts, 0.0).rgb; - let g = textureSampleLevel(src, samp, in.uv + vec2f(-1.0, 1.0) * ts, 0.0).rgb; - let h = textureSampleLevel(src, samp, in.uv + vec2f( 0.0, 1.0) * ts, 0.0).rgb; - let i = textureSampleLevel(src, samp, in.uv + vec2f( 1.0, 1.0) * ts, 0.0).rgb; - let sum = (a + c + g + i) + (b + d + f + h) * 2.0 + e * 4.0; - return vec4f(sum * (1.0 / 16.0), 1.0); -} - -// --------------------------------------------------------------------------- -// Composite — bloom-add → PBR Neutral → grain → vignette (order is mandated). -// --------------------------------------------------------------------------- - -// Khronos PBR Neutral — EXACT port of the Khronos reference implementation. -// Hue-preserving; the FSRS palette keeps its channel ordering. Pinned to the -// CPU mirror in post/tone-reference.ts (pbrNeutralReference) — keep in -// lockstep, the void-preimage tests run against the mirror. -fn pbr_neutral(color_in: vec3f) -> vec3f { - let start_compression = 0.8 - 0.04; - let desaturation = 0.15; - var color = color_in; - let x = min(color.r, min(color.g, color.b)); - // WGSL select(false_value, true_value, condition) — argument order trap. - let offset = select(0.04, x - 6.25 * x * x, x < 0.08); - color = color - vec3f(offset); - let peak = max(color.r, max(color.g, color.b)); - if (peak < start_compression) { - return color; - } - let d = 1.0 - start_compression; - let new_peak = 1.0 - d * d / (peak + d - start_compression); - color = color * (new_peak / peak); - let g = 1.0 / (desaturation * (peak - new_peak) + 1.0); - // mix weight = 1 - g per the Khronos spec. - return mix(color, vec3f(new_peak), 1.0 - g); -} - -// PCG hash — integers only, 24-bit-exact output in [0, 1). Deterministic. -fn pcg(v: u32) -> u32 { - var s = v * 747796405u + 2891336453u; - let t = ((s >> ((s >> 28u) + 4u)) ^ s) * 277803737u; - return (t >> 22u) ^ t; -} - -fn hashf(p: vec2u, f: u32) -> f32 { - return f32(pcg(p.x ^ pcg(p.y ^ pcg(f))) >> 8u) / 16777216.0; -} - -@fragment -fn fs_composite(in: FSOut) -> @location(0) vec4f { - let pix = vec2u(in.pos.xy); - // Exact 1:1 fetch (alpha discarded — see module header). - let scene = textureLoad(scene_tex, pix, 0).rgb; - - // Bloom, normalized by the mip count: the additive up-chain has DC gain - // exactly mipCount, so /mips makes flat-field gain exactly 1 — the void - // preimage holds and brightness is viewport-stable. Chromatic dispersion - // rides the bloom term ONLY (BLOOM_CHROMATIC_TEXELS = 0.0 kills it). - let mips = f32(textureNumLevels(bloom_tex)); - let dims = vec2f(textureDimensions(bloom_tex)); - let dvec = in.uv - vec2f(0.5); - let off = dvec * (BLOOM_CHROMATIC_TEXELS * dot(dvec, dvec) * 4.0) / dims; - let bloom = vec3f( - textureSampleLevel(bloom_tex, samp, in.uv - off, 0.0).r, - textureSampleLevel(bloom_tex, samp, in.uv, 0.0).g, - textureSampleLevel(bloom_tex, samp, in.uv + off, 0.0).b - ) / mips; - - var c = pbr_neutral(scene + BLOOM_STRENGTH * bloom); - - // Seeded TPDF film grain (post-tonemap dither): keyed to the WRAPPED loop - // frame → 720-periodic and capture-pinned. Full strength in the shadows - // (kills #05060a banding), fades out of highlights. - let f = u32(params.frame + 0.5); - let n = hashf(pix, f) + hashf(pix ^ vec2u(0x9E3779B9u, 0x85EBCA6Bu), f) - 1.0; - let w = 1.0 - smoothstep(0.0, 0.8, luma(c)); - c += GRAIN_AMP * n * w; - - // cos⁴ vignette: cos⁴θ = (1 + r²·tan²)⁻², aspect-normalized so rn = 1.0 - // exactly at the corners regardless of viewport shape. Lifted floor keeps - // it an observatory, not a tunnel. - let ar = vec2f(params.viewport_w / max(params.viewport_h, 1.0), 1.0); - let rn = length((in.uv * 2.0 - 1.0) * ar) / length(ar); - let k = rn * rn * VIGNETTE_TAN * VIGNETTE_TAN; - c *= mix(VIGNETTE_LIFT, 1.0, 1.0 / ((1.0 + k) * (1.0 + k))); - - // NO gamma encode — display-referred pass-through, matching the pre-post - // look where shader outputs went straight to the swapchain. - return vec4f(c, 1.0); -} -`,x="rgba16float",ce={color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}};class ue{constructor(e,t,i){s(this,"device");s(this,"paramsBuffer");s(this,"samp");s(this,"blurLayout");s(this,"compositeLayout");s(this,"pipeDownFirst");s(this,"pipeDown");s(this,"pipeUp");s(this,"pipeComposite");s(this,"width",0);s(this,"height",0);s(this,"plan",null);s(this,"sceneTex",null);s(this,"_sceneView",null);s(this,"bloomTex",null);s(this,"mipViews",[]);s(this,"bloomFullView",null);s(this,"downBind",[]);s(this,"upBind",[]);s(this,"compositeBind",null);this.device=e,this.paramsBuffer=t,this.samp=e.createSampler({label:"observatory-post-sampler",minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"});const r=e.createShaderModule({label:"observatory-post",code:le});this.blurLayout=e.createBindGroupLayout({label:"observatory-post-blur-layout",entries:[{binding:1,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d"}},{binding:2,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),this.compositeLayout=e.createBindGroupLayout({label:"observatory-post-composite-layout",entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:2,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:3,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d"}},{binding:4,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d"}}]});const o=e.createPipelineLayout({label:"observatory-post-blur-pipe-layout",bindGroupLayouts:[this.blurLayout]}),n=e.createPipelineLayout({label:"observatory-post-composite-pipe-layout",bindGroupLayouts:[this.compositeLayout]}),l=(h,m,u,p,c)=>e.createRenderPipeline({label:h,layout:m,vertex:{module:r,entryPoint:"vs_fullscreen"},fragment:{module:r,entryPoint:u,targets:[{format:p,blend:c}]},primitive:{topology:"triangle-list"}});this.pipeDownFirst=l("observatory-post-down-karis",o,"fs_downsample_karis",x),this.pipeDown=l("observatory-post-down",o,"fs_downsample",x),this.pipeUp=l("observatory-post-up",o,"fs_upsample_tent",x,ce),this.pipeComposite=l("observatory-post-composite",n,"fs_composite",i)}get sceneView(){if(!this._sceneView)throw new Error("PostChain.ensure() must run before sceneView is used");return this._sceneView}ensure(e,t){var h,m;const i=Math.max(1,Math.floor(e)),r=Math.max(1,Math.floor(t));if(i===this.width&&r===this.height&&this.sceneTex!==null)return;this.width=i,this.height=r,(h=this.sceneTex)==null||h.destroy(),(m=this.bloomTex)==null||m.destroy(),this.sceneTex=this.device.createTexture({label:"observatory-scene-hdr",size:[i,r],format:x,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),this._sceneView=this.sceneTex.createView({label:"observatory-scene-hdr-view"});const o=re(i,r);this.plan=o,this.bloomTex=this.device.createTexture({label:"observatory-bloom-mips",size:[o.baseW,o.baseH],format:x,mipLevelCount:o.mipCount,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING});const n=this.bloomTex;this.mipViews=Array.from({length:o.mipCount},(u,p)=>n.createView({label:`observatory-bloom-mip-${p}`,baseMipLevel:p,mipLevelCount:1})),this.bloomFullView=n.createView({label:"observatory-bloom-full"});const l=this._sceneView;this.downBind=this.mipViews.map((u,p)=>this.device.createBindGroup({label:`observatory-bloom-down-bind-${p}`,layout:this.blurLayout,entries:[{binding:1,resource:p===0?l:this.mipViews[p-1]},{binding:2,resource:this.samp}]})),this.upBind=[];for(let u=0;u+1=0;n--){const l=e.beginRenderPass({label:`observatory-bloom-up-${n}`,colorAttachments:[{view:this.mipViews[n],loadOp:"load",storeOp:"store"}]});l.setPipeline(this.pipeUp),l.setBindGroup(0,this.upBind[n]),l.draw(3),l.end()}const o=e.beginRenderPass({label:"observatory-post-composite",colorAttachments:[{view:t,loadOp:"clear",storeOp:"store"}]});o.setPipeline(this.pipeComposite),o.setBindGroup(0,this.compositeBind),o.draw(3),o.end()}dispose(){var e,t;(e=this.sceneTex)==null||e.destroy(),(t=this.bloomTex)==null||t.destroy(),this.sceneTex=null,this.bloomTex=null,this._sceneView=null,this.bloomFullView=null,this.mipViews=[],this.downBind=[],this.upBind=[],this.compositeBind=null,this.plan=null,this.width=0,this.height=0}}const I=Math.sqrt(5/255/6.25),N=I-5/255,pe={r:I/(1+F),g:(6/255+N)/(1+F),b:(10/255+N)/(1+F),a:1},w=class w{constructor(e){s(this,"canvas");s(this,"device",null);s(this,"context",null);s(this,"format","bgra8unorm");s(this,"clock");s(this,"demo");s(this,"freezeFrame");s(this,"rafId",0);s(this,"running",!1);s(this,"disposed",!1);s(this,"maxDpr");s(this,"onFrame");s(this,"params",new Float32Array(te));s(this,"paramsBuffer",null);s(this,"passes",[]);s(this,"post",null);s(this,"_status",{state:"booting"});s(this,"statusListeners",new Set);s(this,"preFrameHook",null);s(this,"lastRafTs",0);s(this,"fpsEstimate",0);s(this,"accumulatorMs",0);s(this,"paused",!1);s(this,"frame",e=>{var p,c,d,b;if(!this.running||!this.device||!this.context||!this.paramsBuffer||!this.post)return;let t=0;for(this.lastRafTs>0&&(t=e-this.lastRafTs,t>0&&(this.fpsEstimate=Math.round(1e3/t))),this.lastRafTs=e,this.accumulatorMs+=Math.min(t,250);this.accumulatorMs>=w.FIXED_DT_MS;)this.paused||this.clock.tick(),this.accumulatorMs-=w.FIXED_DT_MS;const i=this.clock.state,r=this.freezeFrame??i.frame,o=r/this.clock.framesPerLoop,n=this.params;n[0]=r,n[1]=o,n[5]=.5+.5*Math.sin(2*Math.PI*4*o),n[6]=this.canvas.width,n[7]=this.canvas.height,n[9]=se(this.demo),n[10]=r/60,n[11]=this.freezeFrame!==null?1:0,(p=this.preFrameHook)==null||p.call(this,i.totalFrames),this.device.queue.writeBuffer(this.paramsBuffer,0,n);let l;try{l=this.context.getCurrentTexture()}catch{this.rafId=requestAnimationFrame(this.frame);return}this.post.ensure(l.width,l.height);const h=l.createView(),m=this.device.createCommandEncoder({label:"observatory-frame"});for(const v of this.passes)(c=v.compute)==null||c.call(v,m,r);const u=m.beginRenderPass({label:"observatory-main",colorAttachments:[{view:this.post.sceneView,clearValue:pe,loadOp:"clear",storeOp:"store"}]});for(const v of this.passes)(d=v.render)==null||d.call(v,u,r);u.end(),this.post.encode(m,h),this.device.queue.submit([m.finish()]),(b=this.onFrame)==null||b.call(this,r,this.fpsEstimate),this.rafId=requestAnimationFrame(this.frame)});this.canvas=e.canvas,this.demo=e.demo,this.maxDpr=e.maxDpr??2,this.onFrame=e.onFrame,this.clock=new ee({seed:e.seed}),this.freezeFrame=typeof e.freezeFrame=="number"&&Number.isFinite(e.freezeFrame)?(Math.floor(e.freezeFrame)%this.clock.framesPerLoop+this.clock.framesPerLoop)%this.clock.framesPerLoop:null,this.params[8]=1,this.setCursorPreNdc(999,999,0,0)}get status(){return this._status}get gpuDevice(){return this.device}get presentationFormat(){return this.format}get sceneFormat(){return x}get demoClock(){return this.clock}onStatus(e){return this.statusListeners.add(e),e(this._status),()=>this.statusListeners.delete(e)}setStatus(e){this._status=e;for(const t of this.statusListeners)t(e)}addPass(e){this.passes.push(e)}removePass(e){var i;const t=this.passes.indexOf(e);t!==-1&&(this.passes.splice(t,1),(i=e.dispose)==null||i.call(e))}clearPasses(){var e;for(const t of this.passes)(e=t.dispose)==null||e.call(t);this.passes.length=0}setPreFrameHook(e){this.preFrameHook=e}get totalFrames(){return this.clock.state.totalFrames}setCursorPreNdc(e,t,i=0,r=0){this.params[y.cursorX]=Number.isFinite(e)?e:999,this.params[y.cursorY]=Number.isFinite(t)?t:999,this.params[y.cursorVx]=Number.isFinite(i)?i:0,this.params[y.cursorVy]=Number.isFinite(r)?r:0}setPaused(e){this.paused=e}get isPaused(){return this.paused}get wallNowMs(){return Date.now()}async start(){var r;if(this.disposed)return!1;const e=navigator.gpu;if(!e)return this.setStatus({state:"unsupported",reason:"WebGPU is not available in this browser."}),!1;let t=null;try{t=await e.requestAdapter()}catch(o){return this.setStatus({state:"error",reason:o instanceof Error?o.message:"requestAdapter failed"}),!1}if(!t)return this.setStatus({state:"unsupported",reason:"No suitable GPU adapter found."}),!1;try{this.device=await t.requestDevice()}catch(o){return this.setStatus({state:"error",reason:o instanceof Error?o.message:"requestDevice failed"}),!1}if(this.disposed)return(r=this.device)==null||r.destroy(),this.device=null,!1;this.device.lost.then(o=>{this.disposed||o.reason==="destroyed"||(this.setStatus({state:"error",reason:`GPU device lost: ${o.message}`}),this.stopLoop())}),this.device.onuncapturederror=o=>{console.error("[observatory] WebGPU error:",o.error.message)};const i=this.canvas.getContext("webgpu");return i?(this.context=i,this.format=e.getPreferredCanvasFormat(),this.configureContext(),this.paramsBuffer=this.device.createBuffer({label:"observatory-params",size:this.params.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.post=new ue(this.device,this.paramsBuffer,this.format),this.setStatus({state:"running"}),this.running=!0,this.rafId=requestAnimationFrame(this.frame),!0):(this.setStatus({state:"error",reason:"Could not get webgpu canvas context."}),!1)}resize(){var r;if(!this.device||!this.context)return;const e=Math.min(window.devicePixelRatio||1,this.maxDpr),t=Math.max(1,Math.floor(this.canvas.clientWidth*e)),i=Math.max(1,Math.floor(this.canvas.clientHeight*e));(this.canvas.width!==t||this.canvas.height!==i)&&(this.canvas.width=t,this.canvas.height=i,this.configureContext(),(r=this.post)==null||r.ensure(t,i))}configureContext(){!this.device||!this.context||this.context.configure({device:this.device,format:this.format,alphaMode:"opaque"})}stopLoop(){this.running=!1,this.rafId!==0&&(cancelAnimationFrame(this.rafId),this.rafId=0)}dispose(){var e,t,i;this.disposed||(this.disposed=!0,this.stopLoop(),(e=this.paramsBuffer)==null||e.destroy(),this.paramsBuffer=null,(t=this.post)==null||t.dispose(),this.post=null,(i=this.device)==null||i.destroy(),this.device=null,this.context=null,this.passes=[],this.setStatus({state:"disposed"}),this.statusListeners.clear())}};s(w,"FIXED_DT_MS",1e3/60);let M=w;var me=B(``),he=B(' ',1);function Ne(a,e){H(e,!0);let t=$(e,"freezeFrame",3,null),i,r=null,o=q(X({state:"booting"})),n=null,l=null;V(()=>{r=new M({canvas:i,demo:e.demo,seed:e.seed,freezeFrame:t(),maxDpr:2,onFrame:(c,d)=>{var b;return(b=e.onframe)==null?void 0:b.call(e,c,d)}}),n=r.onStatus(c=>K(o,c,!0)),l=new ResizeObserver(()=>r==null?void 0:r.resize()),l.observe(i),r.start().then(c=>{var d;c&&r&&(r.resize(),(d=e.onready)==null||d.call(e,r))})}),U(()=>{n==null||n(),l==null||l.disconnect(),r==null||r.dispose(),r=null});var h=he(),m=W(h);Z(m,c=>i=c,()=>i);var u=E(m,2);{var p=c=>{var d=me(),b=E(P(d),2),v=P(b,!0);A(b),j(2),A(d),J(()=>z(v,S(o).reason)),T(c,d)};Q(u,c=>{(S(o).state==="unsupported"||S(o).state==="error")&&c(p)})}T(a,h),Y()}function O(a){const e=/^#?([0-9a-fA-F]{6})$/.exec(a.trim());if(!e)return[2/255,3/255,7/255];const t=parseInt(e[1],16);return[(t>>16&255)/255,(t>>8&255)/255,(t&255)/255]}const de={blackwater:"#020307"},f={luciferin:"#E9FFB7",healthy:"#A8FF5E",recall:"#29F2A9",bridge:"#1BD6FF",debt:"#8A4B18",extinction:"#2A160B"},fe=[f.extinction,f.debt,f.healthy,f.luciferin],g={trustMembrane:"#F4F1D0",caution:"#FFD166",veto:"#FF3B30",suppressionScar:"#B90D2B",labile:"#FF7A1A"},_={forward:"#00F5D4",retrograde:"#FF2DF7"},L={validRing:"#6BFFB8",txShadow:"#7C6CFF",supersession:"#FFB000"},Be={throughput:"#9DFFEB"};function Ce(a){const e=Math.max(0,Math.min(1,a)),t=fe.map(O),i=e*(t.length-1),r=Math.min(t.length-2,Math.floor(i)),o=i-r,n=t[r],l=t[r+1];return[n[0]+(l[0]-n[0])*o,n[1]+(l[1]-n[1])*o,n[2]+(l[2]-n[2])*o]}const ve={MemoryCreated:f.healthy,SearchPerformed:_.forward,ActivationSpread:f.recall,ImportanceScored:L.supersession,RetentionDecayed:f.debt,ConnectionDiscovered:_.forward,DeepReferenceCompleted:f.luciferin,BackfillFired:_.retrograde,CausalReceipt:_.retrograde,MemorySuppressed:g.suppressionScar,MemoryUnsuppressed:g.labile,MemoryPromoted:f.luciferin,MemoryDemoted:f.debt,MemoryPrOpened:g.caution,MemoryPrDecided:g.trustMembrane,HookVerdictRecorded:g.veto,TraceEvent:_.forward,DreamStarted:L.txShadow,DreamCompleted:L.validRing,Rac1CascadeSwept:g.suppressionScar};function Ie(a){return O(ve[a]??de.blackwater)}function Oe(a){const e=Math.max(0,Math.min(1,a));return .003+(.018-.003)*e}export{_ as C,C as D,Le as F,g as I,De as L,de as M,Me as N,Ne as O,Ae as P,f as R,Ee as U,Be as V,Ce as a,Te as b,Pe as c,Fe as d,Ie as e,ee as f,y as g,Se as i,Oe as m,O as r,Re as t}; diff --git a/apps/dashboard/build/_app/immutable/chunks/BMB5u1EX.js.br b/apps/dashboard/build/_app/immutable/chunks/BMB5u1EX.js.br deleted file mode 100644 index 8681c2c..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/BMB5u1EX.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/BMB5u1EX.js.gz b/apps/dashboard/build/_app/immutable/chunks/BMB5u1EX.js.gz deleted file mode 100644 index 827bcbb..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/BMB5u1EX.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/BbCqB9Us.js b/apps/dashboard/build/_app/immutable/chunks/BbCqB9Us.js deleted file mode 100644 index 520d3a5..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/BbCqB9Us.js +++ /dev/null @@ -1 +0,0 @@ -import{i as p,E as t}from"./CGq8RnJq.js";import{B as i}from"./W8qDZJD6.js";function E(r,s,...a){var e=new i(r);p(()=>{const n=s()??null;e.ensure(n,n&&(o=>n(o,...a)))},t)}export{E as s}; diff --git a/apps/dashboard/build/_app/immutable/chunks/BbCqB9Us.js.br b/apps/dashboard/build/_app/immutable/chunks/BbCqB9Us.js.br deleted file mode 100644 index 06f5453..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/BbCqB9Us.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/BbCqB9Us.js.gz b/apps/dashboard/build/_app/immutable/chunks/BbCqB9Us.js.gz deleted file mode 100644 index 40d5199..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/BbCqB9Us.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/BfiOPhbz.js b/apps/dashboard/build/_app/immutable/chunks/BfiOPhbz.js deleted file mode 100644 index 0c4d998..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/BfiOPhbz.js +++ /dev/null @@ -1 +0,0 @@ -import{Q as g,R as d,j as c,y as m,S as i,T as b,g as p,U as v,V as y,W as h}from"./CGq8RnJq.js";function x(n=!1){const s=g,e=s.l.u;if(!e)return;let f=()=>v(s.s);if(n){let a=0,t={};const _=y(()=>{let l=!1;const r=s.s;for(const o in r)r[o]!==t[o]&&(t[o]=r[o],l=!0);return l&&a++,a});f=()=>p(_)}e.b.length&&d(()=>{u(s,f),i(e.b)}),c(()=>{const a=m(()=>e.m.map(b));return()=>{for(const t of a)typeof t=="function"&&t()}}),e.a.length&&c(()=>{u(s,f),i(e.a)})}function u(n,s){if(n.l.s)for(const e of n.l.s)p(e);s()}h();export{x as i}; diff --git a/apps/dashboard/build/_app/immutable/chunks/BfiOPhbz.js.br b/apps/dashboard/build/_app/immutable/chunks/BfiOPhbz.js.br deleted file mode 100644 index 83e5cba..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/BfiOPhbz.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/BfiOPhbz.js.gz b/apps/dashboard/build/_app/immutable/chunks/BfiOPhbz.js.gz deleted file mode 100644 index 2f5b730..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/BfiOPhbz.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/Bo4EDkTQ.js b/apps/dashboard/build/_app/immutable/chunks/Bo4EDkTQ.js deleted file mode 100644 index 6690bb6..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/Bo4EDkTQ.js +++ /dev/null @@ -1,1331 +0,0 @@ -var Ol=Object.defineProperty;var Dl=(l,t,e)=>t in l?Ol(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var z=(l,t,e)=>Dl(l,typeof t!="symbol"?t+"":t,e);import{bf as Ll,i as Nl,w as Ul,ai as Vl,p as Wn,c as ot,r as at,X as ct,Y as jt,a as mt,b as Hn,f as vt,aS as Ph,aH as Fh,g as F,u as Bn,j as ji,d as xt,e as Gl,s as rt,bg as Wl,af as Hl}from"./CGq8RnJq.js";import{B as ql}from"./W8qDZJD6.js";import"./Bzak7iHL.js";import{d as Rh,s as Ot,b as Ri,o as Xl,e as Yl}from"./DAau0uzT.js";import{i as _t,b as Jl}from"./Ccqjq5DS.js";import{e as Eh,s as Cn,r as Zl}from"./DqfV0sZu.js";import{s as vs}from"./uCQU803Y.js";import{b as $l}from"./DGM4cicq.js";import{p as ut,a as jl,s as Kl}from"./DV6OI5iy.js";import{a as Ql}from"./D35IQVqe.js";import{e as tc}from"./Ch9vNiEl.js";import{b as ec}from"./DY7cP31Q.js";import{s as Hr}from"./HFGAk8XQ.js";import{t as ic,d as Oh,N as me,U as ir,F as Mt,b as Ki,P as ze,c as Qi,f as ea,L as At,g as zt,O as sc,D as nc}from"./BMB5u1EX.js";import{o as Ya}from"./BKh9s_e0.js";import{N as Ja}from"./CcUbQ_Wl.js";const rc=Symbol("NaN");function g0(l,t,e){Ul&&Vl();var i=new ql(l),s=!Ll();Nl(()=>{var n=t();n!==n&&(n=rc),s&&n!==null&&typeof n=="object"&&(n={}),i.ensure(n,e)})}/** - * @license - * Copyright 2010-2024 Three.js Authors - * SPDX-License-Identifier: MIT - */const Dh="172",y0={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},x0={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},b0=0,v0=1,w0=2,_0=3,M0=0,S0=1,A0=2,I0=3,qr=0,Lh=1,T0=2,ac=0,Za=1,oc=2,C0=3,B0=4,z0=5,$a=100,k0=101,P0=102,F0=103,R0=104,E0=200,O0=201,D0=202,L0=203,ja=204,Ka=205,N0=206,U0=207,V0=208,G0=209,W0=210,H0=211,q0=212,X0=213,Y0=214,J0=0,Z0=1,$0=2,Qa=3,j0=4,K0=5,Q0=6,tg=7,ia=0,eg=1,ig=2,sg=0,ng=1,rg=2,ag=3,og=4,hg=5,lg=6,cg=7,to="attached",hc="detached",sa=300,na=301,lc=302,cc=303,uc=304,dc=306,Xr=1e3,ge=1001,Yr=1002,pe=1003,fc=1004,ug=1004,pc=1005,dg=1005,ae=1006,mc=1007,fg=1007,qn=1008,pg=1008,Nh=1009,gc=1010,yc=1011,xc=1012,bc=1013,ra=1014,Gi=1015,vc=1016,wc=1017,_c=1018,Mc=1020,Sc=35902,Ac=1021,Ic=1022,As=1023,Tc=1024,Cc=1025,sr=1026,eo=1027,Uh=1028,Vh=1029,Bc=1030,zc=1031,mg=1032,kc=1033,Pc=33776,Fc=33777,Rc=33778,Ec=33779,Oc=35840,Dc=35841,Lc=35842,Nc=35843,Uc=36196,Vc=37492,Gc=37496,Wc=37808,Hc=37809,qc=37810,Xc=37811,Yc=37812,Jc=37813,Zc=37814,$c=37815,jc=37816,Kc=37817,Qc=37818,tu=37819,eu=37820,iu=37821,su=36492,nu=36494,ru=36495,au=36283,ou=36284,hu=36285,lu=36286,cu=2200,uu=2201,du=2202,zn=2300,Jr=2301,nr=2302,Ei=2400,Oi=2401,kn=2402,aa=2500,Gh=2501,gg=0,yg=1,xg=2,fu=3200,bg=3201,vg=3202,wg=3203,Hi=0,_g=1,Wh="",ne="srgb",io="srgb-linear",so="linear",rr="srgb",Mg=0,pi=7680,Sg=7681,Ag=7682,Ig=7683,Tg=34055,Cg=34056,Bg=5386,zg=512,kg=513,Pg=514,Fg=515,Rg=516,Eg=517,Og=518,no=519,Dg=512,Lg=513,Ng=514,Ug=515,Vg=516,Gg=517,Wg=518,Hg=519,Pn=35044,qg=35048,Xg=35040,Yg=35045,Jg=35049,Zg=35041,$g=35046,jg=35050,Kg=35042,Qg="100",ty="300 es",Be=2e3,Fn=2001;class Xe{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const i=this._listeners;return i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const n=s.indexOf(e);n!==-1&&s.splice(n,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const i=this._listeners[t.type];if(i!==void 0){t.target=this;const s=i.slice(0);for(let n=0,r=s.length;n>8&255]+kt[l>>16&255]+kt[l>>24&255]+"-"+kt[t&255]+kt[t>>8&255]+"-"+kt[t>>16&15|64]+kt[t>>24&255]+"-"+kt[e&63|128]+kt[e>>8&255]+"-"+kt[e>>16&255]+kt[e>>24&255]+kt[i&255]+kt[i>>8&255]+kt[i>>16&255]+kt[i>>24&255]).toLowerCase()}function X(l,t,e){return Math.max(t,Math.min(e,l))}function oa(l,t){return(l%t+t)%t}function pu(l,t,e,i,s){return i+(l-t)*(s-i)/(e-t)}function mu(l,t,e){return l!==t?(e-l)/(t-l):0}function ws(l,t,e){return(1-e)*l+e*t}function gu(l,t,e,i){return ws(l,t,1-Math.exp(-e*i))}function yu(l,t=1){return t-Math.abs(oa(l,t*2)-t)}function xu(l,t,e){return l<=t?0:l>=e?1:(l=(l-t)/(e-t),l*l*(3-2*l))}function bu(l,t,e){return l<=t?0:l>=e?1:(l=(l-t)/(e-t),l*l*l*(l*(l*6-15)+10))}function vu(l,t){return l+Math.floor(Math.random()*(t-l+1))}function wu(l,t){return l+Math.random()*(t-l)}function _u(l){return l*(.5-Math.random())}function Mu(l){l!==void 0&&(ro=l);let t=ro+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Su(l){return l*ai}function Au(l){return l*Is}function Iu(l){return(l&l-1)===0&&l!==0}function Tu(l){return Math.pow(2,Math.ceil(Math.log(l)/Math.LN2))}function Cu(l){return Math.pow(2,Math.floor(Math.log(l)/Math.LN2))}function Bu(l,t,e,i,s){const n=Math.cos,r=Math.sin,a=n(e/2),o=r(e/2),h=n((t+i)/2),c=r((t+i)/2),u=n((t-i)/2),d=r((t-i)/2),f=n((i-t)/2),p=r((i-t)/2);switch(s){case"XYX":l.set(a*c,o*u,o*d,a*h);break;case"YZY":l.set(o*d,a*c,o*u,a*h);break;case"ZXZ":l.set(o*u,o*d,a*c,a*h);break;case"XZX":l.set(a*c,o*p,o*f,a*h);break;case"YXY":l.set(o*f,a*c,o*p,a*h);break;case"ZYZ":l.set(o*p,o*f,a*c,a*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Dt(l,t){switch(t.constructor){case Float32Array:return l;case Uint32Array:return l/4294967295;case Uint16Array:return l/65535;case Uint8Array:return l/255;case Int32Array:return Math.max(l/2147483647,-1);case Int16Array:return Math.max(l/32767,-1);case Int8Array:return Math.max(l/127,-1);default:throw new Error("Invalid component type.")}}function Y(l,t){switch(t.constructor){case Float32Array:return l;case Uint32Array:return Math.round(l*4294967295);case Uint16Array:return Math.round(l*65535);case Uint8Array:return Math.round(l*255);case Int32Array:return Math.round(l*2147483647);case Int16Array:return Math.round(l*32767);case Int8Array:return Math.round(l*127);default:throw new Error("Invalid component type.")}}const ey={DEG2RAD:ai,RAD2DEG:Is,generateUUID:Qt,clamp:X,euclideanModulo:oa,mapLinear:pu,inverseLerp:mu,lerp:ws,damp:gu,pingpong:yu,smoothstep:xu,smootherstep:bu,randInt:vu,randFloat:wu,randFloatSpread:_u,seededRandom:Mu,degToRad:Su,radToDeg:Au,isPowerOfTwo:Iu,ceilPowerOfTwo:Tu,floorPowerOfTwo:Cu,setQuaternionFromProperEuler:Bu,normalize:Y,denormalize:Dt};class B{constructor(t=0,e=0){B.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6],this.y=s[1]*e+s[4]*i+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=X(this.x,t.x,e.x),this.y=X(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=X(this.x,t,e),this.y=X(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(X(i,t,e))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(X(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),s=Math.sin(e),n=this.x-t.x,r=this.y-t.y;return this.x=n*i-r*s+t.x,this.y=n*s+r*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class be{constructor(t,e,i,s,n,r,a,o,h){be.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,s,n,r,a,o,h)}set(t,e,i,s,n,r,a,o,h){const c=this.elements;return c[0]=t,c[1]=s,c[2]=a,c[3]=e,c[4]=n,c[5]=o,c[6]=i,c[7]=r,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,n=this.elements,r=i[0],a=i[3],o=i[6],h=i[1],c=i[4],u=i[7],d=i[2],f=i[5],p=i[8],m=s[0],g=s[3],x=s[6],y=s[1],b=s[4],v=s[7],_=s[2],M=s[5],A=s[8];return n[0]=r*m+a*y+o*_,n[3]=r*g+a*b+o*M,n[6]=r*x+a*v+o*A,n[1]=h*m+c*y+u*_,n[4]=h*g+c*b+u*M,n[7]=h*x+c*v+u*A,n[2]=d*m+f*y+p*_,n[5]=d*g+f*b+p*M,n[8]=d*x+f*v+p*A,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],a=t[5],o=t[6],h=t[7],c=t[8];return e*r*c-e*a*h-i*n*c+i*a*o+s*n*h-s*r*o}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],a=t[5],o=t[6],h=t[7],c=t[8],u=c*r-a*h,d=a*o-c*n,f=h*n-r*o,p=e*u+i*d+s*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=u*m,t[1]=(s*h-c*i)*m,t[2]=(a*i-s*r)*m,t[3]=d*m,t[4]=(c*e-s*o)*m,t[5]=(s*n-a*e)*m,t[6]=f*m,t[7]=(i*o-h*e)*m,t[8]=(r*e-i*n)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,s,n,r,a){const o=Math.cos(n),h=Math.sin(n);return this.set(i*o,i*h,-i*(o*r+h*a)+r+t,-s*h,s*o,-s*(-h*r+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(ar.makeScale(t,e)),this}rotate(t){return this.premultiply(ar.makeRotation(-t)),this}translate(t,e){return this.premultiply(ar.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let s=0;s<9;s++)if(e[s]!==i[s])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const ar=new be;function zu(l){for(let t=l.length-1;t>=0;--t)if(l[t]>=65535)return!0;return!1}const ku={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Di(l,t){return new ku[l](t)}function Rn(l){return document.createElementNS("http://www.w3.org/1999/xhtml",l)}function iy(){const l=Rn("canvas");return l.style.display="block",l}const ao={};function sy(l){l in ao||(ao[l]=!0,console.warn(l))}function ny(l,t,e){return new Promise(function(i,s){function n(){switch(l.clientWaitSync(t,l.SYNC_FLUSH_COMMANDS_BIT,0)){case l.WAIT_FAILED:s();break;case l.TIMEOUT_EXPIRED:setTimeout(n,e);break;default:i()}}setTimeout(n,e)})}function ry(l){const t=l.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function ay(l){const t=l.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}const oo=new be().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ho=new be().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Pu(){const l={enabled:!0,workingColorSpace:io,spaces:{},convert:function(s,n,r){return this.enabled===!1||n===r||!n||!r||(this.spaces[n].transfer===rr&&(s.r=ke(s.r),s.g=ke(s.g),s.b=ke(s.b)),this.spaces[n].primaries!==this.spaces[r].primaries&&(s.applyMatrix3(this.spaces[n].toXYZ),s.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===rr&&(s.r=Ui(s.r),s.g=Ui(s.g),s.b=Ui(s.b))),s},fromWorkingColorSpace:function(s,n){return this.convert(s,this.workingColorSpace,n)},toWorkingColorSpace:function(s,n){return this.convert(s,n,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Wh?so:this.spaces[s].transfer},getLuminanceCoefficients:function(s,n=this.workingColorSpace){return s.fromArray(this.spaces[n].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,n,r){return s.copy(this.spaces[n].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],i=[.3127,.329];return l.define({[io]:{primaries:t,whitePoint:i,transfer:so,toXYZ:oo,fromXYZ:ho,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:ne},outputColorSpaceConfig:{drawingBufferColorSpace:ne}},[ne]:{primaries:t,whitePoint:i,transfer:rr,toXYZ:oo,fromXYZ:ho,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:ne}}}),l}const $t=Pu();function ke(l){return l<.04045?l*.0773993808:Math.pow(l*.9478672986+.0521327014,2.4)}function Ui(l){return l<.0031308?l*12.92:1.055*Math.pow(l,.41666)-.055}let mi;class Fu{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{mi===void 0&&(mi=Rn("canvas")),mi.width=t.width,mi.height=t.height;const i=mi.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=mi}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Rn("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const s=i.getImageData(0,0,t.width,t.height),n=s.data;for(let r=0;r0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==sa)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Xr:t.x=t.x-Math.floor(t.x);break;case ge:t.x=t.x<0?0:1;break;case Yr:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Xr:t.y=t.y-Math.floor(t.y);break;case ge:t.y=t.y<0?0:1;break;case Yr:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}yt.DEFAULT_IMAGE=null;yt.DEFAULT_MAPPING=sa;yt.DEFAULT_ANISOTROPY=1;class It{constructor(t=0,e=0,i=0,s=1){It.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,s){return this.x=t,this.y=e,this.z=i,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,s=this.z,n=this.w,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*s+r[12]*n,this.y=r[1]*e+r[5]*i+r[9]*s+r[13]*n,this.z=r[2]*e+r[6]*i+r[10]*s+r[14]*n,this.w=r[3]*e+r[7]*i+r[11]*s+r[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,s,n;const o=t.elements,h=o[0],c=o[4],u=o[8],d=o[1],f=o[5],p=o[9],m=o[2],g=o[6],x=o[10];if(Math.abs(c-d)<.01&&Math.abs(u-m)<.01&&Math.abs(p-g)<.01){if(Math.abs(c+d)<.1&&Math.abs(u+m)<.1&&Math.abs(p+g)<.1&&Math.abs(h+f+x-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const b=(h+1)/2,v=(f+1)/2,_=(x+1)/2,M=(c+d)/4,A=(u+m)/4,S=(p+g)/4;return b>v&&b>_?b<.01?(i=0,s=.707106781,n=.707106781):(i=Math.sqrt(b),s=M/i,n=A/i):v>_?v<.01?(i=.707106781,s=0,n=.707106781):(s=Math.sqrt(v),i=M/s,n=S/s):_<.01?(i=.707106781,s=.707106781,n=0):(n=Math.sqrt(_),i=A/n,s=S/n),this.set(i,s,n,e),this}let y=Math.sqrt((g-p)*(g-p)+(u-m)*(u-m)+(d-c)*(d-c));return Math.abs(y)<.001&&(y=1),this.x=(g-p)/y,this.y=(u-m)/y,this.z=(d-c)/y,this.w=Math.acos((h+f+x-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=X(this.x,t.x,e.x),this.y=X(this.y,t.y,e.y),this.z=X(this.z,t.z,e.z),this.w=X(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=X(this.x,t,e),this.y=X(this.y,t,e),this.z=X(this.z,t,e),this.w=X(this.w,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(X(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class ha extends Xe{constructor(t=1,e=1,i={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new It(0,0,t,e),this.scissorTest=!1,this.viewport=new It(0,0,t,e);const s={width:t,height:e,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ae,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);const n=new yt(s,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);n.flipY=!1,n.generateMipmaps=i.generateMipmaps,n.internalFormat=i.internalFormat,this.textures=[];const r=i.count;for(let a=0;a=0?1:-1,b=1-x*x;if(b>Number.EPSILON){const _=Math.sqrt(b),M=Math.atan2(_,x*y);g=Math.sin(g*M)/_,a=Math.sin(a*M)/_}const v=a*y;if(o=o*g+d*v,h=h*g+f*v,c=c*g+p*v,u=u*g+m*v,g===1-a){const _=1/Math.sqrt(o*o+h*h+c*c+u*u);o*=_,h*=_,c*=_,u*=_}}t[e]=o,t[e+1]=h,t[e+2]=c,t[e+3]=u}static multiplyQuaternionsFlat(t,e,i,s,n,r){const a=i[s],o=i[s+1],h=i[s+2],c=i[s+3],u=n[r],d=n[r+1],f=n[r+2],p=n[r+3];return t[e]=a*p+c*u+o*f-h*d,t[e+1]=o*p+c*d+h*u-a*f,t[e+2]=h*p+c*f+a*d-o*u,t[e+3]=c*p-a*u-o*d-h*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,s){return this._x=t,this._y=e,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t._x,s=t._y,n=t._z,r=t._order,a=Math.cos,o=Math.sin,h=a(i/2),c=a(s/2),u=a(n/2),d=o(i/2),f=o(s/2),p=o(n/2);switch(r){case"XYZ":this._x=d*c*u+h*f*p,this._y=h*f*u-d*c*p,this._z=h*c*p+d*f*u,this._w=h*c*u-d*f*p;break;case"YXZ":this._x=d*c*u+h*f*p,this._y=h*f*u-d*c*p,this._z=h*c*p-d*f*u,this._w=h*c*u+d*f*p;break;case"ZXY":this._x=d*c*u-h*f*p,this._y=h*f*u+d*c*p,this._z=h*c*p+d*f*u,this._w=h*c*u-d*f*p;break;case"ZYX":this._x=d*c*u-h*f*p,this._y=h*f*u+d*c*p,this._z=h*c*p-d*f*u,this._w=h*c*u+d*f*p;break;case"YZX":this._x=d*c*u+h*f*p,this._y=h*f*u+d*c*p,this._z=h*c*p-d*f*u,this._w=h*c*u-d*f*p;break;case"XZY":this._x=d*c*u-h*f*p,this._y=h*f*u-d*c*p,this._z=h*c*p+d*f*u,this._w=h*c*u+d*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,s=Math.sin(i);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],s=e[4],n=e[8],r=e[1],a=e[5],o=e[9],h=e[2],c=e[6],u=e[10],d=i+a+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(c-o)*f,this._y=(n-h)*f,this._z=(r-s)*f}else if(i>a&&i>u){const f=2*Math.sqrt(1+i-a-u);this._w=(c-o)/f,this._x=.25*f,this._y=(s+r)/f,this._z=(n+h)/f}else if(a>u){const f=2*Math.sqrt(1+a-i-u);this._w=(n-h)/f,this._x=(s+r)/f,this._y=.25*f,this._z=(o+c)/f}else{const f=2*Math.sqrt(1+u-i-a);this._w=(r-s)/f,this._x=(n+h)/f,this._y=(o+c)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return iMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(X(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const s=Math.min(1,e/i);return this.slerp(t,s),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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,s=t._y,n=t._z,r=t._w,a=e._x,o=e._y,h=e._z,c=e._w;return this._x=i*c+r*a+s*h-n*o,this._y=s*c+r*o+n*a-i*h,this._z=n*c+r*h+i*o-s*a,this._w=r*c-i*a-s*o-n*h,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,s=this._y,n=this._z,r=this._w;let a=r*t._w+i*t._x+s*t._y+n*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=r,this._x=i,this._y=s,this._z=n,this;const o=1-a*a;if(o<=Number.EPSILON){const f=1-e;return this._w=f*r+e*this._w,this._x=f*i+e*this._x,this._y=f*s+e*this._y,this._z=f*n+e*this._z,this.normalize(),this}const h=Math.sqrt(o),c=Math.atan2(h,a),u=Math.sin((1-e)*c)/h,d=Math.sin(e*c)/h;return this._w=r*u+this._w*d,this._x=i*u+this._x*d,this._y=s*u+this._y*d,this._z=n*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(s*Math.sin(t),s*Math.cos(t),n*Math.sin(e),n*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class w{constructor(t=0,e=0,i=0){w.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(lo.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(lo.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,s=this.z,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6]*s,this.y=n[1]*e+n[4]*i+n[7]*s,this.z=n[2]*e+n[5]*i+n[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,s=this.z,n=t.elements,r=1/(n[3]*e+n[7]*i+n[11]*s+n[15]);return this.x=(n[0]*e+n[4]*i+n[8]*s+n[12])*r,this.y=(n[1]*e+n[5]*i+n[9]*s+n[13])*r,this.z=(n[2]*e+n[6]*i+n[10]*s+n[14])*r,this}applyQuaternion(t){const e=this.x,i=this.y,s=this.z,n=t.x,r=t.y,a=t.z,o=t.w,h=2*(r*s-a*i),c=2*(a*e-n*s),u=2*(n*i-r*e);return this.x=e+o*h+r*u-a*c,this.y=i+o*c+a*h-n*u,this.z=s+o*u+n*c-r*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,s=this.z,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*s,this.y=n[1]*e+n[5]*i+n[9]*s,this.z=n[2]*e+n[6]*i+n[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=X(this.x,t.x,e.x),this.y=X(this.y,t.y,e.y),this.z=X(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=X(this.x,t,e),this.y=X(this.y,t,e),this.z=X(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(X(i,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,s=t.y,n=t.z,r=e.x,a=e.y,o=e.z;return this.x=s*o-n*a,this.y=n*r-i*o,this.z=i*a-s*r,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return hr.copy(this).projectOnVector(t),this.sub(hr)}reflect(t){return this.sub(hr.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(X(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,s=this.z-t.z;return e*e+i*i+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const s=Math.sin(e)*t;return this.x=s*Math.sin(i),this.y=Math.cos(e)*t,this.z=s*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const hr=new w,lo=new te;class Ht{constructor(t=new w(1/0,1/0,1/0),e=new w(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,i=t.length;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,ue),ue.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(ts),Ls.subVectors(this.max,ts),gi.subVectors(t.a,ts),yi.subVectors(t.b,ts),xi.subVectors(t.c,ts),De.subVectors(yi,gi),Le.subVectors(xi,yi),Je.subVectors(gi,xi);let e=[0,-De.z,De.y,0,-Le.z,Le.y,0,-Je.z,Je.y,De.z,0,-De.x,Le.z,0,-Le.x,Je.z,0,-Je.x,-De.y,De.x,0,-Le.y,Le.x,0,-Je.y,Je.x,0];return!lr(e,gi,yi,xi,Ls)||(e=[1,0,0,0,1,0,0,0,1],!lr(e,gi,yi,xi,Ls))?!1:(Ns.crossVectors(De,Le),e=[Ns.x,Ns.y,Ns.z],lr(e,gi,yi,xi,Ls))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ue).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(ue).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(_e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),_e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),_e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),_e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),_e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),_e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),_e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),_e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(_e),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const _e=[new w,new w,new w,new w,new w,new w,new w,new w],ue=new w,Ds=new Ht,gi=new w,yi=new w,xi=new w,De=new w,Le=new w,Je=new w,ts=new w,Ls=new w,Ns=new w,Ze=new w;function lr(l,t,e,i,s){for(let n=0,r=l.length-3;n<=r;n+=3){Ze.fromArray(l,n);const a=s.x*Math.abs(Ze.x)+s.y*Math.abs(Ze.y)+s.z*Math.abs(Ze.z),o=t.dot(Ze),h=e.dot(Ze),c=i.dot(Ze);if(Math.max(-Math.max(o,h,c),Math.min(o,h,c))>a)return!1}return!0}const Ou=new Ht,es=new w,cr=new w;class Lt{constructor(t=new w,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const i=this.center;e!==void 0?i.copy(e):Ou.setFromPoints(t).getCenter(i);let s=0;for(let n=0,r=t.length;nthis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;es.subVectors(t,this.center);const e=es.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),s=(i-this.radius)*.5;this.center.addScaledVector(es,s/i),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(cr.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(es.copy(t.center).add(cr)),this.expandByPoint(es.copy(t.center).sub(cr))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Me=new w,ur=new w,Us=new w,Ne=new w,dr=new w,Vs=new w,fr=new w;class ks{constructor(t=new w,e=new w(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Me)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Me.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Me.copy(this.origin).addScaledVector(this.direction,e),Me.distanceToSquared(t))}distanceSqToSegment(t,e,i,s){ur.copy(t).add(e).multiplyScalar(.5),Us.copy(e).sub(t).normalize(),Ne.copy(this.origin).sub(ur);const n=t.distanceTo(e)*.5,r=-this.direction.dot(Us),a=Ne.dot(this.direction),o=-Ne.dot(Us),h=Ne.lengthSq(),c=Math.abs(1-r*r);let u,d,f,p;if(c>0)if(u=r*o-a,d=r*a-o,p=n*c,u>=0)if(d>=-p)if(d<=p){const m=1/c;u*=m,d*=m,f=u*(u+r*d+2*a)+d*(r*u+d+2*o)+h}else d=n,u=Math.max(0,-(r*d+a)),f=-u*u+d*(d+2*o)+h;else d=-n,u=Math.max(0,-(r*d+a)),f=-u*u+d*(d+2*o)+h;else d<=-p?(u=Math.max(0,-(-r*n+a)),d=u>0?-n:Math.min(Math.max(-n,-o),n),f=-u*u+d*(d+2*o)+h):d<=p?(u=0,d=Math.min(Math.max(-n,-o),n),f=d*(d+2*o)+h):(u=Math.max(0,-(r*n+a)),d=u>0?n:Math.min(Math.max(-n,-o),n),f=-u*u+d*(d+2*o)+h);else d=r>0?-n:n,u=Math.max(0,-(r*d+a)),f=-u*u+d*(d+2*o)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(ur).addScaledVector(Us,d),f}intersectSphere(t,e){Me.subVectors(t.center,this.origin);const i=Me.dot(this.direction),s=Me.dot(Me)-i*i,n=t.radius*t.radius;if(s>n)return null;const r=Math.sqrt(n-s),a=i-r,o=i+r;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return i===null?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,s,n,r,a,o;const h=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,d=this.origin;return h>=0?(i=(t.min.x-d.x)*h,s=(t.max.x-d.x)*h):(i=(t.max.x-d.x)*h,s=(t.min.x-d.x)*h),c>=0?(n=(t.min.y-d.y)*c,r=(t.max.y-d.y)*c):(n=(t.max.y-d.y)*c,r=(t.min.y-d.y)*c),i>r||n>s||((n>i||isNaN(i))&&(i=n),(r=0?(a=(t.min.z-d.z)*u,o=(t.max.z-d.z)*u):(a=(t.max.z-d.z)*u,o=(t.min.z-d.z)*u),i>o||a>s)||((a>i||i!==i)&&(i=a),(o=0?i:s,e)}intersectsBox(t){return this.intersectBox(t,Me)!==null}intersectTriangle(t,e,i,s,n){dr.subVectors(e,t),Vs.subVectors(i,t),fr.crossVectors(dr,Vs);let r=this.direction.dot(fr),a;if(r>0){if(s)return null;a=1}else if(r<0)a=-1,r=-r;else return null;Ne.subVectors(this.origin,t);const o=a*this.direction.dot(Vs.crossVectors(Ne,Vs));if(o<0)return null;const h=a*this.direction.dot(dr.cross(Ne));if(h<0||o+h>r)return null;const c=-a*Ne.dot(fr);return c<0?null:this.at(c/r,n)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Z{constructor(t,e,i,s,n,r,a,o,h,c,u,d,f,p,m,g){Z.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,s,n,r,a,o,h,c,u,d,f,p,m,g)}set(t,e,i,s,n,r,a,o,h,c,u,d,f,p,m,g){const x=this.elements;return x[0]=t,x[4]=e,x[8]=i,x[12]=s,x[1]=n,x[5]=r,x[9]=a,x[13]=o,x[2]=h,x[6]=c,x[10]=u,x[14]=d,x[3]=f,x[7]=p,x[11]=m,x[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Z().fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,s=1/bi.setFromMatrixColumn(t,0).length(),n=1/bi.setFromMatrixColumn(t,1).length(),r=1/bi.setFromMatrixColumn(t,2).length();return e[0]=i[0]*s,e[1]=i[1]*s,e[2]=i[2]*s,e[3]=0,e[4]=i[4]*n,e[5]=i[5]*n,e[6]=i[6]*n,e[7]=0,e[8]=i[8]*r,e[9]=i[9]*r,e[10]=i[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,s=t.y,n=t.z,r=Math.cos(i),a=Math.sin(i),o=Math.cos(s),h=Math.sin(s),c=Math.cos(n),u=Math.sin(n);if(t.order==="XYZ"){const d=r*c,f=r*u,p=a*c,m=a*u;e[0]=o*c,e[4]=-o*u,e[8]=h,e[1]=f+p*h,e[5]=d-m*h,e[9]=-a*o,e[2]=m-d*h,e[6]=p+f*h,e[10]=r*o}else if(t.order==="YXZ"){const d=o*c,f=o*u,p=h*c,m=h*u;e[0]=d+m*a,e[4]=p*a-f,e[8]=r*h,e[1]=r*u,e[5]=r*c,e[9]=-a,e[2]=f*a-p,e[6]=m+d*a,e[10]=r*o}else if(t.order==="ZXY"){const d=o*c,f=o*u,p=h*c,m=h*u;e[0]=d-m*a,e[4]=-r*u,e[8]=p+f*a,e[1]=f+p*a,e[5]=r*c,e[9]=m-d*a,e[2]=-r*h,e[6]=a,e[10]=r*o}else if(t.order==="ZYX"){const d=r*c,f=r*u,p=a*c,m=a*u;e[0]=o*c,e[4]=p*h-f,e[8]=d*h+m,e[1]=o*u,e[5]=m*h+d,e[9]=f*h-p,e[2]=-h,e[6]=a*o,e[10]=r*o}else if(t.order==="YZX"){const d=r*o,f=r*h,p=a*o,m=a*h;e[0]=o*c,e[4]=m-d*u,e[8]=p*u+f,e[1]=u,e[5]=r*c,e[9]=-a*c,e[2]=-h*c,e[6]=f*u+p,e[10]=d-m*u}else if(t.order==="XZY"){const d=r*o,f=r*h,p=a*o,m=a*h;e[0]=o*c,e[4]=-u,e[8]=h*c,e[1]=d*u+m,e[5]=r*c,e[9]=f*u-p,e[2]=p*u-f,e[6]=a*c,e[10]=m*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Du,t,Lu)}lookAt(t,e,i){const s=this.elements;return Jt.subVectors(t,e),Jt.lengthSq()===0&&(Jt.z=1),Jt.normalize(),Ue.crossVectors(i,Jt),Ue.lengthSq()===0&&(Math.abs(i.z)===1?Jt.x+=1e-4:Jt.z+=1e-4,Jt.normalize(),Ue.crossVectors(i,Jt)),Ue.normalize(),Gs.crossVectors(Jt,Ue),s[0]=Ue.x,s[4]=Gs.x,s[8]=Jt.x,s[1]=Ue.y,s[5]=Gs.y,s[9]=Jt.y,s[2]=Ue.z,s[6]=Gs.z,s[10]=Jt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,n=this.elements,r=i[0],a=i[4],o=i[8],h=i[12],c=i[1],u=i[5],d=i[9],f=i[13],p=i[2],m=i[6],g=i[10],x=i[14],y=i[3],b=i[7],v=i[11],_=i[15],M=s[0],A=s[4],S=s[8],T=s[12],C=s[1],P=s[5],V=s[9],q=s[13],L=s[2],I=s[6],U=s[10],wt=s[14],Ct=s[3],tt=s[7],J=s[11],ht=s[15];return n[0]=r*M+a*C+o*L+h*Ct,n[4]=r*A+a*P+o*I+h*tt,n[8]=r*S+a*V+o*U+h*J,n[12]=r*T+a*q+o*wt+h*ht,n[1]=c*M+u*C+d*L+f*Ct,n[5]=c*A+u*P+d*I+f*tt,n[9]=c*S+u*V+d*U+f*J,n[13]=c*T+u*q+d*wt+f*ht,n[2]=p*M+m*C+g*L+x*Ct,n[6]=p*A+m*P+g*I+x*tt,n[10]=p*S+m*V+g*U+x*J,n[14]=p*T+m*q+g*wt+x*ht,n[3]=y*M+b*C+v*L+_*Ct,n[7]=y*A+b*P+v*I+_*tt,n[11]=y*S+b*V+v*U+_*J,n[15]=y*T+b*q+v*wt+_*ht,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],s=t[8],n=t[12],r=t[1],a=t[5],o=t[9],h=t[13],c=t[2],u=t[6],d=t[10],f=t[14],p=t[3],m=t[7],g=t[11],x=t[15];return p*(+n*o*u-s*h*u-n*a*d+i*h*d+s*a*f-i*o*f)+m*(+e*o*f-e*h*d+n*r*d-s*r*f+s*h*c-n*o*c)+g*(+e*h*u-e*a*f-n*r*u+i*r*f+n*a*c-i*h*c)+x*(-s*a*c-e*o*u+e*a*d+s*r*u-i*r*d+i*o*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],a=t[5],o=t[6],h=t[7],c=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],x=t[15],y=u*g*h-m*d*h+m*o*f-a*g*f-u*o*x+a*d*x,b=p*d*h-c*g*h-p*o*f+r*g*f+c*o*x-r*d*x,v=c*m*h-p*u*h+p*a*f-r*m*f-c*a*x+r*u*x,_=p*u*o-c*m*o-p*a*d+r*m*d+c*a*g-r*u*g,M=e*y+i*b+s*v+n*_;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/M;return t[0]=y*A,t[1]=(m*d*n-u*g*n-m*s*f+i*g*f+u*s*x-i*d*x)*A,t[2]=(a*g*n-m*o*n+m*s*h-i*g*h-a*s*x+i*o*x)*A,t[3]=(u*o*n-a*d*n-u*s*h+i*d*h+a*s*f-i*o*f)*A,t[4]=b*A,t[5]=(c*g*n-p*d*n+p*s*f-e*g*f-c*s*x+e*d*x)*A,t[6]=(p*o*n-r*g*n-p*s*h+e*g*h+r*s*x-e*o*x)*A,t[7]=(r*d*n-c*o*n+c*s*h-e*d*h-r*s*f+e*o*f)*A,t[8]=v*A,t[9]=(p*u*n-c*m*n-p*i*f+e*m*f+c*i*x-e*u*x)*A,t[10]=(r*m*n-p*a*n+p*i*h-e*m*h-r*i*x+e*a*x)*A,t[11]=(c*a*n-r*u*n-c*i*h+e*u*h+r*i*f-e*a*f)*A,t[12]=_*A,t[13]=(c*m*s-p*u*s+p*i*d-e*m*d-c*i*g+e*u*g)*A,t[14]=(p*a*s-r*m*s-p*i*o+e*m*o+r*i*g-e*a*g)*A,t[15]=(r*u*s-c*a*s+c*i*o-e*u*o-r*i*d+e*a*d)*A,this}scale(t){const e=this.elements,i=t.x,s=t.y,n=t.z;return e[0]*=i,e[4]*=s,e[8]*=n,e[1]*=i,e[5]*=s,e[9]*=n,e[2]*=i,e[6]*=s,e[10]*=n,e[3]*=i,e[7]*=s,e[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,s))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),s=Math.sin(e),n=1-i,r=t.x,a=t.y,o=t.z,h=n*r,c=n*a;return this.set(h*r+i,h*a-s*o,h*o+s*a,0,h*a+s*o,c*a+i,c*o-s*r,0,h*o-s*a,c*o+s*r,n*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,s,n,r){return this.set(1,i,n,0,t,1,r,0,e,s,1,0,0,0,0,1),this}compose(t,e,i){const s=this.elements,n=e._x,r=e._y,a=e._z,o=e._w,h=n+n,c=r+r,u=a+a,d=n*h,f=n*c,p=n*u,m=r*c,g=r*u,x=a*u,y=o*h,b=o*c,v=o*u,_=i.x,M=i.y,A=i.z;return s[0]=(1-(m+x))*_,s[1]=(f+v)*_,s[2]=(p-b)*_,s[3]=0,s[4]=(f-v)*M,s[5]=(1-(d+x))*M,s[6]=(g+y)*M,s[7]=0,s[8]=(p+b)*A,s[9]=(g-y)*A,s[10]=(1-(d+m))*A,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,i){const s=this.elements;let n=bi.set(s[0],s[1],s[2]).length();const r=bi.set(s[4],s[5],s[6]).length(),a=bi.set(s[8],s[9],s[10]).length();this.determinant()<0&&(n=-n),t.x=s[12],t.y=s[13],t.z=s[14],de.copy(this);const h=1/n,c=1/r,u=1/a;return de.elements[0]*=h,de.elements[1]*=h,de.elements[2]*=h,de.elements[4]*=c,de.elements[5]*=c,de.elements[6]*=c,de.elements[8]*=u,de.elements[9]*=u,de.elements[10]*=u,e.setFromRotationMatrix(de),i.x=n,i.y=r,i.z=a,this}makePerspective(t,e,i,s,n,r,a=Be){const o=this.elements,h=2*n/(e-t),c=2*n/(i-s),u=(e+t)/(e-t),d=(i+s)/(i-s);let f,p;if(a===Be)f=-(r+n)/(r-n),p=-2*r*n/(r-n);else if(a===Fn)f=-r/(r-n),p=-r*n/(r-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return o[0]=h,o[4]=0,o[8]=u,o[12]=0,o[1]=0,o[5]=c,o[9]=d,o[13]=0,o[2]=0,o[6]=0,o[10]=f,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,i,s,n,r,a=Be){const o=this.elements,h=1/(e-t),c=1/(i-s),u=1/(r-n),d=(e+t)*h,f=(i+s)*c;let p,m;if(a===Be)p=(r+n)*u,m=-2*u;else if(a===Fn)p=n*u,m=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return o[0]=2*h,o[4]=0,o[8]=0,o[12]=-d,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-f,o[2]=0,o[6]=0,o[10]=m,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let s=0;s<16;s++)if(e[s]!==i[s])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const bi=new w,de=new Z,Du=new w(0,0,0),Lu=new w(1,1,1),Ue=new w,Gs=new w,Jt=new w,co=new Z,uo=new te;class xe{constructor(t=0,e=0,i=0,s=xe.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,s=this._order){return this._x=t,this._y=e,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const s=t.elements,n=s[0],r=s[4],a=s[8],o=s[1],h=s[5],c=s[9],u=s[2],d=s[6],f=s[10];switch(e){case"XYZ":this._y=Math.asin(X(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,f),this._z=Math.atan2(-r,n)):(this._x=Math.atan2(d,h),this._z=0);break;case"YXZ":this._x=Math.asin(-X(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(o,h)):(this._y=Math.atan2(-u,n),this._z=0);break;case"ZXY":this._x=Math.asin(X(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-r,h)):(this._y=0,this._z=Math.atan2(o,n));break;case"ZYX":this._y=Math.asin(-X(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(o,n)):(this._x=0,this._z=Math.atan2(-r,h));break;case"YZX":this._z=Math.asin(X(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-u,n)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-X(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,h),this._y=Math.atan2(a,n)):(this._x=Math.atan2(-c,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return co.makeRotationFromQuaternion(t),this.setFromRotationMatrix(co,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return uo.setFromEuler(this),this.setFromQuaternion(uo,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}xe.DEFAULT_ORDER="XYZ";class Xh{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let i=0;i0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function n(a,o){return a[o.uuid]===void 0&&(a[o.uuid]=o.toJSON(t)),o.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=n(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const o=a.shapes;if(Array.isArray(o))for(let h=0,c=o.length;h0){s.children=[];for(let a=0;a0){s.animations=[];for(let a=0;a0&&(i.geometries=a),o.length>0&&(i.materials=o),h.length>0&&(i.textures=h),c.length>0&&(i.images=c),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=s,i;function r(a){const o=[];for(const h in a){const c=a[h];delete c.metadata,o.push(c)}return o}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let i=0;i0?s.multiplyScalar(1/Math.sqrt(n)):s.set(0,0,0)}static getBarycoord(t,e,i,s,n){fe.subVectors(s,e),Ae.subVectors(i,e),mr.subVectors(t,e);const r=fe.dot(fe),a=fe.dot(Ae),o=fe.dot(mr),h=Ae.dot(Ae),c=Ae.dot(mr),u=r*h-a*a;if(u===0)return n.set(0,0,0),null;const d=1/u,f=(h*o-a*c)*d,p=(r*c-a*o)*d;return n.set(1-f-p,p,f)}static containsPoint(t,e,i,s){return this.getBarycoord(t,e,i,s,Ie)===null?!1:Ie.x>=0&&Ie.y>=0&&Ie.x+Ie.y<=1}static getInterpolation(t,e,i,s,n,r,a,o){return this.getBarycoord(t,e,i,s,Ie)===null?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(n,Ie.x),o.addScaledVector(r,Ie.y),o.addScaledVector(a,Ie.z),o)}static getInterpolatedAttribute(t,e,i,s,n,r){return br.setScalar(0),vr.setScalar(0),wr.setScalar(0),br.fromBufferAttribute(t,e),vr.fromBufferAttribute(t,i),wr.fromBufferAttribute(t,s),r.setScalar(0),r.addScaledVector(br,n.x),r.addScaledVector(vr,n.y),r.addScaledVector(wr,n.z),r}static isFrontFacing(t,e,i,s){return fe.subVectors(i,e),Ae.subVectors(t,e),fe.cross(Ae).dot(s)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,s){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,i,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return fe.subVectors(this.c,this.b),Ae.subVectors(this.a,this.b),fe.cross(Ae).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Kt.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Kt.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,s,n){return Kt.getInterpolation(t,this.a,this.b,this.c,e,i,s,n)}containsPoint(t){return Kt.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Kt.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,s=this.b,n=this.c;let r,a;_i.subVectors(s,i),Mi.subVectors(n,i),gr.subVectors(t,i);const o=_i.dot(gr),h=Mi.dot(gr);if(o<=0&&h<=0)return e.copy(i);yr.subVectors(t,s);const c=_i.dot(yr),u=Mi.dot(yr);if(c>=0&&u<=c)return e.copy(s);const d=o*u-c*h;if(d<=0&&o>=0&&c<=0)return r=o/(o-c),e.copy(i).addScaledVector(_i,r);xr.subVectors(t,n);const f=_i.dot(xr),p=Mi.dot(xr);if(p>=0&&f<=p)return e.copy(n);const m=f*h-o*p;if(m<=0&&h>=0&&p<=0)return a=h/(h-p),e.copy(i).addScaledVector(Mi,a);const g=c*p-f*u;if(g<=0&&u-c>=0&&f-p>=0)return xo.subVectors(n,s),a=(u-c)/(u-c+(f-p)),e.copy(s).addScaledVector(xo,a);const x=1/(g+m+d);return r=m*x,a=d*x,e.copy(i).addScaledVector(_i,r).addScaledVector(Mi,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Yh={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},Ve={h:0,s:0,l:0},Hs={h:0,s:0,l:0};function _r(l,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?l+(t-l)*6*e:e<1/2?t:e<2/3?l+(t-l)*6*(2/3-e):l}class G{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(e===void 0&&i===void 0){const s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=ne){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,$t.toWorkingColorSpace(this,e),this}setRGB(t,e,i,s=$t.workingColorSpace){return this.r=t,this.g=e,this.b=i,$t.toWorkingColorSpace(this,s),this}setHSL(t,e,i,s=$t.workingColorSpace){if(t=oa(t,1),e=X(e,0,1),i=X(i,0,1),e===0)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=_r(r,n,t+1/3),this.g=_r(r,n,t),this.b=_r(r,n,t-1/3)}return $t.toWorkingColorSpace(this,s),this}setStyle(t,e=ne){function i(n){n!==void 0&&parseFloat(n)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let n;const r=s[1],a=s[2];switch(r){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,e);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,e);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=s[1],r=n.length;if(r===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(r===6)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=ne){const i=Yh[t.toLowerCase()];return i!==void 0?this.setHex(i,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=ke(t.r),this.g=ke(t.g),this.b=ke(t.b),this}copyLinearToSRGB(t){return this.r=Ui(t.r),this.g=Ui(t.g),this.b=Ui(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=ne){return $t.fromWorkingColorSpace(Pt.copy(this),t),Math.round(X(Pt.r*255,0,255))*65536+Math.round(X(Pt.g*255,0,255))*256+Math.round(X(Pt.b*255,0,255))}getHexString(t=ne){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=$t.workingColorSpace){$t.fromWorkingColorSpace(Pt.copy(this),e);const i=Pt.r,s=Pt.g,n=Pt.b,r=Math.max(i,s,n),a=Math.min(i,s,n);let o,h;const c=(a+r)/2;if(a===r)o=0,h=0;else{const u=r-a;switch(h=c<=.5?u/(r+a):u/(2-r-a),r){case i:o=(s-n)/u+(s0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const i=t[e];if(i===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Za&&(i.blending=this.blending),this.side!==qr&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==ja&&(i.blendSrc=this.blendSrc),this.blendDst!==Ka&&(i.blendDst=this.blendDst),this.blendEquation!==$a&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Qa&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==no&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==pi&&(i.stencilFail=this.stencilFail),this.stencilZFail!==pi&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==pi&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(n){const r=[];for(const a in n){const o=n[a];delete o.metadata,r.push(o)}return r}if(e){const n=s(t.textures),r=s(t.images);n.length>0&&(i.textures=n),r.length>0&&(i.images=r)}return i}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let i=null;if(e!==null){const s=e.length;i=new Array(s);for(let n=0;n!==s;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class qi extends Nt{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new G(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 xe,this.combine=ia,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Ce=Hu();function Hu(){const l=new ArrayBuffer(4),t=new Float32Array(l),e=new Uint32Array(l),i=new Uint32Array(512),s=new Uint32Array(512);for(let o=0;o<256;++o){const h=o-127;h<-27?(i[o]=0,i[o|256]=32768,s[o]=24,s[o|256]=24):h<-14?(i[o]=1024>>-h-14,i[o|256]=1024>>-h-14|32768,s[o]=-h-1,s[o|256]=-h-1):h<=15?(i[o]=h+15<<10,i[o|256]=h+15<<10|32768,s[o]=13,s[o|256]=13):h<128?(i[o]=31744,i[o|256]=64512,s[o]=24,s[o|256]=24):(i[o]=31744,i[o|256]=64512,s[o]=13,s[o|256]=13)}const n=new Uint32Array(2048),r=new Uint32Array(64),a=new Uint32Array(64);for(let o=1;o<1024;++o){let h=o<<13,c=0;for(;(h&8388608)===0;)h<<=1,c-=8388608;h&=-8388609,c+=947912704,n[o]=h|c}for(let o=1024;o<2048;++o)n[o]=939524096+(o-1024<<13);for(let o=1;o<31;++o)r[o]=o<<23;r[31]=1199570944,r[32]=2147483648;for(let o=33;o<63;++o)r[o]=2147483648+(o-32<<23);r[63]=3347054592;for(let o=1;o<64;++o)o!==32&&(a[o]=1024);return{floatView:t,uint32View:e,baseTable:i,shiftTable:s,mantissaTable:n,exponentTable:r,offsetTable:a}}function Wt(l){Math.abs(l)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),l=X(l,-65504,65504),Ce.floatView[0]=l;const t=Ce.uint32View[0],e=t>>23&511;return Ce.baseTable[e]+((t&8388607)>>Ce.shiftTable[e])}function xs(l){const t=l>>10;return Ce.uint32View[0]=Ce.mantissaTable[Ce.offsetTable[t]+(l&1023)]+Ce.exponentTable[t],Ce.floatView[0]}const ly={toHalfFloat:Wt,fromHalfFloat:xs},bt=new w,qs=new B;class ft{constructor(t,e,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=i,this.usage=Pn,this.updateRanges=[],this.gpuType=Gi,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let s=0,n=this.itemSize;se.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ht);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new w(-1/0,-1/0,-1/0),new w(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let i=0,s=e.length;i0&&(t.userData=this.userData),this.parameters!==void 0){const o=this.parameters;for(const h in o)o[h]!==void 0&&(t[h]=o[h]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const o in i){const h=i[o];t.data.attributes[o]=h.toJSON(t.data)}const s={};let n=!1;for(const o in this.morphAttributes){const h=this.morphAttributes[o],c=[];for(let u=0,d=h.length;u0&&(s[o]=c,n=!0)}n&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;i!==null&&this.setIndex(i.clone(e));const s=t.attributes;for(const h in s){const c=s[h];this.setAttribute(h,c.clone(e))}const n=t.morphAttributes;for(const h in n){const c=[],u=n[h];for(let d=0,f=u.length;d0){const s=e[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=s.length;n(t.far-t.near)**2))&&(bo.copy(n).invert(),$e.copy(t.ray).applyMatrix4(bo),!(i.boundingBox!==null&&$e.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,e,$e)))}_computeIntersections(t,e,i){let s;const n=this.geometry,r=this.material,a=n.index,o=n.attributes.position,h=n.attributes.uv,c=n.attributes.uv1,u=n.attributes.normal,d=n.groups,f=n.drawRange;if(a!==null)if(Array.isArray(r))for(let p=0,m=d.length;pe.far?null:{distance:h,point:js.clone(),object:l}}function Ks(l,t,e,i,s,n,r,a,o,h){l.getVertexPosition(a,Ys),l.getVertexPosition(o,Js),l.getVertexPosition(h,Zs);const c=Ju(l,t,e,i,Ys,Js,Zs,wo);if(c){const u=new w;Kt.getBarycoord(wo,Ys,Js,Zs,u),s&&(c.uv=Kt.getInterpolatedAttribute(s,a,o,h,u,new B)),n&&(c.uv1=Kt.getInterpolatedAttribute(n,a,o,h,u,new B)),r&&(c.normal=Kt.getInterpolatedAttribute(r,a,o,h,u,new w),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));const d={a,b:o,c:h,normal:new w,materialIndex:0};Kt.getNormal(Ys,Js,Zs,d.normal),c.face=d,c.barycoord=u}return c}class Xn extends j{constructor(t=1,e=1,i=1,s=1,n=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:s,heightSegments:n,depthSegments:r};const a=this;s=Math.floor(s),n=Math.floor(n),r=Math.floor(r);const o=[],h=[],c=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,i,e,t,r,n,0),p("z","y","x",1,-1,i,e,-t,r,n,1),p("x","z","y",1,1,t,i,e,s,r,2),p("x","z","y",1,-1,t,i,-e,s,r,3),p("x","y","z",1,-1,t,e,i,s,n,4),p("x","y","z",-1,-1,t,e,-i,s,n,5),this.setIndex(o),this.setAttribute("position",new D(h,3)),this.setAttribute("normal",new D(c,3)),this.setAttribute("uv",new D(u,2));function p(m,g,x,y,b,v,_,M,A,S,T){const C=v/A,P=_/S,V=v/2,q=_/2,L=M/2,I=A+1,U=S+1;let wt=0,Ct=0;const tt=new w;for(let J=0;J0?1:-1,c.push(tt.x,tt.y,tt.z),u.push(Ut/A),u.push(1-J/S),wt+=1}}for(let J=0;J0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}}class ua extends st{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Z,this.projectionMatrix=new Z,this.projectionMatrixInverse=new Z,this.coordinateSystem=Be}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Ge=new w,_o=new B,Mo=new B;class re extends ua{constructor(t=50,e=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=Is*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(ai*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Is*2*Math.atan(Math.tan(ai*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,i){Ge.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Ge.x,Ge.y).multiplyScalar(-t/Ge.z),Ge.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Ge.x,Ge.y).multiplyScalar(-t/Ge.z)}getViewSize(t,e){return this.getViewBounds(t,_o,Mo),e.subVectors(Mo,_o)}setViewOffset(t,e,i,s,n,r){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=s,this.view.width=n,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(ai*.5*this.fov)/this.zoom,i=2*e,s=this.aspect*i,n=-.5*s;const r=this.view;if(this.view!==null&&this.view.enabled){const o=r.fullWidth,h=r.fullHeight;n+=r.offsetX*s/o,e-=r.offsetY*i/h,s*=r.width/o,i*=r.height/h}const a=this.filmOffset;a!==0&&(n+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+s,e,e-i,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const Ai=-90,Ii=1;class Qu extends st{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new re(Ai,Ii,t,e);s.layers=this.layers,this.add(s);const n=new re(Ai,Ii,t,e);n.layers=this.layers,this.add(n);const r=new re(Ai,Ii,t,e);r.layers=this.layers,this.add(r);const a=new re(Ai,Ii,t,e);a.layers=this.layers,this.add(a);const o=new re(Ai,Ii,t,e);o.layers=this.layers,this.add(o);const h=new re(Ai,Ii,t,e);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[i,s,n,r,a,o]=e;for(const h of e)this.remove(h);if(t===Be)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),n.up.set(0,0,-1),n.lookAt(0,1,0),r.up.set(0,0,1),r.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(t===Fn)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),n.up.set(0,0,1),n.lookAt(0,1,0),r.up.set(0,0,-1),r.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const h of e)this.add(h),h.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[n,r,a,o,h,c]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0,s),t.render(e,n),t.setRenderTarget(i,1,s),t.render(e,r),t.setRenderTarget(i,2,s),t.render(e,a),t.setRenderTarget(i,3,s),t.render(e,o),t.setRenderTarget(i,4,s),t.render(e,h),i.texture.generateMipmaps=m,t.setRenderTarget(i,5,s),t.render(e,c),t.setRenderTarget(u,d,f),t.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class da extends yt{constructor(t,e,i,s,n,r,a,o,h,c){t=t!==void 0?t:[],e=e!==void 0?e:na,super(t,e,i,s,n,r,a,o,h,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class xy extends la{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1},s=[i,i,i,i,i,i];this.texture=new da(s,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:ae}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const i={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 ); - - } - `},s=new Xn(5,5,5),n=new ca({name:"CubemapFromEquirect",uniforms:Yn(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Lh,blending:ac});n.uniforms.tEquirect.value=e;const r=new qt(s,n),a=e.minFilter;return e.minFilter===qn&&(e.minFilter=ae),new Qu(1,10,this).update(t,r),e.minFilter=a,r.geometry.dispose(),r.material.dispose(),this}clear(t,e,i,s){const n=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,s);t.setRenderTarget(n)}}class fa{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new G(t),this.density=e}clone(){return new fa(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class pa{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new G(t),this.near=e,this.far=i}clone(){return new pa(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class td extends st{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new xe,this.environmentIntensity=1,this.environmentRotation=new xe,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class ma{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Pn,this.updateRanges=[],this.version=0,this.uuid=Qt()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,i){t*=this.stride,i*=e.stride;for(let s=0,n=this.stride;st.far||e.push({distance:o,point:ns.clone(),uv:Kt.getInterpolation(ns,Qs,as,tn,So,Ar,Ao,new B),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function en(l,t,e,i,s,n){zi.subVectors(l,e).addScalar(.5).multiply(i),s!==void 0?(rs.x=n*zi.x-s*zi.y,rs.y=s*zi.x+n*zi.y):rs.copy(zi),l.copy(t),l.x+=rs.x,l.y+=rs.y,l.applyMatrix4(Jh)}const sn=new w,Io=new w;class ed extends st{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let i=0,s=e.length;i0){let i,s;for(i=1,s=e.length;i0){sn.setFromMatrixPosition(this.matrixWorld);const s=t.ray.origin.distanceTo(sn);this.getObjectForDistance(s).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){sn.setFromMatrixPosition(t.matrixWorld),Io.setFromMatrixPosition(this.matrixWorld);const i=sn.distanceTo(Io)/t.zoom;e[0].object.visible=!0;let s,n;for(s=1,n=e.length;s=r)e[s-1].object.visible=!1,e[s].object.visible=!0;else break}for(this._currentLevel=s-1;s1?null:e.copy(t.start).addScaledVector(i,n)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const i=e||hd.getNormalMatrix(t),s=this.coplanarPoint(Cr).applyMatrix4(t),n=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(n),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const je=new Lt,an=new w;class $h{constructor(t=new Pi,e=new Pi,i=new Pi,s=new Pi,n=new Pi,r=new Pi){this.planes=[t,e,i,s,n,r]}set(t,e,i,s,n,r){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(s),a[4].copy(n),a[5].copy(r),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=Be){const i=this.planes,s=t.elements,n=s[0],r=s[1],a=s[2],o=s[3],h=s[4],c=s[5],u=s[6],d=s[7],f=s[8],p=s[9],m=s[10],g=s[11],x=s[12],y=s[13],b=s[14],v=s[15];if(i[0].setComponents(o-n,d-h,g-f,v-x).normalize(),i[1].setComponents(o+n,d+h,g+f,v+x).normalize(),i[2].setComponents(o+r,d+c,g+p,v+y).normalize(),i[3].setComponents(o-r,d-c,g-p,v-y).normalize(),i[4].setComponents(o-a,d-u,g-m,v-b).normalize(),e===Be)i[5].setComponents(o+a,d+u,g+m,v+b).normalize();else if(e===Fn)i[5].setComponents(a,u,m,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),je.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),je.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(je)}intersectsSprite(t){return je.center.set(0,0,0),je.radius=.7071067811865476,je.applyMatrix4(t.matrixWorld),this.intersectsSphere(je)}intersectsSphere(t){const e=this.planes,i=t.center,s=-t.radius;for(let n=0;n<6;n++)if(e[n].distanceToPoint(i)0?t.max.x:t.min.x,an.y=s.normal.y>0?t.max.y:t.min.y,an.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(an)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Br(l,t){return l-t}function ld(l,t){return l.z-t.z}function cd(l,t){return t.z-l.z}class ud{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,i,s){const n=this.pool,r=this.list;this.index>=n.length&&n.push({start:-1,count:-1,z:-1,index:-1});const a=n[this.index];r.push(a),this.index++,a.start=t,a.count=e,a.z=i,a.index=s}reset(){this.list.length=0,this.index=0}}const Gt=new Z,dd=new G(1,1,1),zr=new $h,on=new Ht,Ke=new Lt,ls=new w,Eo=new w,fd=new w,kr=new ud,Ft=new qt,hn=[];function pd(l,t,e=0){const i=t.itemSize;if(l.isInterleavedBufferAttribute||l.array.constructor!==t.array.constructor){const s=l.count;for(let n=0;n65535?new Uint32Array(s):new Uint16Array(s);e.setIndex(new ft(n,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const i in e.attributes){if(!t.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const s=t.getAttribute(i),n=e.getAttribute(i);if(s.itemSize!==n.itemSize||s.normalized!==n.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){const e=this._instanceInfo;if(t<0||t>=e.length||e[t].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){const e=this._geometryInfo;if(t<0||t>=e.length||e[t].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ht);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let i=0,s=e.length;i=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const i={visible:!0,active:!0,geometryIndex:t};let s=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Br),s=this._availableInstanceIds.shift(),this._instanceInfo[s]=i):(s=this._instanceInfo.length,this._instanceInfo.push(i));const n=this._matricesTexture;Gt.identity().toArray(n.image.data,s*16),n.needsUpdate=!0;const r=this._colorsTexture;return r&&(dd.toArray(r.image.data,s*4),r.needsUpdate=!0),this._visibilityChanged=!0,s}addGeometry(t,e=-1,i=-1){this._initializeGeometry(t),this._validateGeometry(t);const s={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},n=this._geometryInfo;s.vertexStart=this._nextVertexStart,s.reservedVertexCount=e===-1?t.getAttribute("position").count:e;const r=t.getIndex();if(r!==null&&(s.indexStart=this._nextIndexStart,s.reservedIndexCount=i===-1?r.count:i),s.indexStart!==-1&&s.indexStart+s.reservedIndexCount>this._maxIndexCount||s.vertexStart+s.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let o;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Br),o=this._availableGeometryIds.shift(),n[o]=s):(o=this._geometryCount,this._geometryCount++,n.push(s)),this.setGeometryAt(o,t),this._nextIndexStart=s.indexStart+s.reservedIndexCount,this._nextVertexStart=s.vertexStart+s.reservedVertexCount,o}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const i=this.geometry,s=i.getIndex()!==null,n=i.getIndex(),r=e.getIndex(),a=this._geometryInfo[t];if(s&&r.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,h=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(const c in i.attributes){const u=e.getAttribute(c),d=i.getAttribute(c);pd(u,d,o);const f=u.itemSize;for(let p=u.count,m=h;p=e.length||e[t].active===!1)return this;const i=this._instanceInfo;for(let s=0,n=i.length;sa).sort((r,a)=>i[r].vertexStart-i[a].vertexStart),n=this.geometry;for(let r=0,a=i.length;r=this._geometryCount)return null;const i=this.geometry,s=this._geometryInfo[t];if(s.boundingBox===null){const n=new Ht,r=i.index,a=i.attributes.position;for(let o=s.start,h=s.start+s.count;o=this._geometryCount)return null;const i=this.geometry,s=this._geometryInfo[t];if(s.boundingSphere===null){const n=new Lt;this.getBoundingBoxAt(t,on),on.getCenter(n.center);const r=i.index,a=i.attributes.position;let o=0;for(let h=s.start,c=s.start+s.count;ha.active);if(Math.max(...i.map(a=>a.vertexStart+a.reservedVertexCount))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...i.map(o=>o.indexStart+o.reservedIndexCount))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);const n=this.geometry;n.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new j,this._initializeGeometry(n));const r=this.geometry;n.index&&Qe(n.index.array,r.index.array);for(const a in n.attributes)Qe(n.attributes[a].array,r.attributes[a].array)}raycast(t,e){const i=this._instanceInfo,s=this._geometryInfo,n=this.matrixWorld,r=this.geometry;Ft.material=this.material,Ft.geometry.index=r.index,Ft.geometry.attributes=r.attributes,Ft.geometry.boundingBox===null&&(Ft.geometry.boundingBox=new Ht),Ft.geometry.boundingSphere===null&&(Ft.geometry.boundingSphere=new Lt);for(let a=0,o=i.length;a({...e,boundingBox:e.boundingBox!==null?e.boundingBox.clone():null,boundingSphere:e.boundingSphere!==null?e.boundingSphere.clone():null})),this._instanceInfo=t._instanceInfo.map(e=>({...e})),this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(t,e,i,s,n){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const r=s.getIndex(),a=r===null?1:r.array.BYTES_PER_ELEMENT,o=this._instanceInfo,h=this._multiDrawStarts,c=this._multiDrawCounts,u=this._geometryInfo,d=this.perObjectFrustumCulled,f=this._indirectTexture,p=f.image.data;d&&(Gt.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),zr.setFromProjectionMatrix(Gt,t.coordinateSystem));let m=0;if(this.sortObjects){Gt.copy(this.matrixWorld).invert(),ls.setFromMatrixPosition(i.matrixWorld).applyMatrix4(Gt),Eo.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(Gt);for(let y=0,b=o.length;y0){const s=e[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=s.length;ni)return;Pr.applyMatrix4(l.matrixWorld);const o=t.ray.origin.distanceTo(Pr);if(!(ot.far))return{distance:o,point:Do.clone().applyMatrix4(l.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:l}}const Lo=new w,No=new w;class Re extends hi{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,i=[];for(let s=0,n=e.count;s0){const s=e[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=s.length;ns.far)return;n.push({distance:h,distanceToRay:Math.sqrt(a),point:o,index:t,face:null,faceIndex:null,barycoord:null,object:r})}}class Kh extends st{constructor(){super(),this.isGroup=!0,this.type="Group"}}class by extends yt{constructor(t,e,i,s,n,r,a,o,h){super(t,e,i,s,n,r,a,o,h),this.isVideoTexture=!0,this.minFilter=r!==void 0?r:ae,this.magFilter=n!==void 0?n:ae,this.generateMipmaps=!1;const c=this;function u(){c.needsUpdate=!0,t.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class vy extends yt{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=pe,this.minFilter=pe,this.generateMipmaps=!1,this.needsUpdate=!0}}class ya extends yt{constructor(t,e,i,s,n,r,a,o,h,c,u,d){super(null,r,a,o,h,c,s,n,u,d),this.isCompressedTexture=!0,this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class wy extends ya{constructor(t,e,i,s,n,r){super(t,e,i,n,r),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=ge,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class _y extends ya{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,na),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class Qh extends yt{constructor(t,e,i,s,n,r,a,o,h){super(t,e,i,s,n,r,a,o,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class My extends yt{constructor(t,e,i,s,n,r,a,o,h,c=sr){if(c!==sr&&c!==eo)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&c===sr&&(i=ra),i===void 0&&c===eo&&(i=Mc),super(null,s,n,r,a,o,c,i,h),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:pe,this.minFilter=o!==void 0?o:pe,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class ve{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const i=this.getUtoTmapping(t);return this.getPoint(i,e)}getPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return e}getSpacedPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPointAt(i/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let i,s=this.getPoint(0),n=0;e.push(0);for(let r=1;r<=t;r++)i=this.getPoint(r/t),n+=i.distanceTo(s),e.push(n),s=i;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const i=this.getLengths();let s=0;const n=i.length;let r;e?r=e:r=t*i[n-1];let a=0,o=n-1,h;for(;a<=o;)if(s=Math.floor(a+(o-a)/2),h=i[s]-r,h<0)a=s+1;else if(h>0)o=s-1;else{o=s;break}if(s=o,i[s]===r)return s/(n-1);const c=i[s],d=i[s+1]-c,f=(r-c)/d;return(s+f)/(n-1)}getTangent(t,e){let s=t-1e-4,n=t+1e-4;s<0&&(s=0),n>1&&(n=1);const r=this.getPoint(s),a=this.getPoint(n),o=e||(r.isVector2?new B:new w);return o.copy(a).sub(r).normalize(),o}getTangentAt(t,e){const i=this.getUtoTmapping(t);return this.getTangent(i,e)}computeFrenetFrames(t,e){const i=new w,s=[],n=[],r=[],a=new w,o=new Z;for(let f=0;f<=t;f++){const p=f/t;s[f]=this.getTangentAt(p,new w)}n[0]=new w,r[0]=new w;let h=Number.MAX_VALUE;const c=Math.abs(s[0].x),u=Math.abs(s[0].y),d=Math.abs(s[0].z);c<=h&&(h=c,i.set(1,0,0)),u<=h&&(h=u,i.set(0,1,0)),d<=h&&i.set(0,0,1),a.crossVectors(s[0],i).normalize(),n[0].crossVectors(s[0],a),r[0].crossVectors(s[0],n[0]);for(let f=1;f<=t;f++){if(n[f]=n[f-1].clone(),r[f]=r[f-1].clone(),a.crossVectors(s[f-1],s[f]),a.length()>Number.EPSILON){a.normalize();const p=Math.acos(X(s[f-1].dot(s[f]),-1,1));n[f].applyMatrix4(o.makeRotationAxis(a,p))}r[f].crossVectors(s[f],n[f])}if(e===!0){let f=Math.acos(X(n[0].dot(n[t]),-1,1));f/=t,s[0].dot(a.crossVectors(n[0],n[t]))>0&&(f=-f);for(let p=1;p<=t;p++)n[p].applyMatrix4(o.makeRotationAxis(s[p],f*p)),r[p].crossVectors(s[p],n[p])}return{tangents:s,normals:n,binormals:r}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class xa extends ve{constructor(t=0,e=0,i=1,s=1,n=0,r=Math.PI*2,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=s,this.aStartAngle=n,this.aEndAngle=r,this.aClockwise=a,this.aRotation=o}getPoint(t,e=new B){const i=e,s=Math.PI*2;let n=this.aEndAngle-this.aStartAngle;const r=Math.abs(n)s;)n-=s;n0?0:(Math.floor(Math.abs(a)/n)+1)*n:o===0&&a===n-1&&(a=n-2,o=1);let h,c;this.closed||a>0?h=s[(a-1)%n]:(fn.subVectors(s[0],s[1]).add(s[0]),h=fn);const u=s[a%n],d=s[(a+1)%n];if(this.closed||a+2s.length-2?s.length-1:r+1],u=s[r>s.length-3?s.length-1:r+2];return i.set(Go(a,o.x,h.x,c.x,u.x),Go(a,o.y,h.y,c.y,u.y)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e=i){const r=s[n]-i,a=this.curves[n],o=a.getLength(),h=o===0?0:1-r/o;return a.getPointAt(h,e)}n++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let i=0,s=this.curves.length;i1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,i=t.curves.length;e0){const u=h.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(h);const c=h.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Jn extends j{constructor(t=[new B(0,-.5),new B(.5,0),new B(0,.5)],e=12,i=0,s=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:s},e=Math.floor(e),s=X(s,0,Math.PI*2);const n=[],r=[],a=[],o=[],h=[],c=1/e,u=new w,d=new B,f=new w,p=new w,m=new w;let g=0,x=0;for(let y=0;y<=t.length-1;y++)switch(y){case 0:g=t[y+1].x-t[y].x,x=t[y+1].y-t[y].y,f.x=x*1,f.y=-g,f.z=x*0,m.copy(f),f.normalize(),o.push(f.x,f.y,f.z);break;case t.length-1:o.push(m.x,m.y,m.z);break;default:g=t[y+1].x-t[y].x,x=t[y+1].y-t[y].y,f.x=x*1,f.y=-g,f.z=x*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),o.push(f.x,f.y,f.z),m.copy(p)}for(let y=0;y<=e;y++){const b=i+y*c*s,v=Math.sin(b),_=Math.cos(b);for(let M=0;M<=t.length-1;M++){u.x=t[M].x*v,u.y=t[M].y,u.z=t[M].x*_,r.push(u.x,u.y,u.z),d.x=y/e,d.y=M/(t.length-1),a.push(d.x,d.y);const A=o[3*M+0]*v,S=o[3*M+1],T=o[3*M+0]*_;h.push(A,S,T)}}for(let y=0;y0&&b(!0),e>0&&b(!1)),this.setIndex(c),this.setAttribute("position",new D(u,3)),this.setAttribute("normal",new D(d,3)),this.setAttribute("uv",new D(f,2));function y(){const v=new w,_=new w;let M=0;const A=(e-t)/i;for(let S=0;S<=n;S++){const T=[],C=S/n,P=C*(e-t)+t;for(let V=0;V<=s;V++){const q=V/s,L=q*o+a,I=Math.sin(L),U=Math.cos(L);_.x=P*I,_.y=-C*i+g,_.z=P*U,u.push(_.x,_.y,_.z),v.set(I,A,U).normalize(),d.push(v.x,v.y,v.z),f.push(q,1-C),T.push(p++)}m.push(T)}for(let S=0;S0||T!==0)&&(c.push(C,P,q),M+=3),(e>0||T!==n-1)&&(c.push(P,V,q),M+=3)}h.addGroup(x,M,0),x+=M}function b(v){const _=p,M=new B,A=new w;let S=0;const T=v===!0?t:e,C=v===!0?1:-1;for(let V=1;V<=s;V++)u.push(0,g*C,0),d.push(0,C,0),f.push(.5,.5),p++;const P=p;for(let V=0;V<=s;V++){const L=V/s*o+a,I=Math.cos(L),U=Math.sin(L);A.x=T*U,A.y=g*C,A.z=T*I,u.push(A.x,A.y,A.z),d.push(0,C,0),M.x=I*.5+.5,M.y=U*.5*C+.5,f.push(M.x,M.y),p++}for(let V=0;V.9&&A<.1&&(b<.2&&(r[y+0]+=1),v<.2&&(r[y+2]+=1),_<.2&&(r[y+4]+=1))}}function d(y){n.push(y.x,y.y,y.z)}function f(y,b){const v=y*3;b.x=t[v+0],b.y=t[v+1],b.z=t[v+2]}function p(){const y=new w,b=new w,v=new w,_=new w,M=new B,A=new B,S=new B;for(let T=0,C=0;T80*e){a=h=l[0],o=c=l[1];for(let p=e;ph&&(h=u),d>c&&(c=d);f=Math.max(h-a,c-o),f=f!==0?32767/f:0}return Cs(n,r,e,a,o,f,0),r}};function rl(l,t,e,i,s){let n,r;if(s===Yd(l,t,e,i)>0)for(n=t;n=t;n-=i)r=Wo(n,l[n],l[n+1],r);return r&&Zn(r,r.next)&&(zs(r),r=r.next),r}function li(l,t){if(!l)return l;t||(t=l);let e=l,i;do if(i=!1,!e.steiner&&(Zn(e,e.next)||dt(e.prev,e,e.next)===0)){if(zs(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Cs(l,t,e,i,s,n,r){if(!l)return;!r&&n&&Vd(l,i,s,n);let a=l,o,h;for(;l.prev!==l.next;){if(o=l.prev,h=l.next,n?Fd(l,i,s,n):Pd(l)){t.push(o.i/e|0),t.push(l.i/e|0),t.push(h.i/e|0),zs(l),l=h.next,a=h.next;continue}if(l=h,l===a){r?r===1?(l=Rd(li(l),t,e),Cs(l,t,e,i,s,n,2)):r===2&&Ed(l,t,e,i,s,n):Cs(li(l),t,e,i,s,n,1);break}}}function Pd(l){const t=l.prev,e=l,i=l.next;if(dt(t,e,i)>=0)return!1;const s=t.x,n=e.x,r=i.x,a=t.y,o=e.y,h=i.y,c=sn?s>r?s:r:n>r?n:r,f=a>o?a>h?a:h:o>h?o:h;let p=i.next;for(;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&Ni(s,a,n,o,r,h,p.x,p.y)&&dt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Fd(l,t,e,i){const s=l.prev,n=l,r=l.next;if(dt(s,n,r)>=0)return!1;const a=s.x,o=n.x,h=r.x,c=s.y,u=n.y,d=r.y,f=ao?a>h?a:h:o>h?o:h,g=c>u?c>d?c:d:u>d?u:d,x=$r(f,p,t,e,i),y=$r(m,g,t,e,i);let b=l.prevZ,v=l.nextZ;for(;b&&b.z>=x&&v&&v.z<=y;){if(b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==s&&b!==r&&Ni(a,c,o,u,h,d,b.x,b.y)&&dt(b.prev,b,b.next)>=0||(b=b.prevZ,v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==s&&v!==r&&Ni(a,c,o,u,h,d,v.x,v.y)&&dt(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;b&&b.z>=x;){if(b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==s&&b!==r&&Ni(a,c,o,u,h,d,b.x,b.y)&&dt(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;v&&v.z<=y;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==s&&v!==r&&Ni(a,c,o,u,h,d,v.x,v.y)&&dt(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Rd(l,t,e){let i=l;do{const s=i.prev,n=i.next.next;!Zn(s,n)&&al(s,i,i.next,n)&&Bs(s,n)&&Bs(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),zs(i),zs(i.next),i=l=n),i=i.next}while(i!==l);return li(i)}function Ed(l,t,e,i,s,n){let r=l;do{let a=r.next.next;for(;a!==r.prev;){if(r.i!==a.i&&Hd(r,a)){let o=ol(r,a);r=li(r,r.next),o=li(o,o.next),Cs(r,t,e,i,s,n,0),Cs(o,t,e,i,s,n,0);return}a=a.next}r=r.next}while(r!==l)}function Od(l,t,e,i){const s=[];let n,r,a,o,h;for(n=0,r=t.length;n=e.next.y&&e.next.y!==e.y){const d=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=n&&d>i&&(i=d,s=e.x=e.x&&e.x>=o&&n!==e.x&&Ni(rs.x||e.x===s.x&&Ud(s,e)))&&(s=e,c=u)),e=e.next;while(e!==a);return s}function Ud(l,t){return dt(l.prev,l,t.prev)<0&&dt(t.next,l,l.next)<0}function Vd(l,t,e,i){let s=l;do s.z===0&&(s.z=$r(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==l);s.prevZ.nextZ=null,s.prevZ=null,Gd(s)}function Gd(l){let t,e,i,s,n,r,a,o,h=1;do{for(e=l,l=null,n=null,r=0;e;){for(r++,i=e,a=0,t=0;t0||o>0&&i;)a!==0&&(o===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,o--),n?n.nextZ=s:l=s,s.prevZ=n,n=s;e=i}n.nextZ=null,h*=2}while(r>1);return l}function $r(l,t,e,i,s){return l=(l-e)*s|0,t=(t-i)*s|0,l=(l|l<<8)&16711935,l=(l|l<<4)&252645135,l=(l|l<<2)&858993459,l=(l|l<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,l|t<<1}function Wd(l){let t=l,e=l;do(t.x=(l-r)*(n-a)&&(l-r)*(i-a)>=(e-r)*(t-a)&&(e-r)*(n-a)>=(s-r)*(i-a)}function Hd(l,t){return l.next.i!==t.i&&l.prev.i!==t.i&&!qd(l,t)&&(Bs(l,t)&&Bs(t,l)&&Xd(l,t)&&(dt(l.prev,l,t.prev)||dt(l,t.prev,t))||Zn(l,t)&&dt(l.prev,l,l.next)>0&&dt(t.prev,t,t.next)>0)}function dt(l,t,e){return(t.y-l.y)*(e.x-t.x)-(t.x-l.x)*(e.y-t.y)}function Zn(l,t){return l.x===t.x&&l.y===t.y}function al(l,t,e,i){const s=xn(dt(l,t,e)),n=xn(dt(l,t,i)),r=xn(dt(e,i,l)),a=xn(dt(e,i,t));return!!(s!==n&&r!==a||s===0&&yn(l,e,t)||n===0&&yn(l,i,t)||r===0&&yn(e,l,i)||a===0&&yn(e,t,i))}function yn(l,t,e){return t.x<=Math.max(l.x,e.x)&&t.x>=Math.min(l.x,e.x)&&t.y<=Math.max(l.y,e.y)&&t.y>=Math.min(l.y,e.y)}function xn(l){return l>0?1:l<0?-1:0}function qd(l,t){let e=l;do{if(e.i!==l.i&&e.next.i!==l.i&&e.i!==t.i&&e.next.i!==t.i&&al(e,e.next,l,t))return!0;e=e.next}while(e!==l);return!1}function Bs(l,t){return dt(l.prev,l,l.next)<0?dt(l,t,l.next)>=0&&dt(l,l.prev,t)>=0:dt(l,t,l.prev)<0||dt(l,l.next,t)<0}function Xd(l,t){let e=l,i=!1;const s=(l.x+t.x)/2,n=(l.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==l);return i}function ol(l,t){const e=new jr(l.i,l.x,l.y),i=new jr(t.i,t.x,t.y),s=l.next,n=t.prev;return l.next=t,t.prev=l,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function Wo(l,t,e,i){const s=new jr(l,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function zs(l){l.next.prev=l.prev,l.prev.next=l.next,l.prevZ&&(l.prevZ.nextZ=l.nextZ),l.nextZ&&(l.nextZ.prevZ=l.prevZ)}function jr(l,t,e){this.i=l,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Yd(l,t,e,i){let s=0;for(let n=t,r=e-i;n2&&l[t-1].equals(l[0])&&l.pop()}function qo(l,t){for(let e=0;eNumber.EPSILON){const Vt=Math.sqrt(ie),Bt=Math.sqrt(K*K+lt*lt),fi=E.x-O/Vt,Ji=E.y+nt/Vt,tr=R.x-lt/Bt,Rs=R.y+K/Bt,Es=((tr-fi)*lt-(Rs-Ji)*K)/(nt*lt-O*K);W=fi+nt*Es-k.x,N=Ji+O*Es-k.y;const Zi=W*W+N*N;if(Zi<=2)return new B(W,N);et=Math.sqrt(Zi/2)}else{let Vt=!1;nt>Number.EPSILON?K>Number.EPSILON&&(Vt=!0):nt<-Number.EPSILON?K<-Number.EPSILON&&(Vt=!0):Math.sign(O)===Math.sign(lt)&&(Vt=!0),Vt?(W=-O,N=nt,et=Math.sqrt(ie)):(W=nt,N=O,et=Math.sqrt(ie/2))}return new B(W/et,N/et)}const tt=[];for(let k=0,E=L.length,R=E-1,W=k+1;k=0;k--){const E=k/g,R=f*Math.cos(E*Math.PI/2),W=p*Math.sin(E*Math.PI/2)+m;for(let N=0,et=L.length;N=0;){const W=R;let N=R-1;N<0&&(N=k.length-1);for(let et=0,nt=c+g*2;et0)&&f.push(b,v,M),(x!==i-1||o0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class ef extends Nt{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new G(16777215),this.specular=new G(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new G(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Hi,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xe,this.combine=ia,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class sf extends Nt{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new G(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new G(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Hi,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class nf extends Nt{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Hi,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class rf extends Nt{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new G(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new G(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Hi,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xe,this.combine=ia,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class af extends Nt{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=fu,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class of extends Nt{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class hf extends Nt{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new G(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Hi,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class lf extends Xt{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function ri(l,t,e){return!l||!e&&l.constructor===t?l:typeof t.BYTES_PER_ELEMENT=="number"?new t(l):Array.prototype.slice.call(l)}function hl(l){return ArrayBuffer.isView(l)&&!(l instanceof DataView)}function ll(l){function t(s,n){return l[s]-l[n]}const e=l.length,i=new Array(e);for(let s=0;s!==e;++s)i[s]=s;return i.sort(t),i}function Kr(l,t,e){const i=l.length,s=new l.constructor(i);for(let n=0,r=0;r!==i;++n){const a=e[n]*t;for(let o=0;o!==t;++o)s[r++]=l[a+o]}return s}function Ra(l,t,e,i){let s=1,n=l[0];for(;n!==void 0&&n[i]===void 0;)n=l[s++];if(n===void 0)return;let r=n[i];if(r!==void 0)if(Array.isArray(r))do r=n[i],r!==void 0&&(t.push(n.time),e.push.apply(e,r)),n=l[s++];while(n!==void 0);else if(r.toArray!==void 0)do r=n[i],r!==void 0&&(t.push(n.time),r.toArray(e,e.length)),n=l[s++];while(n!==void 0);else do r=n[i],r!==void 0&&(t.push(n.time),e.push(r)),n=l[s++];while(n!==void 0)}function cf(l,t,e,i,s=30){const n=l.clone();n.name=t;const r=[];for(let o=0;o=i)){u.push(h.times[f]);for(let m=0;mn.tracks[o].times[0]&&(a=n.tracks[o].times[0]);for(let o=0;o=a.times[p]){const x=p*u+c,y=x+u-c;m=a.values.slice(x,y)}else{const x=a.createInterpolant(),y=c,b=u-c;x.evaluate(n),m=x.resultBuffer.slice(y,b)}o==="quaternion"&&new te().fromArray(m).normalize().conjugate().toArray(m);const g=h.times.length;for(let x=0;x=n)){const a=e[1];t=n)break e}r=i,i=0;break i}break t}for(;i>>1;te;)--r;if(++r,n!==0||r!==s){n>=r&&(r=Math.max(r,1),n=r-1);const a=this.getValueSize();this.times=i.slice(n,r),this.values=this.values.slice(n*a,r*a)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,s=this.values,n=i.length;n===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let r=null;for(let a=0;a!==n;a++){const o=i[a];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,o),t=!1;break}if(r!==null&&r>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,o,r),t=!1;break}r=o}if(s!==void 0&&hl(s))for(let a=0,o=s.length;a!==o;++a){const h=s[a];if(isNaN(h)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,h),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),i=this.getValueSize(),s=this.getInterpolation()===nr,n=t.length-1;let r=1;for(let a=1;a0){t[r]=t[n];for(let a=n*i,o=r*i,h=0;h!==i;++h)e[o+h]=e[a+h];++r}return r!==t.length?(this.times=t.slice(0,r),this.values=e.slice(0,r*i)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),i=this.constructor,s=new i(this.name,t,e);return s.createInterpolant=this.createInterpolant,s}}we.prototype.TimeBufferType=Float32Array;we.prototype.ValueBufferType=Float32Array;we.prototype.DefaultInterpolation=Jr;class Xi extends we{constructor(t,e,i){super(t,e,i)}}Xi.prototype.ValueTypeName="bool";Xi.prototype.ValueBufferType=Array;Xi.prototype.DefaultInterpolation=zn;Xi.prototype.InterpolantFactoryMethodLinear=void 0;Xi.prototype.InterpolantFactoryMethodSmooth=void 0;class ul extends we{}ul.prototype.ValueTypeName="color";class Nn extends we{}Nn.prototype.ValueTypeName="number";class pf extends jn{constructor(t,e,i,s){super(t,e,i,s)}interpolate_(t,e,i,s){const n=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=(i-e)/(s-e);let h=t*a;for(let c=h+a;h!==c;h+=4)te.slerpFlat(n,0,r,h-a,r,h,o);return n}}class Kn extends we{InterpolantFactoryMethodLinear(t){return new pf(this.times,this.values,this.getValueSize(),t)}}Kn.prototype.ValueTypeName="quaternion";Kn.prototype.InterpolantFactoryMethodSmooth=void 0;class Yi extends we{constructor(t,e,i){super(t,e,i)}}Yi.prototype.ValueTypeName="string";Yi.prototype.ValueBufferType=Array;Yi.prototype.DefaultInterpolation=zn;Yi.prototype.InterpolantFactoryMethodLinear=void 0;Yi.prototype.InterpolantFactoryMethodSmooth=void 0;class Un extends we{}Un.prototype.ValueTypeName="vector";class Vn{constructor(t="",e=-1,i=[],s=aa){this.name=t,this.tracks=i,this.duration=e,this.blendMode=s,this.uuid=Qt(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,s=1/(t.fps||1);for(let r=0,a=i.length;r!==a;++r)e.push(gf(i[r]).scale(s));const n=new this(t.name,t.duration,e,t.blendMode);return n.uuid=t.uuid,n}static toJSON(t){const e=[],i=t.tracks,s={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let n=0,r=i.length;n!==r;++n)e.push(we.toJSON(i[n]));return s}static CreateFromMorphTargetSequence(t,e,i,s){const n=e.length,r=[];for(let a=0;a1){const u=c[1];let d=s[u];d||(s[u]=d=[]),d.push(h)}}const r=[];for(const a in s)r.push(this.CreateFromMorphTargetSequence(a,s[a],e,i));return r}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(u,d,f,p,m){if(f.length!==0){const g=[],x=[];Ra(f,g,x,p),g.length!==0&&m.push(new u(d,g,x))}},s=[],n=t.name||"default",r=t.fps||30,a=t.blendMode;let o=t.length||-1;const h=t.hierarchy||[];for(let u=0;u{e&&e(n),this.manager.itemEnd(t)},0),n;if(Te[t]!==void 0){Te[t].push({onLoad:e,onProgress:i,onError:s});return}Te[t]=[],Te[t].push({onLoad:e,onProgress:i,onError:s});const r=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(r).then(h=>{if(h.status===200||h.status===0){if(h.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||h.body===void 0||h.body.getReader===void 0)return h;const c=Te[t],u=h.body.getReader(),d=h.headers.get("X-File-Size")||h.headers.get("Content-Length"),f=d?parseInt(d):0,p=f!==0;let m=0;const g=new ReadableStream({start(x){y();function y(){u.read().then(({done:b,value:v})=>{if(b)x.close();else{m+=v.byteLength;const _=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let M=0,A=c.length;M{x.error(b)})}}});return new Response(g)}else throw new xf(`fetch for "${h.url}" responded with ${h.status}: ${h.statusText}`,h)}).then(h=>{switch(o){case"arraybuffer":return h.arrayBuffer();case"blob":return h.blob();case"document":return h.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return h.json();default:if(a===void 0)return h.text();{const u=/charset="?([^;"\s]*)"?/i.exec(a),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return h.arrayBuffer().then(p=>f.decode(p))}}}).then(h=>{He.add(t,h);const c=Te[t];delete Te[t];for(let u=0,d=c.length;u{const c=Te[t];if(c===void 0)throw this.manager.itemError(t),h;delete Te[t];for(let u=0,d=c.length;u{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class Ay extends ee{constructor(t){super(t)}load(t,e,i,s){const n=this,r=new qe(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(a){try{e(n.parse(JSON.parse(a)))}catch(o){s?s(o):console.error(o),n.manager.itemError(t)}},i,s)}parse(t){const e=[];for(let i=0;i0:s.vertexColors=t.vertexColors),t.uniforms!==void 0)for(const n in t.uniforms){const r=t.uniforms[n];switch(s.uniforms[n]={},r.type){case"t":s.uniforms[n].value=i(r.value);break;case"c":s.uniforms[n].value=new G().setHex(r.value);break;case"v2":s.uniforms[n].value=new B().fromArray(r.value);break;case"v3":s.uniforms[n].value=new w().fromArray(r.value);break;case"v4":s.uniforms[n].value=new It().fromArray(r.value);break;case"m3":s.uniforms[n].value=new be().fromArray(r.value);break;case"m4":s.uniforms[n].value=new Z().fromArray(r.value);break;default:s.uniforms[n].value=r.value}}if(t.defines!==void 0&&(s.defines=t.defines),t.vertexShader!==void 0&&(s.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(s.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(s.glslVersion=t.glslVersion),t.extensions!==void 0)for(const n in t.extensions)s.extensions[n]=t.extensions[n];if(t.lights!==void 0&&(s.lights=t.lights),t.clipping!==void 0&&(s.clipping=t.clipping),t.size!==void 0&&(s.size=t.size),t.sizeAttenuation!==void 0&&(s.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(s.map=i(t.map)),t.matcap!==void 0&&(s.matcap=i(t.matcap)),t.alphaMap!==void 0&&(s.alphaMap=i(t.alphaMap)),t.bumpMap!==void 0&&(s.bumpMap=i(t.bumpMap)),t.bumpScale!==void 0&&(s.bumpScale=t.bumpScale),t.normalMap!==void 0&&(s.normalMap=i(t.normalMap)),t.normalMapType!==void 0&&(s.normalMapType=t.normalMapType),t.normalScale!==void 0){let n=t.normalScale;Array.isArray(n)===!1&&(n=[n,n]),s.normalScale=new B().fromArray(n)}return t.displacementMap!==void 0&&(s.displacementMap=i(t.displacementMap)),t.displacementScale!==void 0&&(s.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(s.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(s.roughnessMap=i(t.roughnessMap)),t.metalnessMap!==void 0&&(s.metalnessMap=i(t.metalnessMap)),t.emissiveMap!==void 0&&(s.emissiveMap=i(t.emissiveMap)),t.emissiveIntensity!==void 0&&(s.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(s.specularMap=i(t.specularMap)),t.specularIntensityMap!==void 0&&(s.specularIntensityMap=i(t.specularIntensityMap)),t.specularColorMap!==void 0&&(s.specularColorMap=i(t.specularColorMap)),t.envMap!==void 0&&(s.envMap=i(t.envMap)),t.envMapRotation!==void 0&&s.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(s.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(s.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(s.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(s.lightMap=i(t.lightMap)),t.lightMapIntensity!==void 0&&(s.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(s.aoMap=i(t.aoMap)),t.aoMapIntensity!==void 0&&(s.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(s.gradientMap=i(t.gradientMap)),t.clearcoatMap!==void 0&&(s.clearcoatMap=i(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(s.clearcoatRoughnessMap=i(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(s.clearcoatNormalMap=i(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(s.clearcoatNormalScale=new B().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(s.iridescenceMap=i(t.iridescenceMap)),t.iridescenceThicknessMap!==void 0&&(s.iridescenceThicknessMap=i(t.iridescenceThicknessMap)),t.transmissionMap!==void 0&&(s.transmissionMap=i(t.transmissionMap)),t.thicknessMap!==void 0&&(s.thicknessMap=i(t.thicknessMap)),t.anisotropyMap!==void 0&&(s.anisotropyMap=i(t.anisotropyMap)),t.sheenColorMap!==void 0&&(s.sheenColorMap=i(t.sheenColorMap)),t.sheenRoughnessMap!==void 0&&(s.sheenRoughnessMap=i(t.sheenRoughnessMap)),s}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return Oa.createMaterialFromType(t)}static createMaterialFromType(t){const e={ShadowMaterial:Kd,SpriteMaterial:_s,RawShaderMaterial:Qd,ShaderMaterial:ca,PointsMaterial:jh,MeshPhysicalMaterial:tf,MeshStandardMaterial:Fa,MeshPhongMaterial:ef,MeshToonMaterial:sf,MeshNormalMaterial:nf,MeshLambertMaterial:rf,MeshDepthMaterial:af,MeshDistanceMaterial:of,MeshBasicMaterial:qi,MeshMatcapMaterial:hf,LineDashedMaterial:lf,LineBasicMaterial:Xt,Material:Nt};return new e[t]}}class jo{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(t);let e="";for(let i=0,s=t.length;i0){const o=new dl(e);n=new Gn(o),n.setCrossOrigin(this.crossOrigin);for(let h=0,c=t.length;h0){s=new Gn(this.manager),s.setCrossOrigin(this.crossOrigin);for(let r=0,a=t.length;r{const g=new Ht;g.min.fromArray(m.boxMin),g.max.fromArray(m.boxMax);const x=new Lt;return x.radius=m.sphereRadius,x.center.fromArray(m.sphereCenter),{boxInitialized:m.boxInitialized,box:g,sphereInitialized:m.sphereInitialized,sphere:x}}),r._maxInstanceCount=t.maxInstanceCount,r._maxVertexCount=t.maxVertexCount,r._maxIndexCount=t.maxIndexCount,r._geometryInitialized=t.geometryInitialized,r._geometryCount=t.geometryCount,r._matricesTexture=h(t.matricesTexture.uuid),t.colorsTexture!==void 0&&(r._colorsTexture=h(t.colorsTexture.uuid));break;case"LOD":r=new ed;break;case"Line":r=new hi(a(t.geometry),o(t.material));break;case"LineLoop":r=new gd(a(t.geometry),o(t.material));break;case"LineSegments":r=new Re(a(t.geometry),o(t.material));break;case"PointCloud":case"Points":r=new yd(a(t.geometry),o(t.material));break;case"Sprite":r=new bs(o(t.material));break;case"Group":r=new Kh;break;case"Bone":r=new Zh;break;default:r=new st}if(r.uuid=t.uuid,t.name!==void 0&&(r.name=t.name),t.matrix!==void 0?(r.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(t.position!==void 0&&r.position.fromArray(t.position),t.rotation!==void 0&&r.rotation.fromArray(t.rotation),t.quaternion!==void 0&&r.quaternion.fromArray(t.quaternion),t.scale!==void 0&&r.scale.fromArray(t.scale)),t.up!==void 0&&r.up.fromArray(t.up),t.castShadow!==void 0&&(r.castShadow=t.castShadow),t.receiveShadow!==void 0&&(r.receiveShadow=t.receiveShadow),t.shadow&&(t.shadow.intensity!==void 0&&(r.shadow.intensity=t.shadow.intensity),t.shadow.bias!==void 0&&(r.shadow.bias=t.shadow.bias),t.shadow.normalBias!==void 0&&(r.shadow.normalBias=t.shadow.normalBias),t.shadow.radius!==void 0&&(r.shadow.radius=t.shadow.radius),t.shadow.mapSize!==void 0&&r.shadow.mapSize.fromArray(t.shadow.mapSize),t.shadow.camera!==void 0&&(r.shadow.camera=this.parseObject(t.shadow.camera))),t.visible!==void 0&&(r.visible=t.visible),t.frustumCulled!==void 0&&(r.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(r.renderOrder=t.renderOrder),t.userData!==void 0&&(r.userData=t.userData),t.layers!==void 0&&(r.layers.mask=t.layers),t.children!==void 0){const d=t.children;for(let f=0;f"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,i,s){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const n=this,r=He.get(t);if(r!==void 0){if(n.manager.itemStart(t),r.then){r.then(h=>{e&&e(h),n.manager.itemEnd(t)}).catch(h=>{s&&s(h)});return}return setTimeout(function(){e&&e(r),n.manager.itemEnd(t)},0),r}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const o=fetch(t,a).then(function(h){return h.blob()}).then(function(h){return createImageBitmap(h,Object.assign(n.options,{colorSpaceConversion:"none"}))}).then(function(h){return He.add(t,h),e&&e(h),n.manager.itemEnd(t),h}).catch(function(h){s&&s(h),He.remove(t),n.manager.itemError(t),n.manager.itemEnd(t)});He.add(t,o),n.manager.itemStart(t)}}let bn;class pl{static getContext(){return bn===void 0&&(bn=new(window.AudioContext||window.webkitAudioContext)),bn}static setContext(t){bn=t}}class Py extends ee{constructor(t){super(t)}load(t,e,i,s){const n=this,r=new qe(this.manager);r.setResponseType("arraybuffer"),r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(o){try{const h=o.slice(0);pl.getContext().decodeAudioData(h,function(u){e(u)}).catch(a)}catch(h){a(h)}},i,s);function a(o){s?s(o):console.error(o),n.manager.itemError(t)}}}const th=new Z,eh=new Z,ti=new Z;class Fy{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new re,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new re,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,ti.copy(t.projectionMatrix);const s=e.eyeSep/2,n=s*e.near/e.focus,r=e.near*Math.tan(ai*e.fov*.5)/e.zoom;let a,o;eh.elements[12]=-s,th.elements[12]=s,a=-r*e.aspect+n,o=r*e.aspect+n,ti.elements[0]=2*e.near/(o-a),ti.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(ti),a=-r*e.aspect-n,o=r*e.aspect-n,ti.elements[0]=2*e.near/(o-a),ti.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(ti)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(eh),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(th)}}class Ry extends re{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Ff{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=ih(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=ih();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function ih(){return performance.now()}const ei=new w,sh=new te,Rf=new w,ii=new w;class Ey extends st{constructor(){super(),this.type="AudioListener",this.context=pl.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Ff}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(ei,sh,Rf),ii.set(0,0,-1).applyQuaternion(sh),e.positionX){const s=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(ei.x,s),e.positionY.linearRampToValueAtTime(ei.y,s),e.positionZ.linearRampToValueAtTime(ei.z,s),e.forwardX.linearRampToValueAtTime(ii.x,s),e.forwardY.linearRampToValueAtTime(ii.y,s),e.forwardZ.linearRampToValueAtTime(ii.z,s),e.upX.linearRampToValueAtTime(i.x,s),e.upY.linearRampToValueAtTime(i.y,s),e.upZ.linearRampToValueAtTime(i.z,s)}else e.setPosition(ei.x,ei.y,ei.z),e.setOrientation(ii.x,ii.y,ii.z,i.x,i.y,i.z)}}class Ef extends st{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(t=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(i,s,this._addIndex*e,1,e);for(let o=e,h=e+e;o!==h;++o)if(i[o]!==i[o+e]){a.setValue(i,s);break}}saveOriginalState(){const t=this.binding,e=this.buffer,i=this.valueSize,s=i*this._origIndex;t.getValue(e,s);for(let n=i,r=s;n!==r;++n)e[n]=e[s+n%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i=.5)for(let r=0;r!==n;++r)t[e+r]=t[i+r]}_slerp(t,e,i,s){te.slerpFlat(t,e,t,e,t,i,s)}_slerpAdditive(t,e,i,s,n){const r=this._workIndex*n;te.multiplyQuaternionsFlat(t,r,t,e,t,i),te.slerpFlat(t,e,t,e,t,r,s)}_lerp(t,e,i,s,n){const r=1-s;for(let a=0;a!==n;++a){const o=e+a;t[o]=t[o]*r+t[i+a]*s}}_lerpAdditive(t,e,i,s,n){for(let r=0;r!==n;++r){const a=e+r;t[a]=t[a]+t[i+r]*s}}}const Da="\\[\\]\\.:\\/",Lf=new RegExp("["+Da+"]","g"),La="[^"+Da+"]",Nf="[^"+Da.replace("\\.","")+"]",Uf=/((?:WC+[\/:])*)/.source.replace("WC",La),Vf=/(WCOD+)?/.source.replace("WCOD",Nf),Gf=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",La),Wf=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",La),Hf=new RegExp("^"+Uf+Vf+Gf+Wf+"$"),qf=["material","materials","bones","map"];class Xf{constructor(t,e,i){const s=i||it.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,s)}getValue(t,e){this.bind();const i=this._targetGroup.nCachedObjects_,s=this._bindings[i];s!==void 0&&s.getValue(t,e)}setValue(t,e){const i=this._bindings;for(let s=this._targetGroup.nCachedObjects_,n=i.length;s!==n;++s)i[s].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}}class it{constructor(t,e,i){this.path=e,this.parsedPath=i||it.parseTrackName(e),this.node=it.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new it.Composite(t,e,i):new it(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Lf,"")}static parseTrackName(t){const e=Hf.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},s=i.nodeName&&i.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){const n=i.nodeName.substring(s+1);qf.indexOf(n)!==-1&&(i.nodeName=i.nodeName.substring(0,s),i.objectName=n)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(i!==void 0)return i}if(t.children){const i=function(n){for(let r=0;r=n){const u=n++,d=t[u];e[d.uuid]=c,t[c]=d,e[h]=u,t[u]=o;for(let f=0,p=s;f!==p;++f){const m=i[f],g=m[u],x=m[c];m[c]=g,m[u]=x}}}this.nCachedObjects_=n}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,s=i.length;let n=this.nCachedObjects_,r=t.length;for(let a=0,o=arguments.length;a!==o;++a){const h=arguments[a],c=h.uuid,u=e[c];if(u!==void 0)if(delete e[c],u0&&(e[f.uuid]=u),t[u]=f,t.pop();for(let p=0,m=s;p!==m;++p){const g=i[p];g[u]=g[d],g.pop()}}}this.nCachedObjects_=n}subscribe_(t,e){const i=this._bindingsIndicesByPath;let s=i[t];const n=this._bindings;if(s!==void 0)return n[s];const r=this._paths,a=this._parsedPaths,o=this._objects,h=o.length,c=this.nCachedObjects_,u=new Array(h);s=n.length,i[t]=s,r.push(t),a.push(e),n.push(u);for(let d=c,f=o.length;d!==f;++d){const p=o[d];u[d]=new it(p,t,e)}return u}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(i!==void 0){const s=this._paths,n=this._parsedPaths,r=this._bindings,a=r.length-1,o=r[a],h=t[a];e[h]=i,r[i]=o,r.pop(),n[i]=n[a],n.pop(),s[i]=s[a],s.pop()}}}class Yf{constructor(t,e,i=null,s=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=s;const n=e.tracks,r=n.length,a=new Array(r),o={endingStart:Ei,endingEnd:Ei};for(let h=0;h!==r;++h){const c=n[h].createInterpolant(null);a[h]=c,c.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=uu,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,i){if(t.fadeOut(e),this.fadeIn(e),i){const s=this._clip.duration,n=t._clip.duration,r=n/s,a=s/n;t.warp(1,r,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,i){return t.crossFadeFrom(this,e,i)}stopFading(){const t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,i){const s=this._mixer,n=s.time,r=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=s._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,h=a.sampleValues;return o[0]=n,o[1]=n+i,h[0]=t/r,h[1]=e/r,this}stopWarping(){const t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,s){if(!this.enabled){this._updateWeight(t);return}const n=this._startTime;if(n!==null){const o=(t-n)*i;o<0||i===0?e=0:(this._startTime=null,e=i*o)}e*=this._updateTimeScale(t);const r=this._updateTime(e),a=this._updateWeight(t);if(a>0){const o=this._interpolants,h=this._propertyBindings;switch(this.blendMode){case Gh:for(let c=0,u=o.length;c!==u;++c)o[c].evaluate(r),h[c].accumulateAdditive(a);break;case aa:default:for(let c=0,u=o.length;c!==u;++c)o[c].evaluate(r),h[c].accumulate(s,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(i!==null){const s=i.evaluate(t)[0];e*=s,t>i.parameterPositions[1]&&(this.stopFading(),s===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const s=i.evaluate(t)[0];e*=s,t>i.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let s=this.time+t,n=this._loopCount;const r=i===du;if(t===0)return n===-1?s:r&&(n&1)===1?e-s:s;if(i===cu){n===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(s>=e)s=e;else if(s<0)s=0;else{this.time=s;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(n===-1&&(t>=0?(n=0,this._setEndings(!0,this.repetitions===0,r)):this._setEndings(this.repetitions===0,!0,r)),s>=e||s<0){const a=Math.floor(s/e);s-=e*a,n+=Math.abs(a);const o=this.repetitions-n;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,s=t>0?e:0,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(o===1){const h=t<0;this._setEndings(h,!h,r)}else this._setEndings(!1,!1,r);this._loopCount=n,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=s;if(r&&(n&1)===1)return e-s}return s}_setEndings(t,e,i){const s=this._interpolantSettings;i?(s.endingStart=Oi,s.endingEnd=Oi):(t?s.endingStart=this.zeroSlopeAtStart?Oi:Ei:s.endingStart=kn,e?s.endingEnd=this.zeroSlopeAtEnd?Oi:Ei:s.endingEnd=kn)}_scheduleFading(t,e,i){const s=this._mixer,n=s.time;let r=this._weightInterpolant;r===null&&(r=s._lendControlInterpolant(),this._weightInterpolant=r);const a=r.parameterPositions,o=r.sampleValues;return a[0]=n,o[0]=e,a[1]=n+t,o[1]=i,this}}const Jf=new Float32Array(1);class Ny extends Xe{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const i=t._localRoot||this._root,s=t._clip.tracks,n=s.length,r=t._propertyBindings,a=t._interpolants,o=i.uuid,h=this._bindingsByRootAndName;let c=h[o];c===void 0&&(c={},h[o]=c);for(let u=0;u!==n;++u){const d=s[u],f=d.name;let p=c[f];if(p!==void 0)++p.referenceCount,r[u]=p;else{if(p=r[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,f));continue}const m=e&&e._propertyBindings[u].binding.parsedPath;p=new Df(it.create(i,f,m),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,f),r[u]=p}a[u].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const i=(t._localRoot||this._root).uuid,s=t._clip.uuid,n=this._actionsByClip[s];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,s,i)}const e=t._propertyBindings;for(let i=0,s=e.length;i!==s;++i){const n=e[i];n.useCount++===0&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let i=0,s=e.length;i!==s;++i){const n=e[i];--n.useCount===0&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return e!==null&&e=0;--i)t[i].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,s=this.time+=t,n=Math.sign(t),r=this._accuIndex^=1;for(let h=0;h!==i;++h)e[h]._update(s,t,n,r);const a=this._bindings,o=this._nActiveBindings;for(let h=0;h!==o;++h)a[h].apply(r);return this}setTime(t){this.time=0;for(let e=0;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,oh).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const hh=new w,vn=new w;class Zy{constructor(t=new w,e=new w){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){hh.subVectors(t,this.start),vn.subVectors(this.end,this.start);const i=vn.dot(vn);let n=vn.dot(hh)/i;return e&&(n=X(n,0,1)),n}closestPointToPoint(t,e,i){const s=this.closestPointToPointParameter(t,e);return this.delta(i).multiplyScalar(s).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const lh=new w;class $y extends st{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new j,s=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let r=0,a=1,o=32;r1)for(let u=0;u.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{ph.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(ph,e)}}setLength(t,e=t*.2,i=e*.2){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class hx extends Re{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],s=new j;s.setAttribute("position",new D(e,3)),s.setAttribute("color",new D(i,3));const n=new Xt({vertexColors:!0,toneMapped:!1});super(s,n),this.type="AxesHelper"}setColors(t,e,i){const s=new G,n=this.geometry.attributes.color.array;return s.set(t),s.toArray(n,0),s.toArray(n,3),s.set(e),s.toArray(n,6),s.toArray(n,9),s.set(i),s.toArray(n,12),s.toArray(n,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class lx{constructor(){this.type="ShapePath",this.color=new G,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Ln,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,s){return this.currentPath.quadraticCurveTo(t,e,i,s),this}bezierCurveTo(t,e,i,s,n,r){return this.currentPath.bezierCurveTo(t,e,i,s,n,r),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(x){const y=[];for(let b=0,v=x.length;bNumber.EPSILON){if(C<0&&(A=y[M],T=-T,S=y[_],C=-C),x.yS.y)continue;if(x.y===A.y){if(x.x===A.x)return!0}else{const P=C*(x.x-A.x)-T*(x.y-A.y);if(P===0)return!0;if(P<0)continue;v=!v}}else{if(x.y!==A.y)continue;if(S.x<=x.x&&x.x<=A.x||A.x<=x.x&&x.x<=S.x)return!0}}return v}const s=Fe.isClockWise,n=this.subPaths;if(n.length===0)return[];let r,a,o;const h=[];if(n.length===1)return a=n[0],o=new Vi,o.curves=a.curves,h.push(o),h;let c=!s(n[0].getPoints());c=t?!c:c;const u=[],d=[];let f=[],p=0,m;d[p]=void 0,f[p]=[];for(let x=0,y=n.length;x1){let x=!1,y=0;for(let b=0,v=d.length;b0&&x===!1&&(f=u)}let g;for(let x=0,y=d.length;xt?(l.repeat.x=1,l.repeat.y=e/t,l.offset.x=0,l.offset.y=(1-l.repeat.y)/2):(l.repeat.x=t/e,l.repeat.y=1,l.offset.x=(1-l.repeat.x)/2,l.offset.y=0),l}function Kf(l,t){const e=l.image&&l.image.width?l.image.width/l.image.height:1;return e>t?(l.repeat.x=t/e,l.repeat.y=1,l.offset.x=(1-l.repeat.x)/2,l.offset.y=0):(l.repeat.x=1,l.repeat.y=e/t,l.offset.x=0,l.offset.y=(1-l.repeat.y)/2),l}function Qf(l){return l.repeat.x=1,l.repeat.y=1,l.offset.x=0,l.offset.y=0,l}function tp(l,t,e,i){const s=ep(i);switch(e){case Ac:return l*t;case Tc:return l*t;case Cc:return l*t*2;case Uh:return l*t/s.components*s.byteLength;case Vh:return l*t/s.components*s.byteLength;case Bc:return l*t*2/s.components*s.byteLength;case zc:return l*t*2/s.components*s.byteLength;case Ic:return l*t*3/s.components*s.byteLength;case As:return l*t*4/s.components*s.byteLength;case kc:return l*t*4/s.components*s.byteLength;case Pc:case Fc:return Math.floor((l+3)/4)*Math.floor((t+3)/4)*8;case Rc:case Ec:return Math.floor((l+3)/4)*Math.floor((t+3)/4)*16;case Dc:case Nc:return Math.max(l,16)*Math.max(t,8)/4;case Oc:case Lc:return Math.max(l,8)*Math.max(t,8)/2;case Uc:case Vc:return Math.floor((l+3)/4)*Math.floor((t+3)/4)*8;case Gc:return Math.floor((l+3)/4)*Math.floor((t+3)/4)*16;case Wc:return Math.floor((l+3)/4)*Math.floor((t+3)/4)*16;case Hc:return Math.floor((l+4)/5)*Math.floor((t+3)/4)*16;case qc:return Math.floor((l+4)/5)*Math.floor((t+4)/5)*16;case Xc:return Math.floor((l+5)/6)*Math.floor((t+4)/5)*16;case Yc:return Math.floor((l+5)/6)*Math.floor((t+5)/6)*16;case Jc:return Math.floor((l+7)/8)*Math.floor((t+4)/5)*16;case Zc:return Math.floor((l+7)/8)*Math.floor((t+5)/6)*16;case $c:return Math.floor((l+7)/8)*Math.floor((t+7)/8)*16;case jc:return Math.floor((l+9)/10)*Math.floor((t+4)/5)*16;case Kc:return Math.floor((l+9)/10)*Math.floor((t+5)/6)*16;case Qc:return Math.floor((l+9)/10)*Math.floor((t+7)/8)*16;case tu:return Math.floor((l+9)/10)*Math.floor((t+9)/10)*16;case eu:return Math.floor((l+11)/12)*Math.floor((t+9)/10)*16;case iu:return Math.floor((l+11)/12)*Math.floor((t+11)/12)*16;case su:case nu:case ru:return Math.ceil(l/4)*Math.ceil(t/4)*16;case au:case ou:return Math.ceil(l/4)*Math.ceil(t/4)*8;case hu:case lu:return Math.ceil(l/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function ep(l){switch(l){case Nh:case gc:return{byteLength:1,components:1};case xc:case yc:case vc:return{byteLength:2,components:1};case wc:case _c:return{byteLength:2,components:4};case ra:case bc:case Gi:return{byteLength:4,components:1};case Sc:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${l}.`)}const ux={contain:jf,cover:Kf,fill:Qf,getByteLength:tp};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Dh}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Dh);function xl(l){return l>=.7?"active":l>=.4?"dormant":l>=.1?"silent":"unavailable"}const bl={active:"#10b981",dormant:"#f59e0b",silent:"#8b5cf6",unavailable:"#6b7280"},dx={active:"Easily retrievable (retention ≥ 70%)",dormant:"Retrievable with effort (40–70%)",silent:"Difficult, needs cues (10–40%)",unavailable:"Needs reinforcement (< 10%)"},Vr={aha:"#FFD700",confusion:"#EF4444",failure:"#9CA3AF"},fx={aha:"Aha moments and breakthroughs",confusion:"Confusions and weak spots",failure:"Failures and guardrails"};function mh(l,t){return t==="state"?bl[xl(l.retention)]:t==="ahagraph"?vl(l)??Ja[l.type]??"#8B95A5":Ja[l.type]||"#8B95A5"}function vl(l){const t=new Set((l.tags??[]).map(e=>e.toLowerCase()));return t.has("aha")?Vr.aha:t.has("confusion")||t.has("weak-spot")?Vr.confusion:t.has("failure")||t.has("guardrail")?Vr.failure:null}let ds=null;function ip(){if(ds)return ds;const l=128,t=document.createElement("canvas");t.width=l,t.height=l;const e=t.getContext("2d");if(!e)return ds=new yt,ds;const i=e.createRadialGradient(l/2,l/2,0,l/2,l/2,l/2);i.addColorStop(0,"rgba(255, 255, 255, 1.0)"),i.addColorStop(.25,"rgba(255, 255, 255, 0.7)"),i.addColorStop(.55,"rgba(255, 255, 255, 0.2)"),i.addColorStop(1,"rgba(255, 255, 255, 0.0)"),e.fillStyle=i,e.fillRect(0,0,l,l);const s=new Qh(t);return s.needsUpdate=!0,ds=s,s}function gh(l){if(l===0||l===1)return l;const t=.3;return Math.pow(2,-10*l)*Math.sin((l-t/4)*(2*Math.PI)/t)+1}function sp(l){return l*l*((1.70158+1)*l-1.70158)}class px{constructor(){z(this,"group");z(this,"meshMap",new Map);z(this,"glowMap",new Map);z(this,"positions",new Map);z(this,"labelSprites",new Map);z(this,"hoveredNode",null);z(this,"selectedNode",null);z(this,"colorMode","type");z(this,"materializingNodes",[]);z(this,"dissolvingNodes",[]);z(this,"growingNodes",[]);this.group=new Kh}setColorMode(t){if(this.colorMode!==t){this.colorMode=t;for(const[e,i]of this.meshMap){const s=i.userData.retention??0,n=i.userData.type??"fact",r=Array.isArray(i.userData.tags)?i.userData.tags:[],o=mh({type:n,retention:s,tags:r},t),h=new G(o),c=i.material;c.color.copy(h),c.emissive.copy(h);const u=this.glowMap.get(e);u&&u.material.color.copy(h)}}}createNodes(t){const e=(1+Math.sqrt(5))/2,i=t.length;for(let s=0;s0,a=new Fs(s,16,16),o=new Fa({color:new G(n),emissive:new G(n),emissiveIntensity:r?0:.3+t.retention*.5,roughness:.3,metalness:.1,transparent:!0,opacity:r?.2:.3+t.retention*.7}),h=new qt(a,o);h.position.copy(e),h.scale.setScalar(i),h.userData={nodeId:t.id,type:t.type,retention:t.retention,tags:t.tags},this.meshMap.set(t.id,h),this.group.add(h);const c=new _s({map:ip(),color:new G(n),transparent:!0,opacity:i>0?r?.1:.3+t.retention*.35:0,blending:oc,depthWrite:!1}),u=new bs(c);u.scale.set(s*6*i,s*6*i,1),u.position.copy(e),u.userData={isGlow:!0,nodeId:t.id},this.glowMap.set(t.id,u),this.group.add(u);const d=t.label||t.type,f=this.createTextSprite(d,"#94a3b8");return f.position.copy(e),f.position.y+=s*2+1.5,f.userData={isLabel:!0,nodeId:t.id,offset:s*2+1.5},this.group.add(f),this.labelSprites.set(t.id,f),{mesh:h,glow:u,label:f,size:s}}addNode(t,e,i={}){const s=(e==null?void 0:e.clone())??new w((Math.random()-.5)*40,(Math.random()-.5)*40,(Math.random()-.5)*40);this.positions.set(t.id,s);const{mesh:n,glow:r,label:a}=this.createNodeMeshes(t,s,0);return n.scale.setScalar(.001),r.scale.set(.001,.001,1),r.material.opacity=0,a.material.opacity=0,i.isBirthRitual?(n.visible=!1,r.visible=!1,a.visible=!1,n.userData.birthRitualPending={totalFrames:30,targetScale:.5+t.retention*2}):this.materializingNodes.push({id:t.id,frame:0,totalFrames:30,mesh:n,glow:r,label:a,targetScale:.5+t.retention*2}),s}igniteNode(t){const e=this.meshMap.get(t),i=this.glowMap.get(t),s=this.labelSprites.get(t);if(!e||!i||!s)return;const n=e.userData.birthRitualPending;n&&(e.visible=!0,i.visible=!0,s.visible=!0,delete e.userData.birthRitualPending,this.materializingNodes.push({id:t,frame:0,totalFrames:n.totalFrames,mesh:e,glow:i,label:s,targetScale:n.targetScale}))}removeNode(t){const e=this.meshMap.get(t),i=this.glowMap.get(t),s=this.labelSprites.get(t);!e||!i||!s||(this.materializingNodes=this.materializingNodes.filter(n=>n.id!==t),this.dissolvingNodes.push({id:t,frame:0,totalFrames:60,mesh:e,glow:i,label:s,originalScale:e.scale.x}))}growNode(t,e){const i=this.meshMap.get(t);if(!i)return;const s=i.scale.x,n=.5+e*2;i.userData.retention=e,this.growingNodes.push({id:t,frame:0,totalFrames:30,startScale:s,targetScale:n})}createTextSprite(t,e){const i=document.createElement("canvas"),s=i.getContext("2d");if(!s){const x=new yt;return new bs(new _s({map:x,transparent:!0,opacity:0}))}i.width=512,i.height=64;const n=t.length>40?t.slice(0,37)+"...":t;s.clearRect(0,0,i.width,i.height),s.font='600 22px -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif';const a=s.measureText(n).width,h=Math.min(a+14*2,i.width-4),c=40,u=(i.width-h)/2,d=(i.height-c)/2,f=c/2;s.fillStyle="rgba(10, 16, 28, 0.82)",s.beginPath(),s.moveTo(u+f,d),s.lineTo(u+h-f,d),s.quadraticCurveTo(u+h,d,u+h,d+f),s.lineTo(u+h,d+c-f),s.quadraticCurveTo(u+h,d+c,u+h-f,d+c),s.lineTo(u+f,d+c),s.quadraticCurveTo(u,d+c,u,d+c-f),s.lineTo(u,d+f),s.quadraticCurveTo(u,d,u+f,d),s.closePath(),s.fill(),s.strokeStyle="rgba(148, 163, 184, 0.18)",s.lineWidth=1,s.stroke(),s.textAlign="center",s.textBaseline="middle",s.fillStyle=e,s.fillText(n,i.width/2,i.height/2+1);const p=new Qh(i);p.needsUpdate=!0;const m=new _s({map:p,transparent:!0,opacity:0,depthTest:!1,sizeAttenuation:!0}),g=new bs(m);return g.scale.set(9,1.2,1),g}updatePositions(){this.group.children.forEach(t=>{if(t.userData.nodeId){const e=this.positions.get(t.userData.nodeId);if(!e)return;t.userData.isGlow?t.position.copy(e):t.userData.isLabel?(t.position.copy(e),t.position.y+=t.userData.offset):t instanceof qt&&t.position.copy(e)}})}animate(t,e,i,s=1){var r,a;for(let o=this.materializingNodes.length-1;o>=0;o--){const h=this.materializingNodes[o];h.frame++;const c=Math.min(h.frame/h.totalFrames,1),u=gh(c);if(h.mesh.scale.setScalar(Math.max(.001,u)),h.frame>=5){const d=Math.min((h.frame-5)/5,1),f=h.glow.material;f.opacity=d*.4;const p=h.targetScale*6*u;h.glow.scale.set(p,p,1)}if(h.frame>=40){const d=Math.min((h.frame-40)/20,1);h.label.material.opacity=d*.9}h.frame>=60&&this.materializingNodes.splice(o,1)}for(let o=this.dissolvingNodes.length-1;o>=0;o--){const h=this.dissolvingNodes[o];h.frame++;const c=Math.min(h.frame/h.totalFrames,1),u=1-sp(c),d=Math.max(.001,h.originalScale*u);h.mesh.scale.setScalar(d);const f=d*6;h.glow.scale.set(f,f,1);const p=h.mesh.material;p.opacity*=.97,h.glow.material.opacity*=.95,h.label.material.opacity*=.93,h.frame>=h.totalFrames&&(this.group.remove(h.mesh),this.group.remove(h.glow),this.group.remove(h.label),h.mesh.geometry.dispose(),h.mesh.material.dispose(),(r=h.glow.material.map)==null||r.dispose(),h.glow.material.dispose(),(a=h.label.material.map)==null||a.dispose(),h.label.material.dispose(),this.meshMap.delete(h.id),this.glowMap.delete(h.id),this.labelSprites.delete(h.id),this.positions.delete(h.id),this.dissolvingNodes.splice(o,1))}for(let o=this.growingNodes.length-1;o>=0;o--){const h=this.growingNodes[o];h.frame++;const c=Math.min(h.frame/h.totalFrames,1),u=h.startScale+(h.targetScale-h.startScale)*gh(c),d=this.meshMap.get(h.id);d&&d.scale.setScalar(u);const f=this.glowMap.get(h.id);if(f){const p=u*6;f.scale.set(p,p,1)}h.frame>=h.totalFrames&&this.growingNodes.splice(o,1)}const n=new Set([...this.materializingNodes.map(o=>o.id),...this.dissolvingNodes.map(o=>o.id),...this.growingNodes.map(o=>o.id)]);this.meshMap.forEach((o,h)=>{if(n.has(h))return;const c=e.find(y=>y.id===h);if(!c)return;const u=1+Math.sin(t*1.5+e.indexOf(c)*.5)*.15*c.retention;o.scale.setScalar(u);const d=this.positions.get(h),f=d?i.position.distanceTo(d):0,p=1+Math.min(1.4,Math.max(0,(f-60)/100)),m=o.material;if(h===this.hoveredNode)m.emissiveIntensity=1*s;else if(h===this.selectedNode)m.emissiveIntensity=.8*s;else{const b=.3+c.retention*.5+Math.sin(t*(.8+c.retention*.7))*.1*c.retention;m.emissiveIntensity=b*s*p}const g=.3+c.retention*.7;m.opacity=Math.min(1,g*s*p);const x=this.glowMap.get(h);if(x){const y=x.material,b=.3+c.retention*.35;y.opacity=Math.min(.95,b*s*p)}}),this.labelSprites.forEach((o,h)=>{if(n.has(h))return;const c=this.positions.get(h);if(!c)return;const u=i.position.distanceTo(c),d=o.material,f=h===this.hoveredNode||h===this.selectedNode?1:u<40?.9:u<80?.9*(1-(u-40)/40):0;d.opacity+=(f-d.opacity)*.1})}getMeshes(){return Array.from(this.meshMap.values())}dispose(){this.group.traverse(t=>{var e,i,s,n,r;t instanceof qt?((e=t.geometry)==null||e.dispose(),(i=t.material)==null||i.dispose()):t instanceof bs&&((n=(s=t.material)==null?void 0:s.map)==null||n.dispose(),(r=t.material)==null||r.dispose())}),this.materializingNodes=[],this.dissolvingNodes=[],this.growingNodes=[]}}function np(l){var e,i;const t={};for(const s of l)(t[e=s.source]??(t[e]=[])).push({edge:s,otherId:s.target}),(t[i=s.target]??(t[i]=[])).push({edge:s,otherId:s.source});for(const s of Object.keys(t))t[s].sort((n,r)=>(r.edge.weight??0)-(n.edge.weight??0));return t}function Gr(l){const t=(l.type??"").toLowerCase();return t.includes("contradict")||t.includes("conflict")||t.includes("supersede")}function yh(l){const t=(l.type??"").toLowerCase();return t==="causal"||t.includes("causal")||t.includes("cause")}function In(l){const t=Date.parse(l.updatedAt||l.createdAt||"");return Number.isFinite(t)?t:0}function rp(l,t,e,i=7,s={}){var y;const n=s.preferCausal??!1,r=new Map(l.map(b=>[b.id,b])),a={beats:[],centerId:e,pivoted:!1,flowEdges:[]};if(l.length===0)return a;const o=np(t),h=r.has(e);let c=h?e:"";c||(c=((y=l.find(b=>b.isCenter))==null?void 0:y.id)??""),c||(c=l.map(b=>{var v;return{id:b.id,deg:((v=o[b.id])==null?void 0:v.length)??0}}).sort((b,v)=>v.deg-b.deg)[0].id);const u=r.get(c);if(!u)return a;const d=!h,f=new Set([c]),p=[{nodeId:c,node:u,viaEdge:null,kind:"origin",intensity:1}],m=[];let g=c,x=!1;for(;p.length!f.has(A.otherId)&&yh(A.edge))),!v&&!x&&(v=b.find(A=>!f.has(A.otherId)&&Gr(A.edge)),v&&(x=!0)),v||(v=b.find(A=>!f.has(A.otherId))),!v){const A=l.filter(T=>!f.has(T.id)).sort((T,C)=>In(C)-In(T));if(A.length===0)break;const S=A[0];f.add(S.id),p.push({nodeId:S.id,node:S,viaEdge:null,kind:"bridge",intensity:.6}),g=S.id;continue}const _=r.get(v.otherId);if(!_){f.add(v.otherId);continue}f.add(_.id),m.push(v.edge);const M=n&&yh(v.edge);p.push({nodeId:_.id,node:_,viaEdge:v.edge,kind:Gr(v.edge)?"contradiction":"connection",intensity:Gr(v.edge)||M?1:Math.min(1,.55+(v.edge.weight??0)*.45)}),g=_.id}if(p.length_.id!==b).sort((_,M)=>In(M)-In(_))[0];v&&!p.some(_=>_.nodeId===v.id)&&p.push({nodeId:v.id,node:v,viaEdge:null,kind:"recent",intensity:.8})}return{beats:p,centerId:c,pivoted:d,flowEdges:m}}var ap=vt(''),op=vt('CAPTURE'),hp=vt(' '),lp=vt('
');function cp(l,t){Wn(t,!0);let e=ut(t,"demoMode",3,"recall-path"),i=ut(t,"seed",3,"vestige-observatory-v1"),s=ut(t,"nodeCount",3,0),n=ut(t,"edgeCount",3,0),r=ut(t,"centerId",3,""),a=ut(t,"frameCount",3,0),o=ut(t,"fpsEstimate",3,0),h=ut(t,"freezeFrame",3,null);ut(t,"loading",3,!1),ut(t,"error",3,"");function c(){const L=new URLSearchParams({demo:e(),seed:i()});h()!==null&&L.set("frame",String(h()));const I=`${window.location.origin}${ec}/observatory?${L.toString()}`;navigator.clipboard.writeText(I).catch(()=>{})}var u=lp(),d=ot(u),f=ot(d),p=ot(f),m=ot(p,!0);at(p);var g=ct(p,2),x=ot(g);at(g),at(f);var y=ct(f,2),b=ot(y),v=ot(b);at(b);var _=ct(b,2);{var M=L=>{var I=ap(),U=ot(I);at(I),jt(wt=>Ot(U,`center=${wt??""}`),[()=>r().slice(0,8)]),mt(L,I)};_t(_,L=>{r()&&L(M)})}at(y);var A=ct(y,2),S=ot(A),T=ot(S);at(S);var C=ct(S,2);{var P=L=>{var I=op();mt(L,I)},V=L=>{var I=hp(),U=ot(I);at(I),jt(()=>Ot(U,`${o()??""}fps`)),mt(L,I)};_t(C,L=>{h()!==null?L(P):o()>0&&L(V,1)})}var q=ct(C,2);at(A),at(d),at(u),jt((L,I)=>{Ot(m,e()),Ot(x,`seed=${L??""}${i().length>12?"…":""}`),Ot(v,`${s()??""} nodes · ${n()??""} edges`),Ot(T,`frame: ${I??""}`)},[()=>i().slice(0,12),()=>String(a()).padStart(3," ")]),Ri("click",q,c),mt(l,u),Hn()}Rh(["click"]);var up=vt('
'),dp=vt("
"),fp=vt('
');function pp(l,t){Wn(t,!0);let e=ut(t,"steps",19,()=>[]),i=ut(t,"frame",3,0),s=ut(t,"loopFrames",3,720);const n=u=>u/s()*100;function r(u,d){const f=d-u;return f<-14||f>90?0:f<0?1+f/14:1-f/90}let a=Bn(()=>{let u="",d=.15;for(const f of e()){const p=r(f.beatFrame,i());p>d&&(d=p,u=f.label)}return u});var o=Ph(),h=Fh(o);{var c=u=>{var d=fp(),f=ot(d);{var p=y=>{var b=up(),v=ot(b,!0);at(b),jt(()=>Ot(v,F(a))),mt(y,b)};_t(f,y=>{F(a)&&y(p)})}var m=ct(f,2),g=ot(m);Eh(g,17,e,y=>y.beatFrame,(y,b)=>{var v=dp();let _;jt((M,A,S)=>{_=vs(v,1,"tick svelte-8n8iia",null,_,M),Hr(v,`left: ${A??""}%; opacity: ${S??""}`),Cn(v,"title",F(b).label)},[()=>({hot:r(F(b).beatFrame,i())>0,backward:F(b).kind===1}),()=>n(F(b).beatFrame),()=>.45+.55*r(F(b).beatFrame,i())]),mt(y,v)});var x=ct(g,2);at(m),at(d),jt(y=>Hr(x,`left: ${y??""}%`),[()=>n(i())]),mt(u,d)};_t(h,u=>{e().length>0&&u(c)})}mt(l,o),Hn()}var mp=vt('
');function xh(l,t){Wn(t,!0);let e=ut(t,"frame",3,0),i=ut(t,"fadeWindow",19,()=>[600,620,705,719]),s=ut(t,"tone",3,"triumph");const n=(c,u,d)=>{const f=Math.min(1,Math.max(0,(d-c)/(u-c)));return f*f*(3-2*f)};let r=Bn(()=>n(i()[0],i()[1],e())*(1-n(i()[2],i()[3],e())));var a=Ph(),o=Fh(a);{var h=c=>{var u=mp();let d;var f=ot(u),p=ot(f,!0);at(f);var m=ct(f,2),g=ot(m,!0);at(m);var x=ct(m,2),y=ot(x,!0);at(x),at(u),jt(()=>{d=vs(u,1,"verdict svelte-ssd7yu",null,d,{quarantine:s()==="quarantine"}),Hr(u,`opacity: ${F(r)??""}`),Ot(p,t.verdict.headline),Ot(g,t.verdict.causeLabel),Ot(y,t.verdict.receipt)}),mt(c,u)};_t(o,c=>{F(r)>.001&&c(h)})}mt(l,a),Hn()}function bh(l){const t=/^#?([0-9a-fA-F]{6})$/.exec(l.trim());if(!t)return[107/255,114/255,128/255];const e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}function gp(l){const t=vl({tags:l.tags});return bh(t||bl[xl(l.retention)])}function yp(l){const e=[...l.nodes].sort((r,a)=>r.isCenter!==a.isCenter?r.isCenter?-1:1:r.ida.id?1:0).map((r,a)=>ic(r,a)),i=new Map;for(const r of e)i.set(r.id,r.index);const s=[];for(const r of l.edges){const a=i.get(r.source),o=i.get(r.target);a===void 0||o===void 0||a===o||s.push({sourceIndex:a,targetIndex:o,weight:r.weight,type:r.type})}const n=e.findIndex(r=>r.isCenter);return{nodes:e,edges:s,indexById:i,centerIndex:n<0?0:n}}function wl(l,t,e=120){const i=l.nodes.length,s=new Float32Array(i*Mt);for(let n=0;nx.toLowerCase()));g.has("aha")&&(m|=Ki.isAha),(g.has("failure")||g.has("guardrail"))&&(m|=Ki.isFailure),(g.has("confusion")||g.has("weak-spot"))&&(m|=Ki.isConfusion),s[a+me.colorFlags+0]=d,s[a+me.colorFlags+1]=f,s[a+me.colorFlags+2]=p,s[a+me.colorFlags+3]=m}return{data:s,nodeCount:i}}function vh(l){const t=new Uint32Array(Math.max(1,l.edges.length)*ir);return l.edges.forEach((e,i)=>{t[i*ir]=e.sourceIndex,t[i*ir+1]=e.targetIndex}),t}const xp=` -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - capture_mode: f32, - live_kind: f32, - live_frame: f32, - live_energy: f32, - projection_days: f32, -}; - -struct Camera { - view_proj: mat4x4, - right: vec4, - up: vec4, -}; - -struct Node { - pos_radius: vec4, - vel_retention: vec4, - color_flags: vec4, - demo: vec4, -}; - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var camera: Camera; -@group(0) @binding(2) var nodes: array; - -// Iridescent thin-film band — ported EXACTLY from causal-brain-demo.html -// spectral(w) (visual DNA §7.1): indigo → cyan-teal → mint → magenta rim, -// wrapping. Activation glow rides this band; base color stays FSRS state. -fn spectral(w_in: f32) -> vec3 { - let w = fract(w_in); - // var, not let: WGSL only allows dynamic indexing through a reference. - var stops = array, 4>( - vec3(0.20, 0.28, 0.95), // indigo - vec3(0.20, 0.85, 0.90), // cyan-teal - vec3(0.45, 1.00, 0.72), // mint - vec3(0.85, 0.45, 1.00) // magenta rim - ); - let f = w * 4.0; - let i = u32(floor(f)) % 4u; - let frac = f - floor(f); - let a = stops[i]; - let b = stops[(i + 1u) % 4u]; - return mix(a, b, frac); -} - -struct VSOut { - @builtin(position) clip: vec4, - @location(0) uv: vec2, - // Per-instance constants: flat interpolation guarantees the flag bit - // field survives the raster stage bit-exact (no barycentric rounding). - @location(1) @interpolate(flat) color: vec3, - // x retention, y flags (bit field as f32), z recall intensity, w radius - @location(2) @interpolate(flat) misc: vec4, - // Per-demo choreography lanes (demo.y, demo.z, demo.w), gated by demo_id: - // rescue (2) searchlight/wave/shock, forgetting-horizon (3) fade-and-fall, - // firewall (4) flare-membrane/shock. Each demo's choreography pass is the - // ONLY writer of its lanes, and every gated term below is an exact no-op - // when its lane is 0.0 — other demos stay pixel-identical. - @location(3) @interpolate(flat) demo_yzw: vec3, -}; - -// Quad corners for two triangles (vertex_index 0..5). -const CORNERS = array, 6>( - vec2(-1.0, -1.0), - vec2( 1.0, -1.0), - vec2( 1.0, 1.0), - vec2(-1.0, -1.0), - vec2( 1.0, 1.0), - vec2(-1.0, 1.0) -); - -@vertex -fn vs_main( - @builtin(vertex_index) vi: u32, - @builtin(instance_index) ii: u32 -) -> VSOut { - var out: VSOut; - if (ii >= u32(params.node_count)) { - // degenerate — clipped away - out.clip = vec4(0.0, 0.0, 2.0, 1.0); - return out; - } - - let node = nodes[ii]; - let corner = CORNERS[vi]; - - // Breath: halo geometry swells ~6% on the global pulse (§7.2), and the - // center memory breathes a touch deeper — a heartbeat, not a strobe. - let flags = u32(node.color_flags.w); - let is_center = (flags & 1u) != 0u; - var breath = 1.0 + 0.06 * params.pulse; - if (is_center) { - breath = 1.0 + 0.12 * params.pulse; - } - - // Sprite spans ~3.2× the core radius so the halo has room to feather out. - // Recall activation swells the sprite — the wavefront physically blooms. - // Per-demo choreography lanes swell it too, gated by demo_id so each - // demo's grammar can never leak into another (lanes are 0.0 elsewhere, - // and the gate makes the no-op structural, not just numerical). - let recall = node.demo.x; - let dy = node.demo.y; - let dz = node.demo.z; - let dw = node.demo.w; - // The firewall grammar fires for the deterministic demo (demo_id==4) AND for - // a LIVE contradiction/suppression event (live_kind==1). Both write the same - // demo lanes (firewall.wgsl), so the visual reads identically either way. - let firewall_active = params.demo_id == 4.0 || params.live_kind == 1.0; - var lane_swell = 0.0; - if (params.demo_id == 2.0) { - // salience-rescue: searchlight pop, wave shiver, shock bloom. - lane_swell = 0.5 * dy + 0.25 * dz + 0.9 * dw; - } else if (firewall_active) { - // firewall: intrusion flare pop (band (0..1]), membrane presence - // (band [2.6..2.9] via the range gate), crimson shock bloom. - lane_swell = 0.35 * min(dy, 1.0) + 0.3 * smoothstep(1.5, 2.2, dy) + 0.55 * dw; - } - // forgetting-horizon (demo 3): VISUAL displacement toward the horizon — - // down and away from the field axis, ~40.5 units at dz = 1 — plus a - // shrink. pos_radius is NEVER written (the force sim owns positions); - // drift is pure of demo.z, so ?frame=N capture stays exact. CPU mirror: - // forgetting-plan.ts horizonDrift(). - var horizon_scale = 1.0; - var drift = vec3(0.0); - if (params.demo_id == 3.0) { - let dzc = clamp(dz, 0.0, 1.0); - horizon_scale = 1.0 - 0.35 * dzc; - if (dz > 0.0) { - let p = node.pos_radius.xyz; - let r_xz = max(length(p.xz), 0.001); - let away = vec3(p.x / r_xz, 0.0, p.z / r_xz); - drift = dzc * (vec3(0.0, -34.0, 0.0) + away * 22.0); - } - } - let half_size = node.pos_radius.w * 3.2 * breath * (1.0 + 0.9 * recall) - * (1.0 + lane_swell) * horizon_scale; - let world = node.pos_radius.xyz + drift - + camera.right.xyz * corner.x * half_size - + camera.up.xyz * corner.y * half_size; - - out.clip = camera.view_proj * vec4(world, 1.0); - out.uv = corner; - out.color = node.color_flags.rgb; - out.misc = vec4(node.vel_retention.w, node.color_flags.w, node.demo.x, node.pos_radius.w); - out.demo_yzw = vec3(dy, dz, dw); - return out; -} - -@fragment -fn fs_main(in: VSOut) -> @location(0) vec4 { - let d = length(in.uv); - if (d > 1.0) { - discard; - } - - let retention = in.misc.x; - let flags = u32(in.misc.y); - let suppressed = (flags & 2u) != 0u; - let is_center = (flags & 1u) != 0u; - - // Soft sprite: hot core + feathered halo. The halo rides the breath pulse. - let core = smoothstep(0.22, 0.0, d); - let halo = pow(max(1.0 - d, 0.0), 2.4); - var intensity = core * 1.35 + halo * (0.42 + 0.18 * params.pulse); - - // Meaning layer: low-retention memories glow dimmer (drifting toward the - // horizon), the center anchor reads brightest. - intensity = intensity * (0.45 + 0.55 * retention); - if (is_center) { - intensity = intensity * 1.6; - } - if (suppressed) { - intensity = intensity * 0.28; - } - - var color = in.color * intensity; - - // Forgetting-horizon (demo 3): multiplicative dim toward near-black as - // demo.z rises. Floor 0.06 — never fully gone, always retrievable. Sits - // BEFORE the recall block so a rescued memory's ignition burns through - // the fade. demo_yzw.y carries demo.z (vec3 = y/z/w lanes). - if (params.demo_id == 3.0) { - color = color * mix(1.0, 0.06, clamp(in.demo_yzw.y, 0.0, 1.0)); - } - - // Recall activation (§7.1): the thin-film band takes over as the wave - // lands. Hue drifts exactly ONE full spectral cycle per 720-frame loop - // (loop_phase wraps 0→1 and spectral() fract-wraps) — oil-slick shimmer - // with a mathematically invisible loop seam. - let recall = in.misc.z; - if (recall > 0.001) { - let band = spectral(0.1 + params.loop_phase + d * 0.35); - let activation = band * recall * (core * 1.7 + halo * 0.9); - // white-hot pinpoint at full ignition - let flash = vec3(1.0, 1.0, 1.0) * core * recall * 0.55; - color = color + activation + flash; - } - - // Per-demo choreography lanes — gated by demo_id AND on nonzero values so - // every other demo is pixel-unchanged (each demo's pass is the only - // writer of its lanes, and lanes are exactly 0.0 everywhere else). - if (params.demo_id == 2.0) { - if (in.demo_yzw.x > 0.001) { - // Searchlight: cold clinical white — unmistakably NOT the spectral grammar. - color = color + vec3(0.82, 0.90, 1.00) * in.demo_yzw.x * (core * 1.8 + halo * 0.7); - } - if (in.demo_yzw.y > 0.001) { - // Interrogation shimmer: icy spectral strobe as the wave scrubs the past. - color = color + spectral(0.55 + params.loop_phase) * in.demo_yzw.y * (core * 0.9 + halo * 0.5) - + vec3(1.0) * core * in.demo_yzw.y * 0.2; - } - if (in.demo_yzw.z > 0.001) { - // Detonation: crimson blaze + warm-white pinpoint. - color = color + vec3(1.00, 0.16, 0.10) * in.demo_yzw.z * (core * 1.9 + halo * 1.1) - + vec3(1.0, 0.85, 0.8) * core * in.demo_yzw.z * 0.4; - } - } else if (params.demo_id == 4.0 || params.live_kind == 1.0) { - // firewall: demo.y carries TWO value bands — intrusion flare (0..1] - // and membrane [2.6..2.9] — separated by range, one lane. demo.w is - // the crimson shock rim / sever blink. (demo_yzw = y/z/w lanes.) - let fy = in.demo_yzw.x; - let fw = in.demo_yzw.z; - // Intrusion flare: sickly green-white — a hue deliberately OUTSIDE - // both the FSRS palette and the thin-film band. Continuous across the - // band boundary (fades out as fy climbs toward the membrane band). - let flare = min(fy, 1.0) * (1.0 - smoothstep(1.0, 1.8, fy)); - if (flare > 0.001) { - color = color + vec3(0.62, 1.00, 0.55) * flare * (core * 1.7 + halo * 0.9) - + vec3(0.90, 1.00, 0.85) * core * flare * 0.5; - } - // Membrane: quarantine ring at d ≈ 0.75 with fresnel-ish falloff — - // green body, crimson edge. exp(-q·q) squares by multiplication and - // the pow base is clamped ≥ 0 (no pow(neg) anywhere). - let mw = smoothstep(1.5, 2.2, fy); - if (mw > 0.001) { - let q = (d - 0.75) * 9.0; - let ring = exp(-q * q); - let fresnel = pow(clamp(d / 0.75, 0.0, 1.0), 3.0); - let ring_col = mix(vec3(0.55, 1.00, 0.60), vec3(1.00, 0.20, 0.16), - smoothstep(0.72, 0.92, d)); - color = color + ring_col * ring * fresnel * mw * 1.4; - } - // Shockwave: crimson RIM as the front passes (a rim, not a blaze). - if (fw > 0.001) { - let rim = smoothstep(0.45, 0.8, d) * (1.0 - smoothstep(0.85, 1.0, d)); - color = color + vec3(1.00, 0.14, 0.10) * rim * fw * 1.5 - + vec3(1.00, 0.60, 0.50) * core * fw * 0.15; - } - } - - // Additive target (src=one, dst=one): alpha is ignored, light accumulates. - return vec4(color * params.brightness, 1.0); -} -`,bp=` -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - capture_mode: f32, - live_kind: f32, - live_frame: f32, - live_energy: f32, - projection_days: f32, -}; - -struct Node { - pos_radius: vec4, - vel_retention: vec4, - color_flags: vec4, - demo: vec4, -}; - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var nodes: array; -// x source index, y target index, z beat frame, w kind (0 recall, 1 backward) -@group(0) @binding(2) var path: array>; -// x source index, y target node index (Increment 7: force simulation edges) -@group(0) @binding(3) var edges: array>; -// v2.3 living field — per-node LIVE retrievability (real FSRS curve, recomputed -// on the CPU by the LiveBridge). One f32 per node. read to overwrite -// vel_retention.w so render-nodes dims each memory on its true forgetting curve. -@group(0) @binding(4) var live_retention: array; - -// --- Force-simulation helpers (Increment 7) --- - -fn safe_normalize(v: vec3) -> vec3 { - let l = length(v); - if (l < 0.0001) { return vec3(0.0); } - return v / l; -} - -fn clamp_len(v: vec3, hi: f32) -> vec3 { - let l = length(v); - if (l > hi && l > 0.0001) { return v * (hi / l); } - return v; -} - -@compute @workgroup_size(64) -fn recall_sim(@builtin(global_invocation_id) id: vec3) { - let i = id.x; - if (i >= u32(params.node_count)) { - return; - } - - let frame = params.frame; - var intensity = 0.0; - - let steps = u32(params.path_count); - for (var s = 0u; s < steps; s = s + 1u) { - let step = path[s]; - let bf = f32(step.z); - - if (step.y == i) { - // Arrival: sharp attack as the wavefront lands, slow afterglow. - let attack = smoothstep(bf - 14.0, bf + 4.0, frame); - let decay = 1.0 - smoothstep(bf + 40.0, bf + 200.0, frame); - intensity = max(intensity, attack * decay); - } - if (step.x == i && step.x != step.y) { - // Departure: the source shimmers as the wave leaves it. - let rise = smoothstep(bf - 55.0, bf - 30.0, frame); - let fall = 1.0 - smoothstep(bf + 10.0, bf + 70.0, frame); - intensity = max(intensity, rise * fall * 0.45); - } - } - - var node = nodes[i]; - let flags = u32(node.color_flags.w); - let is_center = (flags & 1u) != 0u; - - // Write recall intensity (existing behavior preserved). - node.demo.x = intensity; - - // v2.3 LIVE FSRS decay — overwrite retention with the real forgetting-curve - // value the LiveBridge computed for this node on the CPU. This is the #1 - // moat: render-nodes already dims by vel_retention.w (line ~183), so writing - // the true retrievability here makes every memory visibly forget on its own - // curve. Guarded so a graph with no live-decay data (all zeros) keeps its - // static snapshot instead of collapsing to black. - if (i < arrayLength(&live_retention)) { - let lr = live_retention[i]; - if (lr > 0.0) { - node.vel_retention = vec4(node.vel_retention.xyz, lr); - } - } - - // --- Increment 7: force simulation --- - - // Capture mode (params.capture_mode == 1.0): skip physics integration - // entirely. The storage-buffer state stays frozen at initial upload - // values, making same URL + frame → identical pixels (spec §4 Inc 9). - if (params.capture_mode == 0.0) { - // 7B: center anchor — center node never moves. - // (WGSL forbids swizzle stores — reconstruct the vec4, preserving .w.) - if (is_center) { - node.pos_radius = vec4(0.0, 0.0, 0.0, node.pos_radius.w); - node.vel_retention = vec4(0.0, 0.0, 0.0, node.vel_retention.w); - nodes[i] = node; - return; - } - - let pos = node.pos_radius.xyz; - var force = vec3(0.0); - - // 7C: edge springs — scan existing edgeBuffer, no atomics. - for (var e = 0u; e < u32(params.edge_count); e = e + 1u) { - let edge = edges[e]; - var other_idx = 0xffffffffu; - if (edge.x == i) { other_idx = edge.y; } - if (edge.y == i) { other_idx = edge.x; } - if (other_idx != 0xffffffffu && other_idx < u32(params.node_count)) { - let other = nodes[other_idx].pos_radius.xyz; - let delta = other - pos; - let dist = max(length(delta), 0.001); - let dir = delta / dist; - let stretch = dist - 34.0; - force = force + dir * stretch * 0.00055; - } - } - - // 7D: soft repulsion (only ≤ 500 nodes for performance). - if (u32(params.node_count) <= 500u) { - for (var j = 0u; j < u32(params.node_count); j = j + 1u) { - if (j == i) { continue; } - let other = nodes[j].pos_radius.xyz; - let delta = pos - other; - let d2 = max(dot(delta, delta), 9.0); - force = force + safe_normalize(delta) * (7.5 / d2); - } - } - - // Gentle centering: keeps the field in frame without crushing it. - force = force + (-pos) * 0.0008; - - // v2.3 DREAM STORM — while the real dream pipeline streams (live_kind == - // 2 == LIVE_KIND.dreamStorm), the field enters a metabolic consolidation - // storm: damping loosens (springs overshoot, clusters slosh together as - // new ConnectionDiscovered edges are appended) and a deterministic - // turbulence rides live_energy. Pure of node index + live_frame, so no - // wall clock — the storm is a function of the real event envelope. At - // rest (energy 0) both terms vanish → the field is byte-identical. - var damping = 0.88; - if (params.live_kind == 2.0) { - let e = clamp(params.live_energy, 0.0, 1.4); - damping = 0.88 + 0.09 * e; // up to ~0.97 — longer, sloshier settling - // Curl-free deterministic jitter: phase from node index + live_frame. - let ph = f32(i) * 0.61803 + params.live_frame * 0.05; - let jitter = vec3(sin(ph * 6.2831), sin(ph * 4.7123 + 1.3), sin(ph * 5.318 + 2.1)); - force = force + jitter * (0.006 * e); - } - - // 7B: velocity damping + cap, then position integration. - var vel = node.vel_retention.xyz; - vel = (vel + force) * damping; - vel = clamp_len(vel, 0.42); - node.vel_retention = vec4(vel, node.vel_retention.w); - node.pos_radius = vec4(pos + vel, node.pos_radius.w); - } - // When capture_mode (params.capture_mode == 1.0), node is NOT written back — - // the storage buffer retains its initial upload values, guaranteeing - // deterministic pixels for the same frame index. - nodes[i] = node; -} -`,_l=` -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - capture_mode: f32, - live_kind: f32, - live_frame: f32, - live_energy: f32, - projection_days: f32, -}; - -struct Camera { - view_proj: mat4x4, - right: vec4, - up: vec4, -}; - -struct Node { - pos_radius: vec4, - vel_retention: vec4, - color_flags: vec4, - demo: vec4, -}; - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var camera: Camera; -@group(0) @binding(2) var nodes: array; -// x source index, y target index, z beat frame, w kind (0 recall, 1 backward) -@group(0) @binding(3) var path: array>; - -// Same thin-film band as the node shader (§7.1). -fn spectral(w_in: f32) -> vec3 { - let w = fract(w_in); - // var, not let: WGSL only allows dynamic indexing through a reference. - var stops = array, 4>( - vec3(0.20, 0.28, 0.95), - vec3(0.20, 0.85, 0.90), - vec3(0.45, 1.00, 0.72), - vec3(0.85, 0.45, 1.00) - ); - let f = w * 4.0; - let i = u32(floor(f)) % 4u; - let frac = f - floor(f); - let a = stops[i]; - let b = stops[(i + 1u) % 4u]; - return mix(a, b, frac); -} - -struct VSOut { - @builtin(position) clip: vec4, - // x: t along segment (0 source → 1 target), y: side (-1..1) - @location(0) uv: vec2, - // x: beat frame, y: kind, z: segment visible (0 skips degenerate steps) - // Per-instance constant — flat keeps it bit-exact through the raster. - @location(1) @interpolate(flat) beat: vec3, -}; - -// (t, side) corners for two triangles of the ribbon. -const RIBBON = array, 6>( - vec2(0.0, -1.0), - vec2(1.0, -1.0), - vec2(1.0, 1.0), - vec2(0.0, -1.0), - vec2(1.0, 1.0), - vec2(0.0, 1.0) -); - -@vertex -fn vs_main( - @builtin(vertex_index) vi: u32, - @builtin(instance_index) ii: u32 -) -> VSOut { - var out: VSOut; - if (ii >= u32(params.path_count)) { - out.clip = vec4(0.0, 0.0, 2.0, 1.0); - out.beat = vec3(0.0); - return out; - } - - let step = path[ii]; - let src = nodes[step.x]; - let dst = nodes[step.y]; - let corner = RIBBON[vi]; - - // Degenerate (origin beat: source == target) — emit nothing visible. - if (step.x == step.y) { - out.clip = vec4(0.0, 0.0, 2.0, 1.0); - out.beat = vec3(0.0); - return out; - } - - let a = camera.view_proj * vec4(src.pos_radius.xyz, 1.0); - let b = camera.view_proj * vec4(dst.pos_radius.xyz, 1.0); - - // NDC-space perpendicular for constant screen width. - let ndc_a = a.xy / max(a.w, 0.0001); - let ndc_b = b.xy / max(b.w, 0.0001); - var dir = ndc_b - ndc_a; - let dlen = max(length(dir), 0.0001); - dir = dir / dlen; - let perp = vec2(-dir.y, dir.x); - - // Ribbon half-width in NDC (aspect-corrected), ~2.5 px on a 900px-tall view. - let px = 2.5 / max(params.viewport_h, 1.0) * 2.0; - let width = vec2(px * (params.viewport_h / max(params.viewport_w, 1.0)), px); - - let base = mix(a, b, corner.x); - let offset = perp * width * corner.y * base.w; - out.clip = vec4(base.xy + offset, base.zw); - out.uv = vec2(corner.x, corner.y); - out.beat = vec3(f32(step.z), f32(step.w), 1.0); - return out; -} - -@fragment -fn fs_main(in: VSOut) -> @location(0) vec4 { - if (in.beat.z < 0.5) { - discard; - } - - let frame = params.frame; - let bf = in.beat.x; - let t = in.uv.x; - - // Wave departs 45 frames before the beat and lands exactly on it. - let progress = clamp((frame - (bf - 45.0)) / 45.0, 0.0, 1.0); - // Nothing before departure; trail lingers ~90 frames after arrival. - let live = smoothstep(bf - 46.0, bf - 44.0, frame) - * (1.0 - smoothstep(bf + 40.0, bf + 90.0, frame)); - if (live <= 0.001) { - discard; - } - - // The light packet: gaussian around the wavefront position. - let dwave = (t - progress) * 14.0; - let packet = exp(-dwave * dwave); - - // Fading trail behind the packet — provenance stays visible a beat. - var trail = 0.0; - if (t < progress) { - trail = (1.0 - (progress - t)) * 0.22; - } - - // Feather across the ribbon width. - let across = 1.0 - abs(in.uv.y); - let profile = across * across; - - // Backward/contradiction hops burn hotter into the magenta rim (§7.4). - // Hue drifts one full spectral cycle per loop (seamless at the wrap). - // Kind 2 (salience-rescue probe): a gray failing beam — vector search - // visibly probing lookalikes and coming back empty. Kinds 0/1 unchanged. - var band = spectral(0.15 + t * 0.35 + params.loop_phase); - var packet_white = 0.35; - if (in.beat.y > 1.5) { - band = vec3(0.62, 0.66, 0.72); - packet_white = 0.18; - } else if (in.beat.y > 0.5) { - band = mix(band, vec3(1.0, 0.25, 0.45), 0.55); - } - - let energy = (packet * 1.6 + trail) * profile * live; - let color = band * energy + vec3(1.0) * packet * profile * live * packet_white; - return vec4(color * params.brightness, 1.0); -} -`;function vp(l){return 60+l*60}function Ml(l,t,e=8,i={}){var c;const s=[...l.nodes].sort((u,d)=>u.idd.id?1:0),n=[...l.edges].sort((u,d)=>{const f=`${u.source}\0${u.target}\0${u.type}`,p=`${d.source}\0${d.target}\0${d.type}`;return fp?1:0}),r=i.centerId??l.center_id,a=rp(s,n,r,e,{preferCausal:i.preferCausal}),o=[];for(let u=0;u0?a.beats[u-1].nodeId:d.nodeId,m=t.indexById.get(p)??f,g=(((c=d.viaEdge)==null?void 0:c.type)??"").toLowerCase(),x=g==="causal"||g.includes("causal"),y=d.kind==="contradiction"||x;o.push({sourceIndex:m,targetIndex:f,beatFrame:vp(u),kind:y?ze.backwardCause:ze.recall,beatKind:d.kind,nodeId:d.nodeId,label:d.node.label})}const h=new Uint32Array(Math.max(1,o.length)*Qi);return o.forEach((u,d)=>{h[d*Qi]=u.sourceIndex,h[d*Qi+1]=u.targetIndex,h[d*Qi+2]=u.beatFrame,h[d*Qi+3]=u.kind}),{data:h,steps:o,path:a}}const wp=24,wh=300;class _p{constructor(t){z(this,"engine");z(this,"pipeline",null);z(this,"bindGroup",null);z(this,"cameraBuffer",null);z(this,"nodeBuffer",null);z(this,"edgeBuffer",null);z(this,"cameraData",new Float32Array(wp));z(this,"nodeCount",0);z(this,"simPipeline",null);z(this,"simBindGroup",null);z(this,"pathBuffer",null);z(this,"liveRetentionBuffer",null);z(this,"pathPipeline",null);z(this,"pathBindGroup",null);z(this,"pathStepCount",0);z(this,"graph",null);z(this,"pathSteps",[]);this.engine=t,t.addPass(this)}upload(t,e,i){var f,p,m,g;const s=this.engine.gpuDevice;if(!s)return;const n=(i==null?void 0:i.recallPath)??!0,r=yp(t);this.graph=r;const a=new ea({seed:e}),{data:o,nodeCount:h}=wl(r,a.state.rng);this.nodeCount=h,(f=this.nodeBuffer)==null||f.destroy(),this.nodeBuffer=s.createBuffer({label:"observatory-node-state",size:Math.max(o.byteLength,64),usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC|GPUBufferUsage.VERTEX}),s.queue.writeBuffer(this.nodeBuffer,0,o.buffer);const c=vh(r);(p=this.edgeBuffer)==null||p.destroy(),this.edgeBuffer=s.createBuffer({label:"observatory-edge-index",size:c.byteLength,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),s.queue.writeBuffer(this.edgeBuffer,0,c.buffer);const u=new Float32Array(Math.max(h,4));for(let x=0;x0){const a=t.beginComputePass({label:"observatory-recall-sim"});a.setPipeline(this.simPipeline),a.setBindGroup(0,this.simBindGroup),a.dispatchWorkgroups(Math.ceil(this.nodeCount/64)),a.end()}}render(t){!this.pipeline||!this.bindGroup||this.nodeCount===0||(t.setPipeline(this.pipeline),t.setBindGroup(0,this.bindGroup),t.draw(6,this.nodeCount),this.pathPipeline&&this.pathBindGroup&&this.pathStepCount>0&&(t.setPipeline(this.pathPipeline),t.setBindGroup(0,this.pathBindGroup),t.draw(6,this.pathStepCount)))}get nodeStateBuffer(){return this.nodeBuffer}get cameraUniformBuffer(){return this.cameraBuffer}get nodeCountValue(){return this.nodeCount}get pathStepMeta(){return this.pathSteps}async pickAt(t,e){const i=this.engine.gpuDevice;if(!i||!this.nodeBuffer||!this.graph||this.nodeCount===0)return null;const s=this.nodeCount*Mt*4,n=i.createBuffer({label:"observatory-pick-staging",size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),r=i.createCommandEncoder({label:"observatory-pick-copy"});r.copyBufferToBuffer(this.nodeBuffer,0,n,0,s),i.queue.submit([r.finish()]);let a;try{await n.mapAsync(GPUMapMode.READ),a=new Float32Array(n.getMappedRange().slice(0))}catch{return n.destroy(),null}n.unmap(),n.destroy();const o=this.engine.params[6]||1,h=this.engine.params[7]||1,c=this.engine.params[1],u=Ya(c,o/h,wh).viewProj,d=1/Math.tan(50*Math.PI/360);let f=-1,p=1/0;for(let m=0;m0){const t=l.centerIndex,e=l.edges.filter(i=>i.sourceIndex===t||i.targetIndex===t);if(e.length>0){let i=-1,s=-1;for(const n of e){const r=n.sourceIndex===t?n.targetIndex:n.sourceIndex,a=l.nodes[r];a&&a.retention>s&&(s=a.retention,i=r)}if(i>=0)return i}}for(let t=0;tx.sourceIndex===i||x.targetIndex===i);for(let x=0;xn.sourceIndex===t||n.targetIndex===t),i=e.length;if(i===0)return new Uint32Array(0);const s=new Uint32Array(i*fs);for(let n=0;n, - target_size: vec4, - color_phase: vec4, - state: vec4, -}; - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var particles: array; - -@compute @workgroup_size(64) -fn birth_compute(@builtin(global_invocation_id) id: vec3) { - let i = id.x; - if (i >= arrayLength(&particles)) { - return; - } - - // Capture mode (params.capture_mode == 1.0): skip physics integration. - // The storage-buffer state stays frozen at initial upload values. - if (params.capture_mode == 1.0) { - return; - } - - var particle = particles[i]; - let frame = params.frame; - let phase = params.loop_phase; - - // --- Convergence choreography (integer cycles per 720-frame loop) --- - - // Phase offset (stagger) from start_life.w: 0..1 → delays convergence. - let stagger = particle.start_life.w; - - // Effective frame: staggered loop frame (wraps at 720). - let effFrame = fract(phase + stagger * 0.15) * 720.0; - - // --- Phase 1: latent trace condensing (frames 0–239) --- - // Slow drift toward target. - var t: f32; - if (effFrame < 240.0) { - // Smooth ease-in: 0 → 1 over 240 frames. - t = effFrame / 240.0; - t = t * t * (3.0 - 2.0 * t); // smoothstep - } - // --- Phase 2: engram coalescence (frames 240–329) --- - // Accelerated convergence to target. - else if (effFrame < 330.0) { - let localFrame = effFrame - 240.0; - // 0 → 1 over 90 frames, with slight overshoot then settle. - t = localFrame / 90.0; - t = t * t * (3.0 - 2.0 * t); - // Add a small overshoot (1.05) then settle back to 1.0. - t = 1.0 - 0.05 * (1.0 - t); - } - // --- Phase 3: memory ignition (frames 330–359) --- - // Hold at target (flash handled in render). - else if (effFrame < 360.0) { - t = 1.0; - } - // --- Phase 4: associations engrave (frames 360–509) --- - // Hold at target. - else if (effFrame < 510.0) { - t = 1.0; - } - // --- Phase 5: stabilization (frames 510–719) --- - // Hold at target, then fade alpha for reset. - else { - let localFrame = effFrame - 510.0; - // Fade alpha to 0 for seamless reset at frame 0. - t = 1.0; - particle.state.w = 1.0 - smoothstep(0.0, 150.0, localFrame); - } - - // Interpolate from start to target. - let startPos = particle.start_life.xyz; - let targetPos = particle.target_size.xyz; - // (WGSL forbids swizzle stores - reconstruct, preserving alpha in .w) - particle.state = vec4(mix(startPos, targetPos, t), particle.state.w); - - // Alpha: particles fade in during convergence, fade out during reset. - let fadeIn = smoothstep(0.0, 60.0, effFrame); - particle.state.w = max(particle.state.w, fadeIn * 0.8); - - particles[i] = particle; -} -`,Fp=16,Rp=6,Ep=330,Op=359,Dp=360;class Lp{constructor(t){z(this,"engine");z(this,"nodeRenderer");z(this,"active");z(this,"computePipeline",null);z(this,"computeBindGroup",null);z(this,"particleBuffer",null);z(this,"particleCount",0);z(this,"renderPipeline",null);z(this,"renderBindGroup",null);z(this,"haloPipeline",null);z(this,"haloBindGroup",null);z(this,"haloIndexBuffer",null);z(this,"engravePipeline",null);z(this,"engraveBindGroup",null);z(this,"engraveBuffer",null);z(this,"engraveStepCount",0);z(this,"timeline",[]);z(this,"birthPlan",null);this.engine=t.engine,this.nodeRenderer=t.nodeRenderer,this.active=!1,this.engine.addPass(this)}get engraveSteps(){var t;return((t=this.birthPlan)==null?void 0:t.edgeSteps)??new Uint32Array(0)}upload(t){var n,r;const e=this.engine.gpuDevice;if(!e||!this.nodeRenderer.nodeStateBuffer)return;const i=this.nodeRenderer.graph;if(!i)return;this.birthPlan=Bp(i,t),this.timeline=this.birthPlan.timeline;const s=this.birthPlan.particles.length/Fp;this.particleCount=s,(n=this.particleBuffer)==null||n.destroy(),this.particleBuffer=e.createBuffer({label:"observatory-birth-particles",size:this.birthPlan.particles.byteLength,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),e.queue.writeBuffer(this.particleBuffer,0,this.birthPlan.particles.buffer),(r=this.engraveBuffer)==null||r.destroy(),this.engraveStepCount=this.birthPlan.edgeSteps.length/4,this.engraveStepCount>0&&(this.engraveBuffer=e.createBuffer({label:"observatory-birth-engrave",size:this.birthPlan.edgeSteps.byteLength,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),e.queue.writeBuffer(this.engraveBuffer,0,this.birthPlan.edgeSteps.buffer)),this.createComputePipeline(e),this.createRenderPipeline(e),this.createHaloPipeline(e),this.createEngravePipeline(e)}createComputePipeline(t){const e=t.createShaderModule({label:"observatory-birth-compute",code:Pp});this.computePipeline=t.createComputePipeline({label:"observatory-birth-compute-pipeline",layout:"auto",compute:{module:e,entryPoint:"birth_compute"}});const i=[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.particleBuffer}}];this.computeBindGroup=t.createBindGroup({label:"observatory-birth-compute-bind",layout:this.computePipeline.getBindGroupLayout(0),entries:i})}createRenderPipeline(t){const i=t.createShaderModule({label:"observatory-birth-render",code:` -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - _pad: f32, -}; - -struct Camera { - view_proj: mat4x4, - right: vec4, - up: vec4, -}; - -struct BirthParticle { - start_life: vec4, - target_size: vec4, - color_phase: vec4, - state: vec4, -}; - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var camera: Camera; -@group(0) @binding(2) var particles: array; - -struct VSOut { - @builtin(position) clip: vec4, - @location(0) uv: vec2, - @location(1) @interpolate(flat) color: vec3, - @location(2) @interpolate(flat) misc: vec4, -}; - -const CORNERS = array, 6>( - vec2(-1.0, -1.0), - vec2( 1.0, -1.0), - vec2( 1.0, 1.0), - vec2(-1.0, -1.0), - vec2( 1.0, 1.0), - vec2(-1.0, 1.0) -); - -@vertex -fn vs_main( - @builtin(vertex_index) vi: u32, - @builtin(instance_index) ii: u32 -) -> VSOut { - var out: VSOut; - if (ii >= arrayLength(&particles)) { - out.clip = vec4(0.0, 0.0, 2.0, 1.0); - return out; - } - - let particle = particles[ii]; - let corner = CORNERS[vi]; - - // Current position from state.xyz. - let pos = particle.state.xyz; - - // Base size from target_size.w. - let baseSize = particle.target_size.w; - - // Flash boost during ignition (frames 330–359). - let frame = params.frame; - var flashBoost = 1.0; - if (frame >= 330.0 && frame <= 359.0) { - let flashT = (frame - 330.0) / 29.0; // 0..1 over flash frames - // Sharp flash: peaks at frame 345, fades by 359. - flashBoost = 1.0 + 3.0 * (1.0 - smoothstep(330.0, 345.0, frame)) - + 2.0 * smoothstep(345.0, 359.0, frame); - } - - // Size: base + flash boost + pulse breathing. - let breath = 1.0 + 0.06 * params.pulse; - let halfSize = baseSize * 4.0 * breath * flashBoost; - - let world = pos - + camera.right.xyz * corner.x * halfSize - + camera.up.xyz * corner.y * halfSize; - - out.clip = camera.view_proj * vec4(world, 1.0); - out.uv = corner; - - // Color: violet dust (0.55, 0.32, 1.00) with spectral rim. - let phase = particle.color_phase.w; - let spectralW = fract(params.loop_phase + phase); - var spectralColor: vec3; - var stops = array, 4>( - vec3(0.55, 0.32, 1.00), // violet base - vec3(0.40, 0.60, 1.00), // blue-violet - vec3(0.70, 0.45, 1.00), // magenta-violet - vec3(0.55, 0.32, 1.00) // wrap - ); - let f = spectralW * 4.0; - let i = u32(floor(f)) % 4u; - let frac = f - floor(f); - spectralColor = mix(stops[i], stops[(i + 1u) % 4u], frac); - - // Alpha from state.w (convergence progress + fade). - let alpha = particle.state.w; - - out.color = spectralColor; - out.misc = vec4(baseSize, 0.0, 0.0, alpha); - return out; -} - -@fragment -fn fs_main(in: VSOut) -> @location(0) vec4 { - let d = length(in.uv); - if (d > 1.0) { - discard; - } - - let alpha = in.misc.w; - let core = smoothstep(0.25, 0.0, d); - let halo = pow(max(1.0 - d, 0.0), 2.0); - - // Additive glow: core + halo. - let intensity = core * 1.5 + halo * 0.6; - - // Flash boost during ignition. - let frame = params.frame; - var flash = 0.0; - if (frame >= 330.0 && frame <= 359.0) { - flash = smoothstep(330.0, 345.0, frame) * 2.0; - } - - let color = in.color * (intensity + flash); - - return vec4(color * params.brightness, 1.0); -} -`});this.renderPipeline=t.createRenderPipeline({label:"observatory-birth-render",layout:"auto",vertex:{module:i,entryPoint:"vs_main"},fragment:{module:i,entryPoint:"fs_main",targets:[{format:this.engine.sceneFormat,blend:{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}}]},primitive:{topology:"triangle-list"}});const s=this.nodeRenderer.cameraUniformBuffer;this.renderBindGroup=t.createBindGroup({label:"observatory-birth-render-bind",layout:this.renderPipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:s}},{binding:2,resource:{buffer:this.particleBuffer}}]})}createHaloPipeline(t){const i=t.createShaderModule({label:"observatory-birth-halo",code:` -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - _pad: f32, -}; - -struct Camera { - view_proj: mat4x4, - right: vec4, - up: vec4, -}; - -struct Node { - pos_radius: vec4, - vel_retention: vec4, - color_flags: vec4, - demo: vec4, -}; - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var camera: Camera; -@group(0) @binding(2) var nodes: array; - -struct VSOut { - @builtin(position) clip: vec4, - @location(0) uv: vec2, -}; - -@vertex -fn vs_main( - @builtin(vertex_index) vi: u32, - @builtin(instance_index) ii: u32 -) -> VSOut { - var out: VSOut; - if (ii >= u32(params.node_count)) { - out.clip = vec4(0.0, 0.0, 2.0, 1.0); - return out; - } - - let node = nodes[ii]; - let flags = u32(node.color_flags.w); - let is_target = (flags & 4u) != 0u; // flag 2: is birth target - - if (!is_target) { - out.clip = vec4(0.0, 0.0, 2.0, 1.0); - return out; - } - - // Flash halo: only visible during ignition (frames 330–359). - let frame = params.frame; - if (frame < 330.0 || frame > 359.0) { - out.clip = vec4(0.0, 0.0, 2.0, 1.0); - return out; - } - - // Halo ring: expands during flash, fades by frame 359. - let flashT = (frame - 330.0) / 29.0; // 0..1 - let ringRadius = 0.3 + flashT * 0.5; // expands 0.3 → 0.8 - - // Quad centered on target position. - let pos = node.pos_radius.xyz; - let cornerX = (f32(vi) / 3.0 - 1.0); // -1, 0, 1 (3 unique x) - let cornerY = (f32(vi % 3) / 1.5 - 1.0); // -1, 0, 1 - - // We use 4 vertices for a simple quad (vi 0..3). - let cx = cornerX * ringRadius; - let cy = cornerY * ringRadius; - - let world = pos - + camera.right.xyz * cx - + camera.up.xyz * cy; - - out.clip = camera.view_proj * vec4(world, 1.0); - - // UV for radial fade. - out.uv = vec2(cx / ringRadius, cy / ringRadius); - - return out; -} - -@fragment -fn fs_main(in: VSOut) -> @location(0) vec4 { - let d = length(in.uv); - if (d > 0.7) { - discard; - } - - // Flash: white-hot core, violet rim. - let flashIntensity = 1.0 - smoothstep(0.0, 0.7, d); - let color = vec3(0.7, 0.4, 1.0) * flashIntensity * 2.0; - - // Fade out as flash ends. - let frame = params.frame; - let fadeOut = 1.0 - smoothstep(345.0, 359.0, frame); - - return vec4(color * params.brightness * fadeOut, 1.0); -} -`});this.haloPipeline=t.createRenderPipeline({label:"observatory-birth-halo",layout:"auto",vertex:{module:i,entryPoint:"vs_main"},fragment:{module:i,entryPoint:"fs_main",targets:[{format:this.engine.sceneFormat,blend:{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}}]},primitive:{topology:"triangle-list"}});const s=this.nodeRenderer.cameraUniformBuffer;this.haloBindGroup=t.createBindGroup({label:"observatory-birth-halo-bind",layout:this.haloPipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:s}},{binding:2,resource:{buffer:this.nodeRenderer.nodeStateBuffer}}]})}createEngravePipeline(t){if(this.engraveStepCount===0||!this.engraveBuffer)return;const e=t.createShaderModule({label:"observatory-birth-engrave",code:_l});this.engravePipeline=t.createRenderPipeline({label:"observatory-birth-engrave-pipeline",layout:"auto",vertex:{module:e,entryPoint:"vs_main"},fragment:{module:e,entryPoint:"fs_main",targets:[{format:this.engine.sceneFormat,blend:{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}}]},primitive:{topology:"triangle-list"}}),this.engraveBindGroup=t.createBindGroup({label:"observatory-birth-engrave-bind",layout:this.engravePipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.nodeRenderer.cameraUniformBuffer}},{binding:2,resource:{buffer:this.nodeRenderer.nodeStateBuffer}},{binding:3,resource:{buffer:this.engraveBuffer}}]})}compute(t,e){const i=this.engine.params[9];if(this.active=i===1,!this.active||!this.computePipeline||!this.computeBindGroup)return;const s=t.beginComputePass({label:"observatory-birth-compute"});s.setPipeline(this.computePipeline),s.setBindGroup(0,this.computeBindGroup),s.dispatchWorkgroups(Math.ceil(this.particleCount/64)),s.end()}render(t,e){this.active&&(this.renderPipeline&&this.renderBindGroup&&this.particleCount>0&&(t.setPipeline(this.renderPipeline),t.setBindGroup(0,this.renderBindGroup),t.draw(Rp,this.particleCount)),this.haloPipeline&&this.haloBindGroup&&e>=Ep&&e<=Op&&(t.setPipeline(this.haloPipeline),t.setBindGroup(0,this.haloBindGroup),t.draw(4,this.nodeRenderer.nodeCountValue)),this.engravePipeline&&this.engraveBindGroup&&this.engraveStepCount>0&&e>=Dp&&(t.setPipeline(this.engravePipeline),t.setBindGroup(0,this.engraveBindGroup),t.draw(6,this.engraveStepCount)))}dispose(){var t,e,i,s,n,r,a,o,h,c,u;(t=this.particleBuffer)==null||t.destroy(),this.particleBuffer=null,(i=(e=this.computePipeline)==null?void 0:e.destroy)==null||i.call(e),this.computePipeline=null,this.computeBindGroup=null,(n=(s=this.renderPipeline)==null?void 0:s.destroy)==null||n.call(s),this.renderPipeline=null,this.renderBindGroup=null,(a=(r=this.haloPipeline)==null?void 0:r.destroy)==null||a.call(r),this.haloPipeline=null,this.haloBindGroup=null,(o=this.haloIndexBuffer)==null||o.destroy(),this.haloIndexBuffer=null,(c=(h=this.engravePipeline)==null?void 0:h.destroy)==null||c.call(h),this.engravePipeline=null,this.engraveBindGroup=null,(u=this.engraveBuffer)==null||u.destroy(),this.engraveBuffer=null}}function Np(l){const t=l.hopSlot.toFixed(1),e=l.causeDepth.toFixed(1);return` -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - capture_mode: f32, - live_kind: f32, - live_frame: f32, - live_energy: f32, - projection_days: f32, -}; - -struct Node { - pos_radius: vec4, - vel_retention: vec4, - color_flags: vec4, - demo: vec4, -}; - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var nodes: array; -// 1 u32/node: bits 0-15 hopDepth (0xffff unreached), 16 failure, 17 cause, -// 18 lookalike, 19-21 lookalike k (rescue-plan.ts packing). -@group(0) @binding(2) var wave: array; - -const HOP_SLOT: f32 = ${t}; -const CAUSE_DEPTH: f32 = ${e}; -const TAU: f32 = 6.28318530717958647; - -fn env(f: f32, a0: f32, a1: f32, r0: f32, r1: f32) -> f32 { - return smoothstep(a0, a1, f) * (1.0 - smoothstep(r0, r1, f)); -} - -fn arrival(d: f32) -> f32 { - return min(260.0 + HOP_SLOT * d, 514.0); -} - -@compute @workgroup_size(64) -fn rescue_choreo(@builtin(global_invocation_id) id: vec3) { - let i = id.x; - if (i >= u32(params.node_count)) { - return; - } - if (i >= arrayLength(&wave)) { - return; - } - // Belt-and-braces atop the TS gate: salience-rescue is demo index 2. - if (params.demo_id != 2.0) { - return; - } - - let packed = wave[i]; - let depth_u = packed & 0xffffu; - let d = f32(depth_u); - let is_failure = (packed & 0x10000u) != 0u; - let is_cause = (packed & 0x20000u) != 0u; - let is_look = (packed & 0x40000u) != 0u; - let look_k = f32((packed >> 19u) & 0x7u); - - let f = params.frame; - - var dx = 0.0; - var dy = 0.0; - var dz = 0.0; - var dw = 0.0; - - if (is_failure) { - // Detonation spike, wound simmer, recognition flare as the arc lands. - dw = dw + env(f, 90.0, 96.0, 120.0, 168.0); - dw = dw + 0.35 * env(f, 100.0, 130.0, 600.0, 656.0); - dw = dw + 0.35 * env(f, 552.0, 562.0, 580.0, 640.0); - // Symptom backlight while the cause burns. - dx = dx + 0.4 * env(f, 556.0, 566.0, 620.0, 668.0); - } - if (!is_failure && depth_u >= 1u && depth_u <= 12u) { - // Shockwave blink: crimson concussion, 3 frames/hop of REAL graph distance. - dw = dw + 0.75 * exp(-0.3 * d) - * env(f, 92.0 + 3.0 * d, 96.0 + 3.0 * d, 96.0 + 3.0 * d, 122.0 + 3.0 * d); - } - if (is_look) { - let fk = 138.0 + 28.0 * look_k; - // Searchlight flare — cold pop, sequential, on camera. - dy = dy + env(f, fk - 6.0, fk, fk + 10.0, fk + 26.0); - // Ash residue — the struck-through lookalike stays in frame until the verdict. - dy = dy + 0.15 * smoothstep(fk + 10.0, fk + 26.0, f) * (1.0 - smoothstep(600.0, 656.0, f)); - } - if (!is_failure && depth_u >= 1u && d <= CAUSE_DEPTH) { - let wd = arrival(d); - // Interrogation flicker: 24 integer sine cycles per loop, per-depth phase. - let flicker = 0.75 + 0.25 * sin(TAU * 24.0 * params.loop_phase + 1.7 * d); - dz = dz + env(f, wd - 10.0, wd, wd + 28.0, wd + 64.0) * flicker; - // Scanned ember. - dz = dz + 0.08 * smoothstep(wd + 28.0, wd + 64.0, f) * (1.0 - smoothstep(580.0, 640.0, f)); - } - if (is_cause) { - // Cause ignition rides the EXISTING recall response (render-nodes.wgsl): - // spectral() thin-film band + white-hot core + sprite swell at full intensity. - dx = dx + env(f, 520.0, 546.0, 640.0, 700.0); - } - - // WGSL forbids swizzle stores — reconstruct the FULL vec4; pos/vel/color - // lanes pass through untouched (the force sim owns them). - var node = nodes[i]; - node.demo = vec4(dx, dy, dz, dw); - nodes[i] = node; -} -`}const Up=2;class Vp{constructor(t){z(this,"engine");z(this,"nodeRenderer");z(this,"plan");z(this,"pipeline",null);z(this,"bindGroup",null);z(this,"waveBuffer",null);this.engine=t.engine,this.nodeRenderer=t.nodeRenderer,this.plan=t.plan,this.engine.addPass(this)}upload(){var i;const t=this.engine.gpuDevice;if(!t||!this.engine.paramsBuffer||!this.plan.viable||!this.nodeRenderer.nodeStateBuffer||this.nodeRenderer.nodeCountValue===0)return;(i=this.waveBuffer)==null||i.destroy(),this.waveBuffer=t.createBuffer({label:"observatory-rescue-wave",size:Math.max(4,this.plan.waveData.byteLength),usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),t.queue.writeBuffer(this.waveBuffer,0,this.plan.waveData.buffer);const e=t.createShaderModule({label:"observatory-rescue-choreo",code:Np(this.plan.consts)});this.pipeline=t.createComputePipeline({label:"observatory-rescue-choreo",layout:"auto",compute:{module:e,entryPoint:"rescue_choreo"}}),this.bindGroup=t.createBindGroup({label:"observatory-rescue-bind",layout:this.pipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.nodeRenderer.nodeStateBuffer}},{binding:2,resource:{buffer:this.waveBuffer}}]})}compute(t){if(this.engine.params[9]!==Up||!this.pipeline||!this.bindGroup)return;const e=this.nodeRenderer.nodeCountValue;if(e===0)return;const i=t.beginComputePass({label:"observatory-rescue-choreo"});i.setPipeline(this.pipeline),i.setBindGroup(0,this.bindGroup),i.dispatchWorkgroups(Math.ceil(e/64)),i.end()}dispose(){var t;(t=this.waveBuffer)==null||t.destroy(),this.waveBuffer=null,this.pipeline=null,this.bindGroup=null}}const Gp=4,Wp=90,Hp=138,qp=28,Xp=260,Yp=514,Sh=560,Jp=600,oi=65535,Zp=48,$p={causal:0,temporal:1,shared_concepts:2,complementary:3,semantic:4};function Sl(l,t){const e=new ea({seed:t});return wl(l,e.state.rng).data}function jp(l){const t=new Uint32Array(l.nodes.length);for(const e of l.edges)t[e.sourceIndex]++,t[e.targetIndex]++;return t}function Kp(l,t){const e=l.nodes.length;if(e===0)return-1;const i=jp(l),s=r=>{const a=l.nodes[r],o=new Set(a.tags.map(f=>f.toLowerCase()));let h=0;(o.has("failure")||o.has("guardrail"))&&(h+=3),(o.has("confusion")||o.has("weak-spot"))&&(h+=2),h+=Math.min(i[r],8)/8;const c=t[r*Mt+0],u=t[r*Mt+1],d=t[r*Mt+2];return Math.sqrt(c*c+u*u+d*d)>=54&&(h+=.5),h},n=[r=>r!==l.centerIndex&&!l.nodes[r].suppressed&&i[r]>=2,r=>r!==l.centerIndex&&!l.nodes[r].suppressed,r=>r!==l.centerIndex,()=>!0];for(const r of n){let a=-1,o=-1/0;for(let h=0;ho&&(o=c,a=h)}if(a>=0)return a}return-1}function Qp(l,t){const e=l.nodes.length,i=new Uint16Array(e).fill(oi),s=new Int32Array(e).fill(-1);if(t<0||t>=e)return{depths:i,parents:s};const n=Array.from({length:e},()=>[]);for(const a of l.edges){const o=$p[a.type]??5;n[a.sourceIndex].push({nbr:a.targetIndex,rank:o}),n[a.targetIndex].push({nbr:a.sourceIndex,rank:o})}for(const a of n)a.sort((o,h)=>o.rank-h.rank||o.nbr-h.nbr);i[t]=0;const r=[t];for(let a=0;at.nodes[f].retention<=.45);a.length===0&&(a=r);const o=new Map;let h=1/0,c=-1/0;for(const f of a){const p=s.get(t.nodes[f].id),m=p?Date.parse(p):NaN;Number.isFinite(m)&&(o.set(f,m),mc&&(c=m))}const u=f=>{const p=o.get(f);return p===void 0?0:c===h?1:(c-p)/(c-h)},d=f=>2*(1-t.nodes[f].retention)+.5*Math.min(e[f],6)/6+.5*u(f);return a.sort((f,p)=>{const m=d(f),g=d(p);return g!==m?g-m:e[p]!==e[f]?e[p]-e[f]:f-p}),{index:a[0],depth:e[a[0]]}}return{index:-1,depth:0}}function em(l,t,e,i,s){const n=l[e*Mt+0],r=l[e*Mt+1],a=l[e*Mt+2],o=[];for(let h=0;hh.d2-c.d2||h.i-c.i),o.slice(0,Gp).map(h=>h.i)}function ta(l){const t=Math.max(1,l);return Math.min(84,Math.max(14,Math.floor(252/t)))}function im(l,t){return Math.min(Xp+t*l,Yp)}function Ah(l){return Hp+qp*l}function ye(l){return l.length>64?l.slice(0,64)+"…":l}const ps=4;function Wr(l){const t=new Uint32Array(l);return t.fill(oi),{viable:!1,failureIndex:-1,causeIndex:-1,lookalikeIndices:[],hopDepths:new Uint16Array(l).fill(oi),causeDepth:0,hopSlot:ta(3),waveData:t,pathData:new Uint32Array(4),pathMetas:[],spineBeats:[],verdict:{headline:"root cause found",causeLabel:"",failureLabel:"",causeDate:"",hops:0,k:0,receipt:""},consts:{hopSlot:ta(3),causeDepth:3}}}function sm(l,t,e){var L;const i=t.nodes.length;if(i===0)return Wr(0);const s=Sl(t,e),n=Kp(t,s);if(n<0)return Wr(i);const{depths:r,parents:a}=Qp(t,n),o=tm(l,t,r,n);if(o.index<0){const I=Wr(i);return I.failureIndex=n,I.hopDepths=r,I}const h=o.index,c=Math.max(1,o.depth),u=ta(c),d=I=>im(I,u),f=em(s,i,n,h,t.centerIndex),p=f.length,m=new Uint32Array(i);for(let I=0;I{m[I]|=1<<18|U<<19});const g=[];f.forEach((I,U)=>{g.push({src:n,dst:I,bf:Ah(U),kind:ze.probe,beatKind:"probe"})});const x=[];{let I=h;for(;I!==n&&I>=0&&a[I]>=0;)x.push(I),I=a[I]}const y=new Set(x),b=[];for(let I=0;Ic||a[I]<0||b.push(I)}b.sort((I,U)=>r[I]-r[U]||I-U);const v=[...x.slice().reverse(),...b].slice(0,Zp);v.sort((I,U)=>r[I]-r[U]||I-U);for(const I of v)g.push({src:a[I],dst:I,bf:d(r[I]),kind:ze.backwardCause,beatKind:"wave"});g.push({src:h,dst:n,bf:Sh,kind:ze.backwardCause,beatKind:"arc"});const _=new Uint32Array(Math.max(1,g.length)*ps),M=[];g.forEach((I,U)=>{_[U*ps+0]=I.src,_[U*ps+1]=I.dst,_[U*ps+2]=I.bf,_[U*ps+3]=I.kind,M.push({sourceIndex:I.src,targetIndex:I.dst,beatFrame:I.bf,kind:I.kind,beatKind:I.beatKind,nodeId:t.nodes[I.dst].id,label:ye(t.nodes[I.dst].label)})});const A=ye(t.nodes[n].label),S=ye(t.nodes[h].label),T=[],C=(I,U,wt,Ct)=>{T.push({sourceIndex:n,targetIndex:n,beatFrame:I,kind:U,beatKind:"rescue",nodeId:Ct,label:wt})};C(Wp,1,`failure: ${A}`,t.nodes[n].id),f.forEach((I,U)=>{C(Ah(U),0,`lookalike ✗ · ${ye(t.nodes[I].label)}`,t.nodes[I].id)}),C(d(1),1,"reaching backward through time","rescue-wave-start"),c>=2&&d(c)!==d(1)&&C(d(c),1,`scrubbing past · ${c} hops`,"rescue-wave-deep"),C(Sh,1,`causal arc · ${S}`,t.nodes[h].id),C(Jp,1,"root cause found","rescue-verdict");const P=((L=l.nodes.find(I=>I.id===t.nodes[h].id))==null?void 0:L.createdAt)??"",V=P?P.slice(0,10):"",q={headline:"root cause found",causeLabel:S,failureLabel:A,causeDate:V,hops:c,k:p,receipt:`${c} hops back · ${V} · vector search: 0 for ${p}`};return{viable:!0,failureIndex:n,causeIndex:h,lookalikeIndices:f,hopDepths:r,causeDepth:c,hopSlot:u,waveData:m,pathData:_,pathMetas:M,spineBeats:T,verdict:q,consts:{hopSlot:u,causeDepth:c}}}const nm=` -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - capture_mode: f32, - live_kind: f32, - live_frame: f32, - live_energy: f32, - projection_days: f32, -}; - -struct Node { - pos_radius: vec4, - vel_retention: vec4, - color_flags: vec4, - demo: vec4, -}; - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var nodes: array; -// 1 u32/node: bits 0-7 rank, 8 isDrifting, 9 isRescued, 10-11 rescue slot k -// (forgetting-plan.ts packing). Non-drifting nodes are exactly 0. -@group(0) @binding(2) var horizon: array; - -fn env(f: f32, a0: f32, a1: f32, r0: f32, r1: f32) -> f32 { - return smoothstep(a0, a1, f) * (1.0 - smoothstep(r0, r1, f)); -} - -@compute @workgroup_size(64) -fn forgetting_choreo(@builtin(global_invocation_id) id: vec3) { - let i = id.x; - if (i >= u32(params.node_count)) { - return; - } - if (i >= arrayLength(&horizon)) { - return; - } - // Belt-and-braces atop the TS gate: forgetting-horizon is demo index 3. - if (params.demo_id != 3.0) { - return; - } - - let packed = horizon[i]; - let is_drifting = (packed & 0x100u) != 0u; - let is_rescued = (packed & 0x200u) != 0u; - let rank01 = f32(packed & 0xffu) / 255.0; - let k = f32((packed >> 10u) & 0x3u); - - let f = params.frame; - // Master release: every lane is exactly 0.0 by frame 712 — the seam wall. - let master = 1.0 - smoothstep(660.0, 712.0, f); - - var dx = 0.0; - var dz = 0.0; - - if (is_drifting) { - let onset = 90.0 + 42.0 * rank01; - // Phase 1 — the drift: dim + fall to the 0.55 plateau, retention-staggered. - let phase1 = 0.55 * smoothstep(onset, onset + 210.0, f); - if (is_rescued) { - let rk = 318.0 + 60.0 * k; - // Snap-back begins 22 frames before the recall ribbon lands at rk. - dz = master * phase1 * (1.0 - smoothstep(rk - 22.0, rk + 6.0, f)); - // Ignition rides the EXISTING recall response (render-nodes.wgsl): - // spectral() thin-film band + white-hot core + sprite swell for free. - dx = master * env(f, rk - 26.0, rk, rk + 60.0, rk + 130.0); - } else { - // Phase 2 — the sink: to exactly 1.0 over 640..660 (the ~6% floor era). - let phase2 = 0.45 * smoothstep(480.0 + 24.0 * rank01, 640.0, f); - dz = master * (phase1 + phase2); - } - } - - // WGSL forbids swizzle stores — reconstruct the FULL vec4; pos/vel/color - // lanes pass through untouched (the force sim owns them). demo.y and - // demo.w are hard 0.0: the rescue/firewall grammars can never fire here. - var node = nodes[i]; - node.demo = vec4(dx, 0.0, dz, 0.0); - nodes[i] = node; -} -`,rm=3;class am{constructor(t){z(this,"engine");z(this,"nodeRenderer");z(this,"plan");z(this,"pipeline",null);z(this,"bindGroup",null);z(this,"horizonBuffer",null);this.engine=t.engine,this.nodeRenderer=t.nodeRenderer,this.plan=t.plan,this.engine.addPass(this)}upload(){var i;const t=this.engine.gpuDevice;if(!t||!this.engine.paramsBuffer||!this.plan.viable||!this.nodeRenderer.nodeStateBuffer||this.nodeRenderer.nodeCountValue===0)return;(i=this.horizonBuffer)==null||i.destroy(),this.horizonBuffer=t.createBuffer({label:"observatory-forgetting-horizon",size:Math.max(4,this.plan.horizonData.byteLength),usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),t.queue.writeBuffer(this.horizonBuffer,0,this.plan.horizonData.buffer);const e=t.createShaderModule({label:"observatory-forgetting-choreo",code:nm});this.pipeline=t.createComputePipeline({label:"observatory-forgetting-choreo",layout:"auto",compute:{module:e,entryPoint:"forgetting_choreo"}}),this.bindGroup=t.createBindGroup({label:"observatory-forgetting-bind",layout:this.pipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.nodeRenderer.nodeStateBuffer}},{binding:2,resource:{buffer:this.horizonBuffer}}]})}compute(t){if(this.engine.params[9]!==rm||!this.pipeline||!this.bindGroup)return;const e=this.nodeRenderer.nodeCountValue;if(e===0)return;const i=t.beginComputePass({label:"observatory-forgetting-choreo"});i.setPipeline(this.pipeline),i.setBindGroup(0,this.bindGroup),i.dispatchWorkgroups(Math.ceil(e/64)),i.end()}dispose(){var t;(t=this.horizonBuffer)==null||t.destroy(),this.horizonBuffer=null,this.pipeline=null,this.bindGroup=null}}const om=318,hm=60,Al=3,lm=132,cm=60,um=540,dm=660;function fm(l){const t=[];for(let s=0;sl.nodes[s].retention-l.nodes[n].retention||s-n);const e=t.length;if(e===0)return[];const i=Math.min(e,Math.max(Math.min(Al,e),Math.round(.25*e)));return t.slice(0,i)}function pm(l,t){const e=new Uint32Array(l.nodes.length);for(const n of l.edges)e[n.sourceIndex]++,e[n.targetIndex]++;const i=n=>2*l.nodes[n].retention+Math.min(e[n],8)/8;return t.slice().sort((n,r)=>i(r)-i(n)||n-r).slice(0,Math.min(Al,t.length))}function Ih(l){return om+hm*l}const ms=4;function mm(l){return{viable:!1,driftingIndices:[],rescuedIndices:[],horizonData:new Uint32Array(l),pathData:new Uint32Array(4),pathMetas:[],spineBeats:[]}}function gm(l){const t=l.nodes.length,e=fm(l);if(t<2||e.length<1)return mm(t);const i=pm(l,e),s=e.length,n=new Uint32Array(t);e.forEach((d,f)=>{const p=Math.round(255*f/Math.max(1,s-1));n[d]=p&255|256}),i.forEach((d,f)=>{n[d]|=512|f<<10});const r=new Uint32Array(Math.max(1,i.length)*ms),a=[];i.forEach((d,f)=>{const p=Ih(f);r[f*ms+0]=l.centerIndex,r[f*ms+1]=d,r[f*ms+2]=p,r[f*ms+3]=ze.recall,a.push({sourceIndex:l.centerIndex,targetIndex:d,beatFrame:p,kind:ze.recall,beatKind:"recall",nodeId:l.nodes[d].id,label:ye(l.nodes[d].label)})});const o=[],h=(d,f,p,m)=>{o.push({sourceIndex:l.centerIndex,targetIndex:l.centerIndex,beatFrame:d,kind:f,beatKind:"horizon",nodeId:m,label:p})},c=new Set(i),u=e.filter(d=>!c.has(d)).slice(0,3);return u.forEach((d,f)=>{const p=Math.round(l.nodes[d].retention*100);h(lm+cm*f,1,`fading: ${ye(l.nodes[d].label)} · retention ${p}%`,l.nodes[d].id)}),i.forEach((d,f)=>{h(Ih(f),0,`recalled: ${ye(l.nodes[d].label)}`,l.nodes[d].id)}),u.length>0&&h(um,1,"the unrecalled sink · nothing is deleted","horizon-sink"),h(dm,0,"every memory still retrievable","horizon-retrievable"),{viable:!0,driftingIndices:e,rescuedIndices:i,horizonData:n,pathData:r,pathMetas:a,spineBeats:o}}const ym=` -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - capture_mode: f32, - live_kind: f32, - live_frame: f32, - live_energy: f32, - projection_days: f32, -}; - -struct Node { - pos_radius: vec4, - vel_retention: vec4, - color_flags: vec4, - demo: vec4, -}; - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var nodes: array; -// 1 u32/node: bits 0-7 shockDelay, 8 isIntruder, 9 isSeverNeighbor, -// 10-13 sever slot k (firewall-plan.ts packing). Every node carries a delay. -@group(0) @binding(2) var fire: array; - -const TAU: f32 = 6.28318530717958647; - -fn env(f: f32, a0: f32, a1: f32, r0: f32, r1: f32) -> f32 { - return smoothstep(a0, a1, f) * (1.0 - smoothstep(r0, r1, f)); -} - -@compute @workgroup_size(64) -fn firewall_choreo(@builtin(global_invocation_id) id: vec3) { - let i = id.x; - if (i >= u32(params.node_count)) { - return; - } - if (i >= arrayLength(&fire)) { - return; - } - // Fire in TWO modes: the deterministic demo (demo_id == 4, wrapped loop - // frame) OR a LIVE event (live_kind == 1, driven by live_frame = frames - // since a real MemorySuppressed / contradiction fired). Anything else → - // no-op, and other grammars own the lanes. - let is_demo = params.demo_id == 4.0; - let is_live = params.live_kind == 1.0; - if (!is_demo && !is_live) { - return; - } - - let packed = fire[i]; - let delay = f32(packed & 0xffu); - let is_intruder = (packed & 0x100u) != 0u; - let is_sever = (packed & 0x200u) != 0u; - let k = f32((packed >> 10u) & 0xfu); - - // Live mode replays the SAME 720-frame beat map from the event: f = - // live_frame (clamped to the loop window), loop_phase derived from it so the - // integer-cycle sines still resolve. Demo mode reads the wrapped loop clock. - var f = params.frame; - var lp = params.loop_phase; - if (is_live) { - f = clamp(params.live_frame, 0.0, 719.0); - lp = f / 720.0; - } - - var fy = 0.0; - var fw = 0.0; - - if (is_intruder) { - // Intrusion flare: sickly strobe, band (0..1], 36 integer cycles/loop. - // C¹ handoff into the membrane over 330-332 (the rise sweeps the flare - // band exactly once — the condensation read is intentional). - fy = env(f, 90.0, 96.0, 310.0, 332.0) - * (0.55 + 0.45 * sin(TAU * 36.0 * lp)); - // Membrane: sustained ring band [2.60..2.90], 12 integer cycles/loop. - fy = fy + env(f, 330.0, 352.0, 620.0, 680.0) - * (2.75 + 0.15 * sin(TAU * 12.0 * lp)); - // Source detonation as the front leaves. - fw = env(f, 148.0, 153.0, 162.0, 196.0); - } else { - // Crimson rim as the radial front passes: arrival A = 150 + delay, - // amplitude fades with distance; A ∈ [150, 294] ⇒ all rims dead by 320. - let a = 150.0 + delay; - let amp = 0.9 - 0.45 * (delay / 144.0); - fw = amp * env(f, a - 2.0, a + 3.0, a + 8.0, a + 26.0); - if (is_sever) { - // Node-side receipt of the severed edge; last release 474. - let sk = 345.0 + 21.0 * k; - fw = fw + 0.6 * env(f, sk - 4.0, sk, sk + 6.0, sk + 24.0); - } - } - - // WGSL forbids swizzle stores — reconstruct the FULL vec4; pos/vel/color - // lanes pass through untouched (the force sim owns them). demo.x and - // demo.z are hard 0.0: the recall and horizon grammars can never fire here. - var node = nodes[i]; - node.demo = vec4(0.0, fy, 0.0, fw); - nodes[i] = node; -} -`,xm=4;class Il{constructor(t){z(this,"engine");z(this,"nodeRenderer");z(this,"plan");z(this,"pipeline",null);z(this,"bindGroup",null);z(this,"fireBuffer",null);this.engine=t.engine,this.nodeRenderer=t.nodeRenderer,this.plan=t.plan,this.engine.addPass(this)}upload(){var i;const t=this.engine.gpuDevice;if(!t||!this.engine.paramsBuffer||!this.plan.viable||!this.nodeRenderer.nodeStateBuffer||this.nodeRenderer.nodeCountValue===0)return;(i=this.fireBuffer)==null||i.destroy(),this.fireBuffer=t.createBuffer({label:"observatory-firewall-fire",size:Math.max(4,this.plan.fireData.byteLength),usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),t.queue.writeBuffer(this.fireBuffer,0,this.plan.fireData.buffer);const e=t.createShaderModule({label:"observatory-firewall-choreo",code:ym});this.pipeline=t.createComputePipeline({label:"observatory-firewall-choreo",layout:"auto",compute:{module:e,entryPoint:"firewall_choreo"}}),this.bindGroup=t.createBindGroup({label:"observatory-firewall-bind",layout:this.pipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.nodeRenderer.nodeStateBuffer}},{binding:2,resource:{buffer:this.fireBuffer}}]})}rearm(t){if(this.plan=t,!!this.engine.gpuDevice){if(!t.viable){this.pipeline=null,this.bindGroup=null;return}this.upload()}}get armed(){return this.plan.viable&&!!this.pipeline&&!!this.bindGroup}compute(t){const e=this.engine.params[9]===xm,i=this.engine.params[12]===1;if(!e&&!i||!this.pipeline||!this.bindGroup)return;const s=this.nodeRenderer.nodeCountValue;if(s===0)return;const n=t.beginComputePass({label:"observatory-firewall-choreo"});n.setPipeline(this.pipeline),n.setBindGroup(0,this.bindGroup),n.dispatchWorkgroups(Math.ceil(s/64)),n.end()}dispose(){var t;(t=this.fireBuffer)==null||t.destroy(),this.fireBuffer=null,this.pipeline=null,this.bindGroup=null}}const bm=90,vm=150,wm=144,_m=330,Mm=345,Sm=21,Am=6,Im=480,Tm=["failure","guardrail","confusion"];function Cm(l){const t=l.nodes.length;if(t===0)return-1;const e=new Uint32Array(t);for(const n of l.edges)e[n.sourceIndex]++,e[n.targetIndex]++;const i=n=>l.nodes[n].tags.some(r=>Tm.includes(r.toLowerCase())),s=[n=>n!==l.centerIndex&&!l.nodes[n].suppressed&&i(n),n=>n!==l.centerIndex&&!l.nodes[n].suppressed&&e[n]<=1,n=>n!==l.centerIndex&&!l.nodes[n].suppressed,n=>n!==l.centerIndex];for(const n of s){let r=-1;for(let a=0;a=0)return r}return-1}function Bm(l,t,e){const i=l[e*Mt+0],s=l[e*Mt+1],n=l[e*Mt+2],r=new Array(t);let a=0;for(let h=0;ha&&(a=f)}a<1e-6&&(a=1);const o=new Array(t);for(let h=0;hi-s).slice(0,Am)}function Th(l){return Mm+Sm*l}const gs=4;function km(l){return Na(l)}function Na(l){return{viable:!1,intruderIndex:-1,severedNeighborIndices:[],shockDelays:[],fireData:new Uint32Array(l),pathData:new Uint32Array(4),pathMetas:[],spineBeats:[],verdict:{headline:"threat quarantined",intruderLabel:"",receipt:"memory held in review · Memory PR opened"}}}function Pm(l,t){return Tl(l,t,Cm(l))}function Fm(l,t,e){return e<0||e>=l.nodes.length?Na(l.nodes.length):Tl(l,t,e)}function Tl(l,t,e){const i=l.nodes.length;if(i===0||e<0)return Na(i);const s=Sl(l,t),n=Bm(s,i,e),r=zm(l,e),a=new Uint32Array(i);for(let p=0;p{a[p]|=512|m<<10});const o=new Uint32Array(Math.max(1,r.length)*gs),h=[];r.forEach((p,m)=>{const g=Th(m);o[m*gs+0]=e,o[m*gs+1]=p,o[m*gs+2]=g,o[m*gs+3]=ze.probe,h.push({sourceIndex:e,targetIndex:p,beatFrame:g,kind:ze.probe,beatKind:"sever",nodeId:l.nodes[p].id,label:ye(l.nodes[p].label)})});const c=ye(l.nodes[e].label),u=[],d=(p,m,g)=>{u.push({sourceIndex:e,targetIndex:e,beatFrame:p,kind:1,beatKind:"firewall",nodeId:g,label:m})};return d(bm,`intrusion · ${c}`,l.nodes[e].id),d(vm,"immune response · shockwave","firewall-shock"),d(_m,"membrane forming","firewall-membrane"),r.forEach((p,m)=>{d(Th(m),`edge severed ✗ · ${ye(l.nodes[p].label)}`,l.nodes[p].id)}),d(Im,"threat quarantined","firewall-verdict"),{viable:!0,intruderIndex:e,severedNeighborIndices:r,shockDelays:n,fireData:a,pathData:o,pathMetas:h,spineBeats:u,verdict:{headline:"threat quarantined",intruderLabel:c,receipt:"memory held in review · Memory PR opened"}}}const Ua=.1542;function Rm(l=Ua){return Math.pow(.9,-1/l)-1}function Em(l,t,e=Ua){if(!(l>0))return 0;if(!(t>0))return 1;const i=Rm(e),s=Math.pow(1+i*t/l,-e);return s<0?0:s>1?1:s}const Om=864e5;function Dm(l,t,e=0){if(!l)return e>0?e:0;const i=Date.parse(l);if(!Number.isFinite(i))return e>0?e:0;const s=(t-i)/Om;return Math.max(0,s)+Math.max(0,e)}function Lm(l,t,e,i=0,s=Ua){return l===void 0||!Number.isFinite(l)?1:Em(l,Dm(t,e,i),s)}const Ch={[At.firewall]:620,[At.dreamStorm]:360,[At.causalRecall]:260,[At.birth]:180};class Nm{constructor(t){z(this,"engine");z(this,"renderer");z(this,"graph");z(this,"response");z(this,"seed");z(this,"projectionDays");z(this,"onApply");z(this,"onFirewall");z(this,"firewall",null);z(this,"liveEdges",[]);z(this,"liveEdgeKeys",new Set);z(this,"edgesDirty",!1);z(this,"indexById");z(this,"active",null);z(this,"dreamOpen",!1);z(this,"retention");z(this,"hasLiveDecay",!1);z(this,"eventsSeen",0);z(this,"lastDecayFrame",-1e3);z(this,"lastAppliedMs",0);z(this,"seeded",!1);z(this,"lastProj",-1);this.engine=t.engine,this.renderer=t.renderer,this.graph=t.graph,this.response=t.response,this.seed=t.seed,this.projectionDays=t.projectionDays??(()=>0),this.onApply=t.onApply,this.onFirewall=t.onFirewall,this.indexById=t.graph.indexById;const e=t.graph.nodes.length;this.retention=new Float32Array(e);for(let s=0;se&&(e=s)}this.lastAppliedMs=e,this.seeded=!0}ingest(t){if(t.length===0)return;if(!this.seeded){this.seedWatermark(t);return}let e=this.lastAppliedMs;for(let i=t.length-1;i>=0;i--){const s=t[i],n=zh(s);n>this.lastAppliedMs&&(this.decodeAndArm(s,this.engine.totalFrames),n>e&&(e=n))}this.lastAppliedMs=e}decodeAndArm(t,e){var s;const i=t.data??{};switch(t.type){case"MemorySuppressed":{const n=Fi(i.id);if(!n||!this.indexById.has(n))return;this.arm({kind:At.firewall,startFrame:e,targetId:n,relatedIds:this.neighborsOf(n),pairs:[],scalar:ys(i.estimated_cascade)});break}case"DeepReferenceCompleted":{const r=Um(i.contradiction_pairs).filter(([h,c])=>this.indexById.has(h)&&this.indexById.has(c));if(r.length>0){const h=r[0][0];this.arm({kind:At.firewall,startFrame:e,targetId:h,relatedIds:r.flatMap(c=>c).filter(c=>c!==h),pairs:r,scalar:r.length});return}const a=Fi(i.primary_id),o=kh(i.supporting_ids).filter(h=>this.indexById.has(h));a&&this.indexById.has(a)&&this.arm({kind:At.causalRecall,startFrame:e,targetId:a,relatedIds:o,pairs:[],scalar:ys(i.confidence)});break}case"BackfillFired":case"CausalReceipt":{const n=kh(i.path_ids??i.causal_path).filter(a=>this.indexById.has(a)),r=Fi(i.target_id??i.effect_id)||n[0];r&&this.indexById.has(r)&&this.arm({kind:At.causalRecall,startFrame:e,targetId:r,relatedIds:n.filter(a=>a!==r),pairs:[],scalar:n.length});break}case"DreamStarted":{this.dreamOpen=!0,this.arm({kind:At.dreamStorm,startFrame:e,targetId:"",relatedIds:[],pairs:[],scalar:ys(i.memory_count)});break}case"DreamCompleted":{this.dreamOpen=!1;const n=ys(i.connections_found);this.active&&this.active.kind===At.dreamStorm?this.active.scalar=Math.max(this.active.scalar,n):this.arm({kind:At.dreamStorm,startFrame:e,targetId:"",relatedIds:[],pairs:[],scalar:n});break}case"ConnectionDiscovered":{const n=this.indexById.get(Fi(i.source_id)),r=this.indexById.get(Fi(i.target_id));if(n===void 0||r===void 0||n===r)break;const a=Bh(n,r);if(this.liveEdgeKeys.has(a))break;this.liveEdgeKeys.add(a),this.liveEdges.push({sourceIndex:n,targetIndex:r,weight:ys(i.weight)||.5,type:Fi(i.connection_type)||"semantic"}),this.edgesDirty=!0,this.dreamOpen&&((s=this.active)==null?void 0:s.kind)===At.dreamStorm&&(this.active.scalar+=1);break}}}arm(t){var e;if(this.active=t,this.eventsSeen++,t.kind===At.firewall){const i=this.indexById.get(t.targetId);if(i===void 0)return;const s=Fm(this.graph,this.seed,i);if(!s.viable)return;this.firewall||(this.firewall=new Il({engine:this.engine,nodeRenderer:this.renderer,plan:km(this.graph.nodes.length)})),this.firewall.rearm(s),(e=this.onFirewall)==null||e.call(this,{intruderLabel:s.verdict.intruderLabel,startFrame:t.startFrame})}if(t.kind===At.causalRecall&&this.indexById.has(t.targetId)){const i=Ml(this.response,this.graph,8,{preferCausal:!0,centerId:t.targetId});i.steps.length>0&&this.renderer.setPathSteps(i.data,i.steps)}}neighborsOf(t){const e=this.indexById.get(t);if(e===void 0)return[];const i=[];for(const s of this.graph.edges)if(s.sourceIndex===e?i.push(this.graph.nodes[s.targetIndex].id):s.targetIndex===e&&i.push(this.graph.nodes[s.sourceIndex].id),i.length>=12)break;return i}drain(t){var s;const e=this.engine.params;this.edgesDirty&&(this.renderer.setEdges(this.liveEdges),this.edgesDirty=!1);const i=this.projectionDays();if(e[zt.projectionDays]=i,this.hasLiveDecay&&(t-this.lastDecayFrame>=6||i!==this.lastProj)&&(this.recomputeDecay(i),this.lastDecayFrame=t,this.lastProj=i),this.active){const n=Ch[this.active.kind]??300,r=t-this.active.startFrame;r>n+140?(this.active=null,e[zt.liveKind]=At.none,e[zt.liveEnergy]=0):(e[zt.liveKind]=this.active.kind,e[zt.liveFrame]=Math.max(0,r),e[zt.liveEnergy]=this.energyEnvelope(this.active,r,!1))}else e[zt.liveKind]=At.none,e[zt.liveEnergy]=0;(s=this.onApply)==null||s.call(this,{simFrame:t,activeKind:e[zt.liveKind],eventsSeen:this.eventsSeen})}debugState(){const t=this.engine.params;return{activeKind:t[zt.liveKind],liveEnergy:t[zt.liveEnergy],liveFrame:t[zt.liveFrame],edgeCount:this.liveEdges.length,eventsSeen:this.eventsSeen}}energyEnvelope(t,e,i){if(e<0)return 0;const s=Ch[t.kind]??300;if(t.kind===At.dreamStorm){const a=Math.min(1,e/45),o=1-Math.max(0,(e-(s-90))/90),h=Math.min(1.4,.7+t.scalar*.02);return Math.max(0,a*Math.min(1,o)*h)}const n=Math.min(1,e/24),r=1-Math.max(0,(e-s)/140);return Math.max(0,n*Math.min(1,r))}recomputeDecay(t){const e=this.engine.wallNowMs,i=this.graph.nodes;for(let s=0;stypeof t=="string"):[]}function Um(l){if(!Array.isArray(l))return[];const t=[];for(const e of l)Array.isArray(e)&&e.length>=2&&typeof e[0]=="string"&&typeof e[1]=="string"&&t.push([e[0],e[1]]);return t}var Vm=vt(`
⬤ threat quarantined
memory held in review · Memory PR opened
`),Gm=vt(``),Wm=vt(''),Hm=vt(`
Forgetting horizon
`),qm=vt(``),Xm=vt(""),Ym=vt('
'),Jm=vt('
LOADING MEMORY FIELD...
'),Zm=vt('
'),$m=vt('
NO MEMORIES IN FIELD
'),jm=vt('
'),Km=vt("
");function mx(l,t){Wn(t,!0);const e=()=>jl(tc,"$eventFeed",i),[i,s]=Kl();let n=ut(t,"seed",3,"vestige-observatory-v1"),r=ut(t,"freezeFrame",3,null),a=ut(t,"capture",3,!1),o=ut(t,"showSwitcher",3,!0),h=ut(t,"embedded",3,!1),c=ut(t,"chrome",3,"full"),u=ut(t,"live",3,!1),d=xt(0),f=null,p=xt(!1),m=xt(!1),g=xt(!1);function x(){if(typeof window>"u")return;const O=window.matchMedia("(prefers-reduced-motion: reduce)");O.matches&&!F(g)&&rt(m,!0);const K=lt=>{F(g)||rt(m,lt.matches,!0)};return O.addEventListener("change",K),()=>O.removeEventListener("change",K)}function y(){rt(g,!0),rt(m,!F(m))}ji(()=>{var O;(O=F(tt))==null||O.setPaused(F(m))});let b=xt(""),v=xt(0),_=Bn(()=>F(b)!==""&&F(v)>0),M=xt(null);async function A(O){if(!t.onpick||!J||!F(M))return;const K=F(M).getBoundingClientRect();if(K.width===0||K.height===0)return;const lt=(O.clientX-K.left)/K.width*2-1,ie=-((O.clientY-K.top)/K.height*2-1),$=await J.pickAt(lt,ie);$&&t.onpick($.id)}const S={"recall-path":"RECALL","engram-birth":"BIRTH","salience-rescue":"RESCUE","forgetting-horizon":"HORIZON",firewall:"FIREWALL"};let T=xt(!a());function C(O){(O.key==="h"||O.key==="H")&&rt(T,!F(T)),O.key==="Escape"&&t.onexit&&t.onexit()}let P=xt(null),V=xt(!0),q=xt(""),L=xt(0),I=xt(0),U=xt(0),wt=xt(0),Ct=xt(""),tt=xt(null),J=null,ht=null,Ut=null,oe=xt(null),di=null,Ye=null,Ee=xt(null),Yt=!1,he=xt(Gl([]));async function Qn(){rt(V,!0),rt(q,"");try{const O=await Ql.graph({max_nodes:200,depth:3,sort:"connected"});rt(P,O,!0),rt(U,O.nodeCount,!0),rt(wt,O.edgeCount,!0),rt(Ct,O.center_id,!0)}catch(O){rt(q,O instanceof Error?O.message:"Failed to load graph data",!0)}finally{rt(V,!1)}}function le(O,K){rt(L,O,!0),rt(I,K,!0)}function ce(O){var K;Yt=!1,rt(tt,O,!0),J=new _p(O),(K=t.onready)==null||K.call(t,O)}ji(()=>{if(F(tt)&&J&&F(P)&&!Yt){Yt=!0;const O=t.demo==="engram-birth",K=t.demo==="salience-rescue",lt=t.demo==="forgetting-horizon",ie=t.demo==="firewall";if(J.upload(F(P),n(),{recallPath:!O&&!K&&!lt&&!ie}),O){ht=new Lp({engine:F(tt),nodeRenderer:J,seed:n()}),ht.upload(n());const $=ht.engraveSteps,Vt=[];for(let Bt=0;Bt<$.length/4;Bt++)Vt.push({sourceIndex:$[Bt*4],targetIndex:$[Bt*4+1],beatFrame:$[Bt*4+2],kind:$[Bt*4+3],beatKind:"engrave",nodeId:`engrave-${Bt}`,label:"edge engraved"});J.setPathSteps($,Vt),rt(he,ht.timeline.map((Bt,fi)=>({sourceIndex:0,targetIndex:0,beatFrame:Bt.startFrame,kind:0,beatKind:"birth",nodeId:`birth-${fi}`,label:Bt.label})),!0)}else if(K){const $=sm(F(P),J.graph,n());rt(oe,$,!0),$.viable&&(Ut=new Vp({engine:F(tt),nodeRenderer:J,plan:$}),Ut.upload(),J.setPathSteps($.pathData,$.pathMetas)),rt(he,$.spineBeats,!0)}else if(lt){const $=gm(J.graph);$.viable&&(di=new am({engine:F(tt),nodeRenderer:J,plan:$}),di.upload(),J.setPathSteps($.pathData,$.pathMetas)),rt(he,$.spineBeats,!0)}else if(ie){const $=Pm(J.graph,n());rt(Ee,$,!0),$.viable&&(Ye=new Il({engine:F(tt),nodeRenderer:J,plan:$}),Ye.upload(),J.setPathSteps($.pathData,$.pathMetas)),rt(he,$.spineBeats,!0)}else rt(he,J.pathSteps,!0);u()&&J.graph&&F(P)&&(f=new Nm({engine:F(tt),renderer:J,graph:J.graph,response:F(P),seed:n(),projectionDays:()=>F(d),onFirewall:$=>{rt(b,$.intruderLabel,!0),rt(v,Date.now(),!0)}}),rt(p,f.liveDecayAvailable,!0),F(tt).setPreFrameHook($=>f==null?void 0:f.drain($)),typeof window<"u"&&(window.__vestigeLiveBridge=f)),F(tt).demoClock.reset()}}),ji(()=>{const O=e();f&&f.ingest(O)}),ji(()=>{F(d),f==null||f.refreshDecay()}),ji(()=>{if(!F(v))return;const O=setTimeout(()=>{rt(b,""),rt(v,0)},7e3);return()=>clearTimeout(O)}),Xl(()=>(Qn(),x()));var k=Km();Yl("keydown",Wl,C);let E;var R=ot(k);let W;var N=ot(R);sc(N,{get demo(){return t.demo},get seed(){return n()},get freezeFrame(){return r()},onframe:le,onready:ce}),at(R),Jl(R,O=>rt(M,O),()=>F(M));var et=ct(R,2);{var nt=O=>{var K=jm(),lt=ot(K);{var ie=H=>{var Q=Vm(),Tt=ct(ot(Q),2),Rt=ot(Tt,!0);at(Tt),Hl(2),at(Q),jt(()=>Ot(Rt,F(b))),mt(H,Q)};_t(lt,H=>{u()&&F(_)&&H(ie)})}var $=ct(lt,2);{var Vt=H=>{var Q=Gm(),Tt=ot(Q,!0);at(Q),jt(()=>{Cn(Q,"title",F(m)?"Resume field motion":"Pause field motion (event pulses stay live)"),Cn(Q,"aria-pressed",F(m)),Ot(Tt,F(m)?"▶ RESUME":"❚❚ PAUSE")}),Ri("click",Q,y),mt(H,Q)};_t($,H=>{u()&&H(Vt)})}var Bt=ct($,2);{var fi=H=>{var Q=Hm(),Tt=ct(ot(Q),2);Zl(Tt);var Rt=ct(Tt,2),Oe=ot(Rt,!0);at(Rt);var er=ct(Rt,2);{var Os=$i=>{var Xa=Wm();Ri("click",Xa,()=>rt(d,0)),mt($i,Xa)};_t(er,$i=>{F(d)!==0&&$i(Os)})}at(Q),jt(()=>Ot(Oe,F(d)===0?"now":`+${F(d)}d`)),$l(Tt,()=>F(d),$i=>rt(d,$i)),mt(H,Q)};_t(Bt,H=>{u()&&F(p)&&H(fi)})}var Ji=ct(Bt,2);{var tr=H=>{cp(H,{get demoMode(){return t.demo},get seed(){return n()},get nodeCount(){return F(U)},get edgeCount(){return F(wt)},get centerId(){return F(Ct)},get frameCount(){return F(L)},get fpsEstimate(){return F(I)},get freezeFrame(){return r()},get loading(){return F(V)},get error(){return F(q)}})};_t(Ji,H=>{c()==="full"&&H(tr)})}var Rs=ct(Ji,2);{var Es=H=>{var Q=qm();Ri("click",Q,function(...Tt){var Rt;(Rt=t.onexit)==null||Rt.apply(this,Tt)}),mt(H,Q)};_t(Rs,H=>{c()==="full"&&t.onexit&&H(Es)})}var Zi=ct(Rs,2);{var Cl=H=>{var Q=Ym();Eh(Q,20,()=>nc,Tt=>Tt,(Tt,Rt)=>{var Oe=Xm(),er=ot(Oe,!0);at(Oe),jt(()=>{vs(Oe,1,`font-mono text-[11px] tracking-widest text-left rounded px-3 py-1.5 border transition-colors - ${Rt===t.demo?"text-[#05060a] bg-[#5dcaa5] border-[#5dcaa5]":"text-[#5dcaa5]/60 hover:text-[#5dcaa5] bg-[#05060a]/70 border-[#5dcaa5]/20 hover:border-[#5dcaa5]/50"}`),Cn(Oe,"title",`Play the ${S[Rt]??""} moment`),Ot(er,S[Rt])}),Ri("click",Oe,()=>{var Os;return(Os=t.ondemochange)==null?void 0:Os.call(t,Rt)}),mt(Tt,Oe)}),at(Q),mt(H,Q)};_t(Zi,H=>{c()==="full"&&o()&&H(Cl)})}var Va=ct(Zi,2);{var Bl=H=>{var Q=Jm();mt(H,Q)};_t(Va,H=>{F(V)&&H(Bl)})}var Ga=ct(Va,2);{var zl=H=>{var Q=Zm(),Tt=ot(Q),Rt=ot(Tt,!0);at(Tt),at(Q),jt(()=>Ot(Rt,F(q))),mt(H,Q)};_t(Ga,H=>{F(q)&&!F(V)&&H(zl)})}var Wa=ct(Ga,2);{var kl=H=>{pp(H,{get steps(){return F(he)},get frame(){return F(L)}})};_t(Wa,H=>{c()==="full"&&H(kl)})}var Ha=ct(Wa,2);{var Pl=H=>{xh(H,{get frame(){return F(L)},get verdict(){return F(oe).verdict}})};_t(Ha,H=>{var Q;c()==="full"&&t.demo==="salience-rescue"&&((Q=F(oe))!=null&&Q.viable)&&H(Pl)})}var qa=ct(Ha,2);{var Fl=H=>{{let Q=Bn(()=>({headline:F(Ee).verdict.headline,causeLabel:F(Ee).verdict.intruderLabel,receipt:F(Ee).verdict.receipt}));xh(H,{get frame(){return F(L)},tone:"quarantine",fadeWindow:[480,495,605,620],get verdict(){return F(Q)}})}};_t(qa,H=>{var Q;c()==="full"&&t.demo==="firewall"&&((Q=F(Ee))!=null&&Q.viable)&&H(Fl)})}var Rl=ct(qa,2);{var El=H=>{var Q=$m();mt(H,Q)};_t(Rl,H=>{!F(V)&&F(P)&&F(P).nodeCount===0&&H(El)})}at(K),mt(O,K)};_t(et,O=>{F(T)&&O(nt)})}at(k),jt(()=>{E=vs(k,1,`${h()?"absolute":"fixed"} inset-0 overflow-hidden bg-[#05060a]`,null,E,{"cursor-none":a()}),W=vs(R,1,"absolute inset-0 z-0",null,W,{"cursor-crosshair":!!t.onpick&&!a()})}),Ri("click",R,A),mt(l,k),Hn(),s()}Rh(["click"]);export{fl as $,Dh as A,Lh as B,G as C,qg as D,Xe as E,my as F,Kh as G,vc as H,ma as I,ee as J,qe as K,lf as L,ey as M,ac as N,Nt as O,jh as P,Za as Q,ha as R,Pn as S,Oa as T,ra as U,w as V,Fn as W,zy as X,Hi as Y,_g as Z,qt as _,be as a,pe as a$,re as a0,Xn as a1,yt as a2,My as a3,sg as a4,io as a5,Z as a6,Wh as a7,sa as a8,xe as a9,T0 as aA,sy as aB,Mf as aC,Af as aD,Tf as aE,If as aF,bf as aG,Bf as aH,ng as aI,rg as aJ,ag as aK,og as aL,lg as aM,cg as aN,M0 as aO,cc as aP,uc as aQ,Fs as aR,eo as aS,sr as aT,Mc as aU,Nh as aV,iy as aW,Yr as aX,ge as aY,Xr as aZ,fc as a_,Lg as aa,I0 as ab,Bc as ac,Kd as ad,_s as ae,ft as af,vy as ag,ig as ah,eg as ai,ia as aj,Hh as ak,Gi as al,xy as am,td as an,Qu as ao,dc as ap,j as aq,As as ar,D as as,st as at,pg as au,Pi as av,ne as aw,S0 as ax,$h as ay,qr as az,B as b,qc as b$,Gg as b0,Vg as b1,Wg as b2,Ng as b3,Ug as b4,Hg as b5,Dg as b6,P0 as b7,k0 as b8,$a as b9,wc as bA,_c as bB,Sc as bC,gc as bD,yc as bE,xc as bF,Ac as bG,Ic as bH,Tc as bI,Cc as bJ,Uh as bK,Vh as bL,zc as bM,kc as bN,Pc as bO,Fc as bP,Rc as bQ,Ec as bR,Oc as bS,Dc as bT,Lc as bU,Nc as bV,Uc as bW,Vc as bX,Gc as bY,Wc as bZ,Hc as b_,U0 as ba,G0 as bb,Ka as bc,L0 as bd,N0 as be,V0 as bf,W0 as bg,ja as bh,D0 as bi,O0 as bj,E0 as bk,b0 as bl,v0 as bm,w0 as bn,z0 as bo,B0 as bp,C0 as bq,oc as br,tg as bs,Q0 as bt,K0 as bu,j0 as bv,Qa as bw,$0 as bx,Z0 as by,J0 as bz,Wi as c,nx as c$,Xc as c0,Yc as c1,Jc as c2,Zc as c3,$c as c4,jc as c5,Kc as c6,Qc as c7,tu as c8,eu as c9,F0 as cA,da as cB,mg as cC,Gh as cD,Yf as cE,Vn as cF,Ay as cG,Ny as cH,Ly as cI,Sy as cJ,xd as cK,Ry as cL,ox as cM,to as cN,Ef as cO,Dy as cP,pl as cQ,Ey as cR,Py as cS,hx as cT,fu as cU,md as cV,Zh as cW,Xi as cX,Jy as cY,Ht as cZ,rx as c_,iu as ca,su as cb,au as cc,ou as cd,hu as ce,lu as cf,Pe as cg,Xu as ch,qu as ci,Eg as cj,Rg as ck,Og as cl,Pg as cm,Fg as cn,kg as co,no as cp,zg as cq,Cg as cr,Tg as cs,Ig as ct,Ag as cu,Bg as cv,Sg as cw,Mg as cx,pi as cy,R0 as cz,$t as d,ed as d$,kf as d0,He as d1,ua as d2,sx as d3,Qh as d4,va as d5,bd as d6,wa as d7,Ff as d8,ul as d9,Ma as dA,jg as dB,Jg as dC,zd as dD,xa as dE,Sa as dF,pa as dG,fa as dH,Hy as dI,Qg as dJ,ty as dK,tx as dL,Qy as dM,Aa as dN,ky as dO,Gn as dP,Fu as dQ,zf as dR,ad as dS,fy as dT,py as dU,cy as dV,jn as dW,zn as dX,Jr as dY,nr as dZ,we as d_,wy as da,_y as db,ya as dc,Iy as dd,_a as de,X0 as df,H0 as dg,cx as dh,Ty as di,tl as dj,Td as dk,df as dl,_0 as dm,ve as dn,Bd as dp,hg as dq,Ps as dr,Yy as ds,qh as dt,Cy as du,ly as dv,yf as dw,hc as dx,ix as dy,ff as dz,rr as e,Li as e$,Jn as e0,Xh as e1,ui as e2,hi as e3,Zy as e4,el as e5,Cd as e6,gd as e7,Re as e8,cl as e9,Oy as eA,it as eB,Df as eC,il as eD,sl as eE,te as eF,Kn as eG,pf as eH,bg as eI,vg as eJ,nu as eK,ru as eL,wg as eM,Qd as eN,ks as eO,qy as eP,Uy as eQ,Vy as eR,Ta as eS,ca as eT,Vi as eU,Ca as eV,lx as eW,Fe as eX,ga as eY,jy as eZ,sd as e_,fg as ea,so as eb,jo as ec,dl as ed,cu as ee,du as ef,uu as eg,y0 as eh,gl as ei,af as ej,of as ek,dg as el,ug as em,aa as en,Nn as eo,$n as ep,Y0 as eq,q0 as er,A0 as es,Ln as et,Ia as eu,ax as ev,Ky as ew,yd as ex,ex as ey,ci as ez,na as f,Lt as f0,Xy as f1,Cf as f2,nl as f3,$y as f4,bs as f5,$g as f6,Yg as f7,Fy as f8,Kg as f9,Oi as fA,g0 as fB,mx as fC,ry as fD,ay as fE,ny as fF,Is as fG,yy as fH,gy as fI,Yn as fJ,tp as fK,zu as fL,Zu as fM,Rn as fN,ip as fO,px as fP,dx as fQ,bl as fR,np as fS,In as fT,Gr as fU,rp as fV,fx as fW,Vr as fX,Xg as fa,Zg as fb,Yi as fc,x0 as fd,Ba as fe,By as ff,ux as fg,za as fh,ka as fi,Kt as fj,xg as fk,yg as fl,gg as fm,Pa as fn,uy as fo,dy as fp,ml as fq,Gy as fr,Un as fs,by as ft,hy as fu,oy as fv,la as fw,jd as fx,kn as fy,Ei as fz,lc as g,Be as h,wf as i,Wy as j,Ts as k,Xt as l,qi as m,rf as n,hf as o,nf as p,ef as q,tf as r,Fa as s,sf as t,ae as u,mc as v,pc as w,qn as x,It as y,bc as z}; diff --git a/apps/dashboard/build/_app/immutable/chunks/Bo4EDkTQ.js.br b/apps/dashboard/build/_app/immutable/chunks/Bo4EDkTQ.js.br deleted file mode 100644 index f9e5bd9..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/Bo4EDkTQ.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/Bo4EDkTQ.js.gz b/apps/dashboard/build/_app/immutable/chunks/Bo4EDkTQ.js.gz deleted file mode 100644 index 402260e..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/Bo4EDkTQ.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/BpEKQwpr.js b/apps/dashboard/build/_app/immutable/chunks/BpEKQwpr.js deleted file mode 100644 index e95f02b..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/BpEKQwpr.js +++ /dev/null @@ -1 +0,0 @@ -var Ee=Object.defineProperty;var Ae=(d,e,s)=>e in d?Ee(d,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):d[e]=s;var N=(d,e,s)=>Ae(d,typeof e!="symbol"?e+"":e,s);import"./Bzak7iHL.js";import{d as be,o as Q,b as $,e as Ne}from"./DAau0uzT.js";import{p as Re,j as ee,g as n,y as _e,Y as ke,a as Se,b as Ce,u as Ie,d as R,f as Me,s as p,c as Pe,r as we}from"./CGq8RnJq.js";import{s as Oe}from"./uCQU803Y.js";import{b as Le}from"./Ccqjq5DS.js";import{p as _,s as He,a as Ve}from"./DV6OI5iy.js";import{g as Fe}from"./DJDK-KWF.js";import{b as T}from"./DY7cP31Q.js";import{p as De}from"./CbBCXwzm.js";import{r as m,C as re,R as S,M as Te,I as te,O as ze}from"./BMB5u1EX.js";import{T as ne}from"./D7ozXiSB.js";const Ue=[{href:"/observatory",label:"Observatory",shortcut:"O"},{href:"/graph",label:"Graph",shortcut:"G"},{href:"/memories",label:"Memories",shortcut:"M"},{href:"/timeline",label:"Timeline",shortcut:"T"},{href:"/feed",label:"Feed",shortcut:"F"},{href:"/explore",label:"Explore",shortcut:"E"},{href:"/reasoning",label:"Reasoning",shortcut:"R"},{href:"/stats",label:"Stats",shortcut:"S"},{href:"/settings",label:"Settings",shortcut:","}],M=-.93,P=.83,z=.024,U=.058,Ge=-.965,Xe=-.9,Ye=-.4,We=.92,Be=-.73,Ke=-.44,Ze=.96,G=[...m(re.forward),1],je=[...m(S.luciferin),1],qe=[...m(S.bridge),.36],Je=[...m(S.bridge),.36],Qe=[...m(Te.blackwater),.15];function $e(d,e={}){return new et(d,e)}class et{constructor(e,s){N(this,"text");N(this,"routes");N(this,"activePath");N(this,"hoverHref",null);N(this,"expanded",!1);N(this,"ready",!1);this.text=new ne(e),this.routes=s.routes??Ue,this.activePath=s.activePath??""}async init(){await this.text.init(),this.ready=!0,this.rebuild()}setActivePath(e){this.activePath!==e&&(this.activePath=e,this.rebuild())}setHoverFromNdc(e,s){const l=e<=Xe&&s>=Ye&&s<=We,u=e<=Be&&s>=Ke&&s<=Ze,A=this.expanded?u:l;A!==this.expanded&&(this.expanded=A,A||(this.hoverHref=null),this.rebuild());const x=this.pickAt(e,s),k=(x==null?void 0:x.payload.href)??null;return k!==this.hoverHref&&(this.hoverHref=k,this.rebuild()),x}clearHover(){!this.expanded&&this.hoverHref===null||(this.expanded=!1,this.hoverHref=null,this.rebuild())}pickAt(e,s){const l=this.text.pickAt(e,s);if(!l||l.kind!=="route-nav")return null;const u=l.payload;return u.route?{id:l.id,kind:"route-nav",payload:u.route}:null}render(e){this.text.render(e)}dispose(){this.text.dispose()}rebuild(){this.ready&&this.text.setText(this.expanded?this.buildExpanded():this.buildCollapsed())}buildCollapsed(){return this.routes.map((e,s)=>{const l=this.isActive(e.href),u=e.shortcut??e.label.charAt(0).toUpperCase();return{id:`route-nav-marker:${e.href}`,kind:"route-nav-marker",text:u,x:Ge,y:P-s*U,size:z,color:l?G:Je,startFrame:0,revealSpan:1,maxWidthEm:4}})}buildExpanded(){return[{id:"route-nav:rail",kind:"route-nav-rail",text:"COGNITIVE OS",x:M,y:P+.075,size:.021,color:Qe,revealSpan:1},...this.routes.map((e,s)=>{const l=this.isActive(e.href),u=this.hoverHref===e.href,A=l?G:u?je:qe,x=l?">":u?"+":"-",k=e.shortcut?` ${e.shortcut}`:"";return{id:`route-nav:${e.href}`,kind:"route-nav",text:`${x} ${e.label.toUpperCase()}${k}`,x:l||u?M+.012:M,y:P-s*U,size:l||u?z*1.06:z,color:A,startFrame:0,revealSpan:1,maxWidthEm:16,hitPadX:.03,hitPadY:.02,route:e}}),...this.hoverHref?[{id:"route-nav:hover-ring",kind:"route-nav-focus",text:">>>>>>>>>>>>>>>>",x:M-.01,y:P-this.routes.findIndex(e=>e.href===this.hoverHref)*U-.029,size:.012,color:G,revealSpan:1}]:[]]}isActive(e){const s=this.activePath||"";return s===e||s.endsWith(e)||e==="/observatory"&&(s==="/"||s==="")}}function tt(d){return{organ:d,nodes:[],edges:[],events:[],receipts:[],scalars:{},alive:!1}}var rt=Me("
");function mt(d,e){Re(e,!0);const s=()=>Ve(De,"$page",l),[l,u]=He();let A=_(e,"seed",3,"vestige-route-organ-v1"),x=_(e,"scene",3,null),k=_(e,"embedded",3,!1),se=_(e,"demo",3,"recall-path"),ie=_(e,"loading",3,!1),X=_(e,"error",3,null),ae=_(e,"emptyLabel",3,"NO ROUTE DATA IN FIELD"),C=Ie(()=>x()??tt(e.organ)),f=R(null),v=R(null),i=null,o=null,y=[],w=R(0),O=R(0),b=R(!1),L=R(!1),H=R(!1),V=null,F=null;const oe=[...m(re.forward),1],Y=[...m(S.recall),.58],le=[...m(S.luciferin),.86],W=[...m(te.veto),.9],ue=[...m(te.caution),.78];function ce(){if(typeof window>"u")return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");t.matches&&!n(L)&&p(b,!0);const r=a=>{n(L)||p(b,a.matches,!0)};return t.addEventListener("change",r),()=>t.removeEventListener("change",r)}function de(){p(L,!0),p(b,!n(b)),I()}ee(()=>{var t;(t=n(v))==null||t.setPaused(n(b)),I()});function B(t){var r;if(n(v)){for(const a of y)(r=a.uploadScene)==null||r.call(a,t);n(v).demoClock.reset(),I()}}function he(t,r){p(w,t,!0),p(O,r,!0),o==null||o.setActivePath(K()),I(t,r)}async function fe(t){var r;p(H,!1),p(v,t,!0);for(const a of y)(r=a.dispose)==null||r.call(a);i==null||i.dispose(),o==null||o.dispose(),y=typeof e.passes=="function"?e.passes(t,n(C)):e.passes??[];for(const a of y)t.addPass(a);o=$e(t,{activePath:K()}),i=new ne(t),t.addPass(o),t.addPass(i),await Promise.all([o.init(),i.init()]),n(v)===t&&(p(H,!0),B(n(C)))}ee(()=>{const t=n(C);!n(v)||!n(H)||_e(()=>B(t))});function K(){const t=s().url.pathname;return t.startsWith(T)?t.slice(T.length)||"/":t}function Z(t){return t.replace(/[—–]/g,"-").replace(/[‘’]/g,"'").replace(/[“”]/g,'"').replace(/…/g,"...").replace(/[^\x20-\x7E]/g,"?")}function pe(t=n(w),r=n(O)){const a=[{id:"route-chrome:pause",kind:"route-chrome",text:n(b)?"> RESUME":"|| PAUSE",x:.66,y:-.86,size:.034,color:n(b)?ue:oe,revealSpan:1},{id:"route-chrome:telemetry",kind:"route-telemetry",text:`${e.organ.toUpperCase()} - ${t}F - ${r}FPS`,x:.44,y:.88,size:.022,color:Y,revealSpan:1}];return ie()?a.push({id:"route-chrome:loading",kind:"route-status",text:"REPLAYING COGNITIVE RECEIPT...",x:-.23,y:.02,size:.046,color:le,startFrame:Math.max(0,t-90),revealSpan:72}):X()?a.push({id:"route-chrome:error-pulse",kind:"route-status-pulse",text:"!!!!!!!!!!!!!!!!!!!!!!!!",x:-.36,y:-.035,size:.025,color:W,revealSpan:1},{id:"route-chrome:error",kind:"route-status",text:Z(`ERROR - ${X()}`).slice(0,72),x:-.54,y:.025,size:.032,color:W,revealSpan:14,maxWidthEm:48}):n(C).alive||a.push({id:"route-chrome:empty",kind:"route-status",text:Z(ae()),x:-.36,y:.02,size:.034,color:Y,revealSpan:24,maxWidthEm:48}),a}function I(t=n(w),r=n(O)){i==null||i.setText(pe(t,r))}function j(t){if(!n(f))return null;const r=n(f).getBoundingClientRect();return r.width===0||r.height===0?null:{x:(t.clientX-r.left)/r.width*2-1,y:-((t.clientY-r.top)/r.height*2-1)}}function me(t){if(!n(f)||!n(v))return;const r=n(f).getBoundingClientRect();if(r.width===0||r.height===0)return;const a=Math.max(1e-4,r.width/Math.max(1,r.height)),h={x:t.x*Math.max(a,1),y:t.y/Math.min(a,1)},c=V??h,E={x:c.x+(h.x-c.x)*.35,y:c.y+(h.y-c.y)*.35};V=E,n(v).setCursorPreNdc(E.x,E.y,E.x-c.x,E.y-c.y)}function ve(t){const r=j(t);if(!r)return;me(r);const a=o==null?void 0:o.setHoverFromNdc(r.x,r.y),h=i==null?void 0:i.pickAt(r.x,r.y),c=(h==null?void 0:h.id)??null;c!==F&&(F=c,i==null||i.setRunDepth(c,1)),n(f)&&(n(f).style.cursor=a||h||e.onpick?"crosshair":"default")}function xe(){var t;o==null||o.clearHover(),F=null,i==null||i.setRunDepth(null),V=null,(t=n(v))==null||t.setCursorPreNdc(999,999,0,0),n(f)&&(n(f).style.cursor="default")}async function ye(t){var c,E,q;const r=j(t);if(!r)return;const a=(o==null?void 0:o.pickAt(r.x,r.y))??null;if(a){await Fe(`${T}${a.payload.href}`);return}const h=i==null?void 0:i.pickAt(r.x,r.y);if((h==null?void 0:h.id)==="route-chrome:pause"){de();return}for(let D=y.length-1;D>=0;D--){const J=await((E=(c=y[D]).pickAt)==null?void 0:E.call(c,r.x,r.y));if(J){(q=e.onpick)==null||q.call(e,J);return}}}Q(()=>()=>{var t;for(const r of y)(t=r.dispose)==null||t.call(r);i==null||i.dispose(),o==null||o.dispose(),y=[],i=null,o=null}),Q(()=>ce());var g=rt(),ge=Pe(g);ze(ge,{get demo(){return se()},get seed(){return A()},onframe:he,onready:fe}),we(g),Le(g,t=>p(f,t),()=>n(f)),ke(()=>Oe(g,1,`${k()?"absolute":"fixed"} inset-0 overflow-hidden`)),$("click",g,ye),$("pointermove",g,ve),Ne("pointerleave",g,xe),Se(d,g),Ce(),u()}be(["click","pointermove"]);export{mt as R,tt as e}; diff --git a/apps/dashboard/build/_app/immutable/chunks/BpEKQwpr.js.br b/apps/dashboard/build/_app/immutable/chunks/BpEKQwpr.js.br deleted file mode 100644 index 3d71e58..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/BpEKQwpr.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/BpEKQwpr.js.gz b/apps/dashboard/build/_app/immutable/chunks/BpEKQwpr.js.gz deleted file mode 100644 index 57899bc..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/BpEKQwpr.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/Bzak7iHL.js b/apps/dashboard/build/_app/immutable/chunks/Bzak7iHL.js deleted file mode 100644 index e8f20e7..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/Bzak7iHL.js +++ /dev/null @@ -1 +0,0 @@ -var e;typeof window<"u"&&((e=window.__svelte??(window.__svelte={})).v??(e.v=new Set)).add("5"); diff --git a/apps/dashboard/build/_app/immutable/chunks/Bzak7iHL.js.br b/apps/dashboard/build/_app/immutable/chunks/Bzak7iHL.js.br deleted file mode 100644 index a630794..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/Bzak7iHL.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/Bzak7iHL.js.gz b/apps/dashboard/build/_app/immutable/chunks/Bzak7iHL.js.gz deleted file mode 100644 index f429ed1..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/Bzak7iHL.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/BzfFPM53.js b/apps/dashboard/build/_app/immutable/chunks/BzfFPM53.js deleted file mode 100644 index 0f06a3e..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/BzfFPM53.js +++ /dev/null @@ -1 +0,0 @@ -import{l as s,m as v,h as o,t as c,n as b,o as m,q as h,v as q}from"./CGq8RnJq.js";function _(e,r,l=!1){if(e.multiple){if(r==null)return;if(!b(r))return m();for(var a of e.options)a.selected=r.includes(i(a));return}for(a of e.options){var t=i(a);if(h(t,r)){a.selected=!0;return}}(!l||r!==void 0)&&(e.selectedIndex=-1)}function y(e){var r=new MutationObserver(()=>{_(e,e.__value)});r.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),c(()=>{r.disconnect()})}function p(e,r,l=r){var a=new WeakSet,t=!0;s(e,"change",u=>{var f=u?"[selected]":":checked",n;if(e.multiple)n=[].map.call(e.querySelectorAll(f),i);else{var d=e.querySelector(f)??e.querySelector("option:not([disabled])");n=d&&i(d)}l(n),v!==null&&a.add(v)}),o(()=>{var u=r();if(e===document.activeElement){var f=q??v;if(a.has(f))return}if(_(e,u,t),t&&u===void 0){var n=e.querySelector(":checked");n!==null&&(u=i(n),l(u))}e.__value=u,t=!1}),y(e)}function i(e){return"__value"in e?e.__value:e.value}export{p as b}; diff --git a/apps/dashboard/build/_app/immutable/chunks/BzfFPM53.js.br b/apps/dashboard/build/_app/immutable/chunks/BzfFPM53.js.br deleted file mode 100644 index 38b158d..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/BzfFPM53.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/BzfFPM53.js.gz b/apps/dashboard/build/_app/immutable/chunks/BzfFPM53.js.gz deleted file mode 100644 index 027412c..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/BzfFPM53.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/C2CaJvaA.js b/apps/dashboard/build/_app/immutable/chunks/C2CaJvaA.js deleted file mode 100644 index 33e900e..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/C2CaJvaA.js +++ /dev/null @@ -1 +0,0 @@ -var du=Object.defineProperty;var hu=(E,i,r)=>i in E?du(E,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):E[i]=r;var o=(E,i,r)=>hu(E,typeof i!="symbol"?i+"":i,r);import{StorageBufferAttribute as It,SpriteNodeMaterial as ru}from"./CkiUhdKe.js";import{uniform as h,storage as lt,Fn as R,instanceIndex as W,fract as T,float as t,mx_noise_vec3 as X,vec3 as u,sin as m,cos as b,sqrt as Rt,floor as et,pow as H,abs as nt,clamp as C,vec2 as y,smoothstep as mt,oneMinus as at,mix as M,select as e,cross as is,length as $,min as vu,atan as cs,positionView as bu}from"./Cqk6fVmx.js";import{V as ds,br as pu,eu as gu,dS as fu}from"./Bo4EDkTQ.js";const xu={anchor:0,connection:1,contradiction:2};class Bu{constructor(i,r,g={}){o(this,"count");o(this,"scene");o(this,"renderer");o(this,"bufferPos");o(this,"bufferVel");o(this,"bufferPhase");o(this,"computeNode");o(this,"mesh",null);o(this,"material",null);o(this,"computeInFlight",null);o(this,"uTarget",h(new ds(0,0,0)));o(this,"uTime",h(0));o(this,"uIgnition",h(.2));o(this,"uMode",h(0));o(this,"uContainRadius",h(48));o(this,"uHueShift",h(0));o(this,"uModeTintAmt",h(.25));o(this,"uBurst",h(0));o(this,"uActDim",h(.12));o(this,"uWorld",h(0));o(this,"uPrevWorld",h(0));o(this,"uBlend",h(0));o(this,"worldCount",7);o(this,"uBlast",h(0));o(this,"uBlastTime",h(0));o(this,"uMorphSeed",h(0));o(this,"uChaos",h(0));o(this,"uClash",h(0));o(this,"uFadeNear",h(2));o(this,"uFadeBand",h(7));o(this,"uFogDensity",h(.012));o(this,"uFocus",h(28));o(this,"uFocusRange",h(20));o(this,"uDofDim",h(.3));o(this,"uZoomPeriod",h(9));o(this,"uLambda",h(1.923));o(this,"uZoomOn",h(0));o(this,"uCamVelView",h(new ds(0,0,0)));o(this,"uStreak",h(0));o(this,"uMaxStretch",h(7));o(this,"dreamCount",0);this.renderer=i,this.scene=r,this.count=g.count??15e4;const f=g.spawnRadius??34,q=new Float32Array(this.count*3),D=new Float32Array(this.count*3),c=new Float32Array(this.count);for(let S=0;S{const c=f.element(W),p=q.element(W),B=D.element(W),F=B.mul(12.9898).sin().mul(43758.5453),S=B.mul(78.233).sin().mul(12543.531),L=B.mul(39.346).sin().mul(24634.633),O=T(F),V=T(S),a=T(L),l=O.mul(6.28318),d=V.mul(3.14159),n=this.uContainRadius,w=T(B.mul(3.7)),z=t(.62).add(w.mul(w).mul(.38)),A=t(W),v=R(([s])=>{const x=t(.6),ns=X(s.add(u(x,0,0))).sub(X(s.sub(u(x,0,0)))),ms=X(s.add(u(0,x,0))).sub(X(s.sub(u(0,x,0)))),as=X(s.add(u(0,0,x))).sub(X(s.sub(u(0,0,x))));return u(ms.z.sub(as.y),as.x.sub(ns.z),ns.y.sub(ms.x)).normalize()}),P=u(m(d).mul(b(l)),b(d),m(d).mul(m(l))),G=P.mul(n.mul(z)),tt=P.mul(n.mul(t(.5).add(w.mul(.3)))),N=t(.19),Z=u(m(c.y).sub(c.x.mul(N)),m(c.z).sub(c.y.mul(N)),m(c.x).sub(c.z.mul(N))),_=c.add(Z.mul(n.mul(.12))),j=G,st=u(O.sub(.5).mul(2).mul(n.mul(.8)),V.sub(.5).mul(2).mul(n.mul(.8)),a.sub(.5).mul(2).mul(n.mul(.8))),K=O.mul(6.28318).mul(3).add(a.mul(.6)),it=n.mul(.2).add(n.mul(.8).mul(a)),hs=u(it.mul(b(K)),n.mul(.06).mul(m(B.mul(20))),it.mul(m(K))),rs=t(2.39996323),Wt=A.mul(rs),Dt=Rt(A).mul(n.mul(.0042)),vs=u(Wt.cos().mul(Dt),n.mul(.04).mul(m(B.mul(9))),Wt.sin().mul(Dt)),Y=this.uMorphSeed,xt=this.uChaos,bs=T(Y.mul(.731).add(.13)),ps=T(Y.mul(1.323).add(.51)),gs=T(Y.mul(2.117).add(.27)),yt=t(387),J=T(A.div(yt)),k=et(A.div(yt)).div(yt),Vt=s=>s.exp().sub(s.mul(-1).exp()).mul(.5),Zt=s=>s.exp().add(s.mul(-1).exp()).mul(.5),I=(s,x)=>y(s.x.mul(x.x).sub(s.y.mul(x.y)),s.x.mul(x.y).add(s.y.mul(x.x))),wt=s=>{const x=s.x.exp();return y(x.mul(b(s.y)),x.mul(m(s.y)))},fs=s=>y(s.x.mul(s.x).add(s.y.mul(s.y)).max(1e-12).log().mul(.5),cs(s.y,s.x)),Ot=(s,x)=>wt(I(y(x,t(0)),fs(s))),xs=s=>y(Zt(s.x).mul(b(s.y)),Vt(s.x).mul(m(s.y))),ys=s=>y(Vt(s.x).mul(b(s.y)),Zt(s.x).mul(m(s.y))),Mt=s=>{const x=s.x.mul(s.x).add(s.y.mul(s.y)).max(1e-6);return y(s.x.div(x),s.y.mul(-1).div(x))},ct=t(2).add(et(bs.mul(14))),Nt=l,ws=H(nt(b(ct.mul(Nt).div(4))),t(2).add(ps.mul(8))).add(H(nt(m(ct.mul(Nt).div(4))),t(2).add(gs.mul(8)))).add(1e-4).pow(t(-.5)),Ms=H(nt(b(ct.mul(d).div(4))),t(3)).add(H(nt(m(ct.mul(d).div(4))),t(3))).add(1e-4).pow(t(-.5)),Tt=n.mul(.85).mul(C(ws.mul(Ms).mul(.5),.1,1.4)),Ts=u(m(d).mul(b(l)).mul(Tt),b(d).mul(Tt),m(d).mul(m(l)).mul(Tt)),kt=t(5),Ht=et(T(Y.mul(.013).add(A.mul(.00667))).mul(25)),Et=et(Ht.div(5)),qs=Ht.sub(Et.mul(5)),Cs=J.mul(2).sub(1),Bs=k.mul(1.5708),Lt=y(Cs,Bs),As=wt(y(t(0),Et.mul(6.28318).div(kt))),zs=wt(y(t(0),qs.mul(6.28318).div(kt))),Gt=I(As,Ot(xs(Lt),t(.4))),_t=I(zs,Ot(ys(Lt),t(.4))),jt=this.uTime.mul(.25).add(Y).add(xt.mul(1.5)),Ss=u(Gt.x,_t.x,b(jt).mul(Gt.y).add(m(jt).mul(_t.y))).mul(n.mul(.55)),Kt=Rt(J),Yt=k.mul(6.28318),qt=y(Kt.mul(b(Yt)),Kt.mul(m(Yt))),Q=I(qt,qt),ut=I(Q,qt),dt=Mt(Q),ht=Mt(ut),Fs=y(ut.x.sub(ht.x).add(2.2360679),ut.y.sub(ht.y)),Ct=Mt(Fs),Ps=I(y(t(0),t(1)),y(Q.x.sub(dt.x),Q.y.sub(dt.y))),Is=y(Q.x.add(dt.x),Q.y.add(dt.y)),Rs=I(y(t(0),t(.6667)),y(ut.x.add(ht.x),ut.y.add(ht.y))),Bt=I(Ct,Ps).x,At=I(Ct,Is).x,zt=I(Ct,Rs).x.add(.5),St=Bt.mul(Bt).add(At.mul(At)).add(zt.mul(zt)).max(1e-4),Ws=u(Bt.div(St),At.div(St),zt.div(St).sub(.86)).mul(n.mul(.5)),rt=k.mul(2).sub(1),Jt=Rt(t(1).sub(rt.mul(rt)).max(0)).mul(.9).add(.25),Qt=J.mul(6.28318).add(rt.mul(6).mul(xt.add(.4))),Ds=u(Jt.mul(b(Qt)),rt.mul(1.4),Jt.mul(m(Qt))).mul(n.mul(.5)),Ut=t(2.2).add(xt.mul(2)),vt=J.mul(6.28318).mul(Ut),bt=k.mul(6.28318).mul(Ut),pt=this.uTime.mul(.3).add(Y.mul(6.28318)),Vs=m(vt).mul(b(bt)).add(m(bt).mul(b(pt))).add(m(pt).mul(b(vt))),Zs=b(vt).mul(b(bt)).mul(b(pt)).sub(m(vt).mul(m(bt)).mul(m(pt))),Xt=this.uTime.mul(.15),Os=b(Xt).mul(Vs).add(m(Xt).mul(Zs)),Ns=u(m(k.mul(3.14159)).mul(b(J.mul(6.28318))),b(k.mul(3.14159)),m(k.mul(3.14159)).mul(m(J.mul(6.28318)))).mul(n.mul(.5).add(Os.mul(n.mul(.12)))),Ft=s=>e(s.equal(0),G,e(s.equal(1),tt,e(s.equal(2),_,e(s.equal(3),j,e(s.equal(4),st,e(s.equal(5),hs,e(s.equal(6),vs,e(s.equal(7),Ts,e(s.equal(8),Ss,e(s.equal(9),Ws,e(s.equal(10),Ds,Ns))))))))))),ks=Ft(t(this.uWorld)),Hs=Ft(t(this.uPrevWorld)),Es=mt(t(0),t(1),at(this.uBlend)),Ls=M(Hs,ks,Es),Gs=T(A.mul(.001).add(.5)).greaterThan(.66),Pt=t(this.uWorld).add(5),_s=e(Pt.greaterThan(11),Pt.sub(12),Pt),ot=Ft(_s),$t=this.uTime.mul(.4),ts=b($t),ss=m($t),js=u(ot.x.mul(ts).sub(ot.z.mul(ss)),ot.y,ot.x.mul(ss).add(ot.z.mul(ts))).mul(.52),Ks=this.uTime.div(this.uZoomPeriod).fract(),Ys=this.uTime.div(this.uZoomPeriod).add(.5).fract(),Js=M(t(1),this.uLambda.pow(Ks),this.uZoomOn),Qs=M(t(1),this.uLambda.pow(Ys),this.uZoomOn),Us=Ls.mul(Js),Xs=js.mul(Qs.mul(this.uLambda)),us=M(Us,Xs,Gs.select(t(1),t(0))),$s=c.normalize(),tu=at(T(B.mul(7.3)).mul(.4));p.addAssign($s.mul(this.uBurst.mul(.95).mul(tu))),p.addAssign(us.sub(c).mul(.045));const su=v(c.mul(.045).add(u(0,this.uTime.mul(.2),0))),uu=e(this.uWorld.equal(0),t(.05),e(this.uWorld.equal(5),t(.06),t(0)));p.addAssign(su.mul(uu)),p.addAssign(is(u(0,1,0),c).mul(9e-4).mul(e(this.uWorld.equal(1),t(1),t(0)))),p.addAssign(Z.mul(.012).mul(e(this.uWorld.equal(2),t(1),t(0))));const gt=c.x.div(n.mul(.5)),ft=c.y.div(n.mul(.5)),U=c.z.div(n.mul(.5)),ou=u(U.sub(.7).mul(gt).sub(ft.mul(3.5)),gt.mul(3.5).add(U.sub(.7).mul(ft)),t(.6).add(U.mul(.95)).sub(U.mul(U).mul(U).div(3)).sub(gt.mul(gt).add(ft.mul(ft))));p.addAssign(ou.mul(.008).mul(e(this.uWorld.equal(10),t(1),t(0)))),p.addAssign(is(u(0,1,0),c).mul(.0016).mul(e(this.uWorld.equal(5),t(1),t(0))));const lu=us.normalize().mul(m(this.uTime.mul(1.3).add(B.mul(6.1))).mul(.015));p.addAssign(lu);const os=$(p),eu=t(1.3);p.assign(p.mul(vu(eu,os).div(os.max(1e-4)))),c.addAssign(p),p.mulAssign(.9);const nu=e(this.uWorld.equal(4),t(1.6),t(1)),ls=M(t(.55),t(6),C(this.uBurst,0,1)),mu=et(c.div(ls)).add(.5).mul(ls),au=C(at(this.uBurst.mul(1.4)),0,.9).mul(nu).min(.9);c.assign(M(c,mu,au));const iu=$(c),es=this.uContainRadius,cu=c.normalize().mul(es);c.assign(M(c,cu,iu.greaterThan(es).select(t(1),t(0))))})().compute(this.count)}buildRender(i,r){const g=new ru({transparent:!0,blending:pu,depthWrite:!1}),f=lt(r,"float",this.count),q=lt(i,"vec3",this.count).element(W);g.positionNode=q;const D=g;{const a=u(this.uCamVelView),l=y(a.x,a.y),d=$(l).max(1e-4),n=T(f.element(W).mul(13.17)).mul(.5).add(.75);D.rotationNode=cs(l.y,l.x);const w=C(d.mul(this.uStreak).mul(n).mul(.6).add(1),t(1),this.uMaxStretch),z=t(1);D.scaleNode=y(z.mul(w),z)}const c=R(([a,l,d,n,w])=>l.add(d.mul(b(n.mul(a).add(w).mul(6.28318))))),p=R(([a])=>{const l=a.div(100),d=H(l.sub(60).max(1e-4),t(-.1332047592)).mul(329.698727446),n=l.lessThanEqual(66).select(t(255),d),w=l.max(1e-4).log().mul(99.4708025861).sub(161.1195681661),z=H(l.sub(60).max(1e-4),t(-.0755148492)).mul(288.1221695283),A=l.lessThanEqual(66).select(w,z),v=l.sub(10).max(1e-4).log().mul(138.5177312231).sub(305.0447927307),P=l.greaterThanEqual(66).select(t(255),l.lessThanEqual(19).select(t(0),v));return C(u(n,A,P).div(255),0,1)}),B=R(()=>{const a=q,l=f.element(W),d=$(a.sub(u(this.uTarget))),n=t(W),w=T(n.mul(.001).add(.5)).greaterThan(.66),z=a.x.mul(.03).add(a.y.mul(.021)).add(a.z.mul(.027)),A=T(l.mul(.41).add(d.mul(.06)).add(z).add(this.uTime.mul(.1)).add(this.uHueShift)),v=this.uClash,P=e(v.equal(0),u(0,.85,1),e(v.equal(1),u(.55,1,0),e(v.equal(2),u(1,.82,0),e(v.equal(3),u(0,1,.6),u(.1,.5,1))))),G=e(v.equal(0),u(.3,.2,1),e(v.equal(1),u(0,.7,.5),e(v.equal(2),u(1,.4,0),e(v.equal(3),u(0,.6,1),u(.5,0,1))))),tt=e(v.equal(0),u(1,.25,0),e(v.equal(1),u(1,0,.55),e(v.equal(2),u(.6,0,1),e(v.equal(3),u(1,.1,.3),u(1,.7,0))))),N=e(v.equal(0),u(1,0,.3),e(v.equal(1),u(1,.45,0),e(v.equal(2),u(1,0,.7),e(v.equal(3),u(1,.5,0),u(1,.2,.4))))),Z=mt(t(0),t(1),A),_=M(P,G,Z),j=M(tt,N,Z),st=M(_,j,w.select(t(1),t(0))),K=e(this.uMode.equal(2),u(1,.08,.32),e(this.uMode.equal(3),u(1,.78,.1),u(.1,.9,1)));return M(st,K,this.uModeTintAmt.mul(.4))}),F=R(()=>{const a=q,l=C($(a).div(this.uContainRadius.max(1e-4)),0,1),d=l.mul(l),n=a.normalize(),w=H(at(nt(n.z)),t(4)),z=t(.12).add(d.mul(.6)).add(w.mul(.5)),A=t(W),v=T(A.mul(.001).add(.5)).greaterThan(.66),P=t(.07).add(w.mul(.3)),G=v.select(P,z),tt=this.uTime.div(this.uZoomPeriod).fract(),N=this.uTime.div(this.uZoomPeriod).add(.5).fract(),Z=m(tt.mul(3.14159)),_=m(N.mul(3.14159)),j=Z.add(_).max(1e-4),st=M(t(1),Z.div(j).mul(2).min(1),this.uZoomOn),K=M(t(1),_.div(j).mul(2).min(1),this.uZoomOn),it=v.select(K,st);return G.mul(it)}),S=R(()=>{const a=bu.z.negate(),l=mt(this.uFadeNear,this.uFadeNear.add(this.uFadeBand),a),d=C(this.uFogDensity.mul(a).negate().exp(),.45,1),n=C(a.sub(this.uFocus).abs().div(this.uFocusRange),0,1),w=at(n.mul(this.uDofDim));return l.mul(d).mul(w)}),L=R(()=>{const a=q,l=C(this.uBlast,0,1),d=this.uBlastTime,n=C($(a).div(this.uContainRadius.max(1e-4)),0,1),w=M(t(1600),t(5200),l),z=C(l.mul(1.1).add(.4),0,1.3),A=p(w).mul(z),v=T(n.mul(1.6).sub(d.mul(1.5))),P=c(v,u(.55),u(.55),u(3),u(0,.33,.67));return M(A,P,t(.78))});g.colorNode=R(()=>{const a=C(this.uIgnition.mul(.05).add(.72),0,1.25),l=B().mul(a).mul(F()).mul(this.uActDim),d=mt(t(0),t(.85),C(this.uBlast,0,1)).mul(.6);return M(l,L().mul(F()).mul(this.uActDim),d).mul(S())})(),g.emissiveNode=R(()=>{const a=C(this.uIgnition.mul(.04).add(.85),0,1.35),l=B().mul(a).mul(F()).mul(this.uActDim),d=mt(t(0),t(.85),C(this.uBlast,0,1)).mul(.6);return M(l,L().mul(.85).mul(F()).mul(this.uActDim),d).mul(S())})();const O=new gu(.1,.1),V=new fu(O,g,this.count);V.frustumCulled=!1,this.material=g,this.mesh=V,this.scene.add(this.mesh)}async update(i){const r=Math.max(0,Math.min(i,.05));this.uTime.value+=r,this.uHueShift.value=(this.uHueShift.value+r*.06)%1,this.uBlend.value=Math.max(0,this.uBlend.value-r*1),this.uIgnition.value=Math.max(0,this.uIgnition.value-r*2),this.uBurst.value=Math.max(0,this.uBurst.value-r*.85),this.uBlast.value=Math.max(0,this.uBlast.value-r*.35),this.uBlastTime.value+=r;const g=this.uTime.value/this.uZoomPeriod.value%1,f=this.uZoomOn.value>.5?40-g*16:26+Math.sin(this.uTime.value*.18)*9;this.uFocus.value+=(f-this.uFocus.value)*Math.min(1,r*3),this.computeInFlight&&await this.computeInFlight,this.computeInFlight=this.renderer.computeAsync(this.computeNode).finally(()=>{this.computeInFlight=null}),await this.computeInFlight}transitionTo(i,r,g="II",f=99){this.uTarget.value.copy(r);const q=xu[i]??1;this.uMode.value=q,this.uPrevWorld.value=this.uWorld.value,this.uWorld.value=f%this.worldCount,this.uBlend.value=1,this.uClash.value=f%5,this.uZoomOn.value=f>=2?1:0;const D=f===0?.12:f===1?.2:null,c=g==="I"?.26:1;this.uActDim.value=D??c,this.uIgnition.value=f<=1?.4:g==="I"?1.6:4.5;const p=this.uWorld.value===3;this.uBurst.value=q===2||p?1:.8,this.uBlast.value=f<=1?.25:1,this.uBlastTime.value=0,this.uModeTintAmt.value=q>=2?.7:.22}dreamBeat(){this.dreamCount+=1;const i=7+Math.floor(Math.random()*5);this.uPrevWorld.value=this.uWorld.value,this.uWorld.value=i,this.uBlend.value=1,this.uMorphSeed.value=Math.random()*1e3,this.uClash.value=Math.floor(Math.random()*5),this.uChaos.value=Math.min(1,.25+this.dreamCount*.1),this.uZoomOn.value=1,this.uActDim.value=.85,this.uIgnition.value=3,this.uBurst.value=1,this.uBlast.value=1,this.uBlastTime.value=0;const r=[1,2,3];this.uMode.value=r[Math.floor(Math.random()*r.length)],this.uModeTintAmt.value=.3+Math.random()*.5}setContainRadius(i){this.uContainRadius.value=Math.max(8,i)}setZoom(i){this.uZoomOn.value=i?1:0}setCameraVel(i){this.uCamVelView.value.copy(i)}setStreak(i){this.uStreak.value=i}dispose(){var i,r,g,f;this.mesh&&(this.scene.remove(this.mesh),(i=this.mesh.geometry)==null||i.dispose(),(g=(r=this.mesh).dispose)==null||g.call(r),this.mesh=null),(f=this.material)==null||f.dispose(),this.material=null,this.bufferPos=null,this.bufferVel=null,this.bufferPhase=null}}export{Bu as SemanticComputeStorm}; diff --git a/apps/dashboard/build/_app/immutable/chunks/C2CaJvaA.js.br b/apps/dashboard/build/_app/immutable/chunks/C2CaJvaA.js.br deleted file mode 100644 index 8757bef..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/C2CaJvaA.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/C2CaJvaA.js.gz b/apps/dashboard/build/_app/immutable/chunks/C2CaJvaA.js.gz deleted file mode 100644 index 5ef4ef6..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/C2CaJvaA.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/CGq8RnJq.js b/apps/dashboard/build/_app/immutable/chunks/CGq8RnJq.js deleted file mode 100644 index ac93004..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/CGq8RnJq.js +++ /dev/null @@ -1 +0,0 @@ -var wn=Object.defineProperty;var mt=e=>{throw TypeError(e)};var yn=(e,t,n)=>t in e?wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ye=(e,t,n)=>yn(e,typeof t!="symbol"?t+"":t,n),We=(e,t,n)=>t.has(e)||mt("Cannot "+n);var p=(e,t,n)=>(We(e,t,"read from private field"),n?n.call(e):t.get(e)),F=(e,t,n)=>t.has(e)?mt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),W=(e,t,n,r)=>(We(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),X=(e,t,n)=>(We(e,t,"access private method"),n);var mn=Array.isArray,En=Array.prototype.indexOf,Ae=Array.prototype.includes,yr=Array.from,mr=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,gn=Object.getOwnPropertyDescriptors,Tn=Object.prototype,bn=Array.prototype,Ct=Object.getPrototypeOf,Et=Object.isExtensible;const An=()=>{};function Er(e){return e()}function Sn(e){for(var t=0;t{e=r,t=s});return{promise:n,resolve:e,reject:t}}function gr(e,t){if(Array.isArray(e))return e;if(!(Symbol.iterator in e))return Array.from(e);const n=[];for(const r of e)if(n.push(r),n.length===t)break;return n}const A=2,Pe=4,Me=8,Pt=1<<24,K=16,U=32,we=64,Rn=128,P=512,g=1024,R=2048,V=4096,Y=8192,Q=16384,ne=32768,Ve=65536,gt=1<<17,Mt=1<<18,Fe=1<<19,Ft=1<<20,Tr=1<<25,_e=65536,Je=1<<21,it=1<<22,ee=1<<23,ue=Symbol("$state"),br=Symbol("legacy props"),Ar=Symbol(""),fe=new class extends Error{constructor(){super(...arguments);ye(this,"name","StaleReactionError");ye(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var kt;const Rr=!!((kt=globalThis.document)!=null&&kt.contentType)&&globalThis.document.contentType.includes("xml"),Le=3,Lt=8;function Nn(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Nr(e,t,n){throw new Error("https://svelte.dev/e/each_key_duplicate")}function On(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function xn(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function kn(e){throw new Error("https://svelte.dev/e/effect_orphan")}function Dn(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function Or(){throw new Error("https://svelte.dev/e/hydration_failed")}function xr(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function Cn(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function In(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Pn(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function kr(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const Dr=1,Cr=2,Ir=4,Pr=8,Mr=16,Fr=1,Lr=2,jr=4,Hr=8,Yr=16,jt=1,Mn=2,Fn="[",Ln="[!",qr="[?",jn="]",lt={},T=Symbol(),Hn="http://www.w3.org/1999/xhtml",Vr="http://www.w3.org/2000/svg",Ur="http://www.w3.org/1998/Math/MathML";function ot(e){console.warn("https://svelte.dev/e/hydration_mismatch")}function Br(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function Gr(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}let D=!1;function $r(e){D=e}let y;function ve(e){if(e===null)throw ot(),lt;return y=e}function Yn(){return ve(se(y))}function zr(e){if(D){if(se(y)!==null)throw ot(),lt;y=e}}function Kr(e=1){if(D){for(var t=e,n=y;t--;)n=se(n);y=n}}function Wr(e=!0){for(var t=0,n=y;;){if(n.nodeType===Lt){var r=n.data;if(r===jn){if(t===0)return n;t-=1}else(r===Fn||r===Ln||r[0]==="["&&!isNaN(Number(r.slice(1))))&&(t+=1)}var s=se(n);e&&n.remove(),n=s}}function Xr(e){if(!e||e.nodeType!==Lt)throw ot(),lt;return e.data}function Ht(e){return e===this.v}function qn(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function Yt(e){return!qn(e,this.v)}let Ge=!1;function Zr(){Ge=!0}let S=null;function Ue(e){S=e}function Jr(e,t=!1,n){S={p:S,i:!1,c:null,e:null,s:e,x:null,l:Ge&&!t?{s:null,u:null,$:[]}:null}}function Qr(e){var t=S,n=t.e;if(n!==null){t.e=null;for(var r of n)rn(r)}return t.i=!0,S=t.p,{}}function je(){return!Ge||S!==null&&S.l===null}let ae=[];function qt(){var e=ae;ae=[],Sn(e)}function Tt(e){if(ae.length===0&&!ke){var t=ae;queueMicrotask(()=>{t===ae&&qt()})}ae.push(e)}function Vn(){for(;ae.length>0;)qt()}function Un(e){var t=h;if(t===null)return _.f|=ee,e;if((t.f&ne)===0&&(t.f&Pe)===0)throw e;Be(e,t)}function Be(e,t){for(;t!==null;){if((t.f&Rn)!==0){if((t.f&ne)===0)throw e;try{t.b.error(e);return}catch(n){e=n}}t=t.parent}throw e}const Bn=-7169;function E(e,t){e.f=e.f&Bn|t}function ut(e){(e.f&P)!==0||e.deps===null?E(e,g):E(e,V)}function Vt(e){if(e!==null)for(const t of e)(t.f&A)===0||(t.f&_e)===0||(t.f^=_e,Vt(t.deps))}function Gn(e,t,n){(e.f&R)!==0?t.add(e):(e.f&V)!==0&&n.add(e),Vt(e.deps),E(e,g)}const Ye=new Set;let d=null,bt=null,b=null,O=[],$e=null,Qe=!1,ke=!1;var Ee,ge,le,Te,Ce,Ie,oe,$,be,C,et,tt,nt,Ut;const ht=class ht{constructor(){F(this,C);ye(this,"current",new Map);ye(this,"previous",new Map);F(this,Ee,new Set);F(this,ge,new Set);F(this,le,0);F(this,Te,0);F(this,Ce,null);F(this,Ie,new Set);F(this,oe,new Set);F(this,$,new Map);ye(this,"is_fork",!1);F(this,be,!1)}skip_effect(t){p(this,$).has(t)||p(this,$).set(t,{d:[],m:[]})}unskip_effect(t){var n=p(this,$).get(t);if(n){p(this,$).delete(t);for(var r of n.d)E(r,R),z(r);for(r of n.m)E(r,V),z(r)}}process(t){var s;O=[],this.apply();var n=[],r=[];for(const f of t)X(this,C,tt).call(this,f,n,r);if(X(this,C,et).call(this)){X(this,C,nt).call(this,r),X(this,C,nt).call(this,n);for(const[f,i]of p(this,$))zt(f,i)}else{for(const f of p(this,Ee))f();p(this,Ee).clear(),p(this,le)===0&&X(this,C,Ut).call(this),bt=this,d=null,At(r),At(n),bt=null,(s=p(this,Ce))==null||s.resolve()}b=null}capture(t,n){n!==T&&!this.previous.has(t)&&this.previous.set(t,n),(t.f&ee)===0&&(this.current.set(t,t.v),b==null||b.set(t,t.v))}activate(){d=this,this.apply()}deactivate(){d===this&&(d=null,b=null)}flush(){if(this.activate(),O.length>0){if(Bt(),d!==null&&d!==this)return}else p(this,le)===0&&this.process([]);this.deactivate()}discard(){for(const t of p(this,ge))t(this);p(this,ge).clear()}increment(t){W(this,le,p(this,le)+1),t&&W(this,Te,p(this,Te)+1)}decrement(t){W(this,le,p(this,le)-1),t&&W(this,Te,p(this,Te)-1),!p(this,be)&&(W(this,be,!0),Tt(()=>{W(this,be,!1),X(this,C,et).call(this)?O.length>0&&this.flush():this.revive()}))}revive(){for(const t of p(this,Ie))p(this,oe).delete(t),E(t,R),z(t);for(const t of p(this,oe))E(t,V),z(t);this.flush()}oncommit(t){p(this,Ee).add(t)}ondiscard(t){p(this,ge).add(t)}settled(){return(p(this,Ce)??W(this,Ce,It())).promise}static ensure(){if(d===null){const t=d=new ht;Ye.add(d),ke||Tt(()=>{d===t&&t.flush()})}return d}apply(){}};Ee=new WeakMap,ge=new WeakMap,le=new WeakMap,Te=new WeakMap,Ce=new WeakMap,Ie=new WeakMap,oe=new WeakMap,$=new WeakMap,be=new WeakMap,C=new WeakSet,et=function(){return this.is_fork||p(this,Te)>0},tt=function(t,n,r){t.f^=g;for(var s=t.first;s!==null;){var f=s.f,i=(f&(U|we))!==0,o=i&&(f&g)!==0,a=o||(f&Y)!==0||p(this,$).has(s);if(!a&&s.fn!==null){i?s.f^=g:(f&Pe)!==0?n.push(s):He(s)&&((f&K)!==0&&p(this,oe).add(s),Ne(s));var l=s.first;if(l!==null){s=l;continue}}for(;s!==null;){var c=s.next;if(c!==null){s=c;break}s=s.parent}}},nt=function(t){for(var n=0;n1){this.previous.clear();var t=b,n=!0;for(const f of Ye){if(f===this){n=!1;continue}const i=[];for(const[a,l]of this.current){if(f.current.has(a))if(n&&l!==f.current.get(a))f.current.set(a,l);else continue;i.push(a)}if(i.length===0)continue;const o=[...f.current.keys()].filter(a=>!this.current.has(a));if(o.length>0){var r=O;O=[];const a=new Set,l=new Map;for(const c of i)Gt(c,o,a,l);if(O.length>0){d=f,f.apply();for(const c of O)X(s=f,C,tt).call(s,c,[],[]);f.deactivate()}O=r}}d=null,b=t}Ye.delete(this)};let Se=ht;function $n(e){var t=ke;ke=!0;try{for(var n;;){if(Vn(),O.length===0&&(d==null||d.flush(),O.length===0))return $e=null,n;Bt()}}finally{ke=t}}function Bt(){Qe=!0;var e=null;try{for(var t=0;O.length>0;){var n=Se.ensure();if(t++>1e3){var r,s;zn()}n.process(O),te.clear()}}finally{O=[],Qe=!1,$e=null}}function zn(){try{Dn()}catch(e){Be(e,$e)}}let L=null;function At(e){var t=e.length;if(t!==0){for(var n=0;n0)){te.clear();for(const s of L){if((s.f&(Q|Y))!==0)continue;const f=[s];let i=s.parent;for(;i!==null;)L.has(i)&&(L.delete(i),f.push(i)),i=i.parent;for(let o=f.length-1;o>=0;o--){const a=f[o];(a.f&(Q|Y))===0&&Ne(a)}}L.clear()}}L=null}}function Gt(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(const s of e.reactions){const f=s.f;(f&A)!==0?Gt(s,t,n,r):(f&(it|K))!==0&&(f&R)===0&&$t(s,t,r)&&(E(s,R),z(s))}}function $t(e,t,n){const r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(const s of e.deps){if(Ae.call(t,s))return!0;if((s.f&A)!==0&&$t(s,t,n))return n.set(s,!0),!0}return n.set(e,!1),!1}function z(e){var t=$e=e,n=t.b;if(n!=null&&n.is_pending&&(e.f&(Pe|Me|Pt))!==0&&(e.f&ne)===0){n.defer_effect(e);return}for(;t.parent!==null;){t=t.parent;var r=t.f;if(Qe&&t===h&&(r&K)!==0&&(r&Mt)===0&&(r&ne)!==0)return;if((r&(we|U))!==0){if((r&g)===0)return;t.f^=g}}O.push(t)}function zt(e,t){if(!((e.f&U)!==0&&(e.f&g)!==0)){(e.f&R)!==0?t.d.push(e):(e.f&V)!==0&&t.m.push(e),E(e,g);for(var n=e.first;n!==null;)zt(n,t),n=n.next}}function Kn(e,t,n,r){const s=je()?ct:Jn;var f=e.filter(u=>!u.settled);if(n.length===0&&f.length===0){r(t.map(s));return}var i=h,o=Wn(),a=f.length===1?f[0].promise:f.length>1?Promise.all(f.map(u=>u.promise)):null;function l(u){o();try{r(u)}catch(v){(i.f&Q)===0&&Be(v,i)}rt()}if(n.length===0){a.then(()=>l(t.map(s)));return}function c(){o(),Promise.all(n.map(u=>Zn(u))).then(u=>l([...t.map(s),...u])).catch(u=>Be(u,i))}a?a.then(c):c()}function Wn(){var e=h,t=_,n=S,r=d;return function(f=!0){Re(e),re(t),Ue(n),f&&(r==null||r.activate())}}function rt(e=!0){Re(null),re(null),Ue(null),e&&(d==null||d.deactivate())}function Xn(){var e=h.b,t=d,n=e.is_rendered();return e.update_pending_count(1),t.increment(n),()=>{e.update_pending_count(-1),t.decrement(n)}}function ct(e){var t=A|R,n=_!==null&&(_.f&A)!==0?_:null;return h!==null&&(h.f|=Fe),{ctx:S,deps:null,effects:null,equals:Ht,f:t,fn:e,reactions:null,rv:0,v:T,wv:0,parent:n??h,ac:null}}function Zn(e,t,n){h===null&&Nn();var s=void 0,f=vt(T),i=!_,o=new Map;return or(()=>{var v;var a=It();s=a.promise;try{Promise.resolve(e()).then(a.resolve,a.reject).finally(rt)}catch(m){a.reject(m),rt()}var l=d;if(i){var c=Xn();(v=o.get(l))==null||v.reject(fe),o.delete(l),o.set(l,a)}const u=(m,w=void 0)=>{if(l.activate(),w)w!==fe&&(f.f|=ee,ft(f,w));else{(f.f&ee)!==0&&(f.f^=ee),ft(f,m);for(const[G,N]of o){if(o.delete(G),G===l)break;N.reject(fe)}}c&&c()};a.promise.then(u,m=>u(null,m||"unknown"))}),lr(()=>{for(const a of o.values())a.reject(fe)}),new Promise(a=>{function l(c){function u(){c===s?a(f):l(s)}c.then(u,u)}l(s)})}function es(e){const t=ct(e);return on(t),t}function Jn(e){const t=ct(e);return t.equals=Yt,t}function Qn(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n0&&!Xt&&nr()}return t}function nr(){Xt=!1;for(const e of st)(e.f&g)!==0&&E(e,V),He(e)&&Ne(e);st.clear()}function ns(e,t=1){var n=me(e),r=t===1?n++:n--;return J(e,n),r}function Xe(e){J(e,e.v+1)}function Zt(e,t){var n=e.reactions;if(n!==null)for(var r=je(),s=n.length,f=0;f{if(ce===f)return o();var a=_,l=ce;re(null),xt(f);var c=o();return re(a),xt(l),c};return r&&n.set("length",Z(e.length)),new Proxy(e,{defineProperty(o,a,l){(!("value"in l)||l.configurable===!1||l.enumerable===!1||l.writable===!1)&&Cn();var c=n.get(a);return c===void 0?i(()=>{var u=Z(l.value);return n.set(a,u),u}):J(c,l.value,!0),!0},deleteProperty(o,a){var l=n.get(a);if(l===void 0){if(a in o){const c=i(()=>Z(T));n.set(a,c),Xe(s)}}else J(l,T),Xe(s);return!0},get(o,a,l){var m;if(a===ue)return e;var c=n.get(a),u=a in o;if(c===void 0&&(!u||(m=xe(o,a))!=null&&m.writable)&&(c=i(()=>{var w=Oe(u?o[a]:T),G=Z(w);return G}),n.set(a,c)),c!==void 0){var v=me(c);return v===T?void 0:v}return Reflect.get(o,a,l)},getOwnPropertyDescriptor(o,a){var l=Reflect.getOwnPropertyDescriptor(o,a);if(l&&"value"in l){var c=n.get(a);c&&(l.value=me(c))}else if(l===void 0){var u=n.get(a),v=u==null?void 0:u.v;if(u!==void 0&&v!==T)return{enumerable:!0,configurable:!0,value:v,writable:!0}}return l},has(o,a){var v;if(a===ue)return!0;var l=n.get(a),c=l!==void 0&&l.v!==T||Reflect.has(o,a);if(l!==void 0||h!==null&&(!c||(v=xe(o,a))!=null&&v.writable)){l===void 0&&(l=i(()=>{var m=c?Oe(o[a]):T,w=Z(m);return w}),n.set(a,l));var u=me(l);if(u===T)return!1}return c},set(o,a,l,c){var yt;var u=n.get(a),v=a in o;if(r&&a==="length")for(var m=l;mZ(T)),n.set(m+"",w))}if(u===void 0)(!v||(yt=xe(o,a))!=null&&yt.writable)&&(u=i(()=>Z(void 0)),J(u,Oe(l)),n.set(a,u));else{v=u.v!==T;var G=i(()=>Oe(l));J(u,G)}var N=Reflect.getOwnPropertyDescriptor(o,a);if(N!=null&&N.set&&N.set.call(c,l),!v){if(r&&typeof a=="string"){var wt=n.get("length"),Ke=Number(a);Number.isInteger(Ke)&&Ke>=wt.v&&J(wt,Ke+1)}Xe(s)}return!0},ownKeys(o){me(s);var a=Reflect.ownKeys(o).filter(u=>{var v=n.get(u);return v===void 0||v.v!==T});for(var[l,c]of n)c.v!==T&&!(l in o)&&a.push(l);return a},setPrototypeOf(){In()}})}function St(e){try{if(e!==null&&typeof e=="object"&&ue in e)return e[ue]}catch{}return e}function rs(e,t){return Object.is(St(e),St(t))}var Rt,rr,Jt,Qt,en;function ss(){if(Rt===void 0){Rt=window,rr=document,Jt=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;Qt=xe(t,"firstChild").get,en=xe(t,"nextSibling").get,Et(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),Et(n)&&(n.__t=void 0)}}function de(e=""){return document.createTextNode(e)}function j(e){return Qt.call(e)}function se(e){return en.call(e)}function fs(e,t){if(!D)return j(e);var n=j(y);if(n===null)n=y.appendChild(de());else if(t&&n.nodeType!==Le){var r=de();return n==null||n.before(r),ve(r),r}return t&&ze(n),ve(n),n}function as(e,t=!1){if(!D){var n=j(e);return n instanceof Comment&&n.data===""?se(n):n}if(t){if((y==null?void 0:y.nodeType)!==Le){var r=de();return y==null||y.before(r),ve(r),r}ze(y)}return y}function is(e,t=1,n=!1){let r=D?y:e;for(var s;t--;)s=r,r=se(r);if(!D)return r;if(n){if((r==null?void 0:r.nodeType)!==Le){var f=de();return r===null?s==null||s.after(f):r.before(f),ve(f),f}ze(r)}return ve(r),r}function sr(e){e.textContent=""}function ls(){return!1}function fr(e,t,n){return document.createElementNS(t??Hn,e,void 0)}function ze(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===Le;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function os(e){D&&j(e)!==null&&sr(e)}let Nt=!1;function ar(){Nt||(Nt=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{var t;if(!e.defaultPrevented)for(const n of e.target.elements)(t=n.__on_r)==null||t.call(n)})},{capture:!0}))}function dt(e){var t=_,n=h;re(null),Re(null);try{return e()}finally{re(t),Re(n)}}function us(e,t,n,r=n){e.addEventListener(t,()=>dt(n));const s=e.__on_r;s?e.__on_r=()=>{s(),r(!0)}:e.__on_r=()=>r(!0),ar()}function tn(e){h===null&&(_===null&&kn(),xn()),he&&On()}function ir(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function B(e,t,n){var r=h;r!==null&&(r.f&Y)!==0&&(e|=Y);var s={ctx:S,deps:null,nodes:null,f:e|R|P,first:null,fn:t,last:null,next:null,parent:r,b:r&&r.b,prev:null,teardown:null,wv:0,ac:null};if(n)try{Ne(s)}catch(o){throw pe(s),o}else t!==null&&z(s);var f=s;if(n&&f.deps===null&&f.teardown===null&&f.nodes===null&&f.first===f.last&&(f.f&Fe)===0&&(f=f.first,(e&K)!==0&&(e&Ve)!==0&&f!==null&&(f.f|=Ve)),f!==null&&(f.parent=r,r!==null&&ir(f,r),_!==null&&(_.f&A)!==0&&(e&we)===0)){var i=_;(i.effects??(i.effects=[])).push(f)}return s}function nn(){return _!==null&&!H}function lr(e){const t=B(Me,null,!1);return E(t,g),t.teardown=e,t}function cs(e){tn();var t=h.f,n=!_&&(t&U)!==0&&(t&ne)===0;if(n){var r=S;(r.e??(r.e=[])).push(e)}else return rn(e)}function rn(e){return B(Pe|Ft,e,!1)}function _s(e){return tn(),B(Me|Ft,e,!0)}function vs(e){Se.ensure();const t=B(we|Fe,e,!0);return(n={})=>new Promise(r=>{n.outro?_r(t,()=>{pe(t),r(void 0)}):(pe(t),r(void 0))})}function ds(e){return B(Pe,e,!1)}function or(e){return B(it|Fe,e,!0)}function ps(e,t=0){return B(Me|t,e,!0)}function hs(e,t=[],n=[],r=[]){Kn(r,t,n,s=>{B(Me,()=>e(...s.map(me)),!0)})}function ws(e,t=0){var n=B(K|t,e,!0);return n}function ys(e){return B(U|Fe,e,!0)}function sn(e){var t=e.teardown;if(t!==null){const n=he,r=_;Ot(!0),re(null);try{t.call(null)}finally{Ot(n),re(r)}}}function pt(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){const s=n.ac;s!==null&&dt(()=>{s.abort(fe)});var r=n.next;(n.f&we)!==0?n.parent=null:pe(n,t),n=r}}function ur(e){for(var t=e.first;t!==null;){var n=t.next;(t.f&U)===0&&pe(t),t=n}}function pe(e,t=!0){var n=!1;(t||(e.f&Mt)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(cr(e.nodes.start,e.nodes.end),n=!0),pt(e,t&&!n),De(e,0),E(e,Q);var r=e.nodes&&e.nodes.t;if(r!==null)for(const f of r)f.stop();sn(e);var s=e.parent;s!==null&&s.first!==null&&fn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function cr(e,t){for(;e!==null;){var n=e===t?null:se(e);e.remove(),e=n}}function fn(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 _r(e,t,n=!0){var r=[];an(e,r,!0);var s=()=>{n&&pe(e),t&&t()},f=r.length;if(f>0){var i=()=>--f||s();for(var o of r)o.out(i)}else s()}function an(e,t,n){if((e.f&Y)===0){e.f^=Y;var r=e.nodes&&e.nodes.t;if(r!==null)for(const o of r)(o.is_global||n)&&t.push(o);for(var s=e.first;s!==null;){var f=s.next,i=(s.f&Ve)!==0||(s.f&U)!==0&&(e.f&K)!==0;an(s,t,i?n:!1),s=f}}}function ms(e){ln(e,!0)}function ln(e,t){if((e.f&Y)!==0){e.f^=Y,(e.f&g)===0&&(E(e,R),z(e));for(var n=e.first;n!==null;){var r=n.next,s=(n.f&Ve)!==0||(n.f&U)!==0;ln(n,s?t:!1),n=r}var f=e.nodes&&e.nodes.t;if(f!==null)for(const i of f)(i.is_global||t)&&i.in()}}function Es(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var s=n===r?null:se(n);t.append(n),n=s}}let qe=!1,he=!1;function Ot(e){he=e}let _=null,H=!1;function re(e){_=e}let h=null;function Re(e){h=e}let M=null;function on(e){_!==null&&(M===null?M=[e]:M.push(e))}let x=null,k=0,I=null;function vr(e){I=e}let un=1,ie=0,ce=ie;function xt(e){ce=e}function cn(){return++un}function He(e){var t=e.f;if((t&R)!==0)return!0;if(t&A&&(e.f&=~_e),(t&V)!==0){for(var n=e.deps,r=n.length,s=0;se.wv)return!0}(t&P)!==0&&b===null&&E(e,g)}return!1}function _n(e,t,n=!0){var r=e.reactions;if(r!==null&&!(M!==null&&Ae.call(M,e)))for(var s=0;s{e.ac.abort(fe)}),e.ac=null);try{e.f|=Je;var c=e.fn,u=c();e.f|=ne;var v=e.deps,m=d==null?void 0:d.is_fork;if(x!==null){var w;if(m||De(e,k),v!==null&&k>0)for(v.length=k+x.length,w=0;we});function pr(e){return(Ze==null?void 0:Ze.createHTML(e))??e}function hn(e){var t=fr("template");return t.innerHTML=pr(e.replaceAll("","")),t.content}function q(e,t){var n=h;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function Ss(e,t){var n=(t&jt)!==0,r=(t&Mn)!==0,s,f=!e.startsWith("");return()=>{if(D)return q(y,null),y;s===void 0&&(s=hn(f?e:""+e),n||(s=j(s)));var i=r||Jt?document.importNode(s,!0):s.cloneNode(!0);if(n){var o=j(i),a=i.lastChild;q(o,a)}else q(i,i);return i}}function hr(e,t,n="svg"){var r=!e.startsWith(""),s=(t&jt)!==0,f=`<${n}>${r?e:""+e}`,i;return()=>{if(D)return q(y,null),y;if(!i){var o=hn(f),a=j(o);if(s)for(i=document.createDocumentFragment();j(a);)i.appendChild(j(a));else i=j(a)}var l=i.cloneNode(!0);if(s){var c=j(l),u=l.lastChild;q(c,u)}else q(l,l);return l}}function Rs(e,t){return hr(e,t,"svg")}function Ns(e=""){if(!D){var t=de(e+"");return q(t,t),t}var n=y;return n.nodeType!==Le?(n.before(n=de()),ve(n)):ze(n),q(n,n),n}function Os(){if(D)return q(y,null),y;var e=document.createDocumentFragment(),t=document.createComment(""),n=de();return e.append(t,n),q(t,n),e}function xs(e,t){if(D){var n=h;((n.f&ne)===0||n.nodes.end===null)&&(n.nodes.end=y),Yn();return}e!==null&&e.before(t)}export{rr as $,de as A,Fe as B,Lt as C,se as D,Ve as E,$r as F,ve as G,Mt as H,y as I,j as J,ms as K,pe as L,_r as M,ys as N,Es as O,ls as P,S as Q,_s as R,Sn as S,Er as T,As as U,ct as V,Zr as W,is as X,hs as Y,An as Z,ts as _,xs as a,z as a$,mr as a0,xe as a1,xr as a2,jr as a3,he as a4,h as a5,Q as a6,Yr as a7,Hr as a8,Ge as a9,Hn as aA,Ct as aB,gn as aC,Rr as aD,ar as aE,Ar as aF,Fn as aG,as as aH,cr as aI,ot as aJ,lt as aK,q as aL,fr as aM,Vr as aN,Ur as aO,Rs as aP,qn as aQ,$n as aR,Os as aS,Ns as aT,nn as aU,Xe as aV,Rn as aW,qr as aX,Se as aY,E as aZ,R as a_,Lr as aa,Fr as ab,Jn as ac,ue as ad,br as ae,Kr as af,os as ag,Ir as ah,Yn as ai,Xr as aj,Ln as ak,Wr as al,jn as am,ft as an,Tr as ao,Nr as ap,yr as aq,Dr as ar,Mr as as,vt as at,Cr as au,Y as av,Tt as aw,U as ax,Pr as ay,sr as az,Qr as b,V as b0,Gn as b1,Re as b2,re as b3,Ue as b4,Un as b5,_ as b6,Be as b7,kr as b8,Gr as b9,dt as ba,ss as bb,Or as bc,vs as bd,Ts as be,je as bf,Rt as bg,gr as bh,fs as c,Z as d,Oe as e,Ss as f,me as g,ds as h,ws as i,cs as j,ns as k,us as l,d as m,mn as n,Br as o,Jr as p,rs as q,zr as r,J as s,lr as t,es as u,bt as v,D as w,gs as x,bs as y,ps as z}; diff --git a/apps/dashboard/build/_app/immutable/chunks/CGq8RnJq.js.br b/apps/dashboard/build/_app/immutable/chunks/CGq8RnJq.js.br deleted file mode 100644 index ade9b66..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/CGq8RnJq.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/CGq8RnJq.js.gz b/apps/dashboard/build/_app/immutable/chunks/CGq8RnJq.js.gz deleted file mode 100644 index ac2dc4f..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/CGq8RnJq.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/CKbQrCJw.js b/apps/dashboard/build/_app/immutable/chunks/CKbQrCJw.js deleted file mode 100644 index 739a73e..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/CKbQrCJw.js +++ /dev/null @@ -1 +0,0 @@ -import"./Bzak7iHL.js";import{Y as m,w as y,ai as v,a5 as C,aI as g,I as x,C as _,D as w,aJ as A,aK as z,aL as u,G as L,aM as H,aN as V,aO as E,J as d,a as N,aP as b,c as I,r as O}from"./CGq8RnJq.js";import{s as M}from"./DqfV0sZu.js";import{s as T}from"./uCQU803Y.js";import{p as n}from"./DV6OI5iy.js";function Z(h,c,t=!1,l=!1,p=!1){var a=h,r="";m(()=>{var o=C;if(r===(r=c()??"")){y&&v();return}if(o.nodes!==null&&(g(o.nodes.start,o.nodes.end),o.nodes=null),r!==""){if(y){x.data;for(var e=v(),f=e;e!==null&&(e.nodeType!==_||e.data!=="");)f=e,e=w(e);if(e===null)throw A(),z;u(x,f),a=L(e);return}var k=t?V:l?E:void 0,s=H(t?"svg":l?"math":"template",k);s.innerHTML=r;var i=t||l?s:s.content;if(u(d(i),i.lastChild),t||l)for(;d(i);)a.before(d(i));else a.before(i)}})}const P={blackbox:'',memorypr:'',graph:'',reasoning:'',memories:'',timeline:'',feed:'',explore:'',activation:'',dreams:'',schedule:'',importance:'',duplicates:'',contradictions:'',patterns:'',intentions:'',stats:'',settings:'',command:'',search:'',filter:'',sparkle:'',chevron:'',close:'',pulse:'',logo:''};var R=b('');function Y(h,c){let t=n(c,"size",3,20),l=n(c,"strokeWidth",3,1.6),p=n(c,"class",3,""),a=n(c,"draw",3,!1);var r=R(),o=I(r);Z(o,()=>P[c.name],!0),O(r),m(()=>{M(r,"width",t()),M(r,"height",t()),M(r,"stroke-width",l()),T(r,0,`vestige-icon ${a()?"vestige-icon-draw":""} ${p()??""}`,"svelte-1eqehiz")}),N(h,r)}export{Y as I}; diff --git a/apps/dashboard/build/_app/immutable/chunks/CKbQrCJw.js.br b/apps/dashboard/build/_app/immutable/chunks/CKbQrCJw.js.br deleted file mode 100644 index 24924ae..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/CKbQrCJw.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/CKbQrCJw.js.gz b/apps/dashboard/build/_app/immutable/chunks/CKbQrCJw.js.gz deleted file mode 100644 index d87e87c..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/CKbQrCJw.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/CbBCXwzm.js b/apps/dashboard/build/_app/immutable/chunks/CbBCXwzm.js deleted file mode 100644 index 74d8d90..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/CbBCXwzm.js +++ /dev/null @@ -1 +0,0 @@ -import{s as e}from"./DJDK-KWF.js";const r=()=>{const s=e;return{page:{subscribe:s.page.subscribe},navigating:{subscribe:s.navigating.subscribe},updated:s.updated}},b={subscribe(s){return r().page.subscribe(s)}};export{b as p}; diff --git a/apps/dashboard/build/_app/immutable/chunks/CbBCXwzm.js.br b/apps/dashboard/build/_app/immutable/chunks/CbBCXwzm.js.br deleted file mode 100644 index ad24cbc..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/CbBCXwzm.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/CbBCXwzm.js.gz b/apps/dashboard/build/_app/immutable/chunks/CbBCXwzm.js.gz deleted file mode 100644 index 07721da..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/CbBCXwzm.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/CcUbQ_Wl.js b/apps/dashboard/build/_app/immutable/chunks/CcUbQ_Wl.js deleted file mode 100644 index b9a927a..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/CcUbQ_Wl.js +++ /dev/null @@ -1 +0,0 @@ -const e={fact:"#00A8FF",concept:"#9D00FF",event:"#FFB800",person:"#00FFD1",place:"#00D4FF",note:"#8B95A5",pattern:"#FF3CAC",decision:"#FF4757"},F={MemoryCreated:"#00FFD1",MemoryUpdated:"#00A8FF",MemoryDeleted:"#FF4757",MemoryPromoted:"#00FF88",MemoryDemoted:"#FF6B35",MemorySuppressed:"#A33FFF",MemoryUnsuppressed:"#14E8C6",Rac1CascadeSwept:"#6E3FFF",SearchPerformed:"#818CF8",DeepReferenceCompleted:"#C4B5FD",HookVerdictRecorded:"#F59E0B",DreamStarted:"#9D00FF",DreamProgress:"#B44AFF",DreamCompleted:"#C084FC",ConsolidationStarted:"#FFB800",ConsolidationCompleted:"#FF9500",RetentionDecayed:"#FF4757",ConnectionDiscovered:"#00D4FF",ActivationSpread:"#14E8C6",ImportanceScored:"#FF3CAC",Heartbeat:"#8B95A5"};export{F as E,e as N}; diff --git a/apps/dashboard/build/_app/immutable/chunks/CcUbQ_Wl.js.br b/apps/dashboard/build/_app/immutable/chunks/CcUbQ_Wl.js.br deleted file mode 100644 index e5e0cfe..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/CcUbQ_Wl.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/CcUbQ_Wl.js.gz b/apps/dashboard/build/_app/immutable/chunks/CcUbQ_Wl.js.gz deleted file mode 100644 index 3d7c9cc..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/CcUbQ_Wl.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/Ccqjq5DS.js b/apps/dashboard/build/_app/immutable/chunks/Ccqjq5DS.js deleted file mode 100644 index da5bc31..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/Ccqjq5DS.js +++ /dev/null @@ -1 +0,0 @@ -import{i as R,w as A,ai as S,E as b,aj as g,aG as N,ak as w,al as B,G as F,F as E,h as I,z as O,y as Y,aw as _,ad as e}from"./CGq8RnJq.js";import{B as p}from"./W8qDZJD6.js";function G(a,r,n=!1){A&&S();var c=new p(a),i=n?b:0;function s(f,T){if(A){const h=g(a);var t;if(h===N?t=0:h===w?t=!1:t=parseInt(h.substring(1)),f!==t){var u=B();F(u),c.anchor=u,E(!1),c.ensure(f,T),E(!0);return}}c.ensure(f,T)}R(()=>{var f=!1;r((T,t=0)=>{f=!0,s(t,T)}),f||s(!1,null)},i)}function l(a,r){return a===r||(a==null?void 0:a[e])===r}function H(a={},r,n,c){return I(()=>{var i,s;return O(()=>{i=s,s=[],Y(()=>{a!==n(...s)&&(r(a,...s),i&&l(n(...i),a)&&r(null,...i))})}),()=>{_(()=>{s&&l(n(...s),a)&&r(null,...s)})}}),a}export{H as b,G as i}; diff --git a/apps/dashboard/build/_app/immutable/chunks/Ccqjq5DS.js.br b/apps/dashboard/build/_app/immutable/chunks/Ccqjq5DS.js.br deleted file mode 100644 index 7db8d4a..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/Ccqjq5DS.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/Ccqjq5DS.js.gz b/apps/dashboard/build/_app/immutable/chunks/Ccqjq5DS.js.gz deleted file mode 100644 index 9f86e9d..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/Ccqjq5DS.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/Ch9vNiEl.js b/apps/dashboard/build/_app/immutable/chunks/Ch9vNiEl.js deleted file mode 100644 index f50949a..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/Ch9vNiEl.js +++ /dev/null @@ -1 +0,0 @@ -import{c,w as g}from"./DAau0uzT.js";const v=200;function $(){const{subscribe:e,set:n,update:t}=g({connected:!1,reconnecting:!1,events:[],lastHeartbeat:null,error:null});let o=null,s=null,d=0;function m(i){const l=i||(window.location.port==="5173"?`ws://${window.location.hostname}:3927/ws`:`ws://${window.location.host}/ws`);if((o==null?void 0:o.readyState)!==WebSocket.OPEN)try{o=new WebSocket(l),o.onopen=()=>{d=0,t(r=>({...r,connected:!0,reconnecting:!1,error:null}))},o.onmessage=r=>{try{const u=JSON.parse(r.data);t(f=>{if(u.type==="Heartbeat")return{...f,lastHeartbeat:u};const w=[u,...f.events].slice(0,v);return{...f,events:w}})}catch(u){console.warn("[vestige] Failed to parse WebSocket message:",u)}},o.onclose=()=>{t(r=>({...r,connected:!1})),p(l)},o.onerror=()=>{t(r=>({...r,error:"WebSocket connection failed"}))}}catch(r){t(u=>({...u,error:String(r)}))}}function p(i){s&&clearTimeout(s),t(r=>({...r,reconnecting:!0}));const l=Math.min(1e3*2**d,3e4);d++,s=setTimeout(()=>m(i),l)}function b(){s&&clearTimeout(s),o==null||o.close(),o=null,n({connected:!1,reconnecting:!1,events:[],lastHeartbeat:null,error:null})}function y(){t(i=>({...i,events:[]}))}function h(i){t(l=>{const r=[i,...l.events].slice(0,v);return{...l,events:r}})}return{subscribe:e,connect:m,disconnect:b,clearEvents:y,injectEvent:h}}const a=$(),S=c(a,e=>e.connected),H=c(a,e=>e.reconnecting),T=c(a,e=>e.events);c(a,e=>e.lastHeartbeat);const M=c(a,e=>{var n,t;return((t=(n=e.lastHeartbeat)==null?void 0:n.data)==null?void 0:t.memory_count)??0}),k=c(a,e=>{var n,t;return((t=(n=e.lastHeartbeat)==null?void 0:n.data)==null?void 0:t.avg_retention)??0}),_=c(a,e=>{var n,t;return((t=(n=e.lastHeartbeat)==null?void 0:n.data)==null?void 0:t.suppressed_count)??0}),W=c(a,e=>{var n,t;return((t=(n=e.lastHeartbeat)==null?void 0:n.data)==null?void 0:t.uptime_secs)??0}),N=c(a,e=>e.events.filter(n=>n.type==="TraceEvent")),P=c(a,e=>{var t;const n=e.events.find(o=>o.type==="TraceEvent");return((t=n==null?void 0:n.data)==null?void 0:t.run_id)??null}),R=c(a,e=>e.events.find(n=>n.type==="TraceEvent")??null),C=c(a,e=>e.events.filter(n=>n.type==="MemoryPrOpened"||n.type==="MemoryPrDecided"));function F(e){if(!Number.isFinite(e)||e<0)return"—";const n=Math.floor(e/86400),t=Math.floor(e%86400/3600),o=Math.floor(e%3600/60),s=Math.floor(e%60);return n>0?t>0?`${n}d ${t}h`:`${n}d`:t>0?o>0?`${t}h ${o}m`:`${t}h`:o>0?s>0?`${o}m ${s}s`:`${o}m`:`${s}s`}export{S as a,P as b,M as c,k as d,T as e,F as f,H as i,R as l,C as m,_ as s,N as t,W as u,a as w}; diff --git a/apps/dashboard/build/_app/immutable/chunks/Ch9vNiEl.js.br b/apps/dashboard/build/_app/immutable/chunks/Ch9vNiEl.js.br deleted file mode 100644 index 4bfc8a0..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/Ch9vNiEl.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/Ch9vNiEl.js.gz b/apps/dashboard/build/_app/immutable/chunks/Ch9vNiEl.js.gz deleted file mode 100644 index 560100c..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/Ch9vNiEl.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/CkiUhdKe.js b/apps/dashboard/build/_app/immutable/chunks/CkiUhdKe.js deleted file mode 100644 index d50d685..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/CkiUhdKe.js +++ /dev/null @@ -1,376 +0,0 @@ -import{C as mt,S as vg,I as Ag,c as Rg,G as ll,d as _t,e as Ku,a as Yn,f as Zs,g as Js,W as ln,h as Pn,B as Ct,i as dl,j as Cg,D as zs,k as oa,P as hl,V as j,L as pl,N as en,l as Eg,m as fl,n as wg,o as Mg,p as Bg,q as Fg,r as Ug,s as Pg,t as Dg,E as gl,M as ml,R as Ss,u as ft,v as _o,w as Xs,x as ms,b as Ye,y as Me,z as ze,U as Le,F as yl,A as xl,J as Lg,K as Ig,O as Xu,Q as Ys,T as Vg,X as Gg,Y as Yu,Z as Og,_ as tn,$ as Tl,a0 as kg,a1 as _l,a2 as aa,a3 as vs,H as pt,a4 as ss,a5 as kt,a6 as Ie,a7 as Dn,a8 as zg,a9 as Wg,aa as ua,ab as fr,ac as Ln,ad as $g,ae as Hg,af as Ur,ag as bl,ah as qg,ai as Kg,aj as Xg,ak as Yg,al as ot,am as jg,an as Nl,ao as Qg,ap as bo,aq as Sl,ar as sn,as as ju,at as Zg,au as Jg,av as vl,aw as q,ax as em,ay as tm,az as No,aA as js,aB as sm,aC as nm,aD as rm,aE as im,aF as om,aG as am,aH as um,aI as cm,aJ as lm,aK as dm,aL as hm,aM as pm,aN as fm,aO as gm,aP as jn,aQ as Qn,aR as mm,aS as oi,aT as ai,aU as ui,aV as ys,aW as ym,aX as ci,aY as ca,aZ as li,a_ as So,a$ as bt,b0 as Al,b1 as Rl,b2 as Cl,b3 as El,b4 as wl,b5 as Ml,b6 as Bl,b7 as Fl,b8 as Ul,b9 as Gs,ba as Pl,bb as Dl,bc as Ll,bd as Il,be as Vl,bf as Gl,bg as Ol,bh as kl,bi as zl,bj as Wl,bk as $l,bl as xm,bm as Tm,bn as _m,bo as Hl,bp as $r,bq as Hr,br as qr,bs as ql,bt as Kl,bu as Xl,bv as Yl,bw as jl,bx as Ql,by as Zl,bz as Jl,bA as bm,bB as Nm,bC as ed,bD as An,bE as Rn,bF as Ws,bG as Sm,bH as la,bI as vm,bJ as Am,bK as da,bL as ha,bM as pa,bN as fa,bO as Li,bP as Pr,bQ as Dr,bR as Lr,bS as Qu,bT as Zu,bU as Ju,bV as ec,bW as tc,bX as vo,bY as Ao,bZ as Ro,b_ as Co,b$ as Eo,c0 as wo,c1 as Mo,c2 as Bo,c3 as Fo,c4 as Uo,c5 as Po,c6 as Do,c7 as Lo,c8 as Io,c9 as Vo,ca as Go,cb as Ii,cc as Rm,cd as sc,ce as nc,cf as rc,cg as Cm,ch as Em,ci as wm,cj as Mm,ck as Bm,cl as Fm,cm as Um,cn as Pm,co as Dm,cp as Lm,cq as Im,cr as Vm,cs as Gm,ct as Om,cu as km,cv as zm,cw as Wm,cx as $m,cy as Hm,cz as qm,cA as Km,cB as td,cC as Xm}from"./Bo4EDkTQ.js";import{cD as RR,cE as CR,cF as ER,cG as wR,cH as MR,cI as BR,cJ as FR,cK as UR,cL as PR,cM as DR,cN as LR,cO as IR,cP as VR,cQ as GR,cR as OR,cS as kR,cT as zR,cU as WR,cV as $R,cW as HR,cX as qR,cY as KR,cZ as XR,c_ as YR,c$ as jR,d0 as QR,d1 as ZR,d2 as JR,d3 as e0,d4 as t0,d5 as s0,d6 as n0,d7 as r0,d8 as i0,d9 as o0,da as a0,db as u0,dc as c0,dd as l0,de as d0,df as h0,dg as p0,dh as f0,di as g0,dj as m0,dk as y0,dl as x0,dm as T0,dn as _0,dp as b0,dq as N0,dr as S0,ds as v0,dt as A0,du as R0,dv as C0,dw as E0,dx as w0,dy as M0,dz as B0,dA as F0,dB as U0,dC as P0,dD as D0,dE as L0,dF as I0,dG as V0,dH as G0,dI as O0,dJ as k0,dK as z0,dL as W0,dM as $0,dN as H0,dO as q0,dP as K0,dQ as X0,dR as Y0,dS as j0,dT as Q0,dU as Z0,dV as J0,dW as eC,dX as tC,dY as sC,dZ as nC,d_ as rC,d$ as iC,e0 as oC,e1 as aC,e2 as uC,e3 as cC,e4 as lC,e5 as dC,e6 as hC,e7 as pC,e8 as fC,e9 as gC,ea as mC,eb as yC,ec as xC,ed as TC,ee as _C,ef as bC,eg as NC,eh as SC,ei as vC,ej as AC,ek as RC,el as CC,em as EC,en as wC,eo as MC,ep as BC,eq as FC,er as UC,es as PC,et as DC,eu as LC,ev as IC,ew as VC,ex as GC,ey as OC,ez as kC,eA as zC,eB as WC,eC as $C,eD as HC,eE as qC,eF as KC,eG as XC,eH as YC,eI as jC,eJ as QC,eK as ZC,eL as JC,eM as eE,eN as tE,eO as sE,eP as nE,eQ as rE,eR as iE,eS as oE,eT as aE,eU as uE,eV as cE,eW as lE,eX as dE,eY as hE,eZ as pE,e_ as fE,e$ as gE,f0 as mE,f1 as yE,f2 as xE,f3 as TE,f4 as _E,f5 as bE,f6 as NE,f7 as SE,f8 as vE,f9 as AE,fa as RE,fb as CE,fc as EE,fd as wE,fe as ME,ff as BE,fg as FE,fh as UE,fi as PE,fj as DE,fk as LE,fl as IE,fm as VE,fn as GE,fo as OE,fp as kE,fq as zE,fr as WE,fs as $E,ft as HE,fu as qE,fv as KE,fw as XE,fx as YE,fy as jE,fz as QE,fA as ZE}from"./Bo4EDkTQ.js";/** - * @license - * Copyright 2010-2024 Three.js Authors - * SPDX-License-Identifier: MIT - */const Ym=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveMap","envMap","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class jm{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=Ym,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){const{geometry:s,material:n,object:r}=e;if(t={material:this.getMaterialData(n),geometry:{attributes:this.getAttributesData(s.attributes),indexVersion:s.index?s.index.version:null,drawRange:{start:s.drawRange.start,count:s.drawRange.count}},worldMatrix:r.matrixWorld.clone()},r.center&&(t.center=r.center.clone()),r.morphTargetInfluences&&(t.morphTargetInfluences=r.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){const{width:i,height:a}=e.context;t.bufferWidth=i,t.bufferHeight=a}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const s in e){const n=e[s];t[s]={version:n.version}}return t}containsNode(e){const t=e.material;for(const s in t)if(t[s]&&t[s].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const s of this.refreshUniforms){const n=e[s];n!=null&&(typeof n=="object"&&n.clone!==void 0?n.isTexture===!0?t[s]={id:n.id,version:n.version}:t[s]=n.clone():t[s]=n)}return t}equals(e){const{object:t,material:s,geometry:n}=e,r=this.getRenderObjectData(e);if(r.worldMatrix.equals(t.matrixWorld)!==!0)return r.worldMatrix.copy(t.matrixWorld),!1;const i=r.material;for(const m in i){const x=i[m],N=s[m];if(x.equals!==void 0){if(x.equals(N)===!1)return x.copy(N),!1}else if(N.isTexture===!0){if(x.id!==N.id||x.version!==N.version)return x.id=N.id,x.version=N.version,!1}else if(x!==N)return i[m]=N,!1}if(i.transmission>0){const{width:m,height:x}=e.context;if(r.bufferWidth!==m||r.bufferHeight!==x)return r.bufferWidth=m,r.bufferHeight=x,!1}const a=r.geometry,u=n.attributes,c=a.attributes,l=Object.keys(c),d=Object.keys(u);if(l.length!==d.length)return r.geometry.attributes=this.getAttributesData(u),!1;for(const m of l){const x=c[m],N=u[m];if(N===void 0)return delete c[m],!1;if(x.version!==N.version)return x.version=N.version,!1}const h=n.index,p=a.indexVersion,f=h?h.version:null;if(p!==f)return a.indexVersion=f,!1;if(a.drawRange.start!==n.drawRange.start||a.drawRange.count!==n.drawRange.count)return a.drawRange.start=n.drawRange.start,a.drawRange.count=n.drawRange.count,!1;if(r.morphTargetInfluences){let m=!1;for(let x=0;x>>16,2246822507),t^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&s)+(t>>>0)}const ga=o=>In(o),Zn=o=>In(o),di=(...o)=>In(o);function ma(o,e=!1){const t=[];o.isNode===!0&&(t.push(o.id),o=o.getSelf());for(const{property:s,childNode:n}of Vn(o))t.push(t,In(s.slice(0,-4)),n.getCacheKey(e));return In(t)}function*Vn(o,e=!1){for(const t in o){if(t.startsWith("_")===!0)continue;const s=o[t];if(Array.isArray(s)===!0)for(let n=0;ne.charCodeAt(0)).buffer}var cR=Object.freeze({__proto__:null,arrayBufferToBase64:Na,base64ToArrayBuffer:Sa,getCacheKey:ma,getDataFromObject:ba,getLengthFromType:Ta,getNodeChildren:Vn,getTypeFromLength:ya,getTypedArrayFromType:xa,getValueFromType:_a,getValueType:Ot,hash:di,hashArray:Zn,hashString:ga});const Oo={VERTEX:"vertex",FRAGMENT:"fragment"},W={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Zm={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Ve={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},sd=["fragment","vertex"],ko=["setup","analyze","generate"],zo=[...sd,"compute"],As=["x","y","z","w"];let Jm=0;class O extends gl{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=W.NONE,this.updateBeforeType=W.NONE,this.updateAfterType=W.NONE,this.uuid=ml.generateUUID(),this.version=0,this.global=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Jm++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,W.FRAME)}onRenderUpdate(e){return this.onUpdate(e,W.RENDER)}onObjectUpdate(e){return this.onUpdate(e,W.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Vn(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=di(ma(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let s=0;for(const n of this.getChildren())t["node"+s++]=n;return t.outputNode||null}analyze(e){if(e.increaseUsage(this)===1){const s=e.getNodeProperties(this);for(const n of Object.values(s))n&&n.isNode===!0&&n.build(e)}}generate(e,t){const{outputNode:s}=e.getNodeProperties(this);if(s&&s.isNode===!0)return s.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const s=this.getShared(e);if(this!==s)return s.build(e,t);e.addNode(this),e.addChain(this);let n=null;const r=e.getBuildStage();if(r==="setup"){this.updateReference(e);const i=e.getNodeProperties(this);if(i.initialized!==!0){i.initialized=!0;const a=this.setup(e),u=a&&a.isNode===!0;for(const c of Object.values(i))c&&c.isNode===!0&&c.build(e);u&&a.build(e),i.outputNode=a}}else if(r==="analyze")this.analyze(e);else if(r==="generate")if(this.generate.length===1){const a=this.getNodeType(e),u=e.getDataFromNode(this);n=u.snippet,n===void 0?(n=this.generate(e)||"",u.snippet=n):u.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),n=e.format(n,a,t)}else n=this.generate(e,t)||"";return e.removeChain(this),e.addSequentialNode(this),n}getSerializeChildren(){return Vn(this)}serialize(e){const t=this.getSerializeChildren(),s={};for(const{property:n,index:r,childNode:i}of t)r!==void 0?(s[n]===void 0&&(s[n]=Number.isInteger(r)?[]:{}),s[n][r]=i.toJSON(e.meta).uuid):s[n]=i.toJSON(e.meta).uuid;Object.keys(s).length>0&&(e.inputNodes=s)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const s in e.inputNodes)if(Array.isArray(e.inputNodes[s])){const n=[];for(const r of e.inputNodes[s])n.push(t[r]);this[s]=n}else if(typeof e.inputNodes[s]=="object"){const n={};for(const r in e.inputNodes[s]){const i=e.inputNodes[s][r];n[r]=t[i]}this[s]=n}else{const n=e.inputNodes[s];this[s]=t[n]}}}toJSON(e){const{uuid:t,type:s}=this,n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{},nodes:{}});let r=e.nodes[t];r===void 0&&(r={uuid:t,type:s,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},n!==!0&&(e.nodes[r.uuid]=r),this.serialize(r),delete r.meta);function i(a){const u=[];for(const c in a){const l=a[c];delete l.metadata,u.push(l)}return u}if(n){const a=i(e.textures),u=i(e.images),c=i(e.nodes);a.length>0&&(r.textures=a),u.length>0&&(r.images=u),c.length>0&&(r.nodes=c)}return r}}class Rs extends O{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.node.build(e),s=this.indexNode.build(e,"uint");return`${t}[ ${s} ]`}}class nd extends O{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let s=null;for(const n of this.convertTo.split("|"))(s===null||e.getTypeLength(t)===e.getTypeLength(n))&&(s=n);return s}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const s=this.node,n=this.getNodeType(e),r=s.build(e,n);return e.format(r,n,t)}}class be extends O{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!=="void"&&t!=="void"&&this.hasDependencies(e)){const i=super.build(e,n),a=e.getVarFromNode(this,null,n),u=e.getPropertyName(a);return e.addLineFlowCode(`${u} = ${i}`,this),r.snippet=i,r.propertyName=u,e.format(r.propertyName,n,t)}}return super.build(e,t)}}class ey extends be{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,s)=>t+e.getTypeLength(s.getNodeType(e)),0))}generate(e,t){const s=this.getNodeType(e),n=this.nodes,r=e.getComponentType(s),i=[];for(const u of n){let c=u.build(e);const l=e.getComponentType(u.getNodeType(e));l!==r&&(c=e.format(c,l,r)),i.push(c)}const a=`${e.getType(s)}( ${i.join(", ")} )`;return e.format(a,s,t)}}const ty=As.join("");class Wo extends O{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(As.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const s=this.node,n=e.getTypeLength(s.getNodeType(e));let r=null;if(n>1){let i=null;this.getVectorLength()>=n&&(i=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const u=s.build(e,i);this.components.length===n&&this.components===ty.slice(0,this.components.length)?r=e.format(u,i,t):r=e.format(`${u}.${this.components}`,this.getNodeType(e),t)}else r=s.build(e,t);return r}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class sy extends be{static get type(){return"SetNode"}constructor(e,t,s){super(),this.sourceNode=e,this.components=t,this.targetNode=s}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:s,targetNode:n}=this,r=this.getNodeType(e),i=e.getComponentType(n.getNodeType(e)),a=e.getTypeFromLength(s.length,i),u=n.build(e,a),c=t.build(e,r),l=e.getTypeLength(r),d=[];for(let h=0;ho.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),oc=o=>rd(o).split("").sort().join(""),id={setup(o,e){const t=e.shift();return o(Jn(t),...e)},get(o,e,t){if(typeof e=="string"&&o[e]===void 0){if(o.isStackNode!==!0&&e==="assign")return(...s)=>(nn.assign(t,...s),t);if($s.has(e)){const s=$s.get(e);return o.isStackNode?(...n)=>t.add(s(...n)):(...n)=>s(t,...n)}else{if(e==="self")return o;if(e.endsWith("Assign")&&$s.has(e.slice(0,e.length-6))){const s=$s.get(e.slice(0,e.length-6));return o.isStackNode?(...n)=>t.assign(n[0],s(...n)):(...n)=>t.assign(s(t,...n))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=rd(e),E(new Wo(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=oc(e.slice(3).toLowerCase()),s=>E(new sy(o,e,s));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=oc(e.slice(4).toLowerCase()),()=>E(new ny(E(o),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),E(new Wo(o,e));if(/^\d+$/.test(e)===!0)return E(new Rs(t,new yt(Number(e),"uint")))}}}return Reflect.get(o,e,t)},set(o,e,t,s){return typeof e=="string"&&o[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(s[e].assign(t),!0):Reflect.set(o,e,t,s)}},Vi=new WeakMap,ac=new WeakMap,ry=function(o,e=null){const t=Ot(o);if(t==="node"){let s=Vi.get(o);return s===void 0&&(s=new Proxy(o,id),Vi.set(o,s),Vi.set(s,s)),s}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return E($o(o,e));if(t==="shader")return b(o)}return o},iy=function(o,e=null){for(const t in o)o[t]=E(o[t],e);return o},oy=function(o,e=null){const t=o.length;for(let s=0;sE(s!==null?Object.assign(r,s):r);return e===null?(...r)=>n(new o(...xs(r))):t!==null?(t=E(t),(...r)=>n(new o(e,...xs(r),t))):(...r)=>n(new o(e,...xs(r)))},uy=function(o,...e){return E(new o(...xs(e)))};class cy extends O{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:s}=this,n=e.getNodeProperties(t);if(n.onceOutput)return n.onceOutput;let r=null;if(t.layout){let i=ac.get(e.constructor);i===void 0&&(i=new WeakMap,ac.set(e.constructor,i));let a=i.get(t);a===void 0&&(a=E(e.buildFunctionNode(t)),i.set(t,a)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(a),r=E(a.call(s))}else{const i=t.jsFunc,a=s!==null?i(s,e):i(e);r=E(a)}return t.once&&(n.onceOutput=r),r}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class ly extends O{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Jn(e),E(new cy(this,e))}setup(){return this.call()}}const dy=[!1,!0],hy=[0,1,2,3],py=[-1,-2],od=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],Aa=new Map;for(const o of dy)Aa.set(o,new yt(o));const Ra=new Map;for(const o of hy)Ra.set(o,new yt(o,"uint"));const Ca=new Map([...Ra].map(o=>new yt(o.value,"int")));for(const o of py)Ca.set(o,new yt(o,"int"));const hi=new Map([...Ca].map(o=>new yt(o.value)));for(const o of od)hi.set(o,new yt(o));for(const o of od)hi.set(-o,new yt(-o));const pi={bool:Aa,uint:Ra,ints:Ca,float:hi},uc=new Map([...Aa,...hi]),$o=(o,e)=>uc.has(o)?uc.get(o):o.isNode===!0?o:new yt(o,e),fy=o=>{try{return o.getNodeType()}catch{return}},ve=function(o,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(o)&&t.every(n=>typeof n!="object"))&&(t=[_a(o,...t)]),t.length===1&&e!==null&&e.has(t[0]))return E(e.get(t[0]));if(t.length===1){const n=$o(t[0],o);return fy(n)===o?E(n):E(new nd(n,o))}const s=t.map(n=>$o(n));return E(new ey(s,o))}},Gn=o=>typeof o=="object"&&o!==null?o.value:o,ad=o=>o!=null?o.nodeType||o.convertTo||(typeof o=="string"?o:null):null;function Cn(o,e){return new Proxy(new ly(o,e),id)}const E=(o,e=null)=>ry(o,e),Jn=(o,e=null)=>new iy(o,e),xs=(o,e=null)=>new oy(o,e),C=(...o)=>new ay(...o),U=(...o)=>new uy(...o),b=(o,e)=>{const t=new Cn(o,e),s=(...n)=>{let r;return Jn(n),n[0]&&n[0].isNode?r=[...n]:r=n[0],t.call(r)};return s.shaderNode=t,s.setLayout=n=>(t.setLayout(n),s),s.once=()=>(t.once=!0,s),s},gy=(...o)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),b(...o));R("toGlobal",o=>(o.global=!0,o));const On=o=>{nn=o},Ea=()=>nn,z=(...o)=>nn.If(...o);function ud(o){return nn&&nn.add(o),o}R("append",ud);const cd=new ve("color"),g=new ve("float",pi.float),y=new ve("int",pi.ints),D=new ve("uint",pi.uint),Ht=new ve("bool",pi.bool),M=new ve("vec2"),Ae=new ve("ivec2"),ld=new ve("uvec2"),dd=new ve("bvec2"),T=new ve("vec3"),hd=new ve("ivec3"),dn=new ve("uvec3"),wa=new ve("bvec3"),P=new ve("vec4"),pd=new ve("ivec4"),fd=new ve("uvec4"),gd=new ve("bvec4"),fi=new ve("mat2"),Oe=new ve("mat3"),Ts=new ve("mat4"),my=(o="")=>E(new yt(o,"string")),yy=o=>E(new yt(o,"ArrayBuffer"));R("toColor",cd);R("toFloat",g);R("toInt",y);R("toUint",D);R("toBool",Ht);R("toVec2",M);R("toIVec2",Ae);R("toUVec2",ld);R("toBVec2",dd);R("toVec3",T);R("toIVec3",hd);R("toUVec3",dn);R("toBVec3",wa);R("toVec4",P);R("toIVec4",pd);R("toUVec4",fd);R("toBVec4",gd);R("toMat2",fi);R("toMat3",Oe);R("toMat4",Ts);const md=C(Rs),yd=(o,e)=>E(new nd(E(o),e)),xy=(o,e)=>E(new Wo(E(o),e));R("element",md);R("convert",yd);class xd extends O{static get type(){return"UniformGroupNode"}constructor(e,t=!1,s=1){super("string"),this.name=e,this.shared=t,this.order=s,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const Td=o=>new xd(o),Ma=(o,e=0)=>new xd(o,!0,e),_d=Ma("frame"),k=Ma("render"),Ba=Td("object");class er extends va{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Ba}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const s=this.getSelf();return e=e.bind(s),super.onUpdate(n=>{const r=e(n,s);r!==void 0&&(this.value=r)},t)}generate(e,t){const s=this.getNodeType(e),n=this.getUniformHash(e);let r=e.getNodeFromHash(n);r===void 0&&(e.setHashNode(this,n),r=this);const i=r.getInputType(e),a=e.getUniformFromNode(r,i,e.shaderStage,this.name||e.context.label),u=e.getPropertyName(a);return e.context.label!==void 0&&delete e.context.label,e.format(u,s,t)}}const V=(o,e)=>{const t=ad(e||o),s=o&&o.isNode===!0?o.node&&o.node.value||o.value:o;return E(new er(s,t))};class se extends O{static get type(){return"PropertyNode"}constructor(e,t=null,s=!1){super(e),this.name=t,this.varying=s,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const Fa=(o,e)=>E(new se(o,e)),et=(o,e)=>E(new se(o,e,!0)),ee=U(se,"vec4","DiffuseColor"),Ho=U(se,"vec3","EmissiveColor"),Nt=U(se,"float","Roughness"),kn=U(se,"float","Metalness"),Kr=U(se,"float","Clearcoat"),zn=U(se,"float","ClearcoatRoughness"),fs=U(se,"vec3","Sheen"),gi=U(se,"float","SheenRoughness"),mi=U(se,"float","Iridescence"),Ua=U(se,"float","IridescenceIOR"),Pa=U(se,"float","IridescenceThickness"),Xr=U(se,"float","AlphaT"),Zt=U(se,"float","Anisotropy"),En=U(se,"vec3","AnisotropyT"),_s=U(se,"vec3","AnisotropyB"),We=U(se,"color","SpecularColor"),Wn=U(se,"float","SpecularF90"),Yr=U(se,"float","Shininess"),$n=U(se,"vec4","Output"),bs=U(se,"float","dashSize"),Hn=U(se,"float","gapSize"),Ty=U(se,"float","pointWidth"),wn=U(se,"float","IOR"),jr=U(se,"float","Transmission"),Da=U(se,"float","Thickness"),La=U(se,"float","AttenuationDistance"),Ia=U(se,"color","AttenuationColor"),Va=U(se,"float","Dispersion");class _y extends be{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const s=e.getTypeLength(t.node.getNodeType(e));return As.join("").slice(0,s)!==t.components}return!1}generate(e,t){const{targetNode:s,sourceNode:n}=this,r=this.needsSplitAssign(e),i=s.getNodeType(e),a=s.context({assign:!0}).build(e),u=n.build(e,i),c=n.getNodeType(e),l=e.getDataFromNode(this);let d;if(l.initialized===!0)t!=="void"&&(d=a);else if(r){const h=e.getVarFromNode(this,null,i),p=e.getPropertyName(h);e.addLineFlowCode(`${p} = ${u}`,this);const f=s.node.context({assign:!0}).build(e);for(let m=0;m{const l=c.type,d=l==="pointer";let h;return d?h="&"+u.build(e):h=u.build(e,l),h};if(Array.isArray(r))for(let u=0;u(e=e.length>1||e[0]&&e[0].isNode===!0?xs(e):Jn(e[0]),E(new by(E(o),e)));R("call",Nd);class pe extends be{static get type(){return"OperatorNode"}constructor(e,t,s,...n){if(super(),n.length>0){let r=new pe(e,t,s);for(let i=0;i>"||s==="<<")return e.getIntegerType(i);if(s==="!"||s==="=="||s==="&&"||s==="||"||s==="^^")return"bool";if(s==="<"||s===">"||s==="<="||s===">="){const u=t?e.getTypeLength(t):Math.max(e.getTypeLength(i),e.getTypeLength(a));return u>1?`bvec${u}`:"bool"}else return i==="float"&&e.isMatrix(a)?a:e.isMatrix(i)&&e.isVector(a)?e.getVectorFromMatrix(i):e.isVector(i)&&e.isMatrix(a)?e.getVectorFromMatrix(a):e.getTypeLength(a)>e.getTypeLength(i)?a:i}generate(e,t){const s=this.op,n=this.aNode,r=this.bNode,i=this.getNodeType(e,t);let a=null,u=null;i!=="void"?(a=n.getNodeType(e),u=typeof r<"u"?r.getNodeType(e):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="?e.isVector(a)?u=a:a!==u&&(a=u="float"):s===">>"||s==="<<"?(a=i,u=e.changeComponentType(u,"uint")):e.isMatrix(a)&&e.isVector(u)?u=e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(u)?a=e.getVectorFromMatrix(u):a=u=i):a=u=i;const c=n.build(e,a),l=typeof r<"u"?r.build(e,u):null,d=e.getTypeLength(t),h=e.getFunctionOperator(s);if(t!=="void")return s==="<"&&d>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${c}, ${l} )`,i,t):e.format(`( ${c} < ${l} )`,i,t):s==="<="&&d>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${c}, ${l} )`,i,t):e.format(`( ${c} <= ${l} )`,i,t):s===">"&&d>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${c}, ${l} )`,i,t):e.format(`( ${c} > ${l} )`,i,t):s===">="&&d>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${c}, ${l} )`,i,t):e.format(`( ${c} >= ${l} )`,i,t):s==="!"||s==="~"?e.format(`(${s}${c})`,a,t):h?e.format(`${h}( ${c}, ${l} )`,i,t):e.format(`( ${c} ${s} ${l} )`,i,t);if(a!=="void")return h?e.format(`${h}( ${c}, ${l} )`,i,t):e.format(`${c} ${s} ${l}`,i,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const _e=C(pe,"+"),Y=C(pe,"-"),$=C(pe,"*"),gt=C(pe,"/"),Ga=C(pe,"%"),Sd=C(pe,"=="),vd=C(pe,"!="),Ad=C(pe,"<"),Oa=C(pe,">"),Rd=C(pe,"<="),Cd=C(pe,">="),Ed=C(pe,"&&"),wd=C(pe,"||"),Md=C(pe,"!"),Bd=C(pe,"^^"),Fd=C(pe,"&"),Ud=C(pe,"~"),Pd=C(pe,"|"),Dd=C(pe,"^"),Ld=C(pe,"<<"),Id=C(pe,">>");R("add",_e);R("sub",Y);R("mul",$);R("div",gt);R("modInt",Ga);R("equal",Sd);R("notEqual",vd);R("lessThan",Ad);R("greaterThan",Oa);R("lessThanEqual",Rd);R("greaterThanEqual",Cd);R("and",Ed);R("or",wd);R("not",Md);R("xor",Bd);R("bitAnd",Fd);R("bitNot",Ud);R("bitOr",Pd);R("bitXor",Dd);R("shiftLeft",Ld);R("shiftRight",Id);const Vd=(...o)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),Ga(...o));R("remainder",Vd);class S extends be{static get type(){return"MathNode"}constructor(e,t,s=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=s,this.cNode=n}getInputType(e){const t=this.aNode.getNodeType(e),s=this.bNode?this.bNode.getNodeType(e):null,n=this.cNode?this.cNode.getNodeType(e):null,r=e.isMatrix(t)?0:e.getTypeLength(t),i=e.isMatrix(s)?0:e.getTypeLength(s),a=e.isMatrix(n)?0:e.getTypeLength(n);return r>i&&r>a?t:i>a?s:a>r?n:t}getNodeType(e){const t=this.method;return t===S.LENGTH||t===S.DISTANCE||t===S.DOT?"float":t===S.CROSS?"vec3":t===S.ALL?"bool":t===S.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===S.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){let s=this.method;const n=this.getNodeType(e),r=this.getInputType(e),i=this.aNode,a=this.bNode,u=this.cNode,c=e.renderer.coordinateSystem;if(s===S.TRANSFORM_DIRECTION){let l=i,d=a;e.isMatrix(l.getNodeType(e))?d=P(T(d),0):l=P(T(l),0);const h=$(l,d).xyz;return qt(h).build(e,t)}else{if(s===S.NEGATE)return e.format("( - "+i.build(e,r)+" )",n,t);if(s===S.ONE_MINUS)return Y(1,i).build(e,t);if(s===S.RECIPROCAL)return gt(1,i).build(e,t);if(s===S.DIFFERENCE)return oe(Y(i,a)).build(e,t);{const l=[];return s===S.CROSS||s===S.MOD?l.push(i.build(e,n),a.build(e,n)):c===Pn&&s===S.STEP?l.push(i.build(e,e.getTypeLength(i.getNodeType(e))===1?"float":r),a.build(e,r)):c===Pn&&(s===S.MIN||s===S.MAX)||s===S.MOD?l.push(i.build(e,r),a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":r)):s===S.REFRACT?l.push(i.build(e,r),a.build(e,r),u.build(e,"float")):s===S.MIX?l.push(i.build(e,r),a.build(e,r),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":r)):(c===ln&&s===S.ATAN&&a!==null&&(s="atan2"),l.push(i.build(e,r)),a!==null&&l.push(a.build(e,r)),u!==null&&l.push(u.build(e,r))),e.format(`${e.getMethod(s,n)}( ${l.join(", ")} )`,n,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}S.ALL="all";S.ANY="any";S.RADIANS="radians";S.DEGREES="degrees";S.EXP="exp";S.EXP2="exp2";S.LOG="log";S.LOG2="log2";S.SQRT="sqrt";S.INVERSE_SQRT="inversesqrt";S.FLOOR="floor";S.CEIL="ceil";S.NORMALIZE="normalize";S.FRACT="fract";S.SIN="sin";S.COS="cos";S.TAN="tan";S.ASIN="asin";S.ACOS="acos";S.ATAN="atan";S.ABS="abs";S.SIGN="sign";S.LENGTH="length";S.NEGATE="negate";S.ONE_MINUS="oneMinus";S.DFDX="dFdx";S.DFDY="dFdy";S.ROUND="round";S.RECIPROCAL="reciprocal";S.TRUNC="trunc";S.FWIDTH="fwidth";S.TRANSPOSE="transpose";S.BITCAST="bitcast";S.EQUALS="equals";S.MIN="min";S.MAX="max";S.MOD="mod";S.STEP="step";S.REFLECT="reflect";S.DISTANCE="distance";S.DIFFERENCE="difference";S.DOT="dot";S.CROSS="cross";S.POW="pow";S.TRANSFORM_DIRECTION="transformDirection";S.MIX="mix";S.CLAMP="clamp";S.REFRACT="refract";S.SMOOTHSTEP="smoothstep";S.FACEFORWARD="faceforward";const Gd=g(1e-6),Ny=g(1e6),Qr=g(Math.PI),Sy=g(Math.PI*2),ka=C(S,S.ALL),Od=C(S,S.ANY),kd=C(S,S.RADIANS),zd=C(S,S.DEGREES),za=C(S,S.EXP),rn=C(S,S.EXP2),yi=C(S,S.LOG),vt=C(S,S.LOG2),Pt=C(S,S.SQRT),Wa=C(S,S.INVERSE_SQRT),At=C(S,S.FLOOR),xi=C(S,S.CEIL),qt=C(S,S.NORMALIZE),Xt=C(S,S.FRACT),st=C(S,S.SIN),It=C(S,S.COS),Wd=C(S,S.TAN),$d=C(S,S.ASIN),Hd=C(S,S.ACOS),$a=C(S,S.ATAN),oe=C(S,S.ABS),qn=C(S,S.SIGN),zt=C(S,S.LENGTH),qd=C(S,S.NEGATE),Kd=C(S,S.ONE_MINUS),Ha=C(S,S.DFDX),qa=C(S,S.DFDY),Xd=C(S,S.ROUND),Yd=C(S,S.RECIPROCAL),Ka=C(S,S.TRUNC),jd=C(S,S.FWIDTH),Qd=C(S,S.TRANSPOSE),vy=C(S,S.BITCAST),Zd=C(S,S.EQUALS),Re=C(S,S.MIN),ue=C(S,S.MAX),Xa=C(S,S.MOD),Ti=C(S,S.STEP),Jd=C(S,S.REFLECT),eh=C(S,S.DISTANCE),th=C(S,S.DIFFERENCE),is=C(S,S.DOT),_i=C(S,S.CROSS),ht=C(S,S.POW),Ya=C(S,S.POW,2),sh=C(S,S.POW,3),nh=C(S,S.POW,4),rh=C(S,S.TRANSFORM_DIRECTION),ih=o=>$(qn(o),ht(oe(o),1/3)),ja=o=>is(o,o),Q=C(S,S.MIX),Et=(o,e=0,t=1)=>E(new S(S.CLAMP,E(o),E(e),E(t))),oh=o=>Et(o),Qa=C(S,S.REFRACT),ct=C(S,S.SMOOTHSTEP),Za=C(S,S.FACEFORWARD),ah=b(([o])=>{const s=43758.5453,n=is(o.xy,M(12.9898,78.233)),r=Xa(n,Qr);return Xt(st(r).mul(s))}),uh=(o,e,t)=>Q(e,t,o),ch=(o,e,t)=>ct(e,t,o),lh=(o,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),$a(o,e)),Ay=Za,Ry=Wa;R("all",ka);R("any",Od);R("equals",Zd);R("radians",kd);R("degrees",zd);R("exp",za);R("exp2",rn);R("log",yi);R("log2",vt);R("sqrt",Pt);R("inverseSqrt",Wa);R("floor",At);R("ceil",xi);R("normalize",qt);R("fract",Xt);R("sin",st);R("cos",It);R("tan",Wd);R("asin",$d);R("acos",Hd);R("atan",$a);R("abs",oe);R("sign",qn);R("length",zt);R("lengthSq",ja);R("negate",qd);R("oneMinus",Kd);R("dFdx",Ha);R("dFdy",qa);R("round",Xd);R("reciprocal",Yd);R("trunc",Ka);R("fwidth",jd);R("atan2",lh);R("min",Re);R("max",ue);R("mod",Xa);R("step",Ti);R("reflect",Jd);R("distance",eh);R("dot",is);R("cross",_i);R("pow",ht);R("pow2",Ya);R("pow3",sh);R("pow4",nh);R("transformDirection",rh);R("mix",uh);R("clamp",Et);R("refract",Qa);R("smoothstep",ch);R("faceForward",Za);R("difference",th);R("saturate",oh);R("cbrt",ih);R("transpose",Qd);R("rand",ah);class Cy extends O{static get type(){return"ConditionalNode"}constructor(e,t,s=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=s}getNodeType(e){const{ifNode:t,elseNode:s}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);const n=t.getNodeType(e);if(s!==null){const r=s.getNodeType(e);if(e.getTypeLength(r)>e.getTypeLength(n))return r}return n}setup(e){const t=this.condNode.cache(),s=this.ifNode.cache(),n=this.elseNode?this.elseNode.cache():null,r=e.context.nodeBlock;e.getDataFromNode(s).parentNodeBlock=r,n!==null&&(e.getDataFromNode(n).parentNodeBlock=r);const i=e.getNodeProperties(this);i.condNode=t,i.ifNode=s.context({nodeBlock:s}),i.elseNode=n?n.context({nodeBlock:n}):null}generate(e,t){const s=this.getNodeType(e),n=e.getDataFromNode(this);if(n.nodeProperty!==void 0)return n.nodeProperty;const{condNode:r,ifNode:i,elseNode:a}=e.getNodeProperties(this),u=t!=="void",c=u?Fa(s).build(e):"";n.nodeProperty=c;const l=r.build(e,"bool");e.addFlowCode(` -${e.tab}if ( ${l} ) { - -`).addFlowTab();let d=i.build(e,s);if(d&&(u?d=c+" = "+d+";":d="return "+d+";"),e.removeFlowTab().addFlowCode(e.tab+" "+d+` - -`+e.tab+"}"),a!==null){e.addFlowCode(` else { - -`).addFlowTab();let h=a.build(e,s);h&&(u?h=c+" = "+h+";":h="return "+h+";"),e.removeFlowTab().addFlowCode(e.tab+" "+h+` - -`+e.tab+`} - -`)}else e.addFlowCode(` - -`);return e.format(c,s,t)}}const Ue=C(Cy);R("select",Ue);const dh=(...o)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),Ue(...o));R("cond",dh);class hh extends O{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const s=this.node.build(e);return e.setContext(t),s}generate(e,t){const s=e.getContext();e.setContext({...e.context,...this.value});const n=this.node.build(e,t);return e.setContext(s),n}}const bi=C(hh),ph=(o,e)=>bi(o,{label:e});R("context",bi);R("label",ph);class Ir extends O{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:s}=this,n=e.getVarFromNode(this,s,e.getVectorType(this.getNodeType(e))),r=e.getPropertyName(n),i=t.build(e,n.type);return e.addLineFlowCode(`${r} = ${i}`,this),r}}const fh=C(Ir);R("toVar",(...o)=>fh(...o).append());const gh=o=>(console.warn('TSL: "temp" is deprecated. Use ".toVar()" instead.'),fh(o));R("temp",gh);class Ey extends O{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let s=t.varying;if(s===void 0){const n=this.name,r=this.getNodeType(e);t.varying=s=e.getVaryingFromNode(this,n,r),t.node=this.node}return s.needsInterpolation||(s.needsInterpolation=e.shaderStage==="fragment"),s}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),s=this.setupVarying(e),n=e.shaderStage==="fragment"&&t.reassignPosition===!0&&e.context.needsPositionReassign;if(t.propertyName===void 0||n){const r=this.getNodeType(e),i=e.getPropertyName(s,Oo.VERTEX);e.flowNodeFromShaderStage(Oo.VERTEX,this.node,r,i),t.propertyName=i,n?t.reassignPosition=!1:t.reassignPosition===void 0&&e.context.isPositionNodeInput&&(t.reassignPosition=!0)}return e.getPropertyName(s)}}const ke=C(Ey),mh=o=>ke(o);R("varying",ke);R("vertexStage",mh);const yh=b(([o])=>{const e=o.mul(.9478672986).add(.0521327014).pow(2.4),t=o.mul(.0773993808),s=o.lessThanEqual(.04045);return Q(e,t,s)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),xh=b(([o])=>{const e=o.pow(.41666).mul(1.055).sub(.055),t=o.mul(12.92),s=o.lessThanEqual(.0031308);return Q(e,t,s)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),tr="WorkingColorSpace",Ja="OutputColorSpace";class sr extends be{static get type(){return"ColorSpaceNode"}constructor(e,t,s){super("vec4"),this.colorNode=e,this.source=t,this.target=s}resolveColorSpace(e,t){return t===tr?_t.workingColorSpace:t===Ja?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,s=this.resolveColorSpace(e,this.source),n=this.resolveColorSpace(e,this.target);let r=t;return _t.enabled===!1||s===n||!s||!n||(_t.getTransfer(s)===Ku&&(r=P(yh(r.rgb),r.a)),_t.getPrimaries(s)!==_t.getPrimaries(n)&&(r=P(Oe(_t._getMatrix(new Yn,s,n)).mul(r.rgb),r.a)),_t.getTransfer(n)===Ku&&(r=P(xh(r.rgb),r.a))),r}}const Th=o=>E(new sr(E(o),tr,Ja)),_h=o=>E(new sr(E(o),Ja,tr)),bh=(o,e)=>E(new sr(E(o),tr,e)),eu=(o,e)=>E(new sr(E(o),e,tr)),wy=(o,e,t)=>E(new sr(E(o),e,t));R("toOutputColorSpace",Th);R("toWorkingColorSpace",_h);R("workingToColorSpace",bh);R("colorSpaceToWorking",eu);let My=class extends Rs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),s=this.referenceNode.getNodeType(),n=this.getNodeType();return e.format(t,s,n)}};class Nh extends O{static get type(){return"ReferenceBaseNode"}constructor(e,t,s=null,n=null){super(),this.property=e,this.uniformType=t,this.object=s,this.count=n,this.properties=e.split("."),this.reference=s,this.node=null,this.group=null,this.updateType=W.OBJECT}setGroup(e){return this.group=e,this}element(e){return E(new My(this,E(e)))}setNodeType(e){const t=V(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let s=e[t[0]];for(let n=1;nE(new Nh(o,e,t));class Fy extends Nh{static get type(){return"RendererReferenceNode"}constructor(e,t,s=null){super(e,t,s),this.renderer=s,this.setGroup(k)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const Sh=(o,e,t=null)=>E(new Fy(o,e,t));class Uy extends be{static get type(){return"ToneMappingNode"}constructor(e,t=Ah,s=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=s}customCacheKey(){return di(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,s=this.toneMapping;if(s===ss)return t;let n=null;const r=e.renderer.library.getToneMappingFunction(s);return r!==null?n=P(r(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",s),n=t),n}}const vh=(o,e,t)=>E(new Uy(o,E(e),E(t))),Ah=Sh("toneMappingExposure","float");R("toneMapping",(o,e,t)=>vh(e,t,o));class Py extends va{static get type(){return"BufferAttributeNode"}constructor(e,t=null,s=0,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=s,this.bufferOffset=n,this.usage=vg,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),s=this.value,n=e.getTypeLength(t),r=this.bufferStride||n,i=this.bufferOffset,a=s.isInterleavedBuffer===!0?s:new Ag(s,r),u=new Rg(a,n,i);a.setUsage(this.usage),this.attribute=u,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),s=e.getBufferAttributeFromNode(this,t),n=e.getPropertyName(s);let r=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=n,r=n):r=ke(this).build(e,t),r}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const nr=(o,e=null,t=0,s=0)=>E(new Py(o,e,t,s)),Rh=(o,e=null,t=0,s=0)=>nr(o,e,t,s).setUsage(zs),Zr=(o,e=null,t=0,s=0)=>nr(o,e,t,s).setInstanced(!0),qo=(o,e=null,t=0,s=0)=>Rh(o,e,t,s).setInstanced(!0);R("toAttribute",o=>nr(o.value));class Dy extends O{static get type(){return"ComputeNode"}constructor(e,t,s=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=s,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=W.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let s=t[0];for(let n=1;nE(new Dy(E(o),e,t));R("compute",Ch);class Ly extends O{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const n=this.node.getNodeType(e);return e.setCache(t),n}build(e,...t){const s=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);const r=this.node.build(e,...t);return e.setCache(s),r}}const Mn=(o,e)=>E(new Ly(E(o),e));R("cache",Mn);class Iy extends O{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const Eh=C(Iy);R("bypass",Eh);class wh extends O{static get type(){return"RemapNode"}constructor(e,t,s,n=g(0),r=g(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=s,this.outLowNode=n,this.outHighNode=r,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:s,outLowNode:n,outHighNode:r,doClamp:i}=this;let a=e.sub(t).div(s.sub(t));return i===!0&&(a=a.clamp()),a.mul(r.sub(n)).add(n)}}const Mh=C(wh,null,null,{doClamp:!1}),Bh=C(wh);R("remap",Mh);R("remapClamp",Bh);class Vr extends O{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const s=this.getNodeType(e),n=this.snippet;if(s==="void")e.addLineFlowCode(n,this);else return e.format(`( ${n} )`,s,t)}}const rs=C(Vr),Fh=o=>(o?Ue(o,rs("discard")):rs("discard")).append(),Vy=()=>rs("return").append();R("discard",Fh);class Gy extends be{static get type(){return"RenderOutputNode"}constructor(e,t,s){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=s,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const s=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||ss,n=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Dn;return s!==ss&&(t=t.toneMapping(s)),n!==Dn&&n!==_t.workingColorSpace&&(t=t.workingToColorSpace(n)),t}}const tu=(o,e=null,t=null)=>E(new Gy(E(o),e,t));R("renderOutput",tu);function Oy(o){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",o)}class Uh extends O{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const s=this.getAttributeName(e);if(e.hasGeometryAttribute(s)){const n=e.geometry.getAttribute(s);t=e.getTypeFromAttribute(n)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),s=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),a=e.getAttribute(t,i);return e.shaderStage==="vertex"?e.format(a.name,i,s):ke(this).build(e,s)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(s)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const we=(o,e)=>E(new Uh(o,e)),le=(o=0)=>we("uv"+(o>0?o:""),"vec2");class ky extends O{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const s=this.textureNode.build(e,"property"),n=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${s}, ${n} )`,this.getNodeType(e),t)}}const ns=C(ky);class zy extends er{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=W.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,s=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(s&&s.width!==void 0){const{width:n,height:r}=s;this.value=Math.log2(Math.max(n,r))}}}const Ph=C(zy);class wt extends er{static get type(){return"TextureNode"}constructor(e,t=null,s=null,n=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=s,this.biasNode=n,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=W.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===Le?"uvec4":this.value.type===ze?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return le(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=V(this.value.matrix)),this._matrixUniform.mul(T(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?W.RENDER:W.NONE,this}setupUV(e,t){const s=this.value;return e.isFlipY()&&(s.image instanceof ImageBitmap&&s.flipY===!0||s.isRenderTargetTexture===!0||s.isFramebufferTexture===!0||s.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(y(ns(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const s=this.value;if(!s||s.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let n=this.uvNode;(n===null||e.context.forceUVContext===!0)&&e.context.getUV&&(n=e.context.getUV(this)),n||(n=this.getDefaultUV()),this.updateMatrix===!0&&(n=this.getTransformedUV(n)),n=this.setupUV(e,n);let r=this.levelNode;r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),t.uvNode=n,t.levelNode=r,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,t,s,n,r,i,a,u){const c=this.value;let l;return n?l=e.generateTextureLevel(c,t,s,n,i):r?l=e.generateTextureBias(c,t,s,r,i):u?l=e.generateTextureGrad(c,t,s,u,i):a?l=e.generateTextureCompare(c,t,s,a,i):this.sampler===!1?l=e.generateTextureLoad(c,t,s,i):l=e.generateTexture(c,t,s,i),l}generate(e,t){const s=this.value,n=e.getNodeProperties(this),r=super.generate(e,"property");if(t==="sampler")return r+"_sampler";if(e.isReference(t))return r;{const i=e.getDataFromNode(this);let a=i.propertyName;if(a===void 0){const{uvNode:l,levelNode:d,biasNode:h,compareNode:p,depthNode:f,gradNode:m}=n,x=this.generateUV(e,l),N=d?d.build(e,"float"):null,v=h?h.build(e,"float"):null,w=f?f.build(e,"int"):null,B=p?p.build(e,"float"):null,F=m?[m[0].build(e,"vec2"),m[1].build(e,"vec2")]:null,L=e.getVarFromNode(this);a=e.getPropertyName(L);const I=this.generateSnippet(e,r,x,N,v,w,B,F);e.addLineFlowCode(`${a} = ${I}`,this),i.snippet=I,i.propertyName=a}let u=a;const c=this.getNodeType(e);return e.needsToWorkingColorSpace(s)&&(u=eu(rs(u,c),s.colorSpace).setup(e).build(e,c)),e.format(u,c,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=E(e),t.referenceNode=this.getSelf(),E(t)}blur(e){const t=this.clone();return t.biasNode=E(e).mul(Ph(t)),t.referenceNode=this.getSelf(),E(t)}level(e){const t=this.clone();return t.levelNode=E(e),t.referenceNode=this.getSelf(),E(t)}size(e){return ns(this,e)}bias(e){const t=this.clone();return t.biasNode=E(e),t.referenceNode=this.getSelf(),E(t)}compare(e){const t=this.clone();return t.compareNode=E(e),t.referenceNode=this.getSelf(),E(t)}grad(e,t){const s=this.clone();return s.gradNode=[E(e),E(t)],s.referenceNode=this.getSelf(),E(s)}depth(e){const t=this.clone();return t.depthNode=E(e),t.referenceNode=this.getSelf(),E(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}const K=C(wt),ge=(...o)=>K(...o).setSampler(!1),Wy=o=>(o.isNode===!0?o:K(o)).convert("sampler"),Jt=V("float").label("cameraNear").setGroup(k).onRenderUpdate(({camera:o})=>o.near),es=V("float").label("cameraFar").setGroup(k).onRenderUpdate(({camera:o})=>o.far),He=V("mat4").label("cameraProjectionMatrix").setGroup(k).onRenderUpdate(({camera:o})=>o.projectionMatrix),$y=V("mat4").label("cameraProjectionMatrixInverse").setGroup(k).onRenderUpdate(({camera:o})=>o.projectionMatrixInverse),je=V("mat4").label("cameraViewMatrix").setGroup(k).onRenderUpdate(({camera:o})=>o.matrixWorldInverse),Hy=V("mat4").label("cameraWorldMatrix").setGroup(k).onRenderUpdate(({camera:o})=>o.matrixWorld),qy=V("mat3").label("cameraNormalMatrix").setGroup(k).onRenderUpdate(({camera:o})=>o.normalMatrix),su=V(new j).label("cameraPosition").setGroup(k).onRenderUpdate(({camera:o},e)=>e.value.setFromMatrixPosition(o.matrixWorld));class J extends O{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=W.OBJECT,this._uniformNode=new er(null)}getNodeType(){const e=this.scope;if(e===J.WORLD_MATRIX)return"mat4";if(e===J.POSITION||e===J.VIEW_POSITION||e===J.DIRECTION||e===J.SCALE)return"vec3"}update(e){const t=this.object3d,s=this._uniformNode,n=this.scope;if(n===J.WORLD_MATRIX)s.value=t.matrixWorld;else if(n===J.POSITION)s.value=s.value||new j,s.value.setFromMatrixPosition(t.matrixWorld);else if(n===J.SCALE)s.value=s.value||new j,s.value.setFromMatrixScale(t.matrixWorld);else if(n===J.DIRECTION)s.value=s.value||new j,t.getWorldDirection(s.value);else if(n===J.VIEW_POSITION){const r=e.camera;s.value=s.value||new j,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(r.matrixWorldInverse)}}generate(e){const t=this.scope;return t===J.WORLD_MATRIX?this._uniformNode.nodeType="mat4":(t===J.POSITION||t===J.VIEW_POSITION||t===J.DIRECTION||t===J.SCALE)&&(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}J.WORLD_MATRIX="worldMatrix";J.POSITION="position";J.SCALE="scale";J.VIEW_POSITION="viewPosition";J.DIRECTION="direction";const Ky=C(J,J.DIRECTION),Xy=C(J,J.WORLD_MATRIX),Dh=C(J,J.POSITION),Yy=C(J,J.SCALE),jy=C(J,J.VIEW_POSITION);class Mt extends J{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Qy=U(Mt,Mt.DIRECTION),at=U(Mt,Mt.WORLD_MATRIX),Zy=U(Mt,Mt.POSITION),Jy=U(Mt,Mt.SCALE),ex=U(Mt,Mt.VIEW_POSITION),Lh=V(new Yn).onObjectUpdate(({object:o},e)=>e.value.getNormalMatrix(o.matrixWorld)),Ih=V(new Ie).onObjectUpdate(({object:o},e)=>e.value.copy(o.matrixWorld).invert()),Kt=b(o=>o.renderer.nodes.modelViewMatrix||Vh).once()().toVar("modelViewMatrix"),Vh=je.mul(at),tx=b(o=>(o.context.isHighPrecisionModelViewMatrix=!0,V("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),sx=b(o=>{const e=o.context.isHighPrecisionModelViewMatrix;return V("mat3").onObjectUpdate(({object:t,camera:s})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),Ce=we("position","vec3"),me=Ce.varying("positionLocal"),Jr=Ce.varying("positionPrevious"),Wt=at.mul(me).xyz.varying("v_positionWorld").context({needsPositionReassign:!0}),nu=me.transformDirection(at).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection").context({needsPositionReassign:!0}),xe=b(o=>o.context.setupPositionView(),"vec3").once()().varying("v_positionView").context({needsPositionReassign:!0}),ae=xe.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class nx extends O{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:s}=e;return t.coordinateSystem===Pn&&s.side===Ct?"false":e.getFrontFacing()}}const Gh=U(nx),rr=g(Gh).mul(2).sub(1),Ni=we("normal","vec3"),Xe=b(o=>o.geometry.hasAttribute("normal")===!1?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),T(0,1,0)):Ni,"vec3").once()().toVar("normalLocal"),Oh=xe.dFdx().cross(xe.dFdy()).normalize().toVar("normalFlat"),lt=b(o=>{let e;return o.material.flatShading===!0?e=Oh:e=ke(ru(Xe),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),Si=ke(lt.transformDirection(je),"v_normalWorld").normalize().toVar("normalWorld"),fe=b(o=>o.context.setupNormal(),"vec3").once()().mul(rr).toVar("transformedNormalView"),vi=fe.transformDirection(je).toVar("transformedNormalWorld"),Hs=b(o=>o.context.setupClearcoatNormal(),"vec3").once()().mul(rr).toVar("transformedClearcoatNormalView"),kh=b(([o,e=at])=>{const t=Oe(e),s=o.div(T(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(s).xyz}),ru=b(([o],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(o);const s=Lh.mul(o);return je.transformDirection(s)}),zh=V(0).onReference(({material:o})=>o).onRenderUpdate(({material:o})=>o.refractionRatio),Wh=ae.negate().reflect(fe),$h=ae.negate().refract(fe,zh),Hh=Wh.transformDirection(je).toVar("reflectVector"),qh=$h.transformDirection(je).toVar("reflectVector");class rx extends wt{static get type(){return"CubeTextureNode"}constructor(e,t=null,s=null,n=null){super(e,t,s,n),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===Zs?Hh:e.mapping===Js?qh:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),T(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const s=this.value;return e.renderer.coordinateSystem===ln||!s.isRenderTargetTexture?T(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const on=C(rx);class iu extends er{static get type(){return"BufferNode"}constructor(e,t,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=s}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const ir=(o,e,t)=>E(new iu(o,e,t));class ix extends Rs{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),s=this.getNodeType(),n=this.node.getPaddedType();return e.format(t,n,s)}}class Kh extends iu{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Ot(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=W.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,s=this.elementType;if(s==="float"||s==="int"||s==="uint")for(let n=0;nE(new Kh(o,e)),ox=(o,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),E(new Kh(o,e)));class ax extends Rs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),s=this.referenceNode.getNodeType(),n=this.getNodeType();return e.format(t,s,n)}}class Ai extends O{static get type(){return"ReferenceNode"}constructor(e,t,s=null,n=null){super(),this.property=e,this.uniformType=t,this.object=s,this.count=n,this.properties=e.split("."),this.reference=s,this.node=null,this.group=null,this.name=null,this.updateType=W.OBJECT}element(e){return E(new ax(this,E(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;this.count!==null?t=ir(null,e,this.count):Array.isArray(this.getValueFromReference())?t=Gt(null,e):e==="texture"?t=K(null):e==="cubeTexture"?t=on(null):t=V(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let s=e[t[0]];for(let n=1;nE(new Ai(o,e,t)),Ko=(o,e,t,s)=>E(new Ai(o,e,s,t));class ux extends Ai{static get type(){return"MaterialReferenceNode"}constructor(e,t,s=null){super(e,t,s),this.material=s,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const dt=(o,e,t=null)=>E(new ux(o,e,t)),Ri=b(o=>(o.geometry.hasAttribute("tangent")===!1&&o.geometry.computeTangents(),we("tangent","vec4")))(),or=Ri.xyz.toVar("tangentLocal"),ar=Kt.mul(P(or,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),Xh=ar.transformDirection(je).varying("v_tangentWorld").normalize().toVar("tangentWorld"),ou=ar.toVar("transformedTangentView"),cx=ou.transformDirection(je).normalize().toVar("transformedTangentWorld"),ur=o=>o.mul(Ri.w).xyz,lx=ke(ur(Ni.cross(Ri)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),dx=ke(ur(Xe.cross(or)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),Yh=ke(ur(lt.cross(ar)),"v_bitangentView").normalize().toVar("bitangentView"),hx=ke(ur(Si.cross(Xh)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),jh=ur(fe.cross(ou)).normalize().toVar("transformedBitangentView"),px=jh.transformDirection(je).normalize().toVar("transformedBitangentWorld"),gs=Oe(ar,Yh,lt),Qh=ae.mul(gs),fx=(o,e)=>o.sub(Qh.mul(e)),Zh=(()=>{let o=_s.cross(ae);return o=o.cross(_s).normalize(),o=Q(o,fe,Zt.mul(Nt.oneMinus()).oneMinus().pow2().pow2()).normalize(),o})(),gx=b(o=>{const{eye_pos:e,surf_norm:t,mapN:s,uv:n}=o,r=e.dFdx(),i=e.dFdy(),a=n.dFdx(),u=n.dFdy(),c=t,l=i.cross(c),d=c.cross(r),h=l.mul(a.x).add(d.mul(u.x)),p=l.mul(a.y).add(d.mul(u.y)),f=h.dot(h).max(p.dot(p)),m=rr.mul(f.inverseSqrt());return _e(h.mul(s.x,m),p.mul(s.y,m),c.mul(s.z)).normalize()});class mx extends be{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=Yu}setup(e){const{normalMapType:t,scaleNode:s}=this;let n=this.node.mul(2).sub(1);s!==null&&(n=T(n.xy.mul(s),n.z));let r=null;return t===Og?r=ru(n):t===Yu&&(e.hasGeometryAttribute("tangent")===!0?r=gs.mul(n).normalize():r=gx({eye_pos:xe,surf_norm:lt,mapN:n,uv:le()})),r}}const Xo=C(mx),yx=b(({textureNode:o,bumpScale:e})=>{const t=n=>o.cache().context({getUV:r=>n(r.uvNode||le()),forceUVContext:!0}),s=g(t(n=>n));return M(g(t(n=>n.add(n.dFdx()))).sub(s),g(t(n=>n.add(n.dFdy()))).sub(s)).mul(e)}),xx=b(o=>{const{surf_pos:e,surf_norm:t,dHdxy:s}=o,n=e.dFdx().normalize(),r=e.dFdy().normalize(),i=t,a=r.cross(i),u=i.cross(n),c=n.dot(a).mul(rr),l=c.sign().mul(s.x.mul(a).add(s.y.mul(u)));return c.abs().mul(t).sub(l).normalize()});class Tx extends be{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=yx({textureNode:this.textureNode,bumpScale:e});return xx({surf_pos:xe,surf_norm:lt,dHdxy:t})}}const Jh=C(Tx),cc=new Map;class A extends O{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let s=cc.get(e);return s===void 0&&(s=dt(e,t),cc.set(e,s)),s}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,s=this.scope;let n=null;if(s===A.COLOR){const r=t.color!==void 0?this.getColor(s):T();t.map&&t.map.isTexture===!0?n=r.mul(this.getTexture("map")):n=r}else if(s===A.OPACITY){const r=this.getFloat(s);t.alphaMap&&t.alphaMap.isTexture===!0?n=r.mul(this.getTexture("alpha")):n=r}else if(s===A.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?n=this.getTexture("specular").r:n=g(1);else if(s===A.SPECULAR_INTENSITY){const r=this.getFloat(s);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?n=r.mul(this.getTexture(s).a):n=r}else if(s===A.SPECULAR_COLOR){const r=this.getColor(s);t.specularColorMap&&t.specularColorMap.isTexture===!0?n=r.mul(this.getTexture(s).rgb):n=r}else if(s===A.ROUGHNESS){const r=this.getFloat(s);t.roughnessMap&&t.roughnessMap.isTexture===!0?n=r.mul(this.getTexture(s).g):n=r}else if(s===A.METALNESS){const r=this.getFloat(s);t.metalnessMap&&t.metalnessMap.isTexture===!0?n=r.mul(this.getTexture(s).b):n=r}else if(s===A.EMISSIVE){const r=this.getFloat("emissiveIntensity"),i=this.getColor(s).mul(r);t.emissiveMap&&t.emissiveMap.isTexture===!0?n=i.mul(this.getTexture(s)):n=i}else if(s===A.NORMAL)t.normalMap?(n=Xo(this.getTexture("normal"),this.getCache("normalScale","vec2")),n.normalMapType=t.normalMapType):t.bumpMap?n=Jh(this.getTexture("bump").r,this.getFloat("bumpScale")):n=lt;else if(s===A.CLEARCOAT){const r=this.getFloat(s);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?n=r.mul(this.getTexture(s).r):n=r}else if(s===A.CLEARCOAT_ROUGHNESS){const r=this.getFloat(s);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?n=r.mul(this.getTexture(s).r):n=r}else if(s===A.CLEARCOAT_NORMAL)t.clearcoatNormalMap?n=Xo(this.getTexture(s),this.getCache(s+"Scale","vec2")):n=lt;else if(s===A.SHEEN){const r=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?n=r.mul(this.getTexture("sheenColor").rgb):n=r}else if(s===A.SHEEN_ROUGHNESS){const r=this.getFloat(s);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?n=r.mul(this.getTexture(s).a):n=r,n=n.clamp(.07,1)}else if(s===A.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const r=this.getTexture(s);n=fi(Os.x,Os.y,Os.y.negate(),Os.x).mul(r.rg.mul(2).sub(M(1)).normalize().mul(r.b))}else n=Os;else if(s===A.IRIDESCENCE_THICKNESS){const r=ne("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=ne("0","float",t.iridescenceThicknessRange);n=r.sub(i).mul(this.getTexture(s).g).add(i)}else n=r}else if(s===A.TRANSMISSION){const r=this.getFloat(s);t.transmissionMap?n=r.mul(this.getTexture(s).r):n=r}else if(s===A.THICKNESS){const r=this.getFloat(s);t.thicknessMap?n=r.mul(this.getTexture(s).g):n=r}else if(s===A.IOR)n=this.getFloat(s);else if(s===A.LIGHT_MAP)n=this.getTexture(s).rgb.mul(this.getFloat("lightMapIntensity"));else if(s===A.AO)n=this.getTexture(s).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const r=this.getNodeType(e);n=this.getCache(s,r)}return n}}A.ALPHA_TEST="alphaTest";A.COLOR="color";A.OPACITY="opacity";A.SHININESS="shininess";A.SPECULAR="specular";A.SPECULAR_STRENGTH="specularStrength";A.SPECULAR_INTENSITY="specularIntensity";A.SPECULAR_COLOR="specularColor";A.REFLECTIVITY="reflectivity";A.ROUGHNESS="roughness";A.METALNESS="metalness";A.NORMAL="normal";A.CLEARCOAT="clearcoat";A.CLEARCOAT_ROUGHNESS="clearcoatRoughness";A.CLEARCOAT_NORMAL="clearcoatNormal";A.EMISSIVE="emissive";A.ROTATION="rotation";A.SHEEN="sheen";A.SHEEN_ROUGHNESS="sheenRoughness";A.ANISOTROPY="anisotropy";A.IRIDESCENCE="iridescence";A.IRIDESCENCE_IOR="iridescenceIOR";A.IRIDESCENCE_THICKNESS="iridescenceThickness";A.IOR="ior";A.TRANSMISSION="transmission";A.THICKNESS="thickness";A.ATTENUATION_DISTANCE="attenuationDistance";A.ATTENUATION_COLOR="attenuationColor";A.LINE_SCALE="scale";A.LINE_DASH_SIZE="dashSize";A.LINE_GAP_SIZE="gapSize";A.LINE_WIDTH="linewidth";A.LINE_DASH_OFFSET="dashOffset";A.POINT_WIDTH="pointWidth";A.DISPERSION="dispersion";A.LIGHT_MAP="light";A.AO="ao";const ep=U(A,A.ALPHA_TEST),an=U(A,A.COLOR),tp=U(A,A.SHININESS),sp=U(A,A.EMISSIVE),cr=U(A,A.OPACITY),np=U(A,A.SPECULAR),Yo=U(A,A.SPECULAR_INTENSITY),rp=U(A,A.SPECULAR_COLOR),Bn=U(A,A.SPECULAR_STRENGTH),Gr=U(A,A.REFLECTIVITY),ip=U(A,A.ROUGHNESS),op=U(A,A.METALNESS),ap=U(A,A.NORMAL).context({getUV:null}),up=U(A,A.CLEARCOAT),cp=U(A,A.CLEARCOAT_ROUGHNESS),lp=U(A,A.CLEARCOAT_NORMAL).context({getUV:null}),dp=U(A,A.ROTATION),hp=U(A,A.SHEEN),pp=U(A,A.SHEEN_ROUGHNESS),fp=U(A,A.ANISOTROPY),gp=U(A,A.IRIDESCENCE),mp=U(A,A.IRIDESCENCE_IOR),yp=U(A,A.IRIDESCENCE_THICKNESS),xp=U(A,A.TRANSMISSION),Tp=U(A,A.THICKNESS),_p=U(A,A.IOR),bp=U(A,A.ATTENUATION_DISTANCE),Np=U(A,A.ATTENUATION_COLOR),au=U(A,A.LINE_SCALE),uu=U(A,A.LINE_DASH_SIZE),cu=U(A,A.LINE_GAP_SIZE),Or=U(A,A.LINE_WIDTH),lu=U(A,A.LINE_DASH_OFFSET),Sp=U(A,A.POINT_WIDTH),vp=U(A,A.DISPERSION),du=U(A,A.LIGHT_MAP),Ap=U(A,A.AO),Os=V(new Ye).onReference(function(o){return o.material}).onRenderUpdate(function({material:o}){this.value.set(o.anisotropy*Math.cos(o.anisotropyRotation),o.anisotropy*Math.sin(o.anisotropyRotation))}),hu=b(o=>o.context.setupModelViewProjection(),"vec4").once()().varying("v_modelViewProjection");class de extends O{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),s=this.scope;let n;if(s===de.VERTEX)n=e.getVertexIndex();else if(s===de.INSTANCE)n=e.getInstanceIndex();else if(s===de.DRAW)n=e.getDrawIndex();else if(s===de.INVOCATION_LOCAL)n=e.getInvocationLocalIndex();else if(s===de.INVOCATION_SUBGROUP)n=e.getInvocationSubgroupIndex();else if(s===de.SUBGROUP)n=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+s);let r;return e.shaderStage==="vertex"||e.shaderStage==="compute"?r=n:r=ke(this).build(e,t),r}}de.VERTEX="vertex";de.INSTANCE="instance";de.SUBGROUP="subgroup";de.INVOCATION_LOCAL="invocationLocal";de.INVOCATION_SUBGROUP="invocationSubgroup";de.DRAW="draw";const Rp=U(de,de.VERTEX),lr=U(de,de.INSTANCE),_x=U(de,de.SUBGROUP),bx=U(de,de.INVOCATION_SUBGROUP),Nx=U(de,de.INVOCATION_LOCAL),Cp=U(de,de.DRAW);class Ep extends O{static get type(){return"InstanceNode"}constructor(e,t,s){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=s,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=W.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:s,instanceColor:n}=this;let{instanceMatrixNode:r,instanceColorNode:i}=this;if(r===null){if(t<=1e3)r=ir(s.array,"mat4",Math.max(t,1)).element(lr);else{const u=new Cg(s.array,16,1);this.buffer=u;const c=s.usage===zs?qo:Zr,l=[c(u,"vec4",16,0),c(u,"vec4",16,4),c(u,"vec4",16,8),c(u,"vec4",16,12)];r=Ts(...l)}this.instanceMatrixNode=r}if(n&&i===null){const u=new oa(n.array,3),c=n.usage===zs?qo:Zr;this.bufferColor=u,i=T(c(u,"vec3",3,0)),this.instanceColorNode=i}const a=r.mul(me).xyz;if(me.assign(a),e.hasGeometryAttribute("normal")){const u=kh(Xe,r);Xe.assign(u)}this.instanceColorNode!==null&&et("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==zs&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==zs&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const Sx=C(Ep);class vx extends Ep{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:s,instanceColor:n}=e;super(t,s,n),this.instancedMesh=e}}const wp=C(vx);class Ax extends O{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=lr:this.batchingIdNode=Cp);const s=b(([f])=>{const m=ns(ge(this.batchMesh._indirectTexture),0),x=y(f).modInt(y(m)),N=y(f).div(y(m));return ge(this.batchMesh._indirectTexture,Ae(x,N)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(y(this.batchingIdNode)),n=this.batchMesh._matricesTexture,r=ns(ge(n),0),i=g(s).mul(4).toInt().toVar(),a=i.modInt(r),u=i.div(y(r)),c=Ts(ge(n,Ae(a,u)),ge(n,Ae(a.add(1),u)),ge(n,Ae(a.add(2),u)),ge(n,Ae(a.add(3),u))),l=this.batchMesh._colorsTexture;if(l!==null){const m=b(([x])=>{const N=ns(ge(l),0).x,v=x,w=v.modInt(N),B=v.div(N);return ge(l,Ae(w,B)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(s);et("vec3","vBatchColor").assign(m)}const d=Oe(c);me.assign(c.mul(me));const h=Xe.div(T(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),p=d.mul(h).xyz;Xe.assign(p),e.hasGeometryAttribute("tangent")&&or.mulAssign(d)}}const Mp=C(Ax),lc=new WeakMap;class Bp extends O{static get type(){return"SkinningNode"}constructor(e,t=!1){super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=W.OBJECT,this.skinIndexNode=we("skinIndex","uvec4"),this.skinWeightNode=we("skinWeight","vec4");let s,n,r;t?(s=ne("bindMatrix","mat4"),n=ne("bindMatrixInverse","mat4"),r=Ko("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(s=V(e.bindMatrix,"mat4"),n=V(e.bindMatrixInverse,"mat4"),r=ir(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=s,this.bindMatrixInverseNode=n,this.boneMatricesNode=r,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=me){const{skinIndexNode:s,skinWeightNode:n,bindMatrixNode:r,bindMatrixInverseNode:i}=this,a=e.element(s.x),u=e.element(s.y),c=e.element(s.z),l=e.element(s.w),d=r.mul(t),h=_e(a.mul(n.x).mul(d),u.mul(n.y).mul(d),c.mul(n.z).mul(d),l.mul(n.w).mul(d));return i.mul(h).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=Xe){const{skinIndexNode:s,skinWeightNode:n,bindMatrixNode:r,bindMatrixInverseNode:i}=this,a=e.element(s.x),u=e.element(s.y),c=e.element(s.z),l=e.element(s.w);let d=_e(n.x.mul(a),n.y.mul(u),n.z.mul(c),n.w.mul(l));return d=i.mul(d).mul(r),d.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Ko("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Jr)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||ba(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&Jr.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(me.assign(t),e.hasGeometryAttribute("normal")){const s=this.getSkinnedNormal();Xe.assign(s),e.hasGeometryAttribute("tangent")&&or.assign(s)}}generate(e,t){if(t!=="void")return me.build(e,t)}update(e){const s=(this.useReference?e.object:this.skinnedMesh).skeleton;lc.get(s)!==e.frameId&&(lc.set(s,e.frameId),this.previousBoneMatricesNode!==null&&s.previousBoneMatrices.set(s.boneMatrices),s.update())}}const Rx=o=>E(new Bp(o)),Fp=o=>E(new Bp(o,!0));class Cx extends O{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const s={};for(let r=0,i=this.params.length-1;rNumber(d)?f=">=":f="<"));const x={start:l,end:d},N=x.start,v=x.end;let w="",B="",F="";m||(p==="int"||p==="uint"?f.includes("<")?m="++":m="--":f.includes("<")?m="+= 1.":m="-= 1."),w+=e.getVar(p,h)+" = "+N,B+=h+" "+f+" "+v,F+=h+" "+m;const L=`for ( ${w}; ${B}; ${F} )`;e.addFlowCode((a===0?` -`:"")+e.tab+L+` { - -`).addFlowTab()}const r=n.build(e,"void"),i=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(` -`+e.tab+r);for(let a=0,u=this.params.length-1;aE(new Cx(xs(o,"int"))).append(),Ex=()=>rs("continue").append(),pu=()=>rs("break").append(),wx=(...o)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),te(...o)),Gi=new WeakMap,Je=new Me,dc=b(({bufferMap:o,influence:e,stride:t,width:s,depth:n,offset:r})=>{const i=y(Rp).mul(t).add(r),a=i.div(s),u=i.sub(a.mul(s));return ge(o,Ae(u,a)).depth(n).mul(e)});function Mx(o){const e=o.morphAttributes.position!==void 0,t=o.morphAttributes.normal!==void 0,s=o.morphAttributes.color!==void 0,n=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,r=n!==void 0?n.length:0;let i=Gi.get(o);if(i===void 0||i.count!==r){let N=function(){m.dispose(),Gi.delete(o),o.removeEventListener("dispose",N)};i!==void 0&&i.texture.dispose();const a=o.morphAttributes.position||[],u=o.morphAttributes.normal||[],c=o.morphAttributes.color||[];let l=0;e===!0&&(l=1),t===!0&&(l=2),s===!0&&(l=3);let d=o.attributes.position.count*l,h=1;const p=4096;d>p&&(h=Math.ceil(d/p),d=p);const f=new Float32Array(d*h*4*r),m=new Yg(f,d,h,r);m.type=ot,m.needsUpdate=!0;const x=l*4;for(let v=0;v{const h=g(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?h.assign(ge(this.mesh.morphTexture,Ae(y(d).add(1),y(lr))).r):h.assign(ne("morphTargetInfluences","float").element(d).toVar()),s===!0&&me.addAssign(dc({bufferMap:a,influence:h,stride:u,width:l,depth:d,offset:y(0)})),n===!0&&Xe.addAssign(dc({bufferMap:a,influence:h,stride:u,width:l,depth:d,offset:y(1)}))})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,s)=>t+s,0)}}const Up=C(Bx);class hn extends O{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class Fx extends hn{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Ux extends hh{static get type(){return"LightingContextNode"}constructor(e,t=null,s=null,n=null){super(e),this.lightingModel=t,this.backdropNode=s,this.backdropAlphaNode=n,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,s=T().toVar("directDiffuse"),n=T().toVar("directSpecular"),r=T().toVar("indirectDiffuse"),i=T().toVar("indirectSpecular"),a={directDiffuse:s,directSpecular:n,indirectDiffuse:r,indirectSpecular:i};return{radiance:T().toVar("radiance"),irradiance:T().toVar("irradiance"),iblIrradiance:T().toVar("iblIrradiance"),ambientOcclusion:g(1).toVar("ambientOcclusion"),reflectedLight:a,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const Pp=C(Ux);class Px extends hn{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let fn,gn;class Se extends O{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===Se.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=W.NONE;return(this.scope===Se.SIZE||this.scope===Se.VIEWPORT)&&(e=W.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===Se.VIEWPORT?t!==null?gn.copy(t.viewport):(e.getViewport(gn),gn.multiplyScalar(e.getPixelRatio())):t!==null?(fn.width=t.width,fn.height=t.height):e.getDrawingBufferSize(fn)}setup(){const e=this.scope;let t=null;return e===Se.SIZE?t=V(fn||(fn=new Ye)):e===Se.VIEWPORT?t=V(gn||(gn=new Me)):t=M(dr.div(Kn)),t}generate(e){if(this.scope===Se.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const s=e.getNodeProperties(Kn).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${s}.y - ${t}.y )`}return t}return super.generate(e)}}Se.COORDINATE="coordinate";Se.VIEWPORT="viewport";Se.SIZE="size";Se.UV="uv";const Bt=U(Se,Se.UV),Kn=U(Se,Se.SIZE),dr=U(Se,Se.COORDINATE),$t=U(Se,Se.VIEWPORT),Dp=$t.zw,Lp=dr.sub($t.xy),Dx=Lp.div(Dp),Lx=b(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),Kn),"vec2").once()(),Ix=b(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),Bt),"vec2").once()(),Vx=b(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),Bt.flipY()),"vec2").once()(),mn=new Ye;class Ci extends wt{static get type(){return"ViewportTextureNode"}constructor(e=Bt,t=null,s=null){s===null&&(s=new bl,s.minFilter=ms),super(s,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=W.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(mn);const s=this.value;(s.image.width!==mn.width||s.image.height!==mn.height)&&(s.image.width=mn.width,s.image.height=mn.height,s.needsUpdate=!0);const n=s.generateMipmaps;s.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(s),s.generateMipmaps=n}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Gx=C(Ci),fu=C(Ci,null,null,{generateMipmaps:!0});let Oi=null;class Ox extends Ci{static get type(){return"ViewportDepthTextureNode"}constructor(e=Bt,t=null){Oi===null&&(Oi=new vs),super(e,t,Oi)}}const gu=C(Ox);class qe extends O{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===qe.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,s=this.valueNode;let n=null;if(t===qe.DEPTH_BASE)s!==null&&(n=Vp().assign(s));else if(t===qe.DEPTH)e.isPerspectiveCamera?n=Ip(xe.z,Jt,es):n=Qs(xe.z,Jt,es);else if(t===qe.LINEAR_DEPTH)if(s!==null)if(e.isPerspectiveCamera){const r=mu(s,Jt,es);n=Qs(r,Jt,es)}else n=s;else n=Qs(xe.z,Jt,es);return n}}qe.DEPTH_BASE="depthBase";qe.DEPTH="depth";qe.LINEAR_DEPTH="linearDepth";const Qs=(o,e,t)=>o.add(e).div(e.sub(t)),kx=(o,e,t)=>e.sub(t).mul(o).sub(e),Ip=(o,e,t)=>e.add(o).mul(t).div(t.sub(e).mul(o)),mu=(o,e,t)=>e.mul(t).div(t.sub(e).mul(o).sub(t)),yu=(o,e,t)=>{e=e.max(1e-6).toVar();const s=vt(o.negate().div(e)),n=vt(t.div(e));return s.div(n)},zx=(o,e,t)=>{const s=o.mul(yi(t.div(e)));return g(Math.E).pow(s).mul(e).negate()},Vp=C(qe,qe.DEPTH_BASE),xu=U(qe,qe.DEPTH),ei=C(qe,qe.LINEAR_DEPTH),Wx=ei(gu());xu.assign=o=>Vp(o);class $x extends O{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const Hx=C($x);class ut extends O{static get type(){return"ClippingNode"}constructor(e=ut.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:s,unionPlanes:n}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===ut.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(s,n):this.scope===ut.HARDWARE?this.setupHardwareClipping(n,e):this.setupDefault(s,n)}setupAlphaToCoverage(e,t){return b(()=>{const s=g().toVar("distanceToPlane"),n=g().toVar("distanceToGradient"),r=g(1).toVar("clipOpacity"),i=t.length;if(this.hardwareClipping===!1&&i>0){const u=Gt(t);te(i,({i:c})=>{const l=u.element(c);s.assign(xe.dot(l.xyz).negate().add(l.w)),n.assign(s.fwidth().div(2)),r.mulAssign(ct(n.negate(),n,s))})}const a=e.length;if(a>0){const u=Gt(e),c=g(1).toVar("intersectionClipOpacity");te(a,({i:l})=>{const d=u.element(l);s.assign(xe.dot(d.xyz).negate().add(d.w)),n.assign(s.fwidth().div(2)),c.mulAssign(ct(n.negate(),n,s).oneMinus())}),r.mulAssign(c.oneMinus())}ee.a.mulAssign(r),ee.a.equal(0).discard()})()}setupDefault(e,t){return b(()=>{const s=t.length;if(this.hardwareClipping===!1&&s>0){const r=Gt(t);te(s,({i})=>{const a=r.element(i);xe.dot(a.xyz).greaterThan(a.w).discard()})}const n=e.length;if(n>0){const r=Gt(e),i=Ht(!0).toVar("clipped");te(n,({i:a})=>{const u=r.element(a);i.assign(xe.dot(u.xyz).greaterThan(u.w).and(i))}),i.discard()}})()}setupHardwareClipping(e,t){const s=e.length;return t.enableHardwareClipping(s),b(()=>{const n=Gt(e),r=Hx(t.getClipDistance());te(s,({i})=>{const a=n.element(i),u=xe.dot(a.xyz).sub(a.w).negate();r.element(i).assign(u)})})()}}ut.ALPHA_TO_COVERAGE="alphaToCoverage";ut.DEFAULT="default";ut.HARDWARE="hardware";const qx=()=>E(new ut),Kx=()=>E(new ut(ut.ALPHA_TO_COVERAGE)),Xx=()=>E(new ut(ut.HARDWARE)),Yx=.05,hc=b(([o])=>Xt($(1e4,st($(17,o.x).add($(.1,o.y)))).mul(_e(.1,oe(st($(13,o.y).add(o.x))))))),pc=b(([o])=>hc(M(hc(o.xy),o.z))),jx=b(([o])=>{const e=ue(zt(Ha(o.xyz)),zt(qa(o.xyz))),t=g(1).div(g(Yx).mul(e)).toVar("pixScale"),s=M(rn(At(vt(t))),rn(xi(vt(t)))),n=M(pc(At(s.x.mul(o.xyz))),pc(At(s.y.mul(o.xyz)))),r=Xt(vt(t)),i=_e($(r.oneMinus(),n.x),$(r,n.y)),a=Re(r,r.oneMinus()),u=T(i.mul(i).div($(2,a).mul(Y(1,a))),i.sub($(.5,a)).div(Y(1,a)),Y(1,Y(1,i).mul(Y(1,i)).div($(2,a).mul(Y(1,a))))),c=i.lessThan(a.oneMinus()).select(i.lessThan(a).select(u.x,u.y),u.z);return Et(c,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class ce extends Xu{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.shadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+ma(this)}build(e){this.setup(e)}setupObserver(e){return new jm(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,s=t.getRenderTarget();e.addStack();const n=this.vertexNode||this.setupVertex(e);e.stack.outputNode=n,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let r;const i=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(s!==null?s.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const a=this.setupLighting(e);i!==null&&e.stack.add(i);const u=P(a,ee.a).max(0);if(r=this.setupOutput(e,u),$n.assign(r),this.outputNode!==null&&(r=this.outputNode),s!==null){const c=t.getMRT(),l=this.mrtNode;c!==null?(r=c,l!==null&&(r=c.merge(l))):l!==null&&(r=l)}}else{let a=this.fragmentNode;a.isOutputStructNode!==!0&&(a=P(a)),r=this.setupOutput(e,a)}e.stack.outputNode=r,e.addFlow("fragment",e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:s}=e.clippingContext;let n=null;if(t.length>0||s.length>0){const r=e.renderer.samples;this.alphaToCoverage&&r>1?n=Kx():e.stack.add(qx())}return n}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(Xx()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:s}=e;let n=this.depthNode;if(n===null){const r=t.getMRT();r&&r.has("depth")?n=r.get("depth"):t.logarithmicDepthBuffer===!0&&(s.isPerspectiveCamera?n=yu(xe.z,Jt,es):n=Qs(xe.z,Jt,es))}n!==null&&xu.assign(n).append()}setupPositionView(){return Kt.mul(me).xyz}setupModelViewProjection(){return He.mul(xe)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),hu}setupPosition(e){const{object:t,geometry:s}=e;if((s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color)&&Up(t).append(),t.isSkinnedMesh===!0&&Fp(t).append(),this.displacementMap){const n=dt("displacementMap","texture"),r=dt("displacementScale","float"),i=dt("displacementBias","float");me.addAssign(Xe.normalize().mul(n.x.mul(r).add(i)))}return t.isBatchedMesh&&Mp(t).append(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&wp(t).append(),this.positionNode!==null&&me.assign(this.positionNode.context({isPositionNodeInput:!0})),me}setupDiffuseColor({object:e,geometry:t}){let s=this.colorNode?P(this.colorNode):an;this.vertexColors===!0&&t.hasAttribute("color")&&(s=P(s.xyz.mul(we("color","vec3")),s.a)),e.instanceColor&&(s=et("vec3","vInstanceColor").mul(s)),e.isBatchedMesh&&e._colorsTexture&&(s=et("vec3","vBatchColor").mul(s)),ee.assign(s);const n=this.opacityNode?g(this.opacityNode):cr;if(ee.a.assign(ee.a.mul(n)),this.alphaTestNode!==null||this.alphaTest>0){const r=this.alphaTestNode!==null?g(this.alphaTestNode):ep;ee.a.lessThanEqual(r).discard()}this.alphaHash===!0&&ee.a.lessThan(jx(me)).discard(),this.transparent===!1&&this.blending===Ys&&this.alphaToCoverage===!1&&ee.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?T(0):ee.rgb}setupNormal(){return this.normalNode?T(this.normalNode):ap}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?dt("envMap","cubeTexture"):dt("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Px(du)),t}setupLights(e){const t=[],s=this.setupEnvironment(e);s&&s.isLightingNode&&t.push(s);const n=this.setupLightMap(e);if(n&&n.isLightingNode&&t.push(n),this.aoNode!==null||e.material.aoMap){const i=this.aoNode!==null?this.aoNode:Ap;t.push(new Fx(i))}let r=this.lightsNode||e.lightsNode;return t.length>0&&(r=e.renderer.lighting.createNode([...r.getLights(),...t])),r}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:s,backdropAlphaNode:n,emissiveNode:r}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let u=this.setupOutgoingLight(e);if(a&&a.getScope().hasLights){const c=this.setupLightingModel(e);u=Pp(a,c,s,n)}else s!==null&&(u=T(n!==null?Q(u,s,n):s));return(r&&r.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(Ho.assign(T(r||sp)),u=u.add(Ho)),u}setupOutput(e,t){if(this.fog===!0){const s=e.fogNode;s&&($n.assign(t),t=P(s))}return t}setDefaultValues(e){for(const s in e){const n=e[s];this[s]===void 0&&(this[s]=n,n&&n.clone&&(this[s]=n.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const s in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,s)===void 0&&t[s].get!==void 0&&Object.defineProperty(this.constructor.prototype,s,t[s])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const s=Xu.prototype.toJSON.call(this,e),n=Vn(this);s.inputNodes={};for(const{property:i,childNode:a}of n)s.inputNodes[i]=a.toJSON(e).uuid;function r(i){const a=[];for(const u in i){const c=i[u];delete c.metadata,a.push(c)}return a}if(t){const i=r(e.textures),a=r(e.images),u=r(e.nodes);i.length>0&&(s.textures=i),a.length>0&&(s.images=a),u.length>0&&(s.nodes=u)}return s}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.shadowPositionNode=e.shadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const Qx=new hl;class dR extends ce{static get type(){return"InstancedPointsNodeMaterial"}constructor(e={}){super(),this.isInstancedPointsNodeMaterial=!0,this.useColor=e.vertexColors,this.pointWidth=1,this.pointColorNode=null,this.pointWidthNode=null,this._useAlphaToCoverage=!0,this.setDefaultValues(Qx),this.setValues(e)}setup(e){const{renderer:t}=e,s=this._useAlphaToCoverage,n=this.useColor;this.vertexNode=b(()=>{const r=we("instancePosition").xyz,i=P(Kt.mul(P(r,1))),a=$t.z.div($t.w),u=He.mul(i),c=Ce.xy.toVar();return c.mulAssign(this.pointWidthNode?this.pointWidthNode:Sp),c.assign(c.div($t.z)),c.y.assign(c.y.mul(a)),c.assign(c.mul(u.w)),u.addAssign(P(c,0,0)),u})(),this.fragmentNode=b(()=>{const r=g(1).toVar(),i=ja(le().mul(2).sub(1));if(s&&t.samples>1){const u=g(i.fwidth()).toVar();r.assign(ct(u.oneMinus(),u.add(1),i).oneMinus())}else i.greaterThan(1).discard();let a;return this.pointColorNode?a=this.pointColorNode:n?a=we("instanceColor").mul(an):a=an,r.mulAssign(cr),P(a,r)})(),super.setup(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const Zx=new Eg;class Jx extends ce{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(Zx),this.setValues(e)}}const eT=new pl;class tT extends ce{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(eT),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?g(this.offsetNode):lu,t=this.dashScaleNode?g(this.dashScaleNode):au,s=this.dashSizeNode?g(this.dashSizeNode):uu,n=this.gapSizeNode?g(this.gapSizeNode):cu;bs.assign(s),Hn.assign(n);const r=ke(we("lineDistance").mul(t));(e?r.add(e):r).mod(bs.add(Hn)).greaterThan(bs).discard()}}let ki=null;class sT extends Ci{static get type(){return"ViewportSharedTextureNode"}constructor(e=Bt,t=null){ki===null&&(ki=new bl),super(e,t,ki)}updateReference(){return this}}const Gp=C(sT),nT=new pl;class hR extends ce{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(nT),this.useColor=e.vertexColors,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=en,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,s=this._useAlphaToCoverage,n=this.useColor,r=this._useDash,i=this._useWorldUnits,a=b(({start:c,end:l})=>{const d=He.element(2).element(2),f=He.element(3).element(2).mul(-.5).div(d).sub(c.z).div(l.z.sub(c.z));return P(Q(c.xyz,l.xyz,f),l.w)}).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=b(()=>{const c=we("instanceStart"),l=we("instanceEnd"),d=P(Kt.mul(P(c,1))).toVar("start"),h=P(Kt.mul(P(l,1))).toVar("end");if(r){const F=this.dashScaleNode?g(this.dashScaleNode):au,L=this.offsetNode?g(this.offsetNode):lu,I=we("instanceDistanceStart"),G=we("instanceDistanceEnd");let X=Ce.y.lessThan(.5).select(F.mul(I),F.mul(G));X=X.add(L),et("float","lineDistance").assign(X)}i&&(et("vec3","worldStart").assign(d.xyz),et("vec3","worldEnd").assign(h.xyz));const p=$t.z.div($t.w),f=He.element(2).element(3).equal(-1);z(f,()=>{z(d.z.lessThan(0).and(h.z.greaterThan(0)),()=>{h.assign(a({start:d,end:h}))}).ElseIf(h.z.lessThan(0).and(d.z.greaterThanEqual(0)),()=>{d.assign(a({start:h,end:d}))})});const m=He.mul(d),x=He.mul(h),N=m.xyz.div(m.w),v=x.xyz.div(x.w),w=v.xy.sub(N.xy).toVar();w.x.assign(w.x.mul(p)),w.assign(w.normalize());const B=P().toVar();if(i){const F=h.xyz.sub(d.xyz).normalize(),L=Q(d.xyz,h.xyz,.5).normalize(),I=F.cross(L).normalize(),G=F.cross(I),X=et("vec4","worldPos");X.assign(Ce.y.lessThan(.5).select(d,h));const ie=Or.mul(.5);X.addAssign(P(Ce.x.lessThan(0).select(I.mul(ie),I.mul(ie).negate()),0)),r||(X.addAssign(P(Ce.y.lessThan(.5).select(F.mul(ie).negate(),F.mul(ie)),0)),X.addAssign(P(G.mul(ie),0)),z(Ce.y.greaterThan(1).or(Ce.y.lessThan(0)),()=>{X.subAssign(P(G.mul(2).mul(ie),0))})),B.assign(He.mul(X));const Z=T().toVar();Z.assign(Ce.y.lessThan(.5).select(N,v)),B.z.assign(Z.z.mul(B.w))}else{const F=M(w.y,w.x.negate()).toVar("offset");w.x.assign(w.x.div(p)),F.x.assign(F.x.div(p)),F.assign(Ce.x.lessThan(0).select(F.negate(),F)),z(Ce.y.lessThan(0),()=>{F.assign(F.sub(w))}).ElseIf(Ce.y.greaterThan(1),()=>{F.assign(F.add(w))}),F.assign(F.mul(Or)),F.assign(F.div($t.w)),B.assign(Ce.y.lessThan(.5).select(m,x)),F.assign(F.mul(B.w)),B.assign(B.add(P(F,0,0)))}return B})();const u=b(({p1:c,p2:l,p3:d,p4:h})=>{const p=c.sub(d),f=h.sub(d),m=l.sub(c),x=p.dot(f),N=f.dot(m),v=p.dot(m),w=f.dot(f),F=m.dot(m).mul(w).sub(N.mul(N)),I=x.mul(N).sub(v.mul(w)).div(F).clamp(),G=x.add(N.mul(I)).div(w).clamp();return M(I,G)});if(this.colorNode=b(()=>{const c=le();if(r){const h=this.dashSizeNode?g(this.dashSizeNode):uu,p=this.gapSizeNode?g(this.gapSizeNode):cu;bs.assign(h),Hn.assign(p);const f=et("float","lineDistance");c.y.lessThan(-1).or(c.y.greaterThan(1)).discard(),f.mod(bs.add(Hn)).greaterThan(bs).discard()}const l=g(1).toVar("alpha");if(i){const h=et("vec3","worldStart"),p=et("vec3","worldEnd"),f=et("vec4","worldPos").xyz.normalize().mul(1e5),m=p.sub(h),x=u({p1:h,p2:p,p3:T(0,0,0),p4:f}),N=h.add(m.mul(x.x)),v=f.mul(x.y),F=N.sub(v).length().div(Or);if(!r)if(s&&t.samples>1){const L=F.fwidth();l.assign(ct(L.negate().add(.5),L.add(.5),F).oneMinus())}else F.greaterThan(.5).discard()}else if(s&&t.samples>1){const h=c.x,p=c.y.greaterThan(0).select(c.y.sub(1),c.y.add(1)),f=h.mul(h).add(p.mul(p)),m=g(f.fwidth()).toVar("dlen");z(c.y.abs().greaterThan(1),()=>{l.assign(ct(m.oneMinus(),m.add(1),f).oneMinus())})}else z(c.y.abs().greaterThan(1),()=>{const h=c.x,p=c.y.greaterThan(0).select(c.y.sub(1),c.y.add(1));h.mul(h).add(p.mul(p)).greaterThan(1).discard()});let d;if(this.lineColorNode)d=this.lineColorNode;else if(n){const h=we("instanceColorStart"),p=we("instanceColorEnd");d=Ce.y.lessThan(.5).select(h,p).mul(an)}else d=an;return P(d,l)})(),this.transparent){const c=this.opacityNode?g(this.opacityNode):cr;this.outputNode=P(this.colorNode.rgb.mul(c).add(Gp().rgb.mul(c.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const Op=o=>E(o).mul(.5).add(.5),rT=o=>E(o).mul(2).sub(1),iT=new Bg;class oT extends ce{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(iT),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?g(this.opacityNode):cr;ee.assign(P(Op(fe),e))}}class aT extends be{static get type(){return"EquirectUVNode"}constructor(e=nu){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),s=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return M(t,s)}}const Tu=C(aT);class kp extends jg{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const s=t.minFilter,n=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const r=new _l(5,5,5),i=Tu(nu),a=new ce;a.colorNode=K(t,i,0),a.side=Ct,a.blending=en;const u=new tn(r,a),c=new Nl;c.add(u),t.minFilter===ms&&(t.minFilter=ft);const l=new Qg(1,10,this),d=e.getMRT();return e.setMRT(null),l.update(e,c),e.setMRT(d),t.minFilter=s,t.currentGenerateMipmaps=n,u.geometry.dispose(),u.material.dispose(),this}}const Fn=new WeakMap;class uT extends be{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=on();const t=new td;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=W.RENDER}updateBefore(e){const{renderer:t,material:s}=e,n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const r=n.isTextureNode?n.value:s[n.property];if(r&&r.isTexture){const i=r.mapping;if(i===jn||i===Qn){if(Fn.has(r)){const a=Fn.get(r);fc(a,r.mapping),this._cubeTexture=a}else{const a=r.image;if(cT(a)){const u=new kp(a.height);u.fromEquirectangularTexture(t,r),fc(u.texture,r.mapping),this._cubeTexture=u.texture,Fn.set(r,u.texture),r.addEventListener("dispose",zp)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function cT(o){return o==null?!1:o.height>0}function zp(o){const e=o.target;e.removeEventListener("dispose",zp);const t=Fn.get(e);t!==void 0&&(Fn.delete(e),t.dispose())}function fc(o,e){e===jn?o.mapping=Zs:e===Qn&&(o.mapping=Js)}const Wp=C(uT);class _u extends hn{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=Wp(this.envNode)}}class lT extends hn{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=g(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Ei{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class $p extends Ei{constructor(){super()}indirect(e,t,s){const n=e.ambientOcclusion,r=e.reflectedLight,i=s.context.irradianceLightMap;r.indirectDiffuse.assign(P(0)),i?r.indirectDiffuse.addAssign(i):r.indirectDiffuse.addAssign(P(1,1,1,0)),r.indirectDiffuse.mulAssign(n),r.indirectDiffuse.mulAssign(ee.rgb)}finish(e,t,s){const n=s.material,r=e.outgoingLight,i=s.context.environment;if(i)switch(n.combine){case Xg:r.rgb.assign(Q(r.rgb,r.rgb.mul(i.rgb),Bn.mul(Gr)));break;case Kg:r.rgb.assign(Q(r.rgb,i.rgb,Bn.mul(Gr)));break;case qg:r.rgb.addAssign(i.rgb.mul(Bn.mul(Gr)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",n.combine);break}}}const dT=new fl;class hT extends ce{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(dT),this.setValues(e)}setupNormal(){return lt}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new _u(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new lT(du)),t}setupOutgoingLight(){return ee.rgb}setupLightingModel(){return new $p}}const un=b(({f0:o,f90:e,dotVH:t})=>{const s=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return o.mul(s.oneMinus()).add(e.mul(s))}),Ns=b(o=>o.diffuseColor.mul(1/Math.PI)),pT=()=>g(.25),fT=b(({dotNH:o})=>Yr.mul(g(.5)).add(1).mul(g(1/Math.PI)).mul(o.pow(Yr))),gT=b(({lightDirection:o})=>{const e=o.add(ae).normalize(),t=fe.dot(e).clamp(),s=ae.dot(e).clamp(),n=un({f0:We,f90:1,dotVH:s}),r=pT(),i=fT({dotNH:t});return n.mul(r).mul(i)});class Hp extends $p{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:s}){const r=fe.dot(e).clamp().mul(t);s.directDiffuse.addAssign(r.mul(Ns({diffuseColor:ee.rgb}))),this.specular===!0&&s.directSpecular.addAssign(r.mul(gT({lightDirection:e})).mul(Bn))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:s}){s.indirectDiffuse.addAssign(t.mul(Ns({diffuseColor:ee}))),s.indirectDiffuse.mulAssign(e)}}const mT=new wg;class yT extends ce{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(mT),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new _u(t):null}setupLightingModel(){return new Hp(!1)}}const xT=new Fg;class TT extends ce{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(xT),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new _u(t):null}setupLightingModel(){return new Hp}setupVariants(){const e=(this.shininessNode?g(this.shininessNode):tp).max(1e-4);Yr.assign(e);const t=this.specularNode||np;We.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const qp=b(o=>{if(o.geometry.hasAttribute("normal")===!1)return g(0);const e=lt.dFdx().abs().max(lt.dFdy().abs());return e.x.max(e.y).max(e.z)}),bu=b(o=>{const{roughness:e}=o,t=qp();let s=e.max(.0525);return s=s.add(t),s=s.min(1),s}),Kp=b(({alpha:o,dotNL:e,dotNV:t})=>{const s=o.pow2(),n=e.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt()),r=t.mul(s.add(s.oneMinus().mul(e.pow2())).sqrt());return gt(.5,n.add(r).max(Gd))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),_T=b(({alphaT:o,alphaB:e,dotTV:t,dotBV:s,dotTL:n,dotBL:r,dotNV:i,dotNL:a})=>{const u=a.mul(T(o.mul(t),e.mul(s),i).length()),c=i.mul(T(o.mul(n),e.mul(r),a).length());return gt(.5,u.add(c)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),Xp=b(({alpha:o,dotNH:e})=>{const t=o.pow2(),s=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(s.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),bT=g(1/Math.PI),NT=b(({alphaT:o,alphaB:e,dotNH:t,dotTH:s,dotBH:n})=>{const r=o.mul(e),i=T(e.mul(s),o.mul(n),r.mul(t)),a=i.dot(i),u=r.div(a);return bT.mul(r.mul(u.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),jo=b(o=>{const{lightDirection:e,f0:t,f90:s,roughness:n,f:r,USE_IRIDESCENCE:i,USE_ANISOTROPY:a}=o,u=o.normalView||fe,c=n.pow2(),l=e.add(ae).normalize(),d=u.dot(e).clamp(),h=u.dot(ae).clamp(),p=u.dot(l).clamp(),f=ae.dot(l).clamp();let m=un({f0:t,f90:s,dotVH:f}),x,N;if(Gn(i)&&(m=mi.mix(m,r)),Gn(a)){const v=En.dot(e),w=En.dot(ae),B=En.dot(l),F=_s.dot(e),L=_s.dot(ae),I=_s.dot(l);x=_T({alphaT:Xr,alphaB:c,dotTV:w,dotBV:L,dotTL:v,dotBL:F,dotNV:h,dotNL:d}),N=NT({alphaT:Xr,alphaB:c,dotNH:p,dotTH:B,dotBH:I})}else x=Kp({alpha:c,dotNL:d,dotNV:h}),N=Xp({alpha:c,dotNH:p});return m.mul(x).mul(N)}),Nu=b(({roughness:o,dotNV:e})=>{const t=P(-1,-.0275,-.572,.022),s=P(1,.0425,1.04,-.04),n=o.mul(t).add(s),r=n.x.mul(n.x).min(e.mul(-9.28).exp2()).mul(n.x).add(n.y);return M(-1.04,1.04).mul(r).add(n.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),Yp=b(o=>{const{dotNV:e,specularColor:t,specularF90:s,roughness:n}=o,r=Nu({dotNV:e,roughness:n});return t.mul(r.x).add(s.mul(r.y))}),jp=b(({f:o,f90:e,dotVH:t})=>{const s=t.oneMinus().saturate(),n=s.mul(s),r=s.mul(n,n).clamp(0,.9999);return o.sub(T(e).mul(r)).div(r.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),ST=b(({roughness:o,dotNH:e})=>{const t=o.pow2(),s=g(1).div(t),r=e.pow2().oneMinus().max(.0078125);return g(2).add(s).mul(r.pow(s.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),vT=b(({dotNV:o,dotNL:e})=>g(1).div(g(4).mul(e.add(o).sub(e.mul(o))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),AT=b(({lightDirection:o})=>{const e=o.add(ae).normalize(),t=fe.dot(o).clamp(),s=fe.dot(ae).clamp(),n=fe.dot(e).clamp(),r=ST({roughness:gi,dotNH:n}),i=vT({dotNV:s,dotNL:t});return fs.mul(r).mul(i)}),RT=b(({N:o,V:e,roughness:t})=>{const r=.0078125,i=o.dot(e).saturate(),a=M(t,i.oneMinus().sqrt());return a.assign(a.mul(.984375).add(r)),a}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),CT=b(({f:o})=>{const e=o.length();return ue(e.mul(e).add(o.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),gr=b(({v1:o,v2:e})=>{const t=o.dot(e),s=t.abs().toVar(),n=s.mul(.0145206).add(.4965155).mul(s).add(.8543985).toVar(),r=s.add(4.1616724).mul(s).add(3.417594).toVar(),i=n.div(r),a=t.greaterThan(0).select(i,ue(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(i));return o.cross(e).mul(a)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),gc=b(({N:o,V:e,P:t,mInv:s,p0:n,p1:r,p2:i,p3:a})=>{const u=r.sub(n).toVar(),c=a.sub(n).toVar(),l=u.cross(c),d=T().toVar();return z(l.dot(t.sub(n)).greaterThanEqual(0),()=>{const h=e.sub(o.mul(e.dot(o))).normalize(),p=o.cross(h).negate(),f=s.mul(Oe(h,p,o).transpose()).toVar(),m=f.mul(n.sub(t)).normalize().toVar(),x=f.mul(r.sub(t)).normalize().toVar(),N=f.mul(i.sub(t)).normalize().toVar(),v=f.mul(a.sub(t)).normalize().toVar(),w=T(0).toVar();w.addAssign(gr({v1:m,v2:x})),w.addAssign(gr({v1:x,v2:N})),w.addAssign(gr({v1:N,v2:v})),w.addAssign(gr({v1:v,v2:m})),d.assign(T(CT({f:w})))}),d}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),wi=1/6,Qp=o=>$(wi,$(o,$(o,o.negate().add(3)).sub(3)).add(1)),Qo=o=>$(wi,$(o,$(o,$(3,o).sub(6))).add(4)),Zp=o=>$(wi,$(o,$(o,$(-3,o).add(3)).add(3)).add(1)),Zo=o=>$(wi,ht(o,3)),mc=o=>Qp(o).add(Qo(o)),yc=o=>Zp(o).add(Zo(o)),xc=o=>_e(-1,Qo(o).div(Qp(o).add(Qo(o)))),Tc=o=>_e(1,Zo(o).div(Zp(o).add(Zo(o)))),_c=(o,e,t)=>{const s=o.uvNode,n=$(s,e.zw).add(.5),r=At(n),i=Xt(n),a=mc(i.x),u=yc(i.x),c=xc(i.x),l=Tc(i.x),d=xc(i.y),h=Tc(i.y),p=M(r.x.add(c),r.y.add(d)).sub(.5).mul(e.xy),f=M(r.x.add(l),r.y.add(d)).sub(.5).mul(e.xy),m=M(r.x.add(c),r.y.add(h)).sub(.5).mul(e.xy),x=M(r.x.add(l),r.y.add(h)).sub(.5).mul(e.xy),N=mc(i.y).mul(_e(a.mul(o.sample(p).level(t)),u.mul(o.sample(f).level(t)))),v=yc(i.y).mul(_e(a.mul(o.sample(m).level(t)),u.mul(o.sample(x).level(t))));return N.add(v)},Jp=b(([o,e=g(3)])=>{const t=M(o.size(y(e))),s=M(o.size(y(e.add(1)))),n=gt(1,t),r=gt(1,s),i=_c(o,P(n,t),At(e)),a=_c(o,P(r,s),xi(e));return Xt(e).mix(i,a)}),bc=b(([o,e,t,s,n])=>{const r=T(Qa(e.negate(),qt(o),gt(1,s))),i=T(zt(n[0].xyz),zt(n[1].xyz),zt(n[2].xyz));return qt(r).mul(t.mul(i))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),ET=b(([o,e])=>o.mul(Et(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),wT=fu(),MT=fu(),Nc=b(([o,e,t],{material:s})=>{const r=(s.side===Ct?wT:MT).sample(o),i=vt(Kn.x).mul(ET(e,t));return Jp(r,i)}),Sc=b(([o,e,t])=>(z(t.notEqual(0),()=>{const s=yi(e).negate().div(t);return za(s.negate().mul(o))}),T(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),BT=b(([o,e,t,s,n,r,i,a,u,c,l,d,h,p,f])=>{let m,x;if(f){m=P().toVar(),x=T().toVar();const F=l.sub(1).mul(f.mul(.025)),L=T(l.sub(F),l,l.add(F));te({start:0,end:3},({i:I})=>{const G=L.element(I),X=bc(o,e,d,G,a),ie=i.add(X),Z=c.mul(u.mul(P(ie,1))),Qe=M(Z.xy.div(Z.w)).toVar();Qe.addAssign(1),Qe.divAssign(2),Qe.assign(M(Qe.x,Qe.y.oneMinus()));const Ze=Nc(Qe,t,G);m.element(I).assign(Ze.element(I)),m.a.addAssign(Ze.a),x.element(I).assign(s.element(I).mul(Sc(zt(X),h,p).element(I)))}),m.a.divAssign(3)}else{const F=bc(o,e,d,l,a),L=i.add(F),I=c.mul(u.mul(P(L,1))),G=M(I.xy.div(I.w)).toVar();G.addAssign(1),G.divAssign(2),G.assign(M(G.x,G.y.oneMinus())),m=Nc(G,t,l),x=s.mul(Sc(zt(F),h,p))}const N=x.rgb.mul(m.rgb),v=o.dot(e).clamp(),w=T(Yp({dotNV:v,specularColor:n,specularF90:r,roughness:t})),B=x.r.add(x.g,x.b).div(3);return P(w.oneMinus().mul(N),m.a.oneMinus().mul(B).oneMinus())}),FT=Oe(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),UT=o=>{const e=o.sqrt();return T(1).add(e).div(T(1).sub(e))},vc=(o,e)=>o.sub(e).div(o.add(e)).pow2(),PT=(o,e)=>{const t=o.mul(2*Math.PI*1e-9),s=T(54856e-17,44201e-17,52481e-17),n=T(1681e3,1795300,2208400),r=T(43278e5,93046e5,66121e5),i=g(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let a=s.mul(r.mul(2*Math.PI).sqrt()).mul(n.mul(t).add(e).cos()).mul(t.pow2().negate().mul(r).exp());return a=T(a.x.add(i),a.y,a.z).div(10685e-11),FT.mul(a)},DT=b(({outsideIOR:o,eta2:e,cosTheta1:t,thinFilmThickness:s,baseF0:n})=>{const r=Q(o,e,ct(0,.03,s)),a=o.div(r).pow2().mul(t.pow2().oneMinus()).oneMinus();z(a.lessThan(0),()=>T(1));const u=a.sqrt(),c=vc(r,o),l=un({f0:c,f90:1,dotVH:t}),d=l.oneMinus(),h=r.lessThan(o).select(Math.PI,0),p=g(Math.PI).sub(h),f=UT(n.clamp(0,.9999)),m=vc(f,r.toVec3()),x=un({f0:m,f90:1,dotVH:u}),N=T(f.x.lessThan(r).select(Math.PI,0),f.y.lessThan(r).select(Math.PI,0),f.z.lessThan(r).select(Math.PI,0)),v=r.mul(s,u,2),w=T(p).add(N),B=l.mul(x).clamp(1e-5,.9999),F=B.sqrt(),L=d.pow2().mul(x).div(T(1).sub(B)),G=l.add(L).toVar(),X=L.sub(d).toVar();return te({start:1,end:2,condition:"<=",name:"m"},({m:ie})=>{X.mulAssign(F);const Z=PT(g(ie).mul(v),g(ie).mul(w)).mul(2);G.addAssign(X.mul(Z))}),G.max(T(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),LT=b(({normal:o,viewDir:e,roughness:t})=>{const s=o.dot(e).saturate(),n=t.pow2(),r=Ue(t.lessThan(.25),g(-339.2).mul(n).add(g(161.4).mul(t)).sub(25.9),g(-8.48).mul(n).add(g(14.3).mul(t)).sub(9.95)),i=Ue(t.lessThan(.25),g(44).mul(n).sub(g(23.7).mul(t)).add(3.26),g(1.97).mul(n).sub(g(3.27).mul(t)).add(.72));return Ue(t.lessThan(.25),0,g(.1).mul(t).sub(.025)).add(r.mul(s).add(i).exp()).mul(1/Math.PI).saturate()}),zi=T(.04),Wi=g(1);class Su extends Ei{constructor(e=!1,t=!1,s=!1,n=!1,r=!1,i=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=s,this.anisotropy=n,this.transmission=r,this.dispersion=i,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=T().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=T().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=T().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=T().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=T().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=fe.dot(ae).clamp();this.iridescenceFresnel=DT({outsideIOR:g(1),eta2:Ua,cosTheta1:t,thinFilmThickness:Pa,baseF0:We}),this.iridescenceF0=jp({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=Wt,s=su.sub(Wt).normalize(),n=vi;e.backdrop=BT(n,s,Nt,ee,We,Wn,t,at,je,He,wn,Da,Ia,La,this.dispersion?Va:null),e.backdropAlpha=jr,ee.a.mulAssign(Q(1,e.backdrop.a,jr))}}computeMultiscattering(e,t,s){const n=fe.dot(ae).clamp(),r=Nu({roughness:Nt,dotNV:n}),a=(this.iridescenceF0?mi.mix(We,this.iridescenceF0):We).mul(r.x).add(s.mul(r.y)),c=r.x.add(r.y).oneMinus(),l=We.add(We.oneMinus().mul(.047619)),d=a.mul(l).div(c.mul(l).oneMinus());e.addAssign(a),t.addAssign(d.mul(c))}direct({lightDirection:e,lightColor:t,reflectedLight:s}){const r=fe.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(r.mul(AT({lightDirection:e}))),this.clearcoat===!0){const a=Hs.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(a.mul(jo({lightDirection:e,f0:zi,f90:Wi,roughness:zn,normalView:Hs})))}s.directDiffuse.addAssign(r.mul(Ns({diffuseColor:ee.rgb}))),s.directSpecular.addAssign(r.mul(jo({lightDirection:e,f0:We,f90:1,roughness:Nt,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:s,halfHeight:n,reflectedLight:r,ltc_1:i,ltc_2:a}){const u=t.add(s).sub(n),c=t.sub(s).sub(n),l=t.sub(s).add(n),d=t.add(s).add(n),h=fe,p=ae,f=xe.toVar(),m=RT({N:h,V:p,roughness:Nt}),x=i.sample(m).toVar(),N=a.sample(m).toVar(),v=Oe(T(x.x,0,x.y),T(0,1,0),T(x.z,0,x.w)).toVar(),w=We.mul(N.x).add(We.oneMinus().mul(N.y)).toVar();r.directSpecular.addAssign(e.mul(w).mul(gc({N:h,V:p,P:f,mInv:v,p0:u,p1:c,p2:l,p3:d}))),r.directDiffuse.addAssign(e.mul(ee).mul(gc({N:h,V:p,P:f,mInv:Oe(1,0,0,0,1,0,0,0,1),p0:u,p1:c,p2:l,p3:d})))}indirect(e,t,s){this.indirectDiffuse(e,t,s),this.indirectSpecular(e,t,s),this.ambientOcclusion(e,t,s)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(Ns({diffuseColor:ee})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:s}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul(fs,LT({normal:fe,viewDir:ae,roughness:gi}))),this.clearcoat===!0){const c=Hs.dot(ae).clamp(),l=Yp({dotNV:c,specularColor:zi,specularF90:Wi,roughness:zn});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(l))}const n=T().toVar("singleScattering"),r=T().toVar("multiScattering"),i=t.mul(1/Math.PI);this.computeMultiscattering(n,r,Wn);const a=n.add(r),u=ee.mul(a.r.max(a.g).max(a.b).oneMinus());s.indirectSpecular.addAssign(e.mul(n)),s.indirectSpecular.addAssign(r.mul(i)),s.indirectDiffuse.addAssign(u.mul(i))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const n=fe.dot(ae).clamp().add(e),r=Nt.mul(-16).oneMinus().negate().exp2(),i=e.sub(n.pow(r).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(e),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(i)}finish(e){const{outgoingLight:t}=e;if(this.clearcoat===!0){const s=Hs.dot(ae).clamp(),n=un({dotVH:s,f0:zi,f90:Wi}),r=t.mul(Kr.mul(n).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Kr));t.assign(r)}if(this.sheen===!0){const s=fs.r.max(fs.g).max(fs.b).mul(.157).oneMinus(),n=t.mul(s).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(n)}}}const Ac=g(1),Jo=g(-2),mr=g(.8),$i=g(-1),yr=g(.4),Hi=g(2),xr=g(.305),qi=g(3),Rc=g(.21),IT=g(4),Cc=g(4),VT=g(16),GT=b(([o])=>{const e=T(oe(o)).toVar(),t=g(-1).toVar();return z(e.x.greaterThan(e.z),()=>{z(e.x.greaterThan(e.y),()=>{t.assign(Ue(o.x.greaterThan(0),0,3))}).Else(()=>{t.assign(Ue(o.y.greaterThan(0),1,4))})}).Else(()=>{z(e.z.greaterThan(e.y),()=>{t.assign(Ue(o.z.greaterThan(0),2,5))}).Else(()=>{t.assign(Ue(o.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),OT=b(([o,e])=>{const t=M().toVar();return z(e.equal(0),()=>{t.assign(M(o.z,o.y).div(oe(o.x)))}).ElseIf(e.equal(1),()=>{t.assign(M(o.x.negate(),o.z.negate()).div(oe(o.y)))}).ElseIf(e.equal(2),()=>{t.assign(M(o.x.negate(),o.y).div(oe(o.z)))}).ElseIf(e.equal(3),()=>{t.assign(M(o.z.negate(),o.y).div(oe(o.x)))}).ElseIf(e.equal(4),()=>{t.assign(M(o.x.negate(),o.z).div(oe(o.y)))}).Else(()=>{t.assign(M(o.x,o.y).div(oe(o.z)))}),$(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),kT=b(([o])=>{const e=g(0).toVar();return z(o.greaterThanEqual(mr),()=>{e.assign(Ac.sub(o).mul($i.sub(Jo)).div(Ac.sub(mr)).add(Jo))}).ElseIf(o.greaterThanEqual(yr),()=>{e.assign(mr.sub(o).mul(Hi.sub($i)).div(mr.sub(yr)).add($i))}).ElseIf(o.greaterThanEqual(xr),()=>{e.assign(yr.sub(o).mul(qi.sub(Hi)).div(yr.sub(xr)).add(Hi))}).ElseIf(o.greaterThanEqual(Rc),()=>{e.assign(xr.sub(o).mul(IT.sub(qi)).div(xr.sub(Rc)).add(qi))}).Else(()=>{e.assign(g(-2).mul(vt($(1.16,o))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),ef=b(([o,e])=>{const t=o.toVar();t.assign($(2,t).sub(1));const s=T(t,1).toVar();return z(e.equal(0),()=>{s.assign(s.zyx)}).ElseIf(e.equal(1),()=>{s.assign(s.xzy),s.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{s.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{s.assign(s.zyx),s.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{s.assign(s.xzy),s.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{s.z.mulAssign(-1)}),s}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),tf=b(([o,e,t,s,n,r])=>{const i=g(t),a=T(e),u=Et(kT(i),Jo,r),c=Xt(u),l=At(u),d=T(ea(o,a,l,s,n,r)).toVar();return z(c.notEqual(0),()=>{const h=T(ea(o,a,l.add(1),s,n,r)).toVar();d.assign(Q(d,h,c))}),d}),ea=b(([o,e,t,s,n,r])=>{const i=g(t).toVar(),a=T(e),u=g(GT(a)).toVar(),c=g(ue(Cc.sub(i),0)).toVar();i.assign(ue(i,Cc));const l=g(rn(i)).toVar(),d=M(OT(a,u).mul(l.sub(2)).add(1)).toVar();return z(u.greaterThan(2),()=>{d.y.addAssign(l),u.subAssign(3)}),d.x.addAssign(u.mul(l)),d.x.addAssign(c.mul($(3,VT))),d.y.addAssign($(4,rn(r).sub(l))),d.x.mulAssign(s),d.y.mulAssign(n),o.sample(d).grad(M(),M())}),Ki=b(({envMap:o,mipInt:e,outputDirection:t,theta:s,axis:n,CUBEUV_TEXEL_WIDTH:r,CUBEUV_TEXEL_HEIGHT:i,CUBEUV_MAX_MIP:a})=>{const u=It(s),c=t.mul(u).add(n.cross(t).mul(st(s))).add(n.mul(n.dot(t).mul(u.oneMinus())));return ea(o,c,e,r,i,a)}),sf=b(({n:o,latitudinal:e,poleAxis:t,outputDirection:s,weights:n,samples:r,dTheta:i,mipInt:a,envMap:u,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:l,CUBEUV_MAX_MIP:d})=>{const h=T(Ue(e,t,_i(t,s))).toVar();z(ka(h.equals(T(0))),()=>{h.assign(T(s.z,0,s.x.negate()))}),h.assign(qt(h));const p=T().toVar();return p.addAssign(n.element(y(0)).mul(Ki({theta:0,axis:h,outputDirection:s,mipInt:a,envMap:u,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:l,CUBEUV_MAX_MIP:d}))),te({start:y(1),end:o},({i:f})=>{z(f.greaterThanEqual(r),()=>{pu()});const m=g(i.mul(g(f))).toVar();p.addAssign(n.element(f).mul(Ki({theta:m.mul(-1),axis:h,outputDirection:s,mipInt:a,envMap:u,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:l,CUBEUV_MAX_MIP:d}))),p.addAssign(n.element(f).mul(Ki({theta:m,axis:h,outputDirection:s,mipInt:a,envMap:u,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:l,CUBEUV_MAX_MIP:d})))}),P(p,1)});let ti=null;const Ec=new WeakMap;function zT(o){const e=Math.log2(o)-2,t=1/o;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function WT(o){let e=Ec.get(o);if((e!==void 0?e.pmremVersion:-1)!==o.pmremVersion){const s=o.image;if(o.isCubeTexture)if(HT(s))e=ti.fromCubemap(o,e);else return null;else if(qT(s))e=ti.fromEquirectangular(o,e);else return null;e.pmremVersion=o.pmremVersion,Ec.set(o,e)}return e.texture}class $T extends be{static get type(){return"PMREMNode"}constructor(e,t=null,s=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=s,this._generator=null;const n=new aa;n.isRenderTargetTexture=!0,this._texture=K(n),this._width=V(0),this._height=V(0),this._maxMip=V(0),this.updateBeforeType=W.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=zT(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,s=this._value;t!==s.pmremVersion&&(s.isPMREMTexture===!0?e=s:e=WT(s),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){ti===null&&(ti=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this));const s=this.value;e.renderer.coordinateSystem===Pn&&s.isPMREMTexture!==!0&&s.isRenderTargetTexture===!0&&(t=T(t.x.negate(),t.yz)),t=T(t.x,t.y.negate(),t.z);let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),tf(this._texture,t,n,this._width,this._height,this._maxMip)}}function HT(o){if(o==null)return!1;let e=0;const t=6;for(let s=0;s0}const vu=C($T),wc=new WeakMap;class KT extends hn{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const p=s.isTextureNode?s.value:t[s.property];let f=wc.get(p);f===void 0&&(f=vu(p),wc.set(p,f)),s=f}const r=t.envMap?ne("envMapIntensity","float",e.material):ne("environmentIntensity","float",e.scene),a=t.useAnisotropy===!0||t.anisotropy>0?Zh:fe,u=s.context(Mc(Nt,a)).mul(r),c=s.context(XT(vi)).mul(Math.PI).mul(r),l=Mn(u),d=Mn(c);e.context.radiance.addAssign(l),e.context.iblIrradiance.addAssign(d);const h=e.context.lightingModel.clearcoatRadiance;if(h){const p=s.context(Mc(zn,Hs)).mul(r),f=Mn(p);h.addAssign(f)}}}const Mc=(o,e)=>{let t=null;return{getUV:()=>(t===null&&(t=ae.negate().reflect(e),t=o.mul(o).mix(t,e).normalize(),t=t.transformDirection(je)),t),getTextureLevel:()=>o}},XT=o=>({getUV:()=>o,getTextureLevel:()=>g(1)}),YT=new Pg;class nf extends ce{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(YT),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new KT(t):null}setupLightingModel(){return new Su}setupSpecular(){const e=Q(T(.04),ee.rgb,kn);We.assign(e),Wn.assign(1)}setupVariants(){const e=this.metalnessNode?g(this.metalnessNode):op;kn.assign(e);let t=this.roughnessNode?g(this.roughnessNode):ip;t=bu({roughness:t}),Nt.assign(t),this.setupSpecular(),ee.assign(P(ee.rgb.mul(e.oneMinus()),ee.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const jT=new Ug;class rf extends nf{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(jT),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?g(this.iorNode):_p;wn.assign(e),We.assign(Q(Re(Ya(wn.sub(1).div(wn.add(1))).mul(rp),T(1)).mul(Yo),ee.rgb,kn)),Wn.assign(Q(Yo,1,kn))}setupLightingModel(){return new Su(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?g(this.clearcoatNode):up,s=this.clearcoatRoughnessNode?g(this.clearcoatRoughnessNode):cp;Kr.assign(t),zn.assign(bu({roughness:s}))}if(this.useSheen){const t=this.sheenNode?T(this.sheenNode):hp,s=this.sheenRoughnessNode?g(this.sheenRoughnessNode):pp;fs.assign(t),gi.assign(s)}if(this.useIridescence){const t=this.iridescenceNode?g(this.iridescenceNode):gp,s=this.iridescenceIORNode?g(this.iridescenceIORNode):mp,n=this.iridescenceThicknessNode?g(this.iridescenceThicknessNode):yp;mi.assign(t),Ua.assign(s),Pa.assign(n)}if(this.useAnisotropy){const t=(this.anisotropyNode?M(this.anisotropyNode):fp).toVar();Zt.assign(t.length()),z(Zt.equal(0),()=>{t.assign(M(1,0))}).Else(()=>{t.divAssign(M(Zt)),Zt.assign(Zt.saturate())}),Xr.assign(Zt.pow2().mix(Nt.pow2(),1)),En.assign(gs[0].mul(t.x).add(gs[1].mul(t.y))),_s.assign(gs[1].mul(t.x).sub(gs[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?g(this.transmissionNode):xp,s=this.thicknessNode?g(this.thicknessNode):Tp,n=this.attenuationDistanceNode?g(this.attenuationDistanceNode):bp,r=this.attenuationColorNode?T(this.attenuationColorNode):Np;if(jr.assign(t),Da.assign(s),La.assign(n),Ia.assign(r),this.useDispersion){const i=this.dispersionNode?g(this.dispersionNode):vp;Va.assign(i)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?T(this.clearcoatNormalNode):lp}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class QT extends Su{constructor(e=!1,t=!1,s=!1,n=!1,r=!1,i=!1,a=!1){super(e,t,s,n,r,i),this.useSSS=a}direct({lightDirection:e,lightColor:t,reflectedLight:s},n,r){if(this.useSSS===!0){const i=r.material,{thicknessColorNode:a,thicknessDistortionNode:u,thicknessAmbientNode:c,thicknessAttenuationNode:l,thicknessPowerNode:d,thicknessScaleNode:h}=i,p=e.add(fe.mul(u)).normalize(),f=g(ae.dot(p.negate()).saturate().pow(d).mul(h)),m=T(f.add(c).mul(a));s.directDiffuse.addAssign(m.mul(l.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:s},n,r)}}class pR extends rf{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=g(.1),this.thicknessAmbientNode=g(0),this.thicknessAttenuationNode=g(.1),this.thicknessPowerNode=g(2),this.thicknessScaleNode=g(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new QT(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const ZT=b(({normal:o,lightDirection:e,builder:t})=>{const s=o.dot(e),n=M(s.mul(.5).add(.5),0);if(t.material.gradientMap){const r=dt("gradientMap","texture").context({getUV:()=>n});return T(r.r)}else{const r=n.fwidth().mul(.5);return Q(T(.7),T(1),ct(g(.7).sub(r.x),g(.7).add(r.x),n.x))}});class JT extends Ei{direct({lightDirection:e,lightColor:t,reflectedLight:s},n,r){const i=ZT({normal:Ni,lightDirection:e,builder:r}).mul(t);s.directDiffuse.addAssign(i.mul(Ns({diffuseColor:ee.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:s}){s.indirectDiffuse.addAssign(t.mul(Ns({diffuseColor:ee}))),s.indirectDiffuse.mulAssign(e)}}const e_=new Dg;class t_ extends ce{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(e_),this.setValues(e)}setupLightingModel(){return new JT}}class s_ extends be{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=T(ae.z,0,ae.x.negate()).normalize(),t=ae.cross(e);return M(e.dot(fe),t.dot(fe)).mul(.495).add(.5)}}const of=U(s_),n_=new Mg;class r_ extends ce{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(n_),this.setValues(e)}setupVariants(e){const t=of;let s;e.material.matcap?s=dt("matcap","texture").context({getUV:()=>t}):s=T(Q(.2,.8,t.y)),ee.rgb.mulAssign(s.rgb)}}const i_=new hl;class o_ extends ce{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.setDefaultValues(i_),this.setValues(e)}}class a_ extends be{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:s}=this;if(this.getNodeType(e)==="vec2"){const r=t.cos(),i=t.sin();return fi(r,i,i.negate(),r).mul(s)}else{const r=t,i=Ts(P(1,0,0,0),P(0,It(r.x),st(r.x).negate(),0),P(0,st(r.x),It(r.x),0),P(0,0,0,1)),a=Ts(P(It(r.y),0,st(r.y),0),P(0,1,0,0),P(st(r.y).negate(),0,It(r.y),0),P(0,0,0,1)),u=Ts(P(It(r.z),st(r.z).negate(),0,0),P(st(r.z),It(r.z),0,0),P(0,0,1,0),P(0,0,0,1));return i.mul(a).mul(u).mul(P(s,1)).xyz}}}const Au=C(a_),u_=new Hg;class c_ extends ce{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues(u_),this.setValues(e)}setupPositionView(e){const{object:t,camera:s}=e,n=this.sizeAttenuation,{positionNode:r,rotationNode:i,scaleNode:a}=this,u=Kt.mul(T(r||0));let c=M(at[0].xyz.length(),at[1].xyz.length());if(a!==null&&(c=c.mul(a)),n===!1)if(s.isPerspectiveCamera)c=c.mul(u.z.negate());else{const p=g(2).div(He.element(1).element(1));c=c.mul(p.mul(2))}let l=Ce.xy;if(t.center&&t.center.isVector2===!0){const p=By("center","vec2",t);l=l.sub(p.sub(.5))}l=l.mul(c);const d=g(i||dp),h=Au(l,d);return P(u.xy.add(h),u.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}class l_ extends Ei{constructor(){super(),this.shadowNode=g(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){ee.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(ee.rgb)}}const d_=new $g;class h_ extends ce{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(d_),this.setValues(e)}setupLightingModel(){return new l_}}const p_=b(({texture:o,uv:e})=>{const s=T().toVar();return z(e.x.lessThan(1e-4),()=>{s.assign(T(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{s.assign(T(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{s.assign(T(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{s.assign(T(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{s.assign(T(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{s.assign(T(0,0,-1))}).Else(()=>{const r=o.sample(e.add(T(-.01,0,0))).r.sub(o.sample(e.add(T(.01,0,0))).r),i=o.sample(e.add(T(0,-.01,0))).r.sub(o.sample(e.add(T(0,.01,0))).r),a=o.sample(e.add(T(0,0,-.01))).r.sub(o.sample(e.add(T(0,0,.01))).r);s.assign(T(r,i,a))}),s.normalize()});class f_ extends wt{static get type(){return"Texture3DNode"}constructor(e,t=null,s=null){super(e,t,s),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return T(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const s=this.value;return e.isFlipY()&&(s.isRenderTargetTexture===!0||s.isFramebufferTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(y(ns(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return p_({texture:this,uv:e})}}const af=C(f_);class fR extends ce{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.base=new mt(16777215),this.map=null,this.steps=100,this.testNode=null,this.setValues(e)}setup(e){const t=af(this.map,null,0),s=b(({orig:n,dir:r})=>{const i=T(-.5),a=T(.5),u=r.reciprocal(),c=i.sub(n).mul(u),l=a.sub(n).mul(u),d=Re(c,l),h=ue(c,l),p=ue(d.x,ue(d.y,d.z)),f=Re(h.x,Re(h.y,h.z));return M(p,f)});this.fragmentNode=b(()=>{const n=ke(T(Ih.mul(P(su,1)))),i=ke(Ce.sub(n)).normalize(),a=M(s({orig:n,dir:i})).toVar();a.x.greaterThan(a.y).discard(),a.assign(M(ue(a.x,0),a.y));const u=T(n.add(a.x.mul(i))).toVar(),c=T(i.abs().reciprocal()).toVar(),l=g(Re(c.x,Re(c.y,c.z))).toVar("delta");l.divAssign(dt("steps","float"));const d=P(dt("base","color"),0).toVar();return te({type:"float",start:a.x,end:a.y,update:"+= delta"},()=>{const h=Fa("float","d").assign(t.sample(u.add(.5)).r);this.testNode!==null?this.testNode({map:t,mapValue:h,probe:u,finalColor:d}).append():(d.a.assign(1),pu()),u.addAssign(i.mul(l))}),d.a.equal(0).discard(),P(d)})(),super.setup(e)}}class g_{constructor(e,t){this.nodes=e,this.info=t,this._context=self,this._animationLoop=null,this._requestId=null}start(){const e=(t,s)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this._animationLoop!==null&&this._animationLoop(t,s)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}setAnimationLoop(e){this._animationLoop=e}setContext(e){this._context=e}dispose(){this.stop()}}class Ft{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let s=0;s{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().monitor)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,s=[],n=new Set;for(const r of e){const i=r.node&&r.node.attribute?r.node.attribute:t.getAttribute(r.name);if(i===void 0)continue;s.push(i);const a=i.isInterleavedBufferAttribute?i.data:i;n.add(a)}return this.attributes=s,this.vertexBuffers=Array.from(n.values()),s}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:s,group:n,drawRange:r}=this,i=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),u=a!==null,c=s.isInstancedBufferGeometry?s.instanceCount:e.count>1?e.count:1;if(c===0)return null;if(i.instanceCount=c,e.isBatchedMesh===!0)return i;let l=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(l=2);let d=r.start*l,h=(r.start+r.count)*l;n!==null&&(d=Math.max(d,n.start*l),h=Math.min(h,(n.start+n.count)*l));const p=s.attributes.position;let f=1/0;u?f=a.count:p!=null&&(f=p.count),d=Math.max(d,0),h=Math.min(h,f);const m=h-d;return m<0||m===1/0?null:(i.vertexCount=m,i.firstVertex=d,i)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const s of Object.keys(e.attributes).sort()){const n=e.attributes[s];t+=s+",",n.data&&(t+=n.data.stride+","),n.offset&&(t+=n.offset+","),n.itemSize&&(t+=n.itemSize+","),n.normalized&&(t+="n,")}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t}=this;let s=t.customProgramCacheKey();for(const n of y_(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(n))continue;const r=t[n];let i;if(r!==null){const a=typeof r;a==="number"?i=r!==0?"1":"0":a==="object"?(i="{",r.isTexture&&(i+=r.mapping),i+="}"):i=String(r)}else i=String(r);s+=i+","}return s+=this.clippingContextCacheKey+",",e.geometry&&(s+=this.getGeometryCacheKey()),e.skeleton&&(s+=e.skeleton.bones.length+","),e.morphTargetInfluences&&(s+=e.morphTargetInfluences.length+","),e.isBatchedMesh&&(s+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(s+=e._colorsTexture.uuid+",")),e.count>1&&(s+=e.uuid+","),s+=e.receiveShadow+",",ga(s)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=this._nodes.getCacheKey(this.scene,this.lightsNode);return this.object.receiveShadow&&(e+=1),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const Bs=[];class T_{constructor(e,t,s,n,r,i){this.renderer=e,this.nodes=t,this.geometries=s,this.pipelines=n,this.bindings=r,this.info=i,this.chainMaps={}}get(e,t,s,n,r,i,a,u){const c=this.getChainMap(u);Bs[0]=e,Bs[1]=t,Bs[2]=i,Bs[3]=r;let l=c.get(Bs);return l===void 0?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,s,n,r,i,a,u),c.set(Bs,l)):(l.updateClipping(a),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey!==l.getCacheKey()?(l.dispose(),l=this.get(e,t,s,n,r,i,a,u)):l.version=t.version)),l}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Ft)}dispose(){this.chainMaps={}}createRenderObject(e,t,s,n,r,i,a,u,c,l,d){const h=this.getChainMap(d),p=new x_(e,t,s,n,r,i,a,u,c,l);return p.onDispose=()=>{this.pipelines.delete(p),this.bindings.delete(p),this.nodes.delete(p),h.delete(p.getChainArray())},p}}class os{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const St={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},ts=16,__=211,b_=212;class N_ extends os{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==void 0&&this.backend.destroyAttribute(e),t}update(e,t){const s=this.get(e);if(s.version===void 0)t===St.VERTEX?this.backend.createAttribute(e):t===St.INDEX?this.backend.createIndexAttribute(e):t===St.STORAGE?this.backend.createStorageAttribute(e):t===St.INDIRECT&&this.backend.createIndirectStorageAttribute(e),s.version=this._getBufferAttribute(e).version;else{const n=this._getBufferAttribute(e);(s.version=0;--e)if(o[e]>=65535)return!0;return!1}function uf(o){return o.index!==null?o.index.version:o.attributes.position.version}function Bc(o){const e=[],t=o.index,s=o.attributes.position;if(t!==null){const r=t.array;for(let i=0,a=r.length;i{this.info.memory.geometries--;const r=t.index,i=e.getAttributes();r!==null&&this.attributes.delete(r);for(const u of i)this.attributes.delete(u);const a=this.wireframes.get(t);a!==void 0&&this.attributes.delete(a),t.removeEventListener("dispose",n)};t.addEventListener("dispose",n)}updateAttributes(e){const t=e.getAttributes();for(const r of t)r.isStorageBufferAttribute||r.isStorageInstancedBufferAttribute?this.updateAttribute(r,St.STORAGE):this.updateAttribute(r,St.VERTEX);const s=this.getIndex(e);s!==null&&this.updateAttribute(s,St.INDEX);const n=e.geometry.indirect;n!==null&&this.updateAttribute(n,St.INDIRECT)}updateAttribute(e,t){const s=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,s)):this.attributeCall.get(e.data)!==s&&(this.attributes.update(e,t),this.attributeCall.set(e.data,s),this.attributeCall.set(e,s)):this.attributeCall.get(e)!==s&&(this.attributes.update(e,t),this.attributeCall.set(e,s))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:s}=e;let n=t.index;if(s.wireframe===!0){const r=this.wireframes;let i=r.get(t);i===void 0?(i=Bc(t),r.set(t,i)):i.version!==uf(t)&&(this.attributes.delete(i),i=Bc(t),r.set(t,i)),n=i}return n}}class A_{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.compute={calls:0,frameCalls:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.memory={geometries:0,textures:0}}update(e,t,s){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=s*(t/3):e.isPoints?this.render.points+=s*t:e.isLineSegments?this.render.lines+=s*(t/2):e.isLine?this.render.lines+=s*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}updateTimestamp(e,t){this[e].timestampCalls===0&&(this[e].timestamp=0),this[e].timestamp+=t,this[e].timestampCalls++,this[e].timestampCalls>=this[e].previousFrameCalls&&(this[e].timestampCalls=0)}reset(){const e=this.render.frameCalls;this.render.previousFrameCalls=e;const t=this.compute.frameCalls;this.compute.previousFrameCalls=t,this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class cf{constructor(e){this.cacheKey=e,this.usedTimes=0}}class R_ extends cf{constructor(e,t,s){super(e),this.vertexProgram=t,this.fragmentProgram=s}}class C_ extends cf{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let E_=0;class Xi{constructor(e,t,s,n=null,r=null){this.id=E_++,this.code=e,this.stage=t,this.name=s,this.transforms=n,this.attributes=r,this.usedTimes=0}}class w_ extends os{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:s}=this,n=this.get(e);if(this._needsComputeUpdate(e)){const r=n.pipeline;r&&(r.usedTimes--,r.computeProgram.usedTimes--);const i=this.nodes.getForCompute(e);let a=this.programs.compute.get(i.computeShader);a===void 0&&(r&&r.computeProgram.usedTimes===0&&this._releaseProgram(r.computeProgram),a=new Xi(i.computeShader,"compute",e.name,i.transforms,i.nodeAttributes),this.programs.compute.set(i.computeShader,a),s.createProgram(a));const u=this._getComputeCacheKey(e,a);let c=this.caches.get(u);c===void 0&&(r&&r.usedTimes===0&&this._releasePipeline(r),c=this._getComputePipeline(e,a,u,t)),c.usedTimes++,a.usedTimes++,n.version=e.version,n.pipeline=c}return n.pipeline}getForRender(e,t=null){const{backend:s}=this,n=this.get(e);if(this._needsRenderUpdate(e)){const r=n.pipeline;r&&(r.usedTimes--,r.vertexProgram.usedTimes--,r.fragmentProgram.usedTimes--);const i=e.getNodeBuilderState(),a=e.material?e.material.name:"";let u=this.programs.vertex.get(i.vertexShader);u===void 0&&(r&&r.vertexProgram.usedTimes===0&&this._releaseProgram(r.vertexProgram),u=new Xi(i.vertexShader,"vertex",a),this.programs.vertex.set(i.vertexShader,u),s.createProgram(u));let c=this.programs.fragment.get(i.fragmentShader);c===void 0&&(r&&r.fragmentProgram.usedTimes===0&&this._releaseProgram(r.fragmentProgram),c=new Xi(i.fragmentShader,"fragment",a),this.programs.fragment.set(i.fragmentShader,c),s.createProgram(c));const l=this._getRenderCacheKey(e,u,c);let d=this.caches.get(l);d===void 0?(r&&r.usedTimes===0&&this._releasePipeline(r),d=this._getRenderPipeline(e,u,c,l,t)):e.pipeline=d,d.usedTimes++,u.usedTimes++,c.usedTimes++,n.pipeline=d}return n.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,s,n){s=s||this._getComputeCacheKey(e,t);let r=this.caches.get(s);return r===void 0&&(r=new C_(s,t),this.caches.set(s,r),this.backend.createComputePipeline(r,n)),r}_getRenderPipeline(e,t,s,n,r){n=n||this._getRenderCacheKey(e,t,s);let i=this.caches.get(n);return i===void 0&&(i=new R_(n,t,s),this.caches.set(n,i),e.pipeline=i,this.backend.createRenderPipeline(e,r)),i}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,s){return t.id+","+s.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,s=e.stage;this.programs[s].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class M_ extends os{constructor(e,t,s,n,r,i){super(),this.backend=e,this.textures=s,this.pipelines=r,this.attributes=n,this.nodes=t,this.info=i,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const s of t){const n=this.get(s);n.bindGroup===void 0&&(this._init(s),this.backend.createBindings(s,t,0),n.bindGroup=s)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const s of t){const n=this.get(s);n.bindGroup===void 0&&(this._init(s),this.backend.createBindings(s,t,0),n.bindGroup=s)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const s=t.attribute,n=s.isIndirectStorageBufferAttribute?St.INDIRECT:St.STORAGE;this.attributes.update(s,n)}}_update(e,t){const{backend:s}=this;let n=!1,r=!0,i=0,a=0;for(const u of e.bindings)if(!(u.isNodeUniformsGroup&&this.nodes.updateGroup(u)===!1)){if(u.isUniformBuffer)u.update()&&s.updateBinding(u);else if(u.isSampler)u.update();else if(u.isSampledTexture){const c=this.textures.get(u.texture);u.needsBindingsUpdate(c.generation)&&(n=!0);const l=u.update(),d=u.texture;l&&this.textures.updateTexture(d);const h=s.get(d);if(h.externalTexture!==void 0||c.isDefaultTexture?r=!1:(i=i*10+d.id,a+=d.version),s.isWebGPUBackend===!0&&h.texture===void 0&&h.externalTexture===void 0&&(console.error("Bindings._update: binding should be available:",u,l,d,u.textureNode.value,n),this.textures.updateTexture(d),n=!0),d.isStorageTexture===!0){const p=this.get(d);u.store===!0?p.needsMipmap=!0:this.textures.needsMipmaps(d)&&p.needsMipmap===!0&&(this.backend.generateMipmaps(d),p.needsMipmap=!1)}}}n===!0&&this.backend.updateBindings(e,t,r?i:0,a)}}function B_(o,e){return o.groupOrder!==e.groupOrder?o.groupOrder-e.groupOrder:o.renderOrder!==e.renderOrder?o.renderOrder-e.renderOrder:o.material.id!==e.material.id?o.material.id-e.material.id:o.z!==e.z?o.z-e.z:o.id-e.id}function Fc(o,e){return o.groupOrder!==e.groupOrder?o.groupOrder-e.groupOrder:o.renderOrder!==e.renderOrder?o.renderOrder-e.renderOrder:o.z!==e.z?e.z-o.z:o.id-e.id}function Uc(o){return(o.transmission>0||o.transmissionNode)&&o.side===js&&o.forceSinglePass===!1}class F_{constructor(e,t,s){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,s),this.lightsArray=[],this.scene=t,this.camera=s,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,s,n,r,i,a){let u=this.renderItems[this.renderItemsIndex];return u===void 0?(u={id:e.id,object:e,geometry:t,material:s,groupOrder:n,renderOrder:e.renderOrder,z:r,group:i,clippingContext:a},this.renderItems[this.renderItemsIndex]=u):(u.id=e.id,u.object=e,u.geometry=t,u.material=s,u.groupOrder=n,u.renderOrder=e.renderOrder,u.z=r,u.group=i,u.clippingContext=a),this.renderItemsIndex++,u}push(e,t,s,n,r,i,a){const u=this.getNextRenderItem(e,t,s,n,r,i,a);e.occlusionTest===!0&&this.occlusionQueryCount++,s.transparent===!0||s.transmission>0?(Uc(s)&&this.transparentDoublePass.push(u),this.transparent.push(u)):this.opaque.push(u)}unshift(e,t,s,n,r,i,a){const u=this.getNextRenderItem(e,t,s,n,r,i,a);s.transparent===!0||s.transmission>0?(Uc(s)&&this.transparentDoublePass.unshift(u),this.transparent.unshift(u)):this.opaque.unshift(u)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||B_),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||Fc),this.transparent.length>1&&this.transparent.sort(t||Fc)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,c=a.height>>t;let l=e.depthTexture||r[t];const d=e.depthBuffer===!0||e.stencilBuffer===!0;let h=!1;l===void 0&&d&&(l=new vs,l.format=e.stencilBuffer?oi:ai,l.type=e.stencilBuffer?ui:Le,l.image.width=u,l.image.height=c,r[t]=l),(s.width!==a.width||a.height!==s.height)&&(h=!0,l&&(l.needsUpdate=!0,l.image.width=u,l.image.height=c)),s.width=a.width,s.height=a.height,s.textures=i,s.depthTexture=l||null,s.depth=e.depthBuffer,s.stencil=e.stencilBuffer,s.renderTarget=e,s.sampleCount!==n&&(h=!0,l&&(l.needsUpdate=!0),s.sampleCount=n);const p={sampleCount:n};for(let f=0;f{e.removeEventListener("dispose",f);for(let m=0;m0){const l=e.image;if(l===void 0)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(l.complete===!1)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const d=[];for(const h of e.images)d.push(h);t.images=d}else t.image=l;(s.isDefaultTexture===void 0||s.isDefaultTexture===!0)&&(r.createTexture(e,t),s.isDefaultTexture=!1,s.generation=e.version),e.source.dataReady===!0&&r.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&r.generateMipmaps(e)}}else r.createDefaultTexture(e),s.isDefaultTexture=!0,s.generation=e.version;if(s.initialized!==!0){s.initialized=!0,s.generation=e.version,this.info.memory.textures++;const c=()=>{e.removeEventListener("dispose",c),this._destroyTexture(e),this.info.memory.textures--};e.addEventListener("dispose",c)}s.version=e.version}getSize(e,t=I_){let s=e.images?e.images[0]:e.image;return s?(s.image!==void 0&&(s=s.image),t.width=s.width||1,t.height=s.height||1,t.depth=e.isCubeTexture?6:s.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,s){let n;return e.isCompressedTexture?e.mipmaps?n=e.mipmaps.length:n=1:n=Math.floor(Math.log2(Math.max(t,s)))+1,n}needsMipmaps(e){return this.isEnvironmentTexture(e)||e.isCompressedTexture===!0||e.generateMipmaps}isEnvironmentTexture(e){const t=e.mapping;return t===jn||t===Qn||t===Zs||t===Js}_destroyTexture(e){this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e)}}class Ru extends mt{constructor(e,t,s,n=1){super(e,t,s),this.a=n}set(e,t,s,n=1){return this.a=n,super.set(e,t,s)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class df extends se{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const G_=(o,e)=>E(new df(o,e));class O_ extends O{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const s=new Cn(t);return this._currentCond=Ue(e,s),this.add(this._currentCond)}ElseIf(e,t){const s=new Cn(t),n=Ue(e,s);return this._currentCond.elseNode=n,this._currentCond=n,this}Else(e){return this._currentCond.elseNode=new Cn(e),this}build(e,...t){const s=Ea();On(this);for(const n of this.nodes)n.build(e,"void");return On(s),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const kr=C(O_);class hf extends O{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);const t=this.members,s=[];for(let n=0;n{const e=o.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),ta=(o,e)=>ht($(4,o.mul(Y(1,o))),e),$_=(o,e)=>o.lessThan(.5)?ta(o.mul(2),e).div(2):Y(1,ta($(Y(1,o),2),e).div(2)),H_=(o,e,t)=>ht(gt(ht(o,e),_e(ht(o,e),ht(Y(1,o),t))),1/e),q_=(o,e)=>st(Qr.mul(e.mul(o).sub(1))).div(Qr.mul(e.mul(o).sub(1))),Vt=b(([o])=>o.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),K_=b(([o])=>T(Vt(o.z.add(Vt(o.y.mul(1)))),Vt(o.z.add(Vt(o.x.mul(1)))),Vt(o.y.add(Vt(o.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),X_=b(([o,e,t])=>{const s=T(o).toVar(),n=g(1.4).toVar(),r=g(0).toVar(),i=T(s).toVar();return te({start:g(0),end:g(3),type:"float",condition:"<="},()=>{const a=T(K_(i.mul(2))).toVar();s.addAssign(a.add(t.mul(g(.1).mul(e)))),i.mulAssign(1.8),n.mulAssign(1.5),s.mulAssign(1.2);const u=g(Vt(s.z.add(Vt(s.x.add(Vt(s.y)))))).toVar();r.addAssign(u.div(n)),i.addAssign(.14)}),r}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class Y_ extends O{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let s=this._candidateFnCall;if(s===null){let n=null,r=-1;for(const i of this.functionNodes){const u=i.shaderNode.layout;if(u===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const c=u.inputs;if(t.length===c.length){let l=0;for(let d=0;dr&&(n=i,r=l)}}this._candidateFnCall=s=n(...t)}return s}}const j_=C(Y_),Pe=o=>(...e)=>j_(o,...e),Cs=V(0).setGroup(k).onRenderUpdate(o=>o.time),gf=V(0).setGroup(k).onRenderUpdate(o=>o.deltaTime),Q_=V(0,"uint").setGroup(k).onRenderUpdate(o=>o.frameId),Z_=(o=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),Cs.mul(o)),J_=(o=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),Cs.mul(o)),eb=(o=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),gf.mul(o)),tb=(o=Cs)=>o.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),sb=(o=Cs)=>o.fract().round(),nb=(o=Cs)=>o.add(.5).fract().mul(2).sub(1).abs(),rb=(o=Cs)=>o.fract(),ib=b(([o,e,t=M(.5)])=>Au(o.sub(t),e).add(t)),ob=b(([o,e,t=M(.5)])=>{const s=o.sub(t),n=s.dot(s),i=n.mul(n).mul(e);return o.add(s.mul(i))}),ab=b(({position:o=null,horizontal:e=!0,vertical:t=!1})=>{let s;o!==null?(s=at.toVar(),s[3][0]=o.x,s[3][1]=o.y,s[3][2]=o.z):s=at;const n=je.mul(s);return Gn(e)&&(n[0][0]=at[0].length(),n[0][1]=0,n[0][2]=0),Gn(t)&&(n[1][0]=0,n[1][1]=at[1].length(),n[1][2]=0),n[2][0]=0,n[2][1]=0,n[2][2]=1,He.mul(n).mul(me)}),ub=b(([o=null])=>{const e=ei();return ei(gu(o)).sub(e).lessThan(0).select(Bt,o)});class cb extends O{static get type(){return"SpriteSheetUVNode"}constructor(e,t=le(),s=g(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=s}setup(){const{frameNode:e,uvNode:t,countNode:s}=this,{width:n,height:r}=s,i=e.mod(n.mul(r)).floor(),a=i.mod(n),u=r.sub(i.add(1).div(n).ceil()),c=s.reciprocal(),l=M(a,u);return t.add(l).mul(c)}}const lb=C(cb);class db extends O{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,s=null,n=g(1),r=me,i=Xe){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=s,this.scaleNode=n,this.positionNode=r,this.normalNode=i}setup(){const{textureXNode:e,textureYNode:t,textureZNode:s,scaleNode:n,positionNode:r,normalNode:i}=this;let a=i.abs().normalize();a=a.div(a.dot(T(1)));const u=r.yz.mul(n),c=r.zx.mul(n),l=r.xy.mul(n),d=e.value,h=t!==null?t.value:d,p=s!==null?s.value:d,f=K(d,u).mul(a.x),m=K(h,c).mul(a.y),x=K(p,l).mul(a.z);return _e(f,m,x)}}const mf=C(db),hb=(...o)=>mf(...o),Fs=new vl,as=new j,Us=new j,Yi=new j,yn=new Ie,Tr=new j(0,0,-1),xt=new Me,xn=new j,_r=new j,Tn=new Me,br=new Ye,si=new Ss,pb=Bt.flipX();si.depthTexture=new vs(1,1);let ji=!1;class Cu extends wt{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||si.texture,pb),this._reflectorBaseNode=e.reflector||new fb(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=E(new Cu({defaultTexture:si.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}}class fb extends O{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:s=new Zg,resolution:n=1,generateMipmaps:r=!1,bounces:i=!0,depth:a=!1}=t;this.textureNode=e,this.target=s,this.resolution=n,this.generateMipmaps=r,this.bounces=i,this.depth=a,this.updateBeforeType=i?W.RENDER:W.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){const s=this.resolution;t.getDrawingBufferSize(br),e.setSize(Math.round(br.width*s),Math.round(br.height*s))}setup(e){return this._updateResolution(si,e.renderer),super.setup(e)}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new Ss(0,0,{type:pt}),this.generateMipmaps===!0&&(t.texture.minFilter=Jg,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new vs),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&ji)return!1;ji=!0;const{scene:t,camera:s,renderer:n,material:r}=e,{target:i}=this,a=this.getVirtualCamera(s),u=this.getRenderTarget(a);if(n.getDrawingBufferSize(br),this._updateResolution(u,n),Us.setFromMatrixPosition(i.matrixWorld),Yi.setFromMatrixPosition(s.matrixWorld),yn.extractRotation(i.matrixWorld),as.set(0,0,1),as.applyMatrix4(yn),xn.subVectors(Us,Yi),xn.dot(as)>0)return;xn.reflect(as).negate(),xn.add(Us),yn.extractRotation(s.matrixWorld),Tr.set(0,0,-1),Tr.applyMatrix4(yn),Tr.add(Yi),_r.subVectors(Us,Tr),_r.reflect(as).negate(),_r.add(Us),a.coordinateSystem=s.coordinateSystem,a.position.copy(xn),a.up.set(0,1,0),a.up.applyMatrix4(yn),a.up.reflect(as),a.lookAt(_r),a.near=s.near,a.far=s.far,a.updateMatrixWorld(),a.projectionMatrix.copy(s.projectionMatrix),Fs.setFromNormalAndCoplanarPoint(as,Us),Fs.applyMatrix4(a.matrixWorldInverse),xt.set(Fs.normal.x,Fs.normal.y,Fs.normal.z,Fs.constant);const c=a.projectionMatrix;Tn.x=(Math.sign(xt.x)+c.elements[8])/c.elements[0],Tn.y=(Math.sign(xt.y)+c.elements[9])/c.elements[5],Tn.z=-1,Tn.w=(1+c.elements[10])/c.elements[14],xt.multiplyScalar(1/xt.dot(Tn));const l=0;c.elements[2]=xt.x,c.elements[6]=xt.y,c.elements[10]=n.coordinateSystem===ln?xt.z-l:xt.z+1-l,c.elements[14]=xt.w,this.textureNode.value=u.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=u.depthTexture),r.visible=!1;const d=n.getRenderTarget(),h=n.getMRT(),p=n.autoClear;n.setMRT(null),n.setRenderTarget(u),n.autoClear=!0,n.render(t,a),n.setMRT(h),n.setRenderTarget(d),n.autoClear=p,r.visible=!0,ji=!1}}const gb=o=>E(new Cu(o)),Qi=new Tl(-1,1,1,-1,0,1);class mb extends Sl{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new ju([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new ju(t,2))}}const yb=new mb;class Mi extends tn{constructor(e=null){super(yb,e),this.camera=Qi,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,Qi)}render(e){e.render(this,Qi)}}const xb=new Ye;class Tb extends wt{static get type(){return"RTTNode"}constructor(e,t=null,s=null,n={type:pt}){const r=new Ss(t,s,n);super(r.texture,le()),this.node=e,this.width=t,this.height=s,this.pixelRatio=1,this.renderTarget=r,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new Mi(new ce),this.updateBeforeType=W.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const s=e*this.pixelRatio,n=t*this.pixelRatio;this.renderTarget.setSize(s,n),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();const s=e.getSize(xb);this.setSize(s.width,s.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new wt(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const yf=(o,...e)=>E(new Tb(E(o),...e)),_b=(o,...e)=>o.isTextureNode?o:o.isPassNode?o.getTextureNode():yf(o,...e),ks=b(([o,e,t],s)=>{let n;s.renderer.coordinateSystem===ln?(o=M(o.x,o.y.oneMinus()).mul(2).sub(1),n=P(T(o,e),1)):n=P(T(o.x,o.y.oneMinus(),e).mul(2).sub(1),1);const r=P(t.mul(n));return r.xyz.div(r.w)}),bb=b(([o,e])=>{const t=e.mul(P(o,1)),s=t.xy.div(t.w).mul(.5).add(.5).toVar();return M(s.x,s.y.oneMinus())}),Nb=b(([o,e,t])=>{const s=ns(ge(e)),n=Ae(o.mul(s)).toVar(),r=ge(e,n).toVar(),i=ge(e,n.sub(Ae(2,0))).toVar(),a=ge(e,n.sub(Ae(1,0))).toVar(),u=ge(e,n.add(Ae(1,0))).toVar(),c=ge(e,n.add(Ae(2,0))).toVar(),l=ge(e,n.add(Ae(0,2))).toVar(),d=ge(e,n.add(Ae(0,1))).toVar(),h=ge(e,n.sub(Ae(0,1))).toVar(),p=ge(e,n.sub(Ae(0,2))).toVar(),f=oe(Y(g(2).mul(a).sub(i),r)).toVar(),m=oe(Y(g(2).mul(u).sub(c),r)).toVar(),x=oe(Y(g(2).mul(d).sub(l),r)).toVar(),N=oe(Y(g(2).mul(h).sub(p),r)).toVar(),v=ks(o,r,t).toVar(),w=f.lessThan(m).select(v.sub(ks(o.sub(M(g(1).div(s.x),0)),a,t)),v.negate().add(ks(o.add(M(g(1).div(s.x),0)),u,t))),B=x.lessThan(N).select(v.sub(ks(o.add(M(0,g(1).div(s.y))),d,t)),v.negate().add(ks(o.sub(M(0,g(1).div(s.y))),h,t)));return qt(_i(w,B))});class Sb extends oa{constructor(e,t,s=Float32Array){const n=ArrayBuffer.isView(e)?e:new s(e*t);super(n,t),this.isStorageInstancedBufferAttribute=!0}}class xf extends Ur{constructor(e,t,s=Float32Array){const n=ArrayBuffer.isView(e)?e:new s(e*t);super(n,t),this.isStorageBufferAttribute=!0}}class vb extends Rs{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let s;const n=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&n!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?s=e.generatePBO(this):s=this.node.build(e):s=super.generate(e),n!==!0){const r=this.getNodeType(e);s=e.format(s,r,t)}return s}}const Ab=C(vb);class Rb extends iu{static get type(){return"StorageBufferNode"}constructor(e,t=null,s=0){t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t=ya(e.itemSize),s=e.count),super(e,t,s),this.isStorageBufferNode=!0,this.access=Ve.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Ab(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Ve.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=nr(this.value),this._varying=ke(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}generate(e){if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:s}=this.getAttributeData(),n=s.build(e);return e.registerTransform(n,t),n}}const Bi=(o,e=null,t=0)=>E(new Rb(o,e,t)),Cb=(o,e,t)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),Bi(o,e,t).setPBO(!0)),Eb=(o,e="float")=>{const t=Ta(e),s=xa(e),n=new xf(o,t,s);return Bi(n,e,o)},wb=(o,e="float")=>{const t=Ta(e),s=xa(e),n=new Sb(o,t,s);return Bi(n,e,o)};class Mb extends Uh{static get type(){return"VertexColorNode"}constructor(e=0){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),s=e.hasGeometryAttribute(t);let n;return s===!0?n=super.generate(e):n=e.generateConst(this.nodeType,new Me(1,1,1,1)),n}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const Bb=o=>E(new Mb(o));class Fb extends O{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Ub=U(Fb),_n=new Wg,Zi=new Ie;class Ke extends O{static get type(){return"SceneNode"}constructor(e=Ke.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,s=this.scene!==null?this.scene:e.scene;let n;return t===Ke.BACKGROUND_BLURRINESS?n=ne("backgroundBlurriness","float",s):t===Ke.BACKGROUND_INTENSITY?n=ne("backgroundIntensity","float",s):t===Ke.BACKGROUND_ROTATION?n=V("mat4").label("backgroundRotation").setGroup(k).onRenderUpdate(()=>{const r=s.background;return r!==null&&r.isTexture&&r.mapping!==zg?(_n.copy(s.backgroundRotation),_n.x*=-1,_n.y*=-1,_n.z*=-1,Zi.makeRotationFromEuler(_n)):Zi.identity(),Zi}):console.error("THREE.SceneNode: Unknown scope:",t),n}}Ke.BACKGROUND_BLURRINESS="backgroundBlurriness";Ke.BACKGROUND_INTENSITY="backgroundIntensity";Ke.BACKGROUND_ROTATION="backgroundRotation";const Tf=U(Ke,Ke.BACKGROUND_BLURRINESS),sa=U(Ke,Ke.BACKGROUND_INTENSITY),_f=U(Ke,Ke.BACKGROUND_ROTATION);class Pb extends wt{static get type(){return"StorageTextureNode"}constructor(e,t,s=null){super(e,t),this.storeNode=s,this.isStorageTextureNode=!0,this.access=Ve.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);t.storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let s;return this.storeNode!==null?s=this.generateStore(e):s=super.generate(e,t),s}toReadWrite(){return this.setAccess(Ve.READ_WRITE)}toReadOnly(){return this.setAccess(Ve.READ_ONLY)}toWriteOnly(){return this.setAccess(Ve.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:s,storeNode:n}=t,r=super.generate(e,"property"),i=s.build(e,"uvec2"),a=n.build(e,"vec4"),u=e.generateTextureStore(e,r,i,a);e.addLineFlowCode(u,this)}}const bf=C(Pb),Db=(o,e,t)=>{const s=bf(o,e,t);return t!==null&&s.append(),s};class Lb extends Ai{static get type(){return"UserDataNode"}constructor(e,t,s=null){super(e,t,s),this.userData=s}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const Ib=(o,e,t)=>E(new Lb(o,e,t)),Pc=new WeakMap;class Vb extends be{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=W.OBJECT,this.updateAfterType=W.OBJECT,this.previousModelWorldMatrix=V(new Ie),this.previousProjectionMatrix=V(new Ie).setGroup(k),this.previousCameraViewMatrix=V(new Ie)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:s}){const n=Dc(s);this.previousModelWorldMatrix.value.copy(n);const r=Nf(t);r.frameId!==e&&(r.frameId=e,r.previousProjectionMatrix===void 0?(r.previousProjectionMatrix=new Ie,r.previousCameraViewMatrix=new Ie,r.currentProjectionMatrix=new Ie,r.currentCameraViewMatrix=new Ie,r.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),r.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(r.previousProjectionMatrix.copy(r.currentProjectionMatrix),r.previousCameraViewMatrix.copy(r.currentCameraViewMatrix)),r.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),r.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(r.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(r.previousCameraViewMatrix))}updateAfter({object:e}){Dc(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?He:V(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),s=e.mul(Kt).mul(me),n=this.previousProjectionMatrix.mul(t).mul(Jr),r=s.xy.div(s.w),i=n.xy.div(n.w);return Y(r,i)}}function Nf(o){let e=Pc.get(o);return e===void 0&&(e={},Pc.set(o,e)),e}function Dc(o,e=0){const t=Nf(o);let s=t[e];return s===void 0&&(t[e]=s=new Ie),s}const Gb=U(Vb),Sf=b(([o,e])=>Re(1,o.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),vf=b(([o,e])=>Re(o.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Af=b(([o,e])=>o.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Rf=b(([o,e])=>Q(o.mul(2).mul(e),o.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),Ti(.5,o))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Ob=b(([o,e])=>{const t=e.a.add(o.a.mul(e.a.oneMinus()));return P(e.rgb.mul(e.a).add(o.rgb.mul(o.a).mul(e.a.oneMinus())).div(t),t)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),kb=(...o)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),Sf(o)),zb=(...o)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),vf(o)),Wb=(...o)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),Af(o)),$b=(...o)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),Rf(o)),Hb=b(([o])=>Eu(o.rgb)),qb=b(([o,e=g(1)])=>e.mix(Eu(o.rgb),o.rgb)),Kb=b(([o,e=g(1)])=>{const t=_e(o.r,o.g,o.b).div(3),s=o.r.max(o.g.max(o.b)),n=s.sub(t).mul(e).mul(-3);return Q(o.rgb,s,n)}),Xb=b(([o,e=g(1)])=>{const t=T(.57735,.57735,.57735),s=e.cos();return T(o.rgb.mul(s).add(t.cross(o.rgb).mul(e.sin()).add(t.mul(is(t,o.rgb).mul(s.oneMinus())))))}),Eu=(o,e=T(_t.getLuminanceCoefficients(new j)))=>is(o,e),Yb=b(([o,e=T(1),t=T(0),s=T(1),n=g(1),r=T(_t.getLuminanceCoefficients(new j,kt))])=>{const i=o.rgb.dot(T(r)),a=ue(o.rgb.mul(e).add(t),0).toVar(),u=a.pow(s).toVar();return z(a.r.greaterThan(0),()=>{a.r.assign(u.r)}),z(a.g.greaterThan(0),()=>{a.g.assign(u.g)}),z(a.b.greaterThan(0),()=>{a.b.assign(u.b)}),a.assign(i.add(a.sub(i).mul(n))),P(a.rgb,o.a)});class jb extends be{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const Qb=C(jb),Zb=new Ye;class Cf extends wt{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class Lc extends Cf{static get type(){return"PassMultipleTextureNode"}constructor(e,t,s=!1){super(e,null),this.textureName=t,this.previousTexture=s}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class Ut extends be{static get type(){return"PassNode"}constructor(e,t,s,n={}){super("vec4"),this.scope=e,this.scene=t,this.camera=s,this.options=n,this._pixelRatio=1,this._width=1,this._height=1;const r=new vs;r.isRenderTargetTexture=!0,r.name="depth";const i=new Ss(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:pt,...n});i.texture.name="output",i.depthTexture=r,this.renderTarget=i,this._textures={output:i.texture,depth:r},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=V(0),this._cameraFar=V(0),this._mrt=null,this.isPassNode=!0,this.updateBeforeType=W.FRAME}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const s=this._textures[e],n=this.renderTarget.textures.indexOf(s);this.renderTarget.textures[n]=t,this._textures[e]=t,this._previousTextures[e]=s,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=E(new Lc(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=E(new Lc(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const s=this._cameraNear,n=this._cameraFar;this._viewZNodes[e]=t=mu(this.getTextureNode(e),s,n)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const s=this._cameraNear,n=this._cameraFar,r=this.getViewZNode(e);this._linearDepthNodes[e]=t=Qs(r,s,n)}return t}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.scope===Ut.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:s,camera:n}=this;this._pixelRatio=t.getPixelRatio();const r=t.getSize(Zb);this.setSize(r.width,r.height);const i=t.getRenderTarget(),a=t.getMRT();this._cameraNear.value=n.near,this._cameraFar.value=n.far;for(const u in this._previousTextures)this.toggleTexture(u);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(s,n),t.setRenderTarget(i),t.setMRT(a)}setSize(e,t){this._width=e,this._height=t;const s=this._width*this._pixelRatio,n=this._height*this._pixelRatio;this.renderTarget.setSize(s,n)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}Ut.COLOR="color";Ut.DEPTH="depth";const Jb=(o,e,t)=>E(new Ut(Ut.COLOR,o,e,t)),eN=(o,e)=>E(new Cf(o,e)),tN=(o,e,t)=>E(new Ut(Ut.DEPTH,o,e,t));class sN extends Ut{static get type(){return"ToonOutlinePassNode"}constructor(e,t,s,n,r){super(Ut.COLOR,e,t),this.colorNode=s,this.thicknessNode=n,this.alphaNode=r,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,s=t.getRenderObjectFunction();t.setRenderObjectFunction((n,r,i,a,u,c,l,d)=>{if((u.isMeshToonMaterial||u.isMeshToonNodeMaterial)&&u.wireframe===!1){const h=this._getOutlineMaterial(u);t.renderObject(n,r,i,a,h,c,l,d)}t.renderObject(n,r,i,a,u,c,l,d)}),super.updateBefore(e),t.setRenderObjectFunction(s)}_createMaterial(){const e=new ce;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=Ct;const t=Xe.negate(),s=He.mul(Kt),n=g(1),r=s.mul(P(me,1)),i=s.mul(P(me.add(t),1)),a=qt(r.sub(i));return e.vertexNode=r.add(a.mul(this.thicknessNode).mul(r.w).mul(n)),e.colorNode=P(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const nN=(o,e,t=new mt(0,0,0),s=.003,n=1)=>E(new sN(o,e,E(t),E(s),E(n))),Ef=b(([o,e])=>o.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),wf=b(([o,e])=>(o=o.mul(e),o.div(o.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Mf=b(([o,e])=>{o=o.mul(e),o=o.sub(.004).max(0);const t=o.mul(o.mul(6.2).add(.5)),s=o.mul(o.mul(6.2).add(1.7)).add(.06);return t.div(s).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),rN=b(([o])=>{const e=o.mul(o.add(.0245786)).sub(90537e-9),t=o.mul(o.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),Bf=b(([o,e])=>{const t=Oe(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=Oe(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return o=o.mul(e).div(.6),o=t.mul(o),o=rN(o),o=s.mul(o),o.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),iN=Oe(T(1.6605,-.1246,-.0182),T(-.5876,1.1329,-.1006),T(-.0728,-.0083,1.1187)),oN=Oe(T(.6274,.0691,.0164),T(.3293,.9195,.088),T(.0433,.0113,.8956)),aN=b(([o])=>{const e=T(o).toVar(),t=T(e.mul(e)).toVar(),s=T(t.mul(t)).toVar();return g(15.5).mul(s.mul(t)).sub($(40.14,s.mul(e))).add($(31.96,s).sub($(6.868,t.mul(e))).add($(.4298,t).add($(.1191,e).sub(.00232))))}),Ff=b(([o,e])=>{const t=T(o).toVar(),s=Oe(T(.856627153315983,.137318972929847,.11189821299995),T(.0951212405381588,.761241990602591,.0767994186031903),T(.0482516061458583,.101439036467562,.811302368396859)),n=Oe(T(1.1271005818144368,-.1413297634984383,-.14132976349843826),T(-.11060664309660323,1.157823702216272,-.11060664309660294),T(-.016493938717834573,-.016493938717834257,1.2519364065950405)),r=g(-12.47393),i=g(4.026069);return t.mulAssign(e),t.assign(oN.mul(t)),t.assign(s.mul(t)),t.assign(ue(t,1e-10)),t.assign(vt(t)),t.assign(t.sub(r).div(i.sub(r))),t.assign(Et(t,0,1)),t.assign(aN(t)),t.assign(n.mul(t)),t.assign(ht(ue(T(0),t),T(2.2))),t.assign(iN.mul(t)),t.assign(Et(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Uf=b(([o,e])=>{const t=g(.76),s=g(.15);o=o.mul(e);const n=Re(o.r,Re(o.g,o.b)),r=Ue(n.lessThan(.08),n.sub($(6.25,n.mul(n))),.04);o.subAssign(r);const i=ue(o.r,ue(o.g,o.b));z(i.lessThan(t),()=>o);const a=Y(1,t),u=Y(1,a.mul(a).div(i.add(a.sub(t))));o.mulAssign(u.div(i));const c=Y(1,gt(1,s.mul(i.sub(u)).add(1)));return Q(o,T(u),c)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Ne extends O{static get type(){return"CodeNode"}constructor(e="",t=[],s=""){super("code"),this.isCodeNode=!0,this.code=e,this.includes=t,this.language=s}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const n of t)n.build(e);const s=e.getCodeFromNode(this,this.getNodeType(e));return s.code=this.code,s.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Fi=C(Ne),uN=(o,e)=>Fi(o,e,"js"),cN=(o,e)=>Fi(o,e,"wgsl"),lN=(o,e)=>Fi(o,e,"glsl");class Pf extends Ne{static get type(){return"FunctionNode"}constructor(e="",t=[],s=""){super(e,t,s)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let s=t.nodeFunction;return s===void 0&&(s=e.parser.parseFunction(this.code),t.nodeFunction=s),s}generate(e,t){super.generate(e);const s=this.getNodeFunction(e),n=s.name,r=s.type,i=e.getCodeFromNode(this,r);n!==""&&(i.name=n);const a=e.getPropertyName(i),u=this.getNodeFunction(e).getCode(a);return i.code=u+` -`,t==="property"?a:e.format(`${a}()`,r,t)}}const Df=(o,e=[],t="")=>{for(let r=0;rs.call(...r);return n.functionNode=s,n},dN=(o,e)=>Df(o,e,"glsl"),hN=(o,e)=>Df(o,e,"wgsl");class pN extends O{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new gl,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:g()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=Na(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=Sa(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const zr=C(pN);class Lf extends Map{get(e,t=null,...s){if(this.has(e))return super.get(e);if(t!==null){const n=t(...s);return this.set(e,n),n}}}class fN{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const Wr=new Lf;class gN extends O{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new Lf,this._output=zr(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const s=this._outputs;return s[e]===void 0?s[e]=zr(t):s[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const s=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),s[e]=t,s[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),s[e]=t,s[e].events.addEventListener("refresh",this.onRefresh)):s[e]===void 0?(s[e]=zr(t),s[e].events.addEventListener("refresh",this.onRefresh)):s[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const n=this.getObject()[e];if(typeof n=="function")return n(...t)}async callAsync(e,...t){const n=this.getObject()[e];if(typeof n=="function")return n.constructor.name==="AsyncFunction"?await n(...t):n(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(c,l)=>this.setOutput(c,l),s=new fN(this),n=Wr.get("THREE"),r=Wr.get("TSL"),i=this.getMethod(),a=[s,this._local,Wr,e,t,n,r];this._object=i(...a);const u=this._object.layout;if(u&&(u.cache===!1&&this._local.clear(),this._output.outputType=u.outputType||null,Array.isArray(u.elements)))for(const c of u.elements){const l=c.id||c.name;c.inputType&&(this.getParameter(l)===void 0&&this.setParameter(l,null),this.getParameter(l).inputType=c.inputType),c.outputType&&(this.getOutput(l)===void 0&&this.setOutput(l,null),this.getOutput(l).outputType=c.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let s=this.parameters[t];s.isScriptableNode&&(s=s.getDefaultOutput()),s.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:g()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],s=["layout","init","main","dispose"].join(", "),n="var "+s+`; var output = {}; -`,r=` -return { ...output, `+s+" };",i=n+this.codeNode.code+r;return this._method=new Function(...e,i),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[ga(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const s in this.parameters)t.push(this.parameters[s].getCacheKey(e));return Zn(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const mN=C(gN);function If(o){let e;const t=o.context.getViewZ;return t!==void 0&&(e=t(this)),(e||xe.z).negate()}const wu=b(([o,e],t)=>{const s=If(t);return ct(o,e,s)}),Mu=b(([o],e)=>{const t=If(e);return o.mul(o,t,t).negate().exp().oneMinus()}),Xn=b(([o,e])=>P(e.toFloat().mix($n.rgb,o.toVec3()),$n.a));function yN(o,e,t){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),Xn(o,wu(e,t))}function xN(o,e){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),Xn(o,Mu(e))}let us=null,cs=null;class TN extends O{static get type(){return"RangeNode"}constructor(e=g(),t=g()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Ot(this.minNode.value)),s=e.getTypeLength(Ot(this.maxNode.value));return t>s?t:s}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let s=null;if(t.count>1){const n=this.minNode.value,r=this.maxNode.value,i=e.getTypeLength(Ot(n)),a=e.getTypeLength(Ot(r));us=us||new Me,cs=cs||new Me,us.setScalar(0),cs.setScalar(0),i===1?us.setScalar(n):n.isColor?us.set(n.r,n.g,n.b,1):us.set(n.x,n.y,n.z||0,n.w||0),a===1?cs.setScalar(r):r.isColor?cs.set(r.r,r.g,r.b,1):cs.set(r.x,r.y,r.z||0,r.w||0);const u=4,c=u*t.count,l=new Float32Array(c);for(let h=0;hE(new bN(o,e)),NN=Ui("numWorkgroups","uvec3"),SN=Ui("workgroupId","uvec3"),vN=Ui("localId","uvec3"),AN=Ui("subgroupSize","uint");class RN extends O{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:s}=e;s.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier -`):e.addLineFlowCode(`${t}Barrier()`,this)}}const Bu=C(RN),CN=()=>Bu("workgroup").append(),EN=()=>Bu("storage").append(),wN=()=>Bu("texture").append();class MN extends Rs{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let s;const n=e.context.assign;if(s=super.generate(e),n!==!0){const r=this.getNodeType(e);s=e.format(s,r,t)}return s}}class BN extends O{constructor(e,t,s=0){super(t),this.bufferType=t,this.bufferCount=s,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return E(new MN(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const FN=(o,e)=>E(new BN("Workgroup",o,e));class Be extends be{static get type(){return"AtomicFunctionNode"}constructor(e,t,s,n=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=s,this.storeNode=n}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,s=this.getNodeType(e),n=this.getInputType(e),r=this.pointerNode,i=this.valueNode,a=[];a.push(`&${r.build(e,n)}`),a.push(i.build(e,n));const u=`${e.getMethod(t,s)}( ${a.join(", ")} )`;if(this.storeNode!==null){const c=this.storeNode.build(e,n);e.addLineFlowCode(`${c} = ${u}`,this)}else e.addLineFlowCode(u,this)}}Be.ATOMIC_LOAD="atomicLoad";Be.ATOMIC_STORE="atomicStore";Be.ATOMIC_ADD="atomicAdd";Be.ATOMIC_SUB="atomicSub";Be.ATOMIC_MAX="atomicMax";Be.ATOMIC_MIN="atomicMin";Be.ATOMIC_AND="atomicAnd";Be.ATOMIC_OR="atomicOr";Be.ATOMIC_XOR="atomicXor";const UN=C(Be),Yt=(o,e,t,s=null)=>{const n=UN(o,e,t,s);return n.append(),n},PN=(o,e,t=null)=>Yt(Be.ATOMIC_STORE,o,e,t),DN=(o,e,t=null)=>Yt(Be.ATOMIC_ADD,o,e,t),LN=(o,e,t=null)=>Yt(Be.ATOMIC_SUB,o,e,t),IN=(o,e,t=null)=>Yt(Be.ATOMIC_MAX,o,e,t),VN=(o,e,t=null)=>Yt(Be.ATOMIC_MIN,o,e,t),GN=(o,e,t=null)=>Yt(Be.ATOMIC_AND,o,e,t),ON=(o,e,t=null)=>Yt(Be.ATOMIC_OR,o,e,t),kN=(o,e,t=null)=>Yt(Be.ATOMIC_XOR,o,e,t);let Nr;function hr(o){Nr=Nr||new WeakMap;let e=Nr.get(o);return e===void 0&&Nr.set(o,e={}),e}function Fu(o){const e=hr(o);return e.shadowMatrix||(e.shadowMatrix=V("mat4").setGroup(k).onRenderUpdate(()=>(o.castShadow!==!0&&o.shadow.updateMatrices(o),o.shadow.matrix)))}function Vf(o){const e=hr(o);if(e.projectionUV===void 0){const t=Fu(o).mul(Wt);e.projectionUV=t.xyz.div(t.w)}return e.projectionUV}function Uu(o){const e=hr(o);return e.position||(e.position=V(new j).setGroup(k).onRenderUpdate((t,s)=>s.value.setFromMatrixPosition(o.matrixWorld)))}function Gf(o){const e=hr(o);return e.targetPosition||(e.targetPosition=V(new j).setGroup(k).onRenderUpdate((t,s)=>s.value.setFromMatrixPosition(o.target.matrixWorld)))}function Pi(o){const e=hr(o);return e.viewPosition||(e.viewPosition=V(new j).setGroup(k).onRenderUpdate(({camera:t},s)=>{s.value=s.value||new j,s.value.setFromMatrixPosition(o.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)}))}const Pu=o=>je.transformDirection(Uu(o).sub(Gf(o))),zN=o=>o.sort((e,t)=>e.id-t.id),WN=(o,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===o)return t;return null},Ji=new WeakMap;class Du extends O{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=T().toVar("totalDiffuse"),this.totalSpecularNode=T().toVar("totalSpecular"),this.outgoingLightNode=T().toVar("outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=[],t=this._lights;for(let s=0;s0}}const $N=(o=[])=>E(new Du).setLights(o);class HN extends O{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=W.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({material:e}){Lu.assign(e.shadowPositionNode||Wt)}dispose(){this.updateBeforeType=W.NONE}}const Lu=T().toVar("shadowPositionWorld");function Iu(o,e={}){return e.toneMapping=o.toneMapping,e.toneMappingExposure=o.toneMappingExposure,e.outputColorSpace=o.outputColorSpace,e.renderTarget=o.getRenderTarget(),e.activeCubeFace=o.getActiveCubeFace(),e.activeMipmapLevel=o.getActiveMipmapLevel(),e.renderObjectFunction=o.getRenderObjectFunction(),e.pixelRatio=o.getPixelRatio(),e.mrt=o.getMRT(),e.clearColor=o.getClearColor(e.clearColor||new mt),e.clearAlpha=o.getClearAlpha(),e.autoClear=o.autoClear,e.scissorTest=o.getScissorTest(),e}function Of(o,e){return e=Iu(o,e),o.setMRT(null),o.setRenderObjectFunction(null),o.setClearColor(0,1),o.autoClear=!0,e}function kf(o,e){o.toneMapping=e.toneMapping,o.toneMappingExposure=e.toneMappingExposure,o.outputColorSpace=e.outputColorSpace,o.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),o.setRenderObjectFunction(e.renderObjectFunction),o.setPixelRatio(e.pixelRatio),o.setMRT(e.mrt),o.setClearColor(e.clearColor,e.clearAlpha),o.autoClear=e.autoClear,o.setScissorTest(e.scissorTest)}function Vu(o,e={}){return e.background=o.background,e.backgroundNode=o.backgroundNode,e.overrideMaterial=o.overrideMaterial,e}function zf(o,e){return e=Vu(o,e),o.background=null,o.backgroundNode=null,o.overrideMaterial=null,e}function Wf(o,e){o.background=e.background,o.backgroundNode=e.backgroundNode,o.overrideMaterial=e.overrideMaterial}function qN(o,e,t={}){return t=Iu(o,t),t=Vu(e,t),t}function $f(o,e,t){return t=Of(o,t),t=zf(e,t),t}function Hf(o,e,t){kf(o,t),Wf(e,t)}var gR=Object.freeze({__proto__:null,resetRendererAndSceneState:$f,resetRendererState:Of,resetSceneState:zf,restoreRendererAndSceneState:Hf,restoreRendererState:kf,restoreSceneState:Wf,saveRendererAndSceneState:qN,saveRendererState:Iu,saveSceneState:Vu});const Ic=new WeakMap,KN=b(([o,e,t])=>{let s=Wt.sub(o).length();return s=s.sub(e).div(t.sub(e)),s=s.saturate(),s}),XN=o=>{const e=o.shadow.camera,t=ne("near","float",e).setGroup(k),s=ne("far","float",e).setGroup(k),n=Dh(o);return KN(n,t,s)},YN=o=>{let e=Ic.get(o);if(e===void 0){const t=o.isPointLight?XN(o):null;e=new ce,e.colorNode=P(0,0,0,1),e.depthNode=t,e.isShadowNodeMaterial=!0,e.name="ShadowMaterial",e.fog=!1,Ic.set(o,e)}return e},qf=b(({depthTexture:o,shadowCoord:e})=>K(o,e.xy).compare(e.z)),Kf=b(({depthTexture:o,shadowCoord:e,shadow:t})=>{const s=(m,x)=>K(o,m).compare(x),n=ne("mapSize","vec2",t).setGroup(k),r=ne("radius","float",t).setGroup(k),i=M(1).div(n),a=i.x.negate().mul(r),u=i.y.negate().mul(r),c=i.x.mul(r),l=i.y.mul(r),d=a.div(2),h=u.div(2),p=c.div(2),f=l.div(2);return _e(s(e.xy.add(M(a,u)),e.z),s(e.xy.add(M(0,u)),e.z),s(e.xy.add(M(c,u)),e.z),s(e.xy.add(M(d,h)),e.z),s(e.xy.add(M(0,h)),e.z),s(e.xy.add(M(p,h)),e.z),s(e.xy.add(M(a,0)),e.z),s(e.xy.add(M(d,0)),e.z),s(e.xy,e.z),s(e.xy.add(M(p,0)),e.z),s(e.xy.add(M(c,0)),e.z),s(e.xy.add(M(d,f)),e.z),s(e.xy.add(M(0,f)),e.z),s(e.xy.add(M(p,f)),e.z),s(e.xy.add(M(a,l)),e.z),s(e.xy.add(M(0,l)),e.z),s(e.xy.add(M(c,l)),e.z)).mul(1/17)}),Xf=b(({depthTexture:o,shadowCoord:e,shadow:t})=>{const s=(l,d)=>K(o,l).compare(d),n=ne("mapSize","vec2",t).setGroup(k),r=M(1).div(n),i=r.x,a=r.y,u=e.xy,c=Xt(u.mul(n).add(.5));return u.subAssign(c.mul(r)),_e(s(u,e.z),s(u.add(M(i,0)),e.z),s(u.add(M(0,a)),e.z),s(u.add(r),e.z),Q(s(u.add(M(i.negate(),0)),e.z),s(u.add(M(i.mul(2),0)),e.z),c.x),Q(s(u.add(M(i.negate(),a)),e.z),s(u.add(M(i.mul(2),a)),e.z),c.x),Q(s(u.add(M(0,a.negate())),e.z),s(u.add(M(0,a.mul(2))),e.z),c.y),Q(s(u.add(M(i,a.negate())),e.z),s(u.add(M(i,a.mul(2))),e.z),c.y),Q(Q(s(u.add(M(i.negate(),a.negate())),e.z),s(u.add(M(i.mul(2),a.negate())),e.z),c.x),Q(s(u.add(M(i.negate(),a.mul(2))),e.z),s(u.add(M(i.mul(2),a.mul(2))),e.z),c.x),c.y)).mul(1/9)}),Yf=b(({depthTexture:o,shadowCoord:e})=>{const t=g(1).toVar(),s=K(o).sample(e.xy).rg,n=Ti(e.z,s.x);return z(n.notEqual(g(1)),()=>{const r=e.z.sub(s.x),i=ue(0,s.y.mul(s.y));let a=i.div(i.add(r.mul(r)));a=Et(Y(a,.3).div(.95-.3)),t.assign(Et(ue(n,a)))}),t}),jN=b(({samples:o,radius:e,size:t,shadowPass:s})=>{const n=g(0).toVar(),r=g(0).toVar(),i=o.lessThanEqual(g(1)).select(g(0),g(2).div(o.sub(1))),a=o.lessThanEqual(g(1)).select(g(0),g(-1));te({start:y(0),end:y(o),type:"int",condition:"<"},({i:c})=>{const l=a.add(g(c).mul(i)),d=s.sample(_e(dr.xy,M(0,l).mul(e)).div(t)).x;n.addAssign(d),r.addAssign(d.mul(d))}),n.divAssign(o),r.divAssign(o);const u=Pt(r.sub(n.mul(n)));return M(n,u)}),QN=b(({samples:o,radius:e,size:t,shadowPass:s})=>{const n=g(0).toVar(),r=g(0).toVar(),i=o.lessThanEqual(g(1)).select(g(0),g(2).div(o.sub(1))),a=o.lessThanEqual(g(1)).select(g(0),g(-1));te({start:y(0),end:y(o),type:"int",condition:"<"},({i:c})=>{const l=a.add(g(c).mul(i)),d=s.sample(_e(dr.xy,M(l,0).mul(e)).div(t));n.addAssign(d.x),r.addAssign(_e(d.y.mul(d.y),d.x.mul(d.x)))}),n.divAssign(o),r.divAssign(o);const u=Pt(r.sub(n.mul(n)));return M(n,u)}),ZN=[qf,Kf,Xf,Yf];let eo;const Sr=new Mi;class jf extends HN{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this.isShadowNode=!0}setupShadowFilter(e,{filterFn:t,depthTexture:s,shadowCoord:n,shadow:r}){const i=n.x.greaterThanEqual(0).and(n.x.lessThanEqual(1)).and(n.y.greaterThanEqual(0)).and(n.y.lessThanEqual(1)).and(n.z.lessThanEqual(1)),a=t({depthTexture:s,shadowCoord:n,shadow:r});return i.select(a,g(1))}setupShadowCoord(e,t){const{shadow:s}=this,{renderer:n}=e,r=ne("bias","float",s).setGroup(k);let i=t,a;if(s.camera.isOrthographicCamera||n.logarithmicDepthBuffer!==!0)i=i.xyz.div(i.w),a=i.z,n.coordinateSystem===ln&&(a=a.mul(2).sub(1));else{const u=i.w;i=i.xy.div(u);const c=ne("near","float",s.camera).setGroup(k),l=ne("far","float",s.camera).setGroup(k);a=yu(u.negate(),c,l)}return i=T(i.x,i.y.oneMinus(),a.add(r)),i}getShadowFilterFn(e){return ZN[e]}setupShadow(e){const{renderer:t}=e,{light:s,shadow:n}=this,r=t.shadowMap.type,i=new vs(n.mapSize.width,n.mapSize.height);i.compareFunction=ua;const a=e.createRenderTarget(n.mapSize.width,n.mapSize.height);if(a.depthTexture=i,n.camera.updateProjectionMatrix(),r===fr){i.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:Ln,type:pt}),this.vsmShadowMapHorizontal=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:Ln,type:pt});const N=K(i),v=K(this.vsmShadowMapVertical.texture),w=ne("blurSamples","float",n).setGroup(k),B=ne("radius","float",n).setGroup(k),F=ne("mapSize","vec2",n).setGroup(k);let L=this.vsmMaterialVertical||(this.vsmMaterialVertical=new ce);L.fragmentNode=jN({samples:w,radius:B,size:F,shadowPass:N}).context(e.getSharedContext()),L.name="VSMVertical",L=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new ce),L.fragmentNode=QN({samples:w,radius:B,size:F,shadowPass:v}).context(e.getSharedContext()),L.name="VSMHorizontal"}const u=ne("intensity","float",n).setGroup(k),c=ne("normalBias","float",n).setGroup(k),l=Fu(s).mul(Lu.add(vi.mul(c))),d=this.setupShadowCoord(e,l),h=n.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(h===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const p=r===fr?this.vsmShadowMapHorizontal.texture:i,f=this.setupShadowFilter(e,{filterFn:h,shadowTexture:a.texture,depthTexture:p,shadowCoord:d,shadow:n}),m=K(a.texture,d),x=Q(1,f.rgb.mix(m,1),u.mul(m.a)).toVar();return this.shadowMap=a,this.shadow.map=a,x}setup(e){if(e.renderer.shadowMap.enabled!==!1)return b(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){const{shadow:t,shadowMap:s,light:n}=this,{renderer:r,scene:i}=e;t.updateMatrices(n),s.setSize(t.mapSize.width,t.mapSize.height),r.render(i,t.camera)}updateShadow(e){const{shadowMap:t,light:s,shadow:n}=this,{renderer:r,scene:i,camera:a}=e,u=r.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c,n.camera.layers.mask=a.layers.mask;const l=r.getRenderObjectFunction(),d=r.getMRT(),h=d?d.has("velocity"):!1;eo=$f(r,i,eo),i.overrideMaterial=YN(s),r.setRenderObjectFunction((p,f,m,x,N,v,...w)=>{(p.castShadow===!0||p.receiveShadow&&u===fr)&&(h&&(ba(p).useVelocity=!0),p.onBeforeShadow(r,p,a,n.camera,x,f.overrideMaterial,v),r.renderObject(p,f,m,x,N,v,...w),p.onAfterShadow(r,p,a,n.camera,x,f.overrideMaterial,v))}),r.setRenderTarget(t),this.renderShadow(e),r.setRenderObjectFunction(l),s.isPointLight!==!0&&u===fr&&this.vsmPass(r),Hf(r,i,eo)}vsmPass(e){const{shadow:t}=this;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height),e.setRenderTarget(this.vsmShadowMapVertical),Sr.material=this.vsmMaterialVertical,Sr.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Sr.material=this.vsmMaterialHorizontal,Sr.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const Qf=(o,e)=>E(new jf(o,e));class Es extends hn{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new mt,this.colorNode=e&&e.colorNode||V(this.color).setGroup(k),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=W.FRAME}customCacheKey(){return di(this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadowNode(){return Qf(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let s=this.shadowColorNode;if(s===null){const n=this.light.shadow.shadowNode;let r;n!==void 0?r=E(n):r=this.setupShadowNode(e),this.shadowNode=r,this.shadowColorNode=s=this.colorNode.mul(r),this.baseColorNode=this.colorNode}this.colorNode=s}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const Gu=b(o=>{const{lightDistance:e,cutoffDistance:t,decayExponent:s}=o,n=e.pow(s).max(.01).reciprocal();return t.greaterThan(0).select(n.mul(e.div(t).pow4().oneMinus().clamp().pow2()),n)}),JN=new mt,Tt=b(([o,e])=>{const t=o.toVar(),s=oe(t),n=gt(1,ue(s.x,ue(s.y,s.z)));s.mulAssign(n),t.mulAssign(n.mul(e.mul(2).oneMinus()));const r=M(t.xy).toVar(),a=e.mul(1.5).oneMinus();return z(s.z.greaterThanEqual(a),()=>{z(t.z.greaterThan(0),()=>{r.x.assign(Y(4,t.x))})}).ElseIf(s.x.greaterThanEqual(a),()=>{const u=qn(t.x);r.x.assign(t.z.mul(u).add(u.mul(2)))}).ElseIf(s.y.greaterThanEqual(a),()=>{const u=qn(t.y);r.x.assign(t.x.add(u.mul(2)).add(2)),r.y.assign(t.z.mul(u).sub(2))}),M(.125,.25).mul(r).add(M(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),eS=b(({depthTexture:o,bd3D:e,dp:t,texelSize:s})=>K(o,Tt(e,s.y)).compare(t)),tS=b(({depthTexture:o,bd3D:e,dp:t,texelSize:s,shadow:n})=>{const r=ne("radius","float",n).setGroup(k),i=M(-1,1).mul(r).mul(s.y);return K(o,Tt(e.add(i.xyy),s.y)).compare(t).add(K(o,Tt(e.add(i.yyy),s.y)).compare(t)).add(K(o,Tt(e.add(i.xyx),s.y)).compare(t)).add(K(o,Tt(e.add(i.yyx),s.y)).compare(t)).add(K(o,Tt(e,s.y)).compare(t)).add(K(o,Tt(e.add(i.xxy),s.y)).compare(t)).add(K(o,Tt(e.add(i.yxy),s.y)).compare(t)).add(K(o,Tt(e.add(i.xxx),s.y)).compare(t)).add(K(o,Tt(e.add(i.yxx),s.y)).compare(t)).mul(1/9)}),sS=b(({filterFn:o,depthTexture:e,shadowCoord:t,shadow:s})=>{const n=t.xyz.toVar(),r=n.length(),i=V("float").setGroup(k).onRenderUpdate(()=>s.camera.near),a=V("float").setGroup(k).onRenderUpdate(()=>s.camera.far),u=ne("bias","float",s).setGroup(k),c=V(s.mapSize).setGroup(k),l=g(1).toVar();return z(r.sub(a).lessThanEqual(0).and(r.sub(i).greaterThanEqual(0)),()=>{const d=r.sub(i).div(a.sub(i)).toVar();d.addAssign(u);const h=n.normalize(),p=M(1).div(c.mul(M(4,2)));l.assign(o({depthTexture:e,bd3D:h,dp:d,texelSize:p,shadow:s}))}),l}),Vc=new Me,Ps=new Ye,bn=new Ye;class nS extends jf{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===gm?eS:tS}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:s,depthTexture:n,shadowCoord:r,shadow:i}){return sS({filterFn:t,shadowTexture:s,depthTexture:n,shadowCoord:r,shadow:i})}renderShadow(e){const{shadow:t,shadowMap:s,light:n}=this,{renderer:r,scene:i}=e,a=t.getFrameExtents();bn.copy(t.mapSize),bn.multiply(a),s.setSize(bn.width,bn.height),Ps.copy(t.mapSize);const u=r.autoClear,c=r.getClearColor(JN),l=r.getClearAlpha();r.autoClear=!1,r.setClearColor(t.clearColor,t.clearAlpha),r.clear();const d=t.getViewportCount();for(let h=0;hE(new nS(o,e)),Zf=b(({color:o,lightViewPosition:e,cutoffDistance:t,decayExponent:s},n)=>{const r=n.context.lightingModel,i=e.sub(xe),a=i.normalize(),u=i.length(),c=Gu({lightDistance:u,cutoffDistance:t,decayExponent:s}),l=o.mul(c),d=n.context.reflectedLight;r.direct({lightDirection:a,lightColor:l,reflectedLight:d},n.stack,n)});class iS extends Es{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=V(0).setGroup(k),this.decayExponentNode=V(2).setGroup(k)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return rS(this.light)}setup(e){super.setup(e),Zf({color:this.colorNode,lightViewPosition:Pi(this.light),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}).append()}}const oS=b(([o=le()])=>{const e=o.mul(2),t=e.x.floor(),s=e.y.floor();return t.add(s).mod(2).sign()}),Un=b(([o,e,t])=>{const s=g(t).toVar(),n=g(e).toVar(),r=Ht(o).toVar();return Ue(r,n,s)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),ni=b(([o,e])=>{const t=Ht(e).toVar(),s=g(o).toVar();return Ue(t,s.negate(),s)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Te=b(([o])=>{const e=g(o).toVar();return y(At(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),he=b(([o,e])=>{const t=g(o).toVar();return e.assign(Te(t)),t.sub(g(e))}),aS=b(([o,e,t,s,n,r])=>{const i=g(r).toVar(),a=g(n).toVar(),u=g(s).toVar(),c=g(t).toVar(),l=g(e).toVar(),d=g(o).toVar(),h=g(Y(1,a)).toVar();return Y(1,i).mul(d.mul(h).add(l.mul(a))).add(i.mul(c.mul(h).add(u.mul(a))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),uS=b(([o,e,t,s,n,r])=>{const i=g(r).toVar(),a=g(n).toVar(),u=T(s).toVar(),c=T(t).toVar(),l=T(e).toVar(),d=T(o).toVar(),h=g(Y(1,a)).toVar();return Y(1,i).mul(d.mul(h).add(l.mul(a))).add(i.mul(c.mul(h).add(u.mul(a))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),Jf=Pe([aS,uS]),cS=b(([o,e,t,s,n,r,i,a,u,c,l])=>{const d=g(l).toVar(),h=g(c).toVar(),p=g(u).toVar(),f=g(a).toVar(),m=g(i).toVar(),x=g(r).toVar(),N=g(n).toVar(),v=g(s).toVar(),w=g(t).toVar(),B=g(e).toVar(),F=g(o).toVar(),L=g(Y(1,p)).toVar(),I=g(Y(1,h)).toVar();return g(Y(1,d)).toVar().mul(I.mul(F.mul(L).add(B.mul(p))).add(h.mul(w.mul(L).add(v.mul(p))))).add(d.mul(I.mul(N.mul(L).add(x.mul(p))).add(h.mul(m.mul(L).add(f.mul(p))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),lS=b(([o,e,t,s,n,r,i,a,u,c,l])=>{const d=g(l).toVar(),h=g(c).toVar(),p=g(u).toVar(),f=T(a).toVar(),m=T(i).toVar(),x=T(r).toVar(),N=T(n).toVar(),v=T(s).toVar(),w=T(t).toVar(),B=T(e).toVar(),F=T(o).toVar(),L=g(Y(1,p)).toVar(),I=g(Y(1,h)).toVar();return g(Y(1,d)).toVar().mul(I.mul(F.mul(L).add(B.mul(p))).add(h.mul(w.mul(L).add(v.mul(p))))).add(d.mul(I.mul(N.mul(L).add(x.mul(p))).add(h.mul(m.mul(L).add(f.mul(p))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),eg=Pe([cS,lS]),dS=b(([o,e,t])=>{const s=g(t).toVar(),n=g(e).toVar(),r=D(o).toVar(),i=D(r.bitAnd(D(7))).toVar(),a=g(Un(i.lessThan(D(4)),n,s)).toVar(),u=g($(2,Un(i.lessThan(D(4)),s,n))).toVar();return ni(a,Ht(i.bitAnd(D(1)))).add(ni(u,Ht(i.bitAnd(D(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),hS=b(([o,e,t,s])=>{const n=g(s).toVar(),r=g(t).toVar(),i=g(e).toVar(),a=D(o).toVar(),u=D(a.bitAnd(D(15))).toVar(),c=g(Un(u.lessThan(D(8)),i,r)).toVar(),l=g(Un(u.lessThan(D(4)),r,Un(u.equal(D(12)).or(u.equal(D(14))),i,n))).toVar();return ni(c,Ht(u.bitAnd(D(1)))).add(ni(l,Ht(u.bitAnd(D(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Ee=Pe([dS,hS]),pS=b(([o,e,t])=>{const s=g(t).toVar(),n=g(e).toVar(),r=dn(o).toVar();return T(Ee(r.x,n,s),Ee(r.y,n,s),Ee(r.z,n,s))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),fS=b(([o,e,t,s])=>{const n=g(s).toVar(),r=g(t).toVar(),i=g(e).toVar(),a=dn(o).toVar();return T(Ee(a.x,i,r,n),Ee(a.y,i,r,n),Ee(a.z,i,r,n))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),nt=Pe([pS,fS]),gS=b(([o])=>{const e=g(o).toVar();return $(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),mS=b(([o])=>{const e=g(o).toVar();return $(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),yS=b(([o])=>{const e=T(o).toVar();return $(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),tg=Pe([gS,yS]),xS=b(([o])=>{const e=T(o).toVar();return $(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),sg=Pe([mS,xS]),tt=b(([o,e])=>{const t=y(e).toVar(),s=D(o).toVar();return s.shiftLeft(t).bitOr(s.shiftRight(y(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),ng=b(([o,e,t])=>{o.subAssign(t),o.bitXorAssign(tt(t,y(4))),t.addAssign(e),e.subAssign(o),e.bitXorAssign(tt(o,y(6))),o.addAssign(t),t.subAssign(e),t.bitXorAssign(tt(e,y(8))),e.addAssign(o),o.subAssign(t),o.bitXorAssign(tt(t,y(16))),t.addAssign(e),e.subAssign(o),e.bitXorAssign(tt(o,y(19))),o.addAssign(t),t.subAssign(e),t.bitXorAssign(tt(e,y(4))),e.addAssign(o)}),pr=b(([o,e,t])=>{const s=D(t).toVar(),n=D(e).toVar(),r=D(o).toVar();return s.bitXorAssign(n),s.subAssign(tt(n,y(14))),r.bitXorAssign(s),r.subAssign(tt(s,y(11))),n.bitXorAssign(r),n.subAssign(tt(r,y(25))),s.bitXorAssign(n),s.subAssign(tt(n,y(16))),r.bitXorAssign(s),r.subAssign(tt(s,y(4))),n.bitXorAssign(r),n.subAssign(tt(r,y(14))),s.bitXorAssign(n),s.subAssign(tt(n,y(24))),s}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),Ge=b(([o])=>{const e=D(o).toVar();return g(e).div(g(D(y(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),Rt=b(([o])=>{const e=g(o).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),TS=b(([o])=>{const e=y(o).toVar(),t=D(D(1)).toVar(),s=D(D(y(3735928559)).add(t.shiftLeft(D(2))).add(D(13))).toVar();return pr(s.add(D(e)),s,s)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),_S=b(([o,e])=>{const t=y(e).toVar(),s=y(o).toVar(),n=D(D(2)).toVar(),r=D().toVar(),i=D().toVar(),a=D().toVar();return r.assign(i.assign(a.assign(D(y(3735928559)).add(n.shiftLeft(D(2))).add(D(13))))),r.addAssign(D(s)),i.addAssign(D(t)),pr(r,i,a)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),bS=b(([o,e,t])=>{const s=y(t).toVar(),n=y(e).toVar(),r=y(o).toVar(),i=D(D(3)).toVar(),a=D().toVar(),u=D().toVar(),c=D().toVar();return a.assign(u.assign(c.assign(D(y(3735928559)).add(i.shiftLeft(D(2))).add(D(13))))),a.addAssign(D(r)),u.addAssign(D(n)),c.addAssign(D(s)),pr(a,u,c)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),NS=b(([o,e,t,s])=>{const n=y(s).toVar(),r=y(t).toVar(),i=y(e).toVar(),a=y(o).toVar(),u=D(D(4)).toVar(),c=D().toVar(),l=D().toVar(),d=D().toVar();return c.assign(l.assign(d.assign(D(y(3735928559)).add(u.shiftLeft(D(2))).add(D(13))))),c.addAssign(D(a)),l.addAssign(D(i)),d.addAssign(D(r)),ng(c,l,d),c.addAssign(D(n)),pr(c,l,d)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),SS=b(([o,e,t,s,n])=>{const r=y(n).toVar(),i=y(s).toVar(),a=y(t).toVar(),u=y(e).toVar(),c=y(o).toVar(),l=D(D(5)).toVar(),d=D().toVar(),h=D().toVar(),p=D().toVar();return d.assign(h.assign(p.assign(D(y(3735928559)).add(l.shiftLeft(D(2))).add(D(13))))),d.addAssign(D(c)),h.addAssign(D(u)),p.addAssign(D(a)),ng(d,h,p),d.addAssign(D(i)),h.addAssign(D(r)),pr(d,h,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),re=Pe([TS,_S,bS,NS,SS]),vS=b(([o,e])=>{const t=y(e).toVar(),s=y(o).toVar(),n=D(re(s,t)).toVar(),r=dn().toVar();return r.x.assign(n.bitAnd(y(255))),r.y.assign(n.shiftRight(y(8)).bitAnd(y(255))),r.z.assign(n.shiftRight(y(16)).bitAnd(y(255))),r}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),AS=b(([o,e,t])=>{const s=y(t).toVar(),n=y(e).toVar(),r=y(o).toVar(),i=D(re(r,n,s)).toVar(),a=dn().toVar();return a.x.assign(i.bitAnd(y(255))),a.y.assign(i.shiftRight(y(8)).bitAnd(y(255))),a.z.assign(i.shiftRight(y(16)).bitAnd(y(255))),a}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),rt=Pe([vS,AS]),RS=b(([o])=>{const e=M(o).toVar(),t=y().toVar(),s=y().toVar(),n=g(he(e.x,t)).toVar(),r=g(he(e.y,s)).toVar(),i=g(Rt(n)).toVar(),a=g(Rt(r)).toVar(),u=g(Jf(Ee(re(t,s),n,r),Ee(re(t.add(y(1)),s),n.sub(1),r),Ee(re(t,s.add(y(1))),n,r.sub(1)),Ee(re(t.add(y(1)),s.add(y(1))),n.sub(1),r.sub(1)),i,a)).toVar();return tg(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),CS=b(([o])=>{const e=T(o).toVar(),t=y().toVar(),s=y().toVar(),n=y().toVar(),r=g(he(e.x,t)).toVar(),i=g(he(e.y,s)).toVar(),a=g(he(e.z,n)).toVar(),u=g(Rt(r)).toVar(),c=g(Rt(i)).toVar(),l=g(Rt(a)).toVar(),d=g(eg(Ee(re(t,s,n),r,i,a),Ee(re(t.add(y(1)),s,n),r.sub(1),i,a),Ee(re(t,s.add(y(1)),n),r,i.sub(1),a),Ee(re(t.add(y(1)),s.add(y(1)),n),r.sub(1),i.sub(1),a),Ee(re(t,s,n.add(y(1))),r,i,a.sub(1)),Ee(re(t.add(y(1)),s,n.add(y(1))),r.sub(1),i,a.sub(1)),Ee(re(t,s.add(y(1)),n.add(y(1))),r,i.sub(1),a.sub(1)),Ee(re(t.add(y(1)),s.add(y(1)),n.add(y(1))),r.sub(1),i.sub(1),a.sub(1)),u,c,l)).toVar();return sg(d)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),Ou=Pe([RS,CS]),ES=b(([o])=>{const e=M(o).toVar(),t=y().toVar(),s=y().toVar(),n=g(he(e.x,t)).toVar(),r=g(he(e.y,s)).toVar(),i=g(Rt(n)).toVar(),a=g(Rt(r)).toVar(),u=T(Jf(nt(rt(t,s),n,r),nt(rt(t.add(y(1)),s),n.sub(1),r),nt(rt(t,s.add(y(1))),n,r.sub(1)),nt(rt(t.add(y(1)),s.add(y(1))),n.sub(1),r.sub(1)),i,a)).toVar();return tg(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),wS=b(([o])=>{const e=T(o).toVar(),t=y().toVar(),s=y().toVar(),n=y().toVar(),r=g(he(e.x,t)).toVar(),i=g(he(e.y,s)).toVar(),a=g(he(e.z,n)).toVar(),u=g(Rt(r)).toVar(),c=g(Rt(i)).toVar(),l=g(Rt(a)).toVar(),d=T(eg(nt(rt(t,s,n),r,i,a),nt(rt(t.add(y(1)),s,n),r.sub(1),i,a),nt(rt(t,s.add(y(1)),n),r,i.sub(1),a),nt(rt(t.add(y(1)),s.add(y(1)),n),r.sub(1),i.sub(1),a),nt(rt(t,s,n.add(y(1))),r,i,a.sub(1)),nt(rt(t.add(y(1)),s,n.add(y(1))),r.sub(1),i,a.sub(1)),nt(rt(t,s.add(y(1)),n.add(y(1))),r,i.sub(1),a.sub(1)),nt(rt(t.add(y(1)),s.add(y(1)),n.add(y(1))),r.sub(1),i.sub(1),a.sub(1)),u,c,l)).toVar();return sg(d)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),ku=Pe([ES,wS]),MS=b(([o])=>{const e=g(o).toVar(),t=y(Te(e)).toVar();return Ge(re(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),BS=b(([o])=>{const e=M(o).toVar(),t=y(Te(e.x)).toVar(),s=y(Te(e.y)).toVar();return Ge(re(t,s))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),FS=b(([o])=>{const e=T(o).toVar(),t=y(Te(e.x)).toVar(),s=y(Te(e.y)).toVar(),n=y(Te(e.z)).toVar();return Ge(re(t,s,n))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),US=b(([o])=>{const e=P(o).toVar(),t=y(Te(e.x)).toVar(),s=y(Te(e.y)).toVar(),n=y(Te(e.z)).toVar(),r=y(Te(e.w)).toVar();return Ge(re(t,s,n,r))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),PS=Pe([MS,BS,FS,US]),DS=b(([o])=>{const e=g(o).toVar(),t=y(Te(e)).toVar();return T(Ge(re(t,y(0))),Ge(re(t,y(1))),Ge(re(t,y(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),LS=b(([o])=>{const e=M(o).toVar(),t=y(Te(e.x)).toVar(),s=y(Te(e.y)).toVar();return T(Ge(re(t,s,y(0))),Ge(re(t,s,y(1))),Ge(re(t,s,y(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),IS=b(([o])=>{const e=T(o).toVar(),t=y(Te(e.x)).toVar(),s=y(Te(e.y)).toVar(),n=y(Te(e.z)).toVar();return T(Ge(re(t,s,n,y(0))),Ge(re(t,s,n,y(1))),Ge(re(t,s,n,y(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),VS=b(([o])=>{const e=P(o).toVar(),t=y(Te(e.x)).toVar(),s=y(Te(e.y)).toVar(),n=y(Te(e.z)).toVar(),r=y(Te(e.w)).toVar();return T(Ge(re(t,s,n,r,y(0))),Ge(re(t,s,n,r,y(1))),Ge(re(t,s,n,r,y(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),rg=Pe([DS,LS,IS,VS]),ri=b(([o,e,t,s])=>{const n=g(s).toVar(),r=g(t).toVar(),i=y(e).toVar(),a=T(o).toVar(),u=g(0).toVar(),c=g(1).toVar();return te(i,()=>{u.addAssign(c.mul(Ou(a))),c.mulAssign(n),a.mulAssign(r)}),u}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),ig=b(([o,e,t,s])=>{const n=g(s).toVar(),r=g(t).toVar(),i=y(e).toVar(),a=T(o).toVar(),u=T(0).toVar(),c=g(1).toVar();return te(i,()=>{u.addAssign(c.mul(ku(a))),c.mulAssign(n),a.mulAssign(r)}),u}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),GS=b(([o,e,t,s])=>{const n=g(s).toVar(),r=g(t).toVar(),i=y(e).toVar(),a=T(o).toVar();return M(ri(a,i,r,n),ri(a.add(T(y(19),y(193),y(17))),i,r,n))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),OS=b(([o,e,t,s])=>{const n=g(s).toVar(),r=g(t).toVar(),i=y(e).toVar(),a=T(o).toVar(),u=T(ig(a,i,r,n)).toVar(),c=g(ri(a.add(T(y(19),y(193),y(17))),i,r,n)).toVar();return P(u,c)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),kS=b(([o,e,t,s,n,r,i])=>{const a=y(i).toVar(),u=g(r).toVar(),c=y(n).toVar(),l=y(s).toVar(),d=y(t).toVar(),h=y(e).toVar(),p=M(o).toVar(),f=T(rg(M(h.add(l),d.add(c)))).toVar(),m=M(f.x,f.y).toVar();m.subAssign(.5),m.mulAssign(u),m.addAssign(.5);const x=M(M(g(h),g(d)).add(m)).toVar(),N=M(x.sub(p)).toVar();return z(a.equal(y(2)),()=>oe(N.x).add(oe(N.y))),z(a.equal(y(3)),()=>ue(oe(N.x),oe(N.y))),is(N,N)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),zS=b(([o,e,t,s,n,r,i,a,u])=>{const c=y(u).toVar(),l=g(a).toVar(),d=y(i).toVar(),h=y(r).toVar(),p=y(n).toVar(),f=y(s).toVar(),m=y(t).toVar(),x=y(e).toVar(),N=T(o).toVar(),v=T(rg(T(x.add(p),m.add(h),f.add(d)))).toVar();v.subAssign(.5),v.mulAssign(l),v.addAssign(.5);const w=T(T(g(x),g(m),g(f)).add(v)).toVar(),B=T(w.sub(N)).toVar();return z(c.equal(y(2)),()=>oe(B.x).add(oe(B.y)).add(oe(B.z))),z(c.equal(y(3)),()=>ue(ue(oe(B.x),oe(B.y)),oe(B.z))),is(B,B)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),pn=Pe([kS,zS]),WS=b(([o,e,t])=>{const s=y(t).toVar(),n=g(e).toVar(),r=M(o).toVar(),i=y().toVar(),a=y().toVar(),u=M(he(r.x,i),he(r.y,a)).toVar(),c=g(1e6).toVar();return te({start:-1,end:y(1),name:"x",condition:"<="},({x:l})=>{te({start:-1,end:y(1),name:"y",condition:"<="},({y:d})=>{const h=g(pn(u,l,d,i,a,n,s)).toVar();c.assign(Re(c,h))})}),z(s.equal(y(0)),()=>{c.assign(Pt(c))}),c}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),$S=b(([o,e,t])=>{const s=y(t).toVar(),n=g(e).toVar(),r=M(o).toVar(),i=y().toVar(),a=y().toVar(),u=M(he(r.x,i),he(r.y,a)).toVar(),c=M(1e6,1e6).toVar();return te({start:-1,end:y(1),name:"x",condition:"<="},({x:l})=>{te({start:-1,end:y(1),name:"y",condition:"<="},({y:d})=>{const h=g(pn(u,l,d,i,a,n,s)).toVar();z(h.lessThan(c.x),()=>{c.y.assign(c.x),c.x.assign(h)}).ElseIf(h.lessThan(c.y),()=>{c.y.assign(h)})})}),z(s.equal(y(0)),()=>{c.assign(Pt(c))}),c}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),HS=b(([o,e,t])=>{const s=y(t).toVar(),n=g(e).toVar(),r=M(o).toVar(),i=y().toVar(),a=y().toVar(),u=M(he(r.x,i),he(r.y,a)).toVar(),c=T(1e6,1e6,1e6).toVar();return te({start:-1,end:y(1),name:"x",condition:"<="},({x:l})=>{te({start:-1,end:y(1),name:"y",condition:"<="},({y:d})=>{const h=g(pn(u,l,d,i,a,n,s)).toVar();z(h.lessThan(c.x),()=>{c.z.assign(c.y),c.y.assign(c.x),c.x.assign(h)}).ElseIf(h.lessThan(c.y),()=>{c.z.assign(c.y),c.y.assign(h)}).ElseIf(h.lessThan(c.z),()=>{c.z.assign(h)})})}),z(s.equal(y(0)),()=>{c.assign(Pt(c))}),c}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),qS=b(([o,e,t])=>{const s=y(t).toVar(),n=g(e).toVar(),r=T(o).toVar(),i=y().toVar(),a=y().toVar(),u=y().toVar(),c=T(he(r.x,i),he(r.y,a),he(r.z,u)).toVar(),l=g(1e6).toVar();return te({start:-1,end:y(1),name:"x",condition:"<="},({x:d})=>{te({start:-1,end:y(1),name:"y",condition:"<="},({y:h})=>{te({start:-1,end:y(1),name:"z",condition:"<="},({z:p})=>{const f=g(pn(c,d,h,p,i,a,u,n,s)).toVar();l.assign(Re(l,f))})})}),z(s.equal(y(0)),()=>{l.assign(Pt(l))}),l}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),KS=Pe([WS,qS]),XS=b(([o,e,t])=>{const s=y(t).toVar(),n=g(e).toVar(),r=T(o).toVar(),i=y().toVar(),a=y().toVar(),u=y().toVar(),c=T(he(r.x,i),he(r.y,a),he(r.z,u)).toVar(),l=M(1e6,1e6).toVar();return te({start:-1,end:y(1),name:"x",condition:"<="},({x:d})=>{te({start:-1,end:y(1),name:"y",condition:"<="},({y:h})=>{te({start:-1,end:y(1),name:"z",condition:"<="},({z:p})=>{const f=g(pn(c,d,h,p,i,a,u,n,s)).toVar();z(f.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(f)}).ElseIf(f.lessThan(l.y),()=>{l.y.assign(f)})})})}),z(s.equal(y(0)),()=>{l.assign(Pt(l))}),l}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),YS=Pe([$S,XS]),jS=b(([o,e,t])=>{const s=y(t).toVar(),n=g(e).toVar(),r=T(o).toVar(),i=y().toVar(),a=y().toVar(),u=y().toVar(),c=T(he(r.x,i),he(r.y,a),he(r.z,u)).toVar(),l=T(1e6,1e6,1e6).toVar();return te({start:-1,end:y(1),name:"x",condition:"<="},({x:d})=>{te({start:-1,end:y(1),name:"y",condition:"<="},({y:h})=>{te({start:-1,end:y(1),name:"z",condition:"<="},({z:p})=>{const f=g(pn(c,d,h,p,i,a,u,n,s)).toVar();z(f.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(f)}).ElseIf(f.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(f)}).ElseIf(f.lessThan(l.z),()=>{l.z.assign(f)})})})}),z(s.equal(y(0)),()=>{l.assign(Pt(l))}),l}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),QS=Pe([HS,jS]),ZS=b(([o])=>{const e=o.y,t=o.z,s=T().toVar();return z(e.lessThan(1e-4),()=>{s.assign(T(t,t,t))}).Else(()=>{let n=o.x;n=n.sub(At(n)).mul(6).toVar();const r=y(Ka(n)),i=n.sub(g(r)),a=t.mul(e.oneMinus()),u=t.mul(e.mul(i).oneMinus()),c=t.mul(e.mul(i.oneMinus()).oneMinus());z(r.equal(y(0)),()=>{s.assign(T(t,c,a))}).ElseIf(r.equal(y(1)),()=>{s.assign(T(u,t,a))}).ElseIf(r.equal(y(2)),()=>{s.assign(T(a,t,c))}).ElseIf(r.equal(y(3)),()=>{s.assign(T(a,u,t))}).ElseIf(r.equal(y(4)),()=>{s.assign(T(c,a,t))}).Else(()=>{s.assign(T(t,a,u))})}),s}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),JS=b(([o])=>{const e=T(o).toVar(),t=g(e.x).toVar(),s=g(e.y).toVar(),n=g(e.z).toVar(),r=g(Re(t,Re(s,n))).toVar(),i=g(ue(t,ue(s,n))).toVar(),a=g(i.sub(r)).toVar(),u=g().toVar(),c=g().toVar(),l=g().toVar();return l.assign(i),z(i.greaterThan(0),()=>{c.assign(a.div(i))}).Else(()=>{c.assign(0)}),z(c.lessThanEqual(0),()=>{u.assign(0)}).Else(()=>{z(t.greaterThanEqual(i),()=>{u.assign(s.sub(n).div(a))}).ElseIf(s.greaterThanEqual(i),()=>{u.assign(_e(2,n.sub(t).div(a)))}).Else(()=>{u.assign(_e(4,t.sub(s).div(a)))}),u.mulAssign(1/6),z(u.lessThan(0),()=>{u.addAssign(1)})}),T(u,c,l)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),ev=b(([o])=>{const e=T(o).toVar(),t=wa(Oa(e,T(.04045))).toVar(),s=T(e.div(12.92)).toVar(),n=T(ht(ue(e.add(T(.055)),T(0)).div(1.055),T(2.4))).toVar();return Q(s,n,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),og=(o,e)=>{o=g(o),e=g(e);const t=M(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return ct(o.sub(t),o.add(t),e)},ag=(o,e,t,s)=>Q(o,e,t[s].clamp()),tv=(o,e,t=le())=>ag(o,e,t,"x"),sv=(o,e,t=le())=>ag(o,e,t,"y"),ug=(o,e,t,s,n)=>Q(o,e,og(t,s[n])),nv=(o,e,t,s=le())=>ug(o,e,t,s,"x"),rv=(o,e,t,s=le())=>ug(o,e,t,s,"y"),iv=(o=1,e=0,t=le())=>t.mul(o).add(e),ov=(o,e=1)=>(o=g(o),o.abs().pow(e).mul(o.sign())),av=(o,e=1,t=.5)=>g(o).sub(t).mul(e).add(t),uv=(o=le(),e=1,t=0)=>Ou(o.convert("vec2|vec3")).mul(e).add(t),cv=(o=le(),e=1,t=0)=>ku(o.convert("vec2|vec3")).mul(e).add(t),lv=(o=le(),e=1,t=0)=>(o=o.convert("vec2|vec3"),P(ku(o),Ou(o.add(M(19,73)))).mul(e).add(t)),dv=(o=le(),e=1)=>KS(o.convert("vec2|vec3"),e,y(1)),hv=(o=le(),e=1)=>YS(o.convert("vec2|vec3"),e,y(1)),pv=(o=le(),e=1)=>QS(o.convert("vec2|vec3"),e,y(1)),fv=(o=le())=>PS(o.convert("vec2|vec3")),gv=(o=le(),e=3,t=2,s=.5,n=1)=>ri(o,y(e),t,s).mul(n),mv=(o=le(),e=3,t=2,s=.5,n=1)=>GS(o,y(e),t,s).mul(n),yv=(o=le(),e=3,t=2,s=.5,n=1)=>ig(o,y(e),t,s).mul(n),xv=(o=le(),e=3,t=2,s=.5,n=1)=>OS(o,y(e),t,s).mul(n),Tv=b(([o,e,t])=>{const s=qt(o).toVar("nDir"),n=Y(g(.5).mul(e.sub(t)),Wt).div(s).toVar("rbmax"),r=Y(g(-.5).mul(e.sub(t)),Wt).div(s).toVar("rbmin"),i=T().toVar("rbminmax");i.x=s.x.greaterThan(g(0)).select(n.x,r.x),i.y=s.y.greaterThan(g(0)).select(n.y,r.y),i.z=s.z.greaterThan(g(0)).select(n.z,r.z);const a=Re(Re(i.x,i.y),i.z).toVar("correction");return Wt.add(s.mul(a)).toVar("boxIntersection").sub(t)}),cg=b(([o,e])=>{const t=o.x,s=o.y,n=o.z;let r=e.element(0).mul(.886227);return r=r.add(e.element(1).mul(2*.511664).mul(s)),r=r.add(e.element(2).mul(2*.511664).mul(n)),r=r.add(e.element(3).mul(2*.511664).mul(t)),r=r.add(e.element(4).mul(2*.429043).mul(t).mul(s)),r=r.add(e.element(5).mul(2*.429043).mul(s).mul(n)),r=r.add(e.element(6).mul(n.mul(n).mul(.743125).sub(.247708))),r=r.add(e.element(7).mul(2*.429043).mul(t).mul(n)),r=r.add(e.element(8).mul(.429043).mul($(t,t).sub($(s,s)))),r});var mR=Object.freeze({__proto__:null,BRDF_GGX:jo,BRDF_Lambert:Ns,BasicShadowFilter:qf,Break:pu,Continue:Ex,DFGApprox:Nu,D_GGX:Xp,Discard:Fh,EPSILON:Gd,F_Schlick:un,Fn:b,INFINITY:Ny,If:z,Loop:te,NodeAccess:Ve,NodeShaderStage:Oo,NodeType:Zm,NodeUpdateType:W,PCFShadowFilter:Kf,PCFSoftShadowFilter:Xf,PI:Qr,PI2:Sy,Return:Vy,Schlick_to_F0:jp,ScriptableNodeResources:Wr,ShaderNode:Cn,TBNViewMatrix:gs,VSMShadowFilter:Yf,V_GGX_SmithCorrelated:Kp,abs:oe,acesFilmicToneMapping:Bf,acos:Hd,add:_e,addMethodChaining:R,addNodeElement:Oy,agxToneMapping:Ff,all:ka,alphaT:Xr,and:Ed,anisotropy:Zt,anisotropyB:_s,anisotropyT:En,any:Od,append:ud,arrayBuffer:yy,asin:$d,assign:bd,atan:$a,atan2:lh,atomicAdd:DN,atomicAnd:GN,atomicFunc:Yt,atomicMax:IN,atomicMin:VN,atomicOr:ON,atomicStore:PN,atomicSub:LN,atomicXor:kN,attenuationColor:Ia,attenuationDistance:La,attribute:we,attributeArray:Eb,backgroundBlurriness:Tf,backgroundIntensity:sa,backgroundRotation:_f,batch:Mp,billboarding:ab,bitAnd:Fd,bitNot:Ud,bitOr:Pd,bitXor:Dd,bitangentGeometry:lx,bitangentLocal:dx,bitangentView:Yh,bitangentWorld:hx,bitcast:vy,blendBurn:Sf,blendColor:Ob,blendDodge:vf,blendOverlay:Rf,blendScreen:Af,blur:sf,bool:Ht,buffer:ir,bufferAttribute:nr,bumpMap:Jh,burn:kb,bvec2:dd,bvec3:wa,bvec4:gd,bypass:Eh,cache:Mn,call:Nd,cameraFar:es,cameraNear:Jt,cameraNormalMatrix:qy,cameraPosition:su,cameraProjectionMatrix:He,cameraProjectionMatrixInverse:$y,cameraViewMatrix:je,cameraWorldMatrix:Hy,cbrt:ih,cdl:Yb,ceil:xi,checker:oS,cineonToneMapping:Mf,clamp:Et,clearcoat:Kr,clearcoatRoughness:zn,code:Fi,color:cd,colorSpaceToWorking:eu,colorToDirection:rT,compute:Ch,cond:dh,context:bi,convert:yd,convertColorSpace:wy,convertToTexture:_b,cos:It,cross:_i,cubeTexture:on,dFdx:Ha,dFdy:qa,dashSize:bs,defaultBuildStages:ko,defaultShaderStages:sd,defined:Gn,degrees:zd,deltaTime:gf,densityFog:xN,densityFogFactor:Mu,depth:xu,depthPass:tN,difference:th,diffuseColor:ee,directPointLight:Zf,directionToColor:Op,dispersion:Va,distance:eh,div:gt,dodge:zb,dot:is,drawIndex:Cp,dynamicBufferAttribute:Rh,element:md,emissive:Ho,equal:Sd,equals:Zd,equirectUV:Tu,exp:za,exp2:rn,expression:rs,faceDirection:rr,faceForward:Za,faceforward:Ay,float:g,floor:At,fog:Xn,fract:Xt,frameGroup:_d,frameId:Q_,frontFacing:Gh,fwidth:jd,gain:$_,gapSize:Hn,getConstNodeType:ad,getCurrentStack:Ea,getDirection:ef,getDistanceAttenuation:Gu,getGeometryRoughness:qp,getNormalFromDepth:Nb,getParallaxCorrectNormal:Tv,getRoughness:bu,getScreenPosition:bb,getShIrradianceAt:cg,getTextureIndex:pf,getViewPosition:ks,glsl:lN,glslFn:dN,grayscale:Hb,greaterThan:Oa,greaterThanEqual:Cd,hash:W_,highpModelNormalViewMatrix:sx,highpModelViewMatrix:tx,hue:Xb,instance:Sx,instanceIndex:lr,instancedArray:wb,instancedBufferAttribute:Zr,instancedDynamicBufferAttribute:qo,instancedMesh:wp,int:y,inverseSqrt:Wa,inversesqrt:Ry,invocationLocalIndex:Nx,invocationSubgroupIndex:bx,ior:wn,iridescence:mi,iridescenceIOR:Ua,iridescenceThickness:Pa,ivec2:Ae,ivec3:hd,ivec4:pd,js:uN,label:ph,length:zt,lengthSq:ja,lessThan:Ad,lessThanEqual:Rd,lightPosition:Uu,lightProjectionUV:Vf,lightShadowMatrix:Fu,lightTargetDirection:Pu,lightTargetPosition:Gf,lightViewPosition:Pi,lightingContext:Pp,lights:$N,linearDepth:ei,linearToneMapping:Ef,localId:vN,log:yi,log2:vt,logarithmicDepthToViewZ:zx,loop:wx,luminance:Eu,mat2:fi,mat3:Oe,mat4:Ts,matcapUV:of,materialAO:Ap,materialAlphaTest:ep,materialAnisotropy:fp,materialAnisotropyVector:Os,materialAttenuationColor:Np,materialAttenuationDistance:bp,materialClearcoat:up,materialClearcoatNormal:lp,materialClearcoatRoughness:cp,materialColor:an,materialDispersion:vp,materialEmissive:sp,materialIOR:_p,materialIridescence:gp,materialIridescenceIOR:mp,materialIridescenceThickness:yp,materialLightMap:du,materialLineDashOffset:lu,materialLineDashSize:uu,materialLineGapSize:cu,materialLineScale:au,materialLineWidth:Or,materialMetalness:op,materialNormal:ap,materialOpacity:cr,materialPointWidth:Sp,materialReference:dt,materialReflectivity:Gr,materialRefractionRatio:zh,materialRotation:dp,materialRoughness:ip,materialSheen:hp,materialSheenRoughness:pp,materialShininess:tp,materialSpecular:np,materialSpecularColor:rp,materialSpecularIntensity:Yo,materialSpecularStrength:Bn,materialThickness:Tp,materialTransmission:xp,max:ue,maxMipLevel:Ph,mediumpModelViewMatrix:Vh,metalness:kn,min:Re,mix:Q,mixElement:uh,mod:Xa,modInt:Ga,modelDirection:Qy,modelNormalMatrix:Lh,modelPosition:Zy,modelScale:Jy,modelViewMatrix:Kt,modelViewPosition:ex,modelViewProjection:hu,modelWorldMatrix:at,modelWorldMatrixInverse:Ih,morphReference:Up,mrt:ff,mul:$,mx_aastep:og,mx_cell_noise_float:fv,mx_contrast:av,mx_fractal_noise_float:gv,mx_fractal_noise_vec2:mv,mx_fractal_noise_vec3:yv,mx_fractal_noise_vec4:xv,mx_hsvtorgb:ZS,mx_noise_float:uv,mx_noise_vec3:cv,mx_noise_vec4:lv,mx_ramplr:tv,mx_ramptb:sv,mx_rgbtohsv:JS,mx_safepower:ov,mx_splitlr:nv,mx_splittb:rv,mx_srgb_texture_to_lin_rec709:ev,mx_transform_uv:iv,mx_worley_noise_float:dv,mx_worley_noise_vec2:hv,mx_worley_noise_vec3:pv,negate:qd,neutralToneMapping:Uf,nodeArray:xs,nodeImmutable:U,nodeObject:E,nodeObjects:Jn,nodeProxy:C,normalFlat:Oh,normalGeometry:Ni,normalLocal:Xe,normalMap:Xo,normalView:lt,normalWorld:Si,normalize:qt,not:Md,notEqual:vd,numWorkgroups:NN,objectDirection:Ky,objectGroup:Ba,objectPosition:Dh,objectScale:Yy,objectViewPosition:jy,objectWorldMatrix:Xy,oneMinus:Kd,or:wd,orthographicDepthToViewZ:kx,oscSawtooth:rb,oscSine:tb,oscSquare:sb,oscTriangle:nb,output:$n,outputStruct:k_,overlay:$b,overloadingFn:Pe,parabola:ta,parallaxDirection:Qh,parallaxUV:fx,parameter:G_,pass:Jb,passTexture:eN,pcurve:H_,perspectiveDepthToViewZ:mu,pmremTexture:vu,pointUV:Ub,pointWidth:Ty,positionGeometry:Ce,positionLocal:me,positionPrevious:Jr,positionView:xe,positionViewDirection:ae,positionWorld:Wt,positionWorldDirection:nu,posterize:Qb,pow:ht,pow2:Ya,pow3:sh,pow4:nh,property:Fa,radians:kd,rand:ah,range:_N,rangeFog:yN,rangeFogFactor:wu,reciprocal:Yd,reference:ne,referenceBuffer:Ko,reflect:Jd,reflectVector:Hh,reflectView:Wh,reflector:gb,refract:Qa,refractVector:qh,refractView:$h,reinhardToneMapping:wf,remainder:Vd,remap:Mh,remapClamp:Bh,renderGroup:k,renderOutput:tu,rendererReference:Sh,rotate:Au,rotateUV:ib,roughness:Nt,round:Xd,rtt:yf,sRGBTransferEOTF:yh,sRGBTransferOETF:xh,sampler:Wy,saturate:oh,saturation:qb,screen:Wb,screenCoordinate:dr,screenSize:Kn,screenUV:Bt,scriptable:mN,scriptableValue:zr,select:Ue,setCurrentStack:On,shaderStages:zo,shadow:Qf,shadowPositionWorld:Lu,sharedUniformGroup:Ma,sheen:fs,sheenRoughness:gi,shiftLeft:Ld,shiftRight:Id,shininess:Yr,sign:qn,sin:st,sinc:q_,skinning:Rx,skinningReference:Fp,smoothstep:ct,smoothstepElement:ch,specularColor:We,specularF90:Wn,spherizeUV:ob,split:xy,spritesheetUV:lb,sqrt:Pt,stack:kr,step:Ti,storage:Bi,storageBarrier:EN,storageObject:Cb,storageTexture:bf,string:my,sub:Y,subgroupIndex:_x,subgroupSize:AN,tan:Wd,tangentGeometry:Ri,tangentLocal:or,tangentView:ar,tangentWorld:Xh,temp:gh,texture:K,texture3D:af,textureBarrier:wN,textureBicubic:Jp,textureCubeUV:tf,textureLoad:ge,textureSize:ns,textureStore:Db,thickness:Da,time:Cs,timerDelta:eb,timerGlobal:J_,timerLocal:Z_,toOutputColorSpace:Th,toWorkingColorSpace:_h,toneMapping:vh,toneMappingExposure:Ah,toonOutlinePass:nN,transformDirection:rh,transformNormal:kh,transformNormalToView:ru,transformedBentNormalView:Zh,transformedBitangentView:jh,transformedBitangentWorld:px,transformedClearcoatNormalView:Hs,transformedNormalView:fe,transformedNormalWorld:vi,transformedTangentView:ou,transformedTangentWorld:cx,transmission:jr,transpose:Qd,triNoise3D:X_,triplanarTexture:hb,triplanarTextures:mf,trunc:Ka,tslFn:gy,uint:D,uniform:V,uniformArray:Gt,uniformGroup:Td,uniforms:ox,userData:Ib,uv:le,uvec2:ld,uvec3:dn,uvec4:fd,varying:ke,varyingProperty:et,vec2:M,vec3:T,vec4:P,vectorComponents:As,velocity:Gb,vertexColor:Bb,vertexIndex:Rp,vertexStage:mh,vibrance:Kb,viewZToLogarithmicDepth:yu,viewZToOrthographicDepth:Qs,viewZToPerspectiveDepth:Ip,viewport:$t,viewportBottomLeft:Vx,viewportCoordinate:Lp,viewportDepthTexture:gu,viewportLinearDepth:Wx,viewportMipTexture:fu,viewportResolution:Lx,viewportSafeUV:ub,viewportSharedTexture:Gp,viewportSize:Dp,viewportTexture:Gx,viewportTopLeft:Ix,viewportUV:Dx,wgsl:cN,wgslFn:hN,workgroupArray:FN,workgroupBarrier:CN,workgroupId:SN,workingToColorSpace:bh,xor:Bd});const Lt=new Ru;class _v extends os{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,s){const n=this.renderer,r=this.nodes.getBackgroundNode(e)||e.background;let i=!1;if(r===null)n._clearColor.getRGB(Lt,kt),Lt.a=n._clearColor.a;else if(r.isColor===!0)r.getRGB(Lt,kt),Lt.a=1,i=!0;else if(r.isNode===!0){const a=this.get(e),u=r;Lt.copy(n._clearColor);let c=a.backgroundMesh;if(c===void 0){const d=bi(P(u).mul(sa),{getUV:()=>_f.mul(Si),getTextureLevel:()=>Tf});let h=hu;h=h.setZ(h.w);const p=new ce;p.name="Background.material",p.side=Ct,p.depthTest=!1,p.depthWrite=!1,p.fog=!1,p.lights=!1,p.vertexNode=h,p.colorNode=d,a.backgroundMeshNode=d,a.backgroundMesh=c=new tn(new mm(1,32,32),p),c.frustumCulled=!1,c.name="Background.mesh",c.onBeforeRender=function(f,m,x){this.matrixWorld.copyPosition(x.matrixWorld)}}const l=u.getCacheKey();a.backgroundCacheKey!==l&&(a.backgroundMeshNode.node=P(u).mul(sa),a.backgroundMeshNode.needsUpdate=!0,c.material.needsUpdate=!0,a.backgroundCacheKey=l),t.unshift(c,c.geometry,c.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",r);if(n.autoClear===!0||i===!0){const a=s.clearColorValue;a.r=Lt.r,a.g=Lt.g,a.b=Lt.b,a.a=Lt.a,(n.backend.isWebGLBackend===!0||n.alpha===!0)&&(a.r*=a.a,a.g*=a.a,a.b*=a.a),s.depthClearValue=n._clearDepth,s.stencilClearValue=n._clearStencil,s.clearColor=n.autoClearColor===!0,s.clearDepth=n.autoClearDepth===!0,s.clearStencil=n.autoClearStencil===!0}else s.clearColor=!1,s.clearDepth=!1,s.clearStencil=!1}}let bv=0;class na{constructor(e="",t=[],s=0,n=[]){this.name=e,this.bindings=t,this.index=s,this.bindingsReference=n,this.id=bv++}}class Nv{constructor(e,t,s,n,r,i,a,u,c,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=s,this.transforms=l,this.nodeAttributes=n,this.bindings=r,this.updateNodes=i,this.updateBeforeNodes=a,this.updateAfterNodes=u,this.monitor=c,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const n=new na(t.name,[],t.index,t);e.push(n);for(const r of t.bindings)n.bindings.push(r.clone())}else e.push(t);return e}}class Gc{constructor(e,t,s=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=s}}class Sv{constructor(e,t,s){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=s.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class lg{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class vv extends lg{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class Av{constructor(e,t,s=""){this.name=e,this.type=t,this.code=s,Object.defineProperty(this,"isNodeCode",{value:!0})}}let Rv=0;class to{constructor(e=null){this.id=Rv++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class Cv extends O{static get type(){return"StructTypeNode"}constructor(e,t){super(),this.name=e,this.types=t,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class ws{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class Ev extends ws{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class wv extends ws{constructor(e,t=new Ye){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class Mv extends ws{constructor(e,t=new j){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class Bv extends ws{constructor(e,t=new Me){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class Fv extends ws{constructor(e,t=new mt){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class Uv extends ws{constructor(e,t=new Yn){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class Pv extends ws{constructor(e,t=new Ie){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class Dv extends Ev{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Lv extends wv{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Iv extends Mv{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Vv extends Bv{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Gv extends Fv{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Ov extends Uv{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class kv extends Pv{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const qs=4,Oc=[.125,.215,.35,.446,.526,.582],hs=20,so=new Tl(-1,1,1,-1,0,1),zv=new kg(90,1),kc=new mt;let no=null,ro=0,io=0;const ds=(1+Math.sqrt(5))/2,Ds=1/ds,zc=[new j(-ds,Ds,0),new j(ds,Ds,0),new j(-Ds,0,ds),new j(Ds,0,ds),new j(0,ds,-Ds),new j(0,ds,Ds),new j(-1,1,-1),new j(1,1,-1),new j(-1,1,1),new j(1,1,1)],Wv=[3,1,5,0,4,2],oo=ef(le(),we("faceIndex")).normalize(),zu=T(oo.x,oo.y,oo.z);class $v{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,s=.1,n=100,r=null){if(this._setSize(256),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const a=r||this._allocateTargets();return this.fromSceneAsync(e,t,s,n,a),a}no=this._renderer.getRenderTarget(),ro=this._renderer.getActiveCubeFace(),io=this._renderer.getActiveMipmapLevel();const i=r||this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(e,s,n,i),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}async fromSceneAsync(e,t=0,s=.1,n=100,r=null){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,s,n,r)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const s=t||this._allocateTargets();return this.fromEquirectangularAsync(e,s),s}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const s=t||this._allocateTargets();return this.fromCubemapAsync(e,t),s}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=$c(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Hc(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===Zs||e.mapping===Js?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?m:0,m,m),u.render(e,r)}u.autoClear=c,e.background=h}_textureToCubeUV(e,t){const s=this._renderer,n=e.mapping===Zs||e.mapping===Js;n?this._cubemapMaterial===null&&(this._cubemapMaterial=$c(e)):this._equirectMaterial===null&&(this._equirectMaterial=Hc(e));const r=n?this._cubemapMaterial:this._equirectMaterial;r.fragmentNode.value=e;const i=this._lodMeshes[0];i.material=r;const a=this._cubeSize;vr(t,0,0,3*a,2*a),s.setRenderTarget(t),s.render(i,so)}_applyPMREM(e){const t=this._renderer,s=t.autoClear;t.autoClear=!1;const n=this._lodPlanes.length;for(let r=1;rhs&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${hs}`);const N=[];let v=0;for(let I=0;Iw-qs?n-w+qs:0),L=4*(this._cubeSize-B);vr(t,F,L,3*B,2*B),u.setRenderTarget(t),u.render(d,so)}}function Hv(o){const e=[],t=[],s=[],n=[];let r=o;const i=o-qs+1+Oc.length;for(let a=0;ao-qs?c=Oc[a-o+qs-1]:a===0&&(c=0),s.push(c);const l=1/(u-2),d=-l,h=1+l,p=[d,d,h,d,h,h,d,d,h,h,d,h],f=6,m=6,x=3,N=2,v=1,w=new Float32Array(x*m*f),B=new Float32Array(N*m*f),F=new Float32Array(v*m*f);for(let I=0;I2?0:-1,ie=[G,X,0,G+2/3,X,0,G+2/3,X+1,0,G,X,0,G+2/3,X+1,0,G,X+1,0],Z=Wv[I];w.set(ie,x*m*Z),B.set(p,N*m*Z);const Qe=[Z,Z,Z,Z,Z,Z];F.set(Qe,v*m*Z)}const L=new Sl;L.setAttribute("position",new Ur(w,x)),L.setAttribute("uv",new Ur(B,N)),L.setAttribute("faceIndex",new Ur(F,v)),e.push(L),n.push(new tn(L,null)),r>qs&&r--}return{lodPlanes:e,sizeLods:t,sigmas:s,lodMeshes:n}}function Wc(o,e,t){const s=new Ss(o,e,t);return s.texture.mapping=bo,s.texture.name="PMREM.cubeUv",s.texture.isPMREMTexture=!0,s.scissorTest=!0,s}function vr(o,e,t,s,n){o.viewport.set(e,t,s,n),o.scissor.set(e,t,s,n)}function Wu(o){const e=new ce;return e.depthTest=!1,e.depthWrite=!1,e.blending=en,e.name=`PMREM_${o}`,e}function qv(o,e,t){const s=Gt(new Array(hs).fill(0)),n=V(new j(0,1,0)),r=V(0),i=g(hs),a=V(0),u=V(1),c=K(null),l=V(0),d=g(1/e),h=g(1/t),p=g(o),f={n:i,latitudinal:a,weights:s,poleAxis:n,outputDirection:zu,dTheta:r,samples:u,envMap:c,mipInt:l,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:h,CUBEUV_MAX_MIP:p},m=Wu("blur");return m.uniforms=f,m.fragmentNode=sf({...f,latitudinal:a.equal(1)}),m}function $c(o){const e=Wu("cubemap");return e.fragmentNode=on(o,zu),e}function Hc(o){const e=Wu("equirect");return e.fragmentNode=K(o,Tu(zu),0),e}const qc=new WeakMap,Kv=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Ar=o=>/e/g.test(o)?String(o).replace(/\+/g,""):(o=Number(o),o+(o%1?"":".0"));class dg{constructor(e,t,s){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=s,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.monitor=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:""},this.chaining=[],this.stack=kr(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new to,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=qc.get(this.renderer);return e===void 0&&(e=new Ft,qc.set(this.renderer,e)),e}createRenderTarget(e,t,s){return new Ss(e,t,s)}createCubeRenderTarget(e,t){return new kp(e,t)}createPMREMGenerator(){return new $v(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const s=this.getBindGroupsCache(),n=[];let r=!0;for(const a of t)n.push(a),r=r&&a.groupNode.shared!==!0;let i;return r?(i=s.get(n),i===void 0&&(i=new na(e,n,this.bindingsIndexes[e].group,n),s.set(n,i))):i=new na(e,n,this.bindingsIndexes[e].group,n),i}getBindGroupArray(e,t){const s=this.bindings[t];let n=s[e];return n===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),s[e]=n=[]),n}getBindings(){let e=this.bindGroups;if(e===null){const t={},s=this.bindings;for(const n of zo)for(const r in s[n]){const i=s[n][r];(t[r]||(t[r]=[])).push(...i)}e=[];for(const n in t){const r=t[n],i=this._getBindGroup(n,r);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,s)=>t.bindings[0].groupNode.order-s.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${Ar(t.r)}, ${Ar(t.g)}, ${Ar(t.b)} )`;const s=this.getTypeLength(e),n=this.getComponentType(e),r=i=>this.generateConst(n,i);if(s===2)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)} )`;if(s===3)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)}, ${r(t.z)} )`;if(s===4)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)}, ${r(t.z)}, ${r(t.w)} )`;if(s>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(r).join(", ")} )`;if(s>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const s=this.attributes;for(const r of s)if(r.name===e)return r;const n=new Gc(e,t);return s.push(n),n}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===ze)return"int";if(t===Le)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;const s=ya(e);return(t==="float"?"":t[0])+s}getTypeFromArray(e){return Kv.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const s=t.array,n=e.itemSize,r=e.normalized;let i;return!(e instanceof yl)&&r!==!0&&(i=this.getTypeFromArray(s)),this.getTypeFromLength(n,i)}getTypeLength(e){const t=this.getVectorType(e),s=/vec([2-4])/.exec(t);return s!==null?Number(s[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){return this.stack=kr(this.stack),this.stacks.push(Ea()||this.stack),On(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,On(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,s=null){s=s===null?e.isGlobal(this)?this.globalCache:this.cache:s;let n=s.getData(e);return n===void 0&&(n={},s.setData(e,n)),n[t]===void 0&&(n[t]={}),n[t]}getNodeProperties(e,t="any"){const s=this.getDataFromNode(e,t);return s.properties||(s.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const s=this.getDataFromNode(e);let n=s.bufferAttribute;if(n===void 0){const r=this.uniforms.index++;n=new Gc("nodeAttribute"+r,t,e),this.bufferAttributes.push(n),s.bufferAttribute=n}return n}getStructTypeFromNode(e,t,s=this.shaderStage){const n=this.getDataFromNode(e,s);let r=n.structType;if(r===void 0){const i=this.structs.index++;r=new Cv("StructType"+i,t),this.structs[s].push(r),n.structType=r}return r}getUniformFromNode(e,t,s=this.shaderStage,n=null){const r=this.getDataFromNode(e,s,this.globalCache);let i=r.uniform;if(i===void 0){const a=this.uniforms.index++;i=new Sv(n||"nodeUniform"+a,t,e),this.uniforms[s].push(i),r.uniform=i}return i}getVarFromNode(e,t=null,s=e.getNodeType(this),n=this.shaderStage){const r=this.getDataFromNode(e,n);let i=r.variable;if(i===void 0){const a=this.vars[n]||(this.vars[n]=[]);t===null&&(t="nodeVar"+a.length),i=new lg(t,s),a.push(i),r.variable=i}return i}getVaryingFromNode(e,t=null,s=e.getNodeType(this)){const n=this.getDataFromNode(e,"any");let r=n.varying;if(r===void 0){const i=this.varyings,a=i.length;t===null&&(t="nodeVarying"+a),r=new vv(t,s),i.push(r),n.varying=r}return r}getCodeFromNode(e,t,s=this.shaderStage){const n=this.getDataFromNode(e);let r=n.code;if(r===void 0){const i=this.codes[s]||(this.codes[s]=[]),a=i.length;r=new Av("nodeCode"+a,t),i.push(r),n.code=r}return r}addFlowCodeHierarchy(e,t){const{flowCodes:s,flowCodeBlock:n}=this.getDataFromNode(e);let r=!0,i=t;for(;i;){if(n.get(i)===!0){r=!1;break}i=this.getDataFromNode(i).parentNodeBlock}if(r)for(const a of s)this.addLineFlowCode(a)}addLineFlowCodeBlock(e,t,s){const n=this.getDataFromNode(e),r=n.flowCodes||(n.flowCodes=[]),i=n.flowCodeBlock||(n.flowCodeBlock=new WeakMap);r.push(t),i.set(s,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`; -`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),s=this.flowChildNode(e,t);return this.flowsData.set(e,s),s}buildFunctionNode(e){const t=new Pf,s=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=s,t}flowShaderNode(e){const t=e.layout,s={[Symbol.iterator](){let i=0;const a=Object.values(this);return{next:()=>({value:a[i],done:i++>=a.length})}}};for(const i of t.inputs)s[i.name]=new df(i.type,i.name);e.layout=null;const n=e.call(s),r=this.flowStagesNode(n,t.type);return e.layout=t,r}flowStagesNode(e,t=null){const s=this.flow,n=this.vars,r=this.cache,i=this.buildStage,a=this.stack,u={code:""};this.flow=u,this.vars={},this.cache=new to,this.stack=kr();for(const c of ko)this.setBuildStage(c),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=s,this.vars=n,this.cache=r,this.stack=a,this.setBuildStage(i),u}getFunctionOperator(){return null}flowChildNode(e,t=null){const s=this.flow,n={code:""};return this.flow=n,n.result=e.build(this,t),this.flow=s,n}flowNodeFromShaderStage(e,t,s=null,n=null){const r=this.shaderStage;this.setShaderStage(e);const i=this.flowChildNode(t,s);return n!==null&&(i.code+=`${this.tab+n} = ${i.result}; -`),this.flowCode[e]=this.flowCode[e]+i.code,this.setShaderStage(r),i}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t){return`${this.getType(e)} ${t}`}getVars(e){let t="";const s=this.vars[e];if(s!==void 0)for(const n of s)t+=`${this.getVar(n.type,n.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let s="";if(t!==void 0)for(const n of t)s+=n.code+` -`;return s}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:s}=this;if(t!==null){let n=s.library.fromMaterial(t);n===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),n=new ce),n.build(this)}else this.addFlow("compute",e);for(const n of ko){this.setBuildStage(n),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const r of zo){this.setShaderStage(r);const i=this.flowNodes[r];for(const a of i)n==="generate"?this.flowNode(a):a.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if(t==="float"||t==="int"||t==="uint")return new Dv(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new Lv(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new Iv(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new Vv(e);if(t==="color")return new Gv(e);if(t==="mat3")return new Ov(e);if(t==="mat4")return new kv(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,s){if(t=this.getVectorType(t),s=this.getVectorType(s),t===s||s===null||this.isReference(s))return e;const n=this.getTypeLength(t),r=this.getTypeLength(s);return n===16&&r===9?`${this.getType(s)}(${e}[0].xyz, ${e}[1].xyz, ${e}[2].xyz)`:n===9&&r===4?`${this.getType(s)}(${e}[0].xy, ${e}[1].xy)`:n>4||r>4||r===0?e:n===r?`${this.getType(s)}( ${e} )`:n>r?this.format(`${e}.${"xyz".slice(0,r)}`,this.getTypeFromLength(r,this.getComponentType(t)),s):r===4&&n>1?`${this.getType(s)}( ${this.format(e,t,"vec3")}, 1.0 )`:n===2?`${this.getType(s)}( ${this.format(e,t,"vec2")}, 0.0 )`:(n===1&&r>1&&t!==this.getComponentType(s)&&(e=`${this.getType(this.getComponentType(s))}( ${e} )`),`${this.getType(s)}( ${e} )`)}getSignature(){return`// Three.js r${xl} - Node System -`}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class Kc{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let s=e.get(t);return s===void 0&&(s={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,s)),s}updateBeforeNode(e){const t=e.getUpdateBeforeType(),s=e.updateReference(this);if(t===W.FRAME){const{frameMap:n}=this._getMaps(this.updateBeforeMap,s);n.get(s)!==this.frameId&&e.updateBefore(this)!==!1&&n.set(s,this.frameId)}else if(t===W.RENDER){const{renderMap:n}=this._getMaps(this.updateBeforeMap,s);n.get(s)!==this.renderId&&e.updateBefore(this)!==!1&&n.set(s,this.renderId)}else t===W.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),s=e.updateReference(this);if(t===W.FRAME){const{frameMap:n}=this._getMaps(this.updateAfterMap,s);n.get(s)!==this.frameId&&e.updateAfter(this)!==!1&&n.set(s,this.frameId)}else if(t===W.RENDER){const{renderMap:n}=this._getMaps(this.updateAfterMap,s);n.get(s)!==this.renderId&&e.updateAfter(this)!==!1&&n.set(s,this.renderId)}else t===W.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),s=e.updateReference(this);if(t===W.FRAME){const{frameMap:n}=this._getMaps(this.updateMap,s);n.get(s)!==this.frameId&&e.update(this)!==!1&&n.set(s,this.frameId)}else if(t===W.RENDER){const{renderMap:n}=this._getMaps(this.updateMap,s);n.get(s)!==this.renderId&&e.update(this)!==!1&&n.set(s,this.renderId)}else t===W.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class $u{constructor(e,t,s=null,n="",r=!1){this.type=e,this.name=t,this.count=s,this.qualifier=n,this.isConst=r}}$u.isNodeFunctionInput=!0;class Xv extends Es{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,s=this.colorNode,n=Pu(this.light),r=e.context.reflectedLight;t.direct({lightDirection:n,lightColor:s,reflectedLight:r},e.stack,e)}}const ao=new Ie,Rr=new Ie;let Nn=null;class Yv extends Es{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=V(new j).setGroup(k),this.halfWidth=V(new j).setGroup(k),this.updateType=W.RENDER}update(e){super.update(e);const{light:t}=this,s=e.camera.matrixWorldInverse;Rr.identity(),ao.copy(t.matrixWorld),ao.premultiply(s),Rr.extractRotation(ao),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Rr),this.halfHeight.value.applyMatrix4(Rr)}setup(e){super.setup(e);let t,s;e.isAvailable("float32Filterable")?(t=K(Nn.LTC_FLOAT_1),s=K(Nn.LTC_FLOAT_2)):(t=K(Nn.LTC_HALF_1),s=K(Nn.LTC_HALF_2));const{colorNode:n,light:r}=this,i=e.context.lightingModel,a=Pi(r),u=e.context.reflectedLight;i.directRectArea({lightColor:n,lightPosition:a,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:u,ltc_1:t,ltc_2:s},e.stack,e)}static setLTC(e){Nn=e}}class hg extends Es{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=V(0).setGroup(k),this.penumbraCosNode=V(0).setGroup(k),this.cutoffDistanceNode=V(0).setGroup(k),this.decayExponentNode=V(0).setGroup(k)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e){const{coneCosNode:t,penumbraCosNode:s}=this;return ct(t,s,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:s,cutoffDistanceNode:n,decayExponentNode:r,light:i}=this,a=Pi(i).sub(xe),u=a.normalize(),c=u.dot(Pu(i)),l=this.getSpotAttenuation(c),d=a.length(),h=Gu({lightDistance:d,cutoffDistance:n,decayExponent:r});let p=s.mul(l).mul(h);if(i.map){const m=Vf(i),x=K(i.map,m.xy).onRenderUpdate(()=>i.map);p=m.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(x),p)}const f=e.context.reflectedLight;t.direct({lightDirection:u,lightColor:p,reflectedLight:f},e.stack,e)}}class jv extends hg{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e){const t=this.light.iesMap;let s=null;if(t&&t.isTexture===!0){const n=e.acos().mul(1/Math.PI);s=K(t,M(n,0),0).r}else s=super.getSpotAttenuation(e);return s}}class Qv extends Es{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class Zv extends Es{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=Uu(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=V(new mt).setGroup(k)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:s,lightDirectionNode:n}=this,i=lt.dot(n).mul(.5).add(.5),a=Q(s,t,i);e.context.irradiance.addAssign(a)}}class Jv extends Es{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let s=0;s<9;s++)t.push(new j);this.lightProbe=Gt(t)}update(e){const{light:t}=this;super.update(e);for(let s=0;s<9;s++)this.lightProbe.array[s].copy(t.sh.coefficients[s]).multiplyScalar(t.intensity)}setup(e){const t=cg(Si,this.lightProbe);e.context.irradiance.addAssign(t)}}class pg{parseFunction(){console.warn("Abstract function.")}}class Hu{constructor(e,t,s="",n=""){this.type=e,this.inputs=t,this.name=s,this.precision=n}getCode(){console.warn("Abstract function.")}}Hu.isNodeFunction=!0;const eA=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,tA=/[a-z_0-9]+/ig,Xc="#pragma main",sA=o=>{o=o.trim();const e=o.indexOf(Xc),t=e!==-1?o.slice(e+Xc.length):o,s=t.match(eA);if(s!==null&&s.length===5){const n=s[4],r=[];let i=null;for(;(i=tA.exec(n))!==null;)r.push(i);const a=[];let u=0;for(;u0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==s||n){const r=this.getCacheNode("background",s,()=>{if(s.isCubeTexture===!0||s.mapping===jn||s.mapping===Qn||s.mapping===bo){if(e.backgroundBlurriness>0||s.mapping===bo)return vu(s);{let i;return s.isCubeTexture===!0?i=on(s):i=K(s),Wp(i)}}else{if(s.isTexture===!0)return K(s,Bt.flipY()).setUpdateMatrix(!0);s.isColor!==!0&&console.error("WebGPUNodes: Unsupported background configuration.",s)}},n);t.backgroundNode=r,t.background=s,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,s,n=!1){const r=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let i=r.get(t);return(i===void 0||n)&&(i=s(),r.set(t,i)),i}updateFog(e){const t=this.get(e),s=e.fog;if(s){if(t.fog!==s){const n=this.getCacheNode("fog",s,()=>{if(s.isFogExp2){const r=ne("color","color",s).setGroup(k),i=ne("density","float",s).setGroup(k);return Xn(r,Mu(i))}else if(s.isFog){const r=ne("color","color",s).setGroup(k),i=ne("near","float",s).setGroup(k),a=ne("far","float",s).setGroup(k);return Xn(r,wu(i,a))}else console.error("THREE.Renderer: Unsupported fog configuration.",s)});t.fogNode=n,t.fog=s}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),s=e.environment;if(s){if(t.environment!==s){const n=this.getCacheNode("environment",s,()=>{if(s.isCubeTexture===!0)return on(s);if(s.isTexture===!0)return K(s);console.error("Nodes: Unsupported environment configuration.",s)});t.environmentNode=n,t.environment=s}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,s=null,n=null,r=null){const i=this.nodeFrame;return i.renderer=e,i.scene=t,i.object=s,i.camera=n,i.material=r,i}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace}hasOutputChange(e){return Yc.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,s=this.getOutputCacheKey(),n=K(e,Bt).renderOutput(t.toneMapping,t.currentColorSpace);return Yc.set(e,s),n}updateBefore(e){const t=e.getNodeBuilderState();for(const s of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(s)}updateAfter(e){const t=e.getNodeBuilderState();for(const s of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(s)}updateForCompute(e){const t=this.getNodeFrame(),s=this.getForCompute(e);for(const n of s.updateNodes)t.updateNode(n)}updateForRender(e){const t=this.getNodeFrameForRender(e),s=e.getNodeBuilderState();for(const n of s.updateNodes)t.updateNode(n)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new Kc,this.nodeBuilderCache=new Map,this.cacheLib={}}}const uo=new vl;class ii{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new Yn,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,s){const n=e.length;for(let r=0;r{await this.compileAsync(d,h);const f=this._renderLists.get(d,h),m=this._renderContexts.get(d,h,this._renderTarget),x=d.overrideMaterial||p.material,N=this._objects.get(p,x,d,h,f.lightsNode,m,m.clippingContext),{fragmentShader:v,vertexShader:w}=N.getNodeBuilderState();return{fragmentShader:v,vertexShader:w}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let s=this.backend;try{await s.init(this)}catch(n){if(this._getFallback!==null)try{this.backend=s=this._getFallback(n),await s.init(this)}catch(r){t(r);return}else{t(n);return}}this._nodes=new iA(this,s),this._animation=new g_(this._nodes,this.info),this._attributes=new N_(s),this._background=new _v(this,this._nodes),this._geometries=new v_(this._attributes,this.info),this._textures=new V_(this,s,this.info),this._pipelines=new w_(s,this._nodes),this._bindings=new M_(s,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new T_(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new U_(this.lighting),this._bundles=new aA,this._renderContexts=new L_,this._animation.start(),this._initialized=!0,e()}),this._initPromise)}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,s=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();const n=this._nodes.nodeFrame,r=n.renderId,i=this._currentRenderContext,a=this._currentRenderObjectFunction,u=this._compilationPromises,c=e.isScene===!0?e:jc;s===null&&(s=e);const l=this._renderTarget,d=this._renderContexts.get(s,t,l),h=this._activeMipmapLevel,p=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=p,n.renderId++,n.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||(d.clippingContext=new ii),d.clippingContext.updateGlobal(c,t),c.onBeforeRender(this,e,t,l);const f=this._renderLists.get(e,t);if(f.begin(),this._projectObject(e,t,0,f,d.clippingContext),s!==e&&s.traverseVisible(function(w){w.isLight&&w.layers.test(t.layers)&&f.pushLight(w)}),f.finish(),l!==null){this._textures.updateRenderTarget(l,h);const w=this._textures.get(l);d.textures=w.textures,d.depthTexture=w.depthTexture}else d.textures=null,d.depthTexture=null;this._background.update(c,f,d);const m=f.opaque,x=f.transparent,N=f.transparentDoublePass,v=f.lightsNode;this.opaque===!0&&m.length>0&&this._renderObjects(m,t,c,v),this.transparent===!0&&x.length>0&&this._renderTransparents(x,N,t,c,v),n.renderId=r,this._currentRenderContext=i,this._currentRenderObjectFunction=a,this._compilationPromises=u,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(p)}async renderAsync(e,t){this._initialized===!1&&await this.init();const s=this._renderScene(e,t);await this.backend.resolveTimestampAsync(s,"render")}async waitForGPU(){await this.backend.waitForGPU()}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost: - -Message: ${e.message}`;e.reason&&(t+=` -Reason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,s){const{bundleGroup:n,camera:r,renderList:i}=e,a=this._currentRenderContext,u=this._bundles.get(n,r),c=this.backend.get(u);c.renderContexts===void 0&&(c.renderContexts=new Set);const l=n.version!==c.version,d=c.renderContexts.has(a)===!1||l;if(c.renderContexts.add(a),d){this.backend.beginBundle(a),(c.renderObjects===void 0||l)&&(c.renderObjects=[]),this._currentRenderBundle=u;const h=i.opaque;this.opaque===!0&&h.length>0&&this._renderObjects(h,r,t,s),this._currentRenderBundle=null,this.backend.finishBundle(a,u),c.version=n.version}else{const{renderObjects:h}=c;for(let p=0,f=h.length;p>=h,f.viewportValue.height>>=h,f.viewportValue.minDepth=w,f.viewportValue.maxDepth=B,f.viewport=f.viewportValue.equals(co)===!1,f.scissorValue.copy(N).multiplyScalar(v).floor(),f.scissor=this._scissorTest&&f.scissorValue.equals(co)===!1,f.scissorValue.width>>=h,f.scissorValue.height>>=h,f.clippingContext||(f.clippingContext=new ii),f.clippingContext.updateGlobal(c,t),c.onBeforeRender(this,e,t,p),Er.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),lo.setFromProjectionMatrix(Er,m);const F=this._renderLists.get(e,t);if(F.begin(),this._projectObject(e,t,0,F,f.clippingContext),F.finish(),this.sortObjects===!0&&F.sort(this._opaqueSort,this._transparentSort),p!==null){this._textures.updateRenderTarget(p,h);const Z=this._textures.get(p);f.textures=Z.textures,f.depthTexture=Z.depthTexture,f.width=Z.width,f.height=Z.height,f.renderTarget=p,f.depth=p.depthBuffer,f.stencil=p.stencilBuffer}else f.textures=null,f.depthTexture=null,f.width=this.domElement.width,f.height=this.domElement.height,f.depth=this.depth,f.stencil=this.stencil;f.width>>=h,f.height>>=h,f.activeCubeFace=d,f.activeMipmapLevel=h,f.occlusionQueryCount=F.occlusionQueryCount,this._background.update(c,F,f),this.backend.beginRender(f);const{bundles:L,lightsNode:I,transparentDoublePass:G,transparent:X,opaque:ie}=F;if(L.length>0&&this._renderBundles(L,c,I),this.opaque===!0&&ie.length>0&&this._renderObjects(ie,t,c,I),this.transparent===!0&&X.length>0&&this._renderTransparents(X,G,t,c,I),this.backend.finishRender(f),r.renderId=i,this._currentRenderContext=a,this._currentRenderObjectFunction=u,n!==null){this.setRenderTarget(l,d,h);const Z=this._quad;this._nodes.hasOutputChange(p.texture)&&(Z.material.fragmentNode=this._nodes.getOutputNode(p.texture),Z.material.needsUpdate=!0),this._renderScene(Z,Z.camera,!1)}return c.onAfterRender(this,e,t,p),f}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,s){this._width=e,this._height=t,this._pixelRatio=s,this.domElement.width=Math.floor(e*s),this.domElement.height=Math.floor(t*s),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setSize(e,t,s=!0){this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),s===!0&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,s,n){const r=this._scissor;e.isVector4?r.copy(e):r.set(e,t,s,n)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,s,n,r=0,i=1){const a=this._viewport;e.isVector4?a.copy(e):a.set(e,t,s,n),a.minDepth=r,a.maxDepth=i}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,s=!0){if(this._initialized===!1)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,s);const n=this._renderTarget||this._getFrameBufferTarget();let r=null;if(n!==null){this._textures.updateRenderTarget(n);const i=this._textures.get(n);r=this._renderContexts.get(null,null,n),r.textures=i.textures,r.depthTexture=i.depthTexture,r.width=i.width,r.height=i.height,r.renderTarget=n,r.depth=n.depthBuffer,r.stencil=n.stencilBuffer}if(this.backend.clear(e,t,s,r),n!==null&&this._renderTarget===null){const i=this._quad;this._nodes.hasOutputChange(n.texture)&&(i.material.fragmentNode=this._nodes.getOutputNode(n.texture),i.material.needsUpdate=!0),this._renderScene(i,i.camera,!1)}}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,s=!0){this._initialized===!1&&await this.init(),this.clear(e,t,s)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this._renderTarget!==null?ss:this.toneMapping}get currentColorSpace(){return this._renderTarget!==null?kt:this.outputColorSpace}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,s=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=s}getRenderTarget(){return this._renderTarget}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(this.isDeviceLost===!0)return;if(this._initialized===!1)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,s=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const n=this.backend,r=this._pipelines,i=this._bindings,a=this._nodes,u=Array.isArray(e)?e:[e];if(u[0]===void 0||u[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");n.beginCompute(e);for(const c of u){if(r.has(c)===!1){const h=()=>{c.removeEventListener("dispose",h),r.delete(c),i.delete(c),a.delete(c)};c.addEventListener("dispose",h);const p=c.onInitFunction;p!==null&&p.call(c,{renderer:this})}a.updateForCompute(c),i.updateForCompute(c);const l=i.getForCompute(c),d=r.getForCompute(c,l);n.compute(e,c,l,d)}n.finishCompute(e),t.renderId=s}async computeAsync(e){this._initialized===!1&&await this.init(),this.compute(e),await this.backend.resolveTimestampAsync(e,"compute")}async hasFeatureAsync(e){return this._initialized===!1&&await this.init(),this.backend.hasFeature(e)}hasFeature(e){return this._initialized===!1?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){this._initialized===!1&&await this.init(),this._textures.updateTexture(e)}initTexture(e){this._initialized===!1&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=jt.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=jt.copy(t).floor();else{console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=jt.set(0,0,e.image.width,e.image.height);let s=this._currentRenderContext,n;s!==null?n=s.renderTarget:(n=this._renderTarget||this._getFrameBufferTarget(),n!==null&&(this._textures.updateRenderTarget(n),s=this._textures.get(n))),this._textures.updateTexture(e,{renderTarget:n}),this.backend.copyFramebufferToTexture(e,s,t)}copyTextureToTexture(e,t,s=null,n=null,r=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,s,n,r)}async readRenderTargetPixelsAsync(e,t,s,n,r,i=0,a=0){return this.backend.copyTextureToBuffer(e.textures[i],t,s,n,r,a)}_projectObject(e,t,s,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)s=e.renderOrder,e.isClippingGroup&&e.enabled&&(r=r.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)n.pushLight(e);else if(e.isSprite){if(!e.frustumCulled||lo.intersectsSprite(e)){this.sortObjects===!0&&jt.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Er);const{geometry:u,material:c}=e;c.visible&&n.push(e,u,c,s,jt.z,null,r)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||lo.intersectsObject(e))){const{geometry:u,material:c}=e;if(this.sortObjects===!0&&(u.boundingSphere===null&&u.computeBoundingSphere(),jt.copy(u.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(Er)),Array.isArray(c)){const l=u.groups;for(let d=0,h=l.length;d0){for(const{material:i}of t)i.side=Ct;this._renderObjects(t,s,n,r,"backSide");for(const{material:i}of t)i.side=No;this._renderObjects(e,s,n,r);for(const{material:i}of t)i.side=js}else this._renderObjects(e,s,n,r)}_renderObjects(e,t,s,n,r=null){for(let i=0,a=e.length;i0,p.isShadowNodeMaterial&&(p.side=r.shadowSide===null?r.side:r.shadowSide,r.depthNode&&r.depthNode.isNode&&(h=p.depthNode,p.depthNode=r.depthNode),r.castShadowNode&&r.castShadowNode.isNode&&(d=p.colorNode,p.colorNode=r.castShadowNode)),r=p}r.transparent===!0&&r.side===js&&r.forceSinglePass===!1?(r.side=Ct,this._handleObjectFunction(e,r,t,s,a,i,u,"backSide"),r.side=No,this._handleObjectFunction(e,r,t,s,a,i,u,c),r.side=js):this._handleObjectFunction(e,r,t,s,a,i,u,c),l!==void 0&&(t.overrideMaterial.positionNode=l),h!==void 0&&(t.overrideMaterial.depthNode=h),d!==void 0&&(t.overrideMaterial.colorNode=d),e.onAfterRender(this,t,s,n,r,i)}_renderObjectDirect(e,t,s,n,r,i,a,u){const c=this._objects.get(e,t,s,n,r,this._currentRenderContext,a,u);c.drawRange=e.geometry.drawRange,c.group=i;const l=this._nodes.needsRefresh(c);l&&(this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c)),this._pipelines.updateForRender(c),this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(c),c.bundle=this._currentRenderBundle.bundleGroup),this.backend.draw(c,this.info),l&&this._nodes.updateAfter(c)}_createObjectPipeline(e,t,s,n,r,i,a,u){const c=this._objects.get(e,t,s,n,r,this._currentRenderContext,a,u);c.drawRange=e.geometry.drawRange,c.group=i,this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c),this._pipelines.getForRender(c,this._compilationPromises),this._nodes.updateAfter(c)}get compile(){return this.compileAsync}}class qu{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}function dA(o){return o+(ts-o%ts)%ts}class gg extends qu{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return dA(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class mg extends gg{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let hA=0;class yg extends mg{constructor(e,t){super("UniformBuffer_"+hA++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class pA extends mg{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=0;for(let t=0,s=this.uniforms.length;t0?h:"";a=`${l.name} { - ${d} ${i.name}[${p}]; -}; -`}else a=`${this.getVectorType(i.type)} ${this.getPropertyName(i,e)};`,u=!0;const c=i.node.precision;if(c!==null&&(a=_A[c]+" "+a),u){a=" "+a;const l=i.groupNode.name;(n[l]||(n[l]=[])).push(a)}else a="uniform "+a,s.push(a)}let r="";for(const i in n){const a=n[i];r+=this._getGLSLUniformStruct(e+"_"+i,a.join(` -`))+` -`}return r+=s.join(` -`),r}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==ze){let s=e;e.isInterleavedBufferAttribute&&(s=e.data);const n=s.array;n instanceof Uint32Array||n instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const s=this.getAttributesArray();let n=0;for(const r of s)t+=`layout( location = ${n++} ) in ${r.type} ${r.name}; -`}return t}getStructMembers(e){const t=[],s=e.getMemberTypes();for(let n=0;ns*n,1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,s=this.shaderStage){const n=this.extensions[s]||(this.extensions[s]=new Map);n.has(e)===!1&&n.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const n=this.renderer.backend.extensions;this.object.isBatchedMesh&&n.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const s=this.extensions[e];if(s!==void 0)for(const{name:n,behavior:r}of s.values())t.push(`#extension ${n} : ${r}`);return t.join(` -`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=Qc[e];if(t===void 0){let s;switch(t=!1,e){case"float32Filterable":s="OES_texture_float_linear";break;case"clipDistance":s="WEBGL_clip_cull_distance";break}if(s!==void 0){const n=this.renderer.backend.extensions;n.has(s)&&(n.get(s),t=!0)}Qc[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let s=0;s0&&(s+=` -`),s+=` // flow -> ${c} - `),s+=`${u.code} - `,a===r&&t!=="compute"&&(s+=`// result - `,t==="vertex"?(s+="gl_Position = ",s+=`${u.result};`):t==="fragment"&&(a.outputNode.isOutputStructNode||(s+="fragColor = ",s+=`${u.result};`)))}const i=e[t];i.extensions=this.getExtensions(t),i.uniforms=this.getUniforms(t),i.attributes=this.getAttributes(t),i.varyings=this.getVaryings(t),i.vars=this.getVars(t),i.structs=this.getStructs(t),i.codes=this.getCodes(t),i.transforms=this.getTransforms(t),i.flow=s}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,s,n=null){const r=super.getUniformFromNode(e,t,s,n),i=this.getDataFromNode(e,s,this.globalCache);let a=i.uniformGPU;if(a===void 0){const u=e.groupNode,c=u.name,l=this.getBindGroupArray(c,s);if(t==="texture")a=new Di(r.name,r.node,u),l.push(a);else if(t==="cubeTexture")a=new Tg(r.name,r.node,u),l.push(a);else if(t==="texture3D")a=new _g(r.name,r.node,u),l.push(a);else if(t==="buffer"){e.name=`NodeBuffer_${e.id}`,r.name=`buffer${e.id}`;const d=new yg(e,u);d.name=e.name,l.push(d),a=d}else{const d=this.uniformGroups[s]||(this.uniformGroups[s]={});let h=d[c];h===void 0&&(h=new xg(s+"_"+c,u),d[c]=h,l.push(h)),a=this.getNodeUniform(r,t),h.addUniform(a)}i.uniformGPU=a}return r}}let ho=null,Ls=null;class bg{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampAsync(){}async waitForGPU(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return ho=ho||new Ye,this.renderer.getDrawingBufferSize(ho)}setScissorTest(){}getClearColor(){const e=this.renderer;return Ls=Ls||new Ru,e.getClearColor(Ls),Ls.getRGB(Ls,this.renderer.currentColorSpace),Ls}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:ym(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${xl} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let NA=0;class SA{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class vA{constructor(e){this.backend=e}createAttribute(e,t){const s=this.backend,{gl:n}=s,r=e.array,i=e.usage||n.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,u=s.get(a);let c=u.bufferGPU;c===void 0&&(c=this._createBuffer(n,t,r,i),u.bufferGPU=c,u.bufferType=t,u.version=a.version);let l;if(r instanceof Float32Array)l=n.FLOAT;else if(r instanceof Uint16Array)e.isFloat16BufferAttribute?l=n.HALF_FLOAT:l=n.UNSIGNED_SHORT;else if(r instanceof Int16Array)l=n.SHORT;else if(r instanceof Uint32Array)l=n.UNSIGNED_INT;else if(r instanceof Int32Array)l=n.INT;else if(r instanceof Int8Array)l=n.BYTE;else if(r instanceof Uint8Array)l=n.UNSIGNED_BYTE;else if(r instanceof Uint8ClampedArray)l=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+r);let d={bufferGPU:c,bufferType:t,type:l,byteLength:r.byteLength,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:l===n.INT||l===n.UNSIGNED_INT||e.gpuType===ze,id:NA++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const h=this._createBuffer(n,t,r,i);d=new SA(d,h)}s.set(e,d)}updateAttribute(e){const t=this.backend,{gl:s}=t,n=e.array,r=e.isInterleavedBufferAttribute?e.data:e,i=t.get(r),a=i.bufferType,u=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(s.bindBuffer(a,i.bufferGPU),u.length===0)s.bufferSubData(a,0,n);else{for(let c=0,l=u.length;c1?this.enable(n.SAMPLE_ALPHA_TO_COVERAGE):this.disable(n.SAMPLE_ALPHA_TO_COVERAGE),s>0&&this.currentClippingPlanes!==s)for(let u=0;u<8;u++)u{function r(){const i=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(i===e.WAIT_FAILED){e.deleteSync(t),n();return}if(i===e.TIMEOUT_EXPIRED){requestAnimationFrame(r);return}e.deleteSync(t),s()}r()})}}let el=!1,wr,fo,tl;class CA{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},el===!1&&(this._init(this.gl),el=!0)}_init(e){wr={[li]:e.REPEAT,[ca]:e.CLAMP_TO_EDGE,[ci]:e.MIRRORED_REPEAT},fo={[bt]:e.NEAREST,[So]:e.NEAREST_MIPMAP_NEAREST,[Xs]:e.NEAREST_MIPMAP_LINEAR,[ft]:e.LINEAR,[_o]:e.LINEAR_MIPMAP_NEAREST,[ms]:e.LINEAR_MIPMAP_LINEAR},tl={[Bl]:e.NEVER,[Ml]:e.ALWAYS,[ua]:e.LESS,[wl]:e.LEQUAL,[El]:e.EQUAL,[Cl]:e.GEQUAL,[Rl]:e.GREATER,[Al]:e.NOTEQUAL}}filterFallback(e){const{gl:t}=this;return e===bt||e===So||e===Xs?t.NEAREST:t.LINEAR}getGLTextureType(e){const{gl:t}=this;let s;return e.isCubeTexture===!0?s=t.TEXTURE_CUBE_MAP:e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?s=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?s=t.TEXTURE_3D:s=t.TEXTURE_2D,s}getInternalFormat(e,t,s,n,r=!1){const{gl:i,extensions:a}=this;if(e!==null){if(i[e]!==void 0)return i[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let u=t;return t===i.RED&&(s===i.FLOAT&&(u=i.R32F),s===i.HALF_FLOAT&&(u=i.R16F),s===i.UNSIGNED_BYTE&&(u=i.R8),s===i.UNSIGNED_SHORT&&(u=i.R16),s===i.UNSIGNED_INT&&(u=i.R32UI),s===i.BYTE&&(u=i.R8I),s===i.SHORT&&(u=i.R16I),s===i.INT&&(u=i.R32I)),t===i.RED_INTEGER&&(s===i.UNSIGNED_BYTE&&(u=i.R8UI),s===i.UNSIGNED_SHORT&&(u=i.R16UI),s===i.UNSIGNED_INT&&(u=i.R32UI),s===i.BYTE&&(u=i.R8I),s===i.SHORT&&(u=i.R16I),s===i.INT&&(u=i.R32I)),t===i.RG&&(s===i.FLOAT&&(u=i.RG32F),s===i.HALF_FLOAT&&(u=i.RG16F),s===i.UNSIGNED_BYTE&&(u=i.RG8),s===i.UNSIGNED_SHORT&&(u=i.RG16),s===i.UNSIGNED_INT&&(u=i.RG32UI),s===i.BYTE&&(u=i.RG8I),s===i.SHORT&&(u=i.RG16I),s===i.INT&&(u=i.RG32I)),t===i.RG_INTEGER&&(s===i.UNSIGNED_BYTE&&(u=i.RG8UI),s===i.UNSIGNED_SHORT&&(u=i.RG16UI),s===i.UNSIGNED_INT&&(u=i.RG32UI),s===i.BYTE&&(u=i.RG8I),s===i.SHORT&&(u=i.RG16I),s===i.INT&&(u=i.RG32I)),t===i.RGB&&(s===i.FLOAT&&(u=i.RGB32F),s===i.HALF_FLOAT&&(u=i.RGB16F),s===i.UNSIGNED_BYTE&&(u=i.RGB8),s===i.UNSIGNED_SHORT&&(u=i.RGB16),s===i.UNSIGNED_INT&&(u=i.RGB32UI),s===i.BYTE&&(u=i.RGB8I),s===i.SHORT&&(u=i.RGB16I),s===i.INT&&(u=i.RGB32I),s===i.UNSIGNED_BYTE&&(u=n===q&&r===!1?i.SRGB8:i.RGB8),s===i.UNSIGNED_SHORT_5_6_5&&(u=i.RGB565),s===i.UNSIGNED_SHORT_5_5_5_1&&(u=i.RGB5_A1),s===i.UNSIGNED_SHORT_4_4_4_4&&(u=i.RGB4),s===i.UNSIGNED_INT_5_9_9_9_REV&&(u=i.RGB9_E5)),t===i.RGB_INTEGER&&(s===i.UNSIGNED_BYTE&&(u=i.RGB8UI),s===i.UNSIGNED_SHORT&&(u=i.RGB16UI),s===i.UNSIGNED_INT&&(u=i.RGB32UI),s===i.BYTE&&(u=i.RGB8I),s===i.SHORT&&(u=i.RGB16I),s===i.INT&&(u=i.RGB32I)),t===i.RGBA&&(s===i.FLOAT&&(u=i.RGBA32F),s===i.HALF_FLOAT&&(u=i.RGBA16F),s===i.UNSIGNED_BYTE&&(u=i.RGBA8),s===i.UNSIGNED_SHORT&&(u=i.RGBA16),s===i.UNSIGNED_INT&&(u=i.RGBA32UI),s===i.BYTE&&(u=i.RGBA8I),s===i.SHORT&&(u=i.RGBA16I),s===i.INT&&(u=i.RGBA32I),s===i.UNSIGNED_BYTE&&(u=n===q&&r===!1?i.SRGB8_ALPHA8:i.RGBA8),s===i.UNSIGNED_SHORT_4_4_4_4&&(u=i.RGBA4),s===i.UNSIGNED_SHORT_5_5_5_1&&(u=i.RGB5_A1)),t===i.RGBA_INTEGER&&(s===i.UNSIGNED_BYTE&&(u=i.RGBA8UI),s===i.UNSIGNED_SHORT&&(u=i.RGBA16UI),s===i.UNSIGNED_INT&&(u=i.RGBA32UI),s===i.BYTE&&(u=i.RGBA8I),s===i.SHORT&&(u=i.RGBA16I),s===i.INT&&(u=i.RGBA32I)),t===i.DEPTH_COMPONENT&&(s===i.UNSIGNED_INT&&(u=i.DEPTH24_STENCIL8),s===i.FLOAT&&(u=i.DEPTH_COMPONENT32F)),t===i.DEPTH_STENCIL&&s===i.UNSIGNED_INT_24_8&&(u=i.DEPTH24_STENCIL8),(u===i.R16F||u===i.R32F||u===i.RG16F||u===i.RG32F||u===i.RGBA16F||u===i.RGBA32F)&&a.get("EXT_color_buffer_float"),u}setTextureParameters(e,t){const{gl:s,extensions:n,backend:r}=this;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,t.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,t.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.NONE),s.texParameteri(e,s.TEXTURE_WRAP_S,wr[t.wrapS]),s.texParameteri(e,s.TEXTURE_WRAP_T,wr[t.wrapT]),(e===s.TEXTURE_3D||e===s.TEXTURE_2D_ARRAY)&&s.texParameteri(e,s.TEXTURE_WRAP_R,wr[t.wrapR]),s.texParameteri(e,s.TEXTURE_MAG_FILTER,fo[t.magFilter]);const i=t.mipmaps!==void 0&&t.mipmaps.length>0,a=t.minFilter===ft&&i?ms:t.minFilter;if(s.texParameteri(e,s.TEXTURE_MIN_FILTER,fo[a]),t.compareFunction&&(s.texParameteri(e,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(e,s.TEXTURE_COMPARE_FUNC,tl[t.compareFunction])),n.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===bt||t.minFilter!==Xs&&t.minFilter!==ms||t.type===ot&&n.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const u=n.get("EXT_texture_filter_anisotropic");s.texParameterf(e,u.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,r.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:s,defaultTextures:n}=this,r=this.getGLTextureType(e);let i=n[r];i===void 0&&(i=t.createTexture(),s.state.bindTexture(r,i),t.texParameteri(r,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(r,t.TEXTURE_MAG_FILTER,t.NEAREST),n[r]=i),s.set(e,{textureGPU:i,glTextureType:r,isDefault:!0})}createTexture(e,t){const{gl:s,backend:n}=this,{levels:r,width:i,height:a,depth:u}=t,c=n.utils.convert(e.format,e.colorSpace),l=n.utils.convert(e.type),d=this.getInternalFormat(e.internalFormat,c,l,e.colorSpace,e.isVideoTexture),h=s.createTexture(),p=this.getGLTextureType(e);n.state.bindTexture(p,h),this.setTextureParameters(p,e),e.isDataArrayTexture||e.isCompressedArrayTexture?s.texStorage3D(s.TEXTURE_2D_ARRAY,r,d,i,a,u):e.isData3DTexture?s.texStorage3D(s.TEXTURE_3D,r,d,i,a,u):e.isVideoTexture||s.texStorage2D(p,r,d,i,a),n.set(e,{textureGPU:h,glTextureType:p,glFormat:c,glType:l,glInternalFormat:d})}copyBufferToTexture(e,t){const{gl:s,backend:n}=this,{textureGPU:r,glTextureType:i,glFormat:a,glType:u}=n.get(t),{width:c,height:l}=t.source.data;s.bindBuffer(s.PIXEL_UNPACK_BUFFER,e),n.state.bindTexture(i,r),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.texSubImage2D(i,0,0,0,c,l,a,u,0),s.bindBuffer(s.PIXEL_UNPACK_BUFFER,null),n.state.unbindTexture()}updateTexture(e,t){const{gl:s}=this,{width:n,height:r}=t,{textureGPU:i,glTextureType:a,glFormat:u,glType:c,glInternalFormat:l}=this.backend.get(e);if(e.isRenderTargetTexture||i===void 0)return;const d=h=>h.isDataTexture?h.image.data:typeof HTMLImageElement<"u"&&h instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&h instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&h instanceof ImageBitmap||h instanceof OffscreenCanvas?h:h.data;if(this.backend.state.bindTexture(a,i),this.setTextureParameters(a,e),e.isCompressedTexture){const h=e.mipmaps,p=t.image;for(let f=0;f0,h=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const p=a!==0||u!==0;let f,m;if(e.isDepthTexture===!0?(f=n.DEPTH_BUFFER_BIT,m=n.DEPTH_ATTACHMENT,t.stencil&&(f|=n.STENCIL_BUFFER_BIT)):(f=n.COLOR_BUFFER_BIT,m=n.COLOR_ATTACHMENT0),p){const x=this.backend.get(t.renderTarget),N=x.framebuffers[t.getCacheKey()],v=x.msaaFrameBuffer;r.bindFramebuffer(n.DRAW_FRAMEBUFFER,N),r.bindFramebuffer(n.READ_FRAMEBUFFER,v);const w=h-u-l;n.blitFramebuffer(a,w,a+c,w+l,a,w,a+c,w+l,f,n.NEAREST),r.bindFramebuffer(n.READ_FRAMEBUFFER,N),r.bindTexture(n.TEXTURE_2D,i),n.copyTexSubImage2D(n.TEXTURE_2D,0,0,0,a,w,c,l),r.unbindTexture()}else{const x=n.createFramebuffer();r.bindFramebuffer(n.DRAW_FRAMEBUFFER,x),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,m,n.TEXTURE_2D,i,0),n.blitFramebuffer(0,0,c,l,0,0,c,l,f,n.NEAREST),n.deleteFramebuffer(x)}}else r.bindTexture(n.TEXTURE_2D,i),n.copyTexSubImage2D(n.TEXTURE_2D,0,0,0,a,h-l-u,c,l),r.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t){const{gl:s}=this,n=t.renderTarget,{samples:r,depthTexture:i,depthBuffer:a,stencilBuffer:u,width:c,height:l}=n;if(s.bindRenderbuffer(s.RENDERBUFFER,e),a&&!u){let d=s.DEPTH_COMPONENT24;r>0?(i&&i.isDepthTexture&&i.type===s.FLOAT&&(d=s.DEPTH_COMPONENT32F),s.renderbufferStorageMultisample(s.RENDERBUFFER,r,d,c,l)):s.renderbufferStorage(s.RENDERBUFFER,d,c,l),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,e)}else a&&u&&(r>0?s.renderbufferStorageMultisample(s.RENDERBUFFER,r,s.DEPTH24_STENCIL8,c,l):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,c,l),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,s,n,r,i){const{backend:a,gl:u}=this,{textureGPU:c,glFormat:l,glType:d}=this.backend.get(e),h=u.createFramebuffer();u.bindFramebuffer(u.READ_FRAMEBUFFER,h);const p=e.isCubeTexture?u.TEXTURE_CUBE_MAP_POSITIVE_X+i:u.TEXTURE_2D;u.framebufferTexture2D(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,p,c,0);const f=this._getTypedArrayType(d),m=this._getBytesPerTexel(d,l),N=n*r*m,v=u.createBuffer();u.bindBuffer(u.PIXEL_PACK_BUFFER,v),u.bufferData(u.PIXEL_PACK_BUFFER,N,u.STREAM_READ),u.readPixels(t,s,n,r,l,d,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const w=new f(N/f.BYTES_PER_ELEMENT);return u.bindBuffer(u.PIXEL_PACK_BUFFER,v),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,w),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),u.deleteFramebuffer(h),w}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:s}=this;let n=0;if(e===s.UNSIGNED_BYTE&&(n=1),(e===s.UNSIGNED_SHORT_4_4_4_4||e===s.UNSIGNED_SHORT_5_5_5_1||e===s.UNSIGNED_SHORT_5_6_5||e===s.UNSIGNED_SHORT||e===s.HALF_FLOAT)&&(n=2),(e===s.UNSIGNED_INT||e===s.FLOAT)&&(n=4),t===s.RGBA)return n*4;if(t===s.RGB)return n*3;if(t===s.ALPHA)return n}}class EA{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class wA{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){const s=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const sl={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query"};class MA{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:s,mode:n,object:r,type:i,info:a,index:u}=this;u!==0?s.drawElements(n,t,i,e):s.drawArrays(n,e,t),a.update(r,t,n,1)}renderInstances(e,t,s){const{gl:n,mode:r,type:i,index:a,object:u,info:c}=this;s!==0&&(a!==0?n.drawElementsInstanced(r,t,i,e,s):n.drawArraysInstanced(r,e,t,s),c.update(u,t,r,s))}renderMultiDraw(e,t,s){const{extensions:n,mode:r,object:i,info:a}=this;if(s===0)return;const u=n.get("WEBGL_multi_draw");if(u===null)for(let c=0;c0)){const s=t.queryQueue.shift();this.initTimestampQuery(s)}}async resolveTimestampAsync(e,t="render"){if(!this.disjoint||!this.trackTimestamp)return;const s=this.get(e);s.gpuQueries||(s.gpuQueries=[]);for(let n=0;n0&&(s.currentOcclusionQueries=s.occlusionQueries,s.currentOcclusionQueryObjects=s.occlusionQueryObjects,s.lastOcclusionObject=null,s.occlusionQueries=new Array(n),s.occlusionQueryObjects=new Array(n),s.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:s}=this,n=this.get(e),r=n.previousContext,i=e.occlusionQueryCount;i>0&&(i>n.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(a!==null)for(let u=0;u0){const l=u.framebuffers[e.getCacheKey()],d=t.COLOR_BUFFER_BIT,h=u.msaaFrameBuffer,p=e.textures;s.bindFramebuffer(t.READ_FRAMEBUFFER,h),s.bindFramebuffer(t.DRAW_FRAMEBUFFER,l);for(let f=0;f{let u=0;for(let c=0;c0&&r.add(n[c]),s[c]=null,i.deleteQuery(l),u++)}u1?N.renderInstances(B,v,w):N.render(B,v),u.bindVertexArray(null)}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,s,n,r,i){return this.textureUtils.copyTextureToBuffer(e,t,s,n,r,i)}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new bA(e,t)}createProgram(e){const t=this.gl,{stage:s,code:n}=e,r=s==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(r,n),t.compileShader(r),this.set(e,{shaderGPU:r})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){const s=this.gl,n=e.pipeline,{fragmentProgram:r,vertexProgram:i}=n,a=s.createProgram(),u=this.get(r).shaderGPU,c=this.get(i).shaderGPU;if(s.attachShader(a,u),s.attachShader(a,c),s.linkProgram(a),this.set(n,{programGPU:a,fragmentShader:u,vertexShader:c}),t!==null&&this.parallel){const l=new Promise(d=>{const h=this.parallel,p=()=>{s.getProgramParameter(a,h.COMPLETION_STATUS_KHR)?(this._completeCompile(e,n),d()):requestAnimationFrame(p)};p()});t.push(l);return}this._completeCompile(e,n)}_handleSource(e,t){const s=e.split(` -`),n=[],r=Math.max(t-6,0),i=Math.min(t+6,s.length);for(let a=r;a":" "} ${u}: ${s[a]}`)}return n.join(` -`)}_getShaderErrors(e,t,s){const n=e.getShaderParameter(t,e.COMPILE_STATUS),r=e.getShaderInfoLog(t).trim();if(n&&r==="")return"";const i=/ERROR: 0:(\d+)/.exec(r);if(i){const a=parseInt(i[1]);return s.toUpperCase()+` - -`+r+` - -`+this._handleSource(e.getShaderSource(t),a)}else return r}_logProgramError(e,t,s){if(this.renderer.debug.checkShaderErrors){const n=this.gl,r=n.getProgramInfoLog(e).trim();if(n.getProgramParameter(e,n.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(n,e,s,t);else{const i=this._getShaderErrors(n,s,"vertex"),a=this._getShaderErrors(n,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(e,n.VALIDATE_STATUS)+` - -Program Info Log: `+r+` -`+i+` -`+a)}else r!==""&&console.warn("THREE.WebGLProgram: Program Info Log:",r)}}_completeCompile(e,t){const{state:s,gl:n}=this,r=this.get(t),{programGPU:i,fragmentShader:a,vertexShader:u}=r;n.getProgramParameter(i,n.LINK_STATUS)===!1&&this._logProgramError(i,a,u),s.useProgram(i);const c=e.getBindings();this._setupBindings(c,i),this.set(t,{programGPU:i})}createComputePipeline(e,t){const{state:s,gl:n}=this,r={stage:"fragment",code:`#version 300 es -precision highp float; -void main() {}`};this.createProgram(r);const{computeProgram:i}=e,a=n.createProgram(),u=this.get(r).shaderGPU,c=this.get(i).shaderGPU,l=i.transforms,d=[],h=[];for(let x=0;xsl[n]===e),s=this.extensions;for(let n=0;n0){if(p===void 0){const N=[];p=t.createFramebuffer(),s.bindFramebuffer(t.FRAMEBUFFER,p);const v=[],w=e.textures;for(let B=0;B, - @location( 0 ) vTex : vec2 -}; - -@vertex -fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct { - - var Varys : VarysStruct; - - var pos = array< vec2, 4 >( - vec2( -1.0, 1.0 ), - vec2( 1.0, 1.0 ), - vec2( -1.0, -1.0 ), - vec2( 1.0, -1.0 ) - ); - - var tex = array< vec2, 4 >( - vec2( 0.0, 0.0 ), - vec2( 1.0, 0.0 ), - vec2( 0.0, 1.0 ), - vec2( 1.0, 1.0 ) - ); - - Varys.vTex = tex[ vertexIndex ]; - Varys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 ); - - return Varys; - -} -`,s=` -@group( 0 ) @binding( 0 ) -var imgSampler : sampler; - -@group( 0 ) @binding( 1 ) -var img : texture_2d; - -@fragment -fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { - - return textureSample( img, imgSampler, vTex ); - -} -`,n=` -@group( 0 ) @binding( 0 ) -var imgSampler : sampler; - -@group( 0 ) @binding( 1 ) -var img : texture_2d; - -@fragment -fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { - - return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) ); - -} -`;this.mipmapSampler=e.createSampler({minFilter:ps.Linear}),this.flipYSampler=e.createSampler({minFilter:ps.Nearest}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:t}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:s}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:n})}getTransferPipeline(e){let t=this.transferPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:Ks.TriangleStrip,stripIndexFormat:cn.Uint32},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:Ks.TriangleStrip,stripIndexFormat:cn.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,s=0){const n=t.format,{width:r,height:i}=t.size,a=this.getTransferPipeline(n),u=this.getFlipYPipeline(n),c=this.device.createTexture({size:{width:r,height:i,depthOrArrayLayers:1},format:n,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),l=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:$e.TwoD,baseArrayLayer:s}),d=c.createView({baseMipLevel:0,mipLevelCount:1,dimension:$e.TwoD,baseArrayLayer:0}),h=this.device.createCommandEncoder({}),p=(f,m,x)=>{const N=f.getBindGroupLayout(0),v=this.device.createBindGroup({layout:N,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:m}]}),w=h.beginRenderPass({colorAttachments:[{view:x,loadOp:ye.Clear,storeOp:De.Store,clearValue:[0,0,0,0]}]});w.setPipeline(f),w.setBindGroup(0,v),w.draw(4,1,0,0),w.end()};p(a,l,d),p(u,d,l),this.device.queue.submit([h.finish()]),c.destroy()}generateMipmaps(e,t,s=0){const n=this.get(e);n.useCount===void 0&&(n.useCount=0,n.layers=[]);const r=n.layers[s]||this._mipmapCreateBundles(e,t,s),i=this.device.createCommandEncoder({});this._mipmapRunBundles(i,r),this.device.queue.submit([i.finish()]),n.useCount!==0&&(n.layers[s]=r),n.useCount++}_mipmapCreateBundles(e,t,s){const n=this.getTransferPipeline(t.format),r=n.getBindGroupLayout(0);let i=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:$e.TwoD,baseArrayLayer:s});const a=[];for(let u=1;u1;for(let a=0;a]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,zA=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,ol={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},WA=o=>{o=o.trim();const e=o.match(kA);if(e!==null&&e.length===4){const t=e[2],s=[];let n=null;for(;(n=zA.exec(t))!==null;)s.push({name:n[1],type:n[2]});const r=[];for(let l=0;l "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class HA extends pg{parseFunction(e){return new $A(e)}}const Vs=typeof self<"u"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},qA={[Ve.READ_ONLY]:"read",[Ve.WRITE_ONLY]:"write",[Ve.READ_WRITE]:"read_write"},al={[li]:"repeat",[ca]:"clamp",[ci]:"mirror"},Br={vertex:Vs?Vs.VERTEX:1,fragment:Vs?Vs.FRAGMENT:2,compute:Vs?Vs.COMPUTE:4},ul={instance:!0,swizzleAssign:!1,storageBuffer:!0},KA={"^^":"tsl_xor"},XA={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},cl={},it={tsl_xor:new Ne("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Ne("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Ne("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Ne("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Ne("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Ne("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Ne("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Ne("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Ne("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Ne("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Ne("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new Ne("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Ne(` -fn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f { - - let res = vec2f( iRes ); - - let uvScaled = coord * res; - let uvWrapping = ( ( uvScaled % res ) + res ) % res; - - // https://www.shadertoy.com/view/WtyXRy - - let uv = uvWrapping - 0.5; - let iuv = floor( uv ); - let f = fract( uv ); - - let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level ); - let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level ); - let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level ); - let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level ); - - return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); - -} -`)},vn={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};typeof navigator<"u"&&/Windows/g.test(navigator.userAgent)&&(it.pow_float=new Ne("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),it.pow_vec2=new Ne("fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }",[it.pow_float]),it.pow_vec3=new Ne("fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }",[it.pow_float]),it.pow_vec4=new Ne("fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }",[it.pow_float]),vn.pow_float="tsl_pow_float",vn.pow_vec2="tsl_pow_vec2",vn.pow_vec3="tsl_pow_vec3",vn.pow_vec4="tsl_pow_vec4");let Ng="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(Ng+=`diagnostic( off, derivative_uniformity ); -`);class YA extends dg{constructor(e,t){super(e,t,new HA),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==Dn}_generateTextureSample(e,t,s,n,r=this.shaderStage){return r==="fragment"?n?`textureSample( ${t}, ${t}_sampler, ${s}, ${n} )`:`textureSample( ${t}, ${t}_sampler, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,s):this.generateTextureLod(e,t,s,n,"0")}_generateVideoSample(e,t,s=this.shaderStage){if(s==="fragment")return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${s} shader.`)}_generateTextureSampleLevel(e,t,s,n,r,i=this.shaderStage){return(i==="fragment"||i==="compute")&&this.isUnfilterable(e)===!1?`textureSampleLevel( ${t}, ${t}_sampler, ${s}, ${n} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,s,n):this.generateTextureLod(e,t,s,r,n)}generateWrapFunction(e){const t=`tsl_coord_${al[e.wrapS]}S_${al[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let s=cl[t];if(s===void 0){const n=[],r=e.isData3DTexture?"vec3f":"vec2f";let i=`fn ${t}( coord : ${r} ) -> ${r} { - - return ${r}( -`;const a=(u,c)=>{u===li?(n.push(it.repeatWrapping_float),i+=` tsl_repeatWrapping_float( coord.${c} )`):u===ca?(n.push(it.clampWrapping_float),i+=` tsl_clampWrapping_float( coord.${c} )`):u===ci?(n.push(it.mirrorWrapping_float),i+=` tsl_mirrorWrapping_float( coord.${c} )`):(i+=` coord.${c}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${u}" for vertex shader.`))};a(e.wrapS,"x"),i+=`, -`,a(e.wrapT,"y"),e.isData3DTexture&&(i+=`, -`,a(e.wrapR,"z")),i+=` - ); - -} -`,cl[t]=s=new Ne(i,n)}return s.build(this),t}generateTextureDimension(e,t,s){const n=this.getDataFromNode(e,this.shaderStage,this.globalCache);n.dimensionsSnippet===void 0&&(n.dimensionsSnippet={});let r=n.dimensionsSnippet[s];if(n.dimensionsSnippet[s]===void 0){let i,a;const{primarySamples:u}=this.renderer.backend.utils.getTextureSampleData(e),c=u>1;e.isData3DTexture?a="vec3":a="vec2",c||e.isVideoTexture||e.isStorageTexture?i=t:i=`${t}${s?`, u32( ${s} )`:""}`,r=new Ir(new Vr(`textureDimensions( ${i} )`,a)),n.dimensionsSnippet[s]=r,(e.isDataArrayTexture||e.isData3DTexture)&&(n.arrayLayerCount=new Ir(new Vr(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(n.cubeFaceCount=new Ir(new Vr("6u","u32")))}return r.build(this)}generateFilteredTexture(e,t,s,n="0u"){this._include("biquadraticTexture");const r=this.generateWrapFunction(e),i=this.generateTextureDimension(e,t,n);return`tsl_biquadraticTexture( ${t}, ${r}( ${s} ), ${i}, u32( ${n} ) )`}generateTextureLod(e,t,s,n,r="0u"){const i=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,r),u=e.isData3DTexture?"vec3":"vec2",c=`${u}(${i}(${s}) * ${u}(${a}))`;return this.generateTextureLoad(e,t,c,n,r)}generateTextureLoad(e,t,s,n,r="0u"){return e.isVideoTexture===!0||e.isStorageTexture===!0?`textureLoad( ${t}, ${s} )`:n?`textureLoad( ${t}, ${s}, ${n}, u32( ${r} ) )`:`textureLoad( ${t}, ${s}, u32( ${r} ) )`}generateTextureStore(e,t,s,n){return`textureStore( ${t}, ${s}, ${n} )`}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===ot||this.isSampleCompare(e)===!1&&e.minFilter===bt&&e.magFilter===bt||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,s,n,r=this.shaderStage){let i=null;return e.isVideoTexture===!0?i=this._generateVideoSample(t,s,r):this.isUnfilterable(e)?i=this.generateTextureLod(e,t,s,n,"0",r):i=this._generateTextureSample(e,t,s,n,r),i}generateTextureGrad(e,t,s,n,r,i=this.shaderStage){if(i==="fragment")return`textureSampleGrad( ${t}, ${t}_sampler, ${s}, ${n[0]}, ${n[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${i} shader.`)}generateTextureCompare(e,t,s,n,r,i=this.shaderStage){if(i==="fragment")return`textureSampleCompare( ${t}, ${t}_sampler, ${s}, ${n} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${i} shader.`)}generateTextureLevel(e,t,s,n,r,i=this.shaderStage){let a=null;return e.isVideoTexture===!0?a=this._generateVideoSample(t,s,i):a=this._generateTextureSampleLevel(e,t,s,n,r,i),a}generateTextureBias(e,t,s,n,r,i=this.shaderStage){if(i==="fragment")return`textureSampleBias( ${t}, ${t}_sampler, ${s}, ${n} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${i} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){const s=e.name,n=e.type;return n==="texture"||n==="cubeTexture"||n==="storageTexture"||n==="texture3D"?s:n==="buffer"||n==="storageBuffer"||n==="indirectStorageBuffer"?`NodeBuffer_${e.id}.${s}`:e.groupNode.name+"."+s}return super.getPropertyName(e)}getOutputStructName(){return"output"}_getUniformGroupCount(e){return Object.keys(this.uniforms[e]).length}getFunctionOperator(e){const t=KA[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?Ve.READ_ONLY:e.access}getStorageAccess(e,t){return qA[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,s,n=null){const r=super.getUniformFromNode(e,t,s,n),i=this.getDataFromNode(e,s,this.globalCache);if(i.uniformGPU===void 0){let a;const u=e.groupNode,c=u.name,l=this.getBindGroupArray(c,s);if(t==="texture"||t==="cubeTexture"||t==="storageTexture"||t==="texture3D"){let d=null;const h=this.getNodeAccess(e,s);if(t==="texture"||t==="storageTexture"?d=new Di(r.name,r.node,u,h):t==="cubeTexture"?d=new Tg(r.name,r.node,u,h):t==="texture3D"&&(d=new _g(r.name,r.node,u,h)),d.store=e.isStorageTextureNode===!0,d.setVisibility(Br[s]),(s==="fragment"||s==="compute")&&this.isUnfilterable(e.value)===!1&&d.store===!1){const p=new UA(`${r.name}_sampler`,r.node,u);p.setVisibility(Br[s]),l.push(p,d),a=[p,d]}else l.push(d),a=[d]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const d=t==="buffer"?yg:LA,h=new d(e,u);h.setVisibility(Br[s]),l.push(h),a=h}else{const d=this.uniformGroups[s]||(this.uniformGroups[s]={});let h=d[c];h===void 0&&(h=new xg(c,u),h.setVisibility(Br[s]),d[c]=h,l.push(h)),a=this.getNodeUniform(r,t),h.addUniform(a)}i.uniformGPU=a}return r}getBuiltin(e,t,s,n=this.shaderStage){const r=this.builtins[n]||(this.builtins[n]=new Map);return r.has(e)===!1&&r.set(e,{name:e,property:t,type:s}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,s=this.flowShaderNode(e),n=[];for(const i of t.inputs)n.push(i.name+" : "+this.getType(i.type));let r=`fn ${t.name}( ${n.join(", ")} ) -> ${this.getType(t.type)} { -${s.vars} -${s.code} -`;return s.result&&(r+=` return ${s.result}; -`),r+=` -} -`,r}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],s=this.directives[e];if(s!==void 0)for(const n of s)t.push(`enable ${n};`);return t.join(` -`)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],s=this.builtins[e];if(s!==void 0)for(const{name:n,property:r,type:i}of s.values())t.push(`@builtin( ${n} ) ${r} : ${i}`);return t.join(`, - `)}getScopedArray(e,t,s,n){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:s,bufferCount:n}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:s,scope:n,bufferType:r,bufferCount:i}of this.scopedArrays.values()){const a=this.getType(r);t.push(`var<${n}> ${s}: array< ${a}, ${i} >;`)}return t.join(` -`)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","id","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){const s=this.getBuiltins("attribute");s&&t.push(s);const n=this.getAttributesArray();for(let r=0,i=n.length;r`)}const n=this.getBuiltins("output");return n&&t.push(" "+n),t.join(`, -`)}getStructs(e){const t=[],s=this.structs[e];for(let n=0,r=s.length;n output : ${a}; - -`)}return t.join(` - -`)}getVar(e,t){return`var ${t} : ${this.getType(e)}`}getVars(e){const t=[],s=this.vars[e];if(s!==void 0)for(const n of s)t.push(` ${this.getVar(n.type,n.name)};`);return` -${t.join(` -`)} -`}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","Vertex","vec4","vertex"),e==="vertex"||e==="fragment"){const r=this.varyings,i=this.vars[e];for(let a=0;a1&&(p="_multisampled"),d.isCubeTexture===!0)h="texture_cube";else if(d.isDataArrayTexture===!0||d.isCompressedArrayTexture===!0)h="texture_2d_array";else if(d.isDepthTexture===!0)h=`texture_depth${p}_2d`;else if(d.isVideoTexture===!0)h="texture_external";else if(d.isData3DTexture===!0)h="texture_3d";else if(u.node.isStorageTextureNode===!0){const m=ia(d),x=this.getStorageAccess(u.node,e);h=`texture_storage_2d<${m}, ${x}>`}else{const m=this.getComponentTypeFromTexture(d).charAt(0);h=`texture${p}_2d<${m}32>`}s.push(`@binding( ${l.binding++} ) @group( ${l.group} ) var ${u.name} : ${h};`)}else if(u.type==="buffer"||u.type==="storageBuffer"||u.type==="indirectStorageBuffer"){const d=u.node,h=this.getType(d.bufferType),p=d.bufferCount,f=p>0&&u.type==="buffer"?", "+p:"",m=d.isAtomic?`atomic<${h}>`:`${h}`,x=` ${u.name} : array< ${m}${f} > -`,N=d.isStorageBufferNode?`storage, ${this.getStorageAccess(d,e)}`:"uniform";n.push(this._getWGSLStructBinding("NodeBuffer_"+d.id,x,N,l.binding++,l.group))}else{const d=this.getType(this.getVectorType(u.type)),h=u.groupNode.name;(i[h]||(i[h]={index:l.binding++,id:l.group,snippets:[]})).snippets.push(` ${u.name} : ${d}`)}}for(const u in i){const c=i[u];r.push(this._getWGSLStructBinding(u,c.snippets.join(`, -`),"uniform",c.index,c.id))}let a=s.join(` -`);return a+=n.join(` -`),a+=r.join(` -`),a}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){const s=e[t];s.uniforms=this.getUniforms(t),s.attributes=this.getAttributes(t),s.varyings=this.getVaryings(t),s.structs=this.getStructs(t),s.vars=this.getVars(t),s.codes=this.getCodes(t),s.directives=this.getDirectives(t),s.scopedArrays=this.getScopedArrays(t);let n=`// code - -`;n+=this.flowCode[t];const r=this.flowNodes[t],i=r[r.length-1],a=i.outputNode,u=a!==void 0&&a.isOutputStructNode===!0;for(const c of r){const l=this.getFlowData(c),d=c.name;if(d&&(n.length>0&&(n+=` -`),n+=` // flow -> ${d} - `),n+=`${l.code} - `,c===i&&t!=="compute"){if(n+=`// result - - `,t==="vertex")n+=`varyings.Vertex = ${l.result};`;else if(t==="fragment")if(u)s.returnType=a.nodeType,n+=`return ${l.result};`;else{let h=" @location(0) color: vec4";const p=this.getBuiltins("output");p&&(h+=`, - `+p),s.returnType="OutputStruct",s.structs+=this._getWGSLStruct("OutputStruct",h),s.structs+=` -var output : OutputStruct; - -`,n+=`output.color = ${l.result}; - - return output;`}}}s.flow=n}this.material!==null?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let s;return t!==null&&(s=this._getWGSLMethod(e+"_"+t)),s===void 0&&(s=this._getWGSLMethod(e)),s||e}getType(e){return XA[e]||e}isAvailable(e){let t=ul[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),ul[e]=t),t}_getWGSLMethod(e){return it[e]!==void 0&&this._include(e),vn[e]}_include(e){const t=it[e];return t.build(this),this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()} -// directives -${e.directives} - -// uniforms -${e.uniforms} - -// varyings -${e.varyings} -var varyings : VaryingsStruct; - -// codes -${e.codes} - -@vertex -fn main( ${e.attributes} ) -> VaryingsStruct { - - // vars - ${e.vars} - - // flow - ${e.flow} - - return varyings; - -} -`}_getWGSLFragmentCode(e){return`${this.getSignature()} -// global -${Ng} - -// uniforms -${e.uniforms} - -// structs -${e.structs} - -// codes -${e.codes} - -@fragment -fn main( ${e.varyings} ) -> ${e.returnType} { - - // vars - ${e.vars} - - // flow - ${e.flow} - -} -`}_getWGSLComputeCode(e,t){return`${this.getSignature()} -// directives -${e.directives} - -// system -var instanceIndex : u32; - -// locals -${e.scopedArrays} - -// uniforms -${e.uniforms} - -// codes -${e.codes} - -@compute @workgroup_size( ${t} ) -fn main( ${e.attributes} ) { - - // system - instanceIndex = id.x + id.y * numWorkgroups.x * u32(${t}) + id.z * numWorkgroups.x * numWorkgroups.y * u32(${t}); - - // vars - ${e.vars} - - // flow - ${e.flow} - -} -`}_getWGSLStruct(e,t){return` -struct ${e} { -${t} -};`}_getWGSLStructBinding(e,t,s,n=0,r=0){const i=e+"Struct";return`${this._getWGSLStruct(i,t)} -@binding( ${n} ) @group( ${r} ) -var<${s}> ${e} : ${i};`}}class jA{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=_.Depth24PlusStencil8:e.depth&&(t=_.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const r=this.backend.renderer,i=r.getRenderTarget();t=i?i.samples:r.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const s=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:s?1:t,isMSAA:s}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return Ks.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return Ks.LineList;if(e.isLine)return Ks.LineStrip;if(e.isMesh)return Ks.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){return navigator.userAgent.includes("Quest")?_.BGRA8Unorm:navigator.gpu.getPreferredCanvasFormat()}}const QA=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),ZA=new Map([[yl,["float16"]]]),JA=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class eR{constructor(e){this.backend=e}createAttribute(e,t){const s=this._getBufferAttribute(e),n=this.backend,r=n.get(s);let i=r.buffer;if(i===void 0){const a=n.device;let u=s.array;if(e.normalized===!1&&(u.constructor===Int16Array||u.constructor===Uint16Array)){const l=new Uint32Array(u.length);for(let d=0;d1&&(u.multisampled=!0,i.texture.isDepthTexture||(u.sampleType=Is.UnfilterableFloat)),i.texture.isDepthTexture)u.sampleType=Is.Depth;else if(i.texture.isDataTexture||i.texture.isDataArrayTexture||i.texture.isData3DTexture){const l=i.texture.type;l===ze?u.sampleType=Is.SInt:l===Le?u.sampleType=Is.UInt:l===ot&&(this.backend.hasFeature("float32-filterable")?u.sampleType=Is.Float:u.sampleType=Is.UnfilterableFloat)}i.isSampledCubeTexture?u.viewDimension=$e.Cube:i.texture.isDataArrayTexture||i.texture.isCompressedArrayTexture?u.viewDimension=$e.TwoDArray:i.isSampledTexture3D&&(u.viewDimension=$e.ThreeD),a.texture=u}else console.error(`WebGPUBindingUtils: Unsupported binding "${i}".`);n.push(a)}return s.createBindGroupLayout({entries:n})}createBindings(e,t,s,n=0){const{backend:r,bindGroupLayoutCache:i}=this,a=r.get(e);let u=i.get(e.bindingsReference);u===void 0&&(u=this.createBindingsLayout(e),i.set(e.bindingsReference,u));let c;s>0&&(a.groups===void 0&&(a.groups=[],a.versions=[]),a.versions[s]===n&&(c=a.groups[s])),c===void 0&&(c=this.createBindGroup(e,u),s>0&&(a.groups[s]=c,a.versions[s]=n)),a.group=c,a.layout=u}updateBinding(e){const t=this.backend,s=t.device,n=e.buffer,r=t.get(e).buffer;s.queue.writeBuffer(r,0,n,0)}createBindGroup(e,t){const s=this.backend,n=s.device;let r=0;const i=[];for(const a of e.bindings){if(a.isUniformBuffer){const u=s.get(a);if(u.buffer===void 0){const c=a.byteLength,l=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,d=n.createBuffer({label:"bindingBuffer_"+a.name,size:c,usage:l});u.buffer=d}i.push({binding:r,resource:{buffer:u.buffer}})}else if(a.isStorageBuffer){const u=s.get(a);if(u.buffer===void 0){const c=a.attribute;u.buffer=s.get(c).buffer}i.push({binding:r,resource:{buffer:u.buffer}})}else if(a.isSampler){const u=s.get(a.texture);i.push({binding:r,resource:u.sampler})}else if(a.isSampledTexture){const u=s.get(a.texture);let c;if(u.externalTexture!==void 0)c=n.importExternalTexture({source:u.externalTexture});else{const l=a.store?1:u.texture.mipLevelCount,d=`view-${u.texture.width}-${u.texture.height}-${l}`;if(c=u[d],c===void 0){const h=BA.All;let p;a.isSampledCubeTexture?p=$e.Cube:a.isSampledTexture3D?p=$e.ThreeD:a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?p=$e.TwoDArray:p=$e.TwoD,c=u[d]=u.texture.createView({aspect:h,dimension:p,mipLevelCount:l})}}i.push({binding:r,resource:c})}r++}return n.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:i})}}class sR{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:s,material:n,geometry:r,pipeline:i}=e,{vertexProgram:a,fragmentProgram:u}=i,c=this.backend,l=c.device,d=c.utils,h=c.get(i),p=[];for(const Ze of e.getBindings()){const Dt=c.get(Ze);p.push(Dt.layout)}const f=c.attributeUtils.createShaderVertexBuffers(e);let m;n.transparent===!0&&n.blending!==en&&(m=this._getBlending(n));let x={};n.stencilWrite===!0&&(x={compare:this._getStencilCompare(n),failOp:this._getStencilOperation(n.stencilFail),depthFailOp:this._getStencilOperation(n.stencilZFail),passOp:this._getStencilOperation(n.stencilZPass)});const N=this._getColorWriteMask(n),v=[];if(e.context.textures!==null){const Ze=e.context.textures;for(let Dt=0;Dt1},layout:l.createPipelineLayout({bindGroupLayouts:p})},ie={},Z=e.context.depth,Qe=e.context.stencil;if((Z===!0||Qe===!0)&&(Z===!0&&(ie.format=I,ie.depthWriteEnabled=n.depthWrite,ie.depthCompare=L),Qe===!0&&(ie.stencilFront=x,ie.stencilBack={},ie.stencilReadMask=n.stencilFuncMask,ie.stencilWriteMask=n.stencilWriteMask),X.depthStencil=ie),t===null)h.pipeline=l.createRenderPipeline(X);else{const Ze=new Promise(Dt=>{l.createRenderPipelineAsync(X).then(Ms=>{h.pipeline=Ms,Dt()})});t.push(Ze)}}createBundleEncoder(e){const t=this.backend,{utils:s,device:n}=t,r=s.getCurrentDepthStencilFormat(e),i=s.getCurrentColorFormat(e),a=this._getSampleCount(e),u={label:"renderBundleEncoder",colorFormats:[i],depthStencilFormat:r,sampleCount:a};return n.createRenderBundleEncoder(u)}createComputePipeline(e,t){const s=this.backend,n=s.device,r=s.get(e.computeProgram).module,i=s.get(e),a=[];for(const u of t){const c=s.get(u);a.push(c.layout)}i.pipeline=n.createComputePipeline({compute:r,layout:n.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(e){let t,s;const n=e.blending,r=e.blendSrc,i=e.blendDst,a=e.blendEquation;if(n===Hl){const u=e.blendSrcAlpha!==null?e.blendSrcAlpha:r,c=e.blendDstAlpha!==null?e.blendDstAlpha:i,l=e.blendEquationAlpha!==null?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(i),operation:this._getBlendOperation(a)},s={srcFactor:this._getBlendFactor(u),dstFactor:this._getBlendFactor(c),operation:this._getBlendOperation(l)}}else{const u=e.premultipliedAlpha,c=(l,d,h,p)=>{t={srcFactor:l,dstFactor:d,operation:ls.Add},s={srcFactor:h,dstFactor:p,operation:ls.Add}};if(u)switch(n){case Ys:c(H.One,H.OneMinusSrcAlpha,H.One,H.OneMinusSrcAlpha);break;case qr:c(H.One,H.One,H.One,H.One);break;case Hr:c(H.Zero,H.OneMinusSrc,H.Zero,H.One);break;case $r:c(H.Zero,H.Src,H.Zero,H.SrcAlpha);break}else switch(n){case Ys:c(H.SrcAlpha,H.OneMinusSrcAlpha,H.One,H.OneMinusSrcAlpha);break;case qr:c(H.SrcAlpha,H.One,H.SrcAlpha,H.One);break;case Hr:c(H.Zero,H.OneMinusSrc,H.Zero,H.One);break;case $r:c(H.Zero,H.Src,H.Zero,H.Src);break}}if(t!==void 0&&s!==void 0)return{color:t,alpha:s};console.error("THREE.WebGPURenderer: Invalid blending: ",n)}_getBlendFactor(e){let t;switch(e){case $l:t=H.Zero;break;case Wl:t=H.One;break;case zl:t=H.Src;break;case Il:t=H.OneMinusSrc;break;case kl:t=H.SrcAlpha;break;case Ll:t=H.OneMinusSrcAlpha;break;case Gl:t=H.Dst;break;case Dl:t=H.OneMinusDstColor;break;case Vl:t=H.DstAlpha;break;case Pl:t=H.OneMinusDstAlpha;break;case Ol:t=H.SrcAlphaSaturated;break;case __:t=H.Constant;break;case b_:t=H.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const s=e.stencilFunc;switch(s){case Im:t=Fe.Never;break;case Lm:t=Fe.Always;break;case Dm:t=Fe.Less;break;case Pm:t=Fe.LessEqual;break;case Um:t=Fe.Equal;break;case Fm:t=Fe.GreaterEqual;break;case Bm:t=Fe.Greater;break;case Mm:t=Fe.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",s)}return t}_getStencilOperation(e){let t;switch(e){case Hm:t=Qt.Keep;break;case $m:t=Qt.Zero;break;case Wm:t=Qt.Replace;break;case zm:t=Qt.Invert;break;case km:t=Qt.IncrementClamp;break;case Om:t=Qt.DecrementClamp;break;case Gm:t=Qt.IncrementWrap;break;case Vm:t=Qt.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Gs:t=ls.Add;break;case Ul:t=ls.Subtract;break;case Fl:t=ls.ReverseSubtract;break;case Km:t=ls.Min;break;case qm:t=ls.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,s){const n={},r=this.backend.utils;switch(n.topology=r.getPrimitiveTopology(e,s),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(n.stripIndexFormat=t.index.array instanceof Uint16Array?cn.Uint16:cn.Uint32),s.side){case No:n.frontFace=go.CCW,n.cullMode=mo.Back;break;case Ct:n.frontFace=go.CCW,n.cullMode=mo.Front;break;case js:n.frontFace=go.CCW,n.cullMode=mo.None;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",s.side);break}return n}_getColorWriteMask(e){return e.colorWrite===!0?rl.All:rl.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Fe.Always;else{const s=e.depthFunc;switch(s){case Jl:t=Fe.Never;break;case Zl:t=Fe.Always;break;case Ql:t=Fe.Less;break;case jl:t=Fe.LessEqual;break;case Yl:t=Fe.Equal;break;case Xl:t=Fe.GreaterEqual;break;case Kl:t=Fe.Greater;break;case ql:t=Fe.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",s)}}return t}}class nR extends bg{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.trackTimestamp=e.trackTimestamp===!0,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new jA(this),this.attributeUtils=new eR(this),this.bindingUtils=new tR(this),this.pipelineUtils=new sR(this),this.textureUtils=new OA(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let s;if(t.device===void 0){const i={powerPreference:t.powerPreference},a=typeof navigator<"u"?await navigator.gpu.requestAdapter(i):null;if(a===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const u=Object.values(ra),c=[];for(const d of u)a.features.has(d)&&c.push(d);const l={requiredFeatures:c,requiredLimits:t.requiredLimits};s=await a.requestDevice(l)}else s=t.device;s.lost.then(i=>{const a={api:"WebGPU",message:i.message||"Unknown reason",reason:i.reason||null,originalEvent:i};e.onDeviceLost(a)});const n=t.context!==void 0?t.context:e.domElement.getContext("webgpu");this.device=s,this.context=n;const r=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(ra.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:r}),this.updateSize()}get coordinateSystem(){return ln}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){const s=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(s.depth,s.stencil).createView()});const n=e.colorAttachments[0];this.renderer.samples>0?n.view=this.colorBuffer.createView():n.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_getRenderPassDescriptor(e,t={}){const s=e.renderTarget,n=this.get(s);let r=n.descriptors;if(r===void 0||n.width!==s.width||n.height!==s.height||n.dimensions!==s.dimensions||n.activeMipmapLevel!==s.activeMipmapLevel||n.activeCubeFace!==e.activeCubeFace||n.samples!==s.samples||n.loadOp!==t.loadOp){r={},n.descriptors=r;const u=()=>{s.removeEventListener("dispose",u),this.delete(s)};s.addEventListener("dispose",u)}const i=e.getCacheKey();let a=r[i];if(a===void 0){const u=e.textures,c=[];let l;for(let d=0;d0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,r=s.createQuerySet({type:"occlusion",count:n,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=r,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(n),t.lastOcclusionObject=null);let i;e.textures===null?i=this._getDefaultRenderPassDescriptor():i=this._getRenderPassDescriptor(e,{loadOp:ye.Load}),this.initTimestampQuery(e,i),i.occlusionQuerySet=r;const a=i.depthStencilAttachment;if(e.textures!==null){const l=i.colorAttachments;for(let d=0;d0&&t.currentPass.executeBundles(t.renderBundles),s>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery(),t.currentPass.end(),s>0){const n=s*8;let r=this.occludedResolveCache.get(n);r===void 0&&(r=this.device.createBuffer({size:n,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(n,r));const i=this.device.createBuffer({size:n,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,s,r,0),t.encoder.copyBufferToBuffer(r,0,i,0,n),t.occlusionQueryBuffer=i,this.resolveOccludedAsync(e)}if(this.prepareTimestampBuffer(e,t.encoder),this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const n=e.textures;for(let r=0;ra?(c.x=Math.min(t.dispatchCount,a),c.y=Math.ceil(t.dispatchCount/a)):c.x=t.dispatchCount,r.dispatchWorkgroups(c.x,c.y,c.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.prepareTimestampBuffer(e,t.cmdEncoderGPU),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:s,context:n,pipeline:r}=e,i=e.getBindings(),a=this.get(n),u=this.get(r).pipeline,c=a.currentSets,l=a.currentPass,d=e.getDrawParameters();if(d===null)return;c.pipeline!==u&&(l.setPipeline(u),c.pipeline=u);const h=c.bindingGroups;for(let x=0,N=i.length;x1?0:B;f===!0?l.drawIndexed(N[B],F,x[B]/p.array.BYTES_PER_ELEMENT,0,L):l.draw(N[B],F,x[B],L)}}else if(f===!0){const{vertexCount:x,instanceCount:N,firstVertex:v}=d,w=e.getIndirect();if(w!==null){const B=this.get(w).buffer;l.drawIndexedIndirect(B,0)}else l.drawIndexed(x,N,v,0,0);t.update(s,x,N)}else{const{vertexCount:x,instanceCount:N,firstVertex:v}=d,w=e.getIndirect();if(w!==null){const B=this.get(w).buffer;l.drawIndirect(B,0)}else l.draw(x,N,v,0);t.update(s,x,N)}}needsRenderUpdate(e){const t=this.get(e),{object:s,material:n}=e,r=this.utils,i=r.getSampleCountRenderContext(e.context),a=r.getCurrentColorSpace(e.context),u=r.getCurrentColorFormat(e.context),c=r.getCurrentDepthStencilFormat(e.context),l=r.getPrimitiveTopology(s,n);let d=!1;return(t.material!==n||t.materialVersion!==n.version||t.transparent!==n.transparent||t.blending!==n.blending||t.premultipliedAlpha!==n.premultipliedAlpha||t.blendSrc!==n.blendSrc||t.blendDst!==n.blendDst||t.blendEquation!==n.blendEquation||t.blendSrcAlpha!==n.blendSrcAlpha||t.blendDstAlpha!==n.blendDstAlpha||t.blendEquationAlpha!==n.blendEquationAlpha||t.colorWrite!==n.colorWrite||t.depthWrite!==n.depthWrite||t.depthTest!==n.depthTest||t.depthFunc!==n.depthFunc||t.stencilWrite!==n.stencilWrite||t.stencilFunc!==n.stencilFunc||t.stencilFail!==n.stencilFail||t.stencilZFail!==n.stencilZFail||t.stencilZPass!==n.stencilZPass||t.stencilFuncMask!==n.stencilFuncMask||t.stencilWriteMask!==n.stencilWriteMask||t.side!==n.side||t.alphaToCoverage!==n.alphaToCoverage||t.sampleCount!==i||t.colorSpace!==a||t.colorFormat!==u||t.depthStencilFormat!==c||t.primitiveTopology!==l||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=n,t.materialVersion=n.version,t.transparent=n.transparent,t.blending=n.blending,t.premultipliedAlpha=n.premultipliedAlpha,t.blendSrc=n.blendSrc,t.blendDst=n.blendDst,t.blendEquation=n.blendEquation,t.blendSrcAlpha=n.blendSrcAlpha,t.blendDstAlpha=n.blendDstAlpha,t.blendEquationAlpha=n.blendEquationAlpha,t.colorWrite=n.colorWrite,t.depthWrite=n.depthWrite,t.depthTest=n.depthTest,t.depthFunc=n.depthFunc,t.stencilWrite=n.stencilWrite,t.stencilFunc=n.stencilFunc,t.stencilFail=n.stencilFail,t.stencilZFail=n.stencilZFail,t.stencilZPass=n.stencilZPass,t.stencilFuncMask=n.stencilFuncMask,t.stencilWriteMask=n.stencilWriteMask,t.side=n.side,t.alphaToCoverage=n.alphaToCoverage,t.sampleCount=i,t.colorSpace=a,t.colorFormat=u,t.depthStencilFormat=c,t.primitiveTopology=l,t.clippingContextCacheKey=e.clippingContextCacheKey,d=!0),d}getRenderCacheKey(e){const{object:t,material:s}=e,n=this.utils,r=e.context;return[s.transparent,s.blending,s.premultipliedAlpha,s.blendSrc,s.blendDst,s.blendEquation,s.blendSrcAlpha,s.blendDstAlpha,s.blendEquationAlpha,s.colorWrite,s.depthWrite,s.depthTest,s.depthFunc,s.stencilWrite,s.stencilFunc,s.stencilFail,s.stencilZFail,s.stencilZPass,s.stencilFuncMask,s.stencilWriteMask,s.side,n.getSampleCountRenderContext(r),n.getCurrentColorSpace(r),n.getCurrentColorFormat(r),n.getCurrentDepthStencilFormat(r),n.getPrimitiveTopology(t,s),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,s,n,r,i){return this.textureUtils.copyTextureToBuffer(e,t,s,n,r,i)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;const s=this.get(e);if(!s.timeStampQuerySet){const n=e.isComputeNode?"compute":"render",r=this.device.createQuerySet({type:"timestamp",count:2,label:`timestamp_${n}_${e.id}`});Object.assign(t,{timestampWrites:{querySet:r,beginningOfPassWriteIndex:0,endOfPassWriteIndex:1}}),s.timeStampQuerySet=r}}prepareTimestampBuffer(e,t){if(!this.trackTimestamp)return;const s=this.get(e),n=2*BigInt64Array.BYTES_PER_ELEMENT;s.currentTimestampQueryBuffers===void 0&&(s.currentTimestampQueryBuffers={resolveBuffer:this.device.createBuffer({label:"timestamp resolve buffer",size:n,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),resultBuffer:this.device.createBuffer({label:"timestamp result buffer",size:n,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})});const{resolveBuffer:r,resultBuffer:i}=s.currentTimestampQueryBuffers;t.resolveQuerySet(s.timeStampQuerySet,0,2,r,0),i.mapState==="unmapped"&&t.copyBufferToBuffer(r,0,i,0,n)}async resolveTimestampAsync(e,t="render"){if(!this.trackTimestamp)return;const s=this.get(e);if(s.currentTimestampQueryBuffers===void 0)return;const{resultBuffer:n}=s.currentTimestampQueryBuffers;n.mapState==="unmapped"&&n.mapAsync(GPUMapMode.READ).then(()=>{const r=new BigUint64Array(n.getMappedRange()),i=Number(r[1]-r[0])/1e6;this.renderer.info.updateTimestamp(t,i),n.unmap()})}createNodeBuilder(e,t){return new YA(e,t)}createProgram(e){const t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name!==""?`_${e.name}`:"")}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){const t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){const s=this.get(e),r=s.currentPass.finish();this.get(t).bundleGPU=r,s.currentSets=s._currentSets,s.currentPass=s._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,s,n){this.bindingUtils.createBindings(e,t,s,n)}updateBindings(e,t,s,n){this.bindingUtils.createBindings(e,t,s,n)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,s=null,n=null,r=0){let i=0,a=0,u=0,c=0,l=0,d=0,h=e.image.width,p=e.image.height;s!==null&&(c=s.x,l=s.y,d=s.z||0,h=s.width,p=s.height),n!==null&&(i=n.x,a=n.y,u=n.z||0);const f=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),m=this.get(e).texture,x=this.get(t).texture;f.copyTextureToTexture({texture:m,mipLevel:r,origin:{x:c,y:l,z:d}},{texture:x,mipLevel:r,origin:{x:i,y:a,z:u}},[h,p,1]),this.device.queue.submit([f.finish()])}copyFramebufferToTexture(e,t,s){const n=this.get(t);let r=null;t.renderTarget?e.isDepthTexture?r=this.get(t.depthTexture).texture:r=this.get(t.textures[0]).texture:e.isDepthTexture?r=this.textureUtils.getDepthBuffer(t.depth,t.stencil):r=this.context.getCurrentTexture();const i=this.get(e).texture;if(r.format!==i.format){console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",r.format,i.format);return}let a;if(n.currentPass?(n.currentPass.end(),a=n.encoder):a=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),a.copyTextureToTexture({texture:r,origin:[s.x,s.y,0]},{texture:i},[s.z,s.w]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e),n.currentPass){const{descriptor:u}=n;for(let c=0;c(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new nl(e)));const s=new t(e);super(s,e),this.library=new iR,this.isWebGPURenderer=!0}}class xR extends ll{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}}const Sg=new ce,Fr=new Mi(Sg);class TR{constructor(e,t=P(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0,Sg.name="PostProcessing"}render(){this._update();const e=this.renderer,t=e.toneMapping,s=e.outputColorSpace;e.toneMapping=ss,e.outputColorSpace=kt,Fr.render(e),e.toneMapping=t,e.outputColorSpace=s}_update(){if(this.needsUpdate===!0){const e=this.renderer,t=e.toneMapping,s=e.outputColorSpace;Fr.material.fragmentNode=this.outputColorTransform===!0?tu(this.outputNode,t,s):this.outputNode.context({toneMapping:t,outputColorSpace:s}),Fr.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){this._update();const e=this.renderer,t=e.toneMapping,s=e.outputColorSpace;e.toneMapping=ss,e.outputColorSpace=kt,await Fr.renderAsync(e),e.toneMapping=t,e.outputColorSpace=s}}class _R extends aa{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=ft,this.minFilter=ft,this.isStorageTexture=!0}}class bR extends xf{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class oR extends Lg{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,s,n){const r=new Ig(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,i=>{try{t(this.parse(JSON.parse(i)))}catch(a){n?n(a):console.error(a),this.manager.itemError(e)}},s,n)}parseNodes(e){const t={};if(e!==void 0){for(const n of e){const{uuid:r,type:i}=n;t[r]=this.createNodeFromType(i),t[r].uuid=r}const s={nodes:t,textures:this.textures};for(const n of e)n.meta=s,t[n.uuid].deserialize(n),delete n.meta}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const n={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=n,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return this.nodes[e]===void 0?(console.error("THREE.NodeLoader: Node type not found:",e),g()):E(new this.nodes[e])}}class aR extends Vg{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),s=this.nodes,n=e.inputNodes;for(const r in n){const i=n[r];t[r]=s[i]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return t!==void 0?new t:super.createMaterialFromType(e)}}class NR extends Gg{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const s=super.parse(e,t);return this._nodesJSON=null,s}parseNodes(e,t){if(e!==void 0){const s=new oR;return s.setNodes(this.nodes),s.setTextures(t),s.parseNodes(e)}return{}}parseMaterials(e,t){const s={};if(e!==void 0){const n=this.parseNodes(this._nodesJSON,t),r=new aR;r.setTextures(t),r.setNodes(n),r.setNodeMaterials(this.nodeMaterials);for(let i=0,a=e.length;i{const o=e?"?"+new URLSearchParams(e).toString():"";return t(`/memories${o}`)},get:e=>t(`/memories/${e}`),delete:e=>t(`/memories/${e}`,{method:"DELETE"}),promote:e=>t(`/memories/${e}/promote`,{method:"POST"}),demote:e=>t(`/memories/${e}/demote`,{method:"POST"}),suppress:(e,o)=>t(`/memories/${e}/suppress`,{method:"POST",body:o?JSON.stringify({reason:o}):void 0}),unsuppress:e=>t(`/memories/${e}/unsuppress`,{method:"POST"})},search:(e,o=20)=>t(`/search?q=${encodeURIComponent(e)}&limit=${o}`),stats:()=>t("/stats"),health:()=>t("/health"),timeline:(e=7,o=200)=>t(`/timeline?days=${e}&limit=${o}`),graph:e=>{const o=e?"?"+new URLSearchParams(Object.entries(e).filter(([,r])=>r!==void 0).map(([r,i])=>[r,String(i)])).toString():"";return t(`/graph${o}`)},dream:()=>t("/dream",{method:"POST"}),explore:(e,o="associations",r,i=10)=>t("/explore",{method:"POST",body:JSON.stringify({from_id:e,action:o,to_id:r,limit:i})}),predict:()=>t("/predict",{method:"POST"}),importance:e=>t("/importance",{method:"POST",body:JSON.stringify({content:e})}),consolidate:()=>t("/consolidate",{method:"POST"}),retentionDistribution:()=>t("/retention-distribution"),memoryChangelog:(e=100)=>t(`/changelog?limit=${e}`),duplicates:(e=.8,o=20)=>t(`/duplicates?threshold=${e}&limit=${o}`),contradictions:e=>{const o=e?"?"+new URLSearchParams(Object.entries(e).filter(([,r])=>r!==void 0).map(([r,i])=>[r,String(i)])).toString():"";return t(`/contradictions${o}`)},crossProjectPatterns:()=>t("/patterns/cross-project"),memoryAudit:(e,o=100)=>t(`/memories/${encodeURIComponent(e)}/audit?limit=${o}`),intentions:(e="active")=>t(`/intentions?status=${e}`),deepReference:(e,o=20)=>t("/deep_reference",{method:"POST",body:JSON.stringify({query:e,depth:o})}),sanhedrin:{latest:()=>t("/sanhedrin/latest"),telemetry:(e=7)=>t(`/sanhedrin/telemetry?days=${e}`),appeal:(e,o,r,i)=>t("/sanhedrin/appeal",{method:"POST",body:JSON.stringify({reason:e,note:o,claimId:r,receiptId:i})})},traces:{list:(e=50)=>t(`/traces?limit=${e}`),get:e=>t(`/traces/${encodeURIComponent(e)}`),exportUrl:e=>`${s}/traces/${encodeURIComponent(e)}/export`},receipts:{list:(e=50)=>t(`/receipts?limit=${e}`),listForRun:(e,o=50)=>t(`/receipts?run=${encodeURIComponent(e)}&limit=${o}`),get:e=>t(`/receipts/${encodeURIComponent(e)}`)},memoryPrs:{list:(e,o=100)=>{const r=new URLSearchParams;return e&&r.set("status",e),r.set("limit",String(o)),t(`/memory-prs?${r.toString()}`)},get:e=>t(`/memory-prs/${encodeURIComponent(e)}`),act:(e,o)=>t(`/memory-prs/${encodeURIComponent(e)}/${o}`,{method:"POST"}),getMode:()=>t("/memory-prs/mode"),setMode:e=>t("/memory-prs/mode",{method:"POST",body:JSON.stringify({mode:e})})}};export{n as a}; diff --git a/apps/dashboard/build/_app/immutable/chunks/D35IQVqe.js.br b/apps/dashboard/build/_app/immutable/chunks/D35IQVqe.js.br deleted file mode 100644 index d8bafd1..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/D35IQVqe.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/D35IQVqe.js.gz b/apps/dashboard/build/_app/immutable/chunks/D35IQVqe.js.gz deleted file mode 100644 index 29dd91f..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/D35IQVqe.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/D7ozXiSB.js b/apps/dashboard/build/_app/immutable/chunks/D7ozXiSB.js deleted file mode 100644 index e4b678b..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/D7ozXiSB.js +++ /dev/null @@ -1,134 +0,0 @@ -var F=Object.defineProperty;var N=(a,e,t)=>e in a?F(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var u=(a,e,t)=>N(a,typeof e!="symbol"?e+"":e,t);import{r as D}from"./BMB5u1EX.js";import{b as G}from"./DY7cP31Q.js";const L=32,U=126,P=63,z=.6,R=1.32,S="...";function O(a){return new Map(a.glyphs.map(e=>[e.unicode,e]))}function A(a){const e=a.codePointAt(0)??P;return e>=L&&e<=U?a:"?"}function C(a,e){if(e===void 0||e<0)return a;if(e===0)return"";const t=Array.from(a,A);return t.length<=e?t.join(""):e<=S.length?".".repeat(e):`${t.slice(0,e-S.length).join("")}${S}`}function k(a,e){return a.split(` -`).map(t=>C(t,e))}function V(a,e,t={}){var h;const r=O(e),s=r.get(P),o=e.atlas.width,i=e.atlas.height,n=t.advance??z,c=t.lineHeight??((h=e.metrics)==null?void 0:h.lineHeight)??R,p=t.maxWidthEm===void 0?void 0:Math.max(0,Math.floor(t.maxWidthEm/n)),d=[];let g=0;for(const x of k(a,p)){let f=0;for(const m of Array.from(x)){const _=A(m).codePointAt(0)??P,l=r.get(_)??s;if(l!=null&&l.planeBounds&&l.atlasBounds){const y=l.planeBounds,v=l.atlasBounds,T=v.left/o,w=1-v.top/i,B=(v.right-v.left)/o,M=1-v.bottom/i-w;d.push({x:f+y.left,y:g+y.bottom,w:y.right-y.left,h:y.top-y.bottom,u:T,v:w,uw:B,vh:M})}f+=n}g-=c}return d}async function j(a){var h,x,f;const e=`${G}/msdf/jetbrains-mono.json`,t=`${G}/msdf/jetbrains-mono.png`,r=await fetch(e);if(!r.ok)throw new Error(`MSDF atlas JSON failed: ${r.status} ${e}`);const s=await r.json();if(((h=s.atlas)==null?void 0:h.yOrigin)!=="bottom")throw new Error(`MSDF atlas yOrigin must be bottom, got ${((x=s.atlas)==null?void 0:x.yOrigin)??"missing"}`);const o=await fetch(t);if(!o.ok)throw new Error(`MSDF atlas PNG failed: ${o.status} ${t}`);const i=await o.blob(),n=await createImageBitmap(i),c=a.createTexture({label:"msdf-jetbrains-mono-rgba8unorm",size:[n.width,n.height,1],format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT});a.queue.copyExternalImageToTexture({source:n},{texture:c},{width:n.width,height:n.height}),(f=n.close)==null||f.call(n);const p=a.createSampler({label:"msdf-jetbrains-mono-linear-sampler",magFilter:"linear",minFilter:"linear",mipmapFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}),d=c.createView({label:"msdf-jetbrains-mono-view"}),g=new Map(s.glyphs.map(m=>[m.unicode,m]));return{...s,glyphMap:g,texture:c,textureView:d,sampler:p,dispose:()=>c.destroy()}}const H=` -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - capture_mode: f32, - live_kind: f32, - live_frame: f32, - live_energy: f32, - projection_days: f32, - cursor_x: f32, - cursor_y: f32, - cursor_vx: f32, - cursor_vy: f32, -}; - -struct Glyph { - anchor_size: vec4f, - quad_offset: vec4f, - uv_rect: vec4f, - info: vec4f, - color: vec4f, -}; - -struct VSOut { - @builtin(position) clip: vec4f, - @location(0) uv: vec2f, - @location(1) @interpolate(flat) info: vec4f, - @location(2) @interpolate(flat) color: vec4f, - @location(3) @interpolate(flat) weight: f32, -}; - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var glyphs: array; -@group(0) @binding(2) var atlas_sampler: sampler; -@group(0) @binding(3) var atlas_tex: texture_2d; - -const QUAD = array( - vec2f(0.0, 0.0), vec2f(1.0, 0.0), vec2f(1.0, 1.0), - vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(0.0, 1.0) -); - -fn median3(c: vec3f) -> f32 { - return max(min(c.r, c.g), min(max(c.r, c.g), c.b)); -} - -@vertex -fn vs_text(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - let glyph = glyphs[ii]; - let corner = QUAD[vi]; - let anchor = glyph.anchor_size.xy; - let size = glyph.anchor_size.zw; - let quad_offset = glyph.quad_offset.xy; - let uv_min = glyph.uv_rect.xy; - let uv_max = glyph.uv_rect.zw; - let aspect = max(0.0001, params.viewport_w / max(1.0, params.viewport_h)); - let depth = clamp(glyph.info.z, 0.0, 1.0); - let cursor_pre = vec2f(params.cursor_x, params.cursor_y); - let cursor_delta = cursor_pre - anchor; - let d = distance(anchor, cursor_pre); - // Wide influence radius so the field reacts when the cursor is anywhere NEAR - // the text, not only dead-on (v1 R=0.45 was too tight to feel). - let R = 0.75; - let cursor_w = exp(-(d * d) / (R * R)); - // Per-glyph SCALE-UP near the cursor: glyphs the pointer approaches swell toward - // you. Scaling the quad around its anchor is the most legible "alive" cue. - let grow = 1.0 + cursor_w * 0.55; - var pos = anchor + (quad_offset + corner * size) * grow; - // Depth → clip z. Trust (depth~1) floats forward (small z), low-trust sinks back. - // Cursor lifts a glyph forward, but z MUST stay > 0 or clip.z<0 clips the quad - // behind the near plane and the glyph vanishes (v1 bug: cursor made text disappear). - var z = mix(0.42, 0.10, depth); - z = clamp(z - cursor_w * 0.42, 0.04, 0.6); - let lean_dir = select(vec2f(0.0, 0.0), normalize(cursor_delta), length(cursor_delta) > 0.0001); - pos = pos + lean_dir * cursor_w * 0.04; - pos = pos + vec2f(sin(params.time * 0.6), cos(params.time * 0.5)) * ((1.0 - depth) * 0.006) * params.pulse; - // Keep glyphs square in BOTH orientations: normalize by the longer axis. - // Landscape (aspect>1): narrow x. Portrait (aspect<1): shrink y instead — - // dividing x by aspect<1 would WIDEN x and push text off-screen. - pos.x = pos.x / max(aspect, 1.0); - pos.y = pos.y * min(aspect, 1.0); - let wclip = 1.0 + z; - var out: VSOut; - out.clip = vec4f(pos, z, wclip); - out.uv = vec2f(mix(uv_min.x, uv_max.x, corner.x), mix(uv_max.y, uv_min.y, corner.y)); - out.info = vec4f(glyph.info.x, glyph.info.y, cursor_w, depth); - out.color = glyph.color; - out.weight = clamp(glyph.info.w, 0.0, 1.0); - return out; -} - -@fragment -fn fs_text(in: VSOut) -> @location(0) vec4f { - let atlas_px = vec2f(textureDimensions(atlas_tex, 0)); - let cursor_w = clamp(in.info.z, 0.0, 1.0); - let depth = clamp(in.info.w, 0.0, 1.0); - let weight = clamp(in.weight, 0.0, 1.0); - var uv = in.uv; - uv = uv + vec2f(sin(uv.y * 40.0 + params.time * 3.0), cos(uv.x * 40.0 + params.time * 3.0)) * (cursor_w * 0.007); - let msdf = textureSample(atlas_tex, atlas_sampler, uv).rgb; - let dist = median3(msdf); - let uv_width = max(fwidth(uv), vec2f(1.0 / max(atlas_px.x, 1.0), 1.0 / max(atlas_px.y, 1.0))); - let texels_per_px = max(length(uv_width * atlas_px), 0.0001); - let screen_range = max(0.5, 4.0 / texels_per_px); - // Depth-of-field: far/un-hovered glyphs soften, cursor sharpens. Kept GENTLE so - // the resting field stays READABLE regardless of the data's depth value. - let dof = (1.0 - depth) * (1.0 - cursor_w); - let screen_range_dof = screen_range / (1.0 + dof * 0.6); - // Weight (FSRS retention) modulates stroke mass WITHIN a readable band: it can - // thicken a lot but only thin slightly, so a low-retention record never - // disappears (data must be legible even at weight~0 — every route depends on this). - let weight_bias = (weight - 0.5) * 0.10 + 0.03; - let px_dist = screen_range_dof * (dist - 0.5 + weight_bias); - let coverage = clamp(px_dist + 0.5, 0.0, 1.0); - let reveal_span = max(1.0, in.info.y); - let reveal = clamp((params.frame - in.info.x) / reveal_span, 0.0, 1.0); - let alpha = coverage * in.color.a * reveal; - if (alpha < 0.001) { discard; } - // Glow floor keeps EVERY line clearly lit at rest (even depth~0), depth adds - // forward-brightness, cursor pushes near glyphs HARD past the bloom line to flare. - let glow = mix(1.15, 1.5, depth) + cursor_w * 1.4; - let rgb = in.color.rgb * params.brightness * glow; - return vec4f(rgb * alpha, alpha); -} -`,E=20,q=[...D("#22C7DE"),1];class K{constructor(e){u(this,"engine");u(this,"atlas",null);u(this,"bindLayout",null);u(this,"pipeline",null);u(this,"glyphBuffer",null);u(this,"bindGroup",null);u(this,"glyphCapacity",0);u(this,"glyphCount",0);u(this,"pendingItems",[]);u(this,"runs",[]);u(this,"runDepths",new Map);u(this,"initPromise",null);this.engine=e}async init(){return this.initPromise?this.initPromise:(this.initPromise=this.initInner(),this.initPromise)}async initInner(){const e=this.engine.gpuDevice;!e||!this.engine.paramsBuffer||(this.atlas=await j(e),this.ensurePipeline(e),this.pendingItems.length&&this.uploadItems(this.pendingItems))}setText(e){const t=typeof e=="string"?[{text:e,x:-.62,y:0,size:.075}]:Array.isArray(e)?e:[e];this.pendingItems=t,this.uploadItems(t)}ensurePipeline(e){if(this.pipeline||!this.engine.paramsBuffer)return;const t=e.createShaderModule({label:"msdf-text-wgsl",code:H});this.bindLayout=e.createBindGroupLayout({label:"msdf-text-bind-layout",entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.VERTEX,buffer:{type:"read-only-storage"}},{binding:2,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:3,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}}]});const r=e.createPipelineLayout({label:"msdf-text-pipeline-layout",bindGroupLayouts:[this.bindLayout]}),s={color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};this.pipeline=e.createRenderPipeline({label:"msdf-text-pipeline",layout:r,vertex:{module:t,entryPoint:"vs_text"},fragment:{module:t,entryPoint:"fs_text",targets:[{format:this.engine.sceneFormat,blend:s}]},primitive:{topology:"triangle-list"}})}uploadItems(e){const t=this.engine.gpuDevice;if(!t||!this.engine.paramsBuffer||!this.atlas)return;this.ensurePipeline(t);const r=[],s=[];let o=0;e.forEach((n,c)=>{const p=n.size??.075,d=V(n.text,this.atlas,{maxWidthEm:n.maxWidthEm}),g=n.color??q,h=d,x=o;let f=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,b=Number.POSITIVE_INFINITY,_=Number.NEGATIVE_INFINITY;for(const l of h){const y=n.x+l.x*p,v=n.x+(l.x+l.w)*p,T=n.y+l.y*p,w=n.y+(l.y+l.h)*p;f=Math.min(f,y),m=Math.max(m,v),b=Math.min(b,T),_=Math.max(_,w),W(r,n,l,g,p,o++)}if(h.length>0){const l=n.id??`msdf-text:${c}`;s.push({id:l,kind:n.kind??"text",text:n.text,x0:f,x1:m,y0:b,y1:_,payload:n,glyphStart:x,glyphCount:o-x}),this.runDepths.set(l,I(n.depth??.5))}}),this.runs=s,this.glyphCount=r.length/E;const i=new Float32Array(r.length||E);i.set(r),this.ensureGlyphBuffer(t,Math.max(1,this.glyphCount)),!(!this.glyphBuffer||!this.bindLayout)&&(t.queue.writeBuffer(this.glyphBuffer,0,i),this.bindGroup=t.createBindGroup({label:"msdf-text-bind-group",layout:this.bindLayout,entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.glyphBuffer}},{binding:2,resource:this.atlas.sampler},{binding:3,resource:this.atlas.textureView}]}))}ensureGlyphBuffer(e,t){var r;this.glyphBuffer&&this.glyphCapacity>=t||((r=this.glyphBuffer)==null||r.destroy(),this.glyphCapacity=Math.max(t,Math.ceil(this.glyphCapacity*1.5),32),this.glyphBuffer=e.createBuffer({label:"msdf-text-glyphs",size:this.glyphCapacity*E*4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}))}render(e){!this.pipeline||!this.bindGroup||this.glyphCount<=0||(e.setPipeline(this.pipeline),e.setBindGroup(0,this.bindGroup),e.draw(6,this.glyphCount))}pickAt(e,t){const r=Math.max(1e-4,(this.engine.params[6]||1)/Math.max(1,this.engine.params[7]||1)),s=Math.max(r,1),o=Math.min(r,1);for(const i of this.runs){const n=(i.payload.hitPadX??i.payload.hitPad??0)/s,c=(i.payload.hitPadY??i.payload.hitPad??0)*o,p=i.x0/s-n,d=i.x1/s+n,g=i.y0*o-c,h=i.y1*o+c;if(e>=p&&e<=d&&t>=g&&t<=h)return{id:i.id,kind:i.kind,payload:i.payload}}return null}setRunDepth(e,t=.5){const r=this.engine.gpuDevice;if(!(!r||!this.glyphBuffer))for(const s of this.runs){const o=s.id===e?t:s.payload.depth??.5,i=I(o);if(this.runDepths.get(s.id)===i)continue;this.runDepths.set(s.id,i);const n=new Float32Array([i]);for(let c=0;c{throw TypeError(t)};var Ce=(t,e,s)=>e in t?ze(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var Q=(t,e,s)=>Ce(t,typeof e!="symbol"?e+"":e,s),ae=(t,e,s)=>e.has(t)||be("Cannot "+s);var r=(t,e,s)=>(ae(t,e,"read from private field"),s?s.call(t):e.get(t)),_=(t,e,s)=>e.has(t)?be("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),o=(t,e,s,n)=>(ae(t,e,"write to private field"),n?n.call(t,s):e.set(t,s),s),b=(t,e,s)=>(ae(t,e,"access private method"),s);import{aU as He,g as Re,z as Pe,y as G,aV as ye,aw as $,at as Ae,I as L,w as Y,a5 as C,aW as ve,i as Ve,ai as We,ak as je,aX as we,N as I,A as De,aY as oe,M as fe,O as $e,aZ as me,a_ as Je,a$ as Ee,b0 as Ge,b1 as Qe,b2 as te,b3 as se,b4 as Te,b5 as Ue,b6 as Ne,Q as H,an as Ze,L as ue,G as re,af as Ke,al as Xe,b7 as U,E as et,B as tt,b8 as st,b9 as rt,t as nt,ba as it,a0 as at,bb as ce,J as ot,C as Oe,aG as ft,D as ut,aK as le,F as Z,bc as ct,az as lt,bd as ht,aq as dt,p as _t,aL as pt,am as gt,aJ as bt,b as yt,Z as P,aQ as vt,S as wt,j as mt,a9 as Et,aR as Tt,be as St,x as Rt}from"./CGq8RnJq.js";function ke(t){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function At(t){let e=0,s=Ae(0),n;return()=>{He()&&(Re(s),Pe(()=>(e===0&&(n=G(()=>t(()=>ye(s)))),e+=1,()=>{$(()=>{e-=1,e===0&&(n==null||n(),n=void 0,ye(s))})})))}}var Dt=et|tt;function Nt(t,e,s,n){new Ot(t,e,s,n)}var w,J,R,q,y,A,m,T,O,x,M,V,W,j,k,ne,h,Me,Fe,Ie,he,X,ee,de;class Ot{constructor(e,s,n,f){_(this,h);Q(this,"parent");Q(this,"is_pending",!1);Q(this,"transform_error");_(this,w);_(this,J,Y?L:null);_(this,R);_(this,q);_(this,y);_(this,A,null);_(this,m,null);_(this,T,null);_(this,O,null);_(this,x,0);_(this,M,0);_(this,V,!1);_(this,W,new Set);_(this,j,new Set);_(this,k,null);_(this,ne,At(()=>(o(this,k,Ae(r(this,x))),()=>{o(this,k,null)})));var i;o(this,w,e),o(this,R,s),o(this,q,u=>{var l=C;l.b=this,l.f|=ve,n(u)}),this.parent=C.b,this.transform_error=f??((i=this.parent)==null?void 0:i.transform_error)??(u=>u),o(this,y,Ve(()=>{if(Y){const u=r(this,J);We();const l=u.data===je;if(u.data.startsWith(we)){const a=JSON.parse(u.data.slice(we.length));b(this,h,Fe).call(this,a)}else l?b(this,h,Ie).call(this):b(this,h,Me).call(this)}else b(this,h,he).call(this)},Dt)),Y&&o(this,w,L)}defer_effect(e){Qe(e,r(this,W),r(this,j))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!r(this,R).pending}update_pending_count(e){b(this,h,de).call(this,e),o(this,x,r(this,x)+e),!(!r(this,k)||r(this,V))&&(o(this,V,!0),$(()=>{o(this,V,!1),r(this,k)&&Ze(r(this,k),r(this,x))}))}get_effect_pending(){return r(this,ne).call(this),Re(r(this,k))}error(e){var s=r(this,R).onerror;let n=r(this,R).failed;if(!s&&!n)throw e;r(this,A)&&(ue(r(this,A)),o(this,A,null)),r(this,m)&&(ue(r(this,m)),o(this,m,null)),r(this,T)&&(ue(r(this,T)),o(this,T,null)),Y&&(re(r(this,J)),Ke(),re(Xe()));var f=!1,i=!1;const u=()=>{if(f){rt();return}f=!0,i&&st(),r(this,T)!==null&&fe(r(this,T),()=>{o(this,T,null)}),b(this,h,ee).call(this,()=>{oe.ensure(),b(this,h,he).call(this)})},l=c=>{try{i=!0,s==null||s(c,u),i=!1}catch(a){U(a,r(this,y)&&r(this,y).parent)}n&&o(this,T,b(this,h,ee).call(this,()=>{oe.ensure();try{return I(()=>{var a=C;a.b=this,a.f|=ve,n(r(this,w),()=>c,()=>u)})}catch(a){return U(a,r(this,y).parent),null}}))};$(()=>{var c;try{c=this.transform_error(e)}catch(a){U(a,r(this,y)&&r(this,y).parent);return}c!==null&&typeof c=="object"&&typeof c.then=="function"?c.then(l,a=>U(a,r(this,y)&&r(this,y).parent)):l(c)})}}w=new WeakMap,J=new WeakMap,R=new WeakMap,q=new WeakMap,y=new WeakMap,A=new WeakMap,m=new WeakMap,T=new WeakMap,O=new WeakMap,x=new WeakMap,M=new WeakMap,V=new WeakMap,W=new WeakMap,j=new WeakMap,k=new WeakMap,ne=new WeakMap,h=new WeakSet,Me=function(){try{o(this,A,I(()=>r(this,q).call(this,r(this,w))))}catch(e){this.error(e)}},Fe=function(e){const s=r(this,R).failed;s&&o(this,T,I(()=>{s(r(this,w),()=>e,()=>()=>{})}))},Ie=function(){const e=r(this,R).pending;e&&(this.is_pending=!0,o(this,m,I(()=>e(r(this,w)))),$(()=>{var s=o(this,O,document.createDocumentFragment()),n=De();s.append(n),o(this,A,b(this,h,ee).call(this,()=>(oe.ensure(),I(()=>r(this,q).call(this,n))))),r(this,M)===0&&(r(this,w).before(s),o(this,O,null),fe(r(this,m),()=>{o(this,m,null)}),b(this,h,X).call(this))}))},he=function(){try{if(this.is_pending=this.has_pending_snippet(),o(this,M,0),o(this,x,0),o(this,A,I(()=>{r(this,q).call(this,r(this,w))})),r(this,M)>0){var e=o(this,O,document.createDocumentFragment());$e(r(this,A),e);const s=r(this,R).pending;o(this,m,I(()=>s(r(this,w))))}else b(this,h,X).call(this)}catch(s){this.error(s)}},X=function(){this.is_pending=!1;for(const e of r(this,W))me(e,Je),Ee(e);for(const e of r(this,j))me(e,Ge),Ee(e);r(this,W).clear(),r(this,j).clear()},ee=function(e){var s=C,n=Ne,f=H;te(r(this,y)),se(r(this,y)),Te(r(this,y).ctx);try{return e()}catch(i){return Ue(i),null}finally{te(s),se(n),Te(f)}},de=function(e){var s;if(!this.has_pending_snippet()){this.parent&&b(s=this.parent,h,de).call(s,e);return}o(this,M,r(this,M)+e),r(this,M)===0&&(b(this,h,X).call(this),r(this,m)&&fe(r(this,m),()=>{o(this,m,null)}),r(this,O)&&(r(this,w).before(r(this,O)),o(this,O,null)))};const kt=["touchstart","touchmove"];function Mt(t){return kt.includes(t)}const B=Symbol("events"),Le=new Set,_e=new Set;function Ft(t,e,s,n={}){function f(i){if(n.capture||pe.call(e,i),!i.cancelBubble)return it(()=>s==null?void 0:s.call(this,i))}return t.startsWith("pointer")||t.startsWith("touch")||t==="wheel"?$(()=>{e.addEventListener(t,f,n)}):e.addEventListener(t,f,n),f}function Ht(t,e,s,n,f){var i={capture:n,passive:f},u=Ft(t,e,s,i);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&nt(()=>{e.removeEventListener(t,u,i)})}function Pt(t,e,s){(e[B]??(e[B]={}))[t]=s}function Vt(t){for(var e=0;e{throw F});throw E}}finally{t[B]=e,delete t.currentTarget,se(S),te(D)}}}function Wt(t,e){var s=e==null?"":typeof e=="object"?e+"":e;s!==(t.__t??(t.__t=t.nodeValue))&&(t.__t=s,t.nodeValue=s+"")}function Ye(t,e){return Be(t,e)}function It(t,e){ce(),e.intro=e.intro??!1;const s=e.target,n=Y,f=L;try{for(var i=ot(s);i&&(i.nodeType!==Oe||i.data!==ft);)i=ut(i);if(!i)throw le;Z(!0),re(i);const u=Be(t,{...e,anchor:i});return Z(!1),u}catch(u){if(u instanceof Error&&u.message.split(` -`).some(l=>l.startsWith("https://svelte.dev/e/")))throw u;return u!==le&&console.warn("Failed to hydrate: ",u),e.recover===!1&&ct(),ce(),lt(s),Z(!1),Ye(t,e)}finally{Z(n),re(f)}}const K=new Map;function Be(t,{target:e,anchor:s,props:n={},events:f,context:i,intro:u=!0,transformError:l}){ce();var c=void 0,a=ht(()=>{var S=s??e.appendChild(De());Nt(S,{pending:()=>{}},g=>{_t({});var d=H;if(i&&(d.c=i),f&&(n.$$events=f),Y&&pt(g,null),c=t(g,n)||{},Y&&(C.nodes.end=L,L===null||L.nodeType!==Oe||L.data!==gt))throw bt(),le;yt()},l);var D=new Set,E=g=>{for(var d=0;d{var N;for(var g of D)for(const v of[e,document]){var d=K.get(v),p=d.get(g);--p==0?(v.removeEventListener(g,pe),d.delete(g),d.size===0&&K.delete(v)):d.set(g,p)}_e.delete(E),S!==s&&((N=S.parentNode)==null||N.removeChild(S))}});return ge.set(c,a),c}let ge=new WeakMap;function Lt(t,e){const s=ge.get(t);return s?(ge.delete(t),s(e)):Promise.resolve()}function qe(t,e,s){if(t==null)return e(void 0),s&&s(void 0),P;const n=G(()=>t.subscribe(e,s));return n.unsubscribe?()=>n.unsubscribe():n}const z=[];function Yt(t,e){return{subscribe:Bt(t,e).subscribe}}function Bt(t,e=P){let s=null;const n=new Set;function f(l){if(vt(t,l)&&(t=l,s)){const c=!z.length;for(const a of n)a[1](),z.push(a,t);if(c){for(let a=0;a{n.delete(a),n.size===0&&s&&(s(),s=null)}}return{set:f,update:i,subscribe:u}}function jt(t,e,s){const n=!Array.isArray(t),f=n?[t]:t;if(!f.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const i=e.length<2;return Yt(s,(u,l)=>{let c=!1;const a=[];let S=0,D=P;const E=()=>{if(S)return;D();const d=e(n?a[0]:a,u,l);i?u(d):D=typeof d=="function"?d:P},g=f.map((d,p)=>qe(d,N=>{a[p]=N,S&=~(1<{S|=1<e=s)(),e}function xe(t){H===null&&ke(),Et&&H.l!==null?xt(H).m.push(t):mt(()=>{const e=G(t);if(typeof e=="function")return e})}function qt(t){H===null&&ke(),xe(()=>()=>G(t))}function xt(t){var e=t.l;return e.u??(e.u={a:[],b:[],m:[]})}const Jt=Object.freeze(Object.defineProperty({__proto__:null,flushSync:Tt,hydrate:It,mount:Ye,onDestroy:qt,onMount:xe,settled:St,tick:Rt,unmount:Lt,untrack:G},Symbol.toStringTag,{value:"Module"}));export{qt as a,Pt as b,jt as c,Vt as d,Ht as e,qe as f,$t as g,It as h,Jt as i,Ye as m,xe as o,Wt as s,Lt as u,Bt as w}; diff --git a/apps/dashboard/build/_app/immutable/chunks/DAau0uzT.js.br b/apps/dashboard/build/_app/immutable/chunks/DAau0uzT.js.br deleted file mode 100644 index b9014b8..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DAau0uzT.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/DAau0uzT.js.gz b/apps/dashboard/build/_app/immutable/chunks/DAau0uzT.js.gz deleted file mode 100644 index e94a5e7..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DAau0uzT.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/DETSv_kY.js b/apps/dashboard/build/_app/immutable/chunks/DETSv_kY.js deleted file mode 100644 index c57068c..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/DETSv_kY.js +++ /dev/null @@ -1,238 +0,0 @@ -var D=Object.defineProperty;var N=(o,e,t)=>e in o?D(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var f=(o,e,t)=>N(o,typeof e!="symbol"?e+"":e,t);import{r as h,C as F,I as C,R as x,a as I}from"./BMB5u1EX.js";const M=` -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - capture_mode: f32, - live_kind: f32, - live_frame: f32, - live_energy: f32, - projection_days: f32, - cursor_x: f32, - cursor_y: f32, - cursor_vx: f32, - cursor_vy: f32, -}; - -// One living cell. 16 floats = 4 vec4, 16-byte aligned lanes. -struct LivingCellGpu { - // x,y NDC base position; z billboard radius; w orbit ring radius (== length(xy)) - pos_radius: vec4f, - // rgb hue; w energy 0..1 (brightness / activation) - hue_energy: vec4f, - // x orbit phase (0..1); y flags (bit0 selected, bit1 endangered/scar, bit2 pulse-strong); - // z secondary metric (retention-ish 0..1); w spin scale - phase_flags: vec4f, - // x ring index / group; y satellite twinkle seed; z,w reserved - extra: vec4f, -}; - -const TAU: f32 = 6.28318530718; - -// Living orbital drift — the thing that makes the field MOVE. Deterministic: -// a pure function of params.time + the cell's own phase. ring_spin gives inner -// (high-phase) cells a faster turn, like a spinning galaxy core. -fn ring_spin(phase01: f32) -> f32 { - let speed = 0.045 + phase01 * 0.10; - return params.time * speed; -} - -fn orbit(base: vec2f, phase01: f32, spin_scale: f32) -> vec2f { - let radius = length(base); - if (radius < 0.0001) { return base; } - let ang0 = atan2(base.y, base.x); - let ang = ang0 + ring_spin(phase01) * spin_scale + sin(params.time * 0.6 + phase01 * TAU) * 0.02; - let rr = radius * (1.0 + 0.016 * sin(params.time * 1.1 + phase01 * TAU)); - return vec2f(cos(ang), sin(ang)) * rr; -} -`,k=` -${M} - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var cells: array; - -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); - -struct VSOut { - @builtin(position) clip: vec4f, - @location(0) uv: vec2f, - @location(1) @interpolate(flat) hue_energy: vec4f, - @location(2) @interpolate(flat) info: vec4f, // x phase, y flags, z metric2, w spin -}; - -@vertex -fn vs_splat(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - let c = cells[ii]; - let corner = QUAD[vi]; - let phase = c.phase_flags.x; - // breathe the splat radius so density is never a flat print - let breathe = 1.0 + 0.14 * sin(params.time * 1.5 + phase * TAU); - let r = c.pos_radius.z * 2.4 * breathe * (1.0 + c.hue_energy.w * 0.9); - let center = orbit(c.pos_radius.xy, phase, c.phase_flags.w); - var out: VSOut; - out.clip = vec4f(center + corner * r, 0.0, 1.0); - out.uv = corner; - out.hue_energy = c.hue_energy; - out.info = c.phase_flags; - return out; -} - -@fragment -fn fs_splat(in: VSOut) -> @location(0) vec4f { - let d = length(in.uv); - if (d > 1.0) { discard; } - let energy = clamp(in.hue_energy.w, 0.0, 1.0); - let metric2 = clamp(in.info.z, 0.0, 1.0); - let flags = in.info.y; - let scar = select(0.0, 1.0, (flags >= 2.0 && flags < 4.0) || flags >= 6.0); - let body = exp(-d * d * 2.7) * (0.32 + energy * 0.95); - // .r = raw density (fills the void), .g = oxygen (energy-weighted), - // .b = scar/seam accent for endangered cells - return vec4f(body, body * (0.4 + metric2 * 0.9), body * scar * 0.7, 1.0); -} -`,z=` -struct BlurDir { dir: vec2f, _pad: vec2f }; -@group(0) @binding(0) var blur_sampler: sampler; -@group(0) @binding(1) var blur_src: texture_2d; -@group(0) @binding(2) var blur_dir: BlurDir; -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); -struct VSOut { @builtin(position) clip: vec4f, @location(0) uv: vec2f }; -@vertex -fn vs_fullscreen(@builtin(vertex_index) vi: u32) -> VSOut { - var out: VSOut; - let p = QUAD[vi]; - out.clip = vec4f(p, 0.0, 1.0); - out.uv = p * 0.5 + vec2f(0.5); - return out; -} -@fragment -fn fs_blur(in: VSOut) -> @location(0) vec4f { - let dims = vec2f(textureDimensions(blur_src, 0)); - let stepv = blur_dir.dir / max(dims, vec2f(1.0)); - var acc = textureSampleLevel(blur_src, blur_sampler, in.uv - stepv * 2.0, 0.0) * 0.06136; - acc = acc + textureSampleLevel(blur_src, blur_sampler, in.uv - stepv, 0.0) * 0.24477; - acc = acc + textureSampleLevel(blur_src, blur_sampler, in.uv, 0.0) * 0.38774; - acc = acc + textureSampleLevel(blur_src, blur_sampler, in.uv + stepv, 0.0) * 0.24477; - acc = acc + textureSampleLevel(blur_src, blur_sampler, in.uv + stepv * 2.0, 0.0) * 0.06136; - return acc; -} -`,$=` -${M} - -@group(0) @binding(0) var params: Params; -@group(0) @binding(3) var field_sampler: sampler; -@group(0) @binding(4) var field_tex: texture_2d; - -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); -struct VSOut { @builtin(position) clip: vec4f, @location(0) uv: vec2f }; -@vertex -fn vs_fullscreen(@builtin(vertex_index) vi: u32) -> VSOut { - var out: VSOut; - let p = QUAD[vi]; - out.clip = vec4f(p, 0.0, 1.0); - out.uv = p * 0.5 + vec2f(0.5); - return out; -} - -@fragment -fn fs_membrane(in: VSOut) -> @location(0) vec4f { - let dims = vec2f(textureDimensions(field_tex, 0)); - let px = 1.0 / max(dims, vec2f(1.0)); - let f = textureSample(field_tex, field_sampler, in.uv); - let left = textureSampleLevel(field_tex, field_sampler, in.uv - vec2f(px.x, 0.0), 0.0); - let right = textureSampleLevel(field_tex, field_sampler, in.uv + vec2f(px.x, 0.0), 0.0); - let down = textureSampleLevel(field_tex, field_sampler, in.uv - vec2f(0.0, px.y), 0.0); - let up = textureSampleLevel(field_tex, field_sampler, in.uv + vec2f(0.0, px.y), 0.0); - let density = clamp(f.r, 0.0, 5.0); - let oxygen = clamp(f.g, 0.0, 5.0); - let scar = clamp(f.b, 0.0, 3.0); - let grad = length(vec2f((right.r + right.g) - (left.r + left.g), (up.r + up.g) - (down.r + down.g))); - let membrane = smoothstep(0.05, 0.62, density) * (1.0 - smoothstep(2.0, 4.0, density)); - let edge = smoothstep(0.008, 0.11, grad) * membrane; - let breath = 0.72 + 0.55 * params.pulse; - let blackwater = vec3f(0.006, 0.012, 0.015); - let amber = vec3f(0.86, 0.42, 0.12); - let oxygen_col = vec3f(0.66, 1.0, 0.37); - let scarlet = vec3f(1.0, 0.23, 0.18); - var color = blackwater * (0.35 + density * 0.14); - color = color + mix(amber, oxygen_col, clamp(oxygen / max(density, 0.001), 0.0, 1.0)) * density * 0.34 * breath; - color = color + vec3f(0.91, 1.0, 0.72) * edge * (0.85 + 0.5 * params.pulse); - color = color + scarlet * scar * (0.6 + 0.4 * params.pulse); - let vignette = smoothstep(1.02, 0.10, distance(in.uv, vec2f(0.5))); - return vec4f(color * (0.5 + 0.5 * vignette) * params.brightness, 1.0); -} -`,H=` -${M} - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var cells: array; - -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); - -struct VSOut { - @builtin(position) clip: vec4f, - @location(0) uv: vec2f, - @location(1) @interpolate(flat) hue_energy: vec4f, - @location(2) @interpolate(flat) info: vec4f, -}; - -@vertex -fn vs_cell(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - let c = cells[ii]; - let corner = QUAD[vi]; - let phase = c.phase_flags.x; - let flags = c.phase_flags.y; - let selected = select(0.0, 1.0, flags == 1.0 || flags == 3.0 || flags == 5.0 || flags == 7.0); - let beat = 1.0 + 0.22 * sin(params.time * 2.3 + c.extra.y * 1.7); - let r = c.pos_radius.z * (0.85 + c.hue_energy.w * 0.9 + selected * 1.3) * beat; - let center = orbit(c.pos_radius.xy, phase, c.phase_flags.w); - var out: VSOut; - out.clip = vec4f(center + corner * r, 0.0, 1.0); - out.uv = corner; - out.hue_energy = c.hue_energy; - out.info = c.phase_flags; - return out; -} - -@fragment -fn fs_cell(in: VSOut) -> @location(0) vec4f { - let d = length(in.uv); - if (d > 1.0) { discard; } - let hue = in.hue_energy.rgb; - let energy = clamp(in.hue_energy.w, 0.0, 1.0); - let flags = in.info.y; - let metric2 = clamp(in.info.z, 0.0, 1.0); - let selected = select(0.0, 1.0, flags == 1.0 || flags == 3.0 || flags == 5.0 || flags == 7.0); - let scar = select(0.0, 1.0, (flags >= 2.0 && flags < 4.0) || flags >= 6.0); - let phase = in.info.x; - let twinkle = 0.6 + 0.8 * (0.5 + 0.5 * sin(params.time * 2.1 + phase * 26.0)); - let body = exp(-d * d * 2.7) * (0.55 + energy * 1.7) * twinkle; - let rim = smoothstep(0.98, 0.72, d) * (1.0 - smoothstep(0.72, 0.40, d)); - let scarlet = vec3f(1.0, 0.23, 0.18); - let ivory = vec3f(0.95, 1.0, 0.86); - var color = hue * body; - color = color + ivory * rim * (0.9 + selected * 1.6); - color = color + scarlet * scar * smoothstep(0.16, 0.0, abs(d - 0.74)) * 1.5; - return vec4f(color, 1.0); -} -`,P="rgba16float",L=2048,G=16;class W{constructor(e){f(this,"engine");f(this,"cells",[]);f(this,"scalars",{});f(this,"resources",null);f(this,"sampler",null);f(this,"splatBindLayout",null);f(this,"blurBindLayout",null);f(this,"membraneBindLayout",null);f(this,"splatPipeline",null);f(this,"blurPipeline",null);f(this,"membranePipeline",null);f(this,"cellPipeline",null);f(this,"cellCount",0);this.engine=e}setCells(e,t={}){this.cells=e.slice(0,L),this.scalars=t;const r=this.engine.gpuDevice;r&&(this.ensurePipelines(r),this.ensureResources(r),this.uploadBuffers(r))}ensurePipelines(e){if(this.splatPipeline||!this.engine.paramsBuffer)return;const t=S(e,"living-field-splat",k),r=S(e,"living-field-blur",z),i=S(e,"living-field-membrane",$),l=S(e,"living-field-cell",H);this.splatBindLayout=e.createBindGroupLayout({label:"living-field-splat-layout",entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.VERTEX,buffer:{type:"read-only-storage"}}]}),this.blurBindLayout=e.createBindGroupLayout({label:"living-field-blur-layout",entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:2,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}}]}),this.membraneBindLayout=e.createBindGroupLayout({label:"living-field-membrane-layout",entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:3,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:4,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}}]});const s=e.createPipelineLayout({label:"living-field-splat-pl",bindGroupLayouts:[this.splatBindLayout]}),n=e.createPipelineLayout({label:"living-field-blur-pl",bindGroupLayouts:[this.blurBindLayout]}),c=e.createPipelineLayout({label:"living-field-membrane-pl",bindGroupLayouts:[this.membraneBindLayout]});this.sampler=e.createSampler({magFilter:"linear",minFilter:"linear"});const a={color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}};this.splatPipeline=e.createRenderPipeline({label:"living-field-splat",layout:s,vertex:{module:t,entryPoint:"vs_splat"},fragment:{module:t,entryPoint:"fs_splat",targets:[{format:P,blend:a}]},primitive:{topology:"triangle-list"}}),this.blurPipeline=e.createRenderPipeline({label:"living-field-blur",layout:n,vertex:{module:r,entryPoint:"vs_fullscreen"},fragment:{module:r,entryPoint:"fs_blur",targets:[{format:P}]},primitive:{topology:"triangle-list"}}),this.membranePipeline=e.createRenderPipeline({label:"living-field-membrane",layout:c,vertex:{module:i,entryPoint:"vs_fullscreen"},fragment:{module:i,entryPoint:"fs_membrane",targets:[{format:this.engine.sceneFormat,blend:a}]},primitive:{topology:"triangle-list"}}),this.cellPipeline=e.createRenderPipeline({label:"living-field-cells",layout:s,vertex:{module:l,entryPoint:"vs_cell"},fragment:{module:l,entryPoint:"fs_cell",targets:[{format:this.engine.sceneFormat,blend:a}]},primitive:{topology:"triangle-list"}})}ensureResources(e){var w,R,U,A,E;if(!this.splatBindLayout||!this.blurBindLayout||!this.membraneBindLayout||!this.engine.paramsBuffer||!this.sampler)return;const t=Math.max(16,Math.floor((this.engine.params[6]||1280)/2)),r=Math.max(16,Math.floor((this.engine.params[7]||720)/2)),i=!this.resources||this.resources.fieldSize[0]!==t||this.resources.fieldSize[1]!==r;let l=(w=this.resources)==null?void 0:w.cellBuffer,s=(R=this.resources)==null?void 0:R.blurHBuffer,n=(U=this.resources)==null?void 0:U.blurVBuffer;if(l||(l=e.createBuffer({label:"living-field-cells",size:L*G*4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})),s||(s=e.createBuffer({label:"living-field-blur-h",size:16,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),e.queue.writeBuffer(s,0,new Float32Array([1,0,0,0]))),n||(n=e.createBuffer({label:"living-field-blur-v",size:16,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),e.queue.writeBuffer(n,0,new Float32Array([0,1,0,0]))),!i&&this.resources)return;(A=this.resources)==null||A.fieldA.destroy(),(E=this.resources)==null||E.fieldB.destroy();const c=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING,a=e.createTexture({label:"living-field-a",size:[t,r],format:P,usage:c}),u=e.createTexture({label:"living-field-b",size:[t,r],format:P,usage:c}),d=a.createView(),_=u.createView(),g=e.createBindGroup({label:"living-field-splat-bind",layout:this.splatBindLayout,entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:l}}]}),m=e.createBindGroup({label:"living-field-cell-bind",layout:this.splatBindLayout,entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:l}}]}),b=e.createBindGroup({label:"living-field-blur-h-bind",layout:this.blurBindLayout,entries:[{binding:0,resource:this.sampler},{binding:1,resource:d},{binding:2,resource:{buffer:s}}]}),B=e.createBindGroup({label:"living-field-blur-v-bind",layout:this.blurBindLayout,entries:[{binding:0,resource:this.sampler},{binding:1,resource:_},{binding:2,resource:{buffer:n}}]}),v=e.createBindGroup({label:"living-field-membrane-bind",layout:this.membraneBindLayout,entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:3,resource:this.sampler},{binding:4,resource:d}]});this.resources={cellBuffer:l,blurHBuffer:s,blurVBuffer:n,splatBindGroup:g,cellBindGroup:m,blurHBindGroup:b,blurVBindGroup:B,membraneBindGroup:v,fieldA:a,fieldB:u,fieldAView:d,fieldBView:_,fieldSize:[t,r]}}uploadBuffers(e){if(!this.resources)return;const t=new Float32Array(L*G);this.cellCount=Math.min(L,this.cells.length);for(let r=0;r.8&&(a|=4);const u=r*G;t[u+0]=l,t[u+1]=s,t[u+2]=Math.max(.006,p(i.radius,.02)),t[u+3]=n,t[u+4]=p(i.hue[0]),t[u+5]=p(i.hue[1]),t[u+6]=p(i.hue[2]),t[u+7]=O(i.energy),t[u+8]=c,t[u+9]=a,t[u+10]=O(i.metric2??i.energy),t[u+11]=p(i.spin??1,1),t[u+12]=r,t[u+13]=p(i.seed??c*97.13),t[u+14]=0,t[u+15]=0}e.queue.writeBuffer(this.resources.cellBuffer,0,t)}compute(e){const t=this.engine.gpuDevice;if(!t||!this.resources||!this.splatPipeline||!this.blurPipeline)return;this.ensureResources(t);const r=this.resources,i=e.beginRenderPass({label:"living-field-splat-pass",colorAttachments:[{view:r.fieldAView,clearValue:{r:0,g:0,b:0,a:0},loadOp:"clear",storeOp:"store"}]});i.setPipeline(this.splatPipeline),i.setBindGroup(0,r.splatBindGroup),this.cellCount>0&&i.draw(6,this.cellCount),i.end();const l=e.beginRenderPass({label:"living-field-blur-h",colorAttachments:[{view:r.fieldBView,clearValue:{r:0,g:0,b:0,a:0},loadOp:"clear",storeOp:"store"}]});l.setPipeline(this.blurPipeline),l.setBindGroup(0,r.blurHBindGroup),l.draw(6,1),l.end();const s=e.beginRenderPass({label:"living-field-blur-v",colorAttachments:[{view:r.fieldAView,clearValue:{r:0,g:0,b:0,a:0},loadOp:"clear",storeOp:"store"}]});s.setPipeline(this.blurPipeline),s.setBindGroup(0,r.blurVBindGroup),s.draw(6,1),s.end()}render(e){!this.resources||!this.membranePipeline||!this.cellPipeline||(e.setPipeline(this.membranePipeline),e.setBindGroup(0,this.resources.membraneBindGroup),e.draw(6,1),this.cellCount>0&&(e.setPipeline(this.cellPipeline),e.setBindGroup(0,this.resources.cellBindGroup),e.draw(6,this.cellCount)))}orbitCpu(e,t,r,i){const l=Math.hypot(e,t);if(l<1e-4)return{x:e,y:t};const s=this.engine.params[10]||0,n=Math.atan2(t,e),c=(.045+r*.1)*s*i,a=n+c+Math.sin(s*.6+r*Math.PI*2)*.02,u=l*(1+.016*Math.sin(s*1.1+r*Math.PI*2));return{x:Math.cos(a)*u,y:Math.sin(a)*u}}pickAt(e,t){let r=null,i=1/0;for(let l=0;l{for(const l of i.messages)l.type==="error"&&console.error(`[living-field] ${e} WGSL ${l.type} ${l.lineNum}:${l.linePos} ${l.message}`)}),o.popErrorScope().then(i=>{i&&console.error(`[living-field] ${e} shader module validation: ${i.message}`)}),r}const V=2.399963229728653;function X(o,e={}){const t=o.length;if(t===0)return[];const r=e.maxRadius??.92,i=e.minCellR??.012,l=e.maxCellR??.05;return o.map((n,c)=>({d:n,i:c})).sort((n,c)=>(c.d.score||0)-(n.d.score||0)).map(({d:n},c)=>{const a=t>1?c/(t-1):0,u=r*Math.sqrt(.06+.94*a),d=c*V,_=Math.cos(d)*u,g=Math.sin(d)*u,m=y(n.score),b=i+(l-i)*Math.sqrt(m);return{x:_,y:g,radius:b,hue:T(n.hue,m),energy:y(n.energy??.35+.65*m),phase:c/t,pickId:n.id,kind:n.kind,payload:n.payload??n,selected:n.selected,scar:n.scar,metric2:y(n.metric2??m),spin:1}})}function Y(o,e,t={}){if(o.length===0)return[];const i=t.maxRadius??.9,l=t.minCellR??.014,s=t.maxCellR??.05,n=Math.max(1,t.ringCount??new Set(o.map(e)).size),c=new Map;return o.map((a,u)=>{const d=e(a,u),g=((Number.isFinite(d)?Math.floor(d):0)%n+n)%n,m=c.get(g)??0;c.set(g,m+1);const b=i*(.18+.82*(g/Math.max(1,n-1))),B=m*V+g*.7,v=y(a.score);return{x:Math.cos(B)*b,y:Math.sin(B)*b,radius:l+(s-l)*Math.sqrt(v),hue:T(a.hue,v),energy:y(a.energy??.35+.65*v),phase:g/n,pickId:a.id,kind:a.kind,payload:a.payload??a,selected:a.selected,scar:a.scar,metric2:y(a.metric2??v),spin:1}})}const j={oxygen:h(x.luciferin),healthy:h(x.healthy),recall:h(x.recall),bridge:h(x.bridge),debt:h(x.debt),scarlet:h(C.veto),caution:h(C.caution),forward:h(F.forward),retrograde:h(F.retrograde)};function y(o){return Math.min(1,Math.max(0,Number.isFinite(o)?o:0))}function T(o,e){const t=o??I(e);return[Number.isFinite(t[0])?t[0]:0,Number.isFinite(t[1])?t[1]:0,Number.isFinite(t[2])?t[2]:0]}export{j as F,W as L,Y as a,X as l}; diff --git a/apps/dashboard/build/_app/immutable/chunks/DETSv_kY.js.br b/apps/dashboard/build/_app/immutable/chunks/DETSv_kY.js.br deleted file mode 100644 index 267919b..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DETSv_kY.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/DETSv_kY.js.gz b/apps/dashboard/build/_app/immutable/chunks/DETSv_kY.js.gz deleted file mode 100644 index 07a7074..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DETSv_kY.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/DGM4cicq.js b/apps/dashboard/build/_app/immutable/chunks/DGM4cicq.js deleted file mode 100644 index d252fb1..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/DGM4cicq.js +++ /dev/null @@ -1 +0,0 @@ -import{l as k,m as f,x as m,y as t,z as _,w as b,v as y}from"./CGq8RnJq.js";function E(e,a,v=a){var c=new WeakSet;k(e,"input",async r=>{var l=r?e.defaultValue:e.value;if(l=o(e)?u(l):l,v(l),f!==null&&c.add(f),await m(),l!==(l=a())){var h=e.selectionStart,d=e.selectionEnd,n=e.value.length;if(e.value=l??"",d!==null){var s=e.value.length;h===d&&d===n&&s>n?(e.selectionStart=s,e.selectionEnd=s):(e.selectionStart=h,e.selectionEnd=Math.min(d,s))}}}),(b&&e.defaultValue!==e.value||t(a)==null&&e.value)&&(v(o(e)?u(e.value):e.value),f!==null&&c.add(f)),_(()=>{var r=a();if(e===document.activeElement){var l=y??f;if(c.has(l))return}o(e)&&r===u(e.value)||e.type==="date"&&!r&&!e.value||r!==e.value&&(e.value=r??"")})}function S(e,a,v=a){k(e,"change",c=>{var r=c?e.defaultChecked:e.checked;v(r)}),(b&&e.defaultChecked!==e.checked||t(a)==null)&&v(e.checked),_(()=>{var c=a();e.checked=!!c})}function o(e){var a=e.type;return a==="number"||a==="range"}function u(e){return e===""?null:+e}export{S as a,E as b}; diff --git a/apps/dashboard/build/_app/immutable/chunks/DGM4cicq.js.br b/apps/dashboard/build/_app/immutable/chunks/DGM4cicq.js.br deleted file mode 100644 index e4158a6..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DGM4cicq.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/DGM4cicq.js.gz b/apps/dashboard/build/_app/immutable/chunks/DGM4cicq.js.gz deleted file mode 100644 index 85e4bc8..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DGM4cicq.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/DJDK-KWF.js b/apps/dashboard/build/_app/immutable/chunks/DJDK-KWF.js deleted file mode 100644 index 671a5ba..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/DJDK-KWF.js +++ /dev/null @@ -1 +0,0 @@ -import{i as ne,w as re}from"./DAau0uzT.js";import{c as oe,H as C,N as q,r as ot,i as wt,b as L,s as j,p as k,n as ht,f as Dt,g as dt,a as J,d as lt,S as vt,P as qt,e as se,h as ie,o as Kt,j as K,k as ce,l as Ft,m as le,q as fe,t as Mt,u as Tt,v as ue}from"./DY7cP31Q.js";import{x as X,y as he,be as de}from"./CGq8RnJq.js";class yt{constructor(a,e){this.status=a,typeof e=="string"?this.body={message:e}:e?this.body=e:this.body={message:`Error: ${a}`}}toString(){return JSON.stringify(this.body)}}class Et{constructor(a,e){this.status=a,this.location=e}}class bt extends Error{constructor(a,e,r){super(r),this.status=a,this.text=e}}const pe=/^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;function ge(t){const a=[];return{pattern:t==="/"?/^\/$/:new RegExp(`^${_e(t).map(r=>{const n=/^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(r);if(n)return a.push({name:n[1],matcher:n[2],optional:!1,rest:!0,chained:!0}),"(?:/([^]*))?";const o=/^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(r);if(o)return a.push({name:o[1],matcher:o[2],optional:!0,rest:!1,chained:!0}),"(?:/([^/]+))?";if(!r)return;const s=r.split(/\[(.+?)\](?!\])/);return"/"+s.map((c,l)=>{if(l%2){if(c.startsWith("x+"))return ft(String.fromCharCode(parseInt(c.slice(2),16)));if(c.startsWith("u+"))return ft(String.fromCharCode(...c.slice(2).split("-").map(_=>parseInt(_,16))));const h=pe.exec(c),[,u,w,f,d]=h;return a.push({name:f,matcher:d,optional:!!u,rest:!!w,chained:w?l===1&&s[0]==="":!1}),w?"([^]*?)":u?"([^/]*)?":"([^/]+?)"}return ft(c)}).join("")}).join("")}/?$`),params:a}}function me(t){return t!==""&&!/^\([^)]+\)$/.test(t)}function _e(t){return t.slice(1).split("/").filter(me)}function we(t,a,e){const r={},n=t.slice(1),o=n.filter(i=>i!==void 0);let s=0;for(let i=0;ih).join("/"),s=0),l===void 0)if(c.rest)l="";else continue;if(!c.matcher||e[c.matcher](l)){r[c.name]=l;const h=a[i+1],u=n[i+1];h&&!h.rest&&h.optional&&u&&c.chained&&(s=0),!h&&!u&&Object.keys(r).length===o.length&&(s=0);continue}if(c.optional&&c.chained){s++;continue}return}if(!s)return r}function ft(t){return t.normalize().replace(/[[\]]/g,"\\$&").replace(/%/g,"%25").replace(/\//g,"%2[Ff]").replace(/\?/g,"%3[Ff]").replace(/#/g,"%23").replace(/[.*+?^${}()|\\]/g,"\\$&")}function ve({nodes:t,server_loads:a,dictionary:e,matchers:r}){const n=new Set(a);return Object.entries(e).map(([i,[c,l,h]])=>{const{pattern:u,params:w}=ge(i),f={id:i,exec:d=>{const _=u.exec(d);if(_)return we(_,w,r)},errors:[1,...h||[]].map(d=>t[d]),layouts:[0,...l||[]].map(s),leaf:o(c)};return f.errors.length=f.layouts.length=Math.max(f.errors.length,f.layouts.length),f});function o(i){const c=i<0;return c&&(i=~i),[c,t[i]]}function s(i){return i===void 0?i:[n.has(i),t[i]]}}function zt(t,a=JSON.parse){try{return a(sessionStorage[t])}catch{}}function Ot(t,a,e=JSON.stringify){const r=e(a);try{sessionStorage[t]=r}catch{}}function ye(t){return t.filter(a=>a!=null)}function St(t){return t instanceof yt||t instanceof bt?t.status:500}function Ee(t){return t instanceof bt?t.text:"Internal Error"}const{onMount:be}=ne,Se=he??(t=>t()),ke=new Set(["icon","shortcut icon","apple-touch-icon"]),I=zt(Mt)??{},z=zt(Ft)??{},P={url:Tt({}),page:Tt({}),navigating:re(null),updated:oe()};function kt(t){I[t]=j()}function Re(t,a){let e=t+1;for(;I[e];)delete I[e],e+=1;for(e=a+1;z[e];)delete z[e],e+=1}function B(t,a=!1){return a?location.replace(t.href):location.href=t.href,new Promise(()=>{})}async function Bt(){if("serviceWorker"in navigator){const t=await navigator.serviceWorker.getRegistration(L||"/");t&&await t.update()}}function Ct(){}let Rt,pt,Q,U,gt,b;const Z=[],tt=[];let v=null;function mt(){var t;(t=v==null?void 0:v.fork)==null||t.then(a=>a==null?void 0:a.discard()),v=null}const G=new Map,Vt=new Set,Ht=new Set,M=new Set;let m={branch:[],error:null,url:null},Yt=!1,et=!1,jt=!0,V=!1,F=!1,Wt=!1,xt=!1,Lt,y,x,O;const at=new Set,$t=new Map;async function He(t,a,e){var o,s,i,c,l;(o=globalThis.__sveltekit_1vzfo5)!=null&&o.data&&globalThis.__sveltekit_1vzfo5.data,document.URL!==location.href&&(location.href=location.href),b=t,await((i=(s=t.hooks).init)==null?void 0:i.call(s)),Rt=ve(t),U=document.documentElement,gt=a,pt=t.nodes[0],Q=t.nodes[1],pt(),Q(),y=(c=history.state)==null?void 0:c[C],x=(l=history.state)==null?void 0:l[q],y||(y=x=Date.now(),history.replaceState({...history.state,[C]:y,[q]:x},""));const r=I[y];function n(){r&&(history.scrollRestoration="manual",scrollTo(r.x,r.y))}e?(n(),await qe(gt,e)):(await D({type:"enter",url:ot(b.hash?Me(new URL(location.href)):location.href),replace_state:!0}),n()),De()}function xe(){Z.length=0,xt=!1}function Gt(t){tt.some(a=>a==null?void 0:a.snapshot)&&(z[t]=tt.map(a=>{var e;return(e=a==null?void 0:a.snapshot)==null?void 0:e.capture()}))}function Jt(t){var a;(a=z[t])==null||a.forEach((e,r)=>{var n,o;(o=(n=tt[r])==null?void 0:n.snapshot)==null||o.restore(e)})}function Nt(){kt(y),Ot(Mt,I),Gt(x),Ot(Ft,z)}async function Xt(t,a,e,r){let n;a.invalidateAll&&mt(),await D({type:"goto",url:ot(t),keepfocus:a.keepFocus,noscroll:a.noScroll,replace_state:a.replaceState,state:a.state,redirect_count:e,nav_token:r,accept:()=>{a.invalidateAll&&(xt=!0,n=[...$t.keys()]),a.invalidate&&a.invalidate.forEach(Ne)}}),a.invalidateAll&&X().then(X).then(()=>{$t.forEach(({resource:o},s)=>{var i;n!=null&&n.includes(s)&&((i=o.refresh)==null||i.call(o))})})}async function Le(t){if(t.id!==(v==null?void 0:v.id)){mt();const a={};at.add(a),v={id:t.id,token:a,promise:Zt({...t,preload:a}).then(e=>(at.delete(a),e.type==="loaded"&&e.state.error&&mt(),e)),fork:null}}return v.promise}async function ut(t){var e;const a=(e=await st(t,!1))==null?void 0:e.route;a&&await Promise.all([...a.layouts,a.leaf].filter(Boolean).map(r=>r[1]()))}async function Qt(t,a,e){var n;m=t.state;const r=document.querySelector("style[data-sveltekit]");if(r&&r.remove(),Object.assign(k,t.props.page),Lt=new b.root({target:a,props:{...t.props,stores:P,components:tt},hydrate:e,sync:!1}),await Promise.resolve(),Jt(x),e){const o={from:null,to:{params:m.params,route:{id:((n=m.route)==null?void 0:n.id)??null},url:new URL(location.href),scroll:I[y]??j()},willUnload:!1,type:"enter",complete:Promise.resolve()};M.forEach(s=>s(o))}et=!0}function nt({url:t,params:a,branch:e,status:r,error:n,route:o,form:s}){let i="never";if(L&&(t.pathname===L||t.pathname===L+"/"))i="always";else for(const f of e)(f==null?void 0:f.slash)!==void 0&&(i=f.slash);t.pathname=ie(t.pathname,i),t.search=t.search;const c={type:"loaded",state:{url:t,params:a,branch:e,error:n,route:o},props:{constructors:ye(e).map(f=>f.node.component),page:it(k)}};s!==void 0&&(c.props.form=s);let l={},h=!k,u=0;for(let f=0;fi(new URL(s))))return!0;return!1}function At(t,a){return(t==null?void 0:t.type)==="data"?t:(t==null?void 0:t.type)==="skip"?a??null:null}function Pe(t,a){if(!t)return new Set(a.searchParams.keys());const e=new Set([...t.searchParams.keys(),...a.searchParams.keys()]);for(const r of e){const n=t.searchParams.getAll(r),o=a.searchParams.getAll(r);n.every(s=>o.includes(s))&&o.every(s=>n.includes(s))&&e.delete(r)}return e}function Ie({error:t,url:a,route:e,params:r}){return{type:"loaded",state:{error:t,url:a,route:e,params:r,branch:[]},props:{page:it(k),constructors:[]}}}async function Zt({id:t,invalidating:a,url:e,params:r,route:n,preload:o}){if((v==null?void 0:v.id)===t)return at.delete(v.token),v.promise;const{errors:s,layouts:i,leaf:c}=n,l=[...i,c];s.forEach(g=>g==null?void 0:g().catch(()=>{})),l.forEach(g=>g==null?void 0:g[1]().catch(()=>{}));const h=m.url?t!==rt(m.url):!1,u=m.route?n.id!==m.route.id:!1,w=Pe(m.url,e);let f=!1;const d=l.map(async(g,p)=>{var A;if(!g)return;const E=m.branch[p];return g[1]===(E==null?void 0:E.loader)&&!Ae(f,u,h,w,(A=E.universal)==null?void 0:A.uses,r)?E:(f=!0,Ut({loader:g[1],url:e,params:r,route:n,parent:async()=>{var Y;const T={};for(let $=0;${});const _=[];for(let g=0;gPromise.resolve({}),server_data_node:At(o)}),i={node:await Q(),loader:Q,universal:null,server:null,data:null};return nt({url:e,params:n,branch:[s,i],status:t,error:a,route:null})}catch(s){if(s instanceof Et)return Xt(new URL(s.location,location.href),{},0);throw s}}async function Oe(t){const a=t.href;if(G.has(a))return G.get(a);let e;try{const r=(async()=>{let n=await b.hooks.reroute({url:new URL(t),fetch:async(o,s)=>Ue(o,s,t).promise})??t;if(typeof n=="string"){const o=new URL(t);b.hash?o.hash=n:o.pathname=n,n=o}return n})();G.set(a,r),e=await r}catch{G.delete(a);return}return e}async function st(t,a){if(t&&!wt(t,L,b.hash)){const e=await Oe(t);if(!e)return;const r=Ce(e);for(const n of Rt){const o=n.exec(r);if(o)return{id:rt(t),invalidating:a,route:n,params:se(o),url:t}}}}function Ce(t){return ce(b.hash?t.hash.replace(/^#/,"").replace(/[?#].+/,""):t.pathname.slice(L.length))||"/"}function rt(t){return(b.hash?t.hash.replace(/^#/,""):t.pathname)+t.search}function te({url:t,type:a,intent:e,delta:r,event:n,scroll:o}){let s=!1;const i=It(m,e,t,a,o??null);r!==void 0&&(i.navigation.delta=r),n!==void 0&&(i.navigation.event=n);const c={...i.navigation,cancel:()=>{s=!0,i.reject(new Error("navigation cancelled"))}};return V||Vt.forEach(l=>l(c)),s?null:i}async function D({type:t,url:a,popped:e,keepfocus:r,noscroll:n,replace_state:o,state:s={},redirect_count:i=0,nav_token:c={},accept:l=Ct,block:h=Ct,event:u}){var $;const w=O;O=c;const f=await st(a,!1),d=t==="enter"?It(m,f,a,t):te({url:a,type:t,delta:e==null?void 0:e.delta,intent:f,scroll:e==null?void 0:e.scroll,event:u});if(!d){h(),O===c&&(O=w);return}const _=y,g=x;l(),V=!0,et&&d.navigation.type!=="enter"&&P.navigating.set(ht.current=d.navigation);let p=f&&await Zt(f);if(!p){if(wt(a,L,b.hash))return await B(a,o);p=await ee(a,{id:null},await H(new bt(404,"Not Found",`Not found: ${a.pathname}`),{url:a,params:{},route:{id:null}}),404,o)}if(a=(f==null?void 0:f.url)||a,O!==c)return d.reject(new Error("navigation aborted")),!1;if(p.type==="redirect"){if(i<20){await D({type:t,url:new URL(p.location,a),popped:e,keepfocus:r,noscroll:n,replace_state:o,state:s,redirect_count:i+1,nav_token:c}),d.fulfil(void 0);return}p=await Pt({status:500,error:await H(new Error("Redirect loop"),{url:a,params:{},route:{id:null}}),url:a,route:{id:null}})}else p.props.page.status>=400&&await P.updated.check()&&(await Bt(),await B(a,o));if(xe(),kt(_),Gt(g),p.props.page.url.pathname!==a.pathname&&(a.pathname=p.props.page.url.pathname),s=e?e.state:s,!e){const S=o?0:1,W={[C]:y+=S,[q]:x+=S,[vt]:s};(o?history.replaceState:history.pushState).call(history,W,"",a),o||Re(y,x)}const E=f&&(v==null?void 0:v.id)===f.id?v.fork:null;v=null,p.props.page.state=s;let R;if(et){const S=(await Promise.all(Array.from(Ht,N=>N(d.navigation)))).filter(N=>typeof N=="function");if(S.length>0){let N=function(){S.forEach(ct=>{M.delete(ct)})};S.push(N),S.forEach(ct=>{M.add(ct)})}m=p.state,p.props.page&&(p.props.page.url=a);const W=E&&await E;W?R=W.commit():(Lt.$set(p.props),ue(p.props.page),R=($=de)==null?void 0:$()),Wt=!0}else await Qt(p,gt,!1);const{activeElement:A}=document;await R,await X(),await X();let T=null;if(jt){const S=e?e.scroll:n?j():null;S?scrollTo(S.x,S.y):(T=a.hash&&document.getElementById(ae(a)))?T.scrollIntoView():scrollTo(0,0)}const Y=document.activeElement!==A&&document.activeElement!==document.body;!r&&!Y&&Fe(a,!T),jt=!0,p.props.page&&Object.assign(k,p.props.page),V=!1,t==="popstate"&&Jt(x),d.fulfil(void 0),d.navigation.to&&(d.navigation.to.scroll=j()),M.forEach(S=>S(d.navigation)),P.navigating.set(ht.current=null)}async function ee(t,a,e,r,n){return t.origin===Kt&&t.pathname===location.pathname&&!Yt?await Pt({status:r,error:e,url:t,route:a}):await B(t,n)}function je(){let t,a={element:void 0,href:void 0},e;U.addEventListener("mousemove",i=>{const c=i.target;clearTimeout(t),t=setTimeout(()=>{o(c,K.hover)},20)});function r(i){i.defaultPrevented||o(i.composedPath()[0],K.tap)}U.addEventListener("mousedown",r),U.addEventListener("touchstart",r,{passive:!0});const n=new IntersectionObserver(i=>{for(const c of i)c.isIntersecting&&(ut(new URL(c.target.href)),n.unobserve(c.target))},{threshold:0});async function o(i,c){const l=Dt(i,U),h=l===a.element&&(l==null?void 0:l.href)===a.href&&c>=e;if(!l||h)return;const{url:u,external:w,download:f}=dt(l,L,b.hash);if(w||f)return;const d=J(l),_=u&&rt(m.url)===rt(u);if(!(d.reload||_))if(c<=d.preload_data){a={element:l,href:l.href},e=K.tap;const g=await st(u,!1);if(!g)return;Le(g)}else c<=d.preload_code&&(a={element:l,href:l.href},e=c,ut(u))}function s(){n.disconnect();for(const i of U.querySelectorAll("a")){const{url:c,external:l,download:h}=dt(i,L,b.hash);if(l||h)continue;const u=J(i);u.reload||(u.preload_code===K.viewport&&n.observe(i),u.preload_code===K.eager&&ut(c))}}M.add(s),s()}function H(t,a){if(t instanceof yt)return t.body;const e=St(t),r=Ee(t);return b.hooks.handleError({error:t,event:a,status:e,message:r})??{message:r}}function $e(t,a){be(()=>(t.add(a),()=>{t.delete(a)}))}function Ye(t){$e(Ht,t)}function We(t,a={}){return t=new URL(ot(t)),t.origin!==Kt?Promise.reject(new Error("goto: invalid URL")):Xt(t,a,0)}function Ne(t){if(typeof t=="function")Z.push(t);else{const{href:a}=new URL(t,location.href);Z.push(e=>e.href===a)}}function Ge(t,a){const e={[C]:y,[q]:x,[qt]:k.url.href,[vt]:a};history.replaceState(e,"",ot(t)),k.state=a,Lt.$set({page:Se(()=>it(k))})}function De(){var a;history.scrollRestoration="manual",addEventListener("beforeunload",e=>{let r=!1;if(Nt(),!V){const n=It(m,void 0,null,"leave"),o={...n.navigation,cancel:()=>{r=!0,n.reject(new Error("navigation cancelled"))}};Vt.forEach(s=>s(o))}r?(e.preventDefault(),e.returnValue=""):history.scrollRestoration="auto"}),addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&Nt()}),(a=navigator.connection)!=null&&a.saveData||je(),U.addEventListener("click",async e=>{if(e.button||e.which!==1||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.defaultPrevented)return;const r=Dt(e.composedPath()[0],U);if(!r)return;const{url:n,external:o,target:s,download:i}=dt(r,L,b.hash);if(!n)return;if(s==="_parent"||s==="_top"){if(window.parent!==window)return}else if(s&&s!=="_self")return;const c=J(r);if(!(r instanceof SVGAElement)&&n.protocol!==location.protocol&&!(n.protocol==="https:"||n.protocol==="http:")||i)return;const[h,u]=(b.hash?n.hash.replace(/^#/,""):n.href).split("#"),w=h===lt(location);if(o||c.reload&&(!w||!u)){te({url:n,type:"link",event:e})?V=!0:e.preventDefault();return}if(u!==void 0&&w){const[,f]=m.url.href.split("#");if(f===u){if(e.preventDefault(),u===""||u==="top"&&r.ownerDocument.getElementById("top")===null)scrollTo({top:0});else{const d=r.ownerDocument.getElementById(decodeURIComponent(u));d&&(d.scrollIntoView(),d.focus())}return}if(F=!0,kt(y),t(n),!c.replace_state)return;F=!1}e.preventDefault(),await new Promise(f=>{requestAnimationFrame(()=>{setTimeout(f,0)}),setTimeout(f,100)}),await D({type:"link",url:n,keepfocus:c.keepfocus,noscroll:c.noscroll,replace_state:c.replace_state??n.href===location.href,event:e})}),U.addEventListener("submit",e=>{if(e.defaultPrevented)return;const r=HTMLFormElement.prototype.cloneNode.call(e.target),n=e.submitter;if(((n==null?void 0:n.formTarget)||r.target)==="_blank"||((n==null?void 0:n.formMethod)||r.method)!=="get")return;const i=new URL((n==null?void 0:n.hasAttribute("formaction"))&&(n==null?void 0:n.formAction)||r.action);if(wt(i,L,!1))return;const c=e.target,l=J(c);if(l.reload)return;e.preventDefault(),e.stopPropagation();const h=new FormData(c,n);i.search=new URLSearchParams(h).toString(),D({type:"form",url:i,keepfocus:l.keepfocus,noscroll:l.noscroll,replace_state:l.replace_state??i.href===location.href,event:e})}),addEventListener("popstate",async e=>{var r;if(!_t){if((r=e.state)!=null&&r[C]){const n=e.state[C];if(O={},n===y)return;const o=I[n],s=e.state[vt]??{},i=new URL(e.state[qt]??location.href),c=e.state[q],l=m.url?lt(location)===lt(m.url):!1;if(c===x&&(Wt||l)){s!==k.state&&(k.state=s),t(i),I[y]=j(),o&&scrollTo(o.x,o.y),y=n;return}const u=n-y;await D({type:"popstate",url:i,popped:{state:s,scroll:o,delta:u},accept:()=>{y=n,x=c},block:()=>{history.go(-u)},nav_token:O,event:e})}else if(!F){const n=new URL(location.href);t(n),b.hash&&location.reload()}}}),addEventListener("hashchange",()=>{F&&(F=!1,history.replaceState({...history.state,[C]:++y,[q]:x},"",location.href))});for(const e of document.querySelectorAll("link"))ke.has(e.rel)&&(e.href=e.href);addEventListener("pageshow",e=>{e.persisted&&P.navigating.set(ht.current=null)});function t(e){m.url=k.url=e,P.page.set(it(k)),P.page.notify()}}async function qe(t,{status:a=200,error:e,node_ids:r,params:n,route:o,server_route:s,data:i,form:c}){Yt=!0;const l=new URL(location.href);let h;({params:n={},route:o={id:null}}=await st(l,!1)||{}),h=Rt.find(({id:f})=>f===o.id);let u,w=!0;try{const f=r.map(async(_,g)=>{const p=i[g];return p!=null&&p.uses&&(p.uses=Ke(p.uses)),Ut({loader:b.nodes[_],url:l,params:n,route:o,parent:async()=>{const E={};for(let R=0;R{const i=history.state;_t=!0,location.replace(new URL(`#${r}`,location.href)),history.replaceState(i,"",t),a&&scrollTo(o,s),_t=!1})}else{const o=document.body,s=o.getAttribute("tabindex");o.tabIndex=-1,o.focus({preventScroll:!0,focusVisible:!1}),s!==null?o.setAttribute("tabindex",s):o.removeAttribute("tabindex")}const n=getSelection();if(n&&n.type!=="None"){const o=[];for(let s=0;s{if(n.rangeCount===o.length){for(let s=0;s{o=u,s=w});return i.catch(()=>{}),{navigation:{from:{params:t.params,route:{id:((l=t.route)==null?void 0:l.id)??null},url:t.url,scroll:j()},to:e&&{params:(a==null?void 0:a.params)??null,route:{id:((h=a==null?void 0:a.route)==null?void 0:h.id)??null},url:e,scroll:n},willUnload:!a,type:r,complete:i},fulfil:o,reject:s}}function it(t){return{data:t.data,error:t.error,form:t.form,params:t.params,route:t.route,state:t.state,status:t.status,url:t.url}}function Me(t){const a=new URL(t);return a.hash=decodeURIComponent(t.hash),a}function ae(t){let a;if(b.hash){const[,,e]=t.hash.split("#",3);a=e??""}else a=t.hash.slice(1);return decodeURIComponent(a)}export{He as a,We as g,Ye as o,Ge as r,P as s}; diff --git a/apps/dashboard/build/_app/immutable/chunks/DJDK-KWF.js.br b/apps/dashboard/build/_app/immutable/chunks/DJDK-KWF.js.br deleted file mode 100644 index 4673246..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DJDK-KWF.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/DJDK-KWF.js.gz b/apps/dashboard/build/_app/immutable/chunks/DJDK-KWF.js.gz deleted file mode 100644 index 57f76e1..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DJDK-KWF.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/DV6OI5iy.js b/apps/dashboard/build/_app/immutable/chunks/DV6OI5iy.js deleted file mode 100644 index 4f21b0c..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/DV6OI5iy.js +++ /dev/null @@ -1 +0,0 @@ -import{Z as R,_ as y,g as b,t as N,a0 as U,s as A,y as B,a1 as M,a2 as Y,a3 as $,e as w,a4 as x,a5 as Z,a6 as h,a7 as q,a8 as z,a9 as C,aa as G,ab as V,V as j,ac as p,ad as F,ae as H}from"./CGq8RnJq.js";import{f as J,g as K}from"./DAau0uzT.js";let c=!1,g=Symbol();function k(e,r,i){const n=i[r]??(i[r]={store:null,source:y(void 0),unsubscribe:R});if(n.store!==e&&!(g in i))if(n.unsubscribe(),n.store=e??null,e==null)n.source.v=void 0,n.unsubscribe=R;else{var u=!0;n.unsubscribe=J(e,t=>{u?n.source.v=t:A(n.source,t)}),u=!1}return e&&g in i?K(e):b(n.source)}function ee(){const e={};function r(){N(()=>{for(var i in e)e[i].unsubscribe();U(e,g,{enumerable:!1,value:!0})})}return[e,r]}function Q(e){var r=c;try{return c=!1,[e(),c]}finally{c=r}}function re(e,r,i,n){var E;var u=!C||(i&G)!==0,t=(i&z)!==0,T=(i&q)!==0,f=n,o=!0,P=()=>(o&&(o=!1,f=T?B(n):n),f),_;if(t){var D=F in e||H in e;_=((E=M(e,r))==null?void 0:E.set)??(D&&r in e?a=>e[r]=a:void 0)}var d,I=!1;t?[d,I]=Q(()=>e[r]):d=e[r],d===void 0&&n!==void 0&&(d=P(),_&&(u&&Y(),_(d)));var s;if(u?s=()=>{var a=e[r];return a===void 0?P():(o=!0,a)}:s=()=>{var a=e[r];return a!==void 0&&(f=void 0),a===void 0?f:a},u&&(i&$)===0)return s;if(_){var L=e.$$legacy;return(function(a,v){return arguments.length>0?((!u||!v||L||I)&&_(v?s():a),a):s()})}var S=!1,l=((i&V)!==0?j:p)(()=>(S=!1,s()));t&&b(l);var m=Z;return(function(a,v){if(arguments.length>0){const O=v?b(l):u&&t?w(a):a;return A(l,O),S=!0,f!==void 0&&(f=O),a}return x&&S||(m.f&h)!==0?l.v:b(l)})}export{k as a,re as p,ee as s}; diff --git a/apps/dashboard/build/_app/immutable/chunks/DV6OI5iy.js.br b/apps/dashboard/build/_app/immutable/chunks/DV6OI5iy.js.br deleted file mode 100644 index cd6a506..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DV6OI5iy.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/DV6OI5iy.js.gz b/apps/dashboard/build/_app/immutable/chunks/DV6OI5iy.js.gz deleted file mode 100644 index 49684e7..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DV6OI5iy.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/DY7cP31Q.js b/apps/dashboard/build/_app/immutable/chunks/DY7cP31Q.js deleted file mode 100644 index 6460850..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/DY7cP31Q.js +++ /dev/null @@ -1 +0,0 @@ -var x=t=>{throw TypeError(t)};var K=(t,e,n)=>e.has(t)||x("Cannot "+n);var a=(t,e,n)=>(K(t,e,"read from private field"),n?n.call(t):e.get(t)),c=(t,e,n)=>e.has(t)?x("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n);import{w as G,o as I}from"./DAau0uzT.js";import{d as u,g as f,s as d}from"./CGq8RnJq.js";new URL("sveltekit-internal://");function se(t,e){return t==="/"||e==="ignore"?t:e==="never"?t.endsWith("/")?t.slice(0,-1):t:e==="always"&&!t.endsWith("/")?t+"/":t}function ae(t){return t.split("%25").map(decodeURI).join("%25")}function oe(t){for(const e in t)t[e]=decodeURIComponent(t[e]);return t}function ie({href:t}){return t.split("#")[0]}function B(...t){let e=5381;for(const n of t)if(typeof n=="string"){let r=n.length;for(;r;)e=e*33^n.charCodeAt(--r)}else if(ArrayBuffer.isView(n)){const r=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);let s=r.length;for(;s;)e=e*33^r[--s]}else throw new TypeError("value must be a string or TypedArray");return(e>>>0).toString(36)}new TextEncoder;new TextDecoder;function W(t){const e=atob(t),n=new Uint8Array(e.length);for(let r=0;r((t instanceof Request?t.method:(e==null?void 0:e.method)||"GET")!=="GET"&&b.delete(U(t)),X(t,e));const b=new Map;function le(t,e){const n=U(t,e),r=document.querySelector(n);if(r!=null&&r.textContent){r.remove();let{body:s,...l}=JSON.parse(r.textContent);const o=r.getAttribute("data-ttl");return o&&b.set(n,{body:s,init:l,ttl:1e3*Number(o)}),r.getAttribute("data-b64")!==null&&(s=W(s)),Promise.resolve(new Response(s,l))}return window.fetch(t,e)}function ce(t,e,n){if(b.size>0){const r=U(t,n),s=b.get(r);if(s){if(performance.now()o)}function s(o){n=!1,e.set(o)}function l(o){let i;return e.subscribe(h=>{(i===void 0||n&&h!==i)&&o(i=h)})}return{notify:r,set:s,subscribe:l}}const z={v:()=>{}};function Ae(){const{set:t,subscribe:e}=G(!1);let n;async function r(){clearTimeout(n);try{const s=await fetch(`${M}/_app/version.json`,{headers:{pragma:"no-cache","cache-control":"no-cache"}});if(!s.ok)return!1;const o=(await s.json()).version!==F;return o&&(t(!0),z.v(),clearTimeout(n)),o}catch{return!1}}return{subscribe:e,check:r}}function Q(t,e,n){return t.origin!==Y||!t.pathname.startsWith(e)?!0:n?t.pathname!==location.pathname:!1}function Re(t){}const D=new Set(["load","prerender","csr","ssr","trailingSlash","config"]);[...D];const Z=new Set([...D]);[...Z];let E,O,T;const ee=I.toString().includes("$$")||/function \w+\(\) \{\}/.test(I.toString());var _,w,m,v,p,y,A,R,P,S,V,k,j;ee?(E={data:{},form:null,error:null,params:{},route:{id:null},state:{},status:-1,url:new URL("https://example.com")},O={current:null},T={current:!1}):(E=new(P=class{constructor(){c(this,_,u({}));c(this,w,u(null));c(this,m,u(null));c(this,v,u({}));c(this,p,u({id:null}));c(this,y,u({}));c(this,A,u(-1));c(this,R,u(new URL("https://example.com")))}get data(){return f(a(this,_))}set data(e){d(a(this,_),e)}get form(){return f(a(this,w))}set form(e){d(a(this,w),e)}get error(){return f(a(this,m))}set error(e){d(a(this,m),e)}get params(){return f(a(this,v))}set params(e){d(a(this,v),e)}get route(){return f(a(this,p))}set route(e){d(a(this,p),e)}get state(){return f(a(this,y))}set state(e){d(a(this,y),e)}get status(){return f(a(this,A))}set status(e){d(a(this,A),e)}get url(){return f(a(this,R))}set url(e){d(a(this,R),e)}},_=new WeakMap,w=new WeakMap,m=new WeakMap,v=new WeakMap,p=new WeakMap,y=new WeakMap,A=new WeakMap,R=new WeakMap,P),O=new(V=class{constructor(){c(this,S,u(null))}get current(){return f(a(this,S))}set current(e){d(a(this,S),e)}},S=new WeakMap,V),T=new(j=class{constructor(){c(this,k,u(!1))}get current(){return f(a(this,k))}set current(e){d(a(this,k),e)}},k=new WeakMap,j),z.v=()=>T.current=!0);function Ee(t){Object.assign(E,t)}export{ge as H,be as N,he as P,de as S,pe as a,J as b,Ae as c,ie as d,oe as e,me as f,ve as g,se as h,Q as i,N as j,ae as k,ue as l,ce as m,O as n,Y as o,E as p,le as q,_e as r,we as s,fe as t,ye as u,Ee as v,Re as w}; diff --git a/apps/dashboard/build/_app/immutable/chunks/DY7cP31Q.js.br b/apps/dashboard/build/_app/immutable/chunks/DY7cP31Q.js.br deleted file mode 100644 index 0c13105..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DY7cP31Q.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/DY7cP31Q.js.gz b/apps/dashboard/build/_app/immutable/chunks/DY7cP31Q.js.gz deleted file mode 100644 index 12b8114..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DY7cP31Q.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/De_e6MzK.js b/apps/dashboard/build/_app/immutable/chunks/De_e6MzK.js deleted file mode 100644 index e63558b..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/De_e6MzK.js +++ /dev/null @@ -1 +0,0 @@ -import{A as y,i as u,H as _,B as o,w as t,C as g,D as i,F as l,G as d,I as p,J as m}from"./CGq8RnJq.js";function C(n,r){let s=null,E=t;var a;if(t){s=p;for(var e=m(document.head);e!==null&&(e.nodeType!==g||e.data!==n);)e=i(e);if(e===null)l(!1);else{var f=i(e);e.remove(),d(f)}}t||(a=document.head.appendChild(y()));try{u(()=>r(a),_|o)}finally{E&&(l(!0),d(s))}}export{C as h}; diff --git a/apps/dashboard/build/_app/immutable/chunks/De_e6MzK.js.br b/apps/dashboard/build/_app/immutable/chunks/De_e6MzK.js.br deleted file mode 100644 index 2580f5c..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/De_e6MzK.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/De_e6MzK.js.gz b/apps/dashboard/build/_app/immutable/chunks/De_e6MzK.js.gz deleted file mode 100644 index a35c8c3..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/De_e6MzK.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/DnDQzBs4.js b/apps/dashboard/build/_app/immutable/chunks/DnDQzBs4.js deleted file mode 100644 index 30a8e3b..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/DnDQzBs4.js +++ /dev/null @@ -1 +0,0 @@ -import"./Bzak7iHL.js";import{p as ge,j as ke,g as a,c,X as _,r as v,s as u,Y as g,a as f,b as he,d as C,u as xe,f as b}from"./CGq8RnJq.js";import{d as we,s as L,b as V,e as De}from"./DAau0uzT.js";import{i as p,b as ee}from"./Ccqjq5DS.js";import{s as j,e as Ae}from"./DqfV0sZu.js";import{s as D}from"./uCQU803Y.js";import{s as ae}from"./HFGAk8XQ.js";import{p as H}from"./DV6OI5iy.js";import{I as S}from"./CKbQrCJw.js";var Ee=b(' '),Ie=b(''),qe=b(''),ze=b(''),Ce=b(''),Le=b(' '),Se=b(''),Te=b(''),Fe=b('
'),Me=b('
');function Ge(te,s){ge(s,!0);let k=H(s,"value",15),K=H(s,"placeholder",3,"Select…"),ne=H(s,"class",3,""),o=C(!1),A=C(void 0),h=C(void 0),i=C(-1),T="",U,x=xe(()=>s.options.find(e=>e.value===k()));function W(e){var t,n;k(e.value),(t=s.onChange)==null||t.call(s,e.value),I(),(n=a(A))==null||n.focus()}function se(){a(o)?I():E()}function E(){u(o,!0),u(i,Math.max(0,s.options.findIndex(e=>e.value===k())),!0),requestAnimationFrame(()=>{var e,t;(t=(e=a(h))==null?void 0:e.querySelectorAll('[role="option"]')[a(i)])==null||t.scrollIntoView({block:"nearest"})})}function I(){u(o,!1),u(i,-1)}function le(e){if(e.key==="ArrowDown"||e.key==="Enter"||e.key===" ")e.preventDefault(),a(o)?X(1):E();else if(e.key==="ArrowUp")e.preventDefault(),a(o)?X(-1):E();else if(e.key==="Escape")I();else if(e.key==="Home"&&a(o))e.preventDefault(),u(i,0);else if(e.key==="End"&&a(o))e.preventDefault(),u(i,s.options.length-1);else if(a(o)&&e.key==="Enter"&&a(i)>=0)e.preventDefault(),W(s.options[a(i)]);else if(e.key.length===1&&/\S/.test(e.key)){a(o)||E(),clearTimeout(U),T+=e.key.toLowerCase(),U=setTimeout(()=>T="",600);const t=s.options.findIndex(n=>n.label.toLowerCase().startsWith(T));t>=0&&u(i,t,!0)}}function X(e){const t=s.options.length;u(i,(a(i)+e+t)%t),requestAnimationFrame(()=>{var n,l;(l=(n=a(h))==null?void 0:n.querySelectorAll('[role="option"]')[a(i)])==null||l.scrollIntoView({block:"nearest"})})}ke(()=>{if(!a(o))return;function e(t){var n,l;!((n=a(A))!=null&&n.contains(t.target))&&!((l=a(h))!=null&&l.contains(t.target))&&I()}return document.addEventListener("click",e,!0),()=>document.removeEventListener("click",e,!0)});var q=Me(),Y=c(q);{var re=e=>{var t=Ee(),n=c(t,!0);v(t),g(()=>L(n,s.label)),f(e,t)};p(Y,e=>{s.label&&e(re)})}var m=_(Y,2);let B;var G=c(m);{var oe=e=>{var t=Ie(),n=c(t);S(n,{get name(){return s.icon},size:15}),v(t),f(e,t)};p(G,e=>{s.icon&&e(oe)})}var z=_(G,2);let J;var N=c(z);{var de=e=>{var t=qe();g(()=>ae(t,`background:${a(x).color??""}`)),f(e,t)};p(N,e=>{var t;(t=a(x))!=null&&t.color&&e(de)})}var ie=_(N);v(z);var F=_(z,2);let O;var ve=c(F);S(ve,{name:"chevron",size:14}),v(F),v(m),ee(m,e=>u(A,e),()=>a(A));var ce=_(m,2);{var ue=e=>{var t=Fe();Ae(t,23,()=>s.options,n=>n.value,(n,l,P)=>{var y=Te();let Q;var R=c(y);{var fe=r=>{var d=ze(),w=c(d);S(w,{get name(){return a(l).icon},size:15}),v(d),f(r,d)};p(R,r=>{a(l).icon&&r(fe)})}var Z=_(R,2);{var be=r=>{var d=Ce();g(()=>ae(d,`background:${a(l).color??""}`)),f(r,d)};p(Z,r=>{a(l).color&&r(be)})}var M=_(Z,2),_e=c(M,!0);v(M);var $=_(M,2);{var me=r=>{var d=Le(),w=c(d,!0);v(d),g(()=>L(w,a(l).badge)),f(r,d)};p($,r=>{a(l).badge!==void 0&&r(me)})}var pe=_($,2);{var ye=r=>{var d=Se(),w=c(d);S(w,{name:"sparkle",size:12}),v(d),f(r,d)};p(pe,r=>{a(l).value===k()&&r(ye)})}v(y),g(()=>{j(y,"aria-selected",a(l).value===k()),Q=D(y,1,"dd-option svelte-1fd3ybn",null,Q,{"dd-active":a(P)===a(i),"dd-selected":a(l).value===k()}),L(_e,a(l).label)}),De("mouseenter",y,()=>u(i,a(P),!0)),V("click",y,()=>W(a(l))),f(n,y)}),v(t),ee(t,n=>u(h,n),()=>a(h)),g(()=>j(t,"aria-label",s.label??K())),f(e,t)};p(ce,e=>{a(o)&&e(ue)})}v(q),g(()=>{D(q,1,`dd ${ne()??""}`,"svelte-1fd3ybn"),B=D(m,1,"dd-trigger svelte-1fd3ybn",null,B,{"dd-open":a(o)}),j(m,"aria-expanded",a(o)),J=D(z,1,"dd-value svelte-1fd3ybn",null,J,{"dd-placeholder":!a(x)}),L(ie,` ${(a(x)?a(x).label:K())??""}`),O=D(F,1,"dd-chevron svelte-1fd3ybn",null,O,{"dd-chevron-open":a(o)})}),V("click",m,se),V("keydown",m,le),f(te,q),he()}we(["click","keydown"]);export{Ge as D}; diff --git a/apps/dashboard/build/_app/immutable/chunks/DnDQzBs4.js.br b/apps/dashboard/build/_app/immutable/chunks/DnDQzBs4.js.br deleted file mode 100644 index f301287..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DnDQzBs4.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/DnDQzBs4.js.gz b/apps/dashboard/build/_app/immutable/chunks/DnDQzBs4.js.gz deleted file mode 100644 index e26df06..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DnDQzBs4.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/Dp1pzeXC.js b/apps/dashboard/build/_app/immutable/chunks/Dp1pzeXC.js deleted file mode 100644 index 287a815..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/Dp1pzeXC.js +++ /dev/null @@ -1 +0,0 @@ -const y="modulepreload",w=function(f,a){return new URL(f,a).href},E={},g=function(a,u,d){let h=Promise.resolve();if(u&&u.length>0){let s=function(e){return Promise.all(e.map(r=>Promise.resolve(r).then(l=>({status:"fulfilled",value:l}),l=>({status:"rejected",reason:l}))))};const t=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),v=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));h=s(u.map(e=>{if(e=w(e,d),e in E)return;E[e]=!0;const r=e.endsWith(".css"),l=r?'[rel="stylesheet"]':"";if(!!d)for(let i=t.length-1;i>=0;i--){const c=t[i];if(c.href===e&&(!r||c.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${e}"]${l}`))return;const n=document.createElement("link");if(n.rel=r?"stylesheet":y,r||(n.as="script"),n.crossOrigin="",n.href=e,v&&n.setAttribute("nonce",v),document.head.appendChild(n),r)return new Promise((i,c)=>{n.addEventListener("load",i),n.addEventListener("error",()=>c(new Error(`Unable to preload CSS for ${e}`)))})}))}function m(s){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=s,window.dispatchEvent(t),!t.defaultPrevented)throw s}return h.then(s=>{for(const t of s||[])t.status==="rejected"&&m(t.reason);return a().catch(m)})};export{g as _}; diff --git a/apps/dashboard/build/_app/immutable/chunks/Dp1pzeXC.js.br b/apps/dashboard/build/_app/immutable/chunks/Dp1pzeXC.js.br deleted file mode 100644 index 8835f5a..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/Dp1pzeXC.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/Dp1pzeXC.js.gz b/apps/dashboard/build/_app/immutable/chunks/Dp1pzeXC.js.gz deleted file mode 100644 index 4f6661e..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/Dp1pzeXC.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/DqfV0sZu.js b/apps/dashboard/build/_app/immutable/chunks/DqfV0sZu.js deleted file mode 100644 index 17d97b6..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/DqfV0sZu.js +++ /dev/null @@ -1 +0,0 @@ -import{A as F,i as le,ah as ne,w as m,G as y,J as oe,ai as ue,g as W,aj as te,ak as ve,al as Z,F as z,I as b,C as ce,am as de,an as $,m as _e,ao as T,N as q,ap as pe,P as he,ac as ge,n as Ee,aq as K,ar as Ae,as as Te,_ as Ne,at as j,au as me,K as fe,M as ie,av as B,aw as se,ax as Ie,ay as Se,az as Ce,L as we,D as Me,aA as ke,aB as Le,aC as xe,aD as He,aE as Re,aF as De}from"./CGq8RnJq.js";function Ue(e,a){return a}function Oe(e,a,n){for(var u=[],t=a.length,o,l=a.length,_=0;_{if(o){if(o.pending.delete(E),o.done.add(E),o.pending.size===0){var v=e.outrogroups;G(K(o.done)),v.delete(o),v.size===0&&(e.outrogroups=null)}}else l-=1},!1)}if(l===0){var s=u.length===0&&n!==null;if(s){var c=n,f=c.parentNode;Ce(f),f.append(c),e.items.clear()}G(a,!s)}else o={pending:new Set(a),done:new Set},(e.outrogroups??(e.outrogroups=new Set)).add(o)}function G(e,a=!0){for(var n=0;n{var i=n();return Ee(i)?i:i==null?[]:K(i)}),v,d=!0;function I(){r.fallback=f,be(r,v,l,a,u),f!==null&&(v.length===0?(f.f&T)===0?fe(f):(f.f^=T,R(f,null,l)):ie(f,()=>{f=null}))}var w=le(()=>{v=W(E);var i=v.length;let M=!1;if(m){var k=te(l)===ve;k!==(i===0)&&(l=Z(),y(l),z(!1),M=!0)}for(var h=new Set,S=_e,L=he(),p=0;po(l)):(f=q(()=>o(ee??(ee=F()))),f.f|=T)),i>h.size&&pe(),m&&i>0&&y(Z()),!d)if(L){for(const[D,O]of _)h.has(D)||S.skip_effect(O.e);S.oncommit(I),S.ondiscard(()=>{})}else I();M&&z(!0),W(E)}),r={effect:w,items:_,outrogroups:null,fallback:f};d=!1,m&&(l=b)}function H(e){for(;e!==null&&(e.f&Ie)===0;)e=e.next;return e}function be(e,a,n,u,t){var g,D,O,U,Y,P,V,X,J;var o=(u&Se)!==0,l=a.length,_=e.items,s=H(e.effect.first),c,f=null,E,v=[],d=[],I,w,r,i;if(o)for(i=0;i0){var x=(u&ne)!==0&&l===0?n:null;if(o){for(i=0;i{var A,Q;if(E!==void 0)for(r of E)(Q=(A=r.nodes)==null?void 0:A.a)==null||Q.apply()})}function Fe(e,a,n,u,t,o,l,_){var s=(l&Ae)!==0?(l&Te)===0?Ne(n,!1,!1):j(n):null,c=(l&me)!==0?j(t):null;return{v:s,i:c,e:q(()=>(o(a,s??n,c??t,_),()=>{e.delete(u)}))}}function R(e,a,n){if(e.nodes)for(var u=e.nodes.start,t=e.nodes.end,o=a&&(a.f&T)===0?a.nodes.start:n;u!==null;){var l=Me(u);if(o.before(u),u===t)return;u=l}}function N(e,a,n){a===null?e.effect.first=n:a.next=n,n===null?e.effect.last=a:n.prev=a}const ye=Symbol("is custom element"),ze=Symbol("is html"),Be=He?"link":"LINK";function Pe(e){if(m){var a=!1,n=()=>{if(!a){if(a=!0,e.hasAttribute("value")){var u=e.value;re(e,"value",null),e.value=u}if(e.hasAttribute("checked")){var t=e.checked;re(e,"checked",null),e.checked=t}}};e.__on_r=n,se(n),Re()}}function re(e,a,n,u){var t=qe(e);m&&(t[a]=e.getAttribute(a),a==="src"||a==="srcset"||a==="href"&&e.nodeName===Be)||t[a]!==(t[a]=n)&&(a==="loading"&&(e[De]=n),n==null?e.removeAttribute(a):typeof n!="string"&&Ge(e).includes(a)?e[a]=n:e.setAttribute(a,n))}function qe(e){return e.__attributes??(e.__attributes={[ye]:e.nodeName.includes("-"),[ze]:e.namespaceURI===ke})}var ae=new Map;function Ge(e){var a=e.getAttribute("is")||e.nodeName,n=ae.get(a);if(n)return n;ae.set(a,n=[]);for(var u,t=e,o=Element.prototype;o!==t;){u=xe(t);for(var l in u)u[l].set&&n.push(l);t=Le(t)}return n}export{Ye as e,Ue as i,Pe as r,re as s}; diff --git a/apps/dashboard/build/_app/immutable/chunks/DqfV0sZu.js.br b/apps/dashboard/build/_app/immutable/chunks/DqfV0sZu.js.br deleted file mode 100644 index f412758..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DqfV0sZu.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/DqfV0sZu.js.gz b/apps/dashboard/build/_app/immutable/chunks/DqfV0sZu.js.gz deleted file mode 100644 index 6c3ee6d..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/DqfV0sZu.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/HFGAk8XQ.js b/apps/dashboard/build/_app/immutable/chunks/HFGAk8XQ.js deleted file mode 100644 index 2ba0161..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/HFGAk8XQ.js +++ /dev/null @@ -1 +0,0 @@ -import{t as b}from"./uCQU803Y.js";import{w as c}from"./CGq8RnJq.js";function A(i,u={},r,f){for(var a in r){var o=r[a];u[a]!==o&&(r[a]==null?i.style.removeProperty(a):i.style.setProperty(a,o,f))}}function P(i,u,r,f){var a=i.__style;if(c||a!==u){var o=b(u,f);(!c||o!==i.getAttribute("style"))&&(o==null?i.removeAttribute("style"):i.style.cssText=o),i.__style=u}else f&&(Array.isArray(f)?(A(i,r==null?void 0:r[0],f[0]),A(i,r==null?void 0:r[1],f[1],"important")):A(i,r,f));return f}export{P as s}; diff --git a/apps/dashboard/build/_app/immutable/chunks/HFGAk8XQ.js.br b/apps/dashboard/build/_app/immutable/chunks/HFGAk8XQ.js.br deleted file mode 100644 index 47551e2..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/HFGAk8XQ.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/HFGAk8XQ.js.gz b/apps/dashboard/build/_app/immutable/chunks/HFGAk8XQ.js.gz deleted file mode 100644 index f7fb213..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/HFGAk8XQ.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/W8qDZJD6.js b/apps/dashboard/build/_app/immutable/chunks/W8qDZJD6.js deleted file mode 100644 index 2d8fed7..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/W8qDZJD6.js +++ /dev/null @@ -1 +0,0 @@ -var D=Object.defineProperty;var g=i=>{throw TypeError(i)};var F=(i,e,s)=>e in i?D(i,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[e]=s;var w=(i,e,s)=>F(i,typeof e!="symbol"?e+"":e,s),M=(i,e,s)=>e.has(i)||g("Cannot "+s);var t=(i,e,s)=>(M(i,e,"read from private field"),s?s.call(i):e.get(i)),l=(i,e,s)=>e.has(i)?g("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,s),y=(i,e,s,a)=>(M(i,e,"write to private field"),a?a.call(i,s):e.set(i,s),s);import{m as A,K as C,L as k,M as I,A as x,N as B,w as K,I as L,O as N,P as O}from"./CGq8RnJq.js";var r,n,h,u,p,_,v;class j{constructor(e,s=!0){w(this,"anchor");l(this,r,new Map);l(this,n,new Map);l(this,h,new Map);l(this,u,new Set);l(this,p,!0);l(this,_,()=>{var e=A;if(t(this,r).has(e)){var s=t(this,r).get(e),a=t(this,n).get(s);if(a)C(a),t(this,u).delete(s);else{var c=t(this,h).get(s);c&&(t(this,n).set(s,c.effect),t(this,h).delete(s),c.fragment.lastChild.remove(),this.anchor.before(c.fragment),a=c.effect)}for(const[f,o]of t(this,r)){if(t(this,r).delete(f),f===e)break;const d=t(this,h).get(o);d&&(k(d.effect),t(this,h).delete(o))}for(const[f,o]of t(this,n)){if(f===s||t(this,u).has(f))continue;const d=()=>{if(Array.from(t(this,r).values()).includes(f)){var b=document.createDocumentFragment();N(o,b),b.append(x()),t(this,h).set(f,{effect:o,fragment:b})}else k(o);t(this,u).delete(f),t(this,n).delete(f)};t(this,p)||!a?(t(this,u).add(f),I(o,d,!1)):d()}}});l(this,v,e=>{t(this,r).delete(e);const s=Array.from(t(this,r).values());for(const[a,c]of t(this,h))s.includes(a)||(k(c.effect),t(this,h).delete(a))});this.anchor=e,y(this,p,s)}ensure(e,s){var a=A,c=O();if(s&&!t(this,n).has(e)&&!t(this,h).has(e))if(c){var f=document.createDocumentFragment(),o=x();f.append(o),t(this,h).set(e,{effect:B(()=>s(o)),fragment:f})}else t(this,n).set(e,B(()=>s(this.anchor)));if(t(this,r).set(a,e),c){for(const[d,m]of t(this,n))d===e?a.unskip_effect(m):a.skip_effect(m);for(const[d,m]of t(this,h))d===e?a.unskip_effect(m.effect):a.skip_effect(m.effect);a.oncommit(t(this,_)),a.ondiscard(t(this,v))}else K&&(this.anchor=L),t(this,_).call(this)}}r=new WeakMap,n=new WeakMap,h=new WeakMap,u=new WeakMap,p=new WeakMap,_=new WeakMap,v=new WeakMap;export{j as B}; diff --git a/apps/dashboard/build/_app/immutable/chunks/W8qDZJD6.js.br b/apps/dashboard/build/_app/immutable/chunks/W8qDZJD6.js.br deleted file mode 100644 index 360c554..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/W8qDZJD6.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/W8qDZJD6.js.gz b/apps/dashboard/build/_app/immutable/chunks/W8qDZJD6.js.gz deleted file mode 100644 index cc2b590..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/W8qDZJD6.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/kcrnba3G.js b/apps/dashboard/build/_app/immutable/chunks/kcrnba3G.js deleted file mode 100644 index aada27e..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/kcrnba3G.js +++ /dev/null @@ -1,2 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CkiUhdKe.js","./Bo4EDkTQ.js","./CGq8RnJq.js","./W8qDZJD6.js","./Bzak7iHL.js","./DAau0uzT.js","./Ccqjq5DS.js","./DqfV0sZu.js","./uCQU803Y.js","./DGM4cicq.js","./DV6OI5iy.js","./D35IQVqe.js","./Ch9vNiEl.js","./DY7cP31Q.js","./HFGAk8XQ.js","./BMB5u1EX.js","../assets/cognitive-palette.BALpZUFZ.css","./BKh9s_e0.js","./CcUbQ_Wl.js","../assets/ObservatoryStage.CKoSQgn0.css","./Cqk6fVmx.js","./yYBa834L.js","./C2CaJvaA.js"])))=>i.map(i=>d[i]); -var x=Object.defineProperty;var C=(m,t,e)=>t in m?x(m,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):m[t]=e;var i=(m,t,e)=>C(m,typeof t!="symbol"?t+"":t,e);import{_ as d}from"./Dp1pzeXC.js";import{V as p,M as w,a as T}from"./Bo4EDkTQ.js";const f=new p(0,0,0),R=30,l=44;function S(){return typeof navigator<"u"&&"gpu"in navigator}class V{constructor(t){i(this,"container");i(this,"deps");i(this,"renderer");i(this,"scene");i(this,"camera");i(this,"storm");i(this,"post",null);i(this,"booted",!1);i(this,"target",new p(0,0,0));i(this,"flythrough",0);i(this,"prevCamPos",new p);i(this,"camVel",new p);this.container=t}get cameraRef(){return this.camera}async boot(){if(this.booted)return;if(!S())throw new Error("WebGPU not supported");const t=await d(()=>import("./CkiUhdKe.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),import.meta.url),e=await d(()=>import("./Cqk6fVmx.js"),__vite__mapDeps([20,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),import.meta.url),s=await d(()=>import("./yYBa834L.js"),__vite__mapDeps([21,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]),import.meta.url),{SemanticComputeStorm:a}=await d(async()=>{const{SemanticComputeStorm:n}=await import("./C2CaJvaA.js");return{SemanticComputeStorm:n}},__vite__mapDeps([22,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]),import.meta.url);if(this.deps={WebGPURenderer:t.WebGPURenderer,PostProcessing:t.PostProcessing,StormCtor:a,tsl:e,bloomMod:s},!t.WebGPURenderer||!t.Scene||!t.PerspectiveCamera||!t.Color)throw new Error("[cinema] three/webgpu is missing expected exports");const h=Math.max(1,this.container.clientWidth),c=Math.max(1,this.container.clientHeight);this.scene=new t.Scene,this.scene.background=new t.Color(131594),this.camera=new t.PerspectiveCamera(60,h/c,.1,2e3),this.camera.position.set(0,18,60);const o=new this.deps.WebGPURenderer({antialias:!0,alpha:!1});o.setPixelRatio(Math.min(window.devicePixelRatio,2)),o.setSize(h,c),await o.init(),this.container.appendChild(o.domElement),this.renderer=o,this.storm=new this.deps.StormCtor(o,this.scene,{});try{const{pass:n,mrt:b,output:g,emissive:_}=this.deps.tsl,r=n(this.scene,this.camera);if(typeof(r==null?void 0:r.setMRT)!="function"||typeof(r==null?void 0:r.getTextureNode)!="function")throw new Error("three/tsl pass() API mismatch — setMRT/getTextureNode missing");r.setMRT(b({output:g,emissive:_}));const M=r.getTextureNode("output"),P=r.getTextureNode("emissive"),v=this.deps.bloomMod.bloom(P,.6,.65,.35),u=new this.deps.PostProcessing(o);u.outputNode=M.add(v),this.post=u}catch(n){console.warn("[cinema] selective bloom unavailable, rendering without MRT:",n),this.post=null}this.booted=!0}transitionTo(t,e,s="II",a=99){this.booted&&this.storm.transitionTo(t,f,s,a)}dreamBeat(){this.booted&&this.storm.dreamBeat()}setFlythrough(t){this.flythrough=w.clamp(t,0,1),this.booted&&this.storm.setStreak(t)}setStreak(t){this.booted&&this.storm.setStreak(t)}setCameraVel(t){this.booted&&this.storm.setCameraVel(t)}async render(t){if(!this.booted)return;this.camVel.copy(this.camera.position).sub(this.prevCamPos).divideScalar(Math.max(t,.001)),this.prevCamPos.copy(this.camera.position);const e=w.lerp(R,6,this.flythrough),s=this.camera.position.length();if(sl||!Number.isFinite(s)){const n=Math.min(l,Math.max(e,s||l));s>.001?this.camera.position.setLength(n):this.camera.position.set(0,12,n)}this.camera.lookAt(f);const a=this.camVel.clone().applyMatrix3(new T().setFromMatrix4(this.camera.matrixWorldInverse)).negate();this.storm.setCameraVel(a);const h=this.camera.position.length(),c=this.camera.fov*Math.PI/180,o=Math.tan(c/2)*h*.82;this.storm.setContainRadius(o),await this.storm.update(t),this.post?await this.post.renderAsync():await this.renderer.renderAsync(this.scene,this.camera)}resize(){if(!this.booted)return;const t=Math.max(1,this.container.clientWidth),e=Math.max(1,this.container.clientHeight);this.camera.aspect=t/e,this.camera.updateProjectionMatrix(),this.renderer.setSize(t,e)}dispose(){var t,e,s,a,h;this.booted&&((t=this.storm)==null||t.dispose(),(s=(e=this.renderer)==null?void 0:e.dispose)==null||s.call(e),(h=(a=this.renderer)==null?void 0:a.domElement)!=null&&h.parentNode&&this.renderer.domElement.parentNode.removeChild(this.renderer.domElement),this.booted=!1)}}export{V as CinemaSandbox,S as isWebGPUSupported}; diff --git a/apps/dashboard/build/_app/immutable/chunks/kcrnba3G.js.br b/apps/dashboard/build/_app/immutable/chunks/kcrnba3G.js.br deleted file mode 100644 index f7214fa..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/kcrnba3G.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/kcrnba3G.js.gz b/apps/dashboard/build/_app/immutable/chunks/kcrnba3G.js.gz deleted file mode 100644 index 3574681..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/kcrnba3G.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/uCQU803Y.js b/apps/dashboard/build/_app/immutable/chunks/uCQU803Y.js deleted file mode 100644 index df21741..0000000 --- a/apps/dashboard/build/_app/immutable/chunks/uCQU803Y.js +++ /dev/null @@ -1,2 +0,0 @@ -import{w as A}from"./CGq8RnJq.js";function O(r){var t,i,f="";if(typeof r=="string"||typeof r=="number")f+=r;else if(typeof r=="object")if(Array.isArray(r)){var u=r.length;for(t=0;t=0;){var l=o+g;(o===0||h.includes(f[o-1]))&&(l===f.length||h.includes(f[l]))?f=(o===0?"":f.substring(0,o))+f.substring(l+1):o=l}}return f===""?null:f}function j(r,t=!1){var i=t?" !important;":";",f="";for(var u of Object.keys(r)){var g=r[u];g!=null&&g!==""&&(f+=" "+u+": "+g+i)}return f}function p(r){return r[0]!=="-"||r[1]!=="-"?r.toLowerCase():r}function z(r,t){if(t){var i="",f,u;if(Array.isArray(t)?(f=t[0],u=t[1]):f=t,r){r=String(r).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var g=!1,o=0,l=!1,c=[];f&&c.push(...Object.keys(f).map(p)),u&&c.push(...Object.keys(u).map(p));var a=0,s=-1;const v=r.length;for(var n=0;n{const a=this.inputNode,l=j(a.rgb),d=q(this.threshold,this.threshold.add(this.smoothWidth),l);return H(m(0),a,d)});this._highPassFilterMaterial=this._highPassFilterMaterial||new f,this._highPassFilterMaterial.fragmentNode=t().context(r.getSharedContext()),this._highPassFilterMaterial.name="Bloom_highPass",this._highPassFilterMaterial.needsUpdate=!0;const i=[3,5,7,9,11];for(let a=0;a{const d=b(1.2).sub(a);return H(a,d,l)}).setLayout({name:"lerpBloomFactor",type:"float",inputs:[{name:"factor",type:"float"},{name:"radius",type:"float"}]}),u=B(()=>{const a=o(s.element(0),this.radius).mul(m(e.element(0),1)).mul(this._textureNodeBlur0),l=o(s.element(1),this.radius).mul(m(e.element(1),1)).mul(this._textureNodeBlur1),d=o(s.element(2),this.radius).mul(m(e.element(2),1)).mul(this._textureNodeBlur2),h=o(s.element(3),this.radius).mul(m(e.element(3),1)).mul(this._textureNodeBlur3),n=o(s.element(4),this.radius).mul(m(e.element(4),1)).mul(this._textureNodeBlur4);return a.add(l).add(d).add(h).add(n).mul(this.strength)});return this._compositeMaterial=this._compositeMaterial||new f,this._compositeMaterial.fragmentNode=u().context(r.getSharedContext()),this._compositeMaterial.name="Bloom_comp",this._compositeMaterial.needsUpdate=!0,this._textureOutput}dispose(){for(let r=0;rs.sample(n),d=B(()=>{const n=e.element(0).toVar(),T=l(a).rgb.mul(n).toVar();return Q({start:U(1),end:U(t),type:"int",condition:"<"},({i:V})=>{const R=b(V),v=e.element(V),y=u.mul(o).mul(R),A=l(a.add(y)).rgb,C=l(a.sub(y)).rgb;T.addAssign(X(A,C).mul(v)),n.addAssign(b(2).mul(v))}),m(T.div(n),1)}),h=new f;return h.fragmentNode=d().context(r.getSharedContext()),h.name="Bloom_separable",h.needsUpdate=!0,h.colorTexture=s,h.direction=u,h.invSize=o,h}}const k=(S,r,t,i)=>P(new J(P(S),r,t,i));export{k as bloom,J as default}; diff --git a/apps/dashboard/build/_app/immutable/chunks/yYBa834L.js.br b/apps/dashboard/build/_app/immutable/chunks/yYBa834L.js.br deleted file mode 100644 index 8465f3f..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/yYBa834L.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/chunks/yYBa834L.js.gz b/apps/dashboard/build/_app/immutable/chunks/yYBa834L.js.gz deleted file mode 100644 index 91b9b4f..0000000 Binary files a/apps/dashboard/build/_app/immutable/chunks/yYBa834L.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/entry/app.BYOyN8KT.js b/apps/dashboard/build/_app/immutable/entry/app.BYOyN8KT.js deleted file mode 100644 index bed8d23..0000000 --- a/apps/dashboard/build/_app/immutable/entry/app.BYOyN8KT.js +++ /dev/null @@ -1,2 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../nodes/0.CcZXq7cA.js","../chunks/Bzak7iHL.js","../chunks/DAau0uzT.js","../chunks/CGq8RnJq.js","../chunks/Ccqjq5DS.js","../chunks/W8qDZJD6.js","../chunks/DqfV0sZu.js","../chunks/BbCqB9Us.js","../chunks/uCQU803Y.js","../chunks/DGM4cicq.js","../chunks/DV6OI5iy.js","../chunks/CbBCXwzm.js","../chunks/DJDK-KWF.js","../chunks/DY7cP31Q.js","../chunks/Ch9vNiEl.js","../chunks/BfiOPhbz.js","../chunks/HFGAk8XQ.js","../chunks/CcUbQ_Wl.js","../chunks/D35IQVqe.js","../chunks/CKbQrCJw.js","../assets/Icon.tTjeJXhC.css","../assets/0.CLR80qKm.css","../nodes/1.8UKMSR8s.js","../nodes/2.zvt29sR6.js","../nodes/3.C6cru0cW.js","../nodes/4.CIxbWFkr.js","../chunks/BMB5u1EX.js","../assets/cognitive-palette.BALpZUFZ.css","../chunks/D7ozXiSB.js","../nodes/5.XKzsmb3Z.js","../chunks/De_e6MzK.js","../chunks/BpEKQwpr.js","../chunks/DETSv_kY.js","../nodes/6.CNes4HHG.js","../chunks/B9l3DI-J.js","../assets/reveal.Dmxpik8H.css","../assets/6.ksI6gQcB.css","../nodes/7.Cs_QL9bJ.js","../chunks/DnDQzBs4.js","../assets/Dropdown.C2Z-7Phd.css","../assets/7.DQ_AfUnN.css","../nodes/8.DYPUVn-a.js","../nodes/9.Bc6B0Hcn.js","../nodes/10.CMLfe2no.js","../nodes/11.BcR5gOV6.js","../nodes/12.CRVOD7oJ.js","../chunks/Bo4EDkTQ.js","../chunks/BKh9s_e0.js","../assets/ObservatoryStage.CKoSQgn0.css","../chunks/BzfFPM53.js","../chunks/Dp1pzeXC.js","../assets/12.BxoW8Jf1.css","../nodes/13.UdclNjnS.js","../nodes/14.CuNExVd0.js","../nodes/15.D2EVaO6c.js","../nodes/16.BHQZgsg5.js","../nodes/17.DpD2KkS8.js","../nodes/18.DdPknQfI.js","../nodes/19.CLd0kemn.js","../nodes/20.DD0_N4PP.js","../assets/20.Duj1vJUf.css","../nodes/21.yCKOHF-q.js","../nodes/22.kK1AQf2j.js","../nodes/23.B0dVDPB6.js","../nodes/24.taYcndi3.js","../nodes/25.CpxKI_0Q.js","../assets/25.DKhUrxcR.css"])))=>i.map(i=>d[i]); -var z=e=>{throw TypeError(e)};var J=(e,t,r)=>t.has(e)||z("Cannot "+r);var n=(e,t,r)=>(J(e,t,"read from private field"),r?r.call(e):t.get(e)),N=(e,t,r)=>t.has(e)?z("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Y=(e,t,r,_)=>(J(e,t,"write to private field"),_?_.call(e,r):t.set(e,r),r);import{_ as a}from"../chunks/Dp1pzeXC.js";import{w as K,ai as nt,i as mt,E as ut,aj as ct,al as dt,G as lt,F as Q,aG as pt,I as ft,s as S,ae as vt,g as f,aR as Et,a0 as ht,_ as gt,p as Pt,R as Rt,j as Ot,x as Tt,aH as R,X as At,a as v,b as yt,d as B,aS as y,c as It,r as Dt,f as U,u as L,aT as Lt,Y as Vt}from"../chunks/CGq8RnJq.js";import{h as bt,m as xt,u as wt,o as jt,s as kt}from"../chunks/DAau0uzT.js";import"../chunks/Bzak7iHL.js";import{i as j,b as V}from"../chunks/Ccqjq5DS.js";import{B as St}from"../chunks/W8qDZJD6.js";import{p as k}from"../chunks/DV6OI5iy.js";function b(e,t,r){var _;K&&(_=ft,nt());var i=new St(e);mt(()=>{var m=t()??null;if(K){var o=ct(_),s=o===pt,d=m!==null;if(s!==d){var x=dt();lt(x),i.anchor=x,Q(!1),i.ensure(m,m&&(O=>r(O,m))),Q(!0);return}}i.ensure(m,m&&(O=>r(O,m)))},ut)}function Ct(e){return class extends Ft{constructor(t){super({component:e,...t})}}}var E,c;class Ft{constructor(t){N(this,E);N(this,c);var m;var r=new Map,_=(o,s)=>{var d=gt(s,!1,!1);return r.set(o,d),d};const i=new Proxy({...t.props||{},$$events:{}},{get(o,s){return f(r.get(s)??_(s,Reflect.get(o,s)))},has(o,s){return s===vt?!0:(f(r.get(s)??_(s,Reflect.get(o,s))),Reflect.has(o,s))},set(o,s,d){return S(r.get(s)??_(s,d),d),Reflect.set(o,s,d)}});Y(this,c,(t.hydrate?bt:xt)(t.component,{target:t.target,anchor:t.anchor,props:i,context:t.context,intro:t.intro??!1,recover:t.recover,transformError:t.transformError})),(!((m=t==null?void 0:t.props)!=null&&m.$$host)||t.sync===!1)&&Et(),Y(this,E,i.$$events);for(const o of Object.keys(n(this,c)))o==="$set"||o==="$destroy"||o==="$on"||ht(this,o,{get(){return n(this,c)[o]},set(s){n(this,c)[o]=s},enumerable:!0});n(this,c).$set=o=>{Object.assign(i,o)},n(this,c).$destroy=()=>{wt(n(this,c))}}$set(t){n(this,c).$set(t)}$on(t,r){n(this,E)[t]=n(this,E)[t]||[];const _=(...i)=>r.call(this,...i);return n(this,E)[t].push(_),()=>{n(this,E)[t]=n(this,E)[t].filter(i=>i!==_)}}$destroy(){n(this,c).$destroy()}}E=new WeakMap,c=new WeakMap;const Zt={};var Gt=U('
'),Mt=U(" ",1);function Nt(e,t){Pt(t,!0);let r=k(t,"components",23,()=>[]),_=k(t,"data_0",3,null),i=k(t,"data_1",3,null),m=k(t,"data_2",3,null);Rt(()=>t.stores.page.set(t.page)),Ot(()=>{t.stores,t.page,t.constructors,r(),t.form,_(),i(),m(),t.stores.page.notify()});let o=B(!1),s=B(!1),d=B(null);jt(()=>{const u=t.stores.page.subscribe(()=>{f(o)&&(S(s,!0),Tt().then(()=>{S(d,document.title||"untitled page",!0)}))});return S(o,!0),u});const x=L(()=>t.constructors[2]);var O=Mt(),H=R(O);{var Z=u=>{const h=L(()=>t.constructors[0]);var g=y(),I=R(g);b(I,()=>f(h),(P,T)=>{V(T(P,{get data(){return _()},get form(){return t.form},get params(){return t.page.params},children:(l,Bt)=>{var X=y(),et=R(X);{var at=A=>{const C=L(()=>t.constructors[1]);var D=y(),F=R(D);b(F,()=>f(C),(G,M)=>{V(M(G,{get data(){return i()},get form(){return t.form},get params(){return t.page.params},children:(p,Ht)=>{var q=y(),st=R(q);b(st,()=>f(x),(_t,it)=>{V(it(_t,{get data(){return m()},get form(){return t.form},get params(){return t.page.params}}),w=>r()[2]=w,()=>{var w;return(w=r())==null?void 0:w[2]})}),v(p,q)},$$slots:{default:!0}}),p=>r()[1]=p,()=>{var p;return(p=r())==null?void 0:p[1]})}),v(A,D)},ot=A=>{const C=L(()=>t.constructors[1]);var D=y(),F=R(D);b(F,()=>f(C),(G,M)=>{V(M(G,{get data(){return i()},get form(){return t.form},get params(){return t.page.params}}),p=>r()[1]=p,()=>{var p;return(p=r())==null?void 0:p[1]})}),v(A,D)};j(et,A=>{t.constructors[2]?A(at):A(ot,!1)})}v(l,X)},$$slots:{default:!0}}),l=>r()[0]=l,()=>{var l;return(l=r())==null?void 0:l[0]})}),v(u,g)},$=u=>{const h=L(()=>t.constructors[0]);var g=y(),I=R(g);b(I,()=>f(h),(P,T)=>{V(T(P,{get data(){return _()},get form(){return t.form},get params(){return t.page.params}}),l=>r()[0]=l,()=>{var l;return(l=r())==null?void 0:l[0]})}),v(u,g)};j(H,u=>{t.constructors[1]?u(Z):u($,!1)})}var tt=At(H,2);{var rt=u=>{var h=Gt(),g=It(h);{var I=P=>{var T=Lt();Vt(()=>kt(T,f(d))),v(P,T)};j(g,P=>{f(s)&&P(I)})}Dt(h),v(u,h)};j(tt,u=>{f(o)&&u(rt)})}v(e,O),yt()}const $t=Ct(Nt),tr=[()=>a(()=>import("../nodes/0.CcZXq7cA.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]),import.meta.url),()=>a(()=>import("../nodes/1.8UKMSR8s.js"),__vite__mapDeps([22,1,15,3,2,13,12]),import.meta.url),()=>a(()=>import("../nodes/2.zvt29sR6.js"),__vite__mapDeps([23,1,3,7,5]),import.meta.url),()=>a(()=>import("../nodes/3.C6cru0cW.js"),__vite__mapDeps([24,1,15,3,2,12,13]),import.meta.url),()=>a(()=>import("../nodes/4.CIxbWFkr.js"),__vite__mapDeps([25,1,2,3,4,5,26,10,27,28,13]),import.meta.url),()=>a(()=>import("../nodes/5.XKzsmb3Z.js"),__vite__mapDeps([29,1,2,3,30,11,12,13,18,31,8,4,5,10,26,27,28,32]),import.meta.url),()=>a(()=>import("../nodes/6.CNes4HHG.js"),__vite__mapDeps([33,1,2,3,4,5,6,34,7,8,10,19,20,35,16,9,12,13,18,14,31,11,26,27,28,32,36]),import.meta.url),()=>a(()=>import("../nodes/7.Cs_QL9bJ.js"),__vite__mapDeps([37,1,2,3,4,5,6,34,7,8,10,19,20,35,16,38,39,31,12,13,11,26,27,28,32,18,14,40]),import.meta.url),()=>a(()=>import("../nodes/8.DYPUVn-a.js"),__vite__mapDeps([41,1,2,3,30,31,8,4,5,10,12,13,11,26,27,28,32,18]),import.meta.url),()=>a(()=>import("../nodes/9.Bc6B0Hcn.js"),__vite__mapDeps([42,1,2,3,4,5,6,34,7,8,10,19,20,35,9,16,17,31,12,13,11,26,27,28,18]),import.meta.url),()=>a(()=>import("../nodes/10.CMLfe2no.js"),__vite__mapDeps([43,1,2,3,30,4,5,12,13,18,26,10,27,28,32]),import.meta.url),()=>a(()=>import("../nodes/11.BcR5gOV6.js"),__vite__mapDeps([44,1,3,30,10,2,14,31,8,4,5,12,13,11,26,27,28,32]),import.meta.url),()=>a(()=>import("../nodes/12.CRVOD7oJ.js"),__vite__mapDeps([45,1,2,3,4,5,46,6,8,9,10,18,14,13,16,26,27,47,17,48,49,15,50,19,20,38,39,32,51]),import.meta.url),()=>a(()=>import("../nodes/13.UdclNjnS.js"),__vite__mapDeps([52,1,2,3,30,4,5,26,10,27,18,28,13,32]),import.meta.url),()=>a(()=>import("../nodes/14.CuNExVd0.js"),__vite__mapDeps([53,1,2,3,30,18,31,8,4,5,10,12,13,11,26,27,28,32]),import.meta.url),()=>a(()=>import("../nodes/15.D2EVaO6c.js"),__vite__mapDeps([54,1,2,3,30,4,5,26,10,27,18,28,13,32]),import.meta.url),()=>a(()=>import("../nodes/16.BHQZgsg5.js"),__vite__mapDeps([55,1,2,3,30,10,18,14,31,8,4,5,12,13,11,26,27,28,32]),import.meta.url),()=>a(()=>import("../nodes/17.DpD2KkS8.js"),__vite__mapDeps([56,1,2,3,46,5,4,6,8,9,10,18,14,13,16,26,27,47,17,48,30,12,28,32]),import.meta.url),()=>a(()=>import("../nodes/18.DdPknQfI.js"),__vite__mapDeps([57,1,2,3,30,4,5,12,13,26,10,27,47,28]),import.meta.url),()=>a(()=>import("../nodes/19.CLd0kemn.js"),__vite__mapDeps([58,1,2,3,30,31,8,4,5,10,12,13,11,26,27,28,18,32]),import.meta.url),()=>a(()=>import("../nodes/20.DD0_N4PP.js"),__vite__mapDeps([59,1,2,3,4,5,6,30,9,18,31,8,10,12,13,11,26,27,28,32,60]),import.meta.url),()=>a(()=>import("../nodes/21.yCKOHF-q.js"),__vite__mapDeps([61,1,2,3,31,8,4,5,10,12,13,11,26,27,28,18,32]),import.meta.url),()=>a(()=>import("../nodes/22.kK1AQf2j.js"),__vite__mapDeps([62,1,2,3,10,31,8,4,5,12,13,11,26,27,28,32,18,14]),import.meta.url),()=>a(()=>import("../nodes/23.B0dVDPB6.js"),__vite__mapDeps([63,1,2,3,31,8,4,5,10,12,13,11,26,27,28,32,18]),import.meta.url),()=>a(()=>import("../nodes/24.taYcndi3.js"),__vite__mapDeps([64,1,2,3,30,18,26,4,5,10,27,28,13,31,8,12,11]),import.meta.url),()=>a(()=>import("../nodes/25.CpxKI_0Q.js"),__vite__mapDeps([65,1,2,3,4,5,6,30,8,16,9,49,13,66]),import.meta.url)],rr=[],er={"/":[3],"/(app)/_msdftest":[4,[2]],"/(app)/activation":[5,[2]],"/(app)/blackbox":[6,[2]],"/(app)/contradictions":[7,[2]],"/(app)/dreams":[8,[2]],"/(app)/duplicates":[9,[2]],"/(app)/explore":[10,[2]],"/(app)/feed":[11,[2]],"/(app)/graph":[12,[2]],"/(app)/importance":[13,[2]],"/(app)/intentions":[14,[2]],"/(app)/memories":[15,[2]],"/(app)/memory-prs":[16,[2]],"/(app)/observatory":[17,[2]],"/(app)/palace":[18,[2]],"/(app)/patterns":[19,[2]],"/(app)/reasoning":[20,[2]],"/(app)/schedule":[21,[2]],"/(app)/settings":[22,[2]],"/(app)/stats":[23,[2]],"/(app)/timeline":[24,[2]],"/waitlist":[25]},W={handleError:(({error:e})=>{console.error(e)}),reroute:(()=>{}),transport:{}},Yt=Object.fromEntries(Object.entries(W.transport).map(([e,t])=>[e,t.decode])),ar=Object.fromEntries(Object.entries(W.transport).map(([e,t])=>[e,t.encode])),or=!1,sr=(e,t)=>Yt[e](t);export{sr as decode,Yt as decoders,er as dictionary,ar as encoders,or as hash,W as hooks,Zt as matchers,tr as nodes,$t as root,rr as server_loads}; diff --git a/apps/dashboard/build/_app/immutable/entry/app.BYOyN8KT.js.br b/apps/dashboard/build/_app/immutable/entry/app.BYOyN8KT.js.br deleted file mode 100644 index e4ed039..0000000 Binary files a/apps/dashboard/build/_app/immutable/entry/app.BYOyN8KT.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/entry/app.BYOyN8KT.js.gz b/apps/dashboard/build/_app/immutable/entry/app.BYOyN8KT.js.gz deleted file mode 100644 index c714377..0000000 Binary files a/apps/dashboard/build/_app/immutable/entry/app.BYOyN8KT.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/entry/start.DeXDFAvJ.js b/apps/dashboard/build/_app/immutable/entry/start.DeXDFAvJ.js deleted file mode 100644 index 4f5d578..0000000 --- a/apps/dashboard/build/_app/immutable/entry/start.DeXDFAvJ.js +++ /dev/null @@ -1 +0,0 @@ -import{a as r}from"../chunks/DJDK-KWF.js";import{w as t}from"../chunks/DY7cP31Q.js";export{t as load_css,r as start}; diff --git a/apps/dashboard/build/_app/immutable/entry/start.DeXDFAvJ.js.br b/apps/dashboard/build/_app/immutable/entry/start.DeXDFAvJ.js.br deleted file mode 100644 index 060a5bc..0000000 Binary files a/apps/dashboard/build/_app/immutable/entry/start.DeXDFAvJ.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/entry/start.DeXDFAvJ.js.gz b/apps/dashboard/build/_app/immutable/entry/start.DeXDFAvJ.js.gz deleted file mode 100644 index 67fb075..0000000 Binary files a/apps/dashboard/build/_app/immutable/entry/start.DeXDFAvJ.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/0.CcZXq7cA.js b/apps/dashboard/build/_app/immutable/nodes/0.CcZXq7cA.js deleted file mode 100644 index bf3b420..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/0.CcZXq7cA.js +++ /dev/null @@ -1,86 +0,0 @@ -import"../chunks/Bzak7iHL.js";import{s as M,w as at,d as Ue,b as oe,e as Ye,o as st,c as wt,g as ut}from"../chunks/DAau0uzT.js";import{aS as rt,aH as ve,a as b,X as s,c as a,r as t,Y as P,f as w,p as Xe,af as ce,g as e,b as Qe,d as le,e as $t,s as k,u as Y,aT as it}from"../chunks/CGq8RnJq.js";import{i as G,b as Mt}from"../chunks/Ccqjq5DS.js";import{e as Ne,s as Ce,i as Re,r as Ct}from"../chunks/DqfV0sZu.js";import{s as ot}from"../chunks/BbCqB9Us.js";import{s as re}from"../chunks/uCQU803Y.js";import{b as Tt}from"../chunks/DGM4cicq.js";import{a as pe,s as We}from"../chunks/DV6OI5iy.js";import{p as St}from"../chunks/CbBCXwzm.js";import{o as At,g as lt}from"../chunks/DJDK-KWF.js";import{b as ke}from"../chunks/DY7cP31Q.js";import{s as mt,e as ft,c as ht,d as gt,w as dt,u as Et,a as Dt,f as Nt}from"../chunks/Ch9vNiEl.js";import{i as jt}from"../chunks/BfiOPhbz.js";import{s as bt}from"../chunks/HFGAk8XQ.js";import{E as It}from"../chunks/CcUbQ_Wl.js";import{a as qe}from"../chunks/D35IQVqe.js";import{I as Le}from"../chunks/CKbQrCJw.js";var Ft=w('
');function Lt(d){const l=()=>pe(mt,"$suppressedCount",v),[v,o]=We();var h=rt(),$=ve(h);{var _=R=>{var S=Ft(),C=s(a(S),2),x=a(C);t(C),t(S),P(()=>M(x,`Actively forgetting ${l()??""} ${l()===1?"memory":"memories"}`)),b(R,S)};G($,R=>{l()>0&&R(_)})}b(d,h),o()}const Ze=4,Rt=5500,Ot=1500;function Vt(){const{subscribe:d,update:l}=at([]);let v=1,o=0;const h=new Map,$=new Map,_=new Map;function R(i,u){_.set(i,Date.now());const p=setTimeout(()=>{h.delete(i),_.delete(i),C(i)},u);h.set(i,p)}function S(i){const u=v++,p=Date.now(),g={id:u,createdAt:p,...i};l(n=>{const c=[g,...n];if(c.length>Ze){for(const y of c.slice(Ze)){const B=h.get(y.id);B&&clearTimeout(B),h.delete(y.id),$.delete(y.id),_.delete(y.id)}return c.slice(0,Ze)}return c}),R(u,i.dwellMs)}function C(i){const u=h.get(i);u&&(clearTimeout(u),h.delete(i)),$.delete(i),_.delete(i),l(p=>p.filter(g=>g.id!==i))}function x(i,u){const p=h.get(i);if(!p)return;clearTimeout(p),h.delete(i);const g=_.get(i)??Date.now(),n=Date.now()-g,c=Math.max(200,u-n);$.set(i,{remaining:c})}function f(i){const u=$.get(i);u&&($.delete(i),R(i,u.remaining))}function N(){for(const i of h.values())clearTimeout(i);h.clear(),$.clear(),_.clear(),l(()=>[])}function H(i){const u=It[i.type]??"#818CF8",p=i.data;switch(i.type){case"DreamCompleted":{const g=Number(p.memories_replayed??0),n=Number(p.connections_found??0),c=Number(p.insights_generated??0),y=Number(p.duration_ms??0),B=[];return B.push(`Replayed ${g} ${g===1?"memory":"memories"}`),n>0&&B.push(`${n} new connection${n===1?"":"s"}`),c>0&&B.push(`${c} insight${c===1?"":"s"}`),{type:i.type,title:"Dream consolidated",body:`${B.join(" · ")} in ${(y/1e3).toFixed(1)}s`,color:u,dwellMs:7e3}}case"ConsolidationCompleted":{const g=Number(p.nodes_processed??0),n=Number(p.decay_applied??0),c=Number(p.embeddings_generated??0),y=Number(p.duration_ms??0),B=[];return n>0&&B.push(`${n} decayed`),c>0&&B.push(`${c} embedded`),{type:i.type,title:"Consolidation swept",body:`${g} node${g===1?"":"s"}${B.length?" · "+B.join(" · "):""} in ${(y/1e3).toFixed(1)}s`,color:u,dwellMs:6e3}}case"ConnectionDiscovered":{const g=Date.now();if(g-o0?`suppression #${g} · Rac1 cascade ~${n} neighbors`:`suppression #${g}`,color:u,dwellMs:5500}}case"MemoryUnsuppressed":{const g=Number(p.remaining_count??0);return{type:i.type,title:"Recovered",body:g>0?`${g} suppression${g===1?"":"s"} remain`:"fully unsuppressed",color:u,dwellMs:5e3}}case"Rac1CascadeSwept":{const g=Number(p.seeds??0),n=Number(p.neighbors_affected??0);return{type:i.type,title:"Rac1 cascade",body:`${g} seed${g===1?"":"s"} · ${n} dendritic spine${n===1?"":"s"} pruned`,color:u,dwellMs:6e3}}case"MemoryDeleted":return{type:i.type,title:"Memory deleted",body:String(p.id??"").slice(0,8),color:u,dwellMs:4e3};case"HookVerdictRecorded":{const g=String(p.verdict??"NOTE"),n=String(p.reason??"Sanhedrin receipt updated");return{type:i.type,title:`Sanhedrin ${g}`,body:n,color:u,dwellMs:g==="VETO"?8e3:Rt}}case"Heartbeat":case"SearchPerformed":case"RetentionDecayed":case"ActivationSpread":case"ImportanceScored":case"MemoryCreated":case"MemoryUpdated":case"DreamStarted":case"DreamProgress":case"ConsolidationStarted":case"Connected":return null;default:return null}}let O=null;return ft.subscribe(i=>{if(i.length===0)return;const u=[];for(const p of i){if(p===O)break;u.push(p)}if(u.length!==0){O=i[0];for(let p=u.length-1;p>=0;p--){const g=H(u[p]);g&&S(g)}}}),{subscribe:d,dismiss:C,clear:N,pauseDwell:x,resumeDwell:f,push:S}}const De=Vt();var Bt=w(''),Pt=w('
');function Ht(d,l){Xe(l,!1);const v=()=>pe(De,"$toasts",o),[o,h]=We(),$={DreamCompleted:"✦",ConsolidationCompleted:"◉",ConnectionDiscovered:"⟷",MemoryPromoted:"↑",MemoryDemoted:"↓",MemorySuppressed:"◬",MemoryUnsuppressed:"◉",Rac1CascadeSwept:"✺",MemoryDeleted:"✕",HookVerdictRecorded:"⚑"};function _(x){return $[x]??"◆"}function R(x){De.dismiss(x.id)}function S(x,f){(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),De.dismiss(f.id))}jt();var C=Pt();Ne(C,5,v,x=>x.id,(x,f)=>{var N=Bt(),H=s(a(N),2),O=a(H),i=a(O),u=a(i,!0);t(i);var p=s(i,2),g=a(p,!0);t(p),t(O);var n=s(O,2),c=a(n,!0);t(n),t(H),ce(2),t(N),P(y=>{Ce(N,"aria-label",`${e(f).title??""}: ${e(f).body??""}. Click to dismiss.`),bt(N,`--toast-color: ${e(f).color??""}; --toast-dwell: ${e(f).dwellMs??""}ms;`),M(u,y),M(g,e(f).title),M(c,e(f).body)},[()=>_(e(f).type)]),oe("click",N,()=>R(e(f))),oe("keydown",N,y=>S(y,e(f))),Ye("mouseenter",N,()=>De.pauseDwell(e(f).id,e(f).dwellMs)),Ye("mouseleave",N,()=>De.resumeDwell(e(f).id)),Ye("focus",N,()=>De.pauseDwell(e(f).id,e(f).dwellMs)),Ye("blur",N,()=>De.resumeDwell(e(f).id)),b(x,N)}),t(C),b(d,C),Qe(),h()}Ue(["click","keydown"]);function Oe(d){const l=d.data;if(!l||typeof l!="object")return null;const v=l.timestamp??l.at??l.occurred_at;if(v==null)return null;if(typeof v=="number")return Number.isFinite(v)?v>1e12?v:v*1e3:null;if(typeof v!="string")return null;const o=Date.parse(v);return Number.isFinite(o)?o:null}const et=10,xt=3e4,zt=et*xt;function Kt(d,l){const v=l-zt,o=new Array(et).fill(0);for(const $ of d){if($.type==="Heartbeat")continue;const _=Oe($);if(_===null||_l)continue;const R=Math.min(et-1,Math.floor((_-v)/xt));o[R]+=1}const h=Math.max(1,...o);return o.map($=>({count:$,ratio:$/h}))}function qt(d,l){const v=l-864e5;for(const o of d){if(o.type!=="DreamCompleted")continue;return(Oe(o)??l)>=v?o:null}return null}function Wt(d){if(!d||!d.data)return null;const l=d.data,v=typeof l.insights_generated=="number"?l.insights_generated:typeof l.insightsGenerated=="number"?l.insightsGenerated:null;return v!==null&&Number.isFinite(v)?v:null}function Gt(d,l){let v=null,o=null;for(const R of d)if(!v&&R.type==="DreamStarted"&&(v=R),!o&&R.type==="DreamCompleted"&&(o=R),v&&o)break;if(!v)return!1;const h=Oe(v)??l,$=l-300*1e3;return h<$?!1:o?(Oe(o)??l)=o}return!1}var Xt=w(' at risk',1),Qt=w('0 at risk',1),Zt=w(' at risk',1),Jt=w(' intentions',1),ea=w('— intentions'),ta=w('· insights',1),aa=w(' Last dream: ',1),sa=w('No recent dream'),ra=w('
'),na=w('telemetry unavailable'),ia=w('· fail-open',1),oa=w(' vetoes · appeals ',1),la=w('
DREAMING...
',1),da=w(''),ca=w('
memories · avg retention
');function va(d,l){Xe(l,!0);const v=()=>pe(gt,"$avgRetention",$),o=()=>pe(ft,"$eventFeed",$),h=()=>pe(ht,"$memoryCount",$),[$,_]=We(),R=Y(()=>Math.round((v()??0)*100)),S=Y(()=>(v()??0)>=.5);let C=le(null);async function x(){try{const r=await qe.retentionDistribution();if(Array.isArray(r.endangered)&&r.endangered.length>0){k(C,r.endangered.length,!0);return}const m=r.distribution??[];let A=0;for(const z of m){const U=/^(\d+)/.exec(z.range);if(!U)continue;const se=Number.parseInt(U[1],10);Number.isFinite(se)&&se<30&&(A+=z.count??0)}k(C,A,!0)}catch{k(C,null)}}let f=le(null);async function N(){var r;try{const m=await qe.intentions("active");k(f,m.total??((r=m.intentions)==null?void 0:r.length)??0,!0)}catch{k(f,null)}}let H=le($t(Date.now()));const O=Y(()=>{const r=o(),m=qt(r,e(H)),A=m?Oe(m)??e(H):null,z=A!==null?e(H)-A:null;return{isDreaming:Gt(r,e(H)),recent:m,recentMsAgo:z,insights:Wt(m)}}),i=Y(()=>Kt(o(),e(H)));let u=le(null),p=le(!1);async function g(){try{k(u,await qe.sanhedrin.telemetry(7),!0),k(p,!1)}catch{k(u,null),k(p,!0)}}const n=Y(()=>Ut(o(),e(H)));st(()=>{x(),N(),g();const r=setInterval(()=>{k(H,Date.now(),!0)},1e3),m=setInterval(()=>{x(),N(),g()},6e4);return()=>{clearInterval(r),clearInterval(m)}});var c=ca();let y;var B=a(c),_e=a(B),je=a(_e);let Te;var Be=s(je,2);let I;t(_e);var F=s(_e,2),T=a(F,!0);t(F);var te=s(F,6);let X;var Z=a(te);t(te),ce(2),t(B);var j=s(B,4),V=a(j);{var q=r=>{var m=Xt(),A=ve(m),z=a(A,!0);t(A),ce(2),P(()=>M(z,e(C))),b(r,m)},ae=r=>{var m=Qt();ce(2),b(r,m)},xe=r=>{var m=Zt();ce(2),b(r,m)};G(V,r=>{e(C)!==null&&e(C)>0?r(q):e(C)===0?r(ae,1):r(xe,!1)})}t(j);var L=s(j,4),Q=a(L);{var de=r=>{var m=Jt(),A=ve(m);let z;var U=s(A,2);let se;var ne=a(U,!0);t(U),ce(2),P(()=>{z=re(A,1,"inline-flex h-2 w-2 rounded-full svelte-1kk3799",null,z,{"bg-node-pattern":e(f)>5,"animate-ping-slow":e(f)>5,"bg-muted":e(f)<=5}),se=re(U,1,"tabular-nums svelte-1kk3799",null,se,{"text-node-pattern":e(f)>5,"text-text":e(f)>0&&e(f)<=5,"text-muted":e(f)===0}),M(ne,e(f))}),b(r,m)},ue=r=>{var m=ea();b(r,m)};G(Q,r=>{e(f)!==null?r(de):r(ue,!1)})}t(L);var me=s(L,4),fe=a(me);{var Se=r=>{var m=aa(),A=s(ve(m),4),z=a(A,!0);t(A);var U=s(A,2);{var se=ne=>{var Ie=ta(),E=s(ve(Ie),2),D=a(E,!0);t(E),ce(2),P(()=>M(D,e(O).insights)),b(ne,Ie)};G(U,ne=>{e(O).insights!==null&&ne(se)})}P(ne=>M(z,ne),[()=>Yt(e(O).recentMsAgo)]),b(r,m)},he=r=>{var m=sa();b(r,m)};G(fe,r=>{e(O).recent&&e(O).recentMsAgo!==null?r(Se):r(he,!1)})}t(me);var ge=s(me,4),Ee=s(a(ge),2);Ne(Ee,21,()=>e(i),Re,(r,m)=>{var A=ra();P(z=>bt(A,`height: ${z??""}%; opacity: ${e(m).count===0?.18:.5+e(m).ratio*.5};`),[()=>Math.max(10,e(m).ratio*100)]),b(r,A)}),t(Ee),t(ge);var ye=s(ge,4),Pe=s(a(ye),2);{var He=r=>{var m=na();b(r,m)},ze=r=>{var m=oa(),A=ve(m),z=a(A,!0);t(A);var U=s(A,6),se=a(U,!0);t(U);var ne=s(U,4);{var Ie=E=>{var D=ia(),ie=s(ve(D),2),ee=a(ie,!0);t(ie),ce(2),P(()=>M(ee,e(u).failOpen)),b(E,D)};G(ne,E=>{var D;(D=e(u))!=null&&D.failOpen&&E(Ie)})}P(()=>{var E,D,ie;M(z,((D=(E=e(u))==null?void 0:E.byVerdict)==null?void 0:D.VETO)??"—"),M(se,((ie=e(u))==null?void 0:ie.appeals)??"—")}),b(r,m)};G(Pe,r=>{e(p)?r(He):r(ze,!1)})}t(ye);var K=s(ye,2);{var J=r=>{var m=la();ce(2),b(r,m)};G(K,r=>{e(O).isDreaming&&r(J)})}var W=s(K,4);{var be=r=>{var m=da();b(r,m)};G(W,r=>{e(n)&&r(be)})}t(c),P(()=>{y=re(c,1,"ambient-strip relative flex h-9 w-full items-center gap-0 overflow-hidden border-b border-synapse/15 bg-black/40 px-3 text-[11px] text-dim backdrop-blur-md svelte-1kk3799",null,y,{"ambient-flash":e(n)}),Te=re(je,1,"absolute inline-flex h-full w-full animate-ping rounded-full opacity-75 svelte-1kk3799",null,Te,{"bg-recall":e(S),"bg-warning":!e(S)}),I=re(Be,1,"relative inline-flex h-2 w-2 rounded-full svelte-1kk3799",null,I,{"bg-recall":e(S),"bg-warning":!e(S)}),M(T,h()),X=re(te,1,"svelte-1kk3799",null,X,{"text-recall":e(S),"text-warning":!e(S)}),M(Z,`${e(R)??""}%`)}),b(d,c),Qe(),_()}var pa=w(" "),ua=w('
  • '),ma=w(' ',1),fa=w('

    Appeal recorded.

    '),ha=w('

    No appealable veto in this receipt.

    '),ga=w('
    Claim

    Verdict

    Precedent
      Fix

      Appeal
      '),ba=w('
      ');function xa(d,l){Xe(l,!0);const v=["PASS","NOTE","CAUTION","VETO","APPEALED"];let o=le(null),h=le(""),$=le(!1),_=le(null),R=le(null),S=Y(()=>{var n;return((n=e(o))==null?void 0:n.verdictBar)??(e(h)?"CAUTION":"NOTE")}),C=Y(()=>{var n,c;return((n=e(o))==null?void 0:n.claims.find(y=>y.decision==="veto"))??((c=e(o))==null?void 0:c.claims.find(y=>y.decision==="appealed"))??null}),x=Y(()=>{var n;return e(C)??((n=e(o))==null?void 0:n.claims[0])??null}),f=Y(()=>!!e(o)||!!e(h));st(()=>{N();const n=window.setInterval(N,4e3);return()=>window.clearInterval(n)});async function N(){var n;try{const c=await qe.sanhedrin.latest();k(o,c.receipt,!0),k(h,""),((n=c.receipt)==null?void 0:n.verdictBar)==="VETO"&&c.receipt.id!==e(R)&&(k($,!0),k(R,c.receipt.id,!0))}catch(c){k(h,c instanceof Error?c.message:String(c),!0)}}async function H(n){var c;if(!(!e(C)||((c=e(o))==null?void 0:c.verdictBar)!=="VETO")){k(_,n,!0);try{const y=await qe.sanhedrin.appeal(n,void 0,e(C).id,e(o).id);k(o,y.receipt,!0),k($,!0),k(h,"")}catch(y){k(h,y instanceof Error?y.message:String(y),!0)}finally{k(_,null)}}}function O(n){if(!n)return"";const c=new Date(n);return Number.isNaN(c.getTime())?"":c.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function i(n){var c;return(c=n==null?void 0:n.precedent)!=null&&c.length?n.precedent.map(y=>y.summary??y.command??"Precedent recorded.").slice(0,3):["No precedent attached."]}var u=rt(),p=ve(u);{var g=n=>{var c=ba(),y=a(c),B=s(a(y),2);Ne(B,21,()=>v,Re,(j,V)=>{var q=pa();let ae;var xe=a(q,!0);t(q),P(()=>{Ce(q,"aria-current",e(V)===e(S)?"true":void 0),ae=re(q,1,"svelte-1j425e6",null,ae,{active:e(V)===e(S)}),M(xe,e(V))}),b(j,q)}),t(B);var _e=s(B,2),je=a(_e);t(_e);var Te=s(_e,2),Be=a(Te);{var I=j=>{var V=it();P(()=>M(V,e(h))),b(j,V)},F=j=>{var V=it();P(()=>M(V,e(o).summary)),b(j,V)};G(Be,j=>{e(h)?j(I):e(o)&&j(F,1)})}t(Te);var T=s(Te,2),te=a(T,!0);t(T),t(y);var X=s(y,2);{var Z=j=>{var V=ga(),q=a(V),ae=a(q),xe=s(a(ae),2),L=a(xe,!0);t(xe),t(ae);var Q=s(ae,2),de=s(a(Q),2),ue=a(de);t(de),t(Q);var me=s(Q,2),fe=s(a(me),2);Ne(fe,21,()=>i(e(x)),Re,(K,J)=>{var W=ua(),be=a(W,!0);t(W),P(()=>M(be,e(J))),b(K,W)}),t(fe),t(me);var Se=s(me,2),he=s(a(Se),2),ge=a(he,!0);t(he),t(Se),t(q);var Ee=s(q,2),ye=s(a(Ee),2);{var Pe=K=>{var J=ma(),W=ve(J),be=a(W,!0);t(W);var r=s(W,2),m=a(r,!0);t(r);var A=s(r,2),z=a(A,!0);t(A),P((U,se,ne)=>{W.disabled=U,M(be,e(_)==="stale"?"Saving":"Stale"),r.disabled=se,M(m,e(_)==="wrong"?"Saving":"Wrong"),A.disabled=ne,M(z,e(_)==="too_strict"?"Saving":"Too strict")},[()=>!!e(_),()=>!!e(_),()=>!!e(_)]),oe("click",W,()=>H("stale")),oe("click",r,()=>H("wrong")),oe("click",A,()=>H("too_strict")),b(K,J)},He=K=>{var J=fa();b(K,J)},ze=K=>{var J=ha();b(K,J)};G(ye,K=>{e(C)&&e(o).verdictBar==="VETO"?K(Pe):e(o).verdictBar==="APPEALED"?K(He,1):K(ze,!1)})}t(Ee),t(V),P(()=>{var K,J,W,be;M(L,((K=e(x))==null?void 0:K.text)??e(o).draftPreview),M(ue,`${((J=e(x))==null?void 0:J.decision)??e(o).overall??""} · ${((W=e(x))==null?void 0:W.evidence_state)??e(S)??""}`),M(ge,((be=e(x))==null?void 0:be.fix)||"No change required.")}),b(j,V)};G(X,j=>{e($)&&e(o)&&j(Z)})}t(c),P((j,V)=>{re(c,1,j,"svelte-1j425e6"),Ce(y,"aria-expanded",e($)),M(je,`Current verdict: ${e(S)??""}`),M(te,V)},[()=>`verdict-bar tone-${e(S).toLowerCase()}`,()=>{var j;return O((j=e(o))==null?void 0:j.createdAt)}]),oe("click",y,()=>k($,!e($))),b(n,c)};G(p,n=>{e(f)&&n(g)})}b(d,u),Qe()}Ue(["click"]);const _t="vestige.theme",ct="vestige-theme-light",Ve=at("dark"),tt=at(!0),vt=wt([Ve,tt],([d,l])=>d==="auto"?l?"dark":"light":d);function _a(d){return d==="dark"||d==="light"||d==="auto"}function ya(d){if(_a(d)){Ve.set(d);try{localStorage.setItem(_t,d)}catch{}}}function Je(){const d=ut(Ve);ya(d==="dark"?"light":d==="light"?"auto":"dark")}function ka(){if(document.getElementById(ct))return;const d=document.createElement("style");d.id=ct,d.textContent=` -/* Vestige light-mode overrides — injected by theme.ts. - * Activated by [data-theme='light'] on . - * Tokens mirror the real names used in app.css so the cascade stays clean. */ -[data-theme='light'] { - /* Core surface palette (slate scale) */ - --color-void: #f8fafc; /* slate-50 — page background */ - --color-abyss: #f1f5f9; /* slate-100 */ - --color-deep: #e2e8f0; /* slate-200 */ - --color-surface: #f1f5f9; /* slate-100 */ - --color-elevated: #e2e8f0; /* slate-200 */ - --color-subtle: #cbd5e1; /* slate-300 */ - --color-muted: #94a3b8; /* slate-400 */ - --color-dim: #475569; /* slate-600 */ - --color-text: #0f172a; /* slate-900 */ - --color-bright: #020617; /* slate-950 */ -} - -/* Baseline body/html wiring — app.css sets these against the dark - * tokens; we just let the variables do the work. Reassert for clarity. */ -[data-theme='light'] html, -html[data-theme='light'] { - background: var(--color-void); - color: var(--color-text); -} - -/* Glass surfaces — recompose on a light canvas. The original alphas - * are tuned for dark; invert-and-tint for light so panels still read - * as elevated instead of vanishing. */ -[data-theme='light'] .glass { - background: rgba(255, 255, 255, 0.65); - border: 1px solid rgba(99, 102, 241, 0.12); - box-shadow: - inset 0 1px 0 0 rgba(255, 255, 255, 0.6), - 0 4px 24px rgba(15, 23, 42, 0.08); -} -[data-theme='light'] .glass-subtle { - background: rgba(255, 255, 255, 0.55); - border: 1px solid rgba(99, 102, 241, 0.1); - box-shadow: - inset 0 1px 0 0 rgba(255, 255, 255, 0.5), - 0 2px 12px rgba(15, 23, 42, 0.06); -} -[data-theme='light'] .glass-sidebar { - background: rgba(248, 250, 252, 0.82); - border-right: 1px solid rgba(99, 102, 241, 0.14); - box-shadow: - inset -1px 0 0 0 rgba(255, 255, 255, 0.4), - 4px 0 24px rgba(15, 23, 42, 0.08); -} -[data-theme='light'] .glass-panel { - background: rgba(255, 255, 255, 0.75); - border: 1px solid rgba(99, 102, 241, 0.14); - box-shadow: - inset 0 1px 0 0 rgba(255, 255, 255, 0.5), - 0 8px 32px rgba(15, 23, 42, 0.1); -} - -/* Halve glow intensity — neon accents stay recognizable without - * washing out on slate-50. */ -[data-theme='light'] .glow-synapse { - box-shadow: 0 0 10px rgba(99, 102, 241, 0.15), 0 0 30px rgba(99, 102, 241, 0.05); -} -[data-theme='light'] .glow-dream { - box-shadow: 0 0 10px rgba(168, 85, 247, 0.15), 0 0 30px rgba(168, 85, 247, 0.05); -} -[data-theme='light'] .glow-memory { - box-shadow: 0 0 10px rgba(59, 130, 246, 0.15), 0 0 30px rgba(59, 130, 246, 0.05); -} - -/* Ambient orbs are gorgeous on black and blinding on white. Tame them. */ -[data-theme='light'] .ambient-orb { - opacity: 0.18; - filter: blur(100px); -} - -/* Scrollbar recolor for the lighter surface. */ -[data-theme='light'] ::-webkit-scrollbar-thumb { - background: #cbd5e1; -} -[data-theme='light'] ::-webkit-scrollbar-thumb:hover { - background: #94a3b8; -} -`,document.head.appendChild(d)}function pt(d){document.documentElement.dataset.theme=d}let we=null,Ae=null,$e=null,Me=null;function wa(){we&&Ae&&we.removeEventListener("change",Ae),Me==null||Me(),$e==null||$e(),we=null,Ae=null,Me=null,$e=null,ka();let d="dark";try{const l=localStorage.getItem(_t);(l==="dark"||l==="light"||l==="auto")&&(d=l)}catch{}return Ve.set(d),we=window.matchMedia("(prefers-color-scheme: dark)"),tt.set(we.matches),Ae=l=>tt.set(l.matches),we.addEventListener("change",Ae),pt(ut(vt)),Me=vt.subscribe(pt),$e=Ve.subscribe(()=>{}),()=>{we&&Ae&&we.removeEventListener("change",Ae),we=null,Ae=null,Me==null||Me(),$e==null||$e(),Me=null,$e=null}}var $a=w('');function Ma(d){const l=()=>pe(Ve,"$theme",v),[v,o]=We(),h={dark:"Dark",light:"Light",auto:"Auto (system)"},$={dark:"light",light:"auto",auto:"dark"};let _=Y(l),R=Y(()=>$[e(_)]),S=Y(()=>`Toggle theme: ${h[e(_)]} (click for ${h[e(R)]})`);var C=$a(),x=a(C),f=a(x);let N;var H=s(f,2);let O;var i=s(H,2);let u;t(x),t(C),P(()=>{Ce(C,"aria-label",e(S)),Ce(C,"title",e(S)),Ce(C,"data-mode",e(_)),N=re(f,0,"icon svelte-1cmi4dh",null,N,{active:e(_)==="dark"}),O=re(H,0,"icon svelte-1cmi4dh",null,O,{active:e(_)==="light"}),u=re(i,0,"icon svelte-1cmi4dh",null,u,{active:e(_)==="auto"})}),oe("click",C,function(...p){Je==null||Je.apply(this,p)}),b(d,C),o()}Ue(["click"]);var Ca=w(' '),Ta=w('
      '),Sa=w(''),Aa=w(' '),Ea=w('
      ',1),Da=w(''),Na=w('
      No matches
      '),ja=w('
      esc
      '),Ia=w(" ",1);function Ja(d,l){Xe(l,!0);const v=()=>pe(St,"$page",S),o=()=>pe(Dt,"$isConnected",S),h=()=>pe(ht,"$memoryCount",S),$=()=>pe(gt,"$avgRetention",S),_=()=>pe(Et,"$uptimeSeconds",S),R=()=>pe(mt,"$suppressedCount",S),[S,C]=We();let x=le(!1),f=le(""),N=le(void 0),H=Y(()=>v().url.pathname.startsWith(ke)?v().url.pathname.slice(ke.length)||"/":v().url.pathname),O=Y(()=>e(H)==="/waitlist"||e(H).startsWith("/waitlist/")),i=Y(()=>!e(O));st(()=>{e(O)||dt.connect();const I=wa();function F(T){if(e(O)||e(i))return;if((T.metaKey||T.ctrlKey)&&T.key==="k"){T.preventDefault(),k(x,!e(x)),k(f,""),e(x)&&requestAnimationFrame(()=>{var Z;return(Z=e(N))==null?void 0:Z.focus()});return}if(T.key==="Escape"&&e(x)){k(x,!1);return}if(T.target instanceof HTMLInputElement||T.target instanceof HTMLTextAreaElement)return;if(T.key==="/"){T.preventDefault();const Z=document.querySelector('input[type="text"]');Z==null||Z.focus();return}const X={g:"/graph",m:"/memories",t:"/timeline",f:"/feed",e:"/explore",i:"/intentions",s:"/stats",r:"/reasoning",a:"/activation",d:"/dreams",c:"/schedule",p:"/importance",u:"/duplicates",x:"/contradictions",n:"/patterns"}[T.key.toLowerCase()];X&&!T.metaKey&&!T.ctrlKey&&!T.altKey&&(T.preventDefault(),lt(`${ke}${X}`))}return window.addEventListener("keydown",F),()=>{dt.disconnect(),window.removeEventListener("keydown",F),I()}}),At(I=>{if(!(!document.startViewTransition||window.matchMedia("(prefers-reduced-motion: reduce)").matches))return new Promise(F=>{document.startViewTransition(async()=>{F(),await I.complete})})});const u=[{href:"/observatory",label:"Observatory",icon:"sparkle",shortcut:"O"},{href:"/blackbox",label:"Black Box",icon:"blackbox",shortcut:"B"},{href:"/memory-prs",label:"Memory PRs",icon:"memorypr",shortcut:"Q"},{href:"/graph",label:"Graph",icon:"graph",shortcut:"G"},{href:"/reasoning",label:"Reasoning",icon:"reasoning",shortcut:"R"},{href:"/memories",label:"Memories",icon:"memories",shortcut:"M"},{href:"/timeline",label:"Timeline",icon:"timeline",shortcut:"T"},{href:"/feed",label:"Feed",icon:"feed",shortcut:"F"},{href:"/explore",label:"Explore",icon:"explore",shortcut:"E"},{href:"/activation",label:"Activation",icon:"activation",shortcut:"A"},{href:"/dreams",label:"Dreams",icon:"dreams",shortcut:"D"},{href:"/schedule",label:"Schedule",icon:"schedule",shortcut:"C"},{href:"/importance",label:"Importance",icon:"importance",shortcut:"P"},{href:"/duplicates",label:"Duplicates",icon:"duplicates",shortcut:"U"},{href:"/contradictions",label:"Contradictions",icon:"contradictions",shortcut:"X"},{href:"/patterns",label:"Patterns",icon:"patterns",shortcut:"N"},{href:"/intentions",label:"Intentions",icon:"intentions",shortcut:"I"},{href:"/stats",label:"Stats",icon:"stats",shortcut:"S"},{href:"/settings",label:"Settings",icon:"settings",shortcut:","}],p=u.slice(0,5);function g(I,F){const T=F.startsWith(ke)?F.slice(ke.length)||"/":F;return I==="/graph"?T==="/"||T==="/graph":T.startsWith(I)}let n=Y(()=>e(f)?u.filter(I=>I.label.toLowerCase().includes(e(f).toLowerCase())):u);function c(I){k(x,!1),k(f,""),lt(`${ke}${I}`)}var y=Ia(),B=ve(y);{var _e=I=>{var F=rt(),T=ve(F);ot(T,()=>l.children),b(I,F)},je=I=>{var F=Ea(),T=s(ve(F),6),te=a(T),X=a(te),Z=a(X),j=a(Z);Le(j,{name:"logo",size:18,strokeWidth:1.8}),t(Z),ce(2),t(X);var V=s(X,2);Ne(V,21,()=>u,Re,(E,D)=>{const ie=Y(()=>g(e(D).href,v().url.pathname));var ee=Ca(),Fe=a(ee),Ge=a(Fe);Le(Ge,{get name(){return e(D).icon},size:18}),t(Fe);var Ke=s(Fe,2),yt=a(Ke,!0);t(Ke);var nt=s(Ke,2),kt=a(nt,!0);t(nt),t(ee),P(()=>{Ce(ee,"href",`${ke??""}${e(D).href??""}`),re(ee,1,`nav-link group flex items-center gap-3 px-3 py-2.5 rounded-lg transition-all duration-200 text-sm - ${e(ie)?"bg-synapse/15 text-synapse-glow border border-synapse/30 shadow-[0_0_12px_rgba(99,102,241,0.15)] nav-active-border":"text-dim hover:text-text hover:bg-white/[0.03] border border-transparent"}`,"svelte-12qhfyh"),M(yt,e(D).label),M(kt,e(D).shortcut)}),b(E,ee)}),t(V);var q=s(V,2),ae=a(q),xe=a(ae);Le(xe,{name:"command",size:14}),ce(4),t(ae),t(q);var L=s(q,2),Q=a(L),de=a(Q),ue=s(de,2),me=a(ue,!0);t(ue);var fe=s(ue,2),Se=a(fe);Ma(Se),t(fe),t(Q);var he=s(Q,2),ge=a(he),Ee=a(ge);t(ge);var ye=s(ge,2),Pe=a(ye);t(ye);var He=s(ye,2);{var ze=E=>{var D=Ta(),ie=a(D);t(D),P(ee=>M(ie,`up ${ee??""}`),[()=>Nt(_())]),b(E,D)};G(He,E=>{_()>0&&E(ze)})}t(he);var K=s(he,2);{var J=E=>{var D=Sa(),ie=a(D);Lt(ie),t(D),b(E,D)};G(K,E=>{R()>0&&E(J)})}t(L),t(te);var W=s(te,2),be=a(W);va(be,{});var r=s(be,2);xa(r,{});var m=s(r,2),A=a(m);ot(A,()=>l.children),t(m),t(W);var z=s(W,2),U=a(z),se=a(U);Ne(se,17,()=>p,Re,(E,D)=>{const ie=Y(()=>g(e(D).href,v().url.pathname));var ee=Aa(),Fe=a(ee);Le(Fe,{get name(){return e(D).icon},size:20});var Ge=s(Fe,2),Ke=a(Ge,!0);t(Ge),t(ee),P(()=>{Ce(ee,"href",`${ke??""}${e(D).href??""}`),re(ee,1,`flex flex-col items-center gap-0.5 px-3 py-2 rounded-lg transition-all min-w-[3.5rem] - ${e(ie)?"text-synapse-glow":"text-muted"}`),M(Ke,e(D).label)}),b(E,ee)});var ne=s(se,2);t(U),t(z),t(T);var Ie=s(T,2);Ht(Ie,{}),P(E=>{Ce(X,"href",`${ke??""}/graph`),re(de,1,`w-2 h-2 rounded-full ${o()?"bg-recall animate-pulse-glow":"bg-decay"}`),M(me,o()?"Connected":"Offline"),M(Ee,`${h()??""} memories`),M(Pe,`${E??""}% retention`)},[()=>($()*100).toFixed(0)]),oe("click",ae,()=>{k(x,!0),k(f,""),requestAnimationFrame(()=>{var E;return(E=e(N))==null?void 0:E.focus()})}),oe("click",ne,()=>{k(x,!0),k(f,""),requestAnimationFrame(()=>{var E;return(E=e(N))==null?void 0:E.focus()})}),b(I,F)};G(B,I=>{e(O)||e(i)?I(_e):I(je,!1)})}var Te=s(B,2);{var Be=I=>{var F=ja(),T=a(F),te=a(T),X=a(te),Z=a(X);Le(Z,{name:"search",size:16}),t(X);var j=s(X,2);Ct(j),Mt(j,L=>k(N,L),()=>e(N)),ce(2),t(te);var V=s(te,2),q=a(V);Ne(q,17,()=>e(n),Re,(L,Q)=>{var de=Da(),ue=a(de),me=a(ue);Le(me,{get name(){return e(Q).icon},size:17}),t(ue);var fe=s(ue,2),Se=a(fe,!0);t(fe);var he=s(fe,2),ge=a(he,!0);t(he),t(de),P(()=>{M(Se,e(Q).label),M(ge,e(Q).shortcut)}),oe("click",de,()=>c(e(Q).href)),b(L,de)});var ae=s(q,2);{var xe=L=>{var Q=Na();b(L,Q)};G(ae,L=>{e(n).length===0&&L(xe)})}t(V),t(T),t(F),oe("keydown",F,L=>{L.key==="Escape"&&k(x,!1)}),oe("click",F,L=>{L.target===L.currentTarget&&k(x,!1)}),oe("keydown",j,L=>{L.key==="Enter"&&e(n).length>0&&c(e(n)[0].href)}),Tt(j,()=>e(f),L=>k(f,L)),b(I,F)};G(Te,I=>{e(x)&&!e(O)&&!e(i)&&I(Be)})}b(d,y),Qe(),C()}Ue(["click","keydown"]);export{Ja as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/0.CcZXq7cA.js.br b/apps/dashboard/build/_app/immutable/nodes/0.CcZXq7cA.js.br deleted file mode 100644 index c7b61f5..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/0.CcZXq7cA.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/0.CcZXq7cA.js.gz b/apps/dashboard/build/_app/immutable/nodes/0.CcZXq7cA.js.gz deleted file mode 100644 index 9dfec28..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/0.CcZXq7cA.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/1.8UKMSR8s.js b/apps/dashboard/build/_app/immutable/nodes/1.8UKMSR8s.js deleted file mode 100644 index 46ffb4c..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/1.8UKMSR8s.js +++ /dev/null @@ -1 +0,0 @@ -import"../chunks/Bzak7iHL.js";import{i as h}from"../chunks/BfiOPhbz.js";import{p as g,aH as l,Y as v,a as d,b as _,f as x,c as e,r as o,X as $}from"../chunks/CGq8RnJq.js";import{s as p}from"../chunks/DAau0uzT.js";import{p as m}from"../chunks/DY7cP31Q.js";import{s as b}from"../chunks/DJDK-KWF.js";const k={get error(){return m.error},get status(){return m.status}};b.updated.check;const i=k;var E=x("

      ",1);function y(f,c){g(c,!1),h();var t=E(),r=l(t),n=e(r,!0);o(r);var a=$(r,2),u=e(a,!0);o(a),v(()=>{var s;p(n,i.status),p(u,(s=i.error)==null?void 0:s.message)}),d(f,t),_()}export{y as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/1.8UKMSR8s.js.br b/apps/dashboard/build/_app/immutable/nodes/1.8UKMSR8s.js.br deleted file mode 100644 index 79f316f..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/1.8UKMSR8s.js.br +++ /dev/null @@ -1,4 +0,0 @@ -g`¶:I1"e9Q?硞 SAd ~c,w,R=zꨳ{wg &ЅlW@ P`ﴴrAީ 9');function ke(X,z){se(z,!0);const F=[...A("#22C7DE"),1],Q=[...A("#FF3B30"),.92],y=[...A("#29F2A9"),.62],k=40,D=36,V=-1e5;let u=p(null),c=null,i=null,h=null,v=null,f=p(ae([])),m=p(null),d=p(""),R=p(!0),O=p(null),b=null,C=p(null),I=p(null),T=p(null),E=0;ie(()=>{const e=new URLSearchParams(window.location.search);l(d,e.get("q")??"",!0),U()}),oe(()=>{i==null||i.dispose(),h==null||h.dispose(),i=null,h=null,c=null});async function P(e){c=e;const t=new Ce(e);h=t,t.setCells(W()),e.addPass(t);const n=new Oe(e);i=n,await n.init(),n.setText(S()),e.addPass(n),e.demoClock.reset()}function H(e){const t=e.replace(/\s+/g," ").trim();if(t.length<=280)return t;const n=t.slice(0,280),o=n.lastIndexOf(" ");return o>200?n.slice(0,o):n}function G(){try{ye(`?q=${encodeURIComponent(r(d))}`,{})}catch(e){console.warn("[explore] URL sync failed — walk state is not shareable:",e)}}async function U(){var t;const e=++E;if(l(O,null),!r(d).trim())try{const n=await $.memories.list({limit:"1"});if(e!==E)return;const o=(t=n.memories)==null?void 0:t[0];o!=null&&o.content&&(l(d,H(o.content),!0),l(T,o.id,!0),l(I,o.id.slice(0,8),!0),G())}catch{}if(!r(d).trim()){l(R,!1),l(m,null),l(f,[],!0),i==null||i.setText(S()),c==null||c.demoClock.reset();return}l(R,!0),i==null||i.setText(S());try{const n=r(T)?await $.explore(r(T),"associations",void 0,k):await $.search(r(d),k);if(e!==E)return;l(m,"query"in n?n:null,!0),l(f,n.results,!0)}catch(n){if(e!==E)return;l(m,null),l(f,[],!0),l(O,n instanceof Error?n.message:"UNKNOWN EXPLORE FETCH ERROR",!0)}finally{e===E&&(l(R,!1),l(C,null),i==null||i.setText(S()),h==null||h.setCells(W()),c==null||c.demoClock.reset())}}function W(){const e=r(f).map((t,n)=>({id:t.id,score:N(t),hue:n===0?K.oxygen:K.bridge,energy:N(t),metric2:L(t),selected:n===0,kind:"explore-neighbor",payload:t}));return Ie(e,{maxRadius:.9,minCellR:.035,maxCellR:.1})}function w(e){return e.replace(/[\u2014\u2013]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u2026/g,"...").replace(/[^\x20-\x7E]/g,"?")}function B(e){return Math.min(1,Math.max(0,Number.isFinite(e)?e:.5))}function g(e,t=.5){return typeof e=="number"&&Number.isFinite(e)?e:t}function N(e){return B(g(e.similarity,g(e.score,g(e.relevance,g(e.combinedScore,e.retrievalStrength)))))}function L(e){return B(g(e.retention,e.retentionStrength))}function j(e){const t=w(e.content).replace(/\s+/g," ").trim().slice(0,52);return w(`${t} | ${e.id.slice(0,8)} | ${Math.round(N(e)*100)}% | ${Math.round(L(e)*100)}%`)}function M(e,t=y){return{id:"explore:status",kind:"explore-status",text:w(e),x:-.58,y:.02,size:.044,color:t,depth:.78,weight:.62,revealSpan:32,maxWidthEm:50}}function S(){var s;if(r(R))return[M(r(C)?`WALKING FROM ${r(C)}...`:"LOADING SEARCH NEIGHBORS...",F)];if(r(O))return[M(`ERROR - ${r(O)}`.slice(0,72),Q)];if(r(f).length===0){if(!r(d).trim())return[M("SEMANTIC EXPEDITION - EMPTY BRAIN, INGEST A MEMORY TO EXPLORE",y)];const a=(s=r(m))!=null&&s.query?`NO NEIGHBORS FOR "${r(m).query}" | ${r(m).durationMs}ms`:`NO NEIGHBORS FOR "${r(d)}"`;return[M(a,y)]}const e=r(f).slice(0,D),t=.72,n=1.5/Math.max(1,D-1);return[{id:"explore:origin",kind:"explore-origin",text:w(r(I)?`EXPEDITION SEEDED FROM NEWEST MEMORY ${r(I)} - CLICK ANY THOUGHT TO WALK`:`SEMANTIC NEIGHBORHOOD - ${e.length} THOUGHTS - CLICK TO WALK`),x:-.88,y:.82,size:.022,color:y,depth:.85,weight:.6,revealSpan:24,maxWidthEm:60},...e.map((a,Y)=>({id:`explore:${a.id}`,kind:"explore-neighbor",memoryId:a.id,text:j(a),x:-.88,y:t-Y*n,size:.026,color:F,depth:N(a),weight:L(a),startFrame:V+Y*2,revealSpan:20,maxWidthEm:46,hitPadX:.03,hitPadY:.015}))]}function _(e){if(!r(u))return null;const t=r(u).getBoundingClientRect();return t.width<=0||t.height<=0?null:{x:(e.clientX-t.left)/t.width*2-1,y:-((e.clientY-t.top)/t.height*2-1)}}function J(e){if(!r(u)||!c)return;const t=r(u).getBoundingClientRect(),n=Math.max(1e-4,t.width/Math.max(1,t.height)),o={x:e.x*Math.max(n,1),y:e.y/Math.min(n,1)},s=v??o,a={x:s.x+(o.x-s.x)*.35,y:s.y+(o.y-s.y)*.35};v=a,c.setCursorPreNdc(a.x,a.y,a.x-s.x,a.y-s.y)}function Z(e){const t=_(e);if(!t)return;J(t);const n=(i==null?void 0:i.pickAt(t.x,t.y))??null,o=(n==null?void 0:n.kind)==="explore-neighbor"?n.id:null;o!==b&&(b=o,i==null||i.setRunDepth(o,1)),r(u)&&(r(u).style.cursor=o?"crosshair":"default")}function ee(){v=null,b=null,c==null||c.setCursorPreNdc(999,999,0,0),i==null||i.setRunDepth(null),r(u)&&(r(u).style.cursor="default")}async function te(e){const t=_(e);if(!t||!i)return;const n=i.pickAt(t.x,t.y);if((n==null?void 0:n.kind)!=="explore-neighbor")return;const o=n.payload;if(!o.memoryId)return;const s=r(f).find(a=>a.id===o.memoryId);s!=null&&s.content&&(l(C,s.id.slice(0,8),!0),l(T,s.id,!0),l(I,null),l(d,H(s.content),!0),G(),await U())}var x=Te();Ee("15rowvt",e=>{de(()=>{me.title="Explore · Vestige"})});var ne=fe(x);{let e=he(()=>{var t;return`real-explore-neighbors:${r(d)}:${((t=r(m))==null?void 0:t.total)??0}`});Re(ne,{demo:"recall-path",get seed(){return r(e)},onready:P})}xe(x),ge(x,e=>l(u,e),()=>r(u)),q("pointerdown",x,te),q("pointermove",x,Z),le("pointerleave",x,ee),ce(X,x),ue()}re(["pointerdown","pointermove"]);export{ke as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/10.CMLfe2no.js.br b/apps/dashboard/build/_app/immutable/nodes/10.CMLfe2no.js.br deleted file mode 100644 index 1aacf8b..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/10.CMLfe2no.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/10.CMLfe2no.js.gz b/apps/dashboard/build/_app/immutable/nodes/10.CMLfe2no.js.gz deleted file mode 100644 index 8088faf..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/10.CMLfe2no.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/11.BcR5gOV6.js b/apps/dashboard/build/_app/immutable/nodes/11.BcR5gOV6.js deleted file mode 100644 index 2d02957..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/11.BcR5gOV6.js +++ /dev/null @@ -1 +0,0 @@ -var K=Object.defineProperty;var Y=(d,c,a)=>c in d?K(d,c,{enumerable:!0,configurable:!0,writable:!0,value:a}):d[c]=a;var T=(d,c,a)=>Y(d,typeof c!="symbol"?c+"":c,a);import"../chunks/Bzak7iHL.js";import{p as G,j as U,b as X,h as q,g as w,u as x,$ as H}from"../chunks/CGq8RnJq.js";import{h as Q}from"../chunks/De_e6MzK.js";import{s as Z,a as R}from"../chunks/DV6OI5iy.js";import{w as ee,i as te,a as ne,e as ie}from"../chunks/Ch9vNiEl.js";import{R as se}from"../chunks/BpEKQwpr.js";import{r as h,e as re}from"../chunks/BMB5u1EX.js";import{T as oe}from"../chunks/D7ozXiSB.js";import{L as ae,l as ce}from"../chunks/DETSv_kY.js";function _e(d,c){G(c,!0);const a=()=>R(ie,"$eventFeed",y),l=()=>R(ne,"$isConnected",y),p=()=>R(te,"$isReconnecting",y),[y,N]=Z(),P=[...h("#22C7DE"),1],S=[...h("#FFB000"),.9],C=[...h("#FF3B30"),.92],L=[...h("#29F2A9"),.62],f=42;let u=null,m=null,v=x(()=>O(a()));U(()=>{u==null||u.setText(D(a(),l(),p()))});function I(t,e){const n=new j(t);n.uploadScene(e);const i=new oe(t);return u=i,i.init().then(()=>i.setText(D(a(),l(),p()))),[n,{render(o){i.render(o)},pickAt(o,r){const s=i.pickAt(o,r);return s?(s.id!==m&&(m=s.id,i.setRunDepth(s.id,1)),s):(m&&(m=null,i.setRunDepth(null)),null)},dispose(){i.dispose(),u===i&&(u=null)}}]}class j{constructor(e){T(this,"field");this.field=new ae(e)}uploadScene(e){const i=e.nodes.map((r,s)=>({node:r,event:a()[s]})).filter(r=>r.event).map(({node:r,event:s})=>({id:r.source.id,score:r.retention,hue:re(s.type),energy:r.activation,metric2:r.trust,scar:s.type.includes("Deleted")||s.type.includes("Demoted")||s.type.includes("Verdict"),kind:"feed-event",payload:s})),o=i.length<4;this.field.setCells(ce(i,{maxRadius:o?.78:.92,minCellR:o?.24:.018,maxCellR:o?.32:.06}))}compute(e){this.field.compute(e)}render(e){this.field.render(e)}pickAt(e,n){return this.field.pickAt(e,n)}dispose(){this.field.dispose()}}function O(t){const e=t.slice(0,f);return{organ:"feed",nodes:e.map((n,i)=>({source:{kind:"event",id:$(n,i)},index:i,label:n.type,retention:g(n),activation:A(e,n,i),trust:g(n),tags:Object.keys(n.data).slice(0,6),type:n.type})),edges:[],events:e.map((n,i)=>({source:{kind:"event",id:$(n,i)},type:n.type,targetIndex:i,frame:i,energy:g(n)})),receipts:[],scalars:{eventCount:t.length,connected:l()?1:0,reconnecting:p()?1:0},alive:e.length>0}}function D(t,e,n){const i=t.slice(0,f);if(i.length===0)return[z(M(e,n),n?S:e?L:C)];const o=.72,r=1.5/Math.max(1,f-1);return i.map((s,b)=>{const k=$(s,b);return{id:`feed:${k}`,kind:"feed-event",event:s,eventKey:k,text:B(s,k),x:-.9,y:o-b*r,size:.024,color:W(s),depth:.6+.4*A(i,s,b),weight:g(s),startFrame:0,revealSpan:1,maxWidthEm:58,hitPadX:.03,hitPadY:.013}})}function z(t,e){return{id:"feed:connection-state",kind:"feed-state",text:_(t),x:-.52,y:.03,size:.038,color:e,depth:.72,weight:.62,revealSpan:24,maxWidthEm:48}}function B(t,e){const n=V(t.data);return _(`${t.type} | ${e.slice(0,24)} | ${n}`.slice(0,138))}function V(t){const e=Object.entries(t).filter(([,n])=>n!=null&&typeof n!="object").slice(0,5).map(([n,i])=>`${n}=${String(i).replace(/\s+/g," ").slice(0,32)}`);return e.length?e.join(" "):JSON.stringify(t).replace(/\s+/g," ").slice(0,82)}function $(t,e){const n=t.data,i=n.id??n.event_id??n.memory_id??n.trace_id??n.run_id??n.receipt_id??n.pr_id??n.timestamp??n.at??`${t.type}:${e}`;return _(String(i))}function M(t,e){return JSON.stringify({connected:t,reconnecting:e,events:0})}function g(t){const e=t.data,i=[e.energy,e.confidence,e.strength,e.weight,e.composite_score,e.new_retention,e.retention,e.result_count,e.connections_found,e.insights_generated,e.nodes_processed,e.duration_ms].map(Number).find(o=>Number.isFinite(o));return i===void 0?.5:i<0?0:i<=1?i:F(Math.log10(i+1)/3)}function A(t,e,n){const i=t.map(E).filter(r=>r!==null),o=E(e);if(o!==null&&i.length>1){const r=Math.min(...i),s=Math.max(...i);if(s>r)return F((o-r)/(s-r))}return F(1-n/Math.max(1,f-1))}function E(t){const e=t.data.timestamp??t.data.at??t.data.created_at;if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const n=Date.parse(e);return Number.isFinite(n)?n:null}return null}function W(t){return t.type.includes("Deleted")||t.type.includes("Demoted")||t.type.includes("Verdict")?C:t.type.includes("Progress")||t.type.includes("Started")?S:P}function _(t){return t.replace(/[\u2014\u2013]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u2026/g,"...").replace(/[^\x20-\x7E]/g,"?")}function F(t){return Math.min(1,Math.max(0,Number.isFinite(t)?t:.5))}function J(t){t.kind==="feed-event"&&ee.clearEvents()}Q("1o4vd58",t=>{q(()=>{H.title="Feed · Vestige"})});{let t=x(()=>`live-event-stream:${a().length}:${l()?1:0}:${p()?1:0}`),e=x(()=>M(l(),p()));se(d,{organ:"feed",get seed(){return w(t)},get scene(){return w(v)},passes:I,loading:!1,error:null,get emptyLabel(){return w(e)},onpick:J})}X(),N()}export{_e as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/11.BcR5gOV6.js.br b/apps/dashboard/build/_app/immutable/nodes/11.BcR5gOV6.js.br deleted file mode 100644 index 7ac96f1..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/11.BcR5gOV6.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/11.BcR5gOV6.js.gz b/apps/dashboard/build/_app/immutable/nodes/11.BcR5gOV6.js.gz deleted file mode 100644 index 3e715e3..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/11.BcR5gOV6.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/12.CRVOD7oJ.js b/apps/dashboard/build/_app/immutable/nodes/12.CRVOD7oJ.js deleted file mode 100644 index a87937d..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/12.CRVOD7oJ.js +++ /dev/null @@ -1,4076 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../chunks/kcrnba3G.js","../chunks/Dp1pzeXC.js","../chunks/Bo4EDkTQ.js","../chunks/CGq8RnJq.js","../chunks/W8qDZJD6.js","../chunks/Bzak7iHL.js","../chunks/DAau0uzT.js","../chunks/Ccqjq5DS.js","../chunks/DqfV0sZu.js","../chunks/uCQU803Y.js","../chunks/DGM4cicq.js","../chunks/DV6OI5iy.js","../chunks/D35IQVqe.js","../chunks/Ch9vNiEl.js","../chunks/DY7cP31Q.js","../chunks/HFGAk8XQ.js","../chunks/BMB5u1EX.js","../assets/cognitive-palette.BALpZUFZ.css","../chunks/BKh9s_e0.js","../chunks/CcUbQ_Wl.js","../assets/ObservatoryStage.CKoSQgn0.css"])))=>i.map(i=>d[i]); -var mo=Object.defineProperty;var _o=(e,t,n)=>t in e?mo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ve=(e,t,n)=>_o(e,typeof t!="symbol"?t+"":t,n);import"../chunks/Bzak7iHL.js";import{o as Nr,a as ua,s as tt,d as pa,b as mt}from"../chunks/DAau0uzT.js";import{d as He,e as qi,s as te,g as T,p as Yn,j as Fn,a as qe,b as qn,f as $e,c as oe,X as fe,af as Bn,r as ae,Y as Et,u as en,aS as Or,aH as Tn,aT as go,bh as vo}from"../chunks/CGq8RnJq.js";import{b as Ki,i as pt}from"../chunks/Ccqjq5DS.js";import{aW as So,aw as Eo,a4 as sn,y as Nt,C as Ae,ay as Fr,a6 as zn,V as Te,A as xo,fw as jt,d as Mt,x as Qn,H as ln,aV as An,aA as Zt,B as zt,az as ri,fD as Mo,fE as To,a5 as yi,fF as bo,aB as Ln,h as Ao,E as Ro,b as Ze,a0 as Hn,cL as wo,ar as tn,aS as Ti,aT as ha,aU as oi,U as si,a3 as Br,fG as yo,a7 as Un,bw as bi,b7 as Co,b8 as Po,b9 as $n,eq as Do,df as Lo,er as Uo,dg as Io,ba as No,bb as Oo,bc as Fo,bd as Bo,be as Ho,bf as Go,bg as ko,bh as Vo,bi as zo,bj as Wo,bk as Xo,aX as Yo,aY as qo,aZ as Ko,v as Li,u as In,w as ui,a_ as Zo,a$ as ti,b0 as jo,b1 as $o,b2 as Qo,b3 as Jo,b4 as Hr,aa as es,b5 as ts,b6 as ns,av as Gr,a as at,ej as is,eI as as,ek as rs,eT as Ot,aq as Vt,af as wt,_ as Bt,ax as kr,N as cn,ab as Jt,bF as Ai,bA as Vr,bB as zr,G as Jn,a2 as Wr,eu as ma,bC as os,bD as ss,bE as ls,z as Xr,al as bn,bG as cs,bH as ds,bI as fs,bJ as us,bK as ps,bL as Yr,ac as hs,bM as qr,bN as Kr,bO as Ui,bP as Ii,bQ as Ni,bR as Oi,e as ut,bS as va,bT as Sa,bU as Ea,bV as xa,bW as Ma,bX as Ta,bY as ba,bZ as Aa,b_ as Ra,b$ as wa,c0 as ya,c1 as Ca,c2 as Pa,c3 as Da,c4 as La,c5 as Ua,c6 as Ia,c7 as Na,c8 as Oa,c9 as Fa,ca as Ba,cb as Fi,eK as Ha,eL as Ga,cc as ms,cd as ka,ce as Va,cf as za,bs as Zi,bt as ji,bu as $i,bv as Qi,bx as Ji,by as ea,bz as ta,bl as _s,bm as Wa,bn as gs,Q as vi,bo as vs,bp as Xa,bq as Ya,br as Ct,aP as na,aQ as ia,am as Ss,ak as Zr,fH as Ri,ap as Ci,Y as Es,Z as xs,fI as jr,a1 as $r,fJ as qa,a9 as Qr,fK as Ka,eb as Jr,f as li,g as Wn,$ as eo,m as wi,ch as Ms,ci as Ts,fL as bs,dK as Za,fM as It,e1 as As,es as Rs,dq as ws,aN as ys,aM as Cs,aL as to,aK as Ps,aJ as Ds,aI as Ls,cB as Us,dt as Is,fN as Ns,ah as Os,ai as Fs,aj as Bs,cA as Hs,cz as Gs,dh as ks,eh as Gn,fd as Nn,eF as ja,f1 as aa,eO as Vs,M as no,as as $a,d8 as zs,an as Ws,dH as io,aF as Xs,aC as Qa,eP as Ys,dS as qs,P as kn,ex as Vn,l as ra,e3 as oa,eS as Ks,ae as Ja,fO as er,f5 as tr,aR as Zs,fP as js,fQ as $s,fR as nr,fS as Qs,fT as ir,fU as Js,fV as el,fW as tl,fB as nl,fC as ar,fX as il}from"../chunks/Bo4EDkTQ.js";import{e as ni,i as Si,s as _t,r as ci}from"../chunks/DqfV0sZu.js";import{s as on,c as al}from"../chunks/uCQU803Y.js";import{s as di}from"../chunks/HFGAk8XQ.js";import{b as sa,a as rr}from"../chunks/DGM4cicq.js";import{p as ii,s as rl,a as ol}from"../chunks/DV6OI5iy.js";import{b as or}from"../chunks/DY7cP31Q.js";import{N as sl}from"../chunks/CcUbQ_Wl.js";import{b as ll}from"../chunks/BzfFPM53.js";import{i as cl}from"../chunks/BfiOPhbz.js";import{_ as dl}from"../chunks/Dp1pzeXC.js";import{I as mn}from"../chunks/CKbQrCJw.js";import{D as fl}from"../chunks/DnDQzBs4.js";import{a as Pn}from"../chunks/D35IQVqe.js";import{e as ul}from"../chunks/Ch9vNiEl.js";import{l as pl,L as hl}from"../chunks/DETSv_kY.js";import{a as ml}from"../chunks/BMB5u1EX.js";/** - * @license - * Copyright 2010-2024 Three.js Authors - * SPDX-License-Identifier: MIT - */function ao(){let e=null,t=!1,n=null,i=null;function r(a,o){n(a,o),i=e.requestAnimationFrame(r)}return{start:function(){t!==!0&&n!==null&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(a){n=a},setContext:function(a){e=a}}}function _l(e){const t=new WeakMap;function n(s,u){const f=s.array,m=s.usage,_=f.byteLength,v=e.createBuffer();e.bindBuffer(u,v),e.bufferData(u,f,m),s.onUploadCallback();let p;if(f instanceof Float32Array)p=e.FLOAT;else if(f instanceof Uint16Array)s.isFloat16BufferAttribute?p=e.HALF_FLOAT:p=e.UNSIGNED_SHORT;else if(f instanceof Int16Array)p=e.SHORT;else if(f instanceof Uint32Array)p=e.UNSIGNED_INT;else if(f instanceof Int32Array)p=e.INT;else if(f instanceof Int8Array)p=e.BYTE;else if(f instanceof Uint8Array)p=e.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)p=e.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:v,type:p,bytesPerElement:f.BYTES_PER_ELEMENT,version:s.version,size:_}}function i(s,u,f){const m=u.array,_=u.updateRanges;if(e.bindBuffer(f,s),_.length===0)e.bufferSubData(f,0,m);else{_.sort((p,b)=>p.start-b.start);let v=0;for(let p=1;p<_.length;p++){const b=_[v],A=_[p];A.start<=b.start+b.count+1?b.count=Math.max(b.count,A.start+A.count-b.start):(++v,_[v]=A)}_.length=v+1;for(let p=0,b=_.length;p 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`,Ul=`#if NUM_CLIPPING_PLANES > 0 - varying vec3 vClipPosition; - uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; -#endif`,Il=`#if NUM_CLIPPING_PLANES > 0 - varying vec3 vClipPosition; -#endif`,Nl=`#if NUM_CLIPPING_PLANES > 0 - vClipPosition = - mvPosition.xyz; -#endif`,Ol=`#if defined( USE_COLOR_ALPHA ) - diffuseColor *= vColor; -#elif defined( USE_COLOR ) - diffuseColor.rgb *= vColor; -#endif`,Fl=`#if defined( USE_COLOR_ALPHA ) - varying vec4 vColor; -#elif defined( USE_COLOR ) - varying vec3 vColor; -#endif`,Bl=`#if defined( USE_COLOR_ALPHA ) - varying vec4 vColor; -#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) - varying vec3 vColor; -#endif`,Hl=`#if defined( USE_COLOR_ALPHA ) - vColor = vec4( 1.0 ); -#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) - vColor = vec3( 1.0 ); -#endif -#ifdef USE_COLOR - vColor *= color; -#endif -#ifdef USE_INSTANCING_COLOR - vColor.xyz *= instanceColor.xyz; -#endif -#ifdef USE_BATCHING_COLOR - vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); - vColor.xyz *= batchingColor.xyz; -#endif`,Gl=`#define PI 3.141592653589793 -#define PI2 6.283185307179586 -#define PI_HALF 1.5707963267948966 -#define RECIPROCAL_PI 0.3183098861837907 -#define RECIPROCAL_PI2 0.15915494309189535 -#define EPSILON 1e-6 -#ifndef saturate -#define saturate( a ) clamp( a, 0.0, 1.0 ) -#endif -#define whiteComplement( a ) ( 1.0 - saturate( a ) ) -float pow2( const in float x ) { return x*x; } -vec3 pow2( const in vec3 x ) { return x*x; } -float pow3( const in float x ) { return x*x*x; } -float pow4( const in float x ) { float x2 = x*x; return x2*x2; } -float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } -float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } -highp float rand( const in vec2 uv ) { - const highp float a = 12.9898, b = 78.233, c = 43758.5453; - highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); - return fract( sin( sn ) * c ); -} -#ifdef HIGH_PRECISION - float precisionSafeLength( vec3 v ) { return length( v ); } -#else - float precisionSafeLength( vec3 v ) { - float maxComponent = max3( abs( v ) ); - return length( v / maxComponent ) * maxComponent; - } -#endif -struct IncidentLight { - vec3 color; - vec3 direction; - bool visible; -}; -struct ReflectedLight { - vec3 directDiffuse; - vec3 directSpecular; - vec3 indirectDiffuse; - vec3 indirectSpecular; -}; -#ifdef USE_ALPHAHASH - varying vec3 vPosition; -#endif -vec3 transformDirection( in vec3 dir, in mat4 matrix ) { - return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); -} -vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { - return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); -} -mat3 transposeMat3( const in mat3 m ) { - mat3 tmp; - tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); - tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); - tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); - return tmp; -} -bool isPerspectiveMatrix( mat4 m ) { - return m[ 2 ][ 3 ] == - 1.0; -} -vec2 equirectUv( in vec3 dir ) { - float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; - float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; - return vec2( u, v ); -} -vec3 BRDF_Lambert( const in vec3 diffuseColor ) { - return RECIPROCAL_PI * diffuseColor; -} -vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { - float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); - return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} -float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { - float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); - return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} // validated`,kl=`#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`,Vl=`vec3 transformedNormal = objectNormal; -#ifdef USE_TANGENT - vec3 transformedTangent = objectTangent; -#endif -#ifdef USE_BATCHING - mat3 bm = mat3( batchingMatrix ); - transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); - transformedNormal = bm * transformedNormal; - #ifdef USE_TANGENT - transformedTangent = bm * transformedTangent; - #endif -#endif -#ifdef USE_INSTANCING - mat3 im = mat3( instanceMatrix ); - transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); - transformedNormal = im * transformedNormal; - #ifdef USE_TANGENT - transformedTangent = im * transformedTangent; - #endif -#endif -transformedNormal = normalMatrix * transformedNormal; -#ifdef FLIP_SIDED - transformedNormal = - transformedNormal; -#endif -#ifdef USE_TANGENT - transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; - #ifdef FLIP_SIDED - transformedTangent = - transformedTangent; - #endif -#endif`,zl=`#ifdef USE_DISPLACEMENTMAP - uniform sampler2D displacementMap; - uniform float displacementScale; - uniform float displacementBias; -#endif`,Wl=`#ifdef USE_DISPLACEMENTMAP - transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); -#endif`,Xl=`#ifdef USE_EMISSIVEMAP - vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); - #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE - emissiveColor = sRGBTransferEOTF( emissiveColor ); - #endif - totalEmissiveRadiance *= emissiveColor.rgb; -#endif`,Yl=`#ifdef USE_EMISSIVEMAP - uniform sampler2D emissiveMap; -#endif`,ql="gl_FragColor = linearToOutputTexel( gl_FragColor );",Kl=`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 ); -}`,Zl=`#ifdef USE_ENVMAP - #ifdef ENV_WORLDPOS - vec3 cameraToFrag; - if ( isOrthographic ) { - cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); - } else { - cameraToFrag = normalize( vWorldPosition - cameraPosition ); - } - vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); - #ifdef ENVMAP_MODE_REFLECTION - vec3 reflectVec = reflect( cameraToFrag, worldNormal ); - #else - vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); - #endif - #else - vec3 reflectVec = vReflect; - #endif - #ifdef ENVMAP_TYPE_CUBE - vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); - #else - vec4 envColor = vec4( 0.0 ); - #endif - #ifdef ENVMAP_BLENDING_MULTIPLY - outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); - #elif defined( ENVMAP_BLENDING_MIX ) - outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); - #elif defined( ENVMAP_BLENDING_ADD ) - outgoingLight += envColor.xyz * specularStrength * reflectivity; - #endif -#endif`,jl=`#ifdef USE_ENVMAP - uniform float envMapIntensity; - uniform float flipEnvMap; - uniform mat3 envMapRotation; - #ifdef ENVMAP_TYPE_CUBE - uniform samplerCube envMap; - #else - uniform sampler2D envMap; - #endif - -#endif`,$l=`#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`,Ql=`#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`,Jl=`#ifdef USE_ENVMAP - #ifdef ENV_WORLDPOS - vWorldPosition = worldPosition.xyz; - #else - vec3 cameraToVertex; - if ( isOrthographic ) { - cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); - } else { - cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); - } - vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); - #ifdef ENVMAP_MODE_REFLECTION - vReflect = reflect( cameraToVertex, worldNormal ); - #else - vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); - #endif - #endif -#endif`,ec=`#ifdef USE_FOG - vFogDepth = - mvPosition.z; -#endif`,tc=`#ifdef USE_FOG - varying float vFogDepth; -#endif`,nc=`#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`,ic=`#ifdef USE_FOG - uniform vec3 fogColor; - varying float vFogDepth; - #ifdef FOG_EXP2 - uniform float fogDensity; - #else - uniform float fogNear; - uniform float fogFar; - #endif -#endif`,ac=`#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 -}`,rc=`#ifdef USE_LIGHTMAP - uniform sampler2D lightMap; - uniform float lightMapIntensity; -#endif`,oc=`LambertMaterial material; -material.diffuseColor = diffuseColor.rgb; -material.specularStrength = specularStrength;`,sc=`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`,lc=`uniform bool receiveShadow; -uniform vec3 ambientLightColor; -#if defined( USE_LIGHT_PROBES ) - uniform vec3 lightProbe[ 9 ]; -#endif -vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { - float x = normal.x, y = normal.y, z = normal.z; - vec3 result = shCoefficients[ 0 ] * 0.886227; - result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; - result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; - result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; - result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; - result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; - result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); - result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; - result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); - return result; -} -vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { - vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); - vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); - return irradiance; -} -vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { - vec3 irradiance = ambientLightColor; - return irradiance; -} -float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { - float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); - if ( cutoffDistance > 0.0 ) { - distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); - } - return distanceFalloff; -} -float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { - return smoothstep( coneCosine, penumbraCosine, angleCosine ); -} -#if NUM_DIR_LIGHTS > 0 - struct DirectionalLight { - vec3 direction; - vec3 color; - }; - uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; - void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { - light.color = directionalLight.color; - light.direction = directionalLight.direction; - light.visible = true; - } -#endif -#if NUM_POINT_LIGHTS > 0 - struct PointLight { - vec3 position; - vec3 color; - float distance; - float decay; - }; - uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; - void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { - vec3 lVector = pointLight.position - geometryPosition; - light.direction = normalize( lVector ); - float lightDistance = length( lVector ); - light.color = pointLight.color; - light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); - light.visible = ( light.color != vec3( 0.0 ) ); - } -#endif -#if NUM_SPOT_LIGHTS > 0 - struct SpotLight { - vec3 position; - vec3 direction; - vec3 color; - float distance; - float decay; - float coneCos; - float penumbraCos; - }; - uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; - void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { - vec3 lVector = spotLight.position - geometryPosition; - light.direction = normalize( lVector ); - float angleCos = dot( light.direction, spotLight.direction ); - float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); - if ( spotAttenuation > 0.0 ) { - float lightDistance = length( lVector ); - light.color = spotLight.color * spotAttenuation; - light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); - light.visible = ( light.color != vec3( 0.0 ) ); - } else { - light.color = vec3( 0.0 ); - light.visible = false; - } - } -#endif -#if NUM_RECT_AREA_LIGHTS > 0 - struct RectAreaLight { - vec3 color; - vec3 position; - vec3 halfWidth; - vec3 halfHeight; - }; - uniform sampler2D ltc_1; uniform sampler2D ltc_2; - uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; -#endif -#if NUM_HEMI_LIGHTS > 0 - struct HemisphereLight { - vec3 direction; - vec3 skyColor; - vec3 groundColor; - }; - uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; - vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { - float dotNL = dot( normal, hemiLight.direction ); - float hemiDiffuseWeight = 0.5 * dotNL + 0.5; - vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); - return irradiance; - } -#endif`,cc=`#ifdef USE_ENVMAP - vec3 getIBLIrradiance( const in vec3 normal ) { - #ifdef ENVMAP_TYPE_CUBE_UV - vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); - vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); - return PI * envMapColor.rgb * envMapIntensity; - #else - return vec3( 0.0 ); - #endif - } - vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { - #ifdef ENVMAP_TYPE_CUBE_UV - vec3 reflectVec = reflect( - viewDir, normal ); - reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); - reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); - vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); - return envMapColor.rgb * envMapIntensity; - #else - return vec3( 0.0 ); - #endif - } - #ifdef USE_ANISOTROPY - vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { - #ifdef ENVMAP_TYPE_CUBE_UV - vec3 bentNormal = cross( bitangent, viewDir ); - bentNormal = normalize( cross( bentNormal, bitangent ) ); - bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); - return getIBLRadiance( viewDir, bentNormal, roughness ); - #else - return vec3( 0.0 ); - #endif - } - #endif -#endif`,dc=`ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`,fc=`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`,uc=`BlinnPhongMaterial material; -material.diffuseColor = diffuseColor.rgb; -material.specularColor = specular; -material.specularShininess = shininess; -material.specularStrength = specularStrength;`,pc=`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`,hc=`PhysicalMaterial material; -material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); -vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); -float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); -material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; -material.roughness = min( material.roughness, 1.0 ); -#ifdef IOR - material.ior = ior; - #ifdef USE_SPECULAR - float specularIntensityFactor = specularIntensity; - vec3 specularColorFactor = specularColor; - #ifdef USE_SPECULAR_COLORMAP - specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; - #endif - #ifdef USE_SPECULAR_INTENSITYMAP - specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; - #endif - material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); - #else - float specularIntensityFactor = 1.0; - vec3 specularColorFactor = vec3( 1.0 ); - material.specularF90 = 1.0; - #endif - material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); -#else - material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); - material.specularF90 = 1.0; -#endif -#ifdef USE_CLEARCOAT - material.clearcoat = clearcoat; - material.clearcoatRoughness = clearcoatRoughness; - material.clearcoatF0 = vec3( 0.04 ); - material.clearcoatF90 = 1.0; - #ifdef USE_CLEARCOATMAP - material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; - #endif - #ifdef USE_CLEARCOAT_ROUGHNESSMAP - material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; - #endif - material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); - material.clearcoatRoughness += geometryRoughness; - material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); -#endif -#ifdef USE_DISPERSION - material.dispersion = dispersion; -#endif -#ifdef USE_IRIDESCENCE - material.iridescence = iridescence; - material.iridescenceIOR = iridescenceIOR; - #ifdef USE_IRIDESCENCEMAP - material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; - #endif - #ifdef USE_IRIDESCENCE_THICKNESSMAP - material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; - #else - material.iridescenceThickness = iridescenceThicknessMaximum; - #endif -#endif -#ifdef USE_SHEEN - material.sheenColor = sheenColor; - #ifdef USE_SHEEN_COLORMAP - material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; - #endif - material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); - #ifdef USE_SHEEN_ROUGHNESSMAP - material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; - #endif -#endif -#ifdef USE_ANISOTROPY - #ifdef USE_ANISOTROPYMAP - mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); - vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; - vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; - #else - vec2 anisotropyV = anisotropyVector; - #endif - material.anisotropy = length( anisotropyV ); - if( material.anisotropy == 0.0 ) { - anisotropyV = vec2( 1.0, 0.0 ); - } else { - anisotropyV /= material.anisotropy; - material.anisotropy = saturate( material.anisotropy ); - } - material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); - material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; - material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; -#endif`,mc=`struct PhysicalMaterial { - vec3 diffuseColor; - float roughness; - vec3 specularColor; - float specularF90; - float dispersion; - #ifdef USE_CLEARCOAT - float clearcoat; - float clearcoatRoughness; - vec3 clearcoatF0; - float clearcoatF90; - #endif - #ifdef USE_IRIDESCENCE - float iridescence; - float iridescenceIOR; - float iridescenceThickness; - vec3 iridescenceFresnel; - vec3 iridescenceF0; - #endif - #ifdef USE_SHEEN - vec3 sheenColor; - float sheenRoughness; - #endif - #ifdef IOR - float ior; - #endif - #ifdef USE_TRANSMISSION - float transmission; - float transmissionAlpha; - float thickness; - float attenuationDistance; - vec3 attenuationColor; - #endif - #ifdef USE_ANISOTROPY - float anisotropy; - float alphaT; - vec3 anisotropyT; - vec3 anisotropyB; - #endif -}; -vec3 clearcoatSpecularDirect = vec3( 0.0 ); -vec3 clearcoatSpecularIndirect = vec3( 0.0 ); -vec3 sheenSpecularDirect = vec3( 0.0 ); -vec3 sheenSpecularIndirect = vec3(0.0 ); -vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { - float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); - float x2 = x * x; - float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); - return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); -} -float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { - float a2 = pow2( alpha ); - float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); - float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); - return 0.5 / max( gv + gl, EPSILON ); -} -float D_GGX( const in float alpha, const in float dotNH ) { - float a2 = pow2( alpha ); - float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; - return RECIPROCAL_PI * a2 / pow2( denom ); -} -#ifdef USE_ANISOTROPY - float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { - float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); - float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); - float v = 0.5 / ( gv + gl ); - return saturate(v); - } - float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { - float a2 = alphaT * alphaB; - highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); - highp float v2 = dot( v, v ); - float w2 = a2 / v2; - return RECIPROCAL_PI * a2 * pow2 ( w2 ); - } -#endif -#ifdef USE_CLEARCOAT - vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { - vec3 f0 = material.clearcoatF0; - float f90 = material.clearcoatF90; - float roughness = material.clearcoatRoughness; - float alpha = pow2( roughness ); - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float dotVH = saturate( dot( viewDir, halfDir ) ); - vec3 F = F_Schlick( f0, f90, dotVH ); - float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); - float D = D_GGX( alpha, dotNH ); - return F * ( V * D ); - } -#endif -vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { - vec3 f0 = material.specularColor; - float f90 = material.specularF90; - float roughness = material.roughness; - float alpha = pow2( roughness ); - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float dotVH = saturate( dot( viewDir, halfDir ) ); - vec3 F = F_Schlick( f0, f90, dotVH ); - #ifdef USE_IRIDESCENCE - F = mix( F, material.iridescenceFresnel, material.iridescence ); - #endif - #ifdef USE_ANISOTROPY - float dotTL = dot( material.anisotropyT, lightDir ); - float dotTV = dot( material.anisotropyT, viewDir ); - float dotTH = dot( material.anisotropyT, halfDir ); - float dotBL = dot( material.anisotropyB, lightDir ); - float dotBV = dot( material.anisotropyB, viewDir ); - float dotBH = dot( material.anisotropyB, halfDir ); - float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); - float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); - #else - float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); - float D = D_GGX( alpha, dotNH ); - #endif - return F * ( V * D ); -} -vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { - const float LUT_SIZE = 64.0; - const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; - const float LUT_BIAS = 0.5 / LUT_SIZE; - float dotNV = saturate( dot( N, V ) ); - vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); - uv = uv * LUT_SCALE + LUT_BIAS; - return uv; -} -float LTC_ClippedSphereFormFactor( const in vec3 f ) { - float l = length( f ); - return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); -} -vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { - float x = dot( v1, v2 ); - float y = abs( x ); - float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; - float b = 3.4175940 + ( 4.1616724 + y ) * y; - float v = a / b; - float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; - return cross( v1, v2 ) * theta_sintheta; -} -vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { - vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; - vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; - vec3 lightNormal = cross( v1, v2 ); - if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); - vec3 T1, T2; - T1 = normalize( V - N * dot( V, N ) ); - T2 = - cross( N, T1 ); - mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); - vec3 coords[ 4 ]; - coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); - coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); - coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); - coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); - coords[ 0 ] = normalize( coords[ 0 ] ); - coords[ 1 ] = normalize( coords[ 1 ] ); - coords[ 2 ] = normalize( coords[ 2 ] ); - coords[ 3 ] = normalize( coords[ 3 ] ); - vec3 vectorFormFactor = vec3( 0.0 ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); - float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); - return vec3( result ); -} -#if defined( USE_SHEEN ) -float D_Charlie( float roughness, float dotNH ) { - float alpha = pow2( roughness ); - float invAlpha = 1.0 / alpha; - float cos2h = dotNH * dotNH; - float sin2h = max( 1.0 - cos2h, 0.0078125 ); - return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); -} -float V_Neubelt( float dotNV, float dotNL ) { - return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); -} -vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float D = D_Charlie( sheenRoughness, dotNH ); - float V = V_Neubelt( dotNV, dotNL ); - return sheenColor * ( D * V ); -} -#endif -float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { - float dotNV = saturate( dot( normal, viewDir ) ); - float r2 = roughness * roughness; - float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; - float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; - float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); - return saturate( DG * RECIPROCAL_PI ); -} -vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { - float dotNV = saturate( dot( normal, viewDir ) ); - const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); - const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); - vec4 r = roughness * c0 + c1; - float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; - vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; - return fab; -} -vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { - vec2 fab = DFGApprox( normal, viewDir, roughness ); - return specularColor * fab.x + specularF90 * fab.y; -} -#ifdef USE_IRIDESCENCE -void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { -#else -void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { -#endif - vec2 fab = DFGApprox( normal, viewDir, roughness ); - #ifdef USE_IRIDESCENCE - vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); - #else - vec3 Fr = specularColor; - #endif - vec3 FssEss = Fr * fab.x + specularF90 * fab.y; - float Ess = fab.x + fab.y; - float Ems = 1.0 - Ess; - vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); - singleScatter += FssEss; - multiScatter += Fms * Ems; -} -#if NUM_RECT_AREA_LIGHTS > 0 - void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { - vec3 normal = geometryNormal; - vec3 viewDir = geometryViewDir; - vec3 position = geometryPosition; - vec3 lightPos = rectAreaLight.position; - vec3 halfWidth = rectAreaLight.halfWidth; - vec3 halfHeight = rectAreaLight.halfHeight; - vec3 lightColor = rectAreaLight.color; - float roughness = material.roughness; - vec3 rectCoords[ 4 ]; - rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; - rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; - rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; - vec2 uv = LTC_Uv( normal, viewDir, roughness ); - vec4 t1 = texture2D( ltc_1, uv ); - vec4 t2 = texture2D( ltc_2, uv ); - mat3 mInv = mat3( - vec3( t1.x, 0, t1.y ), - vec3( 0, 1, 0 ), - vec3( t1.z, 0, t1.w ) - ); - vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); - reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); - reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); - } -#endif -void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { - float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); - vec3 irradiance = dotNL * directLight.color; - #ifdef USE_CLEARCOAT - float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); - vec3 ccIrradiance = dotNLcc * directLight.color; - clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); - #endif - #ifdef USE_SHEEN - sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); - #endif - reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { - reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { - #ifdef USE_CLEARCOAT - clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); - #endif - #ifdef USE_SHEEN - sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); - #endif - vec3 singleScattering = vec3( 0.0 ); - vec3 multiScattering = vec3( 0.0 ); - vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; - #ifdef USE_IRIDESCENCE - computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); - #else - computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); - #endif - vec3 totalScattering = singleScattering + multiScattering; - vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); - reflectedLight.indirectSpecular += radiance * singleScattering; - reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; - reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; -} -#define RE_Direct RE_Direct_Physical -#define RE_Direct_RectArea RE_Direct_RectArea_Physical -#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical -#define RE_IndirectSpecular RE_IndirectSpecular_Physical -float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { - return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); -}`,_c=` -vec3 geometryPosition = - vViewPosition; -vec3 geometryNormal = normal; -vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); -vec3 geometryClearcoatNormal = vec3( 0.0 ); -#ifdef USE_CLEARCOAT - geometryClearcoatNormal = clearcoatNormal; -#endif -#ifdef USE_IRIDESCENCE - float dotNVi = saturate( dot( normal, geometryViewDir ) ); - if ( material.iridescenceThickness == 0.0 ) { - material.iridescence = 0.0; - } else { - material.iridescence = saturate( material.iridescence ); - } - if ( material.iridescence > 0.0 ) { - material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); - material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); - } -#endif -IncidentLight directLight; -#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) - PointLight pointLight; - #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 - PointLightShadow pointLightShadow; - #endif - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { - pointLight = pointLights[ i ]; - getPointLightInfo( pointLight, geometryPosition, directLight ); - #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) - pointLightShadow = pointLightShadows[ i ]; - directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; - #endif - RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) - SpotLight spotLight; - vec4 spotColor; - vec3 spotLightCoord; - bool inSpotLightMap; - #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 - SpotLightShadow spotLightShadow; - #endif - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { - spotLight = spotLights[ i ]; - getSpotLightInfo( spotLight, geometryPosition, directLight ); - #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) - #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX - #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) - #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS - #else - #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) - #endif - #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) - spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; - inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); - spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); - directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; - #endif - #undef SPOT_LIGHT_MAP_INDEX - #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) - spotLightShadow = spotLightShadows[ i ]; - directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; - #endif - RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) - DirectionalLight directionalLight; - #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 - DirectionalLightShadow directionalLightShadow; - #endif - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { - directionalLight = directionalLights[ i ]; - getDirectionalLightInfo( directionalLight, directLight ); - #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) - directionalLightShadow = directionalLightShadows[ i ]; - directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; - #endif - RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) - RectAreaLight rectAreaLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { - rectAreaLight = rectAreaLights[ i ]; - RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if defined( RE_IndirectDiffuse ) - vec3 iblIrradiance = vec3( 0.0 ); - vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); - #if defined( USE_LIGHT_PROBES ) - irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); - #endif - #if ( NUM_HEMI_LIGHTS > 0 ) - #pragma unroll_loop_start - for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { - irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); - } - #pragma unroll_loop_end - #endif -#endif -#if defined( RE_IndirectSpecular ) - vec3 radiance = vec3( 0.0 ); - vec3 clearcoatRadiance = vec3( 0.0 ); -#endif`,gc=`#if defined( RE_IndirectDiffuse ) - #ifdef USE_LIGHTMAP - vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); - vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; - irradiance += lightMapIrradiance; - #endif - #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) - iblIrradiance += getIBLIrradiance( geometryNormal ); - #endif -#endif -#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) - #ifdef USE_ANISOTROPY - radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); - #else - radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); - #endif - #ifdef USE_CLEARCOAT - clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); - #endif -#endif`,vc=`#if defined( RE_IndirectDiffuse ) - RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); -#endif -#if defined( RE_IndirectSpecular ) - RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); -#endif`,Sc=`#if defined( USE_LOGDEPTHBUF ) - gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; -#endif`,Ec=`#if defined( USE_LOGDEPTHBUF ) - uniform float logDepthBufFC; - varying float vFragDepth; - varying float vIsPerspective; -#endif`,xc=`#ifdef USE_LOGDEPTHBUF - varying float vFragDepth; - varying float vIsPerspective; -#endif`,Mc=`#ifdef USE_LOGDEPTHBUF - vFragDepth = 1.0 + gl_Position.w; - vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); -#endif`,Tc=`#ifdef USE_MAP - vec4 sampledDiffuseColor = texture2D( map, vMapUv ); - #ifdef DECODE_VIDEO_TEXTURE - sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); - #endif - diffuseColor *= sampledDiffuseColor; -#endif`,bc=`#ifdef USE_MAP - uniform sampler2D map; -#endif`,Ac=`#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`,Rc=`#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`,wc=`float metalnessFactor = metalness; -#ifdef USE_METALNESSMAP - vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); - metalnessFactor *= texelMetalness.b; -#endif`,yc=`#ifdef USE_METALNESSMAP - uniform sampler2D metalnessMap; -#endif`,Cc=`#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`,Pc=`#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`,Dc=`#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`,Lc=`#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`,Uc=`#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`,Ic=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; -#ifdef FLAT_SHADED - vec3 fdx = dFdx( vViewPosition ); - vec3 fdy = dFdy( vViewPosition ); - vec3 normal = normalize( cross( fdx, fdy ) ); -#else - vec3 normal = normalize( vNormal ); - #ifdef DOUBLE_SIDED - normal *= faceDirection; - #endif -#endif -#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) - #ifdef USE_TANGENT - mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); - #else - mat3 tbn = getTangentFrame( - vViewPosition, normal, - #if defined( USE_NORMALMAP ) - vNormalMapUv - #elif defined( USE_CLEARCOAT_NORMALMAP ) - vClearcoatNormalMapUv - #else - vUv - #endif - ); - #endif - #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) - tbn[0] *= faceDirection; - tbn[1] *= faceDirection; - #endif -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - #ifdef USE_TANGENT - mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); - #else - mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); - #endif - #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) - tbn2[0] *= faceDirection; - tbn2[1] *= faceDirection; - #endif -#endif -vec3 nonPerturbedNormal = normal;`,Nc=`#ifdef USE_NORMALMAP_OBJECTSPACE - normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; - #ifdef FLIP_SIDED - normal = - normal; - #endif - #ifdef DOUBLE_SIDED - normal = normal * faceDirection; - #endif - normal = normalize( normalMatrix * normal ); -#elif defined( USE_NORMALMAP_TANGENTSPACE ) - vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; - mapN.xy *= normalScale; - normal = normalize( tbn * mapN ); -#elif defined( USE_BUMPMAP ) - normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`,Oc=`#ifndef FLAT_SHADED - varying vec3 vNormal; - #ifdef USE_TANGENT - varying vec3 vTangent; - varying vec3 vBitangent; - #endif -#endif`,Fc=`#ifndef FLAT_SHADED - varying vec3 vNormal; - #ifdef USE_TANGENT - varying vec3 vTangent; - varying vec3 vBitangent; - #endif -#endif`,Bc=`#ifndef FLAT_SHADED - vNormal = normalize( transformedNormal ); - #ifdef USE_TANGENT - vTangent = normalize( transformedTangent ); - vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); - #endif -#endif`,Hc=`#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`,Gc=`#ifdef USE_CLEARCOAT - vec3 clearcoatNormal = nonPerturbedNormal; -#endif`,kc=`#ifdef USE_CLEARCOAT_NORMALMAP - vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; - clearcoatMapN.xy *= clearcoatNormalScale; - clearcoatNormal = normalize( tbn2 * clearcoatMapN ); -#endif`,Vc=`#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`,zc=`#ifdef USE_IRIDESCENCEMAP - uniform sampler2D iridescenceMap; -#endif -#ifdef USE_IRIDESCENCE_THICKNESSMAP - uniform sampler2D iridescenceThicknessMap; -#endif`,Wc=`#ifdef OPAQUE -diffuseColor.a = 1.0; -#endif -#ifdef USE_TRANSMISSION -diffuseColor.a *= material.transmissionAlpha; -#endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Xc=`vec3 packNormalToRGB( const in vec3 normal ) { - return normalize( normal ) * 0.5 + 0.5; -} -vec3 unpackRGBToNormal( const in vec3 rgb ) { - return 2.0 * rgb.xyz - 1.0; -} -const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; -const float Inv255 = 1. / 255.; -const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); -const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); -const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); -const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); -vec4 packDepthToRGBA( const in float v ) { - if( v <= 0.0 ) - return vec4( 0., 0., 0., 0. ); - if( v >= 1.0 ) - return vec4( 1., 1., 1., 1. ); - float vuf; - float af = modf( v * PackFactors.a, vuf ); - float bf = modf( vuf * ShiftRight8, vuf ); - float gf = modf( vuf * ShiftRight8, vuf ); - return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); -} -vec3 packDepthToRGB( const in float v ) { - if( v <= 0.0 ) - return vec3( 0., 0., 0. ); - if( v >= 1.0 ) - return vec3( 1., 1., 1. ); - float vuf; - float bf = modf( v * PackFactors.b, vuf ); - float gf = modf( vuf * ShiftRight8, vuf ); - return vec3( vuf * Inv255, gf * PackUpscale, bf ); -} -vec2 packDepthToRG( const in float v ) { - if( v <= 0.0 ) - return vec2( 0., 0. ); - if( v >= 1.0 ) - return vec2( 1., 1. ); - float vuf; - float gf = modf( v * 256., vuf ); - return vec2( vuf * Inv255, gf ); -} -float unpackRGBAToDepth( const in vec4 v ) { - return dot( v, UnpackFactors4 ); -} -float unpackRGBToDepth( const in vec3 v ) { - return dot( v, UnpackFactors3 ); -} -float unpackRGToDepth( const in vec2 v ) { - return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; -} -vec4 pack2HalfToRGBA( const in vec2 v ) { - vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); - return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); -} -vec2 unpackRGBATo2Half( const in vec4 v ) { - return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); -} -float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { - return ( viewZ + near ) / ( near - far ); -} -float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { - return depth * ( near - far ) - near; -} -float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { - return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); -} -float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { - return ( near * far ) / ( ( far - near ) * depth - far ); -}`,Yc=`#ifdef PREMULTIPLIED_ALPHA - gl_FragColor.rgb *= gl_FragColor.a; -#endif`,qc=`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;`,Kc=`#ifdef DITHERING - gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`,Zc=`#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`,jc=`float roughnessFactor = roughness; -#ifdef USE_ROUGHNESSMAP - vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); - roughnessFactor *= texelRoughness.g; -#endif`,$c=`#ifdef USE_ROUGHNESSMAP - uniform sampler2D roughnessMap; -#endif`,Qc=`#if NUM_SPOT_LIGHT_COORDS > 0 - varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; -#endif -#if NUM_SPOT_LIGHT_MAPS > 0 - uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; -#endif -#ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 - uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; - varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; - struct DirectionalLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; - struct SpotLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; - varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; - struct PointLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - float shadowCameraNear; - float shadowCameraFar; - }; - uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; - #endif - float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { - return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); - } - vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { - return unpackRGBATo2Half( texture2D( shadow, uv ) ); - } - float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ - float occlusion = 1.0; - vec2 distribution = texture2DDistribution( shadow, uv ); - float hard_shadow = step( compare , distribution.x ); - if (hard_shadow != 1.0 ) { - float distance = compare - distribution.x ; - float variance = max( 0.00000, distribution.y * distribution.y ); - float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); - } - return occlusion; - } - float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { - float shadow = 1.0; - shadowCoord.xyz /= shadowCoord.w; - shadowCoord.z += shadowBias; - bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; - bool frustumTest = inFrustum && shadowCoord.z <= 1.0; - if ( frustumTest ) { - #if defined( SHADOWMAP_TYPE_PCF ) - vec2 texelSize = vec2( 1.0 ) / shadowMapSize; - float dx0 = - texelSize.x * shadowRadius; - float dy0 = - texelSize.y * shadowRadius; - float dx1 = + texelSize.x * shadowRadius; - float dy1 = + texelSize.y * shadowRadius; - float dx2 = dx0 / 2.0; - float dy2 = dy0 / 2.0; - float dx3 = dx1 / 2.0; - float dy3 = dy1 / 2.0; - shadow = ( - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) - ) * ( 1.0 / 17.0 ); - #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) - vec2 texelSize = vec2( 1.0 ) / shadowMapSize; - float dx = texelSize.x; - float dy = texelSize.y; - vec2 uv = shadowCoord.xy; - vec2 f = fract( uv * shadowMapSize + 0.5 ); - uv -= f * texelSize; - shadow = ( - texture2DCompare( shadowMap, uv, shadowCoord.z ) + - texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + - texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + - mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), - f.x ) + - mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), - f.x ) + - mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), - f.y ) + - mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), - f.y ) + - mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), - f.x ), - mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), - f.x ), - f.y ) - ) * ( 1.0 / 9.0 ); - #elif defined( SHADOWMAP_TYPE_VSM ) - shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); - #else - shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); - #endif - } - return mix( 1.0, shadow, shadowIntensity ); - } - vec2 cubeToUV( vec3 v, float texelSizeY ) { - vec3 absV = abs( v ); - float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); - absV *= scaleToCube; - v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); - vec2 planar = v.xy; - float almostATexel = 1.5 * texelSizeY; - float almostOne = 1.0 - almostATexel; - if ( absV.z >= almostOne ) { - if ( v.z > 0.0 ) - planar.x = 4.0 - v.x; - } else if ( absV.x >= almostOne ) { - float signX = sign( v.x ); - planar.x = v.z * signX + 2.0 * signX; - } else if ( absV.y >= almostOne ) { - float signY = sign( v.y ); - planar.x = v.x + 2.0 * signY + 2.0; - planar.y = v.z * signY - 2.0; - } - return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); - } - float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { - float shadow = 1.0; - vec3 lightToPosition = shadowCoord.xyz; - - float lightToPositionLength = length( lightToPosition ); - if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { - float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; - vec3 bd3D = normalize( lightToPosition ); - vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); - #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) - vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; - shadow = ( - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) - ) * ( 1.0 / 9.0 ); - #else - shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); - #endif - } - return mix( 1.0, shadow, shadowIntensity ); - } -#endif`,Jc=`#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`,ed=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) - vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); - vec4 shadowWorldPosition; -#endif -#if defined( USE_SHADOWMAP ) - #if NUM_DIR_LIGHT_SHADOWS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { - shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); - vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { - shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); - vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end - #endif -#endif -#if NUM_SPOT_LIGHT_COORDS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { - shadowWorldPosition = worldPosition; - #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) - shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; - #endif - vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end -#endif`,td=`float getShadowMask() { - float shadow = 1.0; - #ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 - DirectionalLightShadow directionalLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { - directionalLight = directionalLightShadows[ i ]; - shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; - } - #pragma unroll_loop_end - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - SpotLightShadow spotLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { - spotLight = spotLightShadows[ i ]; - shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; - } - #pragma unroll_loop_end - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - PointLightShadow pointLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { - pointLight = pointLightShadows[ i ]; - shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; - } - #pragma unroll_loop_end - #endif - #endif - return shadow; -}`,nd=`#ifdef USE_SKINNING - mat4 boneMatX = getBoneMatrix( skinIndex.x ); - mat4 boneMatY = getBoneMatrix( skinIndex.y ); - mat4 boneMatZ = getBoneMatrix( skinIndex.z ); - mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`,id=`#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`,ad=`#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`,rd=`#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`,od=`float specularStrength; -#ifdef USE_SPECULARMAP - vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); - specularStrength = texelSpecular.r; -#else - specularStrength = 1.0; -#endif`,sd=`#ifdef USE_SPECULARMAP - uniform sampler2D specularMap; -#endif`,ld=`#if defined( TONE_MAPPING ) - gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`,cd=`#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; }`,dd=`#ifdef USE_TRANSMISSION - material.transmission = transmission; - material.transmissionAlpha = 1.0; - material.thickness = thickness; - material.attenuationDistance = attenuationDistance; - material.attenuationColor = attenuationColor; - #ifdef USE_TRANSMISSIONMAP - material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; - #endif - #ifdef USE_THICKNESSMAP - material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; - #endif - vec3 pos = vWorldPosition; - vec3 v = normalize( cameraPosition - pos ); - vec3 n = inverseTransformDirection( normal, viewMatrix ); - vec4 transmitted = getIBLVolumeRefraction( - n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, - pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, - material.attenuationColor, material.attenuationDistance ); - material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); - totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); -#endif`,fd=`#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`,ud=`#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`,pd=`#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`,hd=`#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`,md=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 - vec4 worldPosition = vec4( transformed, 1.0 ); - #ifdef USE_BATCHING - worldPosition = batchingMatrix * worldPosition; - #endif - #ifdef USE_INSTANCING - worldPosition = instanceMatrix * worldPosition; - #endif - worldPosition = modelMatrix * worldPosition; -#endif`;const _d=`varying vec2 vUv; -uniform mat3 uvTransform; -void main() { - vUv = ( uvTransform * vec3( uv, 1 ) ).xy; - gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`,gd=`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 -}`,vd=`varying vec3 vWorldDirection; -#include -void main() { - vWorldDirection = transformDirection( position, modelMatrix ); - #include - #include - gl_Position.z = gl_Position.w; -}`,Sd=`#ifdef ENVMAP_TYPE_CUBE - uniform samplerCube envMap; -#elif defined( ENVMAP_TYPE_CUBE_UV ) - uniform sampler2D envMap; -#endif -uniform float flipEnvMap; -uniform float backgroundBlurriness; -uniform float backgroundIntensity; -uniform mat3 backgroundRotation; -varying vec3 vWorldDirection; -#include -void main() { - #ifdef ENVMAP_TYPE_CUBE - vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); - #elif defined( ENVMAP_TYPE_CUBE_UV ) - vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); - #else - vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); - #endif - texColor.rgb *= backgroundIntensity; - gl_FragColor = texColor; - #include - #include -}`,Ed=`varying vec3 vWorldDirection; -#include -void main() { - vWorldDirection = transformDirection( position, modelMatrix ); - #include - #include - gl_Position.z = gl_Position.w; -}`,xd=`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 -}`,Md=`#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; -}`,Td=`#if DEPTH_PACKING == 3200 - uniform float opacity; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -varying vec2 vHighPrecisionZW; -void main() { - vec4 diffuseColor = vec4( 1.0 ); - #include - #if DEPTH_PACKING == 3200 - diffuseColor.a = opacity; - #endif - #include - #include - #include - #include - #include - float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; - #if DEPTH_PACKING == 3200 - gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); - #elif DEPTH_PACKING == 3201 - gl_FragColor = packDepthToRGBA( fragCoordZ ); - #elif DEPTH_PACKING == 3202 - gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); - #elif DEPTH_PACKING == 3203 - gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); - #endif -}`,bd=`#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; -}`,Ad=`#define DISTANCE -uniform vec3 referencePosition; -uniform float nearDistance; -uniform float farDistance; -varying vec3 vWorldPosition; -#include -#include -#include -#include -#include -#include -#include -#include -void main () { - vec4 diffuseColor = vec4( 1.0 ); - #include - #include - #include - #include - #include - float dist = length( vWorldPosition - referencePosition ); - dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); - dist = saturate( dist ); - gl_FragColor = packDepthToRGBA( dist ); -}`,Rd=`varying vec3 vWorldDirection; -#include -void main() { - vWorldDirection = transformDirection( position, modelMatrix ); - #include - #include -}`,wd=`uniform sampler2D tEquirect; -varying vec3 vWorldDirection; -#include -void main() { - vec3 direction = normalize( vWorldDirection ); - vec2 sampleUV = equirectUv( direction ); - gl_FragColor = texture2D( tEquirect, sampleUV ); - #include - #include -}`,yd=`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 -}`,Cd=`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 -}`,Pd=`#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 -}`,Dd=`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 -}`,Ld=`#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 -}`,Ud=`#define LAMBERT -uniform vec3 diffuse; -uniform vec3 emissive; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; - #include - #include - #include - #include - #include - #include - #include -}`,Id=`#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; -}`,Nd=`#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 -}`,Od=`#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 -}`,Fd=`#define NORMAL -uniform float opacity; -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) - varying vec3 vViewPosition; -#endif -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); - #include - #include - #include - #include - gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); - #ifdef OPAQUE - gl_FragColor.a = 1.0; - #endif -}`,Bd=`#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 -}`,Hd=`#define PHONG -uniform vec3 diffuse; -uniform vec3 emissive; -uniform vec3 specular; -uniform float shininess; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; - #include - #include - #include - #include - #include - #include - #include -}`,Gd=`#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 -}`,kd=`#define STANDARD -#ifdef PHYSICAL - #define IOR - #define USE_SPECULAR -#endif -uniform vec3 diffuse; -uniform vec3 emissive; -uniform float roughness; -uniform float metalness; -uniform float opacity; -#ifdef IOR - uniform float ior; -#endif -#ifdef USE_SPECULAR - uniform float specularIntensity; - uniform vec3 specularColor; - #ifdef USE_SPECULAR_COLORMAP - uniform sampler2D specularColorMap; - #endif - #ifdef USE_SPECULAR_INTENSITYMAP - uniform sampler2D specularIntensityMap; - #endif -#endif -#ifdef USE_CLEARCOAT - uniform float clearcoat; - uniform float clearcoatRoughness; -#endif -#ifdef USE_DISPERSION - uniform float dispersion; -#endif -#ifdef USE_IRIDESCENCE - uniform float iridescence; - uniform float iridescenceIOR; - uniform float iridescenceThicknessMinimum; - uniform float iridescenceThicknessMaximum; -#endif -#ifdef USE_SHEEN - uniform vec3 sheenColor; - uniform float sheenRoughness; - #ifdef USE_SHEEN_COLORMAP - uniform sampler2D sheenColorMap; - #endif - #ifdef USE_SHEEN_ROUGHNESSMAP - uniform sampler2D sheenRoughnessMap; - #endif -#endif -#ifdef USE_ANISOTROPY - uniform vec2 anisotropyVector; - #ifdef USE_ANISOTROPYMAP - uniform sampler2D anisotropyMap; - #endif -#endif -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; - vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; - #include - vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; - #ifdef USE_SHEEN - float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); - outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; - #endif - #ifdef USE_CLEARCOAT - float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); - vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); - outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; - #endif - #include - #include - #include - #include - #include - #include -}`,Vd=`#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 -}`,zd=`#define TOON -uniform vec3 diffuse; -uniform vec3 emissive; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; - #include - #include - #include - #include - #include - #include -}`,Wd=`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 -}`,Xd=`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 -}`,Yd=`#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -}`,qd=`uniform vec3 color; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); - #include - #include - #include -}`,Kd=`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 -}`,Zd=`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 -}`,Ye={alphahash_fragment:gl,alphahash_pars_fragment:vl,alphamap_fragment:Sl,alphamap_pars_fragment:El,alphatest_fragment:xl,alphatest_pars_fragment:Ml,aomap_fragment:Tl,aomap_pars_fragment:bl,batching_pars_vertex:Al,batching_vertex:Rl,begin_vertex:wl,beginnormal_vertex:yl,bsdfs:Cl,iridescence_fragment:Pl,bumpmap_pars_fragment:Dl,clipping_planes_fragment:Ll,clipping_planes_pars_fragment:Ul,clipping_planes_pars_vertex:Il,clipping_planes_vertex:Nl,color_fragment:Ol,color_pars_fragment:Fl,color_pars_vertex:Bl,color_vertex:Hl,common:Gl,cube_uv_reflection_fragment:kl,defaultnormal_vertex:Vl,displacementmap_pars_vertex:zl,displacementmap_vertex:Wl,emissivemap_fragment:Xl,emissivemap_pars_fragment:Yl,colorspace_fragment:ql,colorspace_pars_fragment:Kl,envmap_fragment:Zl,envmap_common_pars_fragment:jl,envmap_pars_fragment:$l,envmap_pars_vertex:Ql,envmap_physical_pars_fragment:cc,envmap_vertex:Jl,fog_vertex:ec,fog_pars_vertex:tc,fog_fragment:nc,fog_pars_fragment:ic,gradientmap_pars_fragment:ac,lightmap_pars_fragment:rc,lights_lambert_fragment:oc,lights_lambert_pars_fragment:sc,lights_pars_begin:lc,lights_toon_fragment:dc,lights_toon_pars_fragment:fc,lights_phong_fragment:uc,lights_phong_pars_fragment:pc,lights_physical_fragment:hc,lights_physical_pars_fragment:mc,lights_fragment_begin:_c,lights_fragment_maps:gc,lights_fragment_end:vc,logdepthbuf_fragment:Sc,logdepthbuf_pars_fragment:Ec,logdepthbuf_pars_vertex:xc,logdepthbuf_vertex:Mc,map_fragment:Tc,map_pars_fragment:bc,map_particle_fragment:Ac,map_particle_pars_fragment:Rc,metalnessmap_fragment:wc,metalnessmap_pars_fragment:yc,morphinstance_vertex:Cc,morphcolor_vertex:Pc,morphnormal_vertex:Dc,morphtarget_pars_vertex:Lc,morphtarget_vertex:Uc,normal_fragment_begin:Ic,normal_fragment_maps:Nc,normal_pars_fragment:Oc,normal_pars_vertex:Fc,normal_vertex:Bc,normalmap_pars_fragment:Hc,clearcoat_normal_fragment_begin:Gc,clearcoat_normal_fragment_maps:kc,clearcoat_pars_fragment:Vc,iridescence_pars_fragment:zc,opaque_fragment:Wc,packing:Xc,premultiplied_alpha_fragment:Yc,project_vertex:qc,dithering_fragment:Kc,dithering_pars_fragment:Zc,roughnessmap_fragment:jc,roughnessmap_pars_fragment:$c,shadowmap_pars_fragment:Qc,shadowmap_pars_vertex:Jc,shadowmap_vertex:ed,shadowmask_pars_fragment:td,skinbase_vertex:nd,skinning_pars_vertex:id,skinning_vertex:ad,skinnormal_vertex:rd,specularmap_fragment:od,specularmap_pars_fragment:sd,tonemapping_fragment:ld,tonemapping_pars_fragment:cd,transmission_fragment:dd,transmission_pars_fragment:fd,uv_pars_fragment:ud,uv_pars_vertex:pd,uv_vertex:hd,worldpos_vertex:md,background_vert:_d,background_frag:gd,backgroundCube_vert:vd,backgroundCube_frag:Sd,cube_vert:Ed,cube_frag:xd,depth_vert:Md,depth_frag:Td,distanceRGBA_vert:bd,distanceRGBA_frag:Ad,equirect_vert:Rd,equirect_frag:wd,linedashed_vert:yd,linedashed_frag:Cd,meshbasic_vert:Pd,meshbasic_frag:Dd,meshlambert_vert:Ld,meshlambert_frag:Ud,meshmatcap_vert:Id,meshmatcap_frag:Nd,meshnormal_vert:Od,meshnormal_frag:Fd,meshphong_vert:Bd,meshphong_frag:Hd,meshphysical_vert:Gd,meshphysical_frag:kd,meshtoon_vert:Vd,meshtoon_frag:zd,points_vert:Wd,points_frag:Xd,shadow_vert:Yd,shadow_frag:qd,sprite_vert:Kd,sprite_frag:Zd},me={common:{diffuse:{value:new Ae(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new at},alphaMap:{value:null},alphaMapTransform:{value:new at},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new at}},envmap:{envMap:{value:null},envMapRotation:{value:new at},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new at}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new at}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new at},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new at},normalScale:{value:new Ze(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new at},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new at}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new at}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new at}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ae(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ae(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new at},alphaTest:{value:0},uvTransform:{value:new at}},sprite:{diffuse:{value:new Ae(16777215)},opacity:{value:1},center:{value:new Ze(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new at},alphaMap:{value:null},alphaMapTransform:{value:new at},alphaTest:{value:0}}},Kt={basic:{uniforms:It([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.fog]),vertexShader:Ye.meshbasic_vert,fragmentShader:Ye.meshbasic_frag},lambert:{uniforms:It([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new Ae(0)}}]),vertexShader:Ye.meshlambert_vert,fragmentShader:Ye.meshlambert_frag},phong:{uniforms:It([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new Ae(0)},specular:{value:new Ae(1118481)},shininess:{value:30}}]),vertexShader:Ye.meshphong_vert,fragmentShader:Ye.meshphong_frag},standard:{uniforms:It([me.common,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.roughnessmap,me.metalnessmap,me.fog,me.lights,{emissive:{value:new Ae(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag},toon:{uniforms:It([me.common,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.gradientmap,me.fog,me.lights,{emissive:{value:new Ae(0)}}]),vertexShader:Ye.meshtoon_vert,fragmentShader:Ye.meshtoon_frag},matcap:{uniforms:It([me.common,me.bumpmap,me.normalmap,me.displacementmap,me.fog,{matcap:{value:null}}]),vertexShader:Ye.meshmatcap_vert,fragmentShader:Ye.meshmatcap_frag},points:{uniforms:It([me.points,me.fog]),vertexShader:Ye.points_vert,fragmentShader:Ye.points_frag},dashed:{uniforms:It([me.common,me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ye.linedashed_vert,fragmentShader:Ye.linedashed_frag},depth:{uniforms:It([me.common,me.displacementmap]),vertexShader:Ye.depth_vert,fragmentShader:Ye.depth_frag},normal:{uniforms:It([me.common,me.bumpmap,me.normalmap,me.displacementmap,{opacity:{value:1}}]),vertexShader:Ye.meshnormal_vert,fragmentShader:Ye.meshnormal_frag},sprite:{uniforms:It([me.sprite,me.fog]),vertexShader:Ye.sprite_vert,fragmentShader:Ye.sprite_frag},background:{uniforms:{uvTransform:{value:new at},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ye.background_vert,fragmentShader:Ye.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new at}},vertexShader:Ye.backgroundCube_vert,fragmentShader:Ye.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ye.cube_vert,fragmentShader:Ye.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ye.equirect_vert,fragmentShader:Ye.equirect_frag},distanceRGBA:{uniforms:It([me.common,me.displacementmap,{referencePosition:{value:new Te},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ye.distanceRGBA_vert,fragmentShader:Ye.distanceRGBA_frag},shadow:{uniforms:It([me.lights,me.fog,{color:{value:new Ae(0)},opacity:{value:1}}]),vertexShader:Ye.shadow_vert,fragmentShader:Ye.shadow_frag}};Kt.physical={uniforms:It([Kt.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new at},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new at},clearcoatNormalScale:{value:new Ze(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new at},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new at},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new at},sheen:{value:0},sheenColor:{value:new Ae(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new at},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new at},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new at},transmissionSamplerSize:{value:new Ze},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new at},attenuationDistance:{value:0},attenuationColor:{value:new Ae(0)},specularColor:{value:new Ae(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new at},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new at},anisotropyVector:{value:new Ze},anisotropyMap:{value:null},anisotropyMapTransform:{value:new at}}]),vertexShader:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag};const pi={r:0,b:0,g:0},_n=new Qr,jd=new zn;function $d(e,t,n,i,r,a,o){const s=new Ae(0);let u=a===!0?0:1,f,m,_=null,v=0,p=null;function b(M){let x=M.isScene===!0?M.background:null;return x&&x.isTexture&&(x=(M.backgroundBlurriness>0?n:t).get(x)),x}function A(M){let x=!1;const y=b(M);y===null?l(s,u):y&&y.isColor&&(l(y,1),x=!0);const U=e.xr.getEnvironmentBlendMode();U==="additive"?i.buffers.color.setClear(0,0,0,1,o):U==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(e.autoClear||x)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))}function c(M,x){const y=b(x);y&&(y.isCubeTexture||y.mapping===Ci)?(m===void 0&&(m=new Bt(new $r(1,1,1),new Ot({name:"BackgroundCubeMaterial",uniforms:qa(Kt.backgroundCube.uniforms),vertexShader:Kt.backgroundCube.vertexShader,fragmentShader:Kt.backgroundCube.fragmentShader,side:zt,depthTest:!1,depthWrite:!1,fog:!1})),m.geometry.deleteAttribute("normal"),m.geometry.deleteAttribute("uv"),m.onBeforeRender=function(U,F,V){this.matrixWorld.copyPosition(V.matrixWorld)},Object.defineProperty(m.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(m)),_n.copy(x.backgroundRotation),_n.x*=-1,_n.y*=-1,_n.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(_n.y*=-1,_n.z*=-1),m.material.uniforms.envMap.value=y,m.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,m.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,m.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,m.material.uniforms.backgroundRotation.value.setFromMatrix4(jd.makeRotationFromEuler(_n)),m.material.toneMapped=Mt.getTransfer(y.colorSpace)!==ut,(_!==y||v!==y.version||p!==e.toneMapping)&&(m.material.needsUpdate=!0,_=y,v=y.version,p=e.toneMapping),m.layers.enableAll(),M.unshift(m,m.geometry,m.material,0,0,null)):y&&y.isTexture&&(f===void 0&&(f=new Bt(new ma(2,2),new Ot({name:"BackgroundMaterial",uniforms:qa(Kt.background.uniforms),vertexShader:Kt.background.vertexShader,fragmentShader:Kt.background.fragmentShader,side:ri,depthTest:!1,depthWrite:!1,fog:!1})),f.geometry.deleteAttribute("normal"),Object.defineProperty(f.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(f)),f.material.uniforms.t2D.value=y,f.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,f.material.toneMapped=Mt.getTransfer(y.colorSpace)!==ut,y.matrixAutoUpdate===!0&&y.updateMatrix(),f.material.uniforms.uvTransform.value.copy(y.matrix),(_!==y||v!==y.version||p!==e.toneMapping)&&(f.material.needsUpdate=!0,_=y,v=y.version,p=e.toneMapping),f.layers.enableAll(),M.unshift(f,f.geometry,f.material,0,0,null))}function l(M,x){M.getRGB(pi,jr(e)),i.buffers.color.setClear(pi.r,pi.g,pi.b,x,o)}function O(){m!==void 0&&(m.geometry.dispose(),m.material.dispose()),f!==void 0&&(f.geometry.dispose(),f.material.dispose())}return{getClearColor:function(){return s},setClearColor:function(M,x=1){s.set(M),u=x,l(s,u)},getClearAlpha:function(){return u},setClearAlpha:function(M){u=M,l(s,u)},render:A,addToRenderList:c,dispose:O}}function Qd(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=v(null);let a=r,o=!1;function s(g,D,Z,k,Y){let J=!1;const $=_(k,Z,D);a!==$&&(a=$,f(a.object)),J=p(g,k,Z,Y),J&&b(g,k,Z,Y),Y!==null&&t.update(Y,e.ELEMENT_ARRAY_BUFFER),(J||o)&&(o=!1,x(g,D,Z,k),Y!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(Y).buffer))}function u(){return e.createVertexArray()}function f(g){return e.bindVertexArray(g)}function m(g){return e.deleteVertexArray(g)}function _(g,D,Z){const k=Z.wireframe===!0;let Y=i[g.id];Y===void 0&&(Y={},i[g.id]=Y);let J=Y[D.id];J===void 0&&(J={},Y[D.id]=J);let $=J[k];return $===void 0&&($=v(u()),J[k]=$),$}function v(g){const D=[],Z=[],k=[];for(let Y=0;Y=0){const Ce=Y[X];let Ne=J[X];if(Ne===void 0&&(X==="instanceMatrix"&&g.instanceMatrix&&(Ne=g.instanceMatrix),X==="instanceColor"&&g.instanceColor&&(Ne=g.instanceColor)),Ce===void 0||Ce.attribute!==Ne||Ne&&Ce.data!==Ne.data)return!0;$++}return a.attributesNum!==$||a.index!==k}function b(g,D,Z,k){const Y={},J=D.attributes;let $=0;const ne=Z.getAttributes();for(const X in ne)if(ne[X].location>=0){let Ce=J[X];Ce===void 0&&(X==="instanceMatrix"&&g.instanceMatrix&&(Ce=g.instanceMatrix),X==="instanceColor"&&g.instanceColor&&(Ce=g.instanceColor));const Ne={};Ne.attribute=Ce,Ce&&Ce.data&&(Ne.data=Ce.data),Y[X]=Ne,$++}a.attributes=Y,a.attributesNum=$,a.index=k}function A(){const g=a.newAttributes;for(let D=0,Z=g.length;D=0){let xe=Y[ne];if(xe===void 0&&(ne==="instanceMatrix"&&g.instanceMatrix&&(xe=g.instanceMatrix),ne==="instanceColor"&&g.instanceColor&&(xe=g.instanceColor)),xe!==void 0){const Ce=xe.normalized,Ne=xe.itemSize,je=t.get(xe);if(je===void 0)continue;const Je=je.buffer,Q=je.type,de=je.bytesPerElement,Me=Q===e.INT||Q===e.UNSIGNED_INT||xe.gpuType===Xr;if(xe.isInterleavedBufferAttribute){const he=xe.data,Le=he.stride,Ie=xe.offset;if(he.isInstancedInterleavedBuffer){for(let ke=0;ke0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";F="mediump"}return F==="mediump"&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let f=n.precision!==void 0?n.precision:"highp";const m=u(f);m!==f&&(console.warn("THREE.WebGLRenderer:",f,"not supported, using",m,"instead."),f=m);const _=n.logarithmicDepthBuffer===!0,v=n.reverseDepthBuffer===!0&&t.has("EXT_clip_control"),p=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),b=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),A=e.getParameter(e.MAX_TEXTURE_SIZE),c=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),l=e.getParameter(e.MAX_VERTEX_ATTRIBS),O=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),M=e.getParameter(e.MAX_VARYING_VECTORS),x=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),y=b>0,U=e.getParameter(e.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:u,textureFormatReadable:o,textureTypeReadable:s,precision:f,logarithmicDepthBuffer:_,reverseDepthBuffer:v,maxTextures:p,maxVertexTextures:b,maxTextureSize:A,maxCubemapSize:c,maxAttributes:l,maxVertexUniforms:O,maxVaryings:M,maxFragmentUniforms:x,vertexTextures:y,maxSamples:U}}function tf(e){const t=this;let n=null,i=0,r=!1,a=!1;const o=new Gr,s=new at,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(_,v){const p=_.length!==0||v||i!==0||r;return r=v,i=_.length,p},this.beginShadows=function(){a=!0,m(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(_,v){n=m(_,v,0)},this.setState=function(_,v,p){const b=_.clippingPlanes,A=_.clipIntersection,c=_.clipShadows,l=e.get(_);if(!r||b===null||b.length===0||a&&!c)a?m(null):f();else{const O=a?0:i,M=O*4;let x=l.clippingState||null;u.value=x,x=m(b,v,M,p);for(let y=0;y!==M;++y)x[y]=n[y];l.clippingState=x,this.numIntersection=A?this.numPlanes:0,this.numPlanes+=O}};function f(){u.value!==n&&(u.value=n,u.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function m(_,v,p,b){const A=_!==null?_.length:0;let c=null;if(A!==0){if(c=u.value,b!==!0||c===null){const l=p+A*4,O=v.matrixWorldInverse;s.getNormalMatrix(O),(c===null||c.length0){const f=new Ss(u.height);return f.fromEquirectangularTexture(e,o),t.set(o,f),o.addEventListener("dispose",r),n(f.texture,o.mapping)}else return null}}return o}function r(o){const s=o.target;s.removeEventListener("dispose",r);const u=t.get(s);u!==void 0&&(t.delete(s),u.dispose())}function a(){t=new WeakMap}return{get:i,dispose:a}}const On=4,sr=[.125,.215,.35,.446,.526,.582],Mn=20,Bi=new eo,lr=new Ae;let Hi=null,Gi=0,ki=0,Vi=!1;const En=(1+Math.sqrt(5))/2,Dn=1/En,cr=[new Te(-En,Dn,0),new Te(En,Dn,0),new Te(-Dn,0,En),new Te(Dn,0,En),new Te(0,En,-Dn),new Te(0,En,Dn),new Te(-1,1,-1),new Te(1,1,-1),new Te(-1,1,1),new Te(1,1,1)];class dr{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,n=0,i=.1,r=100){Hi=this._renderer.getRenderTarget(),Gi=this._renderer.getActiveCubeFace(),ki=this._renderer.getActiveMipmapLevel(),Vi=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(t,i,r,a),n>0&&this._blur(a,0,0,n),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(t,n=null){return this._fromTexture(t,n)}fromCubemap(t,n=null){return this._fromTexture(t,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=pr(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ur(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?M:0,M,M),m.setRenderTarget(r),A&&m.render(b,s),m.render(t,s)}b.geometry.dispose(),b.material.dispose(),m.toneMapping=v,m.autoClear=_,t.background=c}_textureToCubeUV(t,n){const i=this._renderer,r=t.mapping===li||t.mapping===Wn;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=pr()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ur());const a=r?this._cubemapMaterial:this._equirectMaterial,o=new Bt(this._lodPlanes[0],a),s=a.uniforms;s.envMap.value=t;const u=this._cubeSize;hi(n,0,0,3*u,2*u),i.setRenderTarget(n),i.render(o,Bi)}_applyPMREM(t){const n=this._renderer,i=n.autoClear;n.autoClear=!1;const r=this._lodPlanes.length;for(let a=1;aMn&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${c} samples when the maximum is set to ${Mn}`);const l=[];let O=0;for(let F=0;FM-On?r-M+On:0),U=4*(this._cubeSize-x);hi(n,y,U,3*x,2*x),u.setRenderTarget(n),u.render(_,Bi)}}function af(e){const t=[],n=[],i=[];let r=e;const a=e-On+1+sr.length;for(let o=0;oe-On?u=sr[o-e+On-1]:o===0&&(u=0),i.push(u);const f=1/(s-2),m=-f,_=1+f,v=[m,m,_,m,_,_,m,m,_,_,m,_],p=6,b=6,A=3,c=2,l=1,O=new Float32Array(A*b*p),M=new Float32Array(c*b*p),x=new Float32Array(l*b*p);for(let U=0;U2?0:-1,E=[F,V,0,F+2/3,V,0,F+2/3,V+1,0,F,V,0,F+2/3,V+1,0,F,V+1,0];O.set(E,A*b*U),M.set(v,c*b*U);const g=[U,U,U,U,U,U];x.set(g,l*b*U)}const y=new Vt;y.setAttribute("position",new wt(O,A)),y.setAttribute("uv",new wt(M,c)),y.setAttribute("faceIndex",new wt(x,l)),t.push(y),r>On&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}function fr(e,t,n){const i=new jt(e,t,n);return i.texture.mapping=Ci,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function hi(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function rf(e,t,n){const i=new Float32Array(Mn),r=new Te(0,1,0);return new Ot({name:"SphericalGaussianBlur",defines:{n:Mn,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:_a(),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:cn,depthTest:!1,depthWrite:!1})}function ur(){return new Ot({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:_a(),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:cn,depthTest:!1,depthWrite:!1})}function pr(){return new Ot({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:_a(),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:cn,depthTest:!1,depthWrite:!1})}function _a(){return` - - precision mediump float; - precision mediump int; - - attribute float faceIndex; - - varying vec3 vOutputDirection; - - // RH coordinate system; PMREM face-indexing convention - vec3 getDirection( vec2 uv, float face ) { - - uv = 2.0 * uv - 1.0; - - vec3 direction = vec3( uv, 1.0 ); - - if ( face == 0.0 ) { - - direction = direction.zyx; // ( 1, v, u ) pos x - - } else if ( face == 1.0 ) { - - direction = direction.xzy; - direction.xz *= -1.0; // ( -u, 1, -v ) pos y - - } else if ( face == 2.0 ) { - - direction.x *= -1.0; // ( -u, v, 1 ) pos z - - } else if ( face == 3.0 ) { - - direction = direction.zyx; - direction.xz *= -1.0; // ( -1, v, -u ) neg x - - } else if ( face == 4.0 ) { - - direction = direction.xzy; - direction.xy *= -1.0; // ( -u, -1, v ) neg y - - } else if ( face == 5.0 ) { - - direction.z *= -1.0; // ( u, v, -1 ) neg z - - } - - return direction; - - } - - void main() { - - vOutputDirection = getDirection( uv, faceIndex ); - gl_Position = vec4( position, 1.0 ); - - } - `}function of(e){let t=new WeakMap,n=null;function i(s){if(s&&s.isTexture){const u=s.mapping,f=u===na||u===ia,m=u===li||u===Wn;if(f||m){let _=t.get(s);const v=_!==void 0?_.texture.pmremVersion:0;if(s.isRenderTargetTexture&&s.pmremVersion!==v)return n===null&&(n=new dr(e)),_=f?n.fromEquirectangular(s,_):n.fromCubemap(s,_),_.texture.pmremVersion=s.pmremVersion,t.set(s,_),_.texture;if(_!==void 0)return _.texture;{const p=s.image;return f&&p&&p.height>0||m&&p&&r(p)?(n===null&&(n=new dr(e)),_=f?n.fromEquirectangular(s):n.fromCubemap(s),_.texture.pmremVersion=s.pmremVersion,t.set(s,_),s.addEventListener("dispose",a),_.texture):null}}}return s}function r(s){let u=0;const f=6;for(let m=0;mt.maxTextureSize&&(y=Math.ceil(x/t.maxTextureSize),x=t.maxTextureSize);const U=new Float32Array(x*y*4*_),F=new Zr(U,x,y,_);F.type=bn,F.needsUpdate=!0;const V=M*4;for(let g=0;g<_;g++){const D=c[g],Z=l[g],k=O[g],Y=x*y*4*g;for(let J=0;J0)return e;const r=t*n;let a=mr[r];if(a===void 0&&(a=new Float32Array(r),mr[r]=a),t!==0){i.toArray(a,0);for(let o=1,s=0;o!==t;++o)s+=n,e[o].toArray(a,s)}return a}function bt(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n":" "} ${s}: ${n[o]}`)}return i.join(` -`)}const Mr=new at;function ou(e){Mt._getMatrix(Mr,Mt.workingColorSpace,e);const t=`mat3( ${Mr.elements.map(n=>n.toFixed(4))} )`;switch(Mt.getTransfer(e)){case Jr:return[t,"LinearTransferOETF"];case ut:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Tr(e,t,n){const i=e.getShaderParameter(t,e.COMPILE_STATUS),r=e.getShaderInfoLog(t).trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return n.toUpperCase()+` - -`+r+` - -`+ru(e.getShaderSource(t),o)}else return r}function su(e,t){const n=ou(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(` -`)}function lu(e,t){let n;switch(t){case Ls:n="Linear";break;case Ds:n="Reinhard";break;case Ps:n="Cineon";break;case to:n="ACESFilmic";break;case Cs:n="AgX";break;case ys:n="Neutral";break;case ws:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const mi=new Te;function cu(){Mt.getLuminanceCoefficients(mi);const e=mi.x.toFixed(4),t=mi.y.toFixed(4),n=mi.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`," return dot( weights, rgb );","}"].join(` -`)}function du(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ei).join(` -`)}function fu(e){const t=[];for(const n in e){const i=e[n];i!==!1&&t.push("#define "+n+" "+i)}return t.join(` -`)}function uu(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function la(e){return e.replace(pu,mu)}const hu=new Map;function mu(e,t){let n=Ye[t];if(n===void 0){const i=hu.get(t);if(i!==void 0)n=Ye[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw new Error("Can not resolve #include <"+t+">")}return la(n)}const _u=/#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 Rr(e){return e.replace(_u,gu)}function gu(e,t,n,i){let r="";for(let a=parseInt(t);a0&&(c+=` -`),l=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(ei).join(` -`),l.length>0&&(l+=` -`)):(c=[wr(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,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 "+m:"",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&&n.flatShading===!1?"#define USE_TANGENT":"",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&&n.flatShading===!1?"#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 "+u:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` -`].filter(ei).join(` -`),l=[wr(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,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 "+f:"",n.envMap?"#define "+m:"",n.envMap?"#define "+_:"",v?"#define CUBEUV_TEXEL_WIDTH "+v.texelWidth:"",v?"#define CUBEUV_TEXEL_HEIGHT "+v.texelHeight:"",v?"#define CUBEUV_MAX_MIP "+v.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.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&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#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.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 "+u:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==sn?"#define TONE_MAPPING":"",n.toneMapping!==sn?Ye.tonemapping_pars_fragment:"",n.toneMapping!==sn?lu("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ye.colorspace_pars_fragment,su("linearToOutputTexel",n.outputColorSpace),cu(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",` -`].filter(ei).join(` -`)),o=la(o),o=br(o,n),o=Ar(o,n),s=la(s),s=br(s,n),s=Ar(s,n),o=Rr(o),s=Rr(s),n.isRawShaderMaterial!==!0&&(O=`#version 300 es -`,c=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(` -`)+` -`+c,l=["#define varying in",n.glslVersion===Za?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Za?"":"#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(` -`)+` -`+l);const M=O+c+o,x=O+l+s,y=xr(r,r.VERTEX_SHADER,M),U=xr(r,r.FRAGMENT_SHADER,x);r.attachShader(A,y),r.attachShader(A,U),n.index0AttributeName!==void 0?r.bindAttribLocation(A,0,n.index0AttributeName):n.morphTargets===!0&&r.bindAttribLocation(A,0,"position"),r.linkProgram(A);function F(D){if(e.debug.checkShaderErrors){const Z=r.getProgramInfoLog(A).trim(),k=r.getShaderInfoLog(y).trim(),Y=r.getShaderInfoLog(U).trim();let J=!0,$=!0;if(r.getProgramParameter(A,r.LINK_STATUS)===!1)if(J=!1,typeof e.debug.onShaderError=="function")e.debug.onShaderError(r,A,y,U);else{const ne=Tr(r,y,"vertex"),X=Tr(r,U,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(A,r.VALIDATE_STATUS)+` - -Material Name: `+D.name+` -Material Type: `+D.type+` - -Program Info Log: `+Z+` -`+ne+` -`+X)}else Z!==""?console.warn("THREE.WebGLProgram: Program Info Log:",Z):(k===""||Y==="")&&($=!1);$&&(D.diagnostics={runnable:J,programLog:Z,vertexShader:{log:k,prefix:c},fragmentShader:{log:Y,prefix:l}})}r.deleteShader(y),r.deleteShader(U),V=new Ei(r,A),E=uu(r,A)}let V;this.getUniforms=function(){return V===void 0&&F(this),V};let E;this.getAttributes=function(){return E===void 0&&F(this),E};let g=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return g===!1&&(g=r.getProgramParameter(A,iu)),g},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(A),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=au++,this.cacheKey=t,this.usedTimes=1,this.program=A,this.vertexShader=y,this.fragmentShader=U,this}let bu=0;class Au{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const n=t.vertexShader,i=t.fragmentShader,r=this._getShaderStage(n),a=this._getShaderStage(i),o=this._getShaderCacheForMaterial(t);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(a)===!1&&(o.add(a),a.usedTimes++),this}remove(t){const n=this.materialCache.get(t);for(const i of n)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const n=this.materialCache;let i=n.get(t);return i===void 0&&(i=new Set,n.set(t,i)),i}_getShaderStage(t){const n=this.shaderCache;let i=n.get(t);return i===void 0&&(i=new Ru(t),n.set(t,i)),i}}class Ru{constructor(t){this.id=bu++,this.code=t,this.usedTimes=0}}function wu(e,t,n,i,r,a,o){const s=new As,u=new Au,f=new Set,m=[],_=r.logarithmicDepthBuffer,v=r.vertexTextures;let p=r.precision;const b={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function A(E){return f.add(E),E===0?"uv":`uv${E}`}function c(E,g,D,Z,k){const Y=Z.fog,J=k.geometry,$=E.isMeshStandardMaterial?Z.environment:null,ne=(E.isMeshStandardMaterial?n:t).get(E.envMap||$),X=ne&&ne.mapping===Ci?ne.image.height:null,xe=b[E.type];E.precision!==null&&(p=r.getMaxPrecision(E.precision),p!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",p,"instead."));const Ce=J.morphAttributes.position||J.morphAttributes.normal||J.morphAttributes.color,Ne=Ce!==void 0?Ce.length:0;let je=0;J.morphAttributes.position!==void 0&&(je=1),J.morphAttributes.normal!==void 0&&(je=2),J.morphAttributes.color!==void 0&&(je=3);let Je,Q,de,Me;if(xe){const ye=Kt[xe];Je=ye.vertexShader,Q=ye.fragmentShader}else Je=E.vertexShader,Q=E.fragmentShader,u.update(E),de=u.getVertexShaderID(E),Me=u.getFragmentShaderID(E);const he=e.getRenderTarget(),Le=e.state.buffers.depth.getReversed(),Ie=k.isInstancedMesh===!0,ke=k.isBatchedMesh===!0,nt=!!E.map,Ke=!!E.matcap,dt=!!ne,R=!!E.aoMap,gt=!!E.lightMap,ze=!!E.bumpMap,We=!!E.normalMap,we=!!E.displacementMap,et=!!E.emissiveMap,be=!!E.metalnessMap,S=!!E.roughnessMap,d=E.anisotropy>0,H=E.clearcoat>0,B=E.dispersion>0,W=E.iridescence>0,G=E.sheen>0,re=E.transmission>0,ie=d&&!!E.anisotropyMap,le=H&&!!E.clearcoatMap,Pe=H&&!!E.clearcoatNormalMap,q=H&&!!E.clearcoatRoughnessMap,ce=W&&!!E.iridescenceMap,_e=W&&!!E.iridescenceThicknessMap,Re=G&&!!E.sheenColorMap,ge=G&&!!E.sheenRoughnessMap,Xe=!!E.specularMap,Ge=!!E.specularColorMap,rt=!!E.specularIntensityMap,I=re&&!!E.transmissionMap,ue=re&&!!E.thicknessMap,K=!!E.gradientMap,C=!!E.alphaMap,z=E.alphaTest>0,j=!!E.alphaHash,se=!!E.extensions;let ve=sn;E.toneMapped&&(he===null||he.isXRRenderTarget===!0)&&(ve=e.toneMapping);const Oe={shaderID:xe,shaderType:E.type,shaderName:E.name,vertexShader:Je,fragmentShader:Q,defines:E.defines,customVertexShaderID:de,customFragmentShaderID:Me,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:p,batching:ke,batchingColor:ke&&k._colorsTexture!==null,instancing:Ie,instancingColor:Ie&&k.instanceColor!==null,instancingMorph:Ie&&k.morphTexture!==null,supportsVertexTextures:v,outputColorSpace:he===null?e.outputColorSpace:he.isXRRenderTarget===!0?he.texture.colorSpace:yi,alphaToCoverage:!!E.alphaToCoverage,map:nt,matcap:Ke,envMap:dt,envMapMode:dt&&ne.mapping,envMapCubeUVHeight:X,aoMap:R,lightMap:gt,bumpMap:ze,normalMap:We,displacementMap:v&&we,emissiveMap:et,normalMapObjectSpace:We&&E.normalMapType===xs,normalMapTangentSpace:We&&E.normalMapType===Es,metalnessMap:be,roughnessMap:S,anisotropy:d,anisotropyMap:ie,clearcoat:H,clearcoatMap:le,clearcoatNormalMap:Pe,clearcoatRoughnessMap:q,dispersion:B,iridescence:W,iridescenceMap:ce,iridescenceThicknessMap:_e,sheen:G,sheenColorMap:Re,sheenRoughnessMap:ge,specularMap:Xe,specularColorMap:Ge,specularIntensityMap:rt,transmission:re,transmissionMap:I,thicknessMap:ue,gradientMap:K,opaque:E.transparent===!1&&E.blending===vi&&E.alphaToCoverage===!1,alphaMap:C,alphaTest:z,alphaHash:j,combine:E.combine,mapUv:nt&&A(E.map.channel),aoMapUv:R&&A(E.aoMap.channel),lightMapUv:gt&&A(E.lightMap.channel),bumpMapUv:ze&&A(E.bumpMap.channel),normalMapUv:We&&A(E.normalMap.channel),displacementMapUv:we&&A(E.displacementMap.channel),emissiveMapUv:et&&A(E.emissiveMap.channel),metalnessMapUv:be&&A(E.metalnessMap.channel),roughnessMapUv:S&&A(E.roughnessMap.channel),anisotropyMapUv:ie&&A(E.anisotropyMap.channel),clearcoatMapUv:le&&A(E.clearcoatMap.channel),clearcoatNormalMapUv:Pe&&A(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:q&&A(E.clearcoatRoughnessMap.channel),iridescenceMapUv:ce&&A(E.iridescenceMap.channel),iridescenceThicknessMapUv:_e&&A(E.iridescenceThicknessMap.channel),sheenColorMapUv:Re&&A(E.sheenColorMap.channel),sheenRoughnessMapUv:ge&&A(E.sheenRoughnessMap.channel),specularMapUv:Xe&&A(E.specularMap.channel),specularColorMapUv:Ge&&A(E.specularColorMap.channel),specularIntensityMapUv:rt&&A(E.specularIntensityMap.channel),transmissionMapUv:I&&A(E.transmissionMap.channel),thicknessMapUv:ue&&A(E.thicknessMap.channel),alphaMapUv:C&&A(E.alphaMap.channel),vertexTangents:!!J.attributes.tangent&&(We||d),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!J.attributes.color&&J.attributes.color.itemSize===4,pointsUvs:k.isPoints===!0&&!!J.attributes.uv&&(nt||C),fog:!!Y,useFog:E.fog===!0,fogExp2:!!Y&&Y.isFogExp2,flatShading:E.flatShading===!0,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:_,reverseDepthBuffer:Le,skinning:k.isSkinnedMesh===!0,morphTargets:J.morphAttributes.position!==void 0,morphNormals:J.morphAttributes.normal!==void 0,morphColors:J.morphAttributes.color!==void 0,morphTargetsCount:Ne,morphTextureStride:je,numDirLights:g.directional.length,numPointLights:g.point.length,numSpotLights:g.spot.length,numSpotLightMaps:g.spotLightMap.length,numRectAreaLights:g.rectArea.length,numHemiLights:g.hemi.length,numDirLightShadows:g.directionalShadowMap.length,numPointLightShadows:g.pointShadowMap.length,numSpotLightShadows:g.spotShadowMap.length,numSpotLightShadowsWithMaps:g.numSpotLightShadowsWithMaps,numLightProbes:g.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:E.dithering,shadowMapEnabled:e.shadowMap.enabled&&D.length>0,shadowMapType:e.shadowMap.type,toneMapping:ve,decodeVideoTexture:nt&&E.map.isVideoTexture===!0&&Mt.getTransfer(E.map.colorSpace)===ut,decodeVideoTextureEmissive:et&&E.emissiveMap.isVideoTexture===!0&&Mt.getTransfer(E.emissiveMap.colorSpace)===ut,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===Zt,flipSided:E.side===zt,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:se&&E.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(se&&E.extensions.multiDraw===!0||ke)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return Oe.vertexUv1s=f.has(1),Oe.vertexUv2s=f.has(2),Oe.vertexUv3s=f.has(3),f.clear(),Oe}function l(E){const g=[];if(E.shaderID?g.push(E.shaderID):(g.push(E.customVertexShaderID),g.push(E.customFragmentShaderID)),E.defines!==void 0)for(const D in E.defines)g.push(D),g.push(E.defines[D]);return E.isRawShaderMaterial===!1&&(O(g,E),M(g,E),g.push(e.outputColorSpace)),g.push(E.customProgramCacheKey),g.join()}function O(E,g){E.push(g.precision),E.push(g.outputColorSpace),E.push(g.envMapMode),E.push(g.envMapCubeUVHeight),E.push(g.mapUv),E.push(g.alphaMapUv),E.push(g.lightMapUv),E.push(g.aoMapUv),E.push(g.bumpMapUv),E.push(g.normalMapUv),E.push(g.displacementMapUv),E.push(g.emissiveMapUv),E.push(g.metalnessMapUv),E.push(g.roughnessMapUv),E.push(g.anisotropyMapUv),E.push(g.clearcoatMapUv),E.push(g.clearcoatNormalMapUv),E.push(g.clearcoatRoughnessMapUv),E.push(g.iridescenceMapUv),E.push(g.iridescenceThicknessMapUv),E.push(g.sheenColorMapUv),E.push(g.sheenRoughnessMapUv),E.push(g.specularMapUv),E.push(g.specularColorMapUv),E.push(g.specularIntensityMapUv),E.push(g.transmissionMapUv),E.push(g.thicknessMapUv),E.push(g.combine),E.push(g.fogExp2),E.push(g.sizeAttenuation),E.push(g.morphTargetsCount),E.push(g.morphAttributeCount),E.push(g.numDirLights),E.push(g.numPointLights),E.push(g.numSpotLights),E.push(g.numSpotLightMaps),E.push(g.numHemiLights),E.push(g.numRectAreaLights),E.push(g.numDirLightShadows),E.push(g.numPointLightShadows),E.push(g.numSpotLightShadows),E.push(g.numSpotLightShadowsWithMaps),E.push(g.numLightProbes),E.push(g.shadowMapType),E.push(g.toneMapping),E.push(g.numClippingPlanes),E.push(g.numClipIntersection),E.push(g.depthPacking)}function M(E,g){s.disableAll(),g.supportsVertexTextures&&s.enable(0),g.instancing&&s.enable(1),g.instancingColor&&s.enable(2),g.instancingMorph&&s.enable(3),g.matcap&&s.enable(4),g.envMap&&s.enable(5),g.normalMapObjectSpace&&s.enable(6),g.normalMapTangentSpace&&s.enable(7),g.clearcoat&&s.enable(8),g.iridescence&&s.enable(9),g.alphaTest&&s.enable(10),g.vertexColors&&s.enable(11),g.vertexAlphas&&s.enable(12),g.vertexUv1s&&s.enable(13),g.vertexUv2s&&s.enable(14),g.vertexUv3s&&s.enable(15),g.vertexTangents&&s.enable(16),g.anisotropy&&s.enable(17),g.alphaHash&&s.enable(18),g.batching&&s.enable(19),g.dispersion&&s.enable(20),g.batchingColor&&s.enable(21),E.push(s.mask),s.disableAll(),g.fog&&s.enable(0),g.useFog&&s.enable(1),g.flatShading&&s.enable(2),g.logarithmicDepthBuffer&&s.enable(3),g.reverseDepthBuffer&&s.enable(4),g.skinning&&s.enable(5),g.morphTargets&&s.enable(6),g.morphNormals&&s.enable(7),g.morphColors&&s.enable(8),g.premultipliedAlpha&&s.enable(9),g.shadowMapEnabled&&s.enable(10),g.doubleSided&&s.enable(11),g.flipSided&&s.enable(12),g.useDepthPacking&&s.enable(13),g.dithering&&s.enable(14),g.transmission&&s.enable(15),g.sheen&&s.enable(16),g.opaque&&s.enable(17),g.pointsUvs&&s.enable(18),g.decodeVideoTexture&&s.enable(19),g.decodeVideoTextureEmissive&&s.enable(20),g.alphaToCoverage&&s.enable(21),E.push(s.mask)}function x(E){const g=b[E.type];let D;if(g){const Z=Kt[g];D=Ri.clone(Z.uniforms)}else D=E.uniforms;return D}function y(E,g){let D;for(let Z=0,k=m.length;Z0?i.push(l):p.transparent===!0?r.push(l):n.push(l)}function u(_,v,p,b,A,c){const l=o(_,v,p,b,A,c);p.transmission>0?i.unshift(l):p.transparent===!0?r.unshift(l):n.unshift(l)}function f(_,v){n.length>1&&n.sort(_||Cu),i.length>1&&i.sort(v||yr),r.length>1&&r.sort(v||yr)}function m(){for(let _=t,v=e.length;_=a.length?(o=new Cr,a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}function Du(){const 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 Te,color:new Ae};break;case"SpotLight":n={position:new Te,direction:new Te,color:new Ae,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Te,color:new Ae,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Te,skyColor:new Ae,groundColor:new Ae};break;case"RectAreaLight":n={color:new Ae,position:new Te,halfWidth:new Te,halfHeight:new Te};break}return e[t.id]=n,n}}}function Lu(){const e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ze};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ze};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ze,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}let Uu=0;function Iu(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Nu(e){const t=new Du,n=Lu(),i={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 f=0;f<9;f++)i.probe.push(new Te);const r=new Te,a=new zn,o=new zn;function s(f){let m=0,_=0,v=0;for(let E=0;E<9;E++)i.probe[E].set(0,0,0);let p=0,b=0,A=0,c=0,l=0,O=0,M=0,x=0,y=0,U=0,F=0;f.sort(Iu);for(let E=0,g=f.length;E0&&(e.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=me.LTC_FLOAT_1,i.rectAreaLTC2=me.LTC_FLOAT_2):(i.rectAreaLTC1=me.LTC_HALF_1,i.rectAreaLTC2=me.LTC_HALF_2)),i.ambient[0]=m,i.ambient[1]=_,i.ambient[2]=v;const V=i.hash;(V.directionalLength!==p||V.pointLength!==b||V.spotLength!==A||V.rectAreaLength!==c||V.hemiLength!==l||V.numDirectionalShadows!==O||V.numPointShadows!==M||V.numSpotShadows!==x||V.numSpotMaps!==y||V.numLightProbes!==F)&&(i.directional.length=p,i.spot.length=A,i.rectArea.length=c,i.point.length=b,i.hemi.length=l,i.directionalShadow.length=O,i.directionalShadowMap.length=O,i.pointShadow.length=M,i.pointShadowMap.length=M,i.spotShadow.length=x,i.spotShadowMap.length=x,i.directionalShadowMatrix.length=O,i.pointShadowMatrix.length=M,i.spotLightMatrix.length=x+y-U,i.spotLightMap.length=y,i.numSpotLightShadowsWithMaps=U,i.numLightProbes=F,V.directionalLength=p,V.pointLength=b,V.spotLength=A,V.rectAreaLength=c,V.hemiLength=l,V.numDirectionalShadows=O,V.numPointShadows=M,V.numSpotShadows=x,V.numSpotMaps=y,V.numLightProbes=F,i.version=Uu++)}function u(f,m){let _=0,v=0,p=0,b=0,A=0;const c=m.matrixWorldInverse;for(let l=0,O=f.length;l=o.length?(s=new Pr(e),o.push(s)):s=o[a],s}function i(){t=new WeakMap}return{get:n,dispose:i}}const Fu=`void main() { - gl_Position = vec4( position, 1.0 ); -}`,Bu=`uniform sampler2D shadow_pass; -uniform vec2 resolution; -uniform float radius; -#include -void main() { - const float samples = float( VSM_SAMPLES ); - float mean = 0.0; - float squared_mean = 0.0; - float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); - float uvStart = samples <= 1.0 ? 0.0 : - 1.0; - for ( float i = 0.0; i < samples; i ++ ) { - float uvOffset = uvStart + i * uvStride; - #ifdef HORIZONTAL_PASS - vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); - mean += distribution.x; - squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; - #else - float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); - mean += depth; - squared_mean += depth * depth; - #endif - } - mean = mean / samples; - squared_mean = squared_mean / samples; - float std_dev = sqrt( squared_mean - mean * mean ); - gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function Hu(e,t,n){let i=new Fr;const r=new Ze,a=new Ze,o=new Nt,s=new is({depthPacking:as}),u=new rs,f={},m=n.maxTextureSize,_={[ri]:zt,[zt]:ri,[Zt]:Zt},v=new Ot({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ze},radius:{value:4}},vertexShader:Fu,fragmentShader:Bu}),p=v.clone();p.defines.HORIZONTAL_PASS=1;const b=new Vt;b.setAttribute("position",new wt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const A=new Bt(b,v),c=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=kr;let l=this.type;this.render=function(U,F,V){if(c.enabled===!1||c.autoUpdate===!1&&c.needsUpdate===!1||U.length===0)return;const E=e.getRenderTarget(),g=e.getActiveCubeFace(),D=e.getActiveMipmapLevel(),Z=e.state;Z.setBlending(cn),Z.buffers.color.setClear(1,1,1,1),Z.buffers.depth.setTest(!0),Z.setScissorTest(!1);const k=l!==Jt&&this.type===Jt,Y=l===Jt&&this.type!==Jt;for(let J=0,$=U.length;J<$;J++){const ne=U[J],X=ne.shadow;if(X===void 0){console.warn("THREE.WebGLShadowMap:",ne,"has no shadow.");continue}if(X.autoUpdate===!1&&X.needsUpdate===!1)continue;r.copy(X.mapSize);const xe=X.getFrameExtents();if(r.multiply(xe),a.copy(X.mapSize),(r.x>m||r.y>m)&&(r.x>m&&(a.x=Math.floor(m/xe.x),r.x=a.x*xe.x,X.mapSize.x=a.x),r.y>m&&(a.y=Math.floor(m/xe.y),r.y=a.y*xe.y,X.mapSize.y=a.y)),X.map===null||k===!0||Y===!0){const Ne=this.type!==Jt?{minFilter:ti,magFilter:ti}:{};X.map!==null&&X.map.dispose(),X.map=new jt(r.x,r.y,Ne),X.map.texture.name=ne.name+".shadowMap",X.camera.updateProjectionMatrix()}e.setRenderTarget(X.map),e.clear();const Ce=X.getViewportCount();for(let Ne=0;Ne0||F.map&&F.alphaTest>0){const Z=g.uuid,k=F.uuid;let Y=f[Z];Y===void 0&&(Y={},f[Z]=Y);let J=Y[k];J===void 0&&(J=g.clone(),Y[k]=J,F.addEventListener("dispose",y)),g=J}if(g.visible=F.visible,g.wireframe=F.wireframe,E===Jt?g.side=F.shadowSide!==null?F.shadowSide:F.side:g.side=F.shadowSide!==null?F.shadowSide:_[F.side],g.alphaMap=F.alphaMap,g.alphaTest=F.alphaTest,g.map=F.map,g.clipShadows=F.clipShadows,g.clippingPlanes=F.clippingPlanes,g.clipIntersection=F.clipIntersection,g.displacementMap=F.displacementMap,g.displacementScale=F.displacementScale,g.displacementBias=F.displacementBias,g.wireframeLinewidth=F.wireframeLinewidth,g.linewidth=F.linewidth,V.isPointLight===!0&&g.isMeshDistanceMaterial===!0){const Z=e.properties.get(g);Z.light=V}return g}function x(U,F,V,E,g){if(U.visible===!1)return;if(U.layers.test(F.layers)&&(U.isMesh||U.isLine||U.isPoints)&&(U.castShadow||U.receiveShadow&&g===Jt)&&(!U.frustumCulled||i.intersectsObject(U))){U.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,U.matrixWorld);const k=t.update(U),Y=U.material;if(Array.isArray(Y)){const J=k.groups;for(let $=0,ne=J.length;$=1):X.indexOf("OpenGL ES")!==-1&&(ne=parseFloat(/^OpenGL ES (\d)/.exec(X)[1]),$=ne>=2);let xe=null,Ce={};const Ne=e.getParameter(e.SCISSOR_BOX),je=e.getParameter(e.VIEWPORT),Je=new Nt().fromArray(Ne),Q=new Nt().fromArray(je);function de(I,ue,K,C){const z=new Uint8Array(4),j=e.createTexture();e.bindTexture(I,j),e.texParameteri(I,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(I,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let se=0;se"u"?!1:/OculusBrowser/g.test(navigator.userAgent),f=new Ze,m=new WeakMap;let _;const v=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function b(S,d){return p?new OffscreenCanvas(S,d):Ns("canvas")}function A(S,d,H){let B=1;const W=be(S);if((W.width>H||W.height>H)&&(B=H/Math.max(W.width,W.height)),B<1)if(typeof HTMLImageElement<"u"&&S instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&S instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&S instanceof ImageBitmap||typeof VideoFrame<"u"&&S instanceof VideoFrame){const G=Math.floor(B*W.width),re=Math.floor(B*W.height);_===void 0&&(_=b(G,re));const ie=d?b(G,re):_;return ie.width=G,ie.height=re,ie.getContext("2d").drawImage(S,0,0,G,re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+W.width+"x"+W.height+") to ("+G+"x"+re+")."),ie}else return"data"in S&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+W.width+"x"+W.height+")."),S;return S}function c(S){return S.generateMipmaps}function l(S){e.generateMipmap(S)}function O(S){return S.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:S.isWebGL3DRenderTarget?e.TEXTURE_3D:S.isWebGLArrayRenderTarget||S.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function M(S,d,H,B,W=!1){if(S!==null){if(e[S]!==void 0)return e[S];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+S+"'")}let G=d;if(d===e.RED&&(H===e.FLOAT&&(G=e.R32F),H===e.HALF_FLOAT&&(G=e.R16F),H===e.UNSIGNED_BYTE&&(G=e.R8)),d===e.RED_INTEGER&&(H===e.UNSIGNED_BYTE&&(G=e.R8UI),H===e.UNSIGNED_SHORT&&(G=e.R16UI),H===e.UNSIGNED_INT&&(G=e.R32UI),H===e.BYTE&&(G=e.R8I),H===e.SHORT&&(G=e.R16I),H===e.INT&&(G=e.R32I)),d===e.RG&&(H===e.FLOAT&&(G=e.RG32F),H===e.HALF_FLOAT&&(G=e.RG16F),H===e.UNSIGNED_BYTE&&(G=e.RG8)),d===e.RG_INTEGER&&(H===e.UNSIGNED_BYTE&&(G=e.RG8UI),H===e.UNSIGNED_SHORT&&(G=e.RG16UI),H===e.UNSIGNED_INT&&(G=e.RG32UI),H===e.BYTE&&(G=e.RG8I),H===e.SHORT&&(G=e.RG16I),H===e.INT&&(G=e.RG32I)),d===e.RGB_INTEGER&&(H===e.UNSIGNED_BYTE&&(G=e.RGB8UI),H===e.UNSIGNED_SHORT&&(G=e.RGB16UI),H===e.UNSIGNED_INT&&(G=e.RGB32UI),H===e.BYTE&&(G=e.RGB8I),H===e.SHORT&&(G=e.RGB16I),H===e.INT&&(G=e.RGB32I)),d===e.RGBA_INTEGER&&(H===e.UNSIGNED_BYTE&&(G=e.RGBA8UI),H===e.UNSIGNED_SHORT&&(G=e.RGBA16UI),H===e.UNSIGNED_INT&&(G=e.RGBA32UI),H===e.BYTE&&(G=e.RGBA8I),H===e.SHORT&&(G=e.RGBA16I),H===e.INT&&(G=e.RGBA32I)),d===e.RGB&&H===e.UNSIGNED_INT_5_9_9_9_REV&&(G=e.RGB9_E5),d===e.RGBA){const re=W?Jr:Mt.getTransfer(B);H===e.FLOAT&&(G=e.RGBA32F),H===e.HALF_FLOAT&&(G=e.RGBA16F),H===e.UNSIGNED_BYTE&&(G=re===ut?e.SRGB8_ALPHA8:e.RGBA8),H===e.UNSIGNED_SHORT_4_4_4_4&&(G=e.RGBA4),H===e.UNSIGNED_SHORT_5_5_5_1&&(G=e.RGB5_A1)}return(G===e.R16F||G===e.R32F||G===e.RG16F||G===e.RG32F||G===e.RGBA16F||G===e.RGBA32F)&&t.get("EXT_color_buffer_float"),G}function x(S,d){let H;return S?d===null||d===si||d===oi?H=e.DEPTH24_STENCIL8:d===bn?H=e.DEPTH32F_STENCIL8:d===Ai&&(H=e.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):d===null||d===si||d===oi?H=e.DEPTH_COMPONENT24:d===bn?H=e.DEPTH_COMPONENT32F:d===Ai&&(H=e.DEPTH_COMPONENT16),H}function y(S,d){return c(S)===!0||S.isFramebufferTexture&&S.minFilter!==ti&&S.minFilter!==In?Math.log2(Math.max(d.width,d.height))+1:S.mipmaps!==void 0&&S.mipmaps.length>0?S.mipmaps.length:S.isCompressedTexture&&Array.isArray(S.image)?d.mipmaps.length:1}function U(S){const d=S.target;d.removeEventListener("dispose",U),V(d),d.isVideoTexture&&m.delete(d)}function F(S){const d=S.target;d.removeEventListener("dispose",F),g(d)}function V(S){const d=i.get(S);if(d.__webglInit===void 0)return;const H=S.source,B=v.get(H);if(B){const W=B[d.__cacheKey];W.usedTimes--,W.usedTimes===0&&E(S),Object.keys(B).length===0&&v.delete(H)}i.remove(S)}function E(S){const d=i.get(S);e.deleteTexture(d.__webglTexture);const H=S.source,B=v.get(H);delete B[d.__cacheKey],o.memory.textures--}function g(S){const d=i.get(S);if(S.depthTexture&&(S.depthTexture.dispose(),i.remove(S.depthTexture)),S.isWebGLCubeRenderTarget)for(let B=0;B<6;B++){if(Array.isArray(d.__webglFramebuffer[B]))for(let W=0;W=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+S+" texture units while this GPU supports only "+r.maxTextures),D+=1,S}function Y(S){const d=[];return d.push(S.wrapS),d.push(S.wrapT),d.push(S.wrapR||0),d.push(S.magFilter),d.push(S.minFilter),d.push(S.anisotropy),d.push(S.internalFormat),d.push(S.format),d.push(S.type),d.push(S.generateMipmaps),d.push(S.premultiplyAlpha),d.push(S.flipY),d.push(S.unpackAlignment),d.push(S.colorSpace),d.join()}function J(S,d){const H=i.get(S);if(S.isVideoTexture&&we(S),S.isRenderTargetTexture===!1&&S.version>0&&H.__version!==S.version){const B=S.image;if(B===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(B.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Q(H,S,d);return}}n.bindTexture(e.TEXTURE_2D,H.__webglTexture,e.TEXTURE0+d)}function $(S,d){const H=i.get(S);if(S.version>0&&H.__version!==S.version){Q(H,S,d);return}n.bindTexture(e.TEXTURE_2D_ARRAY,H.__webglTexture,e.TEXTURE0+d)}function ne(S,d){const H=i.get(S);if(S.version>0&&H.__version!==S.version){Q(H,S,d);return}n.bindTexture(e.TEXTURE_3D,H.__webglTexture,e.TEXTURE0+d)}function X(S,d){const H=i.get(S);if(S.version>0&&H.__version!==S.version){de(H,S,d);return}n.bindTexture(e.TEXTURE_CUBE_MAP,H.__webglTexture,e.TEXTURE0+d)}const xe={[Ko]:e.REPEAT,[qo]:e.CLAMP_TO_EDGE,[Yo]:e.MIRRORED_REPEAT},Ce={[ti]:e.NEAREST,[Zo]:e.NEAREST_MIPMAP_NEAREST,[ui]:e.NEAREST_MIPMAP_LINEAR,[In]:e.LINEAR,[Li]:e.LINEAR_MIPMAP_NEAREST,[Qn]:e.LINEAR_MIPMAP_LINEAR},Ne={[ns]:e.NEVER,[ts]:e.ALWAYS,[es]:e.LESS,[Hr]:e.LEQUAL,[Jo]:e.EQUAL,[Qo]:e.GEQUAL,[$o]:e.GREATER,[jo]:e.NOTEQUAL};function je(S,d){if(d.type===bn&&t.has("OES_texture_float_linear")===!1&&(d.magFilter===In||d.magFilter===Li||d.magFilter===ui||d.magFilter===Qn||d.minFilter===In||d.minFilter===Li||d.minFilter===ui||d.minFilter===Qn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(S,e.TEXTURE_WRAP_S,xe[d.wrapS]),e.texParameteri(S,e.TEXTURE_WRAP_T,xe[d.wrapT]),(S===e.TEXTURE_3D||S===e.TEXTURE_2D_ARRAY)&&e.texParameteri(S,e.TEXTURE_WRAP_R,xe[d.wrapR]),e.texParameteri(S,e.TEXTURE_MAG_FILTER,Ce[d.magFilter]),e.texParameteri(S,e.TEXTURE_MIN_FILTER,Ce[d.minFilter]),d.compareFunction&&(e.texParameteri(S,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(S,e.TEXTURE_COMPARE_FUNC,Ne[d.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(d.magFilter===ti||d.minFilter!==ui&&d.minFilter!==Qn||d.type===bn&&t.has("OES_texture_float_linear")===!1)return;if(d.anisotropy>1||i.get(d).__currentAnisotropy){const H=t.get("EXT_texture_filter_anisotropic");e.texParameterf(S,H.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(d.anisotropy,r.getMaxAnisotropy())),i.get(d).__currentAnisotropy=d.anisotropy}}}function Je(S,d){let H=!1;S.__webglInit===void 0&&(S.__webglInit=!0,d.addEventListener("dispose",U));const B=d.source;let W=v.get(B);W===void 0&&(W={},v.set(B,W));const G=Y(d);if(G!==S.__cacheKey){W[G]===void 0&&(W[G]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,H=!0),W[G].usedTimes++;const re=W[S.__cacheKey];re!==void 0&&(W[S.__cacheKey].usedTimes--,re.usedTimes===0&&E(d)),S.__cacheKey=G,S.__webglTexture=W[G].texture}return H}function Q(S,d,H){let B=e.TEXTURE_2D;(d.isDataArrayTexture||d.isCompressedArrayTexture)&&(B=e.TEXTURE_2D_ARRAY),d.isData3DTexture&&(B=e.TEXTURE_3D);const W=Je(S,d),G=d.source;n.bindTexture(B,S.__webglTexture,e.TEXTURE0+H);const re=i.get(G);if(G.version!==re.__version||W===!0){n.activeTexture(e.TEXTURE0+H);const ie=Mt.getPrimaries(Mt.workingColorSpace),le=d.colorSpace===Un?null:Mt.getPrimaries(d.colorSpace),Pe=d.colorSpace===Un||ie===le?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,d.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,d.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,d.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Pe);let q=A(d.image,!1,r.maxTextureSize);q=et(d,q);const ce=a.convert(d.format,d.colorSpace),_e=a.convert(d.type);let Re=M(d.internalFormat,ce,_e,d.colorSpace,d.isVideoTexture);je(B,d);let ge;const Xe=d.mipmaps,Ge=d.isVideoTexture!==!0,rt=re.__version===void 0||W===!0,I=G.dataReady,ue=y(d,q);if(d.isDepthTexture)Re=x(d.format===Ti,d.type),rt&&(Ge?n.texStorage2D(e.TEXTURE_2D,1,Re,q.width,q.height):n.texImage2D(e.TEXTURE_2D,0,Re,q.width,q.height,0,ce,_e,null));else if(d.isDataTexture)if(Xe.length>0){Ge&&rt&&n.texStorage2D(e.TEXTURE_2D,ue,Re,Xe[0].width,Xe[0].height);for(let K=0,C=Xe.length;K0){const z=Ka(ge.width,ge.height,d.format,d.type);for(const j of d.layerUpdates){const se=ge.data.subarray(j*z/ge.data.BYTES_PER_ELEMENT,(j+1)*z/ge.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,j,ge.width,ge.height,1,ce,se)}d.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,0,ge.width,ge.height,q.depth,ce,ge.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,K,Re,ge.width,ge.height,q.depth,0,ge.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ge?I&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,0,ge.width,ge.height,q.depth,ce,_e,ge.data):n.texImage3D(e.TEXTURE_2D_ARRAY,K,Re,ge.width,ge.height,q.depth,0,ce,_e,ge.data)}else{Ge&&rt&&n.texStorage2D(e.TEXTURE_2D,ue,Re,Xe[0].width,Xe[0].height);for(let K=0,C=Xe.length;K0){const K=Ka(q.width,q.height,d.format,d.type);for(const C of d.layerUpdates){const z=q.data.subarray(C*K/q.data.BYTES_PER_ELEMENT,(C+1)*K/q.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,C,q.width,q.height,1,ce,_e,z)}d.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,q.width,q.height,q.depth,ce,_e,q.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,Re,q.width,q.height,q.depth,0,ce,_e,q.data);else if(d.isData3DTexture)Ge?(rt&&n.texStorage3D(e.TEXTURE_3D,ue,Re,q.width,q.height,q.depth),I&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,q.width,q.height,q.depth,ce,_e,q.data)):n.texImage3D(e.TEXTURE_3D,0,Re,q.width,q.height,q.depth,0,ce,_e,q.data);else if(d.isFramebufferTexture){if(rt)if(Ge)n.texStorage2D(e.TEXTURE_2D,ue,Re,q.width,q.height);else{let K=q.width,C=q.height;for(let z=0;z>=1,C>>=1}}else if(Xe.length>0){if(Ge&&rt){const K=be(Xe[0]);n.texStorage2D(e.TEXTURE_2D,ue,Re,K.width,K.height)}for(let K=0,C=Xe.length;K0&&ue++;const C=be(ce[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,ue,Xe,C.width,C.height)}for(let C=0;C<6;C++)if(q){Ge?I&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+C,0,0,0,ce[C].width,ce[C].height,Re,ge,ce[C].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+C,0,Xe,ce[C].width,ce[C].height,0,Re,ge,ce[C].data);for(let z=0;z>G),_e=Math.max(1,d.height>>G);W===e.TEXTURE_3D||W===e.TEXTURE_2D_ARRAY?n.texImage3D(W,G,le,ce,_e,d.depth,0,re,ie,null):n.texImage2D(W,G,le,ce,_e,0,re,ie,null)}n.bindFramebuffer(e.FRAMEBUFFER,S),We(d)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,B,W,q.__webglTexture,0,ze(d)):(W===e.TEXTURE_2D||W>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&W<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,B,W,q.__webglTexture,G),n.bindFramebuffer(e.FRAMEBUFFER,null)}function he(S,d,H){if(e.bindRenderbuffer(e.RENDERBUFFER,S),d.depthBuffer){const B=d.depthTexture,W=B&&B.isDepthTexture?B.type:null,G=x(d.stencilBuffer,W),re=d.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ie=ze(d);We(d)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,ie,G,d.width,d.height):H?e.renderbufferStorageMultisample(e.RENDERBUFFER,ie,G,d.width,d.height):e.renderbufferStorage(e.RENDERBUFFER,G,d.width,d.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,re,e.RENDERBUFFER,S)}else{const B=d.textures;for(let W=0;W{delete d.__boundDepthTexture,delete d.__depthDisposeCallback,B.removeEventListener("dispose",W)};B.addEventListener("dispose",W),d.__depthDisposeCallback=W}d.__boundDepthTexture=B}if(S.depthTexture&&!d.__autoAllocateDepthBuffer){if(H)throw new Error("target.depthTexture not supported in Cube render targets");Le(d.__webglFramebuffer,S)}else if(H){d.__webglDepthbuffer=[];for(let B=0;B<6;B++)if(n.bindFramebuffer(e.FRAMEBUFFER,d.__webglFramebuffer[B]),d.__webglDepthbuffer[B]===void 0)d.__webglDepthbuffer[B]=e.createRenderbuffer(),he(d.__webglDepthbuffer[B],S,!1);else{const W=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,G=d.__webglDepthbuffer[B];e.bindRenderbuffer(e.RENDERBUFFER,G),e.framebufferRenderbuffer(e.FRAMEBUFFER,W,e.RENDERBUFFER,G)}}else if(n.bindFramebuffer(e.FRAMEBUFFER,d.__webglFramebuffer),d.__webglDepthbuffer===void 0)d.__webglDepthbuffer=e.createRenderbuffer(),he(d.__webglDepthbuffer,S,!1);else{const B=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,W=d.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,W),e.framebufferRenderbuffer(e.FRAMEBUFFER,B,e.RENDERBUFFER,W)}n.bindFramebuffer(e.FRAMEBUFFER,null)}function ke(S,d,H){const B=i.get(S);d!==void 0&&Me(B.__webglFramebuffer,S,S.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),H!==void 0&&Ie(S)}function nt(S){const d=S.texture,H=i.get(S),B=i.get(d);S.addEventListener("dispose",F);const W=S.textures,G=S.isWebGLCubeRenderTarget===!0,re=W.length>1;if(re||(B.__webglTexture===void 0&&(B.__webglTexture=e.createTexture()),B.__version=d.version,o.memory.textures++),G){H.__webglFramebuffer=[];for(let ie=0;ie<6;ie++)if(d.mipmaps&&d.mipmaps.length>0){H.__webglFramebuffer[ie]=[];for(let le=0;le0){H.__webglFramebuffer=[];for(let ie=0;ie0&&We(S)===!1){H.__webglMultisampledFramebuffer=e.createFramebuffer(),H.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,H.__webglMultisampledFramebuffer);for(let ie=0;ie0)for(let le=0;le0)for(let le=0;le0){if(We(S)===!1){const d=S.textures,H=S.width,B=S.height;let W=e.COLOR_BUFFER_BIT;const G=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,re=i.get(S),ie=d.length>1;if(ie)for(let le=0;le0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&d.__useRenderToTexture!==!1}function we(S){const d=o.render.frame;m.get(S)!==d&&(m.set(S,d),S.update())}function et(S,d){const H=S.colorSpace,B=S.format,W=S.type;return S.isCompressedTexture===!0||S.isVideoTexture===!0||H!==yi&&H!==Un&&(Mt.getTransfer(H)===ut?(B!==tn||W!==An)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",H)),d}function be(S){return typeof HTMLImageElement<"u"&&S instanceof HTMLImageElement?(f.width=S.naturalWidth||S.width,f.height=S.naturalHeight||S.height):typeof VideoFrame<"u"&&S instanceof VideoFrame?(f.width=S.displayWidth,f.height=S.displayHeight):(f.width=S.width,f.height=S.height),f}this.allocateTextureUnit=k,this.resetTextureUnits=Z,this.setTexture2D=J,this.setTexture2DArray=$,this.setTexture3D=ne,this.setTextureCube=X,this.rebindTextures=ke,this.setupRenderTarget=nt,this.updateRenderTargetMipmap=Ke,this.updateMultisampleRenderTarget=gt,this.setupDepthRenderbuffer=Ie,this.setupFrameBufferTexture=Me,this.useMultisampledRTT=We}function zu(e,t){function n(i,r=Un){let a;const o=Mt.getTransfer(r);if(i===An)return e.UNSIGNED_BYTE;if(i===Vr)return e.UNSIGNED_SHORT_4_4_4_4;if(i===zr)return e.UNSIGNED_SHORT_5_5_5_1;if(i===os)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===ss)return e.BYTE;if(i===ls)return e.SHORT;if(i===Ai)return e.UNSIGNED_SHORT;if(i===Xr)return e.INT;if(i===si)return e.UNSIGNED_INT;if(i===bn)return e.FLOAT;if(i===ln)return e.HALF_FLOAT;if(i===cs)return e.ALPHA;if(i===ds)return e.RGB;if(i===tn)return e.RGBA;if(i===fs)return e.LUMINANCE;if(i===us)return e.LUMINANCE_ALPHA;if(i===ha)return e.DEPTH_COMPONENT;if(i===Ti)return e.DEPTH_STENCIL;if(i===ps)return e.RED;if(i===Yr)return e.RED_INTEGER;if(i===hs)return e.RG;if(i===qr)return e.RG_INTEGER;if(i===Kr)return e.RGBA_INTEGER;if(i===Ui||i===Ii||i===Ni||i===Oi)if(o===ut)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(i===Ui)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Ii)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Ni)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Oi)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(i===Ui)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Ii)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ni)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Oi)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===va||i===Sa||i===Ea||i===xa)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(i===va)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Sa)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ea)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===xa)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Ma||i===Ta||i===ba)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(i===Ma||i===Ta)return o===ut?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(i===ba)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Aa||i===Ra||i===wa||i===ya||i===Ca||i===Pa||i===Da||i===La||i===Ua||i===Ia||i===Na||i===Oa||i===Fa||i===Ba)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(i===Aa)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Ra)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===wa)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===ya)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Ca)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Pa)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Da)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===La)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Ua)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Ia)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Na)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Oa)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Fa)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Ba)return o===ut?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Fi||i===Ha||i===Ga)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(i===Fi)return o===ut?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Ha)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Ga)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===ms||i===ka||i===Va||i===za)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(i===Fi)return a.COMPRESSED_RED_RGTC1_EXT;if(i===ka)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Va)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===za)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===oi?e.UNSIGNED_INT_24_8:e[i]!==void 0?e[i]:null}return{convert:n}}const Wu={type:"move"};class Wi{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Jn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Jn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Te,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Te),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Jn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Te,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Te),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const n=this._hand;if(n)for(const i of t.hand.values())this._getHandJoint(n,i)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,n,i){let r=null,a=null,o=null;const s=this._targetRay,u=this._grip,f=this._hand;if(t&&n.session.visibilityState!=="visible-blurred"){if(f&&t.hand){o=!0;for(const A of t.hand.values()){const c=n.getJointPose(A,i),l=this._getHandJoint(f,A);c!==null&&(l.matrix.fromArray(c.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,l.jointRadius=c.radius),l.visible=c!==null}const m=f.joints["index-finger-tip"],_=f.joints["thumb-tip"],v=m.position.distanceTo(_.position),p=.02,b=.005;f.inputState.pinching&&v>p+b?(f.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!f.inputState.pinching&&v<=p-b&&(f.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else u!==null&&t.gripSpace&&(a=n.getPose(t.gripSpace,i),a!==null&&(u.matrix.fromArray(a.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,a.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(a.linearVelocity)):u.hasLinearVelocity=!1,a.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(a.angularVelocity)):u.hasAngularVelocity=!1));s!==null&&(r=n.getPose(t.targetRaySpace,i),r===null&&a!==null&&(r=a),r!==null&&(s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,r.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(r.linearVelocity)):s.hasLinearVelocity=!1,r.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(r.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(Wu)))}return s!==null&&(s.visible=r!==null),u!==null&&(u.visible=a!==null),f!==null&&(f.visible=o!==null),this}_getHandJoint(t,n){if(t.joints[n.jointName]===void 0){const i=new Jn;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[n.jointName]=i,t.add(i)}return t.joints[n.jointName]}}const Xu=` -void main() { - - gl_Position = vec4( position, 1.0 ); - -}`,Yu=` -uniform sampler2DArray depthColor; -uniform float depthWidth; -uniform float depthHeight; - -void main() { - - vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); - - if ( coord.x >= 1.0 ) { - - gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; - - } else { - - gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; - - } - -}`;class qu{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,n,i){if(this.texture===null){const r=new Wr,a=t.properties.get(r);a.__webglTexture=n.texture,(n.depthNear!==i.depthNear||n.depthFar!==i.depthFar)&&(this.depthNear=n.depthNear,this.depthFar=n.depthFar),this.texture=r}}getMesh(t){if(this.texture!==null&&this.mesh===null){const n=t.cameras[0].viewport,i=new Ot({vertexShader:Xu,fragmentShader:Yu,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Bt(new ma(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Ku extends Ro{constructor(t,n){super();const i=this;let r=null,a=1,o=null,s="local-floor",u=1,f=null,m=null,_=null,v=null,p=null,b=null;const A=new qu,c=n.getContextAttributes();let l=null,O=null;const M=[],x=[],y=new Ze;let U=null;const F=new Hn;F.viewport=new Nt;const V=new Hn;V.viewport=new Nt;const E=[F,V],g=new wo;let D=null,Z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Q){let de=M[Q];return de===void 0&&(de=new Wi,M[Q]=de),de.getTargetRaySpace()},this.getControllerGrip=function(Q){let de=M[Q];return de===void 0&&(de=new Wi,M[Q]=de),de.getGripSpace()},this.getHand=function(Q){let de=M[Q];return de===void 0&&(de=new Wi,M[Q]=de),de.getHandSpace()};function k(Q){const de=x.indexOf(Q.inputSource);if(de===-1)return;const Me=M[de];Me!==void 0&&(Me.update(Q.inputSource,Q.frame,f||o),Me.dispatchEvent({type:Q.type,data:Q.inputSource}))}function Y(){r.removeEventListener("select",k),r.removeEventListener("selectstart",k),r.removeEventListener("selectend",k),r.removeEventListener("squeeze",k),r.removeEventListener("squeezestart",k),r.removeEventListener("squeezeend",k),r.removeEventListener("end",Y),r.removeEventListener("inputsourceschange",J);for(let Q=0;Q=0&&(x[he]=null,M[he].disconnect(Me))}for(let de=0;de=x.length){x.push(Me),he=Ie;break}else if(x[Ie]===null){x[Ie]=Me,he=Ie;break}if(he===-1)break}const Le=M[he];Le&&Le.connect(Me)}}const $=new Te,ne=new Te;function X(Q,de,Me){$.setFromMatrixPosition(de.matrixWorld),ne.setFromMatrixPosition(Me.matrixWorld);const he=$.distanceTo(ne),Le=de.projectionMatrix.elements,Ie=Me.projectionMatrix.elements,ke=Le[14]/(Le[10]-1),nt=Le[14]/(Le[10]+1),Ke=(Le[9]+1)/Le[5],dt=(Le[9]-1)/Le[5],R=(Le[8]-1)/Le[0],gt=(Ie[8]+1)/Ie[0],ze=ke*R,We=ke*gt,we=he/(-R+gt),et=we*-R;if(de.matrixWorld.decompose(Q.position,Q.quaternion,Q.scale),Q.translateX(et),Q.translateZ(we),Q.matrixWorld.compose(Q.position,Q.quaternion,Q.scale),Q.matrixWorldInverse.copy(Q.matrixWorld).invert(),Le[10]===-1)Q.projectionMatrix.copy(de.projectionMatrix),Q.projectionMatrixInverse.copy(de.projectionMatrixInverse);else{const be=ke+we,S=nt+we,d=ze-et,H=We+(he-et),B=Ke*nt/S*be,W=dt*nt/S*be;Q.projectionMatrix.makePerspective(d,H,B,W,be,S),Q.projectionMatrixInverse.copy(Q.projectionMatrix).invert()}}function xe(Q,de){de===null?Q.matrixWorld.copy(Q.matrix):Q.matrixWorld.multiplyMatrices(de.matrixWorld,Q.matrix),Q.matrixWorldInverse.copy(Q.matrixWorld).invert()}this.updateCamera=function(Q){if(r===null)return;let de=Q.near,Me=Q.far;A.texture!==null&&(A.depthNear>0&&(de=A.depthNear),A.depthFar>0&&(Me=A.depthFar)),g.near=V.near=F.near=de,g.far=V.far=F.far=Me,(D!==g.near||Z!==g.far)&&(r.updateRenderState({depthNear:g.near,depthFar:g.far}),D=g.near,Z=g.far),F.layers.mask=Q.layers.mask|2,V.layers.mask=Q.layers.mask|4,g.layers.mask=F.layers.mask|V.layers.mask;const he=Q.parent,Le=g.cameras;xe(g,he);for(let Ie=0;Ie0&&(c.alphaTest.value=l.alphaTest);const O=t.get(l),M=O.envMap,x=O.envMapRotation;M&&(c.envMap.value=M,gn.copy(x),gn.x*=-1,gn.y*=-1,gn.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(gn.y*=-1,gn.z*=-1),c.envMapRotation.value.setFromMatrix4(Zu.makeRotationFromEuler(gn)),c.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,c.reflectivity.value=l.reflectivity,c.ior.value=l.ior,c.refractionRatio.value=l.refractionRatio),l.lightMap&&(c.lightMap.value=l.lightMap,c.lightMapIntensity.value=l.lightMapIntensity,n(l.lightMap,c.lightMapTransform)),l.aoMap&&(c.aoMap.value=l.aoMap,c.aoMapIntensity.value=l.aoMapIntensity,n(l.aoMap,c.aoMapTransform))}function o(c,l){c.diffuse.value.copy(l.color),c.opacity.value=l.opacity,l.map&&(c.map.value=l.map,n(l.map,c.mapTransform))}function s(c,l){c.dashSize.value=l.dashSize,c.totalSize.value=l.dashSize+l.gapSize,c.scale.value=l.scale}function u(c,l,O,M){c.diffuse.value.copy(l.color),c.opacity.value=l.opacity,c.size.value=l.size*O,c.scale.value=M*.5,l.map&&(c.map.value=l.map,n(l.map,c.uvTransform)),l.alphaMap&&(c.alphaMap.value=l.alphaMap,n(l.alphaMap,c.alphaMapTransform)),l.alphaTest>0&&(c.alphaTest.value=l.alphaTest)}function f(c,l){c.diffuse.value.copy(l.color),c.opacity.value=l.opacity,c.rotation.value=l.rotation,l.map&&(c.map.value=l.map,n(l.map,c.mapTransform)),l.alphaMap&&(c.alphaMap.value=l.alphaMap,n(l.alphaMap,c.alphaMapTransform)),l.alphaTest>0&&(c.alphaTest.value=l.alphaTest)}function m(c,l){c.specular.value.copy(l.specular),c.shininess.value=Math.max(l.shininess,1e-4)}function _(c,l){l.gradientMap&&(c.gradientMap.value=l.gradientMap)}function v(c,l){c.metalness.value=l.metalness,l.metalnessMap&&(c.metalnessMap.value=l.metalnessMap,n(l.metalnessMap,c.metalnessMapTransform)),c.roughness.value=l.roughness,l.roughnessMap&&(c.roughnessMap.value=l.roughnessMap,n(l.roughnessMap,c.roughnessMapTransform)),l.envMap&&(c.envMapIntensity.value=l.envMapIntensity)}function p(c,l,O){c.ior.value=l.ior,l.sheen>0&&(c.sheenColor.value.copy(l.sheenColor).multiplyScalar(l.sheen),c.sheenRoughness.value=l.sheenRoughness,l.sheenColorMap&&(c.sheenColorMap.value=l.sheenColorMap,n(l.sheenColorMap,c.sheenColorMapTransform)),l.sheenRoughnessMap&&(c.sheenRoughnessMap.value=l.sheenRoughnessMap,n(l.sheenRoughnessMap,c.sheenRoughnessMapTransform))),l.clearcoat>0&&(c.clearcoat.value=l.clearcoat,c.clearcoatRoughness.value=l.clearcoatRoughness,l.clearcoatMap&&(c.clearcoatMap.value=l.clearcoatMap,n(l.clearcoatMap,c.clearcoatMapTransform)),l.clearcoatRoughnessMap&&(c.clearcoatRoughnessMap.value=l.clearcoatRoughnessMap,n(l.clearcoatRoughnessMap,c.clearcoatRoughnessMapTransform)),l.clearcoatNormalMap&&(c.clearcoatNormalMap.value=l.clearcoatNormalMap,n(l.clearcoatNormalMap,c.clearcoatNormalMapTransform),c.clearcoatNormalScale.value.copy(l.clearcoatNormalScale),l.side===zt&&c.clearcoatNormalScale.value.negate())),l.dispersion>0&&(c.dispersion.value=l.dispersion),l.iridescence>0&&(c.iridescence.value=l.iridescence,c.iridescenceIOR.value=l.iridescenceIOR,c.iridescenceThicknessMinimum.value=l.iridescenceThicknessRange[0],c.iridescenceThicknessMaximum.value=l.iridescenceThicknessRange[1],l.iridescenceMap&&(c.iridescenceMap.value=l.iridescenceMap,n(l.iridescenceMap,c.iridescenceMapTransform)),l.iridescenceThicknessMap&&(c.iridescenceThicknessMap.value=l.iridescenceThicknessMap,n(l.iridescenceThicknessMap,c.iridescenceThicknessMapTransform))),l.transmission>0&&(c.transmission.value=l.transmission,c.transmissionSamplerMap.value=O.texture,c.transmissionSamplerSize.value.set(O.width,O.height),l.transmissionMap&&(c.transmissionMap.value=l.transmissionMap,n(l.transmissionMap,c.transmissionMapTransform)),c.thickness.value=l.thickness,l.thicknessMap&&(c.thicknessMap.value=l.thicknessMap,n(l.thicknessMap,c.thicknessMapTransform)),c.attenuationDistance.value=l.attenuationDistance,c.attenuationColor.value.copy(l.attenuationColor)),l.anisotropy>0&&(c.anisotropyVector.value.set(l.anisotropy*Math.cos(l.anisotropyRotation),l.anisotropy*Math.sin(l.anisotropyRotation)),l.anisotropyMap&&(c.anisotropyMap.value=l.anisotropyMap,n(l.anisotropyMap,c.anisotropyMapTransform))),c.specularIntensity.value=l.specularIntensity,c.specularColor.value.copy(l.specularColor),l.specularColorMap&&(c.specularColorMap.value=l.specularColorMap,n(l.specularColorMap,c.specularColorMapTransform)),l.specularIntensityMap&&(c.specularIntensityMap.value=l.specularIntensityMap,n(l.specularIntensityMap,c.specularIntensityMapTransform))}function b(c,l){l.matcap&&(c.matcap.value=l.matcap)}function A(c,l){const O=t.get(l).light;c.referencePosition.value.setFromMatrixPosition(O.matrixWorld),c.nearDistance.value=O.shadow.camera.near,c.farDistance.value=O.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function $u(e,t,n,i){let r={},a={},o=[];const s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function u(O,M){const x=M.program;i.uniformBlockBinding(O,x)}function f(O,M){let x=r[O.id];x===void 0&&(b(O),x=m(O),r[O.id]=x,O.addEventListener("dispose",c));const y=M.program;i.updateUBOMapping(O,y);const U=t.render.frame;a[O.id]!==U&&(v(O),a[O.id]=U)}function m(O){const M=_();O.__bindingPointIndex=M;const x=e.createBuffer(),y=O.__size,U=O.usage;return e.bindBuffer(e.UNIFORM_BUFFER,x),e.bufferData(e.UNIFORM_BUFFER,y,U),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,M,x),x}function _(){for(let O=0;O0&&(x+=y-U),O.__size=x,O.__cache={},this}function A(O){const M={boundary:0,storage:0};return typeof O=="number"||typeof O=="boolean"?(M.boundary=4,M.storage=4):O.isVector2?(M.boundary=8,M.storage=8):O.isVector3||O.isColor?(M.boundary=16,M.storage=12):O.isVector4?(M.boundary=16,M.storage=16):O.isMatrix3?(M.boundary=48,M.storage=48):O.isMatrix4?(M.boundary=64,M.storage=64):O.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",O),M}function c(O){const M=O.target;M.removeEventListener("dispose",c);const x=o.indexOf(M.__bindingPointIndex);o.splice(x,1),e.deleteBuffer(r[M.id]),delete r[M.id],delete a[M.id]}function l(){for(const O in r)e.deleteBuffer(r[O]);o=[],r={},a={}}return{bind:u,update:f,dispose:l}}class Qu{constructor(t={}){const{canvas:n=So(),context:i=null,depth:r=!0,stencil:a=!1,alpha:o=!1,antialias:s=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:f=!1,powerPreference:m="default",failIfMajorPerformanceCaveat:_=!1,reverseDepthBuffer:v=!1}=t;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=o;const b=new Uint32Array(4),A=new Int32Array(4);let c=null,l=null;const O=[],M=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Eo,this.toneMapping=sn,this.toneMappingExposure=1;const x=this;let y=!1,U=0,F=0,V=null,E=-1,g=null;const D=new Nt,Z=new Nt;let k=null;const Y=new Ae(0);let J=0,$=n.width,ne=n.height,X=1,xe=null,Ce=null;const Ne=new Nt(0,0,$,ne),je=new Nt(0,0,$,ne);let Je=!1;const Q=new Fr;let de=!1,Me=!1;this.transmissionResolutionScale=1;const he=new zn,Le=new zn,Ie=new Te,ke=new Nt,nt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ke=!1;function dt(){return V===null?X:1}let R=i;function gt(h,N){return n.getContext(h,N)}try{const h={alpha:!0,depth:r,stencil:a,antialias:s,premultipliedAlpha:u,preserveDrawingBuffer:f,powerPreference:m,failIfMajorPerformanceCaveat:_};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${xo}`),n.addEventListener("webglcontextlost",C,!1),n.addEventListener("webglcontextrestored",z,!1),n.addEventListener("webglcontextcreationerror",j,!1),R===null){const N="webgl2";if(R=gt(N,h),R===null)throw gt(N)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(h){throw console.error("THREE.WebGLRenderer: "+h.message),h}let ze,We,we,et,be,S,d,H,B,W,G,re,ie,le,Pe,q,ce,_e,Re,ge,Xe,Ge,rt,I;function ue(){ze=new sf(R),ze.init(),Ge=new zu(R,ze),We=new ef(R,ze,t,Ge),we=new ku(R,ze),We.reverseDepthBuffer&&v&&we.buffers.depth.setReversed(!0),et=new df(R),be=new yu,S=new Vu(R,ze,we,be,We,Ge,et),d=new nf(x),H=new of(x),B=new _l(R),rt=new Qd(R,B),W=new lf(R,B,et,rt),G=new uf(R,W,B,et),Re=new ff(R,We,S),q=new tf(be),re=new wu(x,d,H,ze,We,rt,q),ie=new ju(x,be),le=new Pu,Pe=new Ou(ze),_e=new $d(x,d,H,we,G,p,u),ce=new Hu(x,G,We),I=new $u(R,et,We,we),ge=new Jd(R,ze,et),Xe=new cf(R,ze,et),et.programs=re.programs,x.capabilities=We,x.extensions=ze,x.properties=be,x.renderLists=le,x.shadowMap=ce,x.state=we,x.info=et}ue();const K=new Ku(x,R);this.xr=K,this.getContext=function(){return R},this.getContextAttributes=function(){return R.getContextAttributes()},this.forceContextLoss=function(){const h=ze.get("WEBGL_lose_context");h&&h.loseContext()},this.forceContextRestore=function(){const h=ze.get("WEBGL_lose_context");h&&h.restoreContext()},this.getPixelRatio=function(){return X},this.setPixelRatio=function(h){h!==void 0&&(X=h,this.setSize($,ne,!1))},this.getSize=function(h){return h.set($,ne)},this.setSize=function(h,N,w=!0){if(K.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}$=h,ne=N,n.width=Math.floor(h*X),n.height=Math.floor(N*X),w===!0&&(n.style.width=h+"px",n.style.height=N+"px"),this.setViewport(0,0,h,N)},this.getDrawingBufferSize=function(h){return h.set($*X,ne*X).floor()},this.setDrawingBufferSize=function(h,N,w){$=h,ne=N,X=w,n.width=Math.floor(h*w),n.height=Math.floor(N*w),this.setViewport(0,0,h,N)},this.getCurrentViewport=function(h){return h.copy(D)},this.getViewport=function(h){return h.copy(Ne)},this.setViewport=function(h,N,w,L){h.isVector4?Ne.set(h.x,h.y,h.z,h.w):Ne.set(h,N,w,L),we.viewport(D.copy(Ne).multiplyScalar(X).round())},this.getScissor=function(h){return h.copy(je)},this.setScissor=function(h,N,w,L){h.isVector4?je.set(h.x,h.y,h.z,h.w):je.set(h,N,w,L),we.scissor(Z.copy(je).multiplyScalar(X).round())},this.getScissorTest=function(){return Je},this.setScissorTest=function(h){we.setScissorTest(Je=h)},this.setOpaqueSort=function(h){xe=h},this.setTransparentSort=function(h){Ce=h},this.getClearColor=function(h){return h.copy(_e.getClearColor())},this.setClearColor=function(){_e.setClearColor.apply(_e,arguments)},this.getClearAlpha=function(){return _e.getClearAlpha()},this.setClearAlpha=function(){_e.setClearAlpha.apply(_e,arguments)},this.clear=function(h=!0,N=!0,w=!0){let L=0;if(h){let P=!1;if(V!==null){const ee=V.texture.format;P=ee===Kr||ee===qr||ee===Yr}if(P){const ee=V.texture.type,pe=ee===An||ee===si||ee===Ai||ee===oi||ee===Vr||ee===zr,Se=_e.getClearColor(),Ee=_e.getClearAlpha(),Fe=Se.r,Be=Se.g,De=Se.b;pe?(b[0]=Fe,b[1]=Be,b[2]=De,b[3]=Ee,R.clearBufferuiv(R.COLOR,0,b)):(A[0]=Fe,A[1]=Be,A[2]=De,A[3]=Ee,R.clearBufferiv(R.COLOR,0,A))}else L|=R.COLOR_BUFFER_BIT}N&&(L|=R.DEPTH_BUFFER_BIT),w&&(L|=R.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),R.clear(L)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",C,!1),n.removeEventListener("webglcontextrestored",z,!1),n.removeEventListener("webglcontextcreationerror",j,!1),_e.dispose(),le.dispose(),Pe.dispose(),be.dispose(),d.dispose(),H.dispose(),G.dispose(),rt.dispose(),I.dispose(),re.dispose(),K.dispose(),K.removeEventListener("sessionstart",Pt),K.removeEventListener("sessionend",Ht),vt.stop()};function C(h){h.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),y=!0}function z(){console.log("THREE.WebGLRenderer: Context Restored."),y=!1;const h=et.autoReset,N=ce.enabled,w=ce.autoUpdate,L=ce.needsUpdate,P=ce.type;ue(),et.autoReset=h,ce.enabled=N,ce.autoUpdate=w,ce.needsUpdate=L,ce.type=P}function j(h){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",h.statusMessage)}function se(h){const N=h.target;N.removeEventListener("dispose",se),ve(N)}function ve(h){Oe(h),be.remove(h)}function Oe(h){const N=be.get(h).programs;N!==void 0&&(N.forEach(function(w){re.releaseProgram(w)}),h.isShaderMaterial&&re.releaseShaderCache(h))}this.renderBufferDirect=function(h,N,w,L,P,ee){N===null&&(N=nt);const pe=P.isMesh&&P.matrixWorld.determinant()<0,Se=pn(h,N,w,L,P);we.setMaterial(L,pe);let Ee=w.index,Fe=1;if(L.wireframe===!0){if(Ee=W.getWireframeAttribute(w),Ee===void 0)return;Fe=2}const Be=w.drawRange,De=w.attributes.position;let Qe=Be.start*Fe,st=(Be.start+Be.count)*Fe;ee!==null&&(Qe=Math.max(Qe,ee.start*Fe),st=Math.min(st,(ee.start+ee.count)*Fe)),Ee!==null?(Qe=Math.max(Qe,0),st=Math.min(st,Ee.count)):De!=null&&(Qe=Math.max(Qe,0),st=Math.min(st,De.count));const xt=st-Qe;if(xt<0||xt===1/0)return;rt.setup(P,L,Se,w,Ee);let St,it=ge;if(Ee!==null&&(St=B.get(Ee),it=Xe,it.setIndex(St)),P.isMesh)L.wireframe===!0?(we.setLineWidth(L.wireframeLinewidth*dt()),it.setMode(R.LINES)):it.setMode(R.TRIANGLES);else if(P.isLine){let Ue=L.linewidth;Ue===void 0&&(Ue=1),we.setLineWidth(Ue*dt()),P.isLineSegments?it.setMode(R.LINES):P.isLineLoop?it.setMode(R.LINE_LOOP):it.setMode(R.LINE_STRIP)}else P.isPoints?it.setMode(R.POINTS):P.isSprite&&it.setMode(R.TRIANGLES);if(P.isBatchedMesh)if(P._multiDrawInstances!==null)it.renderMultiDrawInstances(P._multiDrawStarts,P._multiDrawCounts,P._multiDrawCount,P._multiDrawInstances);else if(ze.get("WEBGL_multi_draw"))it.renderMultiDraw(P._multiDrawStarts,P._multiDrawCounts,P._multiDrawCount);else{const Ue=P._multiDrawStarts,Rt=P._multiDrawCounts,lt=P._multiDrawCount,Xt=Ee?B.get(Ee).bytesPerElement:1,Cn=be.get(L).currentProgram.getUniforms();for(let Ft=0;Ft{function ee(){if(L.forEach(function(pe){be.get(pe).currentProgram.isReady()&&L.delete(pe)}),L.size===0){P(h);return}setTimeout(ee,10)}ze.get("KHR_parallel_shader_compile")!==null?ee():setTimeout(ee,10)})};let ot=null;function ft(h){ot&&ot(h)}function Pt(){vt.stop()}function Ht(){vt.start()}const vt=new ao;vt.setAnimationLoop(ft),typeof self<"u"&&vt.setContext(self),this.setAnimationLoop=function(h){ot=h,K.setAnimationLoop(h),h===null?vt.stop():vt.start()},K.addEventListener("sessionstart",Pt),K.addEventListener("sessionend",Ht),this.render=function(h,N){if(N!==void 0&&N.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(y===!0)return;if(h.matrixWorldAutoUpdate===!0&&h.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),K.enabled===!0&&K.isPresenting===!0&&(K.cameraAutoUpdate===!0&&K.updateCamera(N),N=K.getCamera()),h.isScene===!0&&h.onBeforeRender(x,h,N,V),l=Pe.get(h,M.length),l.init(N),M.push(l),Le.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),Q.setFromProjectionMatrix(Le),Me=this.localClippingEnabled,de=q.init(this.clippingPlanes,Me),c=le.get(h,O.length),c.init(),O.push(c),K.enabled===!0&&K.isPresenting===!0){const ee=x.xr.getDepthSensingMesh();ee!==null&&Wt(ee,N,-1/0,x.sortObjects)}Wt(h,N,0,x.sortObjects),c.finish(),x.sortObjects===!0&&c.sort(xe,Ce),Ke=K.enabled===!1||K.isPresenting===!1||K.hasDepthSensing()===!1,Ke&&_e.addToRenderList(c,h),this.info.render.frame++,de===!0&&q.beginShadows();const w=l.state.shadowsArray;ce.render(w,h,N),de===!0&&q.endShadows(),this.info.autoReset===!0&&this.info.reset();const L=c.opaque,P=c.transmissive;if(l.setupLights(),N.isArrayCamera){const ee=N.cameras;if(P.length>0)for(let pe=0,Se=ee.length;pe0&&$t(L,P,h,N),Ke&&_e.render(h),dn(c,h,N);V!==null&&F===0&&(S.updateMultisampleRenderTarget(V),S.updateRenderTargetMipmap(V)),h.isScene===!0&&h.onAfterRender(x,h,N),rt.resetDefaultState(),E=-1,g=null,M.pop(),M.length>0?(l=M[M.length-1],de===!0&&q.setGlobalState(x.clippingPlanes,l.state.camera)):l=null,O.pop(),O.length>0?c=O[O.length-1]:c=null};function Wt(h,N,w,L){if(h.visible===!1)return;if(h.layers.test(N.layers)){if(h.isGroup)w=h.renderOrder;else if(h.isLOD)h.autoUpdate===!0&&h.update(N);else if(h.isLight)l.pushLight(h),h.castShadow&&l.pushShadow(h);else if(h.isSprite){if(!h.frustumCulled||Q.intersectsSprite(h)){L&&ke.setFromMatrixPosition(h.matrixWorld).applyMatrix4(Le);const pe=G.update(h),Se=h.material;Se.visible&&c.push(h,pe,Se,w,ke.z,null)}}else if((h.isMesh||h.isLine||h.isPoints)&&(!h.frustumCulled||Q.intersectsObject(h))){const pe=G.update(h),Se=h.material;if(L&&(h.boundingSphere!==void 0?(h.boundingSphere===null&&h.computeBoundingSphere(),ke.copy(h.boundingSphere.center)):(pe.boundingSphere===null&&pe.computeBoundingSphere(),ke.copy(pe.boundingSphere.center)),ke.applyMatrix4(h.matrixWorld).applyMatrix4(Le)),Array.isArray(Se)){const Ee=pe.groups;for(let Fe=0,Be=Ee.length;Fe0&&Yt(P,N,w),ee.length>0&&Yt(ee,N,w),pe.length>0&&Yt(pe,N,w),we.buffers.depth.setTest(!0),we.buffers.depth.setMask(!0),we.buffers.color.setMask(!0),we.setPolygonOffset(!1)}function $t(h,N,w,L){if((w.isScene===!0?w.overrideMaterial:null)!==null)return;l.state.transmissionRenderTarget[L.id]===void 0&&(l.state.transmissionRenderTarget[L.id]=new jt(1,1,{generateMipmaps:!0,type:ze.has("EXT_color_buffer_half_float")||ze.has("EXT_color_buffer_float")?ln:An,minFilter:Qn,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Mt.workingColorSpace}));const ee=l.state.transmissionRenderTarget[L.id],pe=L.viewport||D;ee.setSize(pe.z*x.transmissionResolutionScale,pe.w*x.transmissionResolutionScale);const Se=x.getRenderTarget();x.setRenderTarget(ee),x.getClearColor(Y),J=x.getClearAlpha(),J<1&&x.setClearColor(16777215,.5),x.clear(),Ke&&_e.render(w);const Ee=x.toneMapping;x.toneMapping=sn;const Fe=L.viewport;if(L.viewport!==void 0&&(L.viewport=void 0),l.setupLightsView(L),de===!0&&q.setGlobalState(x.clippingPlanes,L),Yt(h,w,L),S.updateMultisampleRenderTarget(ee),S.updateRenderTargetMipmap(ee),ze.has("WEBGL_multisampled_render_to_texture")===!1){let Be=!1;for(let De=0,Qe=N.length;De0),De=!!w.morphAttributes.position,Qe=!!w.morphAttributes.normal,st=!!w.morphAttributes.color;let xt=sn;L.toneMapped&&(V===null||V.isXRRenderTarget===!0)&&(xt=x.toneMapping);const St=w.morphAttributes.position||w.morphAttributes.normal||w.morphAttributes.color,it=St!==void 0?St.length:0,Ue=be.get(L),Rt=l.state.lights;if(de===!0&&(Me===!0||h!==g)){const Dt=h===g&&L.id===E;q.setState(L,h,Dt)}let lt=!1;L.version===Ue.__version?(Ue.needsLights&&Ue.lightsStateVersion!==Rt.state.version||Ue.outputColorSpace!==Se||P.isBatchedMesh&&Ue.batching===!1||!P.isBatchedMesh&&Ue.batching===!0||P.isBatchedMesh&&Ue.batchingColor===!0&&P.colorTexture===null||P.isBatchedMesh&&Ue.batchingColor===!1&&P.colorTexture!==null||P.isInstancedMesh&&Ue.instancing===!1||!P.isInstancedMesh&&Ue.instancing===!0||P.isSkinnedMesh&&Ue.skinning===!1||!P.isSkinnedMesh&&Ue.skinning===!0||P.isInstancedMesh&&Ue.instancingColor===!0&&P.instanceColor===null||P.isInstancedMesh&&Ue.instancingColor===!1&&P.instanceColor!==null||P.isInstancedMesh&&Ue.instancingMorph===!0&&P.morphTexture===null||P.isInstancedMesh&&Ue.instancingMorph===!1&&P.morphTexture!==null||Ue.envMap!==Ee||L.fog===!0&&Ue.fog!==ee||Ue.numClippingPlanes!==void 0&&(Ue.numClippingPlanes!==q.numPlanes||Ue.numIntersection!==q.numIntersection)||Ue.vertexAlphas!==Fe||Ue.vertexTangents!==Be||Ue.morphTargets!==De||Ue.morphNormals!==Qe||Ue.morphColors!==st||Ue.toneMapping!==xt||Ue.morphTargetsCount!==it)&&(lt=!0):(lt=!0,Ue.__version=L.version);let Xt=Ue.currentProgram;lt===!0&&(Xt=qt(L,N,P));let Cn=!1,Ft=!1,jn=!1;const ht=Xt.getUniforms(),Gt=Ue.uniforms;if(we.useProgram(Xt.program)&&(Cn=!0,Ft=!0,jn=!0),L.id!==E&&(E=L.id,Ft=!0),Cn||g!==h){we.buffers.depth.getReversed()?(he.copy(h.projectionMatrix),Mo(he),To(he),ht.setValue(R,"projectionMatrix",he)):ht.setValue(R,"projectionMatrix",h.projectionMatrix),ht.setValue(R,"viewMatrix",h.matrixWorldInverse);const Lt=ht.map.cameraPosition;Lt!==void 0&&Lt.setValue(R,Ie.setFromMatrixPosition(h.matrixWorld)),We.logarithmicDepthBuffer&&ht.setValue(R,"logDepthBufFC",2/(Math.log(h.far+1)/Math.LN2)),(L.isMeshPhongMaterial||L.isMeshToonMaterial||L.isMeshLambertMaterial||L.isMeshBasicMaterial||L.isMeshStandardMaterial||L.isShaderMaterial)&&ht.setValue(R,"isOrthographic",h.isOrthographicCamera===!0),g!==h&&(g=h,Ft=!0,jn=!0)}if(P.isSkinnedMesh){ht.setOptional(R,P,"bindMatrix"),ht.setOptional(R,P,"bindMatrixInverse");const Dt=P.skeleton;Dt&&(Dt.boneTexture===null&&Dt.computeBoneTexture(),ht.setValue(R,"boneTexture",Dt.boneTexture,S))}P.isBatchedMesh&&(ht.setOptional(R,P,"batchingTexture"),ht.setValue(R,"batchingTexture",P._matricesTexture,S),ht.setOptional(R,P,"batchingIdTexture"),ht.setValue(R,"batchingIdTexture",P._indirectTexture,S),ht.setOptional(R,P,"batchingColorTexture"),P._colorsTexture!==null&&ht.setValue(R,"batchingColorTexture",P._colorsTexture,S));const kt=w.morphAttributes;if((kt.position!==void 0||kt.normal!==void 0||kt.color!==void 0)&&Re.update(P,w,Xt),(Ft||Ue.receiveShadow!==P.receiveShadow)&&(Ue.receiveShadow=P.receiveShadow,ht.setValue(R,"receiveShadow",P.receiveShadow)),L.isMeshGouraudMaterial&&L.envMap!==null&&(Gt.envMap.value=Ee,Gt.flipEnvMap.value=Ee.isCubeTexture&&Ee.isRenderTargetTexture===!1?-1:1),L.isMeshStandardMaterial&&L.envMap===null&&N.environment!==null&&(Gt.envMapIntensity.value=N.environmentIntensity),Ft&&(ht.setValue(R,"toneMappingExposure",x.toneMappingExposure),Ue.needsLights&&Rn(Gt,jn),ee&&L.fog===!0&&ie.refreshFogUniforms(Gt,ee),ie.refreshMaterialUniforms(Gt,L,X,ne,l.state.transmissionRenderTarget[h.id]),Ei.upload(R,fn(Ue),Gt,S)),L.isShaderMaterial&&L.uniformsNeedUpdate===!0&&(Ei.upload(R,fn(Ue),Gt,S),L.uniformsNeedUpdate=!1),L.isSpriteMaterial&&ht.setValue(R,"center",P.center),ht.setValue(R,"modelViewMatrix",P.modelViewMatrix),ht.setValue(R,"normalMatrix",P.normalMatrix),ht.setValue(R,"modelMatrix",P.matrixWorld),L.isShaderMaterial||L.isRawShaderMaterial){const Dt=L.uniformsGroups;for(let Lt=0,Di=Dt.length;Lt0&&S.useMultisampledRTT(h)===!1?P=be.get(h).__webglMultisampledFramebuffer:Array.isArray(Be)?P=Be[w]:P=Be,D.copy(h.viewport),Z.copy(h.scissor),k=h.scissorTest}else D.copy(Ne).multiplyScalar(X).floor(),Z.copy(je).multiplyScalar(X).floor(),k=Je;if(w!==0&&(P=an),we.bindFramebuffer(R.FRAMEBUFFER,P)&&L&&we.drawBuffers(h,P),we.viewport(D),we.scissor(Z),we.setScissorTest(k),ee){const Ee=be.get(h.texture);R.framebufferTexture2D(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,R.TEXTURE_CUBE_MAP_POSITIVE_X+N,Ee.__webglTexture,w)}else if(pe){const Ee=be.get(h.texture),Fe=N;R.framebufferTextureLayer(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,Ee.__webglTexture,w,Fe)}else if(h!==null&&w!==0){const Ee=be.get(h.texture);R.framebufferTexture2D(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,R.TEXTURE_2D,Ee.__webglTexture,w)}E=-1},this.readRenderTargetPixels=function(h,N,w,L,P,ee,pe){if(!(h&&h.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=be.get(h).__webglFramebuffer;if(h.isWebGLCubeRenderTarget&&pe!==void 0&&(Se=Se[pe]),Se){we.bindFramebuffer(R.FRAMEBUFFER,Se);try{const Ee=h.texture,Fe=Ee.format,Be=Ee.type;if(!We.textureFormatReadable(Fe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!We.textureTypeReadable(Be)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=h.width-L&&w>=0&&w<=h.height-P&&R.readPixels(N,w,L,P,Ge.convert(Fe),Ge.convert(Be),ee)}finally{const Ee=V!==null?be.get(V).__webglFramebuffer:null;we.bindFramebuffer(R.FRAMEBUFFER,Ee)}}},this.readRenderTargetPixelsAsync=async function(h,N,w,L,P,ee,pe){if(!(h&&h.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=be.get(h).__webglFramebuffer;if(h.isWebGLCubeRenderTarget&&pe!==void 0&&(Se=Se[pe]),Se){const Ee=h.texture,Fe=Ee.format,Be=Ee.type;if(!We.textureFormatReadable(Fe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!We.textureTypeReadable(Be))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(N>=0&&N<=h.width-L&&w>=0&&w<=h.height-P){we.bindFramebuffer(R.FRAMEBUFFER,Se);const De=R.createBuffer();R.bindBuffer(R.PIXEL_PACK_BUFFER,De),R.bufferData(R.PIXEL_PACK_BUFFER,ee.byteLength,R.STREAM_READ),R.readPixels(N,w,L,P,Ge.convert(Fe),Ge.convert(Be),0);const Qe=V!==null?be.get(V).__webglFramebuffer:null;we.bindFramebuffer(R.FRAMEBUFFER,Qe);const st=R.fenceSync(R.SYNC_GPU_COMMANDS_COMPLETE,0);return R.flush(),await bo(R,st,4),R.bindBuffer(R.PIXEL_PACK_BUFFER,De),R.getBufferSubData(R.PIXEL_PACK_BUFFER,0,ee),R.deleteBuffer(De),R.deleteSync(st),ee}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(h,N=null,w=0){h.isTexture!==!0&&(Ln("WebGLRenderer: copyFramebufferToTexture function signature has changed."),N=arguments[0]||null,h=arguments[1]);const L=Math.pow(2,-w),P=Math.floor(h.image.width*L),ee=Math.floor(h.image.height*L),pe=N!==null?N.x:0,Se=N!==null?N.y:0;S.setTexture2D(h,0),R.copyTexSubImage2D(R.TEXTURE_2D,w,0,0,pe,Se,P,ee),we.unbindTexture()};const yn=R.createFramebuffer(),Zn=R.createFramebuffer();this.copyTextureToTexture=function(h,N,w=null,L=null,P=0,ee=null){h.isTexture!==!0&&(Ln("WebGLRenderer: copyTextureToTexture function signature has changed."),L=arguments[0]||null,h=arguments[1],N=arguments[2],ee=arguments[3]||0,w=null),ee===null&&(P!==0?(Ln("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ee=P,P=0):ee=0);let pe,Se,Ee,Fe,Be,De,Qe,st,xt;const St=h.isCompressedTexture?h.mipmaps[ee]:h.image;if(w!==null)pe=w.max.x-w.min.x,Se=w.max.y-w.min.y,Ee=w.isBox3?w.max.z-w.min.z:1,Fe=w.min.x,Be=w.min.y,De=w.isBox3?w.min.z:0;else{const kt=Math.pow(2,-P);pe=Math.floor(St.width*kt),Se=Math.floor(St.height*kt),h.isDataArrayTexture?Ee=St.depth:h.isData3DTexture?Ee=Math.floor(St.depth*kt):Ee=1,Fe=0,Be=0,De=0}L!==null?(Qe=L.x,st=L.y,xt=L.z):(Qe=0,st=0,xt=0);const it=Ge.convert(N.format),Ue=Ge.convert(N.type);let Rt;N.isData3DTexture?(S.setTexture3D(N,0),Rt=R.TEXTURE_3D):N.isDataArrayTexture||N.isCompressedArrayTexture?(S.setTexture2DArray(N,0),Rt=R.TEXTURE_2D_ARRAY):(S.setTexture2D(N,0),Rt=R.TEXTURE_2D),R.pixelStorei(R.UNPACK_FLIP_Y_WEBGL,N.flipY),R.pixelStorei(R.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),R.pixelStorei(R.UNPACK_ALIGNMENT,N.unpackAlignment);const lt=R.getParameter(R.UNPACK_ROW_LENGTH),Xt=R.getParameter(R.UNPACK_IMAGE_HEIGHT),Cn=R.getParameter(R.UNPACK_SKIP_PIXELS),Ft=R.getParameter(R.UNPACK_SKIP_ROWS),jn=R.getParameter(R.UNPACK_SKIP_IMAGES);R.pixelStorei(R.UNPACK_ROW_LENGTH,St.width),R.pixelStorei(R.UNPACK_IMAGE_HEIGHT,St.height),R.pixelStorei(R.UNPACK_SKIP_PIXELS,Fe),R.pixelStorei(R.UNPACK_SKIP_ROWS,Be),R.pixelStorei(R.UNPACK_SKIP_IMAGES,De);const ht=h.isDataArrayTexture||h.isData3DTexture,Gt=N.isDataArrayTexture||N.isData3DTexture;if(h.isDepthTexture){const kt=be.get(h),Dt=be.get(N),Lt=be.get(kt.__renderTarget),Di=be.get(Dt.__renderTarget);we.bindFramebuffer(R.READ_FRAMEBUFFER,Lt.__webglFramebuffer),we.bindFramebuffer(R.DRAW_FRAMEBUFFER,Di.__webglFramebuffer);for(let hn=0;hnMath.PI&&(i-=Ut),r<-Math.PI?r+=Ut:r>Math.PI&&(r-=Ut),i<=r?this._spherical.theta=Math.max(i,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+r)/2?Math.max(i,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=o!=this._spherical.radius}if(Tt.setFromSpherical(this._spherical),Tt.applyQuaternion(this._quatInverse),n.copy(this.target).add(Tt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const s=Tt.length();o=this._clampDistance(s*this._scale);const u=s-o;this.object.position.addScaledVector(this._dollyDirection,u),this.object.updateMatrixWorld(),a=!!u}else if(this.object.isOrthographicCamera){const s=new Te(this._mouse.x,this._mouse.y,0);s.unproject(this.object);const u=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=u!==this.object.zoom;const f=new Te(this._mouse.x,this._mouse.y,0);f.unproject(this.object),this.object.position.sub(f).add(s),this.object.updateMatrixWorld(),o=Tt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(_i.origin.copy(this.object.position),_i.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(_i.direction))Xi||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Xi||this._lastTargetPosition.distanceToSquared(this.target)>Xi?(this.dispatchEvent(Dr),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?Ut/60*this.autoRotateSpeed*t:Ut/60/60*this.autoRotateSpeed}_getZoomScale(t){const n=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,n){Tt.setFromMatrixColumn(n,0),Tt.multiplyScalar(-t),this._panOffset.add(Tt)}_panUp(t,n){this.screenSpacePanning===!0?Tt.setFromMatrixColumn(n,1):(Tt.setFromMatrixColumn(n,0),Tt.crossVectors(this.object.up,Tt)),Tt.multiplyScalar(t),this._panOffset.add(Tt)}_pan(t,n){const i=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;Tt.copy(r).sub(this.target);let a=Tt.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*a/i.clientHeight,this.object.matrix),this._panUp(2*n*a/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),r=t-i.left,a=n-i.top,o=i.width,s=i.height;this._mouse.x=r/o*2-1,this._mouse.y=-(a/s)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Ut*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ut*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let n=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(Ut*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),n=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-Ut*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),n=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(Ut*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),n=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-Ut*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const n=this._getSecondPointerPosition(t),i=.5*(t.pageX+n.x),r=.5*(t.pageY+n.y);this._rotateStart.set(i,r)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const n=this._getSecondPointerPosition(t),i=.5*(t.pageX+n.x),r=.5*(t.pageY+n.y);this._panStart.set(i,r)}}_handleTouchStartDolly(t){const n=this._getSecondPointerPosition(t),i=t.pageX-n.x,r=t.pageY-n.y,a=Math.sqrt(i*i+r*r);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const i=this._getSecondPointerPosition(t),r=.5*(t.pageX+i.x),a=.5*(t.pageY+i.y);this._rotateEnd.set(r,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Ut*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ut*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const n=this._getSecondPointerPosition(t),i=.5*(t.pageX+n.x),r=.5*(t.pageY+n.y);this._panEnd.set(i,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const n=this._getSecondPointerPosition(t),i=t.pageX-n.x,r=t.pageY-n.y,a=Math.sqrt(i*i+r*r);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(t.pageX+n.x)*.5,s=(t.pageY+n.y)*.5;this._updateZoomParameters(o,s)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let n=0;n - varying vec2 vUv; - uniform sampler2D colorTexture; - uniform vec2 invSize; - uniform vec2 direction; - uniform float gaussianCoefficients[KERNEL_RADIUS]; - - void main() { - float weightSum = gaussianCoefficients[0]; - vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum; - for( int i = 1; i < KERNEL_RADIUS; i ++ ) { - float x = float(i); - float w = gaussianCoefficients[i]; - vec2 uvOffset = direction * invSize * x; - vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb; - vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb; - diffuseSum += (sample1 + sample2) * w; - weightSum += 2.0 * w; - } - gl_FragColor = vec4(diffuseSum/weightSum, 1.0); - }`})}getCompositeMaterial(t){return new Ot({defines:{NUM_MIPS:t},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:`varying vec2 vUv; - void main() { - vUv = uv; - gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); - }`,fragmentShader:`varying vec2 vUv; - uniform sampler2D blurTexture1; - uniform sampler2D blurTexture2; - uniform sampler2D blurTexture3; - uniform sampler2D blurTexture4; - uniform sampler2D blurTexture5; - uniform float bloomStrength; - uniform float bloomRadius; - uniform float bloomFactors[NUM_MIPS]; - uniform vec3 bloomTintColors[NUM_MIPS]; - - float lerpBloomFactor(const in float factor) { - float mirrorFactor = 1.2 - factor; - return mix(factor, mirrorFactor, bloomRadius); - } - - void main() { - gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) + - lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) + - lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) + - lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) + - lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) ); - }`})}}Xn.BlurDirectionX=new Ze(1,0);Xn.BlurDirectionY=new Ze(0,1);function Ep(){const t=new Float32Array(6e3),n=new Float32Array(2e3*3);for(let a=0;a<2e3;a++){const o=Math.random()*Math.PI*2,s=Math.acos(2*Math.random()-1),u=600+Math.random()*400;t[a*3]=u*Math.sin(s)*Math.cos(o),t[a*3+1]=u*Math.sin(s)*Math.sin(o),t[a*3+2]=u*Math.cos(s);const f=Math.random();n[a*3]=.55+f*.25,n[a*3+1]=.55+f*.15,n[a*3+2]=.75+f*.25}const i=new Vt;i.setAttribute("position",new wt(t,3)),i.setAttribute("color",new wt(n,3));const r=new kn({size:1.6,sizeAttenuation:!0,vertexColors:!0,transparent:!0,opacity:.6,depthWrite:!1,blending:Ct});return new Vn(i,r)}function xp(e){const t=new Ws;t.background=new Ae(328975),t.fog=new io(657946,.0035);const n=new Hn(60,e.clientWidth/e.clientHeight,.1,2e3);n.position.set(0,30,80);const i=new Qu({antialias:!0,alpha:!0,powerPreference:"high-performance"});i.setSize(e.clientWidth,e.clientHeight),i.setPixelRatio(Math.min(window.devicePixelRatio,2)),i.toneMapping=to,i.toneMappingExposure=1.25,e.appendChild(i.domElement);const r=new ep(n,i.domElement);r.enableDamping=!0,r.dampingFactor=.05,r.rotateSpeed=.5,r.zoomSpeed=.8,r.minDistance=12,r.maxDistance=180,r.autoRotate=!0,r.autoRotateSpeed=.3;const a=new gp(i);a.addPass(new vp(t,n));const o=new Xn(new Ze(e.clientWidth,e.clientHeight),.55,.6,.2);a.addPass(o);const s=new Xs(2763354,.7);t.add(s);const u=new Qa(6514417,1.8,240);u.position.set(50,50,50),t.add(u);const f=new Qa(11032055,1.2,240);f.position.set(-50,-30,-50),t.add(f);const m=Ep();t.add(m);const _=new Ys;_.params.Points={threshold:2};const v=new Ze;return{scene:t,camera:n,renderer:i,controls:r,composer:a,bloomPass:o,raycaster:_,mouse:v,lights:{ambient:s,point1:u,point2:f},starfield:m}}function Mp(e,t){const n=t.clientWidth,i=t.clientHeight;e.camera.aspect=n/i,e.camera.updateProjectionMatrix(),e.renderer.setSize(n,i),e.composer.setSize(n,i)}function Tp(e){e.scene.traverse(t=>{var n;(t instanceof Bt||t instanceof qs)&&((n=t.geometry)==null||n.dispose(),Array.isArray(t.material)?t.material.forEach(i=>i.dispose()):t.material&&t.material.dispose())}),e.renderer.dispose(),e.composer.dispose()}class bp{constructor(t){Ve(this,"positions");Ve(this,"velocities");Ve(this,"running",!0);Ve(this,"step",0);Ve(this,"repulsionStrength",500);Ve(this,"attractionStrength",.01);Ve(this,"dampening",.9);Ve(this,"baseMaxSteps",300);Ve(this,"maxSteps",300);Ve(this,"cooldownExtension",0);this.positions=t,this.velocities=new Map;for(const n of t.keys())this.velocities.set(n,new Te)}addNode(t,n){this.positions.set(t,n.clone()),this.velocities.set(t,new Te),this.cooldownExtension=100,this.maxSteps=Math.max(this.maxSteps,this.step+this.cooldownExtension),this.running=!0}removeNode(t){this.positions.delete(t),this.velocities.delete(t)}tick(t){if(!this.running)return;if(this.step>this.maxSteps){this.cooldownExtension>0&&(this.cooldownExtension=0,this.maxSteps=this.baseMaxSteps);return}this.step++;const n=Math.max(.001,1-this.step/this.maxSteps),i=Array.from(this.positions.keys());for(let r=0;r{const r=i;(r.userData.source===t||r.userData.target===t)&&n.push(r)});for(const i of n)this.growingEdges=this.growingEdges.filter(r=>r.line!==i),this.dissolvingEdges.push({line:i,frame:0,totalFrames:40})}animateEdges(t){for(let n=this.growingEdges.length-1;n>=0;n--){const i=this.growingEdges[n];i.frame++;const r=Ap(Math.min(i.frame/i.totalFrames,1)),a=t.get(i.source),o=t.get(i.target);if(!a||!o)continue;const s=a.clone().lerp(o,r),u=i.line.geometry.attributes.position;u.setXYZ(0,a.x,a.y,a.z),u.setXYZ(1,s.x,s.y,s.z),u.needsUpdate=!0;const f=i.line.material;f.opacity=r*.65,i.frame>=i.totalFrames&&(f.opacity=.65,this.growingEdges.splice(n,1))}for(let n=this.dissolvingEdges.length-1;n>=0;n--){const i=this.dissolvingEdges[n];i.frame++;const r=i.frame/i.totalFrames,a=i.line.material;a.opacity=Math.max(0,.65*(1-r)),i.frame>=i.totalFrames&&(this.group.remove(i.line),i.line.geometry.dispose(),i.line.material.dispose(),this.dissolvingEdges.splice(n,1))}}updatePositions(t){this.group.children.forEach(n=>{const i=n;if(this.growingEdges.some(o=>o.line===i)||this.dissolvingEdges.some(o=>o.line===i))return;const r=t.get(i.userData.source),a=t.get(i.userData.target);if(r&&a){const o=i.geometry.attributes.position;o.setXYZ(0,r.x,r.y,r.z),o.setXYZ(1,a.x,a.y,a.z),o.needsUpdate=!0}})}dispose(){this.group.children.forEach(t=>{var i,r;const n=t;(i=n.geometry)==null||i.dispose(),(r=n.material)==null||r.dispose()}),this.growingEdges=[],this.dissolvingEdges=[]}}class wp{constructor(t){Ve(this,"starField");Ve(this,"neuralParticles");this.starField=this.createStarField(),this.neuralParticles=this.createNeuralParticles(),t.add(this.starField),t.add(this.neuralParticles)}createStarField(){const n=new Vt,i=new Float32Array(3e3*3),r=new Float32Array(3e3);for(let o=0;o<3e3;o++)i[o*3]=(Math.random()-.5)*1e3,i[o*3+1]=(Math.random()-.5)*1e3,i[o*3+2]=(Math.random()-.5)*1e3,r[o]=Math.random()*1.5;n.setAttribute("position",new wt(i,3)),n.setAttribute("size",new wt(r,1));const a=new kn({color:6514417,size:.5,transparent:!0,opacity:.4,sizeAttenuation:!0,blending:Ct});return new Vn(n,a)}createNeuralParticles(){const n=new Vt,i=new Float32Array(500*3),r=new Float32Array(500*3);for(let o=0;o<500;o++)i[o*3]=(Math.random()-.5)*100,i[o*3+1]=(Math.random()-.5)*100,i[o*3+2]=(Math.random()-.5)*100,r[o*3]=.4+Math.random()*.3,r[o*3+1]=.3+Math.random()*.2,r[o*3+2]=.8+Math.random()*.2;n.setAttribute("position",new wt(i,3)),n.setAttribute("color",new wt(r,3));const a=new kn({size:.3,vertexColors:!0,transparent:!0,opacity:.4,blending:Ct,sizeAttenuation:!0});return new Vn(n,a)}animate(t){this.starField.rotation.y+=1e-4,this.starField.rotation.x+=5e-5;const n=this.neuralParticles.geometry.attributes.position;for(let i=0;i=0;r--){const a=this.pulseEffects[r];if(a.intensity-=a.decay,a.intensity<=0){this.pulseEffects.splice(r,1);continue}const o=t.get(a.nodeId);if(o){const s=o.material;s.emissive.lerp(a.color,a.intensity*.3),s.emissiveIntensity=Math.max(s.emissiveIntensity,a.intensity)}}for(let r=this.spawnBursts.length-1;r>=0;r--){const a=this.spawnBursts[r];if(a.age++,a.age>120){this.scene.remove(a.particles),a.particles.geometry.dispose(),a.particles.material.dispose(),this.spawnBursts.splice(r,1);continue}const o=a.particles.geometry.attributes.position,s=a.particles.geometry.attributes.velocity;for(let f=0;f=0;r--){const a=this.rainbowBursts[r];if(a.age++,a.age>a.maxAge){this.scene.remove(a.particles),a.particles.geometry.dispose(),a.particles.material.dispose(),this.rainbowBursts.splice(r,1);continue}const o=a.particles.geometry.attributes.position,s=a.particles.geometry.attributes.velocity;for(let v=0;v=0;r--){const a=this.rippleWaves[r];if(a.age++,a.radius+=a.speed,a.age>a.maxAge){this.rippleWaves.splice(r,1);continue}const o=a.radius,s=3;i.forEach((u,f)=>{if(a.pulsedNodes.has(f))return;const m=u.distanceTo(a.origin);m>=o-s&&m<=o+s&&(a.pulsedNodes.add(f),this.addPulse(f,.8,new Ae(65489),.03))})}for(let r=this.implosions.length-1;r>=0;r--){const a=this.implosions[r];if(a.age++,a.age>a.maxAge+20){this.scene.remove(a.particles),a.particles.geometry.dispose(),a.particles.material.dispose(),a.flash&&(this.scene.remove(a.flash),a.flash.geometry.dispose(),a.flash.material.dispose()),this.implosions.splice(r,1);continue}if(a.age<=a.maxAge){const o=a.particles.geometry.attributes.position,s=a.particles.geometry.attributes.velocity,u=1+a.age*.02;for(let m=0;ma.maxAge){const o=(a.age-a.maxAge)/20;a.flash.material.opacity=Math.max(0,1-o),a.flash.scale.setScalar(1+o*3)}}for(let r=this.shockwaves.length-1;r>=0;r--){const a=this.shockwaves[r];if(a.age++,a.age>a.maxAge){this.scene.remove(a.mesh),a.mesh.geometry.dispose(),a.mesh.material.dispose(),this.shockwaves.splice(r,1);continue}const o=a.age/a.maxAge;a.mesh.scale.setScalar(1+o*20),a.mesh.material.opacity=.8*(1-o),a.mesh.lookAt(n.position)}for(let r=this.connectionFlashes.length-1;r>=0;r--){const a=this.connectionFlashes[r];if(a.intensity-=.015,a.intensity<=0){this.scene.remove(a.line),a.line.geometry.dispose(),a.line.material.dispose(),this.connectionFlashes.splice(r,1);continue}a.line.material.opacity=a.intensity}for(let r=this.birthOrbs.length-1;r>=0;r--){const a=this.birthOrbs[r];a.age++;const o=a.gestationFrames+a.flightFrames,s=a.sprite.material,u=a.core.material,f=a.getTargetPos();if(f)a.lastTargetPos.copy(f);else if(a.age>a.gestationFrames&&!a.aborted){a.aborted=!0;const m=a.sprite.position;s.color.setRGB(1,.15,.2),u.color.setRGB(1,.6,.6),this.createImplosion(m,new Ae(16721203)),a.arriveFired=!0,a.age=o+1}if(a.age<=a.gestationFrames){const m=a.age/a.gestationFrames,_=1-Math.pow(1-m,3),v=.85+Math.sin(a.age*.35)*.15,p=.5+_*4.5*v,b=.2+_*1.8*v;a.sprite.scale.set(p,p,1),a.core.scale.set(b,b,1),s.opacity=_*.95,u.opacity=_,s.color.copy(a.color).multiplyScalar(.7+_*.3),a.sprite.position.copy(a.startPos),a.core.position.copy(a.startPos)}else if(a.age<=o){const m=(a.age-a.gestationFrames)/a.flightFrames,_=m<.5?2*m*m:1-Math.pow(-2*m+2,2)/2,v=a.startPos,p=a.lastTargetPos,b=p.x-v.x,A=p.y-v.y,c=p.z-v.z,l=Math.sqrt(b*b+A*A+c*c),O=(v.x+p.x)*.5,M=(v.y+p.y)*.5+30+l*.15,x=(v.z+p.z)*.5,y=1-_,U=y*y,F=2*y*_,V=_*_,E=U*v.x+F*O+V*p.x,g=U*v.y+F*M+V*p.y,D=U*v.z+F*x+V*p.z;a.sprite.position.set(E,g,D),a.core.position.set(E,g,D);const Z=1-_*.35;a.sprite.scale.setScalar(5*Z),a.core.scale.setScalar(2*Z),s.opacity=.95,u.opacity=1,s.color.copy(a.color)}else if(a.arriveFired){const m=a.age-o,_=Math.max(0,1-m/8);s.opacity=.95*_,u.opacity=1*_,a.sprite.scale.setScalar(5*(1+(1-_)*2)),_<=0&&(this.scene.remove(a.sprite),this.scene.remove(a.core),s.dispose(),u.dispose(),this.birthOrbs.splice(r,1))}else{a.arriveFired=!0;try{a.onArrive()}catch(m){console.warn("[birth-orb] onArrive threw",m)}}}}dispose(){for(const t of this.spawnBursts)this.scene.remove(t.particles),t.particles.geometry.dispose(),t.particles.material.dispose();for(const t of this.rainbowBursts)this.scene.remove(t.particles),t.particles.geometry.dispose(),t.particles.material.dispose();for(const t of this.implosions)this.scene.remove(t.particles),t.particles.geometry.dispose(),t.particles.material.dispose(),t.flash&&(this.scene.remove(t.flash),t.flash.geometry.dispose(),t.flash.material.dispose());for(const t of this.shockwaves)this.scene.remove(t.mesh),t.mesh.geometry.dispose(),t.mesh.material.dispose();for(const t of this.connectionFlashes)this.scene.remove(t.line),t.line.geometry.dispose(),t.line.material.dispose();for(const t of this.birthOrbs)this.scene.remove(t.sprite),this.scene.remove(t.core),t.sprite.material.dispose(),t.core.material.dispose();this.pulseEffects=[],this.spawnBursts=[],this.rainbowBursts=[],this.rippleWaves=[],this.implosions=[],this.shockwaves=[],this.connectionFlashes=[],this.birthOrbs=[]}}const Qt={bloomStrength:.8,rotateSpeed:.3,fogColor:328976,fogDensity:.008,nebulaIntensity:0,chromaticIntensity:.002,vignetteRadius:.9,breatheAmplitude:1},rn={bloomStrength:1.8,rotateSpeed:.08,fogColor:656672,fogDensity:.006,nebulaIntensity:1,chromaticIntensity:.005,vignetteRadius:.7,breatheAmplitude:2};class Cp{constructor(){Ve(this,"active",!1);Ve(this,"transition",0);Ve(this,"transitionSpeed",.008);Ve(this,"current");Ve(this,"auroraHue",0);this.current={...Qt}}setActive(t){this.active=t}update(t,n,i,r,a){const o=this.active?1:0;this.transition+=(o-this.transition)*this.transitionSpeed*60*(1/60),this.transition=Math.max(0,Math.min(1,this.transition));const s=this.transition;this.current.bloomStrength=this.lerp(Qt.bloomStrength,rn.bloomStrength,s),this.current.rotateSpeed=this.lerp(Qt.rotateSpeed,rn.rotateSpeed,s),this.current.fogDensity=this.lerp(Qt.fogDensity,rn.fogDensity,s),this.current.nebulaIntensity=this.lerp(Qt.nebulaIntensity,rn.nebulaIntensity,s),this.current.chromaticIntensity=this.lerp(Qt.chromaticIntensity,rn.chromaticIntensity,s),this.current.vignetteRadius=this.lerp(Qt.vignetteRadius,rn.vignetteRadius,s),this.current.breatheAmplitude=this.lerp(Qt.breatheAmplitude,rn.breatheAmplitude,s),n.strength=this.current.bloomStrength,i.autoRotateSpeed=this.current.rotateSpeed;const u=new Ae(Qt.fogColor),f=new Ae(rn.fogColor),m=u.clone().lerp(f,s);if(t.fog=new io(m,this.current.fogDensity),s>.01){this.auroraHue=a*.1%1;const _=new Ae().setHSL(.75+this.auroraHue*.15,.8,.5),v=new Ae().setHSL(.55+this.auroraHue*.2,.7,.4);r.point1.color.lerp(_,s*.3),r.point2.color.lerp(v,s*.3)}else r.point1.color.set(6514417),r.point2.color.set(11032055)}lerp(t,n,i){return t+(n-t)*i}}const Pp=50,ai=[];function Dp(e,t,n){const i=e.tags??[],r=e.type??"";let a=null,o=0;for(const s of t){let u=0;s.type===r&&(u+=2);for(const f of s.tags)i.includes(f)&&(u+=1);u>o&&(o=u,a=s.id)}if(a&&o>0){const s=n.get(a);if(s)return new Te(s.x+(Math.random()-.5)*10,s.y+(Math.random()-.5)*10,s.z+(Math.random()-.5)*10)}return new Te((Math.random()-.5)*40,(Math.random()-.5)*40,(Math.random()-.5)*40)}function Lp(e,t){if(ai.length<=Pp)return;const n=ai.shift();e.edgeManager.removeEdgesForNode(n),e.nodeManager.removeNode(n),e.forceSim.removeNode(n),e.onMutation({type:"edgesRemoved",nodeId:n}),e.onMutation({type:"nodeRemoved",nodeId:n});const i=t.findIndex(r=>r.id===n);i!==-1&&t.splice(i,1)}function Up(e,t,n){var _,v;const{effects:i,nodeManager:r,edgeManager:a,forceSim:o,camera:s,onMutation:u}=t,f=r.positions,m=r.meshMap;switch(e.type){case"MemoryCreated":{const p=e.data;if(!p.id)break;const b={id:p.id,label:(p.content??"").slice(0,60),type:p.node_type??"fact",retention:Math.max(0,Math.min(1,p.retention??.9)),tags:p.tags??[],createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),isCenter:!1},A=Dp(b,n,f),c=r.addNode(b,A,{isBirthRitual:!0});o.addNode(p.id,c),ai.push(p.id),Lp(t,n);const l=new Ae(sl[b.type]||"#00ffd1"),O=l.clone();O.offsetHSL(.15,0,0),i.createBirthOrb(s,l,()=>r.positions.get(b.id),()=>{r.igniteNode(b.id);const M=r.positions.get(b.id)??A,x=r.meshMap.get(b.id);x&&x.scale.multiplyScalar(1.8),i.createRainbowBurst(M,l),i.createShockwave(M,l,s),i.createShockwave(M,O,s),i.createRippleWave(M)}),u({type:"nodeAdded",node:b});break}case"ConnectionDiscovered":{const p=e.data;if(!p.source_id||!p.target_id)break;const b=f.get(p.source_id),A=f.get(p.target_id),c={source:p.source_id,target:p.target_id,weight:p.weight??.5,type:p.connection_type??"semantic"};a.addEdge(c,f),b&&A&&i.createConnectionFlash(b,A,new Ae(54527)),p.source_id&&m.has(p.source_id)&&i.addPulse(p.source_id,1,new Ae(54527),.02),p.target_id&&m.has(p.target_id)&&i.addPulse(p.target_id,1,new Ae(54527),.02),u({type:"edgeAdded",edge:c});break}case"MemoryDeleted":{const p=e.data;if(!p.id)break;const b=f.get(p.id);if(b){const c=new Ae(16729943);i.createImplosion(b,c)}a.removeEdgesForNode(p.id),r.removeNode(p.id),o.removeNode(p.id);const A=ai.indexOf(p.id);A!==-1&&ai.splice(A,1),u({type:"edgesRemoved",nodeId:p.id}),u({type:"nodeRemoved",nodeId:p.id});break}case"MemoryPromoted":{const p=e.data,b=p==null?void 0:p.id;if(!b)break;const A=p.new_retention??.95;if(m.has(b)){r.growNode(b,A),i.addPulse(b,1.2,new Ae(65416),.01);const c=f.get(b);c&&(i.createShockwave(c,new Ae(65416),s),i.createSpawnBurst(c,new Ae(65416))),u({type:"nodeUpdated",nodeId:b,retention:A})}break}case"MemoryDemoted":{const p=e.data,b=p==null?void 0:p.id;if(!b)break;const A=p.new_retention??.3;m.has(b)&&(r.growNode(b,A),i.addPulse(b,.8,new Ae(16729943),.03),u({type:"nodeUpdated",nodeId:b,retention:A}));break}case"MemoryUpdated":{const p=e.data,b=p==null?void 0:p.id;if(!b||!m.has(b))break;i.addPulse(b,.6,new Ae(8490232),.02),p.retention!==void 0&&(r.growNode(b,p.retention),u({type:"nodeUpdated",nodeId:b,retention:p.retention}));break}case"SearchPerformed":{m.forEach((p,b)=>{i.addPulse(b,.6+Math.random()*.4,new Ae(8490232),.02)});break}case"DreamStarted":{m.forEach((p,b)=>{i.addPulse(b,1,new Ae(11032055),.005)});break}case"DreamProgress":{const p=(_=e.data)==null?void 0:_.memory_id;p&&m.has(p)&&i.addPulse(p,1.5,new Ae(12616956),.01);break}case"DreamCompleted":{i.createSpawnBurst(new Te(0,0,0),new Ae(11032055)),i.createShockwave(new Te(0,0,0),new Ae(11032055),s);break}case"RetentionDecayed":{const p=(v=e.data)==null?void 0:v.id;p&&m.has(p)&&i.addPulse(p,.8,new Ae(16729943),.03);break}case"ConsolidationCompleted":{m.forEach((p,b)=>{i.addPulse(b,.4+Math.random()*.3,new Ae(16758784),.015)});break}case"ActivationSpread":{const p=e.data;if(p.source_id&&p.target_ids){const b=f.get(p.source_id);if(b)for(const A of p.target_ids){const c=f.get(A);c&&i.createConnectionFlash(b,c,new Ae(1370310))}}break}case"MemorySuppressed":{const p=e.data;if(!p.id)break;const b=f.get(p.id);if(b){i.createImplosion(b,new Ae(11032055));const A=Math.max(1,p.suppression_count??1),c=Math.min(.4+A*.15,1);i.addPulse(p.id,c,new Ae(11032055),.04)}break}case"MemoryUnsuppressed":{const p=e.data;if(!p.id)break;const b=f.get(p.id);b&&m.has(p.id)&&(i.createRainbowBurst(b,new Ae(65416)),i.addPulse(p.id,1,new Ae(65416),.02));break}case"Rac1CascadeSwept":{const b=e.data.neighbors_affected??0;if(b===0)break;const A=Array.from(m.keys()),c=Math.min(b,A.length,12);for(let l=0;l"u")return Mi;const e=localStorage.getItem(po);if(e===null)return Mi;const t=Number(e);return Number.isFinite(t)?Math.min(da,Math.max(ca,t)):Mi}const xn=Wp();function Wp(){let e=He(!1),t=He(qi(new Date)),n=He(!1),i=He(1),r=He(!1),a=He(qi(zp()));return{get temporalEnabled(){return T(e)},set temporalEnabled(o){te(e,o,!0)},get temporalDate(){return T(t)},set temporalDate(o){te(t,o,!0)},get temporalPlaying(){return T(n)},set temporalPlaying(o){te(n,o,!0)},get temporalSpeed(){return T(i)},set temporalSpeed(o){te(i,o,!0)},get dreamMode(){return T(r)},set dreamMode(o){te(r,o,!0)},get brightness(){return T(a)},set brightness(o){const s=Math.min(da,Math.max(ca,o));if(te(a,s,!0),typeof localStorage<"u")try{localStorage.setItem(po,String(s))}catch{}},brightnessMin:ca,brightnessMax:da,brightnessDefault:Mi}}var Xp=$e('
      ');function Yp(e,t){var Z;Yn(t,!0);let n=ii(t,"events",19,()=>[]),i=ii(t,"isDreaming",3,!1),r=ii(t,"colorMode",3,"type");Fn(()=>{_==null||_.setColorMode(r())});let a,o,s,u=typeof window<"u"&&((Z=window.matchMedia)==null?void 0:Z.call(window,"(prefers-reduced-motion: reduce)").matches),f=null;function m(k){u=k.matches,o!=null&&o.controls&&(o.controls.autoRotate=!u)}let _,v,p,b,A,c,l,O,M=null,x=[];Nr(()=>{var J;o=xp(a),u&&(o.controls.autoRotate=!1),typeof window<"u"&&window.matchMedia&&(f=window.matchMedia("(prefers-reduced-motion: reduce)"),(J=f.addEventListener)==null||J.call(f,"change",m)),l=Op(o.scene).material,O=kp(o.composer),p=new wp(o.scene),_=new js,_.colorMode=r(),v=new Rp,b=new yp(o.scene),c=new Cp;const Y=_.createNodes(t.nodes);v.createEdges(t.edges,Y),A=new bp(Y),x=[...t.nodes],o.scene.add(v.group),o.scene.add(_.group),U(),window.addEventListener("resize",V),a.addEventListener("pointermove",E),a.addEventListener("click",g)}),ua(()=>{var k;cancelAnimationFrame(s),window.removeEventListener("resize",V),(k=f==null?void 0:f.removeEventListener)==null||k.call(f,"change",m),a==null||a.removeEventListener("pointermove",E),a==null||a.removeEventListener("click",g),b==null||b.dispose(),p==null||p.dispose(),_==null||_.dispose(),v==null||v.dispose(),o&&Tp(o)});let y=0;function U(){s=requestAnimationFrame(U);const k=performance.now();y===0&&(y=k);const Y=k-y;if(Y<16)return;y=k-Y%16;const J=k*.001;A.tick(t.edges),_.updatePositions(),v.updatePositions(_.positions),v.animateEdges(_.positions),p.animate(J),_.animate(J,x,o.camera,xn.brightness),c.setActive(i()),c.update(o.scene,o.bloomPass,o.controls,o.lights,J),Fp(l,J,c.current.nebulaIntensity,a.clientWidth,a.clientHeight),Vp(O,J,c.current.nebulaIntensity),F(),b.update(_.meshMap,o.camera,_.positions),o.controls.update(),o.composer.render()}function F(){if(!n()||n().length===0)return;const k=[];for(const J of n()){if(J===M)break;k.push(J)}if(k.length===0)return;if(k.length===n().length&&n().length>=200){console.warn("[vestige] Event horizon overflow: dropping visuals for",k.length,"events"),M=n()[0];return}M=n()[0];const Y={effects:b,nodeManager:_,edgeManager:v,forceSim:A,camera:o.camera,onMutation:J=>{var $;J.type==="nodeAdded"?x=[...x,J.node]:J.type==="nodeRemoved"&&(x=x.filter(ne=>ne.id!==J.nodeId)),($=t.onGraphMutation)==null||$.call(t,J)}};for(let J=k.length-1;J>=0;J--)Up(k[J],Y,x)}function V(){!a||!o||Mp(o,a)}function E(k){const Y=a.getBoundingClientRect();o.mouse.x=(k.clientX-Y.left)/Y.width*2-1,o.mouse.y=-((k.clientY-Y.top)/Y.height)*2+1,o.raycaster.setFromCamera(o.mouse,o.camera);const J=o.raycaster.intersectObjects(_.getMeshes());J.length>0?(_.hoveredNode=J[0].object.userData.nodeId,a.style.cursor="pointer"):(_.hoveredNode=null,a.style.cursor="grab")}function g(){var k;if(_.hoveredNode){_.selectedNode=_.hoveredNode,(k=t.onSelect)==null||k.call(t,_.hoveredNode);const Y=_.positions.get(_.hoveredNode);Y&&o.controls.target.lerp(Y.clone(),.5)}}var D=Xp();Ki(D,k=>a=k,()=>a),qe(e,D),qn()}var qp=$e('
      '),Kp=$e('
      ');function Zp(e,t){Yn(t,!0);let n=ii(t,"width",3,240),i=ii(t,"height",3,80);function r(c){return t.stability<=0?0:Math.exp(-c/t.stability)}let a=en(()=>{const c=[],l=Math.max(t.stability*3,30),O=4,M=n()-O*2,x=i()-O*2;for(let y=0;y<=50;y++){const U=y/50*l,F=r(U),V=O+y/50*M,E=O+(1-F)*x;c.push(`${y===0?"M":"L"}${V.toFixed(1)},${E.toFixed(1)}`)}return c.join(" ")}),o=en(()=>[{label:"Now",days:0,value:t.retention},{label:"1d",days:1,value:r(1)},{label:"7d",days:7,value:r(7)},{label:"30d",days:30,value:r(30)}]);function s(c){return c>.7?"#10b981":c>.4?"#f59e0b":"#ef4444"}var u=Kp(),f=oe(u),m=oe(f),_=fe(m),v=fe(_),p=fe(v),b=fe(p);Bn(),ae(f);var A=fe(f,2);ni(A,21,()=>T(o),Si,(c,l)=>{var O=qp(),M=oe(O),x=oe(M);ae(M);var y=fe(M,2),U=oe(y);ae(y),ae(O),Et((F,V)=>{tt(x,`${T(l).label??""}:`),di(y,`color: ${F??""}`),tt(U,`${V??""}%`)},[()=>s(T(l).value),()=>(T(l).value*100).toFixed(0)]),qe(c,O)}),ae(A),ae(u),Et(c=>{_t(f,"width",n()),_t(f,"height",i()),_t(f,"viewBox",`0 0 ${n()??""} ${i()??""}`),_t(m,"y1",4+(i()-8)*.5),_t(m,"x2",n()-4),_t(m,"y2",4+(i()-8)*.5),_t(_,"y1",4+(i()-8)*.8),_t(_,"x2",n()-4),_t(_,"y2",4+(i()-8)*.8),_t(v,"d",T(a)),_t(p,"d",`${T(a)??""} L${n()-4},${i()-4} L4,${i()-4} Z`),_t(b,"cy",4+(1-t.retention)*(i()-8)),_t(b,"fill",c)},[()=>s(t.retention)]),qe(e,u),qn()}function Ir(e,t,n){const i=n.getTime(),r=new Set,a=new Map,o=e.filter(u=>{const f=new Date(u.createdAt).getTime();if(f<=i){r.add(u.id);const m=i-f,_=1440*60*1e3,v=m<_?.3+.7*(m/_):1;return a.set(u.id,v),!0}return!1}),s=t.filter(u=>r.has(u.source)&&r.has(u.target));return{visibleNodes:o,visibleEdges:s,nodeOpacities:a}}function jp(e){if(e.length===0){const i=new Date;return{oldest:i,newest:i}}let t=1/0,n=-1/0;for(const i of e){const r=new Date(i.createdAt).getTime();rn&&(n=r)}return{oldest:new Date(t),newest:new Date(n)}}var $p=$e(`
      `),Qp=$e('');function Jp(e,t){Yn(t,!0);let n=He(!1),i=He(!1),r=He(1),a=He(100),o,s=0,u=en(()=>jp(t.nodes)),f=en(()=>{const M=T(u).oldest.getTime(),y=T(u).newest.getTime()-M||1;return new Date(M+T(a)/100*y)});function m(M){return M.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function _(){te(n,!T(n)),t.onToggle(T(n)),T(n)&&(te(a,100),t.onDateChange(T(f)))}function v(){te(i,!T(i)),T(i)?(te(a,0),s=performance.now(),p()):cancelAnimationFrame(o)}function p(){T(i)&&(o=requestAnimationFrame(M=>{const x=(M-s)/1e3;s=M;const y=T(u).oldest.getTime(),F=(T(u).newest.getTime()-y)/(1440*60*1e3)||1,V=T(r)/F*100;if(te(a,Math.min(100,T(a)+V*x),!0),t.onDateChange(T(f)),T(a)>=100){te(i,!1);return}p()}))}function b(){t.onDateChange(T(f))}ua(()=>{te(i,!1),cancelAnimationFrame(o)});var A=Or(),c=Tn(A);{var l=M=>{var x=$p(),y=oe(x),U=oe(y),F=oe(U),V=oe(F),E=oe(V,!0);ae(V);var g=fe(V,2),D=oe(g);D.value=D.__value=1;var Z=fe(D);Z.value=Z.__value=7;var k=fe(Z);k.value=k.__value=30,ae(g),ae(F);var Y=fe(F,2),J=oe(Y,!0);ae(Y);var $=fe(Y,2);ae(U);var ne=fe(U,2);ci(ne);var X=fe(ne,2),xe=oe(X),Ce=oe(xe,!0);ae(xe);var Ne=fe(xe,2),je=oe(Ne,!0);ae(Ne),ae(X),ae(y),ae(x),Et((Je,Q,de)=>{tt(E,T(i)?"⏸":"▶"),tt(J,Je),tt(Ce,Q),tt(je,de)},[()=>m(T(f)),()=>m(T(u).oldest),()=>m(T(u).newest)]),mt("click",V,v),ll(g,()=>T(r),Je=>te(r,Je)),mt("click",$,_),mt("input",ne,b),sa(ne,()=>T(a),Je=>te(a,Je)),qe(M,x)},O=M=>{var x=Qp();mt("click",x,_),qe(M,x)};pt(c,M=>{T(n)?M(l):M(O,!1)})}qe(e,A),qn()}pa(["click","input"]);var eh=$e('
      '),th=$e('
      FSRS accessibility
      ');function nh(e,t){Yn(t,!1);const n=["active","dormant","silent","unavailable"];cl();var i=th(),r=fe(oe(i),2);ni(r,1,()=>n,a=>a,(a,o)=>{var s=eh(),u=oe(s),f=fe(u,2),m=oe(f,!0);ae(f);var _=fe(f,2),v=oe(_,!0);ae(_),ae(s),Et(p=>{di(u,`background: ${nr[T(o)]??""}; box-shadow: 0 0 6px ${nr[T(o)]??""}55;`),tt(m,T(o)),tt(v,p)},[()=>{var p;return((p=$s[T(o)].match(/\(([^)]+)\)/))==null?void 0:p[1])??""}]),qe(a,s)}),ae(i),qe(e,i),qn()}const yt=new Te,ih=new Te(0,1,0),ah=new Te(0,0,0);class rh{constructor(t,n,i,r,a={},o={}){Ve(this,"camera");Ve(this,"target");Ve(this,"positions");Ve(this,"path");Ve(this,"cb");Ve(this,"opts");Ve(this,"phase","idle");Ve(this,"beatIndex",0);Ve(this,"phaseElapsed",0);Ve(this,"fromPos",new Te);Ve(this,"toPos",new Te);Ve(this,"fromTarget",new Te);Ve(this,"toTarget",new Te);this.camera=t,this.target=n,this.positions=i,this.path=r,this.cb=a,this.opts={flightSeconds:o.flightSeconds??2.4,dwellSeconds:o.dwellSeconds??3.2,standoff:o.standoff??26,reducedMotion:o.reducedMotion??!1,shots:o.shots??[],centerOnOrigin:o.centerOnOrigin??!1}}shotAt(t){return this.opts.shots[t]??null}flightSecondsAt(t){var n;return((n=this.shotAt(t))==null?void 0:n.flightSeconds)??this.opts.flightSeconds}dwellSecondsAt(t){var n;return((n=this.shotAt(t))==null?void 0:n.dwellSeconds)??this.opts.dwellSeconds}get totalBeats(){return this.path.beats.length}get isRunning(){return this.phase!=="idle"&&this.phase!=="done"}start(){var t,n;if(this.path.beats.length===0){this.phase="done",(n=(t=this.cb).onComplete)==null||n.call(t);return}this.beatIndex=0,this.beginFlightTo(0)}stop(){this.phase="done"}focalPoint(t){return this.opts.centerOnOrigin?ah:this.positions.get(t.nodeId)??null}framePosition(t,n,i){const r=this.focalPoint(t);if(!r)return i.copy(this.camera.position);const a=this.shotAt(n);yt.copy(this.camera.position).sub(r),yt.lengthSq()<1e-4&&yt.set(0,.4,1),yt.normalize();let o=.35;a&&(a.angle==="low"?o=-.45:a.angle==="high"&&(o=.7)),yt.addScaledVector(ih,o).normalize();let s=(a==null?void 0:a.standoff)??this.opts.standoff;return a&&(a.move==="push_in"?s*=.7:a.move==="pull_back"?s*=1.5:a.move==="crane"&&(s*=1.8)),this.opts.centerOnOrigin&&(s=Math.max(31,Math.min(43,s))),i.copy(r).addScaledVector(yt,s)}beginFlightTo(t){var o,s;const n=this.path.beats[t],i=this.focalPoint(n),r=this.shotAt(t);this.fromPos.copy(this.camera.position),this.fromTarget.copy(this.target),this.framePosition(n,t,this.toPos),this.toTarget.copy(i??this.target),this.phaseElapsed=0,this.opts.reducedMotion||(r==null?void 0:r.cut)==="hard_cut"||(r==null?void 0:r.cut)==="match_cut"?(this.camera.position.copy(this.toPos),this.target.copy(this.toTarget),this.phase="dwelling",(s=(o=this.cb).onBeat)==null||s.call(o,n,t,r)):this.phase="flying"}update(t){var s,u,f,m,_,v,p,b,A;if(this.phase==="idle"||this.phase==="done")return;const n=Math.max(0,Math.min(t,.05));this.phaseElapsed+=n;const i=this.flightSecondsAt(this.beatIndex),r=this.dwellSecondsAt(this.beatIndex);if(this.phase==="flying"){const c=Math.min(1,this.phaseElapsed/i),l=oh(c);this.camera.position.lerpVectors(this.fromPos,this.toPos,l),this.target.lerpVectors(this.fromTarget,this.toTarget,l),this.applyDutch(this.beatIndex,l),c>=1&&(this.phase="dwelling",this.phaseElapsed=0,(u=(s=this.cb).onBeat)==null||u.call(s,this.path.beats[this.beatIndex],this.beatIndex,this.shotAt(this.beatIndex)))}else if(this.phase==="dwelling"){if(!this.opts.reducedMotion){const c=this.focalPoint(this.path.beats[this.beatIndex]);c&&(this.target.lerp(c,.02),((f=this.shotAt(this.beatIndex))==null?void 0:f.move)==="orbit"&&this.orbitAround(c,n*.35))}if(this.phaseElapsed>=r){const c=this.beatIndex+1;if(c>=this.path.beats.length){this.phase="done",(_=(m=this.cb).onProgress)==null||_.call(m,1),(p=(v=this.cb).onComplete)==null||p.call(v);return}this.beatIndex=c,this.beginFlightTo(c)}}const a=this.path.beats.length>0?1/this.path.beats.length:0,o=this.phase==="flying"?Math.min(1,this.phaseElapsed/i)*.5:.5+Math.min(1,this.phaseElapsed/r)*.5;(A=(b=this.cb).onProgress)==null||A.call(b,Math.min(1,this.beatIndex*a+o*a))}orbitAround(t,n){yt.copy(this.camera.position).sub(t);const i=Math.cos(n),r=Math.sin(n),a=yt.x*i-yt.z*r,o=yt.x*r+yt.z*i;yt.x=a,yt.z=o,this.camera.position.copy(t).add(yt)}applyDutch(t,n){var a;const r=(((a=this.shotAt(t))==null?void 0:a.dutch)??0)*n;yt.set(0,0,-1).applyQuaternion(this.camera.quaternion),this.camera.up.set(0,1,0).applyAxisAngle(yt,r)}}function oh(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2}const fa={origin:"Origin",connection:"Connection",contradiction:"Tension",recent:"Now",bridge:"Jump",surprise:"Surprise"};function sh(e,t=90){const n=(e??"").replace(/\s+/g," ").trim();return n.length<=t?n:n.slice(0,t-1).trimEnd()+"…"}function Yi(e){const t=(e??"memory").toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function ho(e){return{source:"local-captions",beats:e.beats.map((n,i)=>{var s,u;const r=n.node,a=sh(r.label||`(${Yi(r.type)} memory)`);let o;switch(n.kind){case"origin":o=`We begin at a ${Yi(r.type).toLowerCase()} the graph is centered on — "${a}".`;break;case"contradiction":{o=`This is held in tension with the last memory through ${(s=n.viaEdge)!=null&&s.type?n.viaEdge.type.replace(/_/g," "):"a conflict"}: "${a}".`;break}case"recent":o=`And where the mind is now — a recent memory: "${a}".`;break;case"bridge":o=`Crossing to a separate cluster — "${a}".`;break;default:{const f=((u=n.viaEdge)==null?void 0:u.weight)??0;o=`${f>.66?"strongly":f>.33?"closely":"loosely"} connected from there: a ${Yi(r.type).toLowerCase()} — "${a}".`}}return r.tags&&r.tags.length>0&&i>0&&(o+=` [${r.tags.slice(0,3).join(", ")}]`),{nodeId:n.nodeId,text:o,chip:fa[n.kind]}})}}async function lh(e,t){const n=ho(e);if(!t)return n;let i;try{const r=await Promise.race([t(),new Promise(u=>{i=setTimeout(()=>u(null),6e3)})]),a=Array.isArray(r)?r.filter(u=>!!u&&typeof u.nodeId=="string"&&typeof u.text=="string"&&u.text.trim().length>0):[];if(a.length===0)return n;const o=new Map(a.map(u=>[u.nodeId,u]));return{source:"backend-llm",beats:e.beats.map((u,f)=>{const m=o.get(u.nodeId);if(m){const _=typeof m.chip=="string"&&m.chip.trim()?m.chip:fa[u.kind];return{nodeId:u.nodeId,text:m.text,chip:_}}return n.beats[f]??{nodeId:u.nodeId,text:u.node.label||"(unlabeled memory)",chip:fa[u.kind]}})}}catch{return n}finally{i&&clearTimeout(i)}}function ch(e){const t=(e.type??"").toLowerCase();return t.includes("merge")||t.includes("supersede")||t.includes("duplicate")}function dh(e,t){const n=new Map;for(const i of e)n.set(i,0);for(const i of e){const r=[],a=new Map,o=new Map,s=new Map;for(const _ of e)a.set(_,[]),o.set(_,0),s.set(_,-1);o.set(i,1),s.set(i,0);const u=[i];let f=0;for(;f0;){const _=r.pop();for(const v of a.get(_)??[]){const p=(o.get(v)??0)/(o.get(_)||1)*(1+(m.get(_)??0));m.set(v,(m.get(v)??0)+p)}_!==i&&n.set(_,(n.get(_)??0)+(m.get(_)??0))}}return n}function fh(e,t){const n=new Map;for(const u of e)n.set(u,u);const i=u=>{let f=u;for(;n.get(f)!==f;)f=n.get(f);let m=u;for(;n.get(m)!==f;){const _=n.get(m);n.set(m,f),m=_}return f},r=(u,f)=>{const m=i(u),_=i(f);m!==_&&n.set(m,_)};for(const u of t)n.has(u.source)&&n.has(u.target)&&r(u.source,u.target);const a=new Map,o=new Map;let s=0;for(const u of e){const f=i(u);a.has(f)||a.set(f,s++),o.set(u,a.get(f))}return{clusterOf:o,count:s}}function uh(e,t){var O;const n=e.map(M=>M.id),i=Qs(t),r=[...e].sort((M,x)=>ir(M)-ir(x)),a=new Map;r.forEach((M,x)=>a.set(M.id,e.length>1?x/(e.length-1):1));const o=600;let s=n;n.length>o&&(s=[...n].sort((M,x)=>{var y,U;return(((y=i[x])==null?void 0:y.length)??0)-(((U=i[M])==null?void 0:U.length)??0)}).slice(0,o));const u=dh(s,i);let f=0;for(const M of u.values())f=Math.max(f,M);const{clusterOf:m,count:_}=fh(n,t),v=Math.max(1,...e.map(M=>M.suppression_count??0)),p=new Map;let b=n[0]??"",A=-1;for(const M of e){const x=f>0?(u.get(M.id)??0)/f:0;x>A&&(A=x,b=M.id),p.set(M.id,{nodeId:M.id,degree:((O=i[M.id])==null?void 0:O.length)??0,betweenness:x,clusterId:m.get(M.id)??0,recencyRank:a.get(M.id)??0,retention:gi(M.retention??0),suppression:gi((M.suppression_count??0)/v)})}const c=new Map;for(const M of n)c.set(M,new Set((i[M]??[]).map(x=>x.otherId)));const l=t.map(M=>{const x=c.get(M.source),y=c.get(M.target);let U=0;if(x&&y){const[g,D]=x.size{const m=n>1?f/(n-1):0,_=Mh(m),v=t.nodes.get(u.nodeId),p=u.nodeId===t.peakBetweennessId,b=f===n-1,A=f===0;let c={nodeId:u.nodeId,move:"push_in",angle:"eye",cut:"fly",stormMode:"connection",tone:"curious",scoreCue:"motif",act:_,intensity:.6,tension:.3,why:"a connected memory"};return A&&(c={...c,move:"push_in",tone:"curious",tension:.25,stormMode:"anchor",why:"opening on the focal memory"}),(p||v&&v.betweenness>.6)&&(c={...c,move:"orbit",angle:"low",stormMode:"anchor",intensity:.75,tension:.45,tone:"awe",why:"low-angle orbit — the most load-bearing memory in the graph"}),u.kind==="contradiction"&&(c={...c,move:"push_in",angle:"eye",dutch:.28,cut:"hard_cut",stormMode:"contradiction",intensity:1,tension:.95,tone:"tense",scoreCue:"minor_drop",viaEdgeKey:u.viaEdge?`${u.viaEdge.source}->${u.viaEdge.target}`:void 0,why:"two memories in tension — a Dutch two-shot collision"}),u.kind==="surprise"&&(c={...c,move:"orbit",stormMode:"surprise",intensity:.85,tension:.6,tone:"awe",scoreCue:"motif",why:"a surprising, distant-but-plausible connection"}),v&&(v.retention<.35||v.suppression>.5)&&(c={...c,angle:"high",move:"pull_back",tone:"neutral",intensity:.4,why:"a fading memory — high-angle drift"}),u.kind==="recent"&&(c={...c,move:"push_in",tone:"resolved",tension:.4,why:"where the memory is now"}),b&&(c={...c,move:"crane",cut:"fly",stormMode:"anchor",tone:"awe",tension:.5,scoreCue:"major_resolve",why:"crane pull-back over the whole cluster — resolution"}),c}),r=e.beats.some(u=>u.kind==="contradiction")?"man_in_hole":"rags_to_riches";return{source:"deterministic",logline:`A short film about ${((s=e.beats[0])==null?void 0:s.node.label)??"a memory"} — ${n} shots through the graph${r==="man_in_hole"?", through a contradiction and out the other side":""}.`,arc:r,shots:i}}var bh=$e(''),Ah=$e(' '),Rh=$e(' '),wh=$e('WebGPU'),yh=$e(' '),Ch=$e(`
      Director's plan

      `),Ph=$e('
      '),Dh=$e('

      '),Lh=$e('∞ dreaming'),Uh=$e(''),Ih=$e('

      ',1),Nh=$e(''),Oh=$e(' ',1);function Fh(e,t){Yn(t,!0);let n=He(!1),i=He("idle"),r=He(""),a=He(""),o=He(0),s=He(0),u=He(0),f=He(null),m=He(!1),_=He(!1),v=He(!1),p=He(!0),b=He(""),A=He(""),c=He("I"),l=He(0),O=He(""),M=He(null),x=He(void 0),y=null,U=null,F=null,V=null,E=0,g=0,D=null,Z=0,k=He(null);const Y=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,J=(B,W,G,re)=>B+(W-B)*(1-Math.exp(-G*re)),$={x:0,y:0},ne={yaw:0,pitch:0};let X=0,xe=0,Ce=0;const Ne=2500,je=.35,Je=.22,Q=()=>{Ce=performance.now()},de=14;function Me(B){const W=new Map,G=B.beats.length;for(let re=0;re1?re/(G-1):.5)*2,Pe=Math.sqrt(Math.max(0,1-le*le)),q=re*2.399963;W.set(B.beats[re].nodeId,new Te(Math.cos(q)*Pe*de,le*de*.5,Math.sin(q)*Pe*de))}return W}function he(B){if(!(!T(_)||typeof speechSynthesis>"u"))try{speechSynthesis.cancel();const W=new SpeechSynthesisUtterance(B);W.rate=.98,W.pitch=1,speechSynthesis.speak(W)}catch{}}function Le(B){if(D&&clearInterval(D),te(r,""),Y){te(r,B,!0);return}let W=0;D=setInterval(()=>{te(r,B.slice(0,++W),!0),W>=B.length&&D&&(clearInterval(D),D=null)},18)}function Ie(B){return B==="surprise"?"connection":B}function ke(B,W,G){var ie,le;te(s,W+1);const re=((ie=V==null?void 0:V.beats[W])==null?void 0:ie.text)??B.node.label??"";if(te(a,((le=V==null?void 0:V.beats[W])==null?void 0:le.chip)??"",!0),Le(re),he(re),G&&(te(A,G.why,!0),te(c,G.act,!0),te(l,G.tension,!0)),y&&T(m)){const Pe=nt==null?void 0:nt.get(B.nodeId);if(Pe){const ce=(G==null?void 0:G.stormMode)??"connection";y.transitionTo(Ie(ce),Pe,(G==null?void 0:G.act)??"I",W)}const q=(G==null?void 0:G.tension)??0;y.setFlythrough(Y?0:q*.8)}}let nt=null;async function Ke(){var le,Pe;if(cancelAnimationFrame(E),gt(),D&&clearInterval(D),U==null||U.stop(),y==null||y.dispose(),y=null,U=null,V=null,Z=0,te(A,""),te(O,""),te(M,null),te(c,"I"),te(l,0),te(n,!0),te(i,"planning"),te(b,"Planning a path through your memory…"),te(r,""),te(a,""),te(o,0),te(s,0),F=el(t.nodes,t.edges,t.centerId,7),te(u,F.beats.length,!0),T(u)===0){te(b,"Not enough memory to compose a tour yet."),te(i,"done");return}nt=Me(F);const B=uh(t.nodes,t.edges);te(M,Th(F,B),!0),te(O,T(M).logline,!0);const W=xh(T(M),F);if(te(c,((le=W[0])==null?void 0:le.act)??"I",!0),te(l,((Pe=W[0])==null?void 0:Pe.tension)??0,!0),V=await lh(F,T(v)?et():t.fetchBackendNarration),te(f,V.source,!0),te(m,!1),T(x))try{const{CinemaSandbox:q,isWebGPUSupported:ce}=await dl(async()=>{const{CinemaSandbox:_e,isWebGPUSupported:Re}=await import("../chunks/kcrnba3G.js");return{CinemaSandbox:_e,isWebGPUSupported:Re}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]),import.meta.url);ce()&&(y=new q(T(x)),await y.boot(),te(m,!0))}catch(q){console.warn("[cinema] WebGPU sandbox unavailable, camera-only mode:",q),y=null,te(m,!1)}const G=T(x)&&T(x).clientHeight>0?T(x).clientWidth/T(x).clientHeight:16/9,re=(y==null?void 0:y.cameraRef)??new Hn(60,G,.1,2e3),ie=(y==null?void 0:y.target)??new Te;U=new rh(re,ie,nt,F,{onBeat:ke,onProgress:q=>te(o,q,!0),onComplete:()=>{te(i,"done"),te(b,Y||!T(m)?"End of tour.":"∞ Dreaming — endless generative figures",!0),R()}},{reducedMotion:Y,shots:W,centerOnOrigin:T(m)}),te(i,"playing"),te(b,T(m)?"Rendering 150k-particle semantic storm on WebGPU…":"Cinematic flythrough (captions mode).",!0),g=performance.now(),U.start(),dt()}async function dt(){const B=performance.now(),W=Math.max(0,Math.min(.05,(B-g)/1e3));g=B;try{U==null||U.update(W)}catch(re){console.warn("[cinema] director error:",re)}if(!Y&&y&&T(m)){const re=y.cameraRef,ie=performance.now()-Ce>Ne,le=ie?0:$.x*je,Pe=ie?0:$.y*Je,q=ie?1.5:9;ne.yaw=J(ne.yaw,le,q,W),ne.pitch=J(ne.pitch,Pe,q,W),ie&&(X=J(X,0,1.2,W)),xe=J(xe,X,8,W);const ce=re.position.clone(),_e=new aa().setFromVector3(ce);_e.theta+=ne.yaw,_e.phi=no.clamp(_e.phi+ne.pitch,.2,Math.PI-.2),_e.radius*=1-xe*.35,ce.setFromSpherical(_e),re.position.copy(ce)}const G=y;if(G&&T(m))try{await G.render(W),Z=0}catch(re){++Z>=3&&y===G&&(console.warn("[cinema] WebGPU render failing, dropping to camera-only:",re),te(m,!1),G.dispose(),y=null)}E=requestAnimationFrame(dt)}function R(){Y||!y||!T(m)||(gt(),Y||y==null||y.setFlythrough(.6),y==null||y.dreamBeat(),te(r,""),te(a,"Dreaming"),te(k,setInterval(()=>{if(!y||!T(m)){gt();return}y.dreamBeat()},5500),!0))}function gt(){T(k)&&(clearInterval(T(k)),te(k,null))}function ze(){var B;cancelAnimationFrame(E),gt(),D&&clearInterval(D),typeof speechSynthesis<"u"&&speechSynthesis.cancel(),y&&((B=y.setFlythrough)==null||B.call(y,0)),ne.yaw=ne.pitch=0,X=xe=0,U==null||U.stop(),y==null||y.dispose(),y=null,U=null,te(n,!1),te(i,"idle"),te(m,!1)}let We=He(void 0);function we(B){B.key==="Escape"?(B.preventDefault(),ze()):(B.key==="h"||B.key==="H")&&(B.preventDefault(),te(p,!T(p)))}Fn(()=>{T(n)&&T(We)&&T(We).focus()}),Fn(()=>{if(!(typeof document>"u"))return document.body.classList.toggle("cinema-open",T(n)),()=>document.body.classList.remove("cinema-open")}),Fn(()=>{if(!T(n)||Y||!T(x))return;const B=T(x),W=(q,ce,_e)=>Math.min(_e,Math.max(ce,q));B.style.touchAction="none";const G=q=>{$.x=q.clientX/window.innerWidth*2-1,$.y=-(q.clientY/window.innerHeight)*2+1,Q()},re=q=>{q.preventDefault(),X=W(X+q.deltaY*8e-4,-1,1),Q()};let ie=null;const le=q=>{if(q.touches.length===2){const ce=q.touches[0].clientX-q.touches[1].clientX,_e=q.touches[0].clientY-q.touches[1].clientY,Re=Math.hypot(ce,_e);ie!==null&&(X=W(X+(Re-ie)*.002,-1,1)),ie=Re,Q()}},Pe=()=>{ie=null};return B.addEventListener("pointermove",G,{passive:!0}),B.addEventListener("wheel",re,{passive:!1}),B.addEventListener("touchmove",le,{passive:!0}),B.addEventListener("touchend",Pe),()=>{B.removeEventListener("pointermove",G),B.removeEventListener("wheel",re),B.removeEventListener("touchmove",le),B.removeEventListener("touchend",Pe)}});function et(){return async()=>{var B,W;if(!F)return null;try{te(b,"Loading on-device model (first run downloads weights)…");const re=await import("@huggingface/transformers").catch(()=>null);if(!(re!=null&&re.pipeline))return null;const ie=await re.pipeline("text-generation","onnx-community/Qwen2.5-0.5B-Instruct",{device:"webgpu",dtype:"q4"}),le=ho(F);te(b,"Narrating with the on-device model…");const Pe=[];for(const q of le.beats){const ce=`You are narrating a cinematic tour of an AI's memory graph. In one vivid sentence, narrate this beat: "${q.text}"`,_e=await ie(ce,{max_new_tokens:48,temperature:.7,do_sample:!0}),Re=(W=(B=_e==null?void 0:_e[0])==null?void 0:B.generated_text)==null?void 0:W.replace(ce,"").trim();Pe.push({nodeId:q.nodeId,chip:q.chip,text:Re&&Re.length>4?Re:q.text})}return Pe}catch(G){return console.warn("[cinema] on-device narration failed, using local captions:",G),null}}}ua(ze);var be=Oh(),S=Tn(be),d=fe(S,2);{var H=B=>{var W=Nh(),G=oe(W);Ki(G,q=>te(x,q),()=>T(x));var re=fe(G,2);{var ie=q=>{var ce=bh();mt("click",ce,()=>te(p,!0)),qe(q,ce)};pt(re,q=>{T(p)||q(ie)})}var le=fe(re,2);{var Pe=q=>{var ce=Ih(),_e=Tn(ce),Re=oe(_e),ge=oe(Re);let Xe;var Ge=fe(ge,2),rt=oe(Ge,!0);ae(Ge);var I=fe(Ge,2);{var ue=w=>{var L=Ah(),P=oe(L,!0);ae(L),Et(()=>tt(P,T(M).source==="deterministic"?"Auteur (local)":"Auteur (AI)")),qe(w,L)};pt(I,w=>{T(M)&&w(ue)})}var K=fe(I,2);{var C=w=>{var L=Rh(),P=oe(L,!0);ae(L),Et(()=>tt(P,T(f)==="backend-llm"?"AI narration":"Live captions")),qe(w,L)};pt(K,w=>{T(f)&&w(C)})}var z=fe(K,2);{var j=w=>{var L=wh();qe(w,L)};pt(z,w=>{T(m)&&w(j)})}var se=fe(z,2);{var ve=w=>{var L=yh(),P=oe(L);ae(L),Et(()=>tt(P,`Act ${T(c)??""}`)),qe(w,L)};pt(se,w=>{T(i)==="playing"&&w(ve)})}ae(Re);var Oe=fe(Re,2),ye=oe(Oe),ot=oe(ye);ci(ot),Bn(),ae(ye);var ft=fe(ye,2),Pt=oe(ft);ci(Pt),Bn(),ae(ft);var Ht=fe(ft,2);Ki(Ht,w=>te(We,w),()=>T(We)),ae(Oe),ae(_e);var vt=fe(_e,2);{var Wt=w=>{var L=Ch(),P=fe(oe(L),2),ee=oe(P,!0);ae(P),ae(L),Et(()=>tt(ee,T(O))),qe(w,L)};pt(vt,w=>{T(i)==="planning"&&T(O)&&w(Wt)})}var dn=fe(vt,2),$t=oe(dn);{var Yt=w=>{var L=Ph(),P=oe(L,!0);ae(L),Et(()=>tt(P,T(a))),qe(w,L)};pt($t,w=>{T(a)&&w(Yt)})}var nn=fe($t,2),qt=oe(nn,!0);ae(nn);var fn=fe(nn,2);{var un=w=>{var L=Dh(),P=oe(L);ae(L),Et(()=>tt(P,`▸ ${T(A)??""}`)),qe(w,L)};pt(fn,w=>{T(A)&&T(i)==="playing"&&w(un)})}var pn=fe(fn,2),Rn=oe(pn);ae(pn);var wn=fe(pn,2),an=oe(wn);{var yn=w=>{var L=Lh();qe(w,L)},Zn=w=>{var L=go();Et(()=>tt(L,`Beat ${T(s)??""} / ${T(u)??""}`)),qe(w,L)};pt(an,w=>{T(i)==="done"&&T(k)?w(yn):T(u)>0&&w(Zn,1)})}var h=fe(an,2);{var N=w=>{var L=Uh();mt("click",L,Ke),qe(w,L)};pt(h,w=>{T(i)==="done"&&w(N)})}ae(wn),ae(dn),Et(()=>{Xe=on(ge,1,"cinema-dot svelte-1uwqs3k",null,Xe,{active:T(i)==="playing"}),tt(rt,T(b)),tt(qt,T(r)),di(Rn,`width:${T(o)*100}%; --tension:${T(l)??""}`)}),rr(ot,()=>T(_),w=>te(_,w)),rr(Pt,()=>T(v),w=>te(v,w)),mt("click",Ht,ze),qe(q,ce)};pt(le,q=>{T(p)&&q(Pe)})}ae(W),mt("keydown",W,we),qe(B,W)};pt(d,B=>{T(n)&&B(H)})}mt("click",S,Ke),qe(e,be),qn()}pa(["click","keydown"]);var Bh=$e('

      Weaving your memory graph…

      '),Hh=$e(`

      MCP Backend Offline

      The Vestige MCP server isn't reachable on :3927. - The dashboard is running but has nothing to query.

      Start the backend:
      nohup bash -c 'tail -f /dev/null | VESTIGE_DASHBOARD_ENABLED=true ~/.local/bin/vestige-mcp' > /tmp/vestige.log 2>&1 & -disown
      `),Gh=$e('

      Your Mind Awaits

      No memories yet — the moment Vestige starts remembering, your constellation will bloom here.

      '),kh=$e('

      Your Mind Awaits

      '),Vh=$e('
      '),zh=$e(`
      `),Wh=$e('
      ',1),Xh=$e(' · · ',1),Yh=$e('
      '),qh=$e('
      '),Kh=$e('
      AhaGraph
      '),Zh=$e(' '),jh=$e('
      '),$h=$e("
      "),Qh=$e(`

      Memory Detail

      Retention Forecast
      Explore Connections
      `),Jh=$e('
      '),em=$e(`
      `,1);function Tm(e,t){Yn(t,!0);const n=()=>ol(ul,"$eventFeed",i),[i,r]=rl();let a=He(null),o=null;function s(){var j;const z=(((j=T(a))==null?void 0:j.nodes)??[]).slice(0,600).map(se=>{const ve=u(se.retention);return{id:se.id,score:ve,hue:ml(ve),energy:.35+.65*ve,selected:!!se.isCenter,scar:(se.suppression_count??0)>0,metric2:ve,kind:"graph-node",payload:se}});return pl(z,{maxRadius:.98,minCellR:.008,maxCellR:.036})}function u(C){return Math.min(1,Math.max(0,Number.isFinite(C)?C:0))}function f(C){const z=new hl(C);o=z,z.setCells(s()),C.addPass(z)}Fn(()=>{T(Z)!=="field"&&(o=null)}),Fn(()=>{var C;(C=T(a))==null||C.nodes.length,T(Z)==="field"&&(o==null||o.setCells(s()))});let m=He(null),_=He(!0),v=He(""),p=He(!1),b=He(""),A=He(150);const c=[{value:"50",label:"50 nodes"},{value:"100",label:"100 nodes"},{value:"150",label:"150 nodes"},{value:"200",label:"200 nodes"}];let l=He("150");function O(C){te(A,parseInt(C,10),!0),X()}let M=He(!1),x=He(qi(new Date)),y=He("type");const U=Object.entries(il);let F=He(0),V=He(0),E=He(!1),g=He("recall-path");const D="vestige-graph-renderer";let Z=He("classic");function k(C){te(Z,C,!0);try{localStorage.setItem(D,C)}catch{}}let Y=en(()=>T(a)?T(M)?Ir(T(a).nodes,T(a).edges,T(x)).visibleNodes:T(a).nodes:[]),J=en(()=>T(a)?T(M)?Ir(T(a).nodes,T(a).edges,T(x)).visibleEdges:T(a).edges:[]);function $(C){if(T(a))switch(C.type){case"nodeAdded":T(a).nodes=[...T(a).nodes,C.node],T(a).nodeCount=T(a).nodes.length,te(F,T(a).nodeCount,!0);break;case"nodeRemoved":T(a).nodes=T(a).nodes.filter(z=>z.id!==C.nodeId),T(a).nodeCount=T(a).nodes.length,te(F,T(a).nodeCount,!0);break;case"edgeAdded":T(a).edges=[...T(a).edges,C.edge],T(a).edgeCount=T(a).edges.length,te(V,T(a).edgeCount,!0);break;case"edgesRemoved":T(a).edges=T(a).edges.filter(z=>z.source!==C.nodeId&&z.target!==C.nodeId),T(a).edgeCount=T(a).edges.length,te(V,T(a).edgeCount,!0);break;case"nodeUpdated":{const z=T(a).nodes.find(j=>j.id===C.nodeId);z&&(z.retention=C.retention);break}}}Nr(()=>{const C=typeof navigator<"u"&&"gpu"in navigator;let z=null;try{z=localStorage.getItem(D)}catch{}te(Z,C?z==="classic"?"classic":"field":"classic",!0);const j=new URLSearchParams(window.location.search),se=j.get("colorMode");ne(se)&&te(y,se,!0);const ve=j.get("center");X(void 0,ve||void 0)});function ne(C){return C==="type"||C==="state"||C==="ahagraph"}async function X(C,z){var j;te(_,!0),te(v,"");try{const se=!C&&!z;if(te(a,await Pn.graph({max_nodes:T(A),depth:3,query:C||void 0,center_id:z||void 0,sort:se?"recent":void 0}),!0),se&&T(a)&&T(a).nodeCount<=1&&T(a).edgeCount===0){const ve=await Pn.graph({max_nodes:T(A),depth:3,sort:"connected"});ve&&ve.nodeCount>T(a).nodeCount&&te(a,ve,!0)}T(a)&&(te(F,T(a).nodeCount,!0),te(V,T(a).edgeCount,!0))}catch(se){const ve=se instanceof Error?se.message:String(se),Oe=ve.replace(/\/[\w./-]+\.(sqlite|rs|db|toml|lock)\b/g,"[path]").slice(0,200),ye=se instanceof TypeError||/failed to fetch|NetworkError|load failed/i.test(ve)||/^API 500:?\s*(Internal Server Error)?\s*$/i.test(ve.trim()),ot=(((j=T(a))==null?void 0:j.nodeCount)??0)===0&&/not found|404|empty|no memor/i.test(ve);ye?te(v,"OFFLINE"):ot?te(v,"EMPTY"):te(v,`Failed to load graph: ${Oe}`)}finally{te(_,!1)}}async function xe(){te(p,!0);try{await Pn.dream(),await X()}catch{}finally{te(p,!1)}}async function Ce(C){try{te(m,await Pn.memories.get(C),!0)}catch{te(m,null)}}function Ne(){T(b).trim()&&X(T(b))}var je=em(),Je=Tn(je),Q=oe(Je);{var de=C=>{var z=Bh();qe(C,z)},Me=C=>{var z=Hh(),j=oe(z),se=oe(j),ve=oe(se);mn(ve,{name:"activation",size:52,strokeWidth:1.2}),ae(se);var Oe=fe(se,8),ye=oe(Oe),ot=fe(ye,2);ae(Oe),ae(j),ae(z),Et(()=>_t(ot,"href",`${or??""}/settings`)),mt("click",ye,()=>X()),qe(C,z)},he=C=>{var z=Gh(),j=oe(z),se=oe(j),ve=oe(se);mn(ve,{name:"graph",size:52,strokeWidth:1.2}),ae(se),Bn(4),ae(j),ae(z),qe(C,z)},Le=C=>{var z=kh(),j=oe(z),se=oe(j),ve=oe(se);mn(ve,{name:"graph",size:52,strokeWidth:1.2}),ae(se);var Oe=fe(se,4),ye=oe(Oe,!0);ae(Oe),ae(j),ae(z),Et(()=>tt(ye,T(v))),qe(C,z)},Ie=C=>{var z=Or(),j=Tn(z);{var se=Oe=>{var ye=Vh(),ot=oe(ye);ar(ot,{embedded:!0,live:!0,chrome:"none",demo:"recall-path",showSwitcher:!1,onpick:Ce,onready:f}),ae(ye),qe(Oe,ye)},ve=Oe=>{Yp(Oe,{get nodes(){return T(Y)},get edges(){return T(J)},get centerId(){return T(a).center_id},get events(){return n()},get isDreaming(){return T(p)},get colorMode(){return T(y)},onSelect:Ce,onGraphMutation:$})};pt(j,Oe=>{T(Z)==="field"?Oe(se):Oe(ve,!1)})}qe(C,z)};pt(Q,C=>{T(_)?C(de):T(v)==="OFFLINE"?C(Me,1):T(v)==="EMPTY"?C(he,2):T(v)?C(Le,3):T(a)&&C(Ie,4)})}var ke=fe(Q,2),nt=oe(ke);{var Ke=C=>{var z=zh(),j=oe(z);ci(j);var se=fe(j,2);ae(z),mt("keydown",j,ve=>ve.key==="Enter"&&Ne()),sa(j,()=>T(b),ve=>te(b,ve)),mt("click",se,Ne),qe(C,z)};pt(nt,C=>{T(Z)==="classic"&&C(Ke)})}var dt=fe(nt,2),R=oe(dt),gt=oe(R),ze=fe(gt,2);ae(R);var We=fe(R,2);{var we=C=>{var z=Wh(),j=Tn(z),se=oe(j),ve=fe(se,2),Oe=fe(ve,2);ae(j);var ye=fe(j,2);fl(ye,{get options(){return c},icon:"graph",class:"shrink-0",onChange:O,get value(){return T(l)},set value(vt){te(l,vt,!0)}});var ot=fe(ye,2),ft=fe(oe(ot),2);ci(ft);var Pt=fe(ft,2),Ht=oe(Pt);ae(Pt),ae(ot),Et((vt,Wt)=>{_t(se,"aria-checked",T(y)==="type"),on(se,1,`min-h-9 px-3 py-1.5 rounded-lg transition ${T(y)==="type"?"bg-synapse/25 text-synapse-glow":"text-dim hover:text-text"}`),_t(ve,"aria-checked",T(y)==="state"),on(ve,1,`min-h-9 px-3 py-1.5 rounded-lg transition ${T(y)==="state"?"bg-synapse/25 text-synapse-glow":"text-dim hover:text-text"}`),_t(Oe,"aria-checked",T(y)==="ahagraph"),on(Oe,1,`min-h-9 px-3 py-1.5 rounded-lg transition ${T(y)==="ahagraph"?"bg-synapse/25 text-synapse-glow":"text-dim hover:text-text"}`),_t(ot,"title",`Adjust graph brightness (${vt??""}x). Combines with auto distance compensation.`),_t(ft,"min",xn.brightnessMin),_t(ft,"max",xn.brightnessMax),tt(Ht,`${Wt??""}x`)},[()=>xn.brightness.toFixed(1),()=>xn.brightness.toFixed(1)]),mt("click",se,()=>te(y,"type")),mt("click",ve,()=>te(y,"state")),mt("click",Oe,()=>te(y,"ahagraph")),sa(ft,()=>xn.brightness,vt=>xn.brightness=vt),qe(C,z)};pt(We,C=>{T(Z)==="classic"&&C(we)})}var et=fe(We,2),be=oe(et),S=oe(be);mn(S,{name:"dreams",size:16}),ae(be);var d=fe(be);ae(et);var H=fe(et,2),B=oe(H);mn(B,{name:"sparkle",size:16}),Bn(),ae(H);var W=fe(H,2);{var G=C=>{{let z=en(()=>{var j;return((j=T(a))==null?void 0:j.center_id)??""});Fh(C,{get nodes(){return T(Y)},get edges(){return T(J)},get centerId(){return T(z)}})}};pt(W,C=>{T(Y).length>0&&C(G)})}var re=fe(W,2),ie=oe(re);mn(ie,{name:"pulse",size:16}),ae(re),ae(dt),ae(ke);var le=fe(ke,2),Pe=oe(le);{var q=C=>{var z=Xh(),j=Tn(z),se=oe(j);ae(j);var ve=fe(j,4),Oe=oe(ve);ae(ve);var ye=fe(ve,4),ot=oe(ye);ae(ye),Et(()=>{tt(se,`${T(F)??""} nodes`),tt(Oe,`${T(V)??""} edges`),tt(ot,`depth ${T(a).depth??""}`)}),qe(C,z)};pt(Pe,C=>{T(a)&&C(q)})}ae(le);var ce=fe(le,2);{var _e=C=>{var z=Yh(),j=oe(z);nh(j,{}),ae(z),qe(C,z)};pt(ce,C=>{T(Z)==="classic"&&T(y)==="state"&&C(_e)})}var Re=fe(ce,2);{var ge=C=>{var z=Kh(),j=fe(oe(z),2);ni(j,21,()=>U,Si,(se,ve)=>{var Oe=en(()=>vo(T(ve),2));let ye=()=>T(Oe)[0],ot=()=>T(Oe)[1];var ft=qh(),Pt=oe(ft),Ht=fe(Pt,2),vt=oe(Ht,!0);ae(Ht),ae(ft),Et(()=>{di(Pt,`background: ${ot()??""}`),tt(vt,tl[ye()])}),qe(se,ft)}),ae(j),ae(z),qe(C,z)};pt(Re,C=>{T(Z)==="classic"&&T(y)==="ahagraph"&&C(ge)})}var Xe=fe(Re,2);{var Ge=C=>{Jp(C,{get nodes(){return T(a).nodes},onDateChange:z=>{te(x,z,!0)},onToggle:z=>{te(M,z,!0)}})};pt(Xe,C=>{T(a)&&T(Z)==="classic"&&C(Ge)})}var rt=fe(Xe,2);{var I=C=>{var z=Qh(),j=oe(z),se=fe(oe(j),2);ae(j);var ve=fe(j,2),Oe=oe(ve),ye=oe(Oe),ot=oe(ye,!0);ae(ye);var ft=fe(ye,2);ni(ft,17,()=>T(m).tags,Si,(w,L)=>{var P=Zh(),ee=oe(P,!0);ae(P),Et(()=>tt(ee,T(L))),qe(w,P)}),ae(Oe);var Pt=fe(Oe,2),Ht=oe(Pt,!0);ae(Pt);var vt=fe(Pt,2);ni(vt,21,()=>[{label:"Retention",value:T(m).retentionStrength},{label:"Storage",value:T(m).storageStrength},{label:"Retrieval",value:T(m).retrievalStrength}],Si,(w,L)=>{var P=jh(),ee=oe(P),pe=oe(ee),Se=oe(pe,!0);ae(pe);var Ee=fe(pe,2),Fe=oe(Ee);ae(Ee),ae(ee);var Be=fe(ee,2),De=oe(Be);ae(Be),ae(P),Et(Qe=>{tt(Se,T(L).label),tt(Fe,`${Qe??""}%`),di(De,`width: ${T(L).value*100}%; background: ${T(L).value>.7?"#10b981":T(L).value>.4?"#f59e0b":"#ef4444"}`)},[()=>(T(L).value*100).toFixed(1)]),qe(w,P)}),ae(vt);var Wt=fe(vt,2),dn=fe(oe(Wt),2);{let w=en(()=>T(m).storageStrength*30);Zp(dn,{get retention(){return T(m).retentionStrength},get stability(){return T(w)}})}ae(Wt);var $t=fe(Wt,2),Yt=oe($t),nn=oe(Yt);ae(Yt);var qt=fe(Yt,2),fn=oe(qt);ae(qt);var un=fe(qt,2);{var pn=w=>{var L=$h(),P=oe(L);ae(L),Et(ee=>tt(P,`Accessed: ${ee??""}`),[()=>new Date(T(m).lastAccessedAt).toLocaleString()]),qe(w,L)};pt(un,w=>{T(m).lastAccessedAt&&w(pn)})}var Rn=fe(un,2),wn=oe(Rn);ae(Rn),ae($t);var an=fe($t,2),yn=oe(an),Zn=fe(yn,2);ae(an);var h=fe(an,2),N=oe(h);mn(N,{name:"explore",size:14}),Bn(),ae(h),ae(ve),ae(z),Et((w,L)=>{tt(ot,T(m).nodeType),tt(Ht,T(m).content),tt(nn,`Created: ${w??""}`),tt(fn,`Updated: ${L??""}`),tt(wn,`Reviews: ${T(m).reviewCount??0??""}`),_t(h,"href",`${or??""}/explore`)},[()=>new Date(T(m).createdAt).toLocaleString(),()=>new Date(T(m).updatedAt).toLocaleString()]),mt("click",se,()=>te(m,null)),mt("click",yn,()=>{T(m)&&Pn.memories.promote(T(m).id)}),mt("click",Zn,()=>{T(m)&&Pn.memories.demote(T(m).id)}),qe(C,z)};pt(rt,C=>{T(m)&&C(I)})}ae(Je);var ue=fe(Je,2);{var K=C=>{var z=Jh(),j=oe(z);nl(j,()=>T(g),se=>{ar(se,{get demo(){return T(g)},ondemochange:ve=>te(g,ve,!0),onexit:()=>te(E,!1)})}),ae(z),qe(C,z)};pt(ue,C=>{T(E)&&C(K)})}Et(()=>{_t(gt,"aria-checked",T(Z)==="field"),on(gt,1,`min-h-9 px-3 py-1.5 rounded-lg transition ${T(Z)==="field"?"bg-[#5dcaa5]/25 text-[#7fe6c0]":"text-dim hover:text-text"}`),_t(ze,"aria-checked",T(Z)==="classic"),on(ze,1,`min-h-9 px-3 py-1.5 rounded-lg transition ${T(Z)==="classic"?"bg-synapse/25 text-synapse-glow":"text-dim hover:text-text"}`),et.disabled=T(p),on(et,1,`shrink-0 inline-flex items-center gap-2 min-h-10 px-4 py-2 rounded-xl bg-dream/20 border border-dream/40 text-dream-glow text-sm - hover:bg-dream/30 transition-all backdrop-blur-sm disabled:opacity-50 - ${T(p)?"glow-dream animate-pulse-glow":""}`),on(be,1,al(T(p)?"breathe":"")),tt(d,` ${T(p)?"Dreaming…":"Dream"}`)}),mt("click",gt,()=>k("field")),mt("click",ze,()=>k("classic")),mt("click",et,xe),mt("click",H,()=>te(E,!0)),mt("click",re,()=>X()),qe(e,je),qn(),r()}pa(["click","keydown"]);export{Tm as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/12.CRVOD7oJ.js.br b/apps/dashboard/build/_app/immutable/nodes/12.CRVOD7oJ.js.br deleted file mode 100644 index c76ffb6..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/12.CRVOD7oJ.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/12.CRVOD7oJ.js.gz b/apps/dashboard/build/_app/immutable/nodes/12.CRVOD7oJ.js.gz deleted file mode 100644 index 0c61347..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/12.CRVOD7oJ.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/13.UdclNjnS.js b/apps/dashboard/build/_app/immutable/nodes/13.UdclNjnS.js deleted file mode 100644 index d48978d..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/13.UdclNjnS.js +++ /dev/null @@ -1 +0,0 @@ -import"../chunks/Bzak7iHL.js";import{d as Q,o as Z,a as tt,b as $,e as et}from"../chunks/DAau0uzT.js";import{p as nt,d as E,e as ot,a as rt,b as it,h as at,g as i,f as st,u as ct,c as lt,s as c,$ as mt,r as ut}from"../chunks/CGq8RnJq.js";import{h as dt}from"../chunks/De_e6MzK.js";import{b as pt}from"../chunks/Ccqjq5DS.js";import{r as R,O as ht}from"../chunks/BMB5u1EX.js";import{a as N}from"../chunks/D35IQVqe.js";import{T as ft}from"../chunks/D7ozXiSB.js";import{L as yt,F as D,l as gt}from"../chunks/DETSv_kY.js";var Et=st('
      ');function Ot(b,k){nt(k,!0);const O=[...R("#22C7DE"),1],_=[...R("#FF3B30"),.92],A=[...R("#29F2A9"),.62],P=[...R("#FFB020"),.86],B=36,L=30,U=-1e5,W=.62;let m=E(null),u=null,r=null,l=null,M=null,d=E(ot([])),C=E(0),v=E(!0),f=E(null),I=null;Z(()=>{V()});let x=null;tt(()=>{x==null||x(),r==null||r.dispose(),l==null||l.dispose(),r=null,l=null,u=null});function Y(t){if(typeof window>"u")return()=>{};const e=window.matchMedia("(prefers-reduced-motion: reduce)");t.setPaused(e.matches);const n=o=>t.setPaused(o.matches);return e.addEventListener("change",n),()=>e.removeEventListener("change",n)}async function z(t){u=t,x=Y(t);const e=new yt(t);l=e,e.setCells(S()),t.addPass(e);const n=new ft(t);r=n,await n.init(),n.setText(g()),t.addPass(n),t.demoClock.reset()}async function V(){c(v,!0),c(f,null),r==null||r.setText(g());try{const t=await N.memories.list({limit:String(B)});c(C,t.total,!0);const e=await Promise.allSettled(t.memories.map(async n=>({memory:n,score:await N.importance(n.content)})));c(d,e.filter(n=>n.status==="fulfilled").map(n=>n.value).sort((n,o)=>o.score.composite-n.score.composite),!0),t.memories.length>0&&i(d).length===0&&c(f,"API IMPORTANCE RETURNED NO SCORES")}catch(t){c(d,[],!0),c(C,0),c(f,t instanceof Error?t.message:"UNKNOWN IMPORTANCE FETCH ERROR",!0)}finally{c(v,!1),r==null||r.setText(g()),l==null||l.setCells(S()),u==null||u.demoClock.reset()}}function S(){const t=i(d).map(e=>({id:e.memory.id,score:y(e.score.composite),hue:e.score.recommendation==="save"?D.oxygen:D.caution,energy:Math.max(.35,y(e.score.composite)),metric2:y(e.memory.retentionStrength),kind:"importance",payload:e}));return gt(t,{maxRadius:.9,minCellR:.04,maxCellR:.1})}function w(t){return typeof t!="string"?"":t.replace(/[\u2014\u2013]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u2026/g,"...").replace(/[^\x20-\x7E]/g,"?")}function G(t){const{memory:e,score:n}=t,o=w(e.content??"").replace(/\s+/g," ").trim().slice(0,44),s=H(n);return w(`${o} | ${e.id.slice(0,8)} | ${Math.round(n.composite*100)}% | ${Math.round(e.retentionStrength*100)}% | ${n.recommendation} | ${s}`)}function H(t){return Object.entries(t.channels).sort((e,n)=>n[1]-e[1])[0][0]}function y(t){return Math.min(1,Math.max(0,Number.isFinite(t)?t:.5))}function T(t,e=A){return{id:"importance:status",kind:"importance-status",text:w(t),x:-.58,y:.02,size:.044,color:e,depth:.78,weight:.62,revealSpan:32,maxWidthEm:50}}function g(){if(i(v))return[T("LOADING IMPORTANCE FIELD...",O)];if(i(f))return[T(`ERROR - ${i(f)}`.slice(0,72),_)];if(i(d).length===0)return[T("EMPTY IMPORTANCE FIELD",A)];const t=i(d).slice(0,L),e=.72,n=1.5/Math.max(1,L-1);return t.map((o,s)=>{const a=Math.max(W,y(o.score.composite)),p=y(o.memory.retentionStrength);return{id:`importance:${o.memory.id}`,kind:"importance",memoryId:o.memory.id,text:G(o),x:-.9,y:e-s*n,size:.025,color:o.score.recommendation==="save"?O:P,depth:a,weight:p,startFrame:U+s*2,revealSpan:1,maxWidthEm:54,hitPadX:.03,hitPadY:.018}})}function F(t){if(!i(m))return null;const e=i(m).getBoundingClientRect();return e.width<=0||e.height<=0?null:{x:(t.clientX-e.left)/e.width*2-1,y:-((t.clientY-e.top)/e.height*2-1)}}function K(t){if(!i(m)||!u)return;const e=i(m).getBoundingClientRect(),n=Math.max(1e-4,e.width/Math.max(1,e.height)),o={x:t.x*Math.max(n,1),y:t.y/Math.min(n,1)},s=M??o,a={x:s.x+(o.x-s.x)*.35,y:s.y+(o.y-s.y)*.35};M=a,u.setCursorPreNdc(a.x,a.y,a.x-s.x,a.y-s.y)}function X(t){const e=F(t);if(!e)return;K(e);const n=(r==null?void 0:r.pickAt(e.x,e.y))??null,o=(n==null?void 0:n.kind)==="importance"?n.id:null;o!==I&&(I=o,r==null||r.setRunDepth(o,1)),i(m)&&(i(m).style.cursor=o?"crosshair":"default")}function j(){M=null,I=null,u==null||u.setCursorPreNdc(999,999,0,0),r==null||r.setRunDepth(null),i(m)&&(i(m).style.cursor="default")}async function q(t){var s;const e=F(t);if(!e||!r)return;let n;const o=r.pickAt(e.x,e.y);if((o==null?void 0:o.kind)==="importance")n=o.payload.memoryId;else{const a=l==null?void 0:l.pickAt(e.x,e.y);(a==null?void 0:a.kind)==="importance"&&(n=(s=a.payload.memory)==null?void 0:s.id)}if(n)try{const a=await N.memories.promote(n);c(d,i(d).map(p=>p.memory.id===a.id?{...p,memory:{...p.memory,retentionStrength:a.retentionStrength??p.memory.retentionStrength}}:p),!0),r.setText(g())}catch(a){c(f,a instanceof Error?a.message:"UNKNOWN IMPORTANCE PROMOTE ERROR",!0),r.setText(g())}}var h=Et();dt("mhrd3u",t=>{at(()=>{mt.title="Importance · Vestige"})});var J=lt(h);{let t=ct(()=>`real-importance-field:${i(C)}`);ht(J,{demo:"recall-path",get seed(){return i(t)},onready:z})}ut(h),pt(h,t=>c(m,t),()=>i(m)),$("pointerdown",h,q),$("pointermove",h,X),et("pointerleave",h,j),rt(b,h),it()}Q(["pointerdown","pointermove"]);export{Ot as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/13.UdclNjnS.js.br b/apps/dashboard/build/_app/immutable/nodes/13.UdclNjnS.js.br deleted file mode 100644 index 930c2cc..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/13.UdclNjnS.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/13.UdclNjnS.js.gz b/apps/dashboard/build/_app/immutable/nodes/13.UdclNjnS.js.gz deleted file mode 100644 index d3ef253..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/13.UdclNjnS.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/14.CuNExVd0.js b/apps/dashboard/build/_app/immutable/nodes/14.CuNExVd0.js deleted file mode 100644 index ca7d60f..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/14.CuNExVd0.js +++ /dev/null @@ -1 +0,0 @@ -var Q=Object.defineProperty;var Z=(p,c,m)=>c in p?Q(p,c,{enumerable:!0,configurable:!0,writable:!0,value:m}):p[c]=m;var P=(p,c,m)=>Z(p,typeof c!="symbol"?c+"":c,m);import"../chunks/Bzak7iHL.js";import{o as ee,a as te}from"../chunks/DAau0uzT.js";import{p as re,d as g,e as D,b as ne,h as ie,g as r,s as o,u as v,$ as se}from"../chunks/CGq8RnJq.js";import{h as oe}from"../chunks/De_e6MzK.js";import{a as U}from"../chunks/D35IQVqe.js";import{R as ae}from"../chunks/BpEKQwpr.js";import{r as y,C as ce,R as W,I as z}from"../chunks/BMB5u1EX.js";import{T as le}from"../chunks/D7ozXiSB.js";import{L as ue,F as de,l as pe}from"../chunks/DETSv_kY.js";function Ce(p,c){re(c,!0);const m=[...y(ce.forward),1],Y=[...y(W.luciferin),.88],G=[...y(z.veto),.92],F=[...y(W.recall),.62],H=[...y(z.caution),.9],_=36,h="active",O="all";let a=g(D([])),E=g(D([])),T=g(0),u=g(h),L=g(!0),I=g(null),C=g(null),d=null;ee(()=>{b(h)}),te(()=>{d==null||d.dispose(),d=null});async function b(e=r(u)){o(u,e,!0),o(L,!0),o(I,null),R();try{const[t,n]=await Promise.all([U.intentions(e),U.predict()]);o(a,t.intentions||[],!0),o(E,n.predictions??[],!0),o(T,t.total??r(a).length,!0)}catch(t){o(a,[],!0),o(E,[],!0),o(T,0),o(I,t instanceof Error?t.message:"UNKNOWN INTENTION FETCH ERROR",!0)}finally{o(L,!1),R()}}function V(e,t){const n=new K(e);n.uploadScene(t);const i=new le(e);return d=i,i.init().then(()=>R()),i.setText(w()),[n,i]}class K{constructor(t){P(this,"field");this.field=new ue(t)}uploadScene(t){const n=t.nodes.map(s=>({id:s.source.id,score:s.activation??s.retention,hue:de.forward,energy:s.activation,metric2:s.retention,selected:s.source.id===r(C),kind:"intention",payload:s})),i=n.length<4;this.field.setCells(pe(n,{maxRadius:.82,minCellR:i?.22:.025,maxCellR:i?.3:.075}))}compute(t){this.field.compute(t)}render(t){this.field.render(t)}pickAt(t,n){return this.field.pickAt(t,n)}dispose(){this.field.dispose()}}function R(){d==null||d.setText(w())}function l(e){return e.replace(/[\u2014\u2013]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u2026/g,"...").replace(/[^\x20-\x7E]/g,"?")}function N(e){return Math.min(1,Math.max(0,Number.isFinite(e)?e:.5))}function S(e,t){return typeof e=="number"?N(e):t}function k(e){const t=S(e.retention??e.retentionStrength,Number.NaN);if(Number.isFinite(t))return t;const n=typeof e.reminder_count=="number"?e.reminder_count:0,i=Array.isArray(e.related_memories)?e.related_memories.length:0;return N((n+i+1)/6)}function x(e){return S(e.confidence,N((e.priority||2)/4))}function B(e){try{const t=JSON.parse(e.trigger_data||"{}"),n=t.condition??t.topic??t.at??t.in_minutes??t.inMinutes??t.codebase;return l(String(n??e.trigger_type)).replace(/\s+/g," ").slice(0,26)}catch{return l(e.trigger_type).slice(0,26)}}function X(e){const t=l(e.content).replace(/\s+/g," ").trim().slice(0,48),n=l(e.status).slice(0,12),i=B(e);return l(`${t} | ${e.id.slice(0,8)} | p${e.priority} | ${n} | ${i}`)}function $(e,t=F){return{id:"intentions:status",kind:"intention-status",text:l(e),x:-.58,y:.02,size:.044,color:t,depth:.78,weight:.62,revealSpan:32,maxWidthEm:50}}function M(){return{id:"intentions:filter",kind:"intention-filter",text:r(u)===h?"[ SHOWING: ACTIVE - CLICK FOR ALL ]":"[ SHOWING: ALL - CLICK FOR ACTIVE ]",x:-.94,y:.9,size:.024,color:H,depth:1,weight:.7,revealSpan:12,maxWidthEm:40,hitPadX:.03,hitPadY:.03}}function w(){if(r(L))return[$("LOADING INTENTION FIELD...",m)];if(r(I))return[$(`ERROR - ${r(I)}`.slice(0,72),G)];if(r(a).length===0)return[M(),$(`EMPTY ${r(u).toUpperCase()} INTENTION FIELD`,F)];const e=[M()],t=r(a).slice(0,_),n=.72,i=1.5/Math.max(1,_-1);for(let s=0;s({organ:"intentions",nodes:[...r(a).map((e,t)=>({source:{kind:"receipt",id:e.id},index:t,label:l(e.content).slice(0,48),retention:k(e),activation:x(e),trust:x(e),tags:e.tags??[e.status,e.trigger_type].filter(Boolean),type:e.trigger_type})),...r(E).map((e,t)=>({source:{kind:"memory",id:e.id},index:r(a).length+t,label:l(e.content).slice(0,48),retention:N(e.retention),activation:e.predictedNeed==="high"?1:e.predictedNeed==="medium"?.65:.35,trust:N(e.retention),tags:[e.predictedNeed],type:e.nodeType}))],edges:[],events:[],receipts:r(a).map((e,t)=>({source:{kind:"receipt",id:e.id},label:l(e.status),nodeIndices:[t]})),scalars:{total:r(T),visible:r(a).length,predicted:r(E).length,filter:r(u)===O?1:0},alive:r(a).length>0}));function J(e){var n;if(e.kind==="intention-filter"){b(r(u)===h?O:h);return}if(e.kind!=="intention")return;const t=e.payload;o(C,t.intentionId??((n=t.source)==null?void 0:n.id)??null,!0),R()}oe("16y0tkj",e=>{ie(()=>{se.title="Intentions · Vestige"})});{let e=v(()=>`real-intention-field:${r(u)}:${r(T)}:${r(C)??"none"}`),t=v(()=>`EMPTY ${r(u).toUpperCase()} INTENTION FIELD`);ae(p,{organ:"intentions",get seed(){return r(e)},get scene(){return r(j)},passes:V,get loading(){return r(L)},get error(){return r(I)},get emptyLabel(){return r(t)},onpick:J})}ne()}export{Ce as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/14.CuNExVd0.js.br b/apps/dashboard/build/_app/immutable/nodes/14.CuNExVd0.js.br deleted file mode 100644 index 8c65e6d..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/14.CuNExVd0.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/14.CuNExVd0.js.gz b/apps/dashboard/build/_app/immutable/nodes/14.CuNExVd0.js.gz deleted file mode 100644 index 04eb420..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/14.CuNExVd0.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/15.D2EVaO6c.js b/apps/dashboard/build/_app/immutable/nodes/15.D2EVaO6c.js deleted file mode 100644 index 973fbf2..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/15.D2EVaO6c.js +++ /dev/null @@ -1 +0,0 @@ -import"../chunks/Bzak7iHL.js";import{d as Q,o as Z,a as P,b,e as ee}from"../chunks/DAau0uzT.js";import{p as te,d as f,e as k,a as re,b as ne,h as oe,g as s,f as se,u as ie,c as ae,s as l,$ as le,r as ue}from"../chunks/CGq8RnJq.js";import{h as ce}from"../chunks/De_e6MzK.js";import{b as de}from"../chunks/Ccqjq5DS.js";import{r as L,O as me,a as pe}from"../chunks/BMB5u1EX.js";import{a as v}from"../chunks/D35IQVqe.js";import{T as he}from"../chunks/D7ozXiSB.js";import{L as fe,l as ye}from"../chunks/DETSv_kY.js";var ge=se('
      ');function Te(A,F){te(F,!0);const O=[...L("#22C7DE"),1],Y=[...L("#FF3B30"),.92],N=[...L("#29F2A9"),.62],_=40,D=36,W=.62,B=-1e5;let c=f(null),d=null,n=null,u=null,E=null,y=f(k(new Set)),m=f(k([])),w=f(0),R=f(!0),h=f(null),C=null,M=null;Z(()=>{H()}),P(()=>{M==null||M(),n==null||n.dispose(),u==null||u.dispose(),n=null,u=null,d=null});function K(e){if(typeof window>"u")return()=>{};const t=window.matchMedia("(prefers-reduced-motion: reduce)");e.setPaused(t.matches);const r=o=>e.setPaused(o.matches);return t.addEventListener("change",r),()=>t.removeEventListener("change",r)}async function z(e){d=e,M=K(e);const t=new fe(e);u=t,t.setCells(I()),e.addPass(t);const r=new he(e);n=r,await r.init(),r.setText(x()),e.addPass(r),e.demoClock.reset()}function I(){const e=s(m).map(t=>{const r=g(t.retentionStrength);return{id:t.id,score:g(t.retrievalStrength??r),hue:pe(r),energy:.4+.6*g(t.retrievalStrength??r),metric2:r,scar:s(y).has(t.id),kind:"memory",payload:t}});return ye(e,{maxRadius:.95,minCellR:.014,maxCellR:.05})}async function H(){l(R,!0),l(h,null),n==null||n.setText(x());try{const e=await v.memories.list({limit:String(_)});l(m,e.memories,!0),l(w,e.total,!0)}catch(e){l(m,[],!0),l(w,0),l(h,e instanceof Error?e.message:"UNKNOWN MEMORY FETCH ERROR",!0)}finally{l(R,!1),n==null||n.setText(x()),u==null||u.setCells(I()),d==null||d.demoClock.reset()}}function S(e){return e.replace(/[\u2014\u2013]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u2026/g,"...").replace(/[^\x20-\x7E]/g,"?")}function U(e){const t=S(e.content).replace(/\s+/g," ").trim().slice(0,52);return S(`${t} | ${e.id.slice(0,8)} | ${Math.round(e.retentionStrength*100)}%`)}function g(e){return Math.min(1,Math.max(0,Number.isFinite(e)?e:.5))}function T(e,t=N){return{id:"memories:status",kind:"memory-status",text:S(e),x:-.58,y:.02,size:.044,color:t,depth:.78,weight:.62,revealSpan:32,maxWidthEm:50}}function x(){if(s(R))return[T("LOADING MEMORY FIELD...",O)];if(s(h))return[T(`ERROR - ${s(h)}`.slice(0,72),Y)];if(s(m).length===0)return[T("EMPTY MEMORY FIELD",N)];const e=s(m).slice(0,D),t=.72,r=1.5/Math.max(1,D-1);return e.map((o,i)=>{const a=g(o.retrievalStrength),J=g(o.retentionStrength);return{id:`mem:${o.id}`,kind:"memory",memoryId:o.id,text:U(o),x:-.88,y:t-i*r,size:.026,color:O,depth:Math.max(W,a),weight:J,startFrame:B+i*2,revealSpan:20,maxWidthEm:46,hitPadX:.03,hitPadY:.015}})}function $(e){if(!s(c))return null;const t=s(c).getBoundingClientRect();return t.width<=0||t.height<=0?null:{x:(e.clientX-t.left)/t.width*2-1,y:-((e.clientY-t.top)/t.height*2-1)}}function V(e){if(!s(c)||!d)return;const t=s(c).getBoundingClientRect(),r=Math.max(1e-4,t.width/Math.max(1,t.height)),o={x:e.x*Math.max(r,1),y:e.y/Math.min(r,1)},i=E??o,a={x:i.x+(o.x-i.x)*.35,y:i.y+(o.y-i.y)*.35};E=a,d.setCursorPreNdc(a.x,a.y,a.x-i.x,a.y-i.y)}function q(e){const t=$(e);if(!t)return;V(t);const r=(n==null?void 0:n.pickAt(t.x,t.y))??null,o=(r==null?void 0:r.kind)==="memory"?r.id:null;o!==C&&(C=o,n==null||n.setRunDepth(o,1)),s(c)&&(s(c).style.cursor=o?"crosshair":"default")}function G(){E=null,C=null,d==null||d.setCursorPreNdc(999,999,0,0),n==null||n.setRunDepth(null),s(c)&&(s(c).style.cursor="default")}async function X(e){const t=$(e);if(!t||!n)return;const r=n.pickAt(t.x,t.y);if((r==null?void 0:r.kind)!=="memory")return;const o=r.payload;if(o.memoryId)try{if(e.shiftKey)await v.memories.suppress(o.memoryId,"suppressed from memories field"),l(y,new Set(s(y)).add(o.memoryId),!0);else if(e.altKey){if(!(await v.memories.unsuppress(o.memoryId)).stillSuppressed){const a=new Set(s(y));a.delete(o.memoryId),l(y,a,!0)}}else{const i=await v.memories.promote(o.memoryId);l(m,s(m).map(a=>a.id===i.id?{...a,retentionStrength:i.retentionStrength}:a),!0)}l(h,null),n.setText(x()),u==null||u.setCells(I())}catch(i){l(h,i instanceof Error?i.message:"UNKNOWN MEMORY ACTION ERROR",!0),n.setText(x())}}var p=ge();ce("1mq4kpt",e=>{oe(()=>{le.title="Memories · Vestige"})});var j=ae(p);{let e=ie(()=>`real-memory-field:${s(w)}`);me(j,{demo:"recall-path",get seed(){return s(e)},onready:z})}ue(p),de(p,e=>l(c,e),()=>s(c)),b("pointerdown",p,X),b("pointermove",p,q),ee("pointerleave",p,G),re(A,p),ne()}Q(["pointerdown","pointermove"]);export{Te as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/15.D2EVaO6c.js.br b/apps/dashboard/build/_app/immutable/nodes/15.D2EVaO6c.js.br deleted file mode 100644 index b5f8821..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/15.D2EVaO6c.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/15.D2EVaO6c.js.gz b/apps/dashboard/build/_app/immutable/nodes/15.D2EVaO6c.js.gz deleted file mode 100644 index d24ad21..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/15.D2EVaO6c.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/16.BHQZgsg5.js b/apps/dashboard/build/_app/immutable/nodes/16.BHQZgsg5.js deleted file mode 100644 index 49a86f4..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/16.BHQZgsg5.js +++ /dev/null @@ -1 +0,0 @@ -var Y=Object.defineProperty;var z=(m,c,u)=>c in m?Y(m,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):m[c]=u;var I=(m,c,u)=>z(m,typeof c!="symbol"?c+"":c,u);import"../chunks/Bzak7iHL.js";import{o as j}from"../chunks/DAau0uzT.js";import{p as H,d as g,e as b,j as K,b as V,s as a,h as B,g as i,u as O,$ as G}from"../chunks/CGq8RnJq.js";import{h as X}from"../chunks/De_e6MzK.js";import{a as q,s as J}from"../chunks/DV6OI5iy.js";import{a as T}from"../chunks/D35IQVqe.js";import{m as Q}from"../chunks/Ch9vNiEl.js";import{R as Z}from"../chunks/BpEKQwpr.js";import{r as P,I as ee,R as te}from"../chunks/BMB5u1EX.js";import{T as re}from"../chunks/D7ozXiSB.js";import{L as se,F as ne,l as ie}from"../chunks/DETSv_kY.js";function Re(m,c){H(c,!0);const u=()=>q(Q,"$memoryPrEvents",k),[k,_]=J(),v=[...P("#22C7DE"),1],F=[...P(ee.caution),.9],S=[...P(te.recall),.62],f=28,A=100,$=-1e5;let l=g(b([])),d=g(b([])),R=g(!0),y=g(null);j(()=>{x()});async function x(){a(R,!0),a(y,null);try{const e=await T.memoryPrs.list(void 0,A);a(l,e.prs,!0),a(d,[],!0)}catch(e){a(l,[],!0),a(d,[],!0),a(y,e instanceof Error?e.message:"UNKNOWN MEMORY PR FETCH ERROR",!0)}finally{a(R,!1)}}K(()=>{u().length&&x()});function h(e){return e.replace(/[\u2014\u2013]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u2026/g,"...").replace(/[^\x20-\x7E]/g,"?")}function C(e){return Math.min(1,Math.max(0,Number.isFinite(e)?e:.5))}function M(e,t){if(typeof e=="number"&&Number.isFinite(e))return e;if(!e||typeof e!="object")return null;const n=e;for(const r of t){const s=n[r];if(typeof s=="number"&&Number.isFinite(s))return s}for(const r of Object.values(n)){const s=M(r,t);if(s!==null)return s}return null}function E(e){const t=M(e.diff,["confidence","trust","contradictsTrust","contradicts_trust"]);return t!==null?C(t>1?t/100:t):.5}function w(e){return h(`${e.title} | ${e.id.slice(0,8)} | ${e.status}`).replace(/\s+/g," ").trim().slice(0,96)}function N(){const e=i(l).slice(0,f),t=.74,n=1.46/Math.max(1,f-1),r=e.map((o,p)=>({id:`memory-pr:${o.id}`,kind:"memory-pr",prId:o.id,text:w(o),x:-.9,y:t-p*n,size:.025,color:o.status==="pending"?v:S,depth:E(o),weight:1,startFrame:$+p*2,revealSpan:20,maxWidthEm:54,hitPadX:.03,hitPadY:.019})),s=i(d).slice(0,5).map((o,p)=>({id:`memory-pr-why:${o.code}:${p}`,kind:"memory-pr-why",text:h(`${o.code}: ${o.detail}`).replace(/\s+/g," ").trim().slice(0,86),x:-.82,y:-.76-p*.052,size:.02,color:F,depth:.72,weight:.8,startFrame:$+(e.length+p)*2,revealSpan:18,maxWidthEm:56}));return[...r,...s]}let L=O(()=>({organ:"memory-prs",nodes:i(l).slice(0,f).map((e,t)=>({source:{kind:"pr",id:e.id},index:t,label:w(e),retention:1,activation:E(e),trust:E(e),tags:e.signals.map(n=>h(n.code)),type:h(e.kind)})),edges:[],events:[],receipts:[],scalars:{visiblePrs:Math.min(i(l).length,f),whySignals:i(d).length},alive:i(l).length>0}));function D(e,t){const n=new U(e);n.uploadScene(t);const r=new re(e);return r.init().then(()=>r.setText(N())),[n,{render:s=>r.render(s),uploadScene:()=>r.setText(N()),pickAt:(s,o)=>r.pickAt(s,o),dispose:()=>r.dispose()}]}class U{constructor(t){I(this,"field");this.field=new se(t)}uploadScene(t){const n=t.nodes.map(r=>{var s;return{id:r.source.id,score:r.activation??.5,hue:ne.caution,energy:r.activation,metric2:r.trust,scar:(((s=r.tags)==null?void 0:s.length)??0)>1,kind:"memory-pr",payload:r}});this.field.setCells(ie(n,{maxRadius:.9,minCellR:.035,maxCellR:.09}))}compute(t){this.field.compute(t)}render(t){this.field.render(t)}pickAt(t,n){return this.field.pickAt(t,n)}dispose(){this.field.dispose()}}async function W(e){var r;if(e.kind!=="memory-pr")return;const t=e.payload,n=t.prId??((r=t.source)==null?void 0:r.id);if(n)try{const s=await T.memoryPrs.act(n,"ask_agent_why");a(d,s.why??[],!0)}catch(s){a(y,s instanceof Error?s.message:"UNKNOWN MEMORY PR ACTION ERROR",!0)}}X("c1wbiz",e=>{B(()=>{G.title="Memory PRs · Vestige"})});{let e=O(()=>`memory-pr-field:${i(l).length}:${i(d).length}`);Z(m,{organ:"memory-prs",get seed(){return i(e)},get scene(){return i(L)},passes:D,get loading(){return i(R)},get error(){return i(y)},emptyLabel:"NO MEMORY PRS",onpick:W})}V(),_()}export{Re as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/16.BHQZgsg5.js.br b/apps/dashboard/build/_app/immutable/nodes/16.BHQZgsg5.js.br deleted file mode 100644 index aee9abb..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/16.BHQZgsg5.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/16.BHQZgsg5.js.gz b/apps/dashboard/build/_app/immutable/nodes/16.BHQZgsg5.js.gz deleted file mode 100644 index 5ffa64b..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/16.BHQZgsg5.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/17.DpD2KkS8.js b/apps/dashboard/build/_app/immutable/nodes/17.DpD2KkS8.js deleted file mode 100644 index e6366f5..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/17.DpD2KkS8.js +++ /dev/null @@ -1 +0,0 @@ -import"../chunks/Bzak7iHL.js";import{d as ie,o as le,a as ce,b as z,e as ue}from"../chunks/DAau0uzT.js";import{p as de,d as v,e as me,a as pe,b as he,h as fe,f as ye,g as a,s as p,$ as ge,c as xe,r as ve}from"../chunks/CGq8RnJq.js";import{fB as be,fC as Ce}from"../chunks/Bo4EDkTQ.js";import{h as Ee}from"../chunks/De_e6MzK.js";import{b as we}from"../chunks/Ccqjq5DS.js";import{g as G}from"../chunks/DJDK-KWF.js";import{b as W}from"../chunks/DY7cP31Q.js";import{i as Me,r as b,C as Re,R as Y,I as U,D as Ne,a as Se}from"../chunks/BMB5u1EX.js";import{T as $e}from"../chunks/D7ozXiSB.js";import{l as De,L as Oe}from"../chunks/DETSv_kY.js";import{a as Te}from"../chunks/D35IQVqe.js";const Le=!1,ke=!1,Ve=Object.freeze(Object.defineProperty({__proto__:null,prerender:ke,ssr:Le},Symbol.toStringTag,{value:"Module"}));var _e=ye('
      ');function je(B,P){de(P,!0);const R=new URLSearchParams(window.location.search),k=R.get("demo")??"recall-path";let h=v(me(Me(k)?k:"recall-path"));const X=R.get("seed")??"vestige-observatory-v1",N=R.get("frame"),H=N!==null&&N!==""?Number(N):null,S=[...b(Re.forward),1],_=[...b(Y.recall),.76],$=[...b(Y.luciferin),.9],V=[...b(U.veto),.92],j=[...b(U.caution),.82],I=18;let l=v(null),i=null,n=null,d=null,C=v(null),D=v(!0),E=v(null),O=null,T=null;le(()=>{q()}),ce(()=>{n==null||n.dispose(),d==null||d.dispose(),n=null,d=null,i=null});async function K(e){i=e;const t=new Oe(e);d=t,t.setCells(A()),e.addPass(t);const r=new $e(e);n=r,await r.init(),r.setText(M()),e.addPass(r),e.demoClock.reset()}function A(){var r;const t=(((r=a(C))==null?void 0:r.nodes)??[]).map(o=>({id:o.id,score:c(o.retention),hue:Se(c(o.retention)),energy:.4+.6*c(o.retention),selected:!!o.isCenter,scar:(o.suppression_count??0)>0,metric2:c(o.retention),kind:"observatory-cell",payload:o}));return De(t,{maxRadius:.95,minCellR:.01,maxCellR:.038})}async function q(){p(D,!0),p(E,null),n==null||n.setText(M());try{p(C,await Te.graph({max_nodes:200,depth:3,sort:"connected"}),!0)}catch(e){p(C,null),p(E,e instanceof Error?e.message:"UNKNOWN OBSERVATORY GRAPH ERROR",!0)}finally{p(D,!1),n==null||n.setText(M()),d==null||d.setCells(A()),i==null||i.demoClock.reset()}}function m(e){return e.replace(/[\u2014\u2013]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u2026/g,"...").replace(/[^\x20-\x7E]/g,"?")}function c(e){return Math.min(1,Math.max(0,Number.isFinite(e)?e:.5))}function J(e){const[t]=e.split("-");return m(t.toUpperCase())}function w(e,t){return c(t<=0?0:e/t)}function Q(e){const t=m(e.label).replace(/\s+/g," ").trim().slice(0,44),r=e.tags[0]?m(e.tags[0]).slice(0,14):m(e.type);return m(`${t} | ${e.id.slice(0,8)} | ${r} | ${Math.round(c(e.retention)*100)}%`)}function L(e,t=$){return{id:"observatory:status",kind:"observatory-status",text:m(e),x:-.48,y:.02,size:.044,color:t,depth:.76,weight:.66,revealSpan:32,maxWidthEm:52}}function M(){const e=[],t=a(C),r=t?w(t.nodeCount,Math.max(1,t.nodes.length,200)):.5,o=t?w(t.edgeCount,Math.max(1,t.nodeCount*8)):.5;if(Ne.forEach((s,u)=>{e.push({id:`observatory:demo:${s}`,kind:"observatory-demo",action:"demo",demo:s,text:J(s),x:-.91,y:.76-u*.075,size:.03,color:s===a(h)?$:_,depth:s===a(h)?1:r,weight:s===a(h)?.9:o,startFrame:u*2,revealSpan:14,maxWidthEm:18,hitPadX:.03,hitPadY:.026})}),e.push({id:"observatory:exit",kind:"observatory-exit",action:"exit",text:m("EXIT"),x:.75,y:.82,size:.03,color:j,depth:r,weight:o,revealSpan:10,maxWidthEm:12,hitPadX:.03,hitPadY:.05}),a(D))return[...e,L("LOADING MEMORY FIELD...",S)];if(a(E))return[...e,L(`ERROR - ${a(E)}`.slice(0,76),V)];if(!t||t.nodeCount===0)return[...e,L("NO MEMORIES IN FIELD",_)];[[`NODES ${t.nodeCount}`,w(t.nodeCount,Math.max(1,t.nodes.length,200))],[`EDGES ${t.edgeCount}`,w(t.edgeCount,Math.max(1,t.nodeCount*8))],[`DEPTH ${t.depth}`,c(t.depth/4)],[`CENTER ${t.center_id.slice(0,12)}`,1]].forEach(([s,u],x)=>{e.push({id:`observatory:telemetry:${x}`,kind:"observatory-telemetry",text:m(s),x:.39,y:.72-x*.045,size:.022,color:S,depth:u,weight:o,startFrame:8+x*2,revealSpan:10,maxWidthEm:24})});const g=[...t.nodes].sort((s,u)=>Number(u.isCenter)-Number(s.isCenter)||c(u.retention)-c(s.retention)).slice(0,I),ae=.47,se=1.06/Math.max(1,I-1);return g.forEach((s,u)=>{const x=c(s.retention);e.push({id:`observatory:node:${s.id}`,kind:"observatory-node",text:Q(s),x:-.67,y:ae-u*se,size:.024,color:s.isCenter?$:S,depth:s.isCenter?1:x,weight:x,startFrame:18+u*2,revealSpan:18,maxWidthEm:54})}),e}function Z(e){if(e===a(h))return;p(h,e,!0);const t=new URL(window.location.href);t.searchParams.set("demo",e),history.replaceState(history.state,"",t),n==null||n.setText(M()),i==null||i.demoClock.reset()}function F(e){if(!a(l))return null;const t=a(l).getBoundingClientRect();return t.width<=0||t.height<=0?null:{x:(e.clientX-t.left)/t.width*2-1,y:-((e.clientY-t.top)/t.height*2-1)}}function ee(e){if(!a(l)||!i)return;const t=a(l).getBoundingClientRect(),r=Math.max(1e-4,t.width/Math.max(1,t.height)),o={x:e.x*Math.max(r,1),y:e.y/Math.min(r,1)},y=T??o,g={x:y.x+(o.x-y.x)*.35,y:y.y+(o.y-y.y)*.35};T=g,i.setCursorPreNdc(g.x,g.y,g.x-y.x,g.y-y.y)}function te(e){const t=F(e);if(!t)return;ee(t);const r=(n==null?void 0:n.pickAt(t.x,t.y))??null,o=(r==null?void 0:r.kind)==="observatory-demo"||(r==null?void 0:r.kind)==="observatory-exit"?r.id:null;o!==O&&(O=o,n==null||n.setRunDepth(o,1)),a(l)&&(a(l).style.cursor=o?"crosshair":"default")}function oe(){T=null,O=null,i==null||i.setCursorPreNdc(999,999,0,0),n==null||n.setRunDepth(null),a(l)&&(a(l).style.cursor="default")}async function re(e){const t=F(e);if(!t||!n)return;const r=n.pickAt(t.x,t.y),o=r==null?void 0:r.payload;(o==null?void 0:o.action)==="demo"&&o.demo?Z(o.demo):(o==null?void 0:o.action)==="exit"&&await G(`${W}/graph`)}var f=_e();Ee("2ll0b2",e=>{fe(()=>{ge.title="Observatory · Vestige"})});var ne=xe(f);be(ne,()=>a(h),e=>{Ce(e,{get demo(){return a(h)},get seed(){return X},get freezeFrame(){return H},capture:!0,showSwitcher:!1,chrome:"none",onready:K,onexit:()=>G(`${W}/graph`)})}),ve(f),we(f,e=>p(l,e),()=>a(l)),z("pointerdown",f,re),z("pointermove",f,te),ue("pointerleave",f,oe),pe(B,f),he()}ie(["pointerdown","pointermove"]);export{je as component,Ve as universal}; diff --git a/apps/dashboard/build/_app/immutable/nodes/17.DpD2KkS8.js.br b/apps/dashboard/build/_app/immutable/nodes/17.DpD2KkS8.js.br deleted file mode 100644 index 6d34dff..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/17.DpD2KkS8.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/17.DpD2KkS8.js.gz b/apps/dashboard/build/_app/immutable/nodes/17.DpD2KkS8.js.gz deleted file mode 100644 index ebe7a3f..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/17.DpD2KkS8.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/18.DdPknQfI.js b/apps/dashboard/build/_app/immutable/nodes/18.DdPknQfI.js deleted file mode 100644 index 06bfb21..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/18.DdPknQfI.js +++ /dev/null @@ -1,159 +0,0 @@ -var $=Object.defineProperty;var q=(u,e,r)=>e in u?$(u,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):u[e]=r;var y=(u,e,r)=>q(u,typeof e!="symbol"?e+"":e,r);import"../chunks/Bzak7iHL.js";import{d as W,a as Z,b as G,e as K}from"../chunks/DAau0uzT.js";import{p as J,a as Q,b as ee,h as te,f as re,c as ne,g as _,s as L,d as H,$ as oe,r as ie}from"../chunks/CGq8RnJq.js";import{h as se}from"../chunks/De_e6MzK.js";import{b as ae}from"../chunks/Ccqjq5DS.js";import{g as U}from"../chunks/DJDK-KWF.js";import{b as k}from"../chunks/DY7cP31Q.js";import{r as A,O as ce}from"../chunks/BMB5u1EX.js";import{o as le,p as he,l as fe,m as ue}from"../chunks/BKh9s_e0.js";import{T as de}from"../chunks/D7ozXiSB.js";const pe=28,Y=12,me=18,ge=.32,ve=8.2,ye=2.35,be=1.55,xe={reasoning:"#22C7DE",memory:"#29F2A9",immune:"#FF5E7A",signal:"#FFC44D",temporal:"#8B7BFF",system:"#DDE7FF"},_e={reasoning:0,memory:1,immune:2,signal:3,temporal:4,system:5},Fe=` -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - capture_mode: f32, - live_kind: f32, - live_frame: f32, - live_energy: f32, - projection_days: f32, -}; - -struct Camera { - view_proj: mat4x4, - right: vec4, - up: vec4, - // x: hover code = strength*(hoveredIndex+1), 0 = nothing hovered. - // yzw: focused organ world position (parting pushes others away from it). - hover: vec4, -}; - -struct Organ { - pos_radius: vec4, // xyz world pos, w core radius - color_family: vec4, // rgb accent, w family id - info: vec4, // x center flag, yzw reserved -}; - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var camera: Camera; -@group(0) @binding(2) var organs: array; - -struct VSOut { - @builtin(position) clip: vec4, - @location(0) uv: vec2, - @location(1) @interpolate(flat) accent: vec3, - // x radius, y center flag, z family id, w breath - @location(2) @interpolate(flat) info: vec4, - // focus factor for THIS orb: 1 = the hovered organ, 0 = not (eases via strength) - @location(3) @interpolate(flat) focus: f32, -}; - -const CORNERS = array, 6>( - vec2(-1.0, -1.0), - vec2( 1.0, -1.0), - vec2( 1.0, 1.0), - vec2(-1.0, -1.0), - vec2( 1.0, 1.0), - vec2(-1.0, 1.0) -); - -@vertex -fn vs_main( - @builtin(vertex_index) vi: u32, - @builtin(instance_index) ii: u32 -) -> VSOut { - var out: VSOut; - if (ii >= u32(params.node_count)) { - out.clip = vec4(0.0, 0.0, 2.0, 1.0); - return out; - } - - let organ = organs[ii]; - let corner = CORNERS[vi]; - let is_center = organ.info.x > 0.5; - - // Breath: hero orbs swell ~8% on the global pulse; the center heart breathes - // deeper. A slow per-organ phase offset (from world x) desyncs the field so - // it shimmers like a living constellation, not a single strobe. - let phase_off = organ.pos_radius.x * 0.35 + organ.pos_radius.z * 0.21; - let local_pulse = 0.5 + 0.5 * sin(params.loop_phase * 6.28318530718 * 2.0 + phase_off); - var breath = 1.0 + 0.08 * local_pulse; - if (is_center) { - breath = 1.0 + 0.16 * params.pulse; - } - - // Hero sprite: ~2.6x the core radius. Big enough to fill the view, small - // enough that 19 halos stay DISTINCT instead of merging into one bloom fog - // (3.4 washed the frame out and buried the labels). - // ── Focus+context (hover-to-inspect nav) ── - // hover.x = eased strength 0..1 (0 = nothing focused); hover.yzw = focused - // organ world pos. This orb is "focused" if its world pos matches yzw. - let strength = clamp(camera.hover.x, 0.0, 1.0); - let hover_active = strength > 0.001; - let focused_pos = camera.hover.yzw; - let is_focused = hover_active && distance(organ.pos_radius.xyz, focused_pos) < 0.001; - - // Part the OTHER orbs radially away from the focused organ so the hovered one - // gets breathing room (accordion/fisheye), eased by strength. - var pos = organ.pos_radius.xyz; - if (hover_active && !is_focused) { - let delta = organ.pos_radius.xyz - focused_pos; - let dist = max(length(delta), 0.0001); - pos = pos + (delta / dist) * 2.6 * strength; - } - - // Focused organ swells so it dominates the view. - let focus_scale = select(1.0, 1.0 + 0.6 * strength, is_focused); - let half_size = organ.pos_radius.w * 2.6 * breath * focus_scale; - let world = pos - + camera.right.xyz * corner.x * half_size - + camera.up.xyz * corner.y * half_size; - - out.clip = camera.view_proj * vec4(world, 1.0); - out.uv = corner; - out.accent = organ.color_family.rgb; - out.info = vec4(organ.pos_radius.w, select(0.0, 1.0, is_center), organ.color_family.w, breath); - out.focus = select(0.0, strength, is_focused); - return out; -} - -@fragment -fn fs_main(in: VSOut) -> @location(0) vec4 { - let d = length(in.uv); - if (d > 1.0) { - discard; - } - - let is_center = in.info.y > 0.5; - - // Soft glow: hot core + TIGHTER halo (falls off faster) so orbs read as - // distinct nodes and don't drown the frame + labels in overlapping bloom. - let core = smoothstep(0.22, 0.0, d); - let halo = pow(max(1.0 - d, 0.0), 3.4); - var intensity = core * 1.4 + halo * (0.30 + 0.14 * params.pulse); - - // Thin fresnel ring gives each orb a crisp planetary rim (reads as a sphere, - // not a fuzzy dot) — brightest at the silhouette edge. - let ring = smoothstep(0.62, 0.82, d) * (1.0 - smoothstep(0.9, 1.0, d)); - intensity = intensity + ring * 0.55; - - if (is_center) { - intensity = intensity * 1.7; - } - - // Focus glow: the hovered organ blazes brighter + gets a hotter rim so it - // clearly reads as "the section you're about to enter." - intensity = intensity * (1.0 + 1.3 * in.focus); - intensity = intensity + ring * in.focus * 1.2; - - var color = in.accent * intensity; - // Hovered orb picks up a white-hot center so its label reads on top of it. - color = color + vec3(1.0, 1.0, 1.0) * core * in.focus * 0.7; - - // Center heart gets a white-hot pinpoint core — the cortex the organs orbit. - if (is_center) { - color = color + vec3(1.0, 1.0, 1.0) * core * 0.6; - } - - return vec4(color * params.brightness, 1.0); -} -`,z=class z{constructor(e){y(this,"engine");y(this,"pipeline",null);y(this,"bindGroup",null);y(this,"cameraBuffer",null);y(this,"nodeBuffer",null);y(this,"cameraData",new Float32Array(pe));y(this,"nodeCount",0);y(this,"placed",[]);y(this,"hoveredIndex",-1);y(this,"hoverStrength",0);y(this,"dive",null);y(this,"onArrive",null);this.engine=e}setHovered(e){this.hoveredIndex=e>=0&&er.href===e):-1}startDive(e,r){if(this.dive)return!1;const n=this.placed.find(t=>t.href===e);return n?(this.dive={target:[n.x,n.y,n.z],startMs:this.engine.wallNowMs,href:e},this.onArrive=r,!0):!1}get isDiving(){return this.dive!==null}uploadRegions(e){var s;const r=this.engine.gpuDevice;if(!r)return;const n=this.layout(e);this.placed=n,this.nodeCount=n.length;const t=new Float32Array(Math.max(n.length,1)*Y);for(let o=0;o!i.center).length;let o=0;for(const i of e){if(i.center){r.push({href:i.href,x:0,y:0,z:0,radius:ye,center:!0});continue}const f=o++,d=s>1?1-f/(s-1)*2:0,m=Math.sqrt(Math.max(0,1-d*d)),c=n*f,a=ve*(.82+.18*(f*.6180339887%1));r.push({href:i.href,x:Math.cos(c)*m*a,y:d*a*.82,z:Math.sin(c)*m*a,radius:be,center:!1})}return r}createPipeline(e){if(!this.engine.paramsBuffer||!this.cameraBuffer||!this.nodeBuffer)return;const r=e.createShaderModule({label:"palace-render-nodes",code:Fe});this.pipeline=e.createRenderPipeline({label:"palace-nodes",layout:"auto",vertex:{module:r,entryPoint:"vs_main"},fragment:{module:r,entryPoint:"fs_main",targets:[{format:this.engine.sceneFormat,blend:{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}}]},primitive:{topology:"triangle-list"}}),this.bindGroup=e.createBindGroup({label:"palace-nodes-bind",layout:this.pipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.cameraBuffer}},{binding:2,resource:{buffer:this.nodeBuffer}}]})}currentCamera(){const e=this.engine.params[6]||1,r=this.engine.params[7]||1,n=e/r,t=this.engine.params[1],s=le(t,n,me,ge);if(!this.dive)return s;const o=Math.min(1,(this.engine.wallNowMs-this.dive.startMs)/z.DIVE_MS),i=o*o*o,f=[s.eye[0]+(this.dive.target[0]-s.eye[0])*i*.985,s.eye[1]+(this.dive.target[1]-s.eye[1])*i*.985,s.eye[2]+(this.dive.target[2]-s.eye[2])*i*.985],d=[this.dive.target[0]*i,this.dive.target[1]*i,this.dive.target[2]*i],m=(50-8*i)*Math.PI/180,c=he(m,n,.05,4e3),a=fe(f,d,[0,1,0]),b=ue(c,a);if(o>=1&&this.onArrive){const F=this.onArrive,w=this.dive.href;this.onArrive=null,this.dive=null,queueMicrotask(()=>F(w))}return{viewProj:b,right:s.right,up:s.up,eye:f}}compute(){const e=this.engine.gpuDevice;if(!e||!this.cameraBuffer)return;const r=this.currentCamera();this.cameraData.set(r.viewProj,0),this.cameraData[16]=r.right[0],this.cameraData[17]=r.right[1],this.cameraData[18]=r.right[2],this.cameraData[19]=0,this.cameraData[20]=r.up[0],this.cameraData[21]=r.up[1],this.cameraData[22]=r.up[2],this.cameraData[23]=0;const n=this.hoveredIndex>=0?1:0;this.hoverStrength+=(n-this.hoverStrength)*.18,this.hoverStrength<.001&&(this.hoverStrength=0);const t=this.hoveredIndex>=0?this.placed[this.hoveredIndex]:null;this.cameraData[24]=t?this.hoverStrength:0,this.cameraData[25]=t?t.x:0,this.cameraData[26]=t?t.y:0,this.cameraData[27]=t?t.z:0,e.queue.writeBuffer(this.cameraBuffer,0,this.cameraData)}render(e){!this.pipeline||!this.bindGroup||this.nodeCount===0||(this.engine.params[2]=this.nodeCount,e.setPipeline(this.pipeline),e.setBindGroup(0,this.bindGroup),e.draw(6,this.nodeCount))}pickAt(e,r){if(this.nodeCount===0)return null;const n=this.currentCamera().viewProj,t=1/Math.tan(50*Math.PI/360),s=this.engine.params[6]||1,o=this.engine.params[7]||1,i=s/o;let f=-1,d=1/0;for(let m=0;me.href===u)}const Ee={reasoning:[...A("#FFFFFF"),1],memory:[...A("#FFFFFF"),1],immune:[...A("#FFFFFF"),1],temporal:[...A("#FFFFFF"),1],signal:[...A("#FFFFFF"),1],system:[...A("#FFFFFF"),1]},Ae=[...A("#FFFFFF"),1],Se=1.35,Oe=.028,Re=.6,j=.85,Ie=.05,Be=.03,Ce=1,De=.95,D=[],M=[];function V(u,e,r){return u+(e-u)*r}function X(u){return u<0?0:u>1?1:Number.isFinite(u)?u:0}function Me(u,e={}){const r=e.hoveredHref??null,n=e.dimUnhovered??!0;let t=0;M.length=0;for(let s=0;s.97&&(c=o.ndcX-m*j-w);for(let C=0;CR.x0,P=Math.abs(a-R.y)<(b+R.size)*.75;S&&P&&(a=R.y-(b+R.size)*.85)}M.push({x0:c,x1:c+w,y:a,size:b});const O=i.center?Ae:Ee[i.family],B=[O[0],O[1],O[2],X(F)];let p=D[t];p||(p={id:"",kind:"palace-label",text:"",x:0,y:0,size:0,color:[0,0,0,0],depth:0,weight:.75,revealSpan:1,maxWidthEm:24},D[t]=p),p.id="palace-label:"+o.href,p.kind="palace-label",p.text=i.label,p.x=c,p.y=a,p.size=b,p.color=B,p.depth=d?1:.8+f*.2,p.weight=.95,t++}return D.length=t,D}T.length;var Te=re('
      ');function Xe(u,e){J(e,!0);const r=[...A("#EAFBFF"),1],n=[...A("#CFFFE9"),1];let t=H(null),s=null,o=null,i=null,f=null,d=H(null);Z(()=>{i==null||i.dispose(),i=null,o=null,s=null});async function m(l){s=l,o=new N(l),l.addPass(o),o.uploadRegions(T);const h=new de(l);i=h,await h.init(),l.addPass(h),l.demoClock.reset(),h.setText(F())}function c(){if(!o)return[];const l=o.getScreenPositions(),h=l.filter(x=>x.visible);let g=1/0,v=-1/0;for(const x of h)x.depthv&&(v=x.depth);const E=v===g,I=v-g||1;return l.map(x=>({href:x.href,ndcX:x.ndcX,ndcY:x.ndcY,depth:x.visible?E?1:Math.min(1,Math.max(0,(v-x.depth)/I)):0,visible:x.visible}))}function a(l){return l.replace(/[—–]/g,"-").replace(/[‘’]/g,"'").replace(/[“”]/g,'"').replace(/…/g,"...").replace(/[^\x20-\x7E]/g,"?")}function b(){return[{id:"palace:title",kind:"palace-hud",text:a("THE MEMORY PALACE"),x:-.94,y:.88,size:.062,color:r,depth:1,weight:1,revealSpan:18},{id:"palace:sub",kind:"palace-hud",text:a(`${T.length} ORGANS - CLICK A REGION TO ENTER`),x:-.94,y:.79,size:.032,color:n,depth:1,weight:.85,revealSpan:18,maxWidthEm:70}]}function F(){const l=Me(c(),{hoveredHref:_(d),dimUnhovered:!!_(d)});return[...b(),...l]}function w(){i==null||i.setText(F())}function O(l){if(!_(t))return null;const h=_(t).getBoundingClientRect();return h.width<=0||h.height<=0?null:{x:(l.clientX-h.left)/h.width*2-1,y:-((l.clientY-h.top)/h.height*2-1)}}function B(l){if(!_(t)||!s)return;const h=_(t).getBoundingClientRect(),g=Math.max(1e-4,h.width/Math.max(1,h.height)),v={x:l.x*Math.max(g,1),y:l.y/Math.min(g,1)},E=f??v,I={x:E.x+(v.x-E.x)*.35,y:E.y+(v.y-E.y)*.35};f=I,s.setCursorPreNdc(I.x,I.y,I.x-E.x,I.y-E.y)}function p(l){const h=O(l);if(!h||(B(h),!o))return;const g=o.pickAt(h.x,h.y),v=(g==null?void 0:g.href)??null;v!==_(d)&&(L(d,v,!0),o.setHovered((g==null?void 0:g.index)??-1),_(t)&&(_(t).style.cursor=v?"pointer":"default"))}function C(){f=null,L(d,null),o==null||o.setHovered(-1),s==null||s.setCursorPreNdc(999,999,0,0),_(t)&&(_(t).style.cursor="default")}function R(l){const h=O(l);if(!h||!o||o.isDiving)return;const g=o.pickAt(h.x,h.y);if(!g)return;o.startDive(g.href,E=>{U(`${k}${E}`)})||U(`${k}${g.href}`)}var S=Te();se("1dx67o8",l=>{te(()=>{oe.title="The Memory Palace · Vestige"})});var P=ne(S);ce(P,{demo:"recall-path",seed:"vestige-spatial-palace-v1",onframe:w,onready:m}),ie(S),ae(S,l=>L(t,l),()=>_(t)),G("pointerdown",S,R),G("pointermove",S,p),K("pointerleave",S,C),Q(u,S),ee()}W(["pointerdown","pointermove"]);export{Xe as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/18.DdPknQfI.js.br b/apps/dashboard/build/_app/immutable/nodes/18.DdPknQfI.js.br deleted file mode 100644 index 0b41400..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/18.DdPknQfI.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/18.DdPknQfI.js.gz b/apps/dashboard/build/_app/immutable/nodes/18.DdPknQfI.js.gz deleted file mode 100644 index 5e0826c..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/18.DdPknQfI.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/19.CLd0kemn.js b/apps/dashboard/build/_app/immutable/nodes/19.CLd0kemn.js deleted file mode 100644 index 1475293..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/19.CLd0kemn.js +++ /dev/null @@ -1 +0,0 @@ -var V=Object.defineProperty;var W=(u,c,p)=>c in u?V(u,c,{enumerable:!0,configurable:!0,writable:!0,value:p}):u[c]=p;var j=(u,c,p)=>W(u,typeof c!="symbol"?c+"":c,p);import"../chunks/Bzak7iHL.js";import{o as U}from"../chunks/DAau0uzT.js";import{p as X,d as P,e as q,b as J,h as Q,g as i,s as f,u as S,$ as Z}from"../chunks/CGq8RnJq.js";import{h as ee}from"../chunks/De_e6MzK.js";import{R as te}from"../chunks/BpEKQwpr.js";import{a as w}from"../chunks/D35IQVqe.js";import{r as k}from"../chunks/BMB5u1EX.js";import{T as re}from"../chunks/D7ozXiSB.js";import{L as ne,a as M,F as v}from"../chunks/DETSv_kY.js";function pe(u,c){X(c,!0);const p=[...k("#22C7DE"),1],N=[...k("#FFB020"),.88];[...k("#FF3B30")];const y=42,b=-1e5;let m=P(q({projects:[],patterns:[]})),R=P(!0),A=P(null),d=P(null),E=[],_=null;U(()=>{L(),w.memories.list({limit:"90"}).then(e=>{E=e.memories.map(t=>{const r=a(t.retentionStrength);return{id:t.id,score:.28+.4*r,hue:v.bridge,energy:.14+.28*r,metric2:r,kind:"pattern-pool",payload:t}}),_==null||_.refresh()}).catch(()=>{})});async function L(){f(R,!0),f(A,null);try{f(m,await w.crossProjectPatterns(),!0)}catch(e){f(m,{projects:[],patterns:[]},!0),f(A,e instanceof Error?e.message:String(e),!0)}finally{f(R,!1)}}const $=S(()=>[...i(d)?i(m).patterns.filter(t=>t.category===i(d)):i(m).patterns].sort((t,r)=>r.transfer_count-t.transfer_count||r.confidence-t.confidence)),I=S(()=>O(i(m).projects,i($)));function O(e,t){const r=Math.max(1,...t.map(n=>g(n.transfer_count)));return{organ:"patterns",nodes:t.slice(0,y).map((n,l)=>{const h=a(g(n.transfer_count)/r),x=a(n.confidence);return{source:{kind:"pattern",id:C(n)},index:l,label:F(n),retention:x,activation:h,trust:x,lastAccessed:n.last_used,tags:[n.category,n.origin_project,...n.transferred_to],type:n.category}}),edges:[],events:t.slice(0,y).map((n,l)=>({source:{kind:"event",id:`patterns.${C(n)}.${n.last_used}`},type:n.category,targetIndex:l,frame:12+l*3,energy:a(n.confidence)})),receipts:[],scalars:{projectCount:e.length,patternCount:t.length,maxTransferCount:r,totalTransfers:t.reduce((n,l)=>n+g(l.transfer_count),0)},alive:t.length>0,patterns:t,projects:e,maxTransferCount:r}}const z={ErrorHandling:0,AsyncConcurrency:1,Testing:2,Architecture:3,Performance:4,Security:5};function B(e){const t=new D(e);_=t;const r=new re(e);return r.init(),[t,{render:o=>r.render(o),pickAt:(o,s)=>r.pickAt(o,s),dispose:()=>r.dispose(),uploadScene:o=>r.setText(Y(o))}]}class D{constructor(t){j(this,"field");j(this,"lastNodes",[]);this.field=new ne(t)}uploadScene(t){this.lastNodes=t.nodes,this.apply()}refresh(){this.apply()}apply(){const t=this.lastNodes;if(t.length===0){this.field.setCells(M(E,(o,s)=>s%6,{ringCount:6,maxRadius:.92,minCellR:.02,maxCellR:.05}));return}const r=t.map(o=>{const s=a(g(o.activation??0));return{id:o.source.id,score:s,hue:s>=.5?v.forward:v.bridge,energy:a(.5+.5*g(o.retention??0)),metric2:a(g(o.trust??0)),kind:"pattern",payload:o}});this.field.setCells(M(r,(o,s)=>H(t[s]),{ringCount:6,maxRadius:.92,minCellR:.055,maxCellR:.15}))}compute(t){this.field.compute(t)}render(t){this.field.render(t)}pickAt(t,r){return this.field.pickAt(t,r)}dispose(){this.field.dispose()}}function H(e){const t=e.type;return z[t]??0}function Y(e){const t=e.patterns.slice(0,y),r=.74,o=1.48/Math.max(1,y-1);return t.map((s,n)=>{const l=a(g(s.transfer_count)/e.maxTransferCount),h=a(s.confidence),x=.06*Math.sin(n*.7),K=a(.6+l*.2+(h-.5)*.4+x);return{id:`pattern:${C(s)}`,kind:"pattern",patternKey:C(s),category:s.category,text:F(s),x:-.88,y:r-n*o,size:.024+h*.005,color:i(d)&&s.category===i(d)?N:p,depth:K,weight:h,startFrame:b+n*2,revealSpan:20,maxWidthEm:58,hitPadX:.03,hitPadY:.013}})}function G(e){if(e.kind!=="pattern")return;const t=e.payload;f(d,i(d)===t.category?null:t.category??null,!0)}function F(e){return T([e.name,e.origin_project,e.transferred_to.join(","),e.category,String(e.transfer_count),String(Math.round(a(e.confidence)*100)),e.last_used].join(" | ")).slice(0,118)}function C(e){return T([e.name,e.origin_project,e.category,e.last_used].join(":")).slice(0,180)}function T(e){return e.replace(/[\u2014\u2013]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u2026/g,"...").replace(/[^\x20-\x7E]/g,"?")}function g(e){return Number.isFinite(e)?e:0}function a(e){return Math.min(1,Math.max(0,Number.isFinite(e)?e:0))}ee("1gg45vd",e=>{Q(()=>{Z.title="Patterns · Vestige"})});{let e=S(()=>`cross-project-patterns:${i(m).projects.length}:${i($).length}:${i(d)??"all"}`);te(u,{organ:"patterns",get seed(){return i(e)},get scene(){return i(I)},passes:B,get loading(){return i(R)},get error(){return i(A)},onpick:G})}J()}export{pe as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/19.CLd0kemn.js.br b/apps/dashboard/build/_app/immutable/nodes/19.CLd0kemn.js.br deleted file mode 100644 index bb9e8c7..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/19.CLd0kemn.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/19.CLd0kemn.js.gz b/apps/dashboard/build/_app/immutable/nodes/19.CLd0kemn.js.gz deleted file mode 100644 index 6862ea8..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/19.CLd0kemn.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/2.zvt29sR6.js b/apps/dashboard/build/_app/immutable/nodes/2.zvt29sR6.js deleted file mode 100644 index d2943d4..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/2.zvt29sR6.js +++ /dev/null @@ -1 +0,0 @@ -import"../chunks/Bzak7iHL.js";import{a as i,f as t,c as s,r as d}from"../chunks/CGq8RnJq.js";import{s as l}from"../chunks/BbCqB9Us.js";var n=t('
      ');function f(r,a){var o=n(),e=s(o);l(e,()=>a.children),d(o),i(r,o)}export{f as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/2.zvt29sR6.js.br b/apps/dashboard/build/_app/immutable/nodes/2.zvt29sR6.js.br deleted file mode 100644 index f96724a..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/2.zvt29sR6.js.br +++ /dev/null @@ -1,2 +0,0 @@ -,dh^K67@L=+ $(M@[z3w&ObfZrEIԕ)`IÙ5G$Du -&|?M)JM[{^]VSu7Ę`ip p%2TY Jޠp \ No newline at end of file diff --git a/apps/dashboard/build/_app/immutable/nodes/2.zvt29sR6.js.gz b/apps/dashboard/build/_app/immutable/nodes/2.zvt29sR6.js.gz deleted file mode 100644 index 5b0812c..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/2.zvt29sR6.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/20.DD0_N4PP.js b/apps/dashboard/build/_app/immutable/nodes/20.DD0_N4PP.js deleted file mode 100644 index 682d48d..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/20.DD0_N4PP.js +++ /dev/null @@ -1,198 +0,0 @@ -var Te=Object.defineProperty;var Ie=(t,e,s)=>e in t?Te(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var R=(t,e,s)=>Ie(t,typeof e!="symbol"?e+"":e,s);import"../chunks/Bzak7iHL.js";import{o as $e,e as Ne,s as be}from"../chunks/DAau0uzT.js";import{p as Pe,j as Me,g as v,aH as Le,Y as de,a as ue,b as Fe,d as W,h as Be,X as q,s as N,f as ye,u as _e,$ as De,c as pe,r as se,af as Ge}from"../chunks/CGq8RnJq.js";import{b as Ue,i as Oe}from"../chunks/Ccqjq5DS.js";import{e as Xe,r as We,i as Ye}from"../chunks/DqfV0sZu.js";import{h as Ve}from"../chunks/De_e6MzK.js";import{b as ze}from"../chunks/DGM4cicq.js";import{a as we}from"../chunks/D35IQVqe.js";import{R as He}from"../chunks/BpEKQwpr.js";import{T as qe}from"../chunks/D7ozXiSB.js";import{r as Ke}from"../chunks/BMB5u1EX.js";import{L as je,F as fe,l as Ee}from"../chunks/DETSv_kY.js";const Qe={intent:"Intent classification",retrieve:"Memory retrieval",activate:"Activation expansion",evidence:"Evidence grounding",contradiction:"Contradiction check",synthesis:"Synthesis",recommendation:"Recommendation",receipt:"Composition receipt"},Je=["intent","retrieve","activate","evidence","contradiction","synthesis","recommendation","receipt"];function F(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function y(t,e=""){return typeof t=="string"?t:t==null?e:String(t)}function J(t,e=0){return typeof t=="number"&&Number.isFinite(t)?t:e}function V(t){return Math.max(0,Math.min(1,t))}function Z(t){const e=J(t,0);return V(e>1?e/100:e)}function Ze(t){return t==="primary"||t==="supporting"||t==="contradicting"||t==="superseded"?t:"supporting"}function K(t,e=""){const s=Z(t.trust??t.trust_score??0);return{id:y(t.id??t.memory_id??e),trust:s,date:y(t.date??t.created_at??""),role:Ze(t.role),preview:y(t.preview??t.answer_preview??t.content??""),nodeType:t.node_type?y(t.node_type):t.nodeType?y(t.nodeType):void 0}}function X(t,e,s){return s?{kind:t,id:e,scalar:s}:{kind:t,id:e||`${t}:unknown`}}function P(t,e){return{kind:"scalar",id:`deep_reference.${t}`,scalar:{name:t,value:e}}}function et(t){var f,m,g,w;const e=F(t),u=(Array.isArray(e.evidence)?e.evidence.map(F):[]).map(n=>K(n)).filter(n=>n.id.length>0),h=F(e.recommended),i=Object.keys(h).length>0||u.length>0?{answer_preview:y(h.answer_preview??((f=u[0])==null?void 0:f.preview)??""),memory_id:y(h.memory_id??((m=u[0])==null?void 0:m.id)??""),trust_score:Z(h.trust_score??((g=u[0])==null?void 0:g.trust)??0),date:y(h.date??((w=u[0])==null?void 0:w.date)??"")}:null,a=(Array.isArray(e.contradictions)?e.contradictions.map(F):Array.isArray(e.claim_conflicts)?e.claim_conflicts.map(F):[]).map(n=>{const A=F(n.stronger),L=F(n.weaker);if(Object.keys(A).length>0||Object.keys(L).length>0){const ne=K(A),re=K(L);return{stronger:ne,weaker:re,topic_overlap:V(J(n.topic_overlap,0)),summary:y(n.summary,`Trust-weighted conflict: ${ne.id.slice(0,8)} over ${re.id.slice(0,8)}`)}}const O=K({id:n.a_id,role:"contradicting"}),le=K({id:n.b_id,role:"contradicting"});return{stronger:O,weaker:le,topic_overlap:V(J(n.topic_overlap,0)),summary:y(n.summary??n.reason,"Trust-weighted conflict between high-FSRS memories.")}}).filter(n=>n.stronger.id||n.weaker.id),E=(Array.isArray(e.superseded)?e.superseded.map(F):[]).map(n=>n.id||n.superseded_by?{id:y(n.id),preview:y(n.preview??""),trust:Z(n.trust??0),date:y(n.date??""),superseded_by:y(n.superseded_by??(i==null?void 0:i.memory_id)??""),reason:y(n.reason??"Superseded by newer memory with higher trust.")}:{id:y(n.old_id),preview:y(n.preview??""),trust:Z(n.trust??0),date:y(n.date??""),superseded_by:y(n.new_id??(i==null?void 0:i.memory_id)??""),reason:y(n.reason??"Superseded by newer memory with higher trust.")}).filter(n=>n.id||n.superseded_by),c=Z(e.confidence),l=J(e.memoriesAnalyzed??e.memories_analyzed,u.length),r=J(e.activationExpanded??e.activation_expanded,0),p=y(e.intent??""),b=y(e.reasoning??e.guidance??""),k=y(e.guidance??""),x=y(e.composition_event_id??""),S=y(e.compositionWriteStatus??e.composition_write_status??""),C=x||S,T=x.length>0,M=u.map((n,A)=>({source:X("memory",n.id),index:A,label:n.preview||n.id.slice(0,8),retention:V(n.trust),trust:V(n.trust),lastAccessed:n.date||void 0,tags:[n.role,...n.nodeType?[n.nodeType]:[]],type:n.nodeType??"memory"})),G=new Map(M.map(n=>[n.source.id,n.index])),ee=a.flatMap((n,A)=>{const L=G.get(n.stronger.id),O=G.get(n.weaker.id);return L==null||O==null?[]:[{source:X("pair",`contradiction:${n.stronger.id}:${n.weaker.id}`),sourceIndex:L,targetIndex:O,weight:Math.max(.2,n.topic_overlap||.5),kind:"contradiction"}]}),U=[];a.length>0&&U.push({source:X("event",`deep_reference.contradictions.${a.length}`),type:"ReasoningContradictionInterrupt",targetIndex:-1,frame:250,energy:a.length}),E.length>0&&U.push({source:X("event",`deep_reference.superseded.${E.length}`),type:"ReasoningSupersessionInterrupt",targetIndex:-1,frame:330,energy:E.length});const te=[];C&&te.push({source:T?X("receipt",x):P("compositionWriteStatus",S==="persisted"?1:0),label:T?`receipt ${x.slice(0,8)}`:S,nodeIndices:M.map(n=>n.index)});const $=(n,A,L,O,le,ne,re,Ce="none")=>({index:n,kind:A,label:Qe[A],count:L,confidence:V(O),lit:L>0||O>0,provenance:ne,exposed:le,not_exposed_by_backend:re,interrupt:Ce}),ce=Je.map((n,A)=>{switch(n){case"intent":return $(A,n,p?1:0,p?c:0,{intent:p},P("intent_present",p?1:0),["raw classifier trace"]);case"retrieve":return $(A,n,l||u.length,c,{memoriesAnalyzed:l,evidence_count:u.length},P("memoriesAnalyzed",l),["candidate ids discarded before evidence"]);case"activate":return $(A,n,r,r>0?c:0,{activationExpanded:r},P("activationExpanded",r),["activation path/map"]);case"evidence":return $(A,n,u.length,u.length>0?c:0,{evidence:u},P("evidence_count",u.length),["reranker discarded candidates"]);case"contradiction":return $(A,n,a.length,a.length>0?c:0,{contradictions:a,claim_conflicts:e.claim_conflicts??[]},P("contradiction_count",a.length),["full claim graph"],a.length>0?"contradiction":"none");case"synthesis":return $(A,n,b||k?1:0,b||k?c:0,{reasoning:b,guidance:k},P("synthesis_present",b||k?1:0),["token-level chain internals"]);case"recommendation":return $(A,n,i!=null&&i.memory_id?1:0,(i==null?void 0:i.trust_score)??0,{recommended:i},i!=null&&i.memory_id?X("memory",i.memory_id):P("recommended_present",0),["alternative recommendations"]);case"receipt":return $(A,n,C?1:0,C?c:0,{composition_event_id:x,compositionWriteStatus:S},T?X("receipt",x):P("compositionWriteStatus",S==="persisted"?1:0),["separate receipt field"],E.length>0?"supersession":"none")}});return{organ:"reasoning",nodes:M,edges:ee,events:U,receipts:te,scalars:{confidence:c,memoriesAnalyzed:l,activationExpanded:r,evidenceCount:u.length,contradictionCount:a.length,supersededCount:E.length,compositionPersisted:T?1:0},alive:!!(p||b||k||u.length||a.length||E.length||i!=null&&i.memory_id||C),stages:ce,evidence:u,contradictions:a,superseded:E,recommended:i,raw:e}}const z=[-.86,-.526,-.214,.074,.335,.562,.747,.86],tt=["INTENT","RETRIEVE","ACTIVATE","EVIDENCE","CHALLENGE","SYNTH","DECIDE","SEAL"],xe=0,nt=3,Ae=6,rt=7,st={primary:.04,supporting:.24,contradicting:-.22,superseded:-.48},it=.052,at=6,ot=z[nt]-.02,ct=.14;function lt(t){var c,l;if(!t||!t.alive)return null;const e=String(((c=t.raw)==null?void 0:c.query)??""),s=(t.stages??[]).slice(0,z.length).map((r,p)=>({index:p,kind:(r==null?void 0:r.kind)??String(p),label:(r==null?void 0:r.label)??(r==null?void 0:r.kind)??"",short:tt[p]??((r==null?void 0:r.kind)??"").toUpperCase(),x:z[p],lit:!!(r!=null&&r.lit),confidence:(r==null?void 0:r.confidence)??0,count:(r==null?void 0:r.count)??0})),u=new Map;for(const r of t.evidence??[]){const p=u.get(r.role)??[];p.push(r),u.set(r.role,p)}const h=[];for(const[r,p]of u){const b=st[r],k=p.slice(0,at);k.forEach((x,S)=>{const C=b+(S-(k.length-1)/2)*it,T=ot+S/Math.max(1,k.length-1)*ct;h.push({id:x.id,role:r,trust:x.trust,preview:x.preview,x:T,y:C})})}const i=t.recommended!=null?{x:z[Ae],y:xe,confidence:Math.max(0,Math.min(1,t.recommended.trust_score))}:null,d=i?h.map(r=>({fromX:r.x,fromY:r.y,toX:i.x,toY:i.y,trust:r.trust,role:r.role,sign:r.role==="contradicting"?-1:1})):[],a=new Map(h.map(r=>[r.id,r])),_=(t.contradictions??[]).map(r=>{const p=a.get(r.stronger.id),b=a.get(r.weaker.id);return!p||!b?null:{ax:p.x,ay:p.y,bx:b.x,by:b.y,strength:Math.max(.35,r.topic_overlap||.5)}}).filter(r=>r!==null),E=(t.superseded??[]).map(r=>{const p=a.get(r.id);return p?{x:p.x,y:p.y,toX:(i==null?void 0:i.x)??z[Ae],toY:(i==null?void 0:i.y)??xe}:null}).filter(r=>r!==null);return{query:e,gates:s,evidence:h,ribbons:d,nucleus:i,fringes:_,scars:E,receiptX:z[rt],sourceCount:((l=t.evidence)==null?void 0:l.length)??0}}const dt=` -struct Params { - frame: f32, loopPhase: f32, nodeCount: f32, edgeCount: f32, - pathCount: f32, pulse: f32, viewportW: f32, viewportH: f32, - brightness: f32, demoId: f32, time: f32, captureMode: f32, - liveKind: f32, liveFrame: f32, liveEnergy: f32, projectionDays: f32, - cursorX: f32, cursorY: f32, cursorVx: f32, cursorVy: f32, -}; - -// Instance record (12 floats) — mirrors reasoning-geometry-pass INSTANCE_FLOATS. -struct Inst { - a: vec2f, // endpoint A / center (NDC) - b: vec2f, // endpoint B (== a for points) - kind: f32, // 0 beam, 1 ribbon, 2 nucleus, 3 fringe, 4 scar - thickness: f32, // NDC half-width - trust: f32, // 0..1 - sign: f32, // +1 support / -1 oppose - energy: f32, // 0..1 - seed: f32, // per-instance phase - extra: f32, // kind-specific (fringe strength / nucleus confidence) - pad: f32, -}; - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var insts: array; - -const TAU: f32 = 6.28318530718; -const QUAD = array( - vec2f(0.0, 0.0), vec2f(1.0, 0.0), vec2f(1.0, 1.0), - vec2f(0.0, 0.0), vec2f(1.0, 1.0), vec2f(0.0, 1.0) -); - -struct VSOut { - @builtin(position) clip: vec4f, - @location(0) world: vec2f, // NDC position of this fragment - @location(1) @interpolate(flat) idx: u32, -}; - -fn aspect() -> f32 { return max(0.0001, params.viewportW / max(1.0, params.viewportH)); } - -// smoothstep-based value-suppressing palette (Correll/Moritz/Heer): low trust → -// neutral grey (never jitter), high trust → vivid. base is the category hue. -fn vsup(base: vec3f, trust: f32) -> vec3f { - let s = smoothstep(0.0, 1.0, clamp(trust, 0.0, 1.0)); - let neutral = vec3f(0.42, 0.46, 0.52); - let bright = 0.72 + 0.28 * s; - return mix(neutral, base, s) * bright; -} - -// PRGn-style diverging hue by signed influence: + = green (support), − = purple -// (oppose). |mag| drives saturation; zero-point kept off pure white. -fn prgn(sign: f32, mag: f32) -> vec3f { - let green = vec3f(0.0, 0.85, 0.45); - let purple = vec3f(0.55, 0.15, 0.75); - let base = select(purple, green, sign >= 0.0); - return mix(vec3f(0.35, 0.37, 0.4), base, clamp(mag, 0.0, 1.0)); -} - -@vertex -fn vs_geo(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - var out: VSOut; - let inst = insts[ii]; - let corner = QUAD[vi]; - let asp = aspect(); - - // Bounding quad: for line-like kinds (beam/ribbon/scar/fringe) expand along - // the A→B segment plus thickness on the perpendicular; for point kinds - // (nucleus) a square of side 2*thickness around A. - var pos: vec2f; - let is_point = inst.kind == 2.0; - if (is_point) { - let r = inst.thickness + 0.04; // padding for glow/rings - pos = inst.a + (corner - vec2f(0.5)) * (2.0 * r); - } else { - let dir = inst.b - inst.a; - let len = max(1e-4, length(dir)); - let t_hat = dir / len; - let n_hat = vec2f(-t_hat.y, t_hat.x); - let half_w = inst.thickness + 0.03; // padding for AA/glow - // corner.x runs along the segment (0..1), corner.y across (-1..1) - let along = corner.x; - let across = (corner.y - 0.5) * 2.0; - pos = inst.a + t_hat * (along * len) + n_hat * (across * half_w); - } - - // aspect-correct so circles stay round (mirror the text pass convention). - var clip = pos; - clip.x = clip.x / max(asp, 1.0); - clip.y = clip.y * min(asp, 1.0); - out.clip = vec4f(clip, 0.0, 1.0); - out.world = pos; - out.idx = ii; - return out; -} - -// ── Per-kind SDF shading. Each returns premultiplied additive HDR rgb. ──────── -// FLEET: fill these five. Each is a PURE function of (inst, p, t) → vec3f. Keep -// them deterministic (use params.time via t), additive (return black to skip a -// pixel), and honest (brightness ∝ the real trust/energy/confidence fields). - -fn shade_beam(inst: Inst, p: vec2f, t: f32) -> vec3f { - // BEAM: a bright emissive causal line A→B along y with a flowing pulse. - let d = sdf_segment(p, inst.a, inst.b); - let core = smoothstep(inst.thickness, 0.0, d); - let glow = smoothstep(inst.thickness * 4.0, 0.0, d) * 0.35; - // flow pulse travelling toward the decision (left→right) - let along = clamp((p.x - inst.a.x) / max(1e-4, inst.b.x - inst.a.x), 0.0, 1.0); - let flow = 0.5 + 0.5 * sin(along * 18.0 - t * 3.0); - let cyan = vec3f(0.0, 0.96, 0.83); - return cyan * inst.energy * (core * (0.6 + 0.6 * flow) + glow); -} - -fn shade_ribbon(inst: Inst, p: vec2f, t: f32) -> vec3f { - // RIBBON: tapered (wide at nucleus, narrow at source), UV-scroll flow toward - // the decision, head-bright opacity gradient, PRGn hue by sign. - let along = clamp(dot(p - inst.a, inst.b - inst.a) / max(1e-6, dot(inst.b - inst.a, inst.b - inst.a)), 0.0, 1.0); - let d = sdf_segment(p, inst.a, inst.b); - let taper = inst.thickness * mix(0.35, 1.0, along); // widen toward B (nucleus) - let core = smoothstep(taper, 0.0, d); - // flowing dashes travelling A→B (causal direction) - let flow = 0.5 + 0.5 * sin(along * 26.0 - t * 4.0 - inst.seed); - let headBright = mix(0.35, 1.0, along); // brighter toward the decision head - let hue = prgn(inst.sign, inst.trust); - return hue * inst.energy * core * flow * headBright; -} - -fn shade_nucleus(inst: Inst, p: vec2f, t: f32) -> vec3f { - // NUCLEUS: recommendation core; stability = confidence. Coherent (tight solid - // rings) when confident, scattered/soft when not. Confidence in inst.extra. - let c = inst.extra; - let r = length(p - inst.a); - let coherence = smoothstep(0.0, 1.0, c); - let coreR = inst.thickness * (0.5 + 0.3 * c); - let core = smoothstep(coreR, 0.0, r); - // 1..4 concentric rings, more + tighter as confidence rises - let ringCount = 1.0 + floor(c * 3.0); - let ringPhase = r / max(1e-4, inst.thickness) * ringCount * TAU; - let ring = pow(max(0.0, sin(ringPhase - t * 1.5)), 6.0) * smoothstep(inst.thickness * 1.6, inst.thickness * 0.4, r) * coherence; - let hot = vec3f(0.91, 1.0, 0.72); - return vsup(hot, c) * (core * 1.4 + ring * 0.8); -} - -fn shade_fringe(inst: Inst, p: vec2f, t: f32) -> vec3f { - // FRINGE: two-source interference between contradicting evidence a,b. Scarlet - // standing wave (cos^2) that breathes; reads as "these two conflict". - let r1 = distance(p, inst.a); - let r2 = distance(p, inst.b); - let lambda = 0.05; - let phase = TAU * (r1 - r2) / lambda - t * 2.0; - let fr = cos(phase * 0.5); - let intensity = fr * fr; - // confine the fringe to the region BETWEEN the two sources - let mid = (inst.a + inst.b) * 0.5; - let span = distance(inst.a, inst.b) * 0.6 + 0.06; - let mask = smoothstep(span, span * 0.4, distance(p, mid)); - let scarlet = vec3f(0.95, 0.08, 0.14); - return scarlet * intensity * mask * inst.extra; -} - -fn shade_scar(inst: Inst, p: vec2f, t: f32) -> vec3f { - // SCAR: superseded evidence leaves a dim etched mark at A, with an AMBER - // transfer filament flowing A→B (into the replacement). - let dScar = sdf_segment(p, inst.a - vec2f(0.02, 0.0), inst.a + vec2f(0.02, 0.0)); - let scar = smoothstep(0.006, 0.0, dScar) * 0.5; - let dFil = sdf_segment(p, inst.a, inst.b); - let along = clamp(dot(p - inst.a, inst.b - inst.a) / max(1e-6, dot(inst.b - inst.a, inst.b - inst.a)), 0.0, 1.0); - let flow = 0.5 + 0.5 * sin(along * 20.0 - t * 3.5); - let fil = smoothstep(inst.thickness * 0.6, 0.0, dFil) * flow * (1.0 - along * 0.4); - let amber = vec3f(1.0, 0.82, 0.4); - let ash = vec3f(0.45, 0.4, 0.38); - return ash * scar + amber * fil * 0.7; -} - -// segment SDF helper -fn sdf_segment(p: vec2f, a: vec2f, b: vec2f) -> f32 { - let pa = p - a; - let ba = b - a; - let h = clamp(dot(pa, ba) / max(1e-6, dot(ba, ba)), 0.0, 1.0); - return length(pa - ba * h); -} - -@fragment -fn fs_geo(in: VSOut) -> @location(0) vec4f { - let inst = insts[in.idx]; - let p = in.world; - let t = params.time; - var rgb = vec3f(0.0); - let k = inst.kind; - if (k == 0.0) { rgb = shade_beam(inst, p, t); } - else if (k == 1.0) { rgb = shade_ribbon(inst, p, t); } - else if (k == 2.0) { rgb = shade_nucleus(inst, p, t); } - else if (k == 3.0) { rgb = shade_fringe(inst, p, t); } - else if (k == 4.0) { rgb = shade_scar(inst, p, t); } - rgb = rgb * params.brightness; - // additive: alpha carries nothing; premultiplied rgb is the contribution. - return vec4f(rgb, 1.0); -} -`,ie=12,he=512,j={beam:0,ribbon:1,nucleus:2,fringe:3,scar:4};class ut{constructor(e){R(this,"engine");R(this,"layout",null);R(this,"pipeline",null);R(this,"bindGroup",null);R(this,"instanceBuffer",null);R(this,"instanceCount",0);R(this,"ready",!1);this.engine=e}uploadScene(e){this.layout=(e==null?void 0:e.organ)==="reasoning"?lt(e):null,this.ensurePipeline(),this.uploadInstances()}ensurePipeline(){if(this.pipeline||this.ready)return;const e=this.engine.gpuDevice;if(!e||!this.engine.paramsBuffer)return;this.ready=!0,this.instanceBuffer=e.createBuffer({label:"reasoning-geometry-instances",size:he*ie*4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST});const s=e.createShaderModule({label:"reasoning-geometry-wgsl",code:dt}),u=e.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"read-only-storage"}}]});this.bindGroup=e.createBindGroup({layout:u,entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.instanceBuffer}}]});const h={color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}};this.pipeline=e.createRenderPipeline({label:"reasoning-geometry-pipeline",layout:e.createPipelineLayout({bindGroupLayouts:[u]}),vertex:{module:s,entryPoint:"vs_geo"},fragment:{module:s,entryPoint:"fs_geo",targets:[{format:this.engine.sceneFormat,blend:h}]},primitive:{topology:"triangle-list"}})}uploadInstances(){const e=this.engine.gpuDevice;if(!e||!this.instanceBuffer)return;const s=this.layout;if(!s){this.instanceCount=0;return}const u=new Float32Array(he*ie);let h=0;const i=d=>{h>=he||(u.set(d,h*ie),h++)};for(let d=0;d{const e=Ke(t);return[e[0],e[1],e[2]]},ve=H("#00F5D4"),Re=H("#9DFFEB"),ft=H("#FF3B30"),ht=H("#FFD166"),ae=H("#E9FFB7"),Y=[.42,.46,.52],me=H("#6B7A88"),B=[-.86,-.526,-.214,.074,.335,.562,.747,.86],D=0,mt=["INTENT","RETRIEVE","ACTIVATE","EVIDENCE","CHALLENGE","SYNTH","DECIDE","SEAL"],gt={primary:.04,supporting:.24,contradicting:-.22,superseded:-.48},Se=.052,oe=6,vt=t=>t*t*(3-2*t);function ge(t,e){const s=vt(Math.max(0,Math.min(1,e))),u=.72+.28*s,h=(Y[0]+(t[0]-Y[0])*s)*u,i=(Y[1]+(t[1]-Y[1])*s)*u,d=(Y[2]+(t[2]-Y[2])*s)*u,a=.4+.6*s;return[Math.min(1,h),Math.min(1,i),Math.min(1,d),a]}function ke(t){switch(t){case"primary":return ve;case"supporting":return Re;case"contradicting":return ft;case"superseded":return ht}}function Q(t){return t.replace(/[—–]/g,"-").replace(/[‘’]/g,"'").replace(/[“”]/g,'"').replace(/…/g,"...").replace(/[^\x20-\x7E]/g,"?")}const I=-1e5;class yt{constructor(e){R(this,"text");R(this,"scene",null);R(this,"ready",!1);R(this,"initPromise",null);this.text=new qe(e)}uploadScene(e){this.scene=(e==null?void 0:e.organ)==="reasoning"?e:null,this.ensureReady().then(()=>this.text.setText(this.build()))}render(e){this.text.render(e)}pickAt(e,s){return this.text.pickAt(e,s)}dispose(){this.text.dispose()}async ensureReady(){this.initPromise||(this.initPromise=this.text.init().then(()=>void(this.ready=!0))),await this.initPromise}build(){var a,_,E;const e=this.scene;if(!e||!e.alive)return[];const s=[],u=Q(String(((a=e.raw)==null?void 0:a.query)??"")).slice(0,60);s.push({id:"trace:query",kind:"trace-query",text:u?`> ${u}`:"> (trace)",x:-.94,y:.82,size:.03,color:[...ae,1],weight:.95,depth:1,startFrame:I,revealSpan:1,maxWidthEm:60});const h=e.stages??[];for(let c=0;c{const x=r+(k-(p.length-1)/2)*Se,S=Q(b.preview).replace(/\s+/g," ").trim().slice(0,46);s.push({id:`trace:ev:${b.id}`,kind:"trace-evidence",text:`${S} · ${Math.round(b.trust*100)}%`,x:B[3]-.02,y:x,size:.016,color:ge(ke(c),b.trust),weight:.4+.5*b.trust,depth:.6+.4*b.trust,startFrame:I,revealSpan:1,maxWidthEm:52,hitPadX:.03,hitPadY:.02,ariaLabel:`${c} evidence, trust ${Math.round(b.trust*100)}%: ${S}`,preview:S})}),l.length>oe&&s.push({id:`trace:super:${c}`,kind:"trace-supernode",text:`+${l.length-oe} more ${c}`,x:B[3]-.02,y:r-(oe/2+1)*Se,size:.014,color:[...me,.7],depth:.6,startFrame:I,revealSpan:1,maxWidthEm:30}),s.push({id:`trace:lanelabel:${c}`,kind:"trace-hud",text:c.toUpperCase(),x:B[3]-.16,y:r,size:.013,color:[...ke(c),.55],depth:.7,startFrame:I,revealSpan:1,maxWidthEm:14})}if(e.recommended){const c=Math.max(0,Math.min(1,e.recommended.trust_score)),l=Q(e.recommended.answer_preview).replace(/\s+/g," ").trim().slice(0,48),r=B[6],p=c>=.6;s.push({id:"trace:nucleus",kind:"trace-recommendation",text:p?"O":"o",x:r,y:D,size:.05+.05*c,color:ge(ae,c),weight:.6+.4*c,depth:1,startFrame:I,revealSpan:1,maxWidthEm:4,hitPadX:.06,hitPadY:.06,ariaLabel:`Recommendation, ${Math.round(c*100)}% confidence: ${l}`,preview:l}),s.push({id:"trace:reclabel",kind:"trace-hud",text:`${p?"LOCKED":"OPEN"} · ${Math.round(c*100)}%`,x:r-.05,y:D-.11,size:.016,color:ge(ae,c),depth:1,startFrame:I,revealSpan:1,maxWidthEm:18}),s.push({id:"trace:answer",kind:"trace-hud",text:l,x:r-.28,y:D-.17,size:.016,color:[...ae,.92],depth:.95,startFrame:I,revealSpan:1,maxWidthEm:44,maxLines:2})}const d=((_=e.evidence)==null?void 0:_.length)??0;return s.push({id:"trace:receipt",kind:"trace-receipt",text:`[ ${d} SOURCES SEALED ]`,x:B[7]-.14,y:D-.07,size:.015,color:[...Re,.85],depth:.9,startFrame:I,revealSpan:1,maxWidthEm:24,hitPadX:.05,hitPadY:.04,ariaLabel:`Composition receipt: ${d} sources, analysed ${((E=e.raw)==null?void 0:E.memoriesAnalyzed)??d} memories`}),s}}function bt(t,e){return[pt(t),new yt(t)]}var _t=ye(""),wt=ye('
      '),Et=ye('
      ',1);function Ft(t,e){Pe(e,!0);let s=W(""),u=W(!1),h=W(null),i=W(null),d=W(null),a=W(null),_=null,E=[];function c(){const o=v(i);if(!o||(o.evidence??[]).length===0){const g=E.map((w,n)=>({id:w.id||`rest:${n}`,score:.25+.4*l(w.trust??.5),hue:fe.bridge,energy:.14+.26*l(w.trust??.5),metric2:l(w.trust??.5),kind:"reasoning-rest",payload:w}));return Ee(g,{maxRadius:.9,minCellR:.014,maxCellR:.045})}const f=new Set((o.contradictions??[]).flatMap(g=>{var w,n;return[(w=g.stronger)==null?void 0:w.id,(n=g.weaker)==null?void 0:n.id]}).filter(Boolean)),m=(o.evidence??[]).map((g,w)=>{var n;return{id:g.id||`evidence:${w}`,score:.4+.6*l(g.trust??.5),hue:f.has(g.id)?fe.scarlet:fe.forward,energy:.45+.55*l(g.trust??.5),metric2:l(g.trust??.5),scar:f.has(g.id),selected:g.id===((n=o.recommended)==null?void 0:n.memory_id),kind:"reasoning-evidence",payload:g}});return Ee(m,{maxRadius:.9,minCellR:.016,maxCellR:.06})}function l(o){return Math.min(1,Math.max(0,Number.isFinite(o)?o:.5))}function r(o,f){const m=new je(o);return _=m,m.setCells(c()),[{compute:w=>m.compute(w),render:w=>m.render(w),dispose:()=>{m.dispose(),_===m&&(_=null)}},...bt(o)]}Me(()=>{var o;(o=v(i))==null||o.evidence.length,_==null||_.setCells(c())});const p=["What port does the dev server use?","Should I enable prefix caching with vLLM?","How does FSRS-6 trust scoring work?","Why did the benchmark score drop after the parser change?"];async function b(){const o=v(s).trim();if(!(!o||v(u))){N(u,!0),N(h,null),N(i,null),N(d,null);try{const f=await we.deepReference(o,20);N(i,et(f),!0)}catch(f){N(h,f instanceof Error?f.message:"Unknown error",!0)}finally{N(u,!1)}}}const k=_e(()=>{var m,g;if(v(u))return"Reasoning in progress.";if(v(h))return`Error: ${v(h)}`;if(!v(i))return"Ask a question to trace how Vestige forms a decision from memory.";const o=v(i),f=((m=o.recommended)==null?void 0:m.answer_preview)??"no recommendation";return`Decision trace for "${v(s)}". ${o.evidence.length} evidence memories, ${o.contradictions.length} contradiction${o.contradictions.length===1?"":"s"}, ${o.superseded.length} superseded. Recommendation: ${f}. Confidence ${Math.round((((g=o.recommended)==null?void 0:g.trust_score)??0)*100)} percent.`});function x(o){const f=o.payload;N(d,(f==null?void 0:f.ariaLabel)??(f==null?void 0:f.preview)??`${o.kind} selected`,!0)}function S(o){var f,m;(o.metaKey||o.ctrlKey)&&o.key.toLowerCase()==="k"&&(o.preventDefault(),(f=v(a))==null||f.focus(),(m=v(a))==null||m.select())}$e(()=>{var o;return(o=v(a))==null||o.focus(),window.addEventListener("keydown",S),we.memories.list({limit:"80"}).then(f=>{E=f.memories.map((m,g)=>{const w=l(m.retentionStrength);return{id:m.id||`rest:${g}`,trust:.35+.4*w,date:"",role:"supporting",preview:""}}),_==null||_.setCells(c())}).catch(()=>{}),()=>window.removeEventListener("keydown",S)});var C=Et();Ve("q2v96u",o=>{Be(()=>{De.title="Reasoning Theater · Vestige"})});var T=Le(C);{let o=_e(()=>`reasoning-trace:${v(s)||"empty"}`);He(T,{organ:"reasoning",get seed(){return v(o)},get scene(){return v(i)},passes:r,get loading(){return v(u)},get error(){return v(h)},emptyLabel:"ASK A QUESTION - PRESS CMD+K - WATCH THE DECISION FORM",onpick:x})}var M=q(T,2),G=q(pe(M),2);We(G),Ue(G,o=>N(a,o),()=>v(a));var ee=q(G,2);Xe(ee,21,()=>p,Ye,(o,f)=>{var m=_t(),g={};de(()=>{g!==(g=v(f))&&(m.value=(m.__value=v(f))??"")}),ue(o,m)}),se(ee),Ge(2),se(M);var U=q(M,2),te=pe(U,!0);se(U);var $=q(U,2);{var ce=o=>{var f=wt(),m=pe(f,!0);se(f),de(()=>be(m,v(d))),ue(o,f)};Oe($,o=>{v(d)&&o(ce)})}de(()=>be(te,v(k))),Ne("submit",M,o=>{o.preventDefault(),b()}),ze(G,()=>v(s),o=>N(s,o)),ue(t,C),Fe()}export{Ft as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/20.DD0_N4PP.js.br b/apps/dashboard/build/_app/immutable/nodes/20.DD0_N4PP.js.br deleted file mode 100644 index 392e744..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/20.DD0_N4PP.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/20.DD0_N4PP.js.gz b/apps/dashboard/build/_app/immutable/nodes/20.DD0_N4PP.js.gz deleted file mode 100644 index d442625..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/20.DD0_N4PP.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/21.yCKOHF-q.js b/apps/dashboard/build/_app/immutable/nodes/21.yCKOHF-q.js deleted file mode 100644 index 6ada92d..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/21.yCKOHF-q.js +++ /dev/null @@ -1 +0,0 @@ -var z=Object.defineProperty;var X=(l,c,d)=>c in l?z(l,c,{enumerable:!0,configurable:!0,writable:!0,value:d}):l[c]=d;var x=(l,c,d)=>X(l,typeof c!="symbol"?c+"":c,d);import"../chunks/Bzak7iHL.js";import{o as j}from"../chunks/DAau0uzT.js";import{p as q,d as y,e as G,b as J,g as i,s as o,u as E}from"../chunks/CGq8RnJq.js";import{R as K,e as Q}from"../chunks/BpEKQwpr.js";import{a as A}from"../chunks/D35IQVqe.js";import{r as T}from"../chunks/BMB5u1EX.js";import{T as Z}from"../chunks/D7ozXiSB.js";import{L as ee,F,a as te}from"../chunks/DETSv_kY.js";function de(l,c){q(c,!0);const d=[...T("#22C7DE"),1],D=[...T("#FFB000"),.9],v=[...T("#FF3B30"),.92],N=2e3,I=40,b=200,M=16;let a=y(G([])),S=y(!0),h=y(null);j(()=>{C()});async function C(){o(S,!0),o(h,null);try{const e=await A.memories.list({limit:String(N)});o(a,await L(e.memories),!0)}catch(e){o(a,[],!0),o(h,e instanceof Error?e.message:"API FETCH FAILED",!0)}finally{o(S,!1)}}async function L(e){const t=e.slice(),r=t.map((n,s)=>({memory:n,index:s})).filter(({memory:n})=>!n.nextReviewAt).slice(0,b);for(let n=0;n{try{const W=await A.memories.get(u.id);t[V]={...u,...W}}catch{}}))}return t}function R(e){return e.replace(/[\u2014\u2013]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u2026/g,"...").replace(/[^\x20-\x7E]/g,"?")}function p(e){return Math.min(1,Math.max(0,Number.isFinite(e)?e:.5))}function m(e){const t=e.nextReviewAt?Date.parse(e.nextReviewAt):Number.POSITIVE_INFINITY;return Number.isFinite(t)?t:Number.POSITIVE_INFINITY}function f(e,t){const r=m(e);if(!Number.isFinite(r))return 0;const n=(r-t)/864e5;return p(1-n/30)}function P(e,t){const r=R(e.content).replace(/\s+/g," ").trim().slice(0,48),n=m(e),s=Number.isFinite(n)?Math.ceil((n-t)/864e5):9999,u=s<0?`${Math.abs(s)}D OVER`:s===0?"DUE 0D":`DUE ${s}D`;return R(`${r} | ${e.id.slice(0,8)} | ${u} | ${Math.round(e.retentionStrength*100)}%`)}function _(e){const t=Date.now();return e.filter(r=>!!r.nextReviewAt).slice().sort((r,n)=>{const s=m(r)-m(n);return s!==0?s:(r.retentionStrength??0)-(n.retentionStrength??0)}).sort((r,n)=>f(n,t)-f(r,t))}const g=E(()=>_(i(a))),$=E(()=>i(g).length===0?Q("schedule"):{organ:"schedule",nodes:i(g).slice(0,I).map((e,t)=>({source:{kind:"memory",id:e.id},index:t,label:P(e,Date.now()),retention:p(e.retentionStrength),stability:p(e.retrievalStrength),lastAccessed:e.lastAccessedAt,activation:f(e,Date.now()),tags:e.tags,type:e.nodeType})),edges:[],events:[],receipts:[],scalars:{scheduled:i(g).length,loaded:i(a).length,dueNow:i(g).filter(e=>f(e,Date.now())>=1).length},alive:!0}),O=E(()=>i(a).length===0?"0 MEMORIES LOADED":`${i(a).length} MEMORIES / 0 REVIEW TIMESTAMPS`);function w(e){const r=1.52/Math.max(1,I-1);return e.nodes.slice(0,I).map((n,s)=>({id:`schedule:${n.source.id}`,kind:"schedule-memory",memoryId:n.source.id,text:R(n.label),x:-.9,y:.74-s*r,size:.026,color:k(n.activation??0,n.retention),depth:p(.62+(n.activation??0)*.38),weight:p(n.retention),startFrame:-1e5,revealSpan:1,maxWidthEm:54,hitPadX:.03,hitPadY:.014}))}function k(e,t){return t<.4?v:t<.7?D:d}class H{constructor(t,r){x(this,"text");x(this,"current");this.current=r,this.text=new Z(t),this.text.setText(w(this.current)),this.text.init().then(()=>this.text.setText(w(this.current)))}uploadScene(t){this.current=t,this.text.setText(w(this.current))}render(t){this.text.render(t)}pickAt(t,r){return this.text.pickAt(t,r)}dispose(){this.text.dispose()}}class Y{constructor(t){x(this,"field");this.field=new ee(t)}uploadScene(t){const r=t.nodes.map(n=>({id:n.source.id,score:n.activation??0,hue:n.retention<.4?F.scarlet:n.retention<.7?F.caution:F.oxygen,energy:n.activation,metric2:n.retention,scar:(n.activation??0)>=1,kind:"schedule-memory",payload:n}));this.field.setCells(te(r,n=>n.score>=1?0:n.score>=.75?1:n.score>=.5?2:3,{ringCount:4,maxRadius:.88,minCellR:.045,maxCellR:.11}))}compute(t){this.field.compute(t)}render(t){this.field.render(t)}pickAt(t,r){return this.field.pickAt(t,r)}dispose(){this.field.dispose()}}function B(e,t){const r=new Y(e);return r.uploadScene(t),[r,new H(e,t)]}async function U(e){var n;if(e.kind!=="schedule-memory")return;const t=e.payload,r=t.memoryId??((n=t.source)==null?void 0:n.id);if(r)try{const s=await A.memories.promote(r);o(a,i(a).map(u=>u.id===s.id?{...u,retentionStrength:s.retentionStrength}:u),!0),o(h,null)}catch(s){o(h,s instanceof Error?s.message:"PROMOTE FAILED",!0)}}{let e=E(()=>`schedule-due-field:${i(g).length}:${i(a).length}`);K(l,{organ:"schedule",get seed(){return i(e)},get scene(){return i($)},passes:B,get loading(){return i(S)},get error(){return i(h)},get emptyLabel(){return i(O)},onpick:U})}J()}export{de as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/21.yCKOHF-q.js.br b/apps/dashboard/build/_app/immutable/nodes/21.yCKOHF-q.js.br deleted file mode 100644 index 9f6350b..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/21.yCKOHF-q.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/21.yCKOHF-q.js.gz b/apps/dashboard/build/_app/immutable/nodes/21.yCKOHF-q.js.gz deleted file mode 100644 index aeaf200..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/21.yCKOHF-q.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/22.kK1AQf2j.js b/apps/dashboard/build/_app/immutable/nodes/22.kK1AQf2j.js deleted file mode 100644 index b284a64..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/22.kK1AQf2j.js +++ /dev/null @@ -1 +0,0 @@ -var It=Object.defineProperty;var Tt=(R,h,m)=>h in R?It(R,h,{enumerable:!0,configurable:!0,writable:!0,value:m}):R[h]=m;var G=(R,h,m)=>Tt(R,typeof h!="symbol"?h+"":h,m);import"../chunks/Bzak7iHL.js";import{o as Ct}from"../chunks/DAau0uzT.js";import{p as Nt,j as At,g as e,b as vt,d as f,u as tt,s as i,k as Dt}from"../chunks/CGq8RnJq.js";import{a as Lt,s as Mt}from"../chunks/DV6OI5iy.js";import{R as Ot}from"../chunks/BpEKQwpr.js";import{r as N,C as $t,V as yt,R as et,I as st}from"../chunks/BMB5u1EX.js";import{T as bt}from"../chunks/D7ozXiSB.js";import{L as xt,F as V,l as Pt}from"../chunks/DETSv_kY.js";import{a as w}from"../chunks/D35IQVqe.js";import{w as Gt,a as wt}from"../chunks/Ch9vNiEl.js";function zt(R,h){Nt(h,!0);const m=()=>Lt(wt,"$isConnected",nt),[nt,it]=Mt(),F=[...N($t.forward),1],p=[...N(yt.throughput),.98],I=[...N(et.luciferin),1],A=[...N(et.recall),.98],v=[...N(st.caution),.98],H=[...N(st.veto),.98],_=-1e5,B=1,ot=.95,Y=["fact","concept","pattern","decision","person","place"];let E=f(null),$=f(null),D=f(null),L=f(null),u=f(null),U=f(0),d=f("READY"),y=f(!0),T=null;const at=tt(()=>{var t,s,n;return{organ:"settings",nodes:[],edges:[],events:[],receipts:[],scalars:{memories:((t=e(E))==null?void 0:t.totalMemories)??0,retention:((s=e(E))==null?void 0:s.averageRetention)??0,coverage:((n=e(E))==null?void 0:n.embeddingCoverage)??0},alive:!0}});let C=null;At(()=>{e(E),e($),e(D),e(L),e(u),m(),e(d),e(y),T==null||T.refresh(),C==null||C.setCells(k())});function k(){var n;const t=((n=e($))==null?void 0:n.distribution)??[],s=[];return t.forEach((c,r)=>{const a=(r+.5)/Math.max(1,t.length),M=Math.min(60,Math.ceil(c.count/8));for(let S=0;S.66?V.oxygen:a>.33?V.healthy:V.debt,energy:.3+.6*a,metric2:a,scar:a<.2,kind:"settings-tissue",payload:{band:`${r*10}%`,count:c.count}})}),Pt(s,{maxRadius:.96,minCellR:.01,maxCellR:.04})}Ct(()=>{b()});async function b(){i(y,!0);try{const[t,s]=await Promise.all([w.stats().catch(()=>null),w.retentionDistribution().catch(()=>null)]);i(E,t,!0),i($,s,!0)}finally{i(y,!1)}}async function rt(t){if(!e(u))switch(t.id){case"settings:action:consolidate":await ct();break;case"settings:action:dream":await lt();break;case"settings:action:birth":ut();break;case"settings:action:refresh":await Et();break}}async function ct(){i(u,"consolidate"),i(d,"CONSOLIDATING — FSRS-6 DECAY + MAINTENANCE..."),i(L,null);try{i(D,await w.consolidate(),!0),await b(),i(d,"CONSOLIDATION COMPLETE")}catch(t){i(d,`CONSOLIDATE FAILED - ${t instanceof Error?t.message:String(t)}`.slice(0,64),!0)}finally{i(u,null)}}async function lt(){i(u,"dream"),i(d,"DREAMING — REPLAYING MEMORIES, FINDING CONNECTIONS..."),i(D,null);try{i(L,await w.dream(),!0),await b(),i(d,"DREAM CYCLE COMPLETE")}catch(t){i(d,`DREAM FAILED - ${t instanceof Error?t.message:String(t)}`.slice(0,64),!0)}finally{i(u,null)}}function ut(){const t=Y[e(U)%Y.length];Dt(U),Gt.injectEvent({type:"MemoryCreated",data:{id:`demo-birth-${Date.now()}`,content:`Demo memory #${e(U)} - ${t}`,node_type:t,tags:["demo","v2.3-birth-ritual"],retention:.9}}),i(d,`BIRTH ORB INJECTED - ${t.toUpperCase()} (SEE GRAPH)`)}async function Et(){i(u,"refresh"),i(d,"REFRESHING VITALS...");try{await b(),i(d,"VITALS REFRESHED")}finally{i(u,null)}}function dt(t,s){const n=new xt(t);C=n,n.setCells(k());const c={compute:a=>n.compute(a),render:a=>n.render(a),dispose:()=>{n.dispose(),C===n&&(C=null)}},r=new gt(t);return T=r,r.uploadScene(s),[c,r]}class gt{constructor(s){G(this,"text");G(this,"initPromise",null);G(this,"focused",null);this.text=new bt(s)}uploadScene(s){this.ensureReady().then(()=>this.text.setText(W()))}refresh(){this.ensureReady().then(()=>this.text.setText(W()))}render(s){this.text.render(s)}pickAt(s,n){const c=this.text.pickAt(s,n),r=(c==null?void 0:c.kind)==="settings-action",a=r?c.id:null;return a!==this.focused&&(this.focused=a,this.text.setRunDepth(a,1)),r?c:null}dispose(){this.text.dispose(),T===this&&(T=null)}async ensureReady(){this.initPromise||(this.initPromise=this.text.init()),await this.initPromise}}function W(){var z,X,J,Z,q,Q;const t=[];t.push(o("settings:title","settings-title","SETTINGS & SYSTEM",-.9,.86,.052,I)),t.push(o("settings:subtitle","settings-sub","TUNE THE COGNITIVE ENGINE. WATCH IT BREATHE. RUN THE RITUALS THAT KEEP MEMORY ALIVE.",-.9,.79,.02,p,64));const s=((z=e(E))==null?void 0:z.totalMemories)??0,n=((X=e(E))==null?void 0:X.averageRetention)??0,c=((J=e(E))==null?void 0:J.embeddingCoverage)??0,r=m();t.push(o("settings:v-mem-l","settings-vital","MEMORIES",-.9,.66,.024,p)),t.push(o("settings:v-mem","settings-vital",s.toLocaleString(),-.9,.6,.05,F)),t.push(o("settings:v-ret-l","settings-vital","AVG RETENTION",-.42,.66,.024,p)),t.push(o("settings:v-ret","settings-vital",`${(n*100).toFixed(1)}%`,-.42,.6,.05,ht(n))),t.push(o("settings:v-ws-l","settings-vital","WEBSOCKET",.04,.66,.024,p)),t.push(o("settings:v-ws","settings-vital",r?"ONLINE":"OFFLINE",.04,.6,.05,r?A:H)),t.push(o("settings:v-ver-l","settings-vital","VESTIGE",.5,.66,.024,p)),t.push(o("settings:v-ver","settings-vital",`v${e(E)?"2.2.0":"?"}`,.5,.6,.05,I)),t.push(o("settings:v-cov","settings-vital",`EMBEDDING COVERAGE ${c.toFixed(0)}%`,-.9,.53,.02,p)),t.push(o("settings:hist-h","settings-hist","RETENTION DISTRIBUTION",-.9,.44,.026,I));const a=((Z=e($))==null?void 0:Z.distribution)??[],M=Math.max(1,...a.map(l=>l.count)),S=.38,pt=.05;a.forEach((l,g)=>{const O=S-g*pt,mt=g*10,ft=Math.round(l.count/M*30),Rt="#".repeat(Math.max(l.count>0?1:0,ft)),St=`${String(mt).padStart(3," ")}% ${Rt}`;t.push(o(`settings:hist-${g}`,"settings-hist",St,-.9,O,.02,K(g),60)),t.push(o(`settings:hist-c-${g}`,"settings-hist",l.count.toLocaleString(),.32,O,.02,K(g)))});const P=-.5;if(t.push(x("settings:action:consolidate",e(u)==="consolidate"?"[ CONSOLIDATING... ]":"[ CONSOLIDATE ]",-.9,P,e(u)==="consolidate"?v:F)),t.push(x("settings:action:dream",e(u)==="dream"?"[ DREAMING... ]":"[ DREAM ]",-.36,P,e(u)==="dream"?v:A)),t.push(x("settings:action:birth","[ TRIGGER BIRTH ]",.06,P,I)),t.push(x("settings:action:refresh",e(u)==="refresh"?"[ REFRESHING... ]":"[ REFRESH ]",.56,P,e(u)==="refresh"?v:p)),t.push(o("settings:status","settings-status",`> ${e(d)}`,-.9,-.6,.024,I,72)),e(D)){const l=e(D),g=`PROCESSED ${l.nodesProcessed} DECAYED ${l.decayApplied} EMBEDDED ${l.embeddingsGenerated} MERGED ${l.duplicatesMerged} ${l.durationMs}MS`;t.push(o("settings:res-c","settings-result",g,-.9,-.68,.022,A,72))}if(e(L)){const l=e(L),g=`REPLAYED ${l.memoriesReplayed} CONNECTIONS ${l.connectionsPersisted} INSIGHTS ${((q=l.insights)==null?void 0:q.length)??0}`;t.push(o("settings:res-d","settings-result",g,-.9,-.68,.022,A,72));const O=(Q=l.insights)==null?void 0:Q[0];O&&t.push(o("settings:res-d1","settings-result",`~ ${O.insight}`,-.9,-.74,.02,p,76))}return t.push(o("settings:about","settings-about","RUST + AXUM + SVELTEKIT 2 + SVELTE 5 + WEBGPU | FSRS-6 | NOMIC EMBED v1.5 (256D) | USEARCH HNSW | LOCAL-FIRST, ZERO CLOUD",-.9,-.86,.018,p,88)),t}function o(t,s,n,c,r,a,M,S){return{id:t,kind:s,text:j(n),x:c,y:r,size:a,color:M,depth:ot,weight:.5,startFrame:_,revealSpan:B,maxWidthEm:S}}function x(t,s,n,c,r){return{id:t,kind:"settings-action",text:j(s),x:n,y:c,size:.032,color:r,depth:1,weight:.7,startFrame:_,revealSpan:B,maxWidthEm:40,hitPadX:.03,hitPadY:.05}}function ht(t){return t>.7?A:t>.4?v:H}function K(t){return t<2?H:t<4?v:t<7?F:I}function j(t){return t.replace(/[—–]/g,"-").replace(/[‘’]/g,"'").replace(/[“”]/g,'"').replace(/…/g,"...").replace(/[^\x20-\x7E]/g,"?")}{let t=tt(()=>{var s,n;return`settings-console:${((s=e(E))==null?void 0:s.totalMemories)??0}:${(((n=e(E))==null?void 0:n.averageRetention)??0).toFixed(3)}:${m()}`});Ot(R,{organ:"settings",get seed(){return e(t)},get scene(){return e(at)},passes:dt,get loading(){return e(y)},onpick:rt})}vt(),it()}export{zt as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/22.kK1AQf2j.js.br b/apps/dashboard/build/_app/immutable/nodes/22.kK1AQf2j.js.br deleted file mode 100644 index 81e0e8c..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/22.kK1AQf2j.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/22.kK1AQf2j.js.gz b/apps/dashboard/build/_app/immutable/nodes/22.kK1AQf2j.js.gz deleted file mode 100644 index d33a89e..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/22.kK1AQf2j.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/23.B0dVDPB6.js b/apps/dashboard/build/_app/immutable/nodes/23.B0dVDPB6.js deleted file mode 100644 index cf09203..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/23.B0dVDPB6.js +++ /dev/null @@ -1 +0,0 @@ -var Y=Object.defineProperty;var q=(f,u,m)=>u in f?Y(f,u,{enumerable:!0,configurable:!0,writable:!0,value:m}):f[u]=m;var h=(f,u,m)=>q(f,typeof u!="symbol"?u+"":u,m);import"../chunks/Bzak7iHL.js";import{o as v}from"../chunks/DAau0uzT.js";import{p as B,b as G,g as o,s as a,d as R,u as P}from"../chunks/CGq8RnJq.js";import{R as X}from"../chunks/BpEKQwpr.js";import{r as b,C as J,V as K,R as Q,I as k}from"../chunks/BMB5u1EX.js";import{T as Z}from"../chunks/D7ozXiSB.js";import{L as tt,l as et,F as g}from"../chunks/DETSv_kY.js";import{a as M}from"../chunks/D35IQVqe.js";function dt(f,u){B(u,!0);const m=[...b(J.forward),1],F=[...b(K.throughput),.96],E=[...b(Q.luciferin),.9],A=[...b(k.caution),.88],I=[...b(k.veto),.9];let l=R(null),x=R(!0),y=R(null),C=R(null);const $=P(()=>{const e=o(l)?U(o(l),o(C)):[],t=Object.fromEntries(e.map(n=>[n.metric,n.magnitude]));return{organ:"stats",nodes:[],edges:[],events:[],receipts:e,scalars:t,alive:e.length>0}});v(()=>{L()});async function L(){a(x,!0),a(y,null);try{a(l,await M.stats(),!0)}catch(e){a(l,null),a(y,e instanceof Error?e.message:String(e),!0)}finally{a(x,!1)}}async function T(e){if(e.kind==="stats-vital"){a(x,!0),a(y,null);try{a(C,await M.consolidate(),!0),a(l,await M.stats(),!0)}catch(t){a(y,t instanceof Error?t.message:String(t),!0)}finally{a(x,!1)}}}function V(e,t){const n=new D(e);n.uploadScene(t);const s=new _(e);return s.uploadScene(t),[n,s]}class D{constructor(t){h(this,"field");this.field=new tt(t)}uploadScene(t){const s=t.receipts.map(i=>({id:`stats:${i.metric}`,score:i.magnitude,hue:O(i.metric,i.magnitude),energy:.4+.6*i.magnitude,scar:(i.metric.includes("due")||i.metric.includes("Retention"))&&i.magnitude<.4,kind:"stats-vital",payload:i}));this.field.setCells(et(s,{maxRadius:.86,minCellR:.03,maxCellR:.11}))}compute(t){this.field.compute(t)}render(t){this.field.render(t)}pickAt(t,n){return this.field.pickAt(t,n)}dispose(){this.field.dispose()}}function O(e,t){return e.includes("due")||e.includes("decay")?t>.4?g.caution:g.forward:e.includes("Coverage")||e.includes("Embeddings")?t>.7?g.oxygen:g.bridge:e.includes("Retention")||e.includes("Strength")?t<.4?g.scarlet:g.oxygen:g.recall}class _{constructor(t){h(this,"text");h(this,"initPromise",null);h(this,"scene",null);h(this,"focused",null);this.text=new Z(t)}uploadScene(t){this.scene=t,this.ensureReady().then(()=>this.text.setText(this.buildItems(t)))}render(t){this.text.render(t)}pickAt(t,n){const s=this.text.pickAt(t,n),i=(s==null?void 0:s.id)??null;return i!==this.focused&&(this.focused=i,this.text.setRunDepth(i,1)),s}dispose(){this.text.dispose(),this.scene=null}async ensureReady(){this.initPromise||(this.initPromise=this.text.init()),await this.initPromise}buildItems(t){const n=t.receipts;if(n.length===0)return[];const s=.68,i=1.36/Math.max(1,n.length-1);return n.map((d,r)=>{const c=p(d.magnitude);return{id:`stats:${d.metric}`,kind:"stats-vital",text:d.label,x:-.82,y:s-r*i,size:r<4?.036:.027,color:z(d.metric,c),depth:c,weight:Math.max(.18,Math.sqrt(c)),startFrame:r*2,revealSpan:22,maxWidthEm:48,hitPadX:.03,hitPadY:.03}})}}function U(e,t){const n=Object.entries(e),s=n.map(([,r])=>typeof r=="number"&&Number.isFinite(r)?Math.abs(r):null).filter(r=>r!==null),i=Math.max(1,...s),d=n.map(([r,c],S)=>{const W=N(r,c,i);return w(r,c,W)});if(t)for(const[r,c]of Object.entries(t)){const S=`consolidate.${r}`;d.push(w(S,c,N(S,c,i),d.length))}return d}function w(e,t,n,s){return{source:{kind:"scalar",id:e,scalar:{name:e,value:n}},label:H(`${e} | ${j(e,t)}`),nodeIndices:[],metric:e,rawValue:t,magnitude:p(n)}}function N(e,t,n){if(typeof t=="number"&&Number.isFinite(t))return e.includes("Coverage")?p(t>1?t/100:t):e.includes("average")||e.includes("Retention")||e.includes("Strength")?p(t):p(Math.log10(Math.abs(t)+1)/Math.log10(n+1));if(typeof t=="string"){const s=Date.parse(t);if(Number.isFinite(s)){const i=Math.max(0,(Date.now()-s)/864e5);return p(1/(1+i/30))}return p(t.length/48)}return .5}function j(e,t){return typeof t=="number"&&Number.isFinite(t)?e.includes("Coverage")?`${t.toFixed(t>1?0:2)}%`:e.includes("average")?`${(t*100).toFixed(1)}%`:Number.isInteger(t)?t.toLocaleString():t.toFixed(3):typeof t=="string"?t:String(t)}function z(e,t){return e.includes("due")||e.includes("decay")?t>.4?A:F:e.includes("Coverage")||e.includes("Embeddings")?t>.7?E:m:e.includes("Retention")||e.includes("Strength")?t<.4?I:E:F}function H(e){return e.replace(/[\u2014\u2013]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u2026/g,"...").replace(/[^\x20-\x7E]/g,"?")}function p(e){return Math.min(1,Math.max(0,Number.isFinite(e)?e:.5))}{let e=P(()=>{var t,n,s;return`stats-vitals:${((t=o(l))==null?void 0:t.totalMemories)??0}:${((n=o(l))==null?void 0:n.dueForReview)??0}:${((s=o(l))==null?void 0:s.averageRetention)??0}`});X(f,{organ:"stats",get seed(){return o(e)},get scene(){return o($)},passes:V,get loading(){return o(x)},get error(){return o(y)},onpick:T})}G()}export{dt as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/23.B0dVDPB6.js.br b/apps/dashboard/build/_app/immutable/nodes/23.B0dVDPB6.js.br deleted file mode 100644 index c70e838..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/23.B0dVDPB6.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/23.B0dVDPB6.js.gz b/apps/dashboard/build/_app/immutable/nodes/23.B0dVDPB6.js.gz deleted file mode 100644 index 4e63c55..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/23.B0dVDPB6.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/24.taYcndi3.js b/apps/dashboard/build/_app/immutable/nodes/24.taYcndi3.js deleted file mode 100644 index 5bae681..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/24.taYcndi3.js +++ /dev/null @@ -1,286 +0,0 @@ -var de=Object.defineProperty;var pe=(s,e,t)=>e in s?de(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var w=(s,e,t)=>pe(s,typeof e!="symbol"?e+"":e,t);import"../chunks/Bzak7iHL.js";import{o as me}from"../chunks/DAau0uzT.js";import{p as fe,d as N,e as se,j as he,g as n,b as ge,u as D,h as be,s as A,$ as ve}from"../chunks/CGq8RnJq.js";import{h as ye}from"../chunks/De_e6MzK.js";import{a as le}from"../chunks/D35IQVqe.js";import{r as F,M as xe,R as ae}from"../chunks/BMB5u1EX.js";import{T as Se}from"../chunks/D7ozXiSB.js";import{R as we}from"../chunks/BpEKQwpr.js";const j="rgba16float",K=768,J=96,te=16,ie=12,oe=` -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - capture_mode: f32, - live_kind: f32, - live_frame: f32, - live_energy: f32, - projection_days: f32, -}; - -struct TimelineCellGpu { - // x,y NDC; z cell radius; w ring radius - pos_radius: vec4f, - // x retention, y rewritten, z suppressed, w audit events - signals: vec4f, - // x valid-time phase, y transaction-time phase, z day index, w cell index - time_meta: vec4f, - // x selected, y reserved, z reserved, w reserved - flags: vec4f, -}; - -struct TimelineRingGpu { - // x radius, y count scale, z retention, w day index - shape: vec4f, - // x updated count, y suppressed count, z phase, w selected - activity: vec4f, - // x memory count, y ring index, z reserved, w reserved - // ('meta' is a WGSL reserved keyword — see GOD-TIER §9 / it broke Blackbox too) - stats: vec4f, -}; -`,_e=` -${oe} - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var cells: array; -@group(0) @binding(2) var rings: array; - -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); - -struct VSOut { - @builtin(position) clip: vec4f, - @location(0) uv: vec2f, - @location(1) @interpolate(flat) misc: vec4f, - @location(2) @interpolate(flat) extra: vec4f, -}; - -// Living orbital drift: every cell slowly circulates around the ring center -// (the tree of memory is always turning), plus a per-cell radial breathe. Motion -// is a pure function of params.time + per-cell phase — deterministic, no RNG. -// This is what makes the field MOVE like the Observatory force-sim, not sit still. -// Shared rotation for a given normalized day phase (0 = oldest/outer, 1 = newest/ -// inner). Inner rings turn faster, like the fast core of a spinning galaxy. Cells -// AND their rings both call this so cells stay ON their ring while everything turns. -fn ring_spin(day_phase: f32) -> f32 { - let speed = 0.045 + day_phase * 0.10; - return params.time * speed; -} - -fn orbit(base: vec2f, phase: f32, day_phase: f32, ret: f32) -> vec2f { - let radius = length(base); - if (radius < 0.0001) { return base; } - let ang0 = atan2(base.y, base.x); - // rotate with the ring, plus a tiny per-cell wobble so cells shimmer on the ring - let ang = ang0 + ring_spin(day_phase) + sin(params.time * 0.6 + phase * 6.283) * 0.02; - // radial breathe so the whole tree gently expands/contracts as it turns - let rr = radius * (1.0 + 0.016 * sin(params.time * 1.1 + phase * 6.283)); - return vec2f(cos(ang), sin(ang)) * rr; -} - -@vertex -fn vs_splat(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - let c = cells[ii]; - let corner = QUAD[vi]; - let breathe = 1.0 + 0.10 * sin(params.time * 1.6 + c.time_meta.x * 6.28318); - let r = c.pos_radius.z * breathe * (1.0 + c.flags.x * 1.4); - let center = orbit(c.pos_radius.xy, c.time_meta.w, c.time_meta.x, c.signals.x); - var out: VSOut; - out.clip = vec4f(center + corner * r, 0.0, 1.0); - out.uv = corner; - out.misc = c.signals; - out.extra = c.time_meta; - return out; -} - -@fragment -fn fs_splat(in: VSOut) -> @location(0) vec4f { - let d = length(in.uv); - if (d > 1.0) { discard; } - let retention = clamp(in.misc.x, 0.0, 1.0); - let rewritten = in.misc.y; - let suppressed = in.misc.z; - let audit = clamp(in.misc.w, 0.0, 8.0) / 8.0; - let body = exp(-d*d*3.1) * (0.34 + retention * 0.86); - let seam = rewritten * smoothstep(0.10, 0.0, abs(d - 0.52)) * (0.55 + audit * 0.8); - let scar = suppressed * smoothstep(0.98, 0.68, d); - // .r = valid-time growth density, .g = retention oxygen, .b = transaction-time seam/shadow - return vec4f(body, body * retention, seam + scar * 0.45, 1.0); -} - -@vertex -fn vs_cell(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - let c = cells[ii]; - let corner = QUAD[vi]; - // pulse the cell size with its own heartbeat so cells throb as they orbit - let beat = 1.0 + 0.22 * sin(params.time * 2.3 + c.time_meta.w * 1.7); - let r = c.pos_radius.z * (0.55 + c.flags.x * 0.8) * beat; - let center = orbit(c.pos_radius.xy, c.time_meta.w, c.time_meta.x, c.signals.x); - var out: VSOut; - out.clip = vec4f(center + corner * r, 0.0, 1.0); - out.uv = corner; - out.misc = c.signals; - out.extra = c.time_meta; - return out; -} - -@fragment -fn fs_cell(in: VSOut) -> @location(0) vec4f { - let d = length(in.uv); - if (d > 1.0) { discard; } - let retention = clamp(in.misc.x, 0.0, 1.0); - let rewritten = in.misc.y; - let suppressed = in.misc.z; - let oxygen = vec3f(0.66, 1.0, 0.37); - let amber = vec3f(0.95, 0.55, 0.15); - let indigo = vec3f(0.486, 0.424, 1.0); - let scarlet = vec3f(1.0, 0.23, 0.18); - let core = mix(amber, oxygen, retention); - // Each memory cell is a living bioluminescent organism — pulse by its own phase - // (time_meta.x) so the field twinkles, and push core to HDR so it GLOWS. - let cell_phase = in.extra.x; - let twinkle = 0.6 + 0.8 * (0.5 + 0.5 * sin(params.time * 2.1 + cell_phase * 26.0)); - let body = exp(-d*d*2.7) * (0.55 + retention * 1.7) * twinkle; - let rim = smoothstep(0.98, 0.74, d) * (1.0 - smoothstep(0.74, 0.42, d)); - let seam = smoothstep(0.12, 0.0, abs(d - 0.48)) * rewritten; - let scar = smoothstep(0.16, 0.0, abs(d - 0.76)) * suppressed; - return vec4f(core * body + vec3f(0.91, 1.0, 0.72) * rim * 1.1 + indigo * seam * 1.3 + scarlet * scar * 1.5, 1.0); -} - -@vertex -fn vs_ring(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - let ring = rings[ii]; - let seg = vi / 2u; - let side = f32(vi % 2u) * 2.0 - 1.0; - let t = f32(seg) / 95.0; - // rotate the whole ring with the same galaxy spin the cells use (activity.z = - // normalized ring phase) so cells ride ON their turning ring, alive together. - let angle = t * 6.2831853 + ring_spin(ring.activity.z); - let dir = vec2f(cos(angle), sin(angle)); - let retention = ring.shape.z; - let rewrite = ring.activity.x / max(1.0, ring.stats.x); - let suppressed = ring.activity.y / max(1.0, ring.stats.x); - let thickness = 0.0035 + 0.006 * retention + 0.004 * ring.activity.w; - let ripple = 0.006 * sin(angle * 9.0 + params.time * (0.28 + ring.activity.z)); - let radius = ring.shape.x + side * thickness + ripple * rewrite; - let tx = 0.030 * rewrite; - var out: VSOut; - // Indigo transaction-time shadow: duplicate the ring instance offset by the real rewrite amount. - let indigo_shift = select(0.0, tx, side > 0.0); - out.clip = vec4f(dir * radius + vec2f(indigo_shift, -indigo_shift * 0.42), 0.0, 1.0); - out.uv = vec2f(t, side); - out.misc = vec4f(retention, rewrite, suppressed, ring.activity.w); - out.extra = vec4f(ring.shape.y, ring.shape.w, ring.stats.x, ring.activity.z); - return out; -} - -@fragment -fn fs_ring(in: VSOut) -> @location(0) vec4f { - let retention = clamp(in.misc.x, 0.0, 1.0); - let rewrite = clamp(in.misc.y, 0.0, 1.0); - let suppressed = clamp(in.misc.z, 0.0, 1.0); - let selected = in.misc.w; - let tick = step(0.86, fract(in.uv.x * 24.0)); - let oxygen = vec3f(0.66, 1.0, 0.37); - let amber = vec3f(0.86, 0.42, 0.12); - let indigo = vec3f(0.486, 0.424, 1.0); - let scarlet = vec3f(1.0, 0.23, 0.18); - // Living pulse: each ring breathes with the global breath + a per-ring phase so - // the rings shimmer OUT OF SYNC like a real organism, not one flat pattern. - let phase = in.extra.w; // ring.activity.z packed as phase - let live = 0.55 + 0.65 * (0.5 + 0.5 * sin(params.time * (0.9 + phase * 1.3) + phase * 6.283)); - // HDR brightness (>1) so the enzyme light BLOOMS through the post chain. - var color = mix(amber, oxygen, retention) * (0.5 + 1.5 * retention + 1.1 * selected) * live; - color = color + indigo * rewrite * (1.1 + 0.7 * abs(in.uv.y)); - color = color + scarlet * suppressed * 1.4; - // Bright engraved date ticks flare on selection. - color = color + vec3f(0.91, 1.0, 0.72) * tick * (0.14 + selected * 0.6); - return vec4f(color, 1.0); -} -`,Ge=` -${oe} - -@group(0) @binding(0) var params: Params; -@group(0) @binding(3) var field_sampler: sampler; -@group(0) @binding(4) var field_tex: texture_2d; - -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); - -struct VSOut { @builtin(position) clip: vec4f, @location(0) uv: vec2f }; - -@vertex -fn vs_fullscreen(@builtin(vertex_index) vi: u32) -> VSOut { - var out: VSOut; - let p = QUAD[vi]; - out.clip = vec4f(p, 0.0, 1.0); - out.uv = p * 0.5 + vec2f(0.5); - return out; -} - -@fragment -fn fs_membrane(in: VSOut) -> @location(0) vec4f { - let dims = vec2f(textureDimensions(field_tex, 0)); - let px = 1.0 / max(dims, vec2f(1.0)); - let f = textureSample(field_tex, field_sampler, in.uv); - let left = textureSampleLevel(field_tex, field_sampler, in.uv - vec2f(px.x, 0.0), 0.0); - let right = textureSampleLevel(field_tex, field_sampler, in.uv + vec2f(px.x, 0.0), 0.0); - let down = textureSampleLevel(field_tex, field_sampler, in.uv - vec2f(0.0, px.y), 0.0); - let up = textureSampleLevel(field_tex, field_sampler, in.uv + vec2f(0.0, px.y), 0.0); - let density = clamp(f.r, 0.0, 5.0); - let oxygen = clamp(f.g, 0.0, 5.0); - let seam = clamp(f.b, 0.0, 3.0); - let grad = length(vec2f((right.r + right.g) - (left.r + left.g), (up.r + up.g) - (down.r + down.g))); - let membrane = smoothstep(0.08, 0.70, density) * (1.0 - smoothstep(1.8, 3.8, density)); - let edge = smoothstep(0.01, 0.12, grad) * membrane; - let blackwater = vec3f(0.006, 0.012, 0.014); - let retention = vec3f(0.66, 1.0, 0.37); - let amber = vec3f(0.86, 0.42, 0.12); - let indigo = vec3f(0.486, 0.424, 1.0); - // Metabolic breathing — the whole tissue pulses with the global breath so the - // field reads as ALIVE, not a static print. pulse is 0..1 (params.pulse). - let breath = 0.72 + 0.55 * params.pulse; - var color = blackwater * (0.30 + density * 0.10); - // Oxygen-lit plasma, pushed into HDR (>1) so the post-chain bloom makes it GLOW. - color = color + mix(amber, retention, clamp(oxygen / max(density, 0.001), 0.0, 1.0)) * density * 0.34 * breath; - // Bright enzymatic edge — this is the "wet membrane" rim light; HDR for bloom flare. - color = color + vec3f(0.91, 1.0, 0.72) * edge * (0.85 + 0.5 * params.pulse); - // Indigo transaction-time seams shimmer with the breath. - color = color + indigo * seam * (0.55 + 0.35 * params.pulse); - let vignette = smoothstep(0.98, 0.12, distance(in.uv, vec2f(0.5))); - return vec4f(color * (0.55 + 0.45 * vignette) * params.brightness, 1.0); -} -`,Ae=` -struct BlurDir { dir: vec2f, _pad: vec2f }; -@group(0) @binding(0) var blur_sampler: sampler; -@group(0) @binding(1) var blur_src: texture_2d; -@group(0) @binding(2) var blur_dir: BlurDir; -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); -struct VSOut { @builtin(position) clip: vec4f, @location(0) uv: vec2f }; -@vertex -fn vs_fullscreen(@builtin(vertex_index) vi: u32) -> VSOut { - var out: VSOut; - let p = QUAD[vi]; - out.clip = vec4f(p, 0.0, 1.0); - out.uv = p * 0.5 + vec2f(0.5); - return out; -} -@fragment -fn fs_blur(in: VSOut) -> @location(0) vec4f { - let dims = vec2f(textureDimensions(blur_src, 0)); - let stepv = blur_dir.dir / max(dims, vec2f(1.0)); - var acc = textureSampleLevel(blur_src, blur_sampler, in.uv - stepv * 2.0, 0.0) * 0.06136; - acc = acc + textureSampleLevel(blur_src, blur_sampler, in.uv - stepv, 0.0) * 0.24477; - acc = acc + textureSampleLevel(blur_src, blur_sampler, in.uv, 0.0) * 0.38774; - acc = acc + textureSampleLevel(blur_src, blur_sampler, in.uv + stepv, 0.0) * 0.24477; - acc = acc + textureSampleLevel(blur_src, blur_sampler, in.uv + stepv * 2.0, 0.0) * 0.06136; - return acc; -} -`;class Me{constructor(e,t){w(this,"engine");w(this,"scene",null);w(this,"resources",null);w(this,"sampler",null);w(this,"splatBindLayout",null);w(this,"blurBindLayout",null);w(this,"membraneBindLayout",null);w(this,"splatPipeline",null);w(this,"blurPipeline",null);w(this,"membranePipeline",null);w(this,"cellPipeline",null);w(this,"ringPipeline",null);w(this,"cellCount",0);w(this,"ringCount",0);w(this,"selectedId",null);w(this,"cellGeometry",[]);w(this,"ringGeometry",[]);this.engine=e,this.uploadScene(t)}uploadScene(e){this.scene=e,this.buildGeometry();const t=this.engine.gpuDevice;t&&(this.ensurePipelines(t),this.ensureResources(t),this.uploadBuffers(t))}ensurePipelines(e){if(this.splatPipeline||!this.engine.paramsBuffer)return;const t=re(e,"timeline-growth-rings-splat-wgsl",_e),l=re(e,"timeline-growth-rings-blur-wgsl",Ae),r=re(e,"timeline-growth-rings-membrane-wgsl",Ge);this.splatBindLayout=e.createBindGroupLayout({label:"timeline-growth-rings-splat-bind-layout",entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.VERTEX,buffer:{type:"read-only-storage"}},{binding:2,visibility:GPUShaderStage.VERTEX,buffer:{type:"read-only-storage"}}]}),this.blurBindLayout=e.createBindGroupLayout({label:"timeline-growth-rings-blur-bind-layout",entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:2,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}}]}),this.membraneBindLayout=e.createBindGroupLayout({label:"timeline-growth-rings-membrane-bind-layout",entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:3,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:4,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}}]});const d=e.createPipelineLayout({label:"timeline-growth-rings-splat-layout",bindGroupLayouts:[this.splatBindLayout]}),p=e.createPipelineLayout({label:"timeline-growth-rings-blur-layout",bindGroupLayouts:[this.blurBindLayout]}),v=e.createPipelineLayout({label:"timeline-growth-rings-membrane-layout",bindGroupLayouts:[this.membraneBindLayout]});this.sampler=e.createSampler({magFilter:"linear",minFilter:"linear"}),this.splatPipeline=e.createRenderPipeline({label:"timeline-field-additive-splat",layout:d,vertex:{module:t,entryPoint:"vs_splat"},fragment:{module:t,entryPoint:"fs_splat",targets:[{format:j,blend:{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}}]},primitive:{topology:"triangle-list"}}),this.blurPipeline=e.createRenderPipeline({label:"timeline-field-blur-render-pass",layout:p,vertex:{module:l,entryPoint:"vs_fullscreen"},fragment:{module:l,entryPoint:"fs_blur",targets:[{format:j}]},primitive:{topology:"triangle-list"}});const a={color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}};this.membranePipeline=e.createRenderPipeline({label:"timeline-bitemporal-membrane",layout:v,vertex:{module:r,entryPoint:"vs_fullscreen"},fragment:{module:r,entryPoint:"fs_membrane",targets:[{format:this.engine.sceneFormat,blend:a}]},primitive:{topology:"triangle-list"}}),this.ringPipeline=e.createRenderPipeline({label:"timeline-valid-time-rings",layout:d,vertex:{module:t,entryPoint:"vs_ring"},fragment:{module:t,entryPoint:"fs_ring",targets:[{format:this.engine.sceneFormat,blend:a}]},primitive:{topology:"triangle-strip"}}),this.cellPipeline=e.createRenderPipeline({label:"timeline-memory-cells",layout:d,vertex:{module:t,entryPoint:"vs_cell"},fragment:{module:t,entryPoint:"fs_cell",targets:[{format:this.engine.sceneFormat,blend:a}]},primitive:{topology:"triangle-list"}})}ensureResources(e){var R,C,I,V,k,H;if(!this.splatBindLayout||!this.blurBindLayout||!this.membraneBindLayout||!this.engine.paramsBuffer||!this.sampler)return;const t=Math.max(16,Math.floor((this.engine.params[6]||1280)/2)),l=Math.max(16,Math.floor((this.engine.params[7]||720)/2)),r=!this.resources||this.resources.fieldSize[0]!==t||this.resources.fieldSize[1]!==l;let d=(R=this.resources)==null?void 0:R.cellBuffer,p=(C=this.resources)==null?void 0:C.ringBuffer,v=(I=this.resources)==null?void 0:I.blurHBuffer,a=(V=this.resources)==null?void 0:V.blurVBuffer;if(d||(d=e.createBuffer({label:"timeline-cells",size:K*te*4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})),p||(p=e.createBuffer({label:"timeline-rings",size:J*ie*4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})),v||(v=e.createBuffer({label:"timeline-blur-h-dir",size:16,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),e.queue.writeBuffer(v,0,new Float32Array([1,0,0,0]))),a||(a=e.createBuffer({label:"timeline-blur-v-dir",size:16,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),e.queue.writeBuffer(a,0,new Float32Array([0,1,0,0]))),!r&&this.resources)return;(k=this.resources)==null||k.fieldA.destroy(),(H=this.resources)==null||H.fieldB.destroy();const u=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING,g=e.createTexture({label:"timeline-field-a-rgba16float",size:[t,l],format:j,usage:u}),c=e.createTexture({label:"timeline-field-b-rgba16float",size:[t,l],format:j,usage:u}),b=g.createView(),B=c.createView(),T=e.createBindGroup({label:"timeline-growth-rings-splat-bind",layout:this.splatBindLayout,entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:d}},{binding:2,resource:{buffer:p}}]}),o=e.createBindGroup({label:"timeline-field-blur-h-bind",layout:this.blurBindLayout,entries:[{binding:0,resource:this.sampler},{binding:1,resource:b},{binding:2,resource:{buffer:v}}]}),_=e.createBindGroup({label:"timeline-field-blur-v-bind",layout:this.blurBindLayout,entries:[{binding:0,resource:this.sampler},{binding:1,resource:B},{binding:2,resource:{buffer:a}}]}),U=e.createBindGroup({label:"timeline-membrane-bind",layout:this.membraneBindLayout,entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:3,resource:this.sampler},{binding:4,resource:b}]});this.resources={cellBuffer:d,ringBuffer:p,blurHBuffer:v,blurVBuffer:a,splatBindGroup:T,blurHBindGroup:o,blurVBindGroup:_,membraneBindGroup:U,fieldA:g,fieldB:c,fieldAView:b,fieldBView:B,fieldSize:[t,l]}}buildGeometry(){var t,l;const e=((t=this.scene)==null?void 0:t.cells)??[];this.cellGeometry=e.slice(0,K).map(r=>({cell:r,x:Math.cos(r.angle)*r.radius,y:Math.sin(r.angle)*r.radius,r:.018+r.retention*.016})),this.ringGeometry=(((l=this.scene)==null?void 0:l.rings)??[]).slice(0,J).map(r=>({ring:r,r:r.radius}))}uploadBuffers(e){var p,v,a;if(!this.resources)return;const t=new Float32Array(K*te);this.cellCount=Math.min(K,this.cellGeometry.length);const l=Math.max(1,this.ringGeometry.length-1);for(let u=0;u0&&(e.setPipeline(this.ringPipeline),e.setBindGroup(0,this.resources.splatBindGroup),e.draw(192,this.ringCount)),this.cellCount>0&&(e.setPipeline(this.cellPipeline),e.draw(6,this.cellCount)))}ringSpin(e){const t=this.engine.params[10]||0,l=.045+e*.1;return t*l}orbitCpu(e,t,l,r){const d=Math.hypot(e,t);if(d<1e-4)return{x:e,y:t};const p=this.engine.params[10]||0,a=Math.atan2(t,e)+this.ringSpin(r)+Math.sin(p*.6+l*6.283)*.02,u=d*(1+.016*Math.sin(p*1.1+l*6.283));return{x:Math.cos(a)*u,y:Math.sin(a)*u}}pickAt(e,t){const l=Math.max(1,this.ringGeometry.length-1);let r=null,d=1/0;for(let a=0;a0?a/l:0,c=u.r*(1+.016*Math.sin(v*1.1+g*6.283));if(Math.abs(p-c)<=.03)return this.selectedId=u.ring.id,{id:u.ring.id,kind:"timeline-ring",index:a,payload:u.ring}}return null}dispose(){var e,t,l,r,d,p;(e=this.resources)==null||e.cellBuffer.destroy(),(t=this.resources)==null||t.ringBuffer.destroy(),(l=this.resources)==null||l.blurHBuffer.destroy(),(r=this.resources)==null||r.blurVBuffer.destroy(),(d=this.resources)==null||d.fieldA.destroy(),(p=this.resources)==null||p.fieldB.destroy(),this.resources=null}}function re(s,e,t){s.pushErrorScope("validation");const l=s.createShaderModule({label:e,code:t});return l.getCompilationInfo().then(r=>{for(const d of r.messages)console.error(`[observatory] ${e} WGSL ${d.type} ${d.lineNum}:${d.linePos} ${d.message}`)}),s.popErrorScope().then(r=>{r&&console.error(`[observatory] ${e} shader module validation: ${r.message}`)}),l}function Pe(s,e){return F(xe.blackwater),F(ae.healthy),F(ae.luciferin),[new Me(s,e)]}function Z(s,e=""){return typeof s=="string"?s:s==null?e:String(s)}function W(s,e=0){return typeof s=="number"&&Number.isFinite(s)?s:e}function ue(s){return Math.max(0,Math.min(1,s))}function Q(s,e,t){return{kind:s,id:e||`${s}:unknown`}}function Be(s,e){return{kind:"scalar",id:`timeline.${s}`,scalar:{name:s,value:e}}}function ce(s){return ue(W(s.retentionStrength,0))}function Re(s){return ue(W(s.combinedScore??s.retentionStrength,ce(s)))}function Ee(s,e){return e[s.id]??[]}function ne(s,e){return s.some(t=>t.action===e)}function Te(s){const e=s.days??[],t=s.audits??{},l=[],r=[],d=[],p=[],v=[],a=[],u=e.filter(o=>o.count>0||o.memories.length>0),g=Math.max(1,u.length),c=Math.max(1,...u.map(o=>o.count||o.memories.length));u.forEach((o,_)=>{const U=.16+_/Math.max(1,g-1)*.7,R=o.memories??[],C=[];let I=0,V=0,k=0;R.forEach((h,z)=>{const E=Ee(h,t),Y=ce(h),x=Z(h.updatedAt)!==Z(h.createdAt)||ne(E,"edited")||ne(E,"reconsolidated"),O=ne(E,"suppressed")||W(h.suppression_count,0)>0;x&&(V+=1),O&&(k+=1),I+=Y;const $=l.length;C.push($);const ee=(z+.5)/Math.max(1,R.length)*Math.PI*2+_*.37,i=(z%5-2)*.008,m=U+i,f=Z(h.validFrom??h.createdAt,o.date),S=Z(h.updatedAt??h.createdAt,f),P=h.content||h.id.slice(0,8),G=Q("memory",h.id);if(l.push({source:G,index:$,label:P,retention:Y,trust:Re(h),stability:W(h.storageStrength,void 0),lastAccessed:h.lastAccessedAt??h.updatedAt??h.createdAt,suppression:O?1:0,tags:[o.date,...h.tags??[]],type:h.nodeType??"memory"}),r.push({id:`timeline:${o.date}:${h.id}`,memoryId:h.id,day:o.date,dayIndex:_,nodeIndex:$,angle:ee,radius:m,retention:Y,validFrom:f,transactionAt:S,suppressed:O,rewritten:x,label:P,provenance:G}),(x||O)&&a.push({source:Q("event",`${h.id}:${x?"updated":"suppressed"}:${S}`),type:O?"MemorySuppressed":"MemoryUpdated",targetIndex:$,frame:45+_*10+z,energy:O?1:.65}),E.length>0){v.push({source:Q("receipt",`memory-audit:${h.id}`),label:`audit ${h.id.slice(0,8)} · ${E.length} events`,nodeIndices:[$]});for(const y of E.slice(0,8))a.push({source:Q("event",`${h.id}:${y.action}:${y.timestamp}`),type:`Audit:${y.action}`,targetIndex:$,frame:70+_*12,energy:.4+Math.abs(W(y.new_value,0)-W(y.old_value,0))})}});const H=R.length?I/R.length:0,q=Be(`day.${o.date}.count`,o.count);d.push({id:`timeline-day:${o.date}`,date:o.date,index:_,count:o.count,radius:U,retention:H,updatedCount:V,suppressedCount:k,memoryIndices:C,provenance:q}),v.push({source:q,label:`${o.date} · ${o.count} memories`,nodeIndices:C})});for(let o=1;o({memoryId:o,events:_})),B=W(s.totalMemories,l.length);return{organ:"timeline",nodes:l,edges:p,events:a,receipts:v,scalars:{totalMemories:B,dayCount:u.length,cellCount:r.length,updatedCount:a.filter(o=>o.type==="MemoryUpdated"||o.type==="Audit:edited"||o.type==="Audit:reconsolidated").length,suppressedCount:a.filter(o=>o.type==="MemorySuppressed"||o.type==="Audit:suppressed").length,maxDayCount:c},alive:r.length>0,rings:d,cells:r,audits:b,raw:{days:e,audits:t}}}function Ve(s,e){fe(e,!0);const t=[...F("#22C7DE"),1],l=[...F("#7C6CFF"),.95],r=[...F("#A8FF5E"),.92],d=[...F("#FF3B30"),.92],p=[...F("#29F2A9"),.6],v=[7,14,30,90,365];let a=N(se([])),u=N(!0),g=N(null),c=N(14),b=N(null),B=N(null),T=N(!1),o=N(se({})),_=null,U=null;me(()=>R());async function R(){A(u,!0),A(g,null);try{const i=await le.timeline(n(c),500);A(a,i.timeline,!0)}catch(i){A(a,[],!0),A(g,i instanceof Error?i.message:"Failed to load timeline",!0)}finally{A(u,!1)}}function C(){const i=v.indexOf(n(c));A(c,v[(i+1)%v.length],!0),A(b,null),A(B,null),R()}let I=D(()=>n(a).reduce((i,m)=>i+m.count,0)),V=D(()=>n(a).reduce((i,m)=>i+m.memories.filter(f=>f.updatedAt&&f.createdAt&&f.updatedAt!==f.createdAt).length,0)),k=D(()=>{const i=n(a).flatMap(m=>m.memories);return i.length?i.reduce((m,f)=>m+(f.retentionStrength??0),0)/i.length:0}),H=D(()=>Te({days:n(a),totalMemories:n(I),audits:n(o)}));async function q(i){if(!n(o)[i]){A(T,!0);try{const m=await le.memoryAudit(i,100);A(o,{...n(o),[i]:m.events},!0)}catch(m){A(g,m instanceof Error?m.message:"Failed to load memory audit",!0)}finally{A(T,!1)}}}function h(i){return i?n(a).flatMap(m=>m.memories).find(m=>m.id===i.memoryId)??null:null}let z=D(()=>h(n(b))),E=D(()=>{const i=n(b);return i?n(o)[i.memoryId]??[]:[]});he(()=>{n(a),n(u),n(g),n(c),n(b),n(B),n(z),n(E),n(T),_==null||_.setText(O())});function Y(i){return i.replace(/[—–]/g,"-").replace(/[‘’]/g,"'").replace(/[“”]/g,'"').replace(/…/g,"...").replace(/[^\x20-\x7E]/g,"?")}function x(i,m,f,S,P,G,y,M={}){return{id:i,kind:m,text:Y(f),x:S,y:P,size:G,color:y,depth:.7,weight:.6,revealSpan:18,maxWidthEm:60,...M}}function O(){const i=[];if(i.push(x("tl:title","tl-title","BITEMPORAL GROWTH RINGS",-.94,.9,.04,t,{depth:1,weight:.9})),i.push(x("tl:range","tl-range",`RANGE ${n(c)}D [click to cycle]`,-.94,.82,.024,t,{depth:.85,hitPadX:.03,hitPadY:.05})),n(u))return i.push(x("tl:status","tl-status","WEAVING VALID-TIME RINGS...",-.3,.02,.04,t,{revealSpan:40})),i;if(n(g))return i.push(x("tl:status","tl-status",`ERROR - ${n(g)}`.slice(0,70),-.5,.02,.032,d,{revealSpan:12})),i;if(n(a).length===0)return i.push(x("tl:status","tl-status","NO MEMORY GROWTH RINGS IN THIS WINDOW",-.5,.02,.03,p,{revealSpan:24})),i;if([[`${n(I)}`,"MEMORIES IN VALID-TIME RINGS",t],[`${n(V)}`,"TRANSACTION-TIME SHADOWS",l],[`${n(a).length}`,"CALENDAR SLICES",t],[`${Math.round(n(k)*100)}%`,"AVERAGE RETENTION OXYGEN",r]].forEach(([f,S,P],G)=>{const y=.72-G*.11;i.push(x(`tl:vital-num:${G}`,"tl-vital",f,-.92,y,.05,P,{depth:.9,weight:.85})),i.push(x(`tl:vital-lbl:${G}`,"tl-vital-lbl",S,-.92,y-.05,.017,p,{depth:.5}))}),i.push(x("tl:receipt-hdr","tl-receipt-hdr","TIME-SLICE RECEIPT",.3,.9,.022,l,{depth:.85})),n(b)&&n(z)){const f=n(b),S=n(z).content.replace(/\s+/g," ").trim().slice(0,46),P=f.suppressed?"suppressed":f.rewritten?"rewritten":"created",G=[[`#${f.memoryId.slice(0,12)}`,t],[S,p],[`valid ${String(f.validFrom).slice(0,19)}`,r],[`tx ${String(f.transactionAt).slice(0,19)}`,l],[`retain ${Math.round(f.retention*100)}% state ${P}`,P==="suppressed"?d:r]];G.forEach(([M,L],X)=>{i.push(x(`tl:receipt:${X}`,"tl-receipt",M,.3,.82-X*.06,.018,L,{revealSpan:10,startFrame:X*2}))});const y=.82-G.length*.06-.04;i.push(x("tl:audit-hdr","tl-audit-hdr",n(T)?"MEMORY-AUDIT (loading...)":"MEMORY-AUDIT",.3,y,.016,p,{depth:.5})),n(E).slice(0,10).forEach((M,L)=>{const X=`${M.action} ${String(M.timestamp).slice(0,19)}`;i.push(x(`tl:audit:${L}`,"tl-audit",X,.3,y-.03-L*.045,.015,t,{revealSpan:8,startFrame:L*2,depth:.6}))}),!n(T)&&n(E).length===0&&i.push(x("tl:audit-empty","tl-audit","no audit events returned",.3,y-.03,.015,p))}else if(n(B)){const f=n(B);[[f.date,t],[`memories ${f.count}`,r],[`avg retain ${Math.round(f.retention*100)}%`,r],[`rewrites ${f.updatedCount}`,l],[`suppressed ${f.suppressedCount}`,f.suppressedCount>0?d:p],["click a cell for its audit receipt",p]].forEach(([P,G],y)=>{i.push(x(`tl:ring:${y}`,"tl-receipt",P,.3,.82-y*.06,.017,G,{revealSpan:10,startFrame:y*2}))})}else i.push(x("tl:receipt-hint","tl-receipt","CLICK A GROWTH RING FOR ITS DATE SLICE, OR A CELL FOR ITS VALID-TIME VS TRANSACTION-TIME RECEIPT",.3,.8,.017,p,{maxWidthEm:34,revealSpan:20}));return i}function $(i,m){const f=Pe(i,m),S=new Se(i);_=S,S.init().then(()=>S.setText(O()));const P={render(G){S.render(G)},pickAt(G,y){const M=S.pickAt(G,y),L=M&&(M.kind==="tl-vital"||M.kind==="tl-range")?M.id:null;return L!==U&&(U=L,S.setRunDepth(L,1)),(M==null?void 0:M.kind)==="tl-range"&&C(),null},dispose(){S.dispose(),_===S&&(_=null)}};return[...f,P]}function ee(i){if(i.kind==="timeline-cell"){const m=i.payload;A(b,m,!0),A(B,null),q(m.memoryId)}else if(i.kind==="timeline-ring"){const m=i.payload;A(B,m,!0),A(b,null)}}ye("bqsng9",i=>{be(()=>{ve.title="Bitemporal Growth Rings · Vestige"})});{let i=D(()=>`timeline-growth-rings:${n(c)}:${n(I)}`),m=D(()=>n(u)||n(T));we(s,{organ:"timeline",get seed(){return n(i)},get scene(){return n(H)},passes:$,get loading(){return n(m)},get error(){return n(g)},emptyLabel:"NO MEMORY GROWTH RINGS IN THIS WINDOW",onpick:ee})}ge()}export{Ve as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/24.taYcndi3.js.br b/apps/dashboard/build/_app/immutable/nodes/24.taYcndi3.js.br deleted file mode 100644 index 1c0e2a9..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/24.taYcndi3.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/24.taYcndi3.js.gz b/apps/dashboard/build/_app/immutable/nodes/24.taYcndi3.js.gz deleted file mode 100644 index 63ec594..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/24.taYcndi3.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/25.CpxKI_0Q.js b/apps/dashboard/build/_app/immutable/nodes/25.CpxKI_0Q.js deleted file mode 100644 index ddae1e7..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/25.CpxKI_0Q.js +++ /dev/null @@ -1,6 +0,0 @@ -import"../chunks/Bzak7iHL.js";import{d as it,o as ct,e as $e,s as v,b as mt}from"../chunks/DAau0uzT.js";import{p as dt,d as p,e as pt,Y as f,g as a,a as u,b as vt,h as ut,X as s,c as r,s as c,f as h,$ as ht,af as Qe,r as o,ag as bt}from"../chunks/CGq8RnJq.js";import{b as yt,i as We}from"../chunks/Ccqjq5DS.js";import{e as P,s as Ge,i as k,r as W}from"../chunks/DqfV0sZu.js";import{h as gt}from"../chunks/De_e6MzK.js";import{s as He}from"../chunks/uCQU803Y.js";import{s as ft}from"../chunks/HFGAk8XQ.js";import{b as V}from"../chunks/DGM4cicq.js";import{b as Re}from"../chunks/BzfFPM53.js";import{b as Ue}from"../chunks/DY7cP31Q.js";var qt=h(''),_t=h('
      '),wt=h("

      "),Pt=h('
      '),kt=h('

      '),xt=h('

      '),St=h("
      "),Tt=h('

      Checking the onboarding notes...

      '),Ct=h(''),Mt=h(`
      V Vestige Pro

      June early access

      Vestige Pro

      The paid layer for developers and teams who already trust Vestige as local memory for AI agents. - Sync, backups, team memory, and bot-assisted support come next.

      Early access

      Reserve a Pro seat

      Why Pro exists

      Two plans. One promise: agent memory you can depend on.

      Always-on answers

      The support bot handles the first wave.

      This is the first support layer: instant onboarding answers before anyone has to write an email. - It can run locally from the FAQ now and call a hosted support endpoint later.

      Onboarding bot

      May to June

      The plan is simple.

      1. May Get Vestige into every MCP, Claude Code, Cursor, local AI, Rust, and self-hosted channel that cares about agent memory.
      2. June Invite the first Solo Pro and Team Pro users into sync, backups, shared memory, PostgreSQL-backed deployments, and bot-assisted support.
      3. After Use paid feedback to turn Vestige from a beloved local tool into durable agent-memory infrastructure.
      `);function Rt(Be,Ee){dt(Ee,!0);let q,G=p(""),j=p(""),I=p("solo"),J=p("sync"),x=p(""),H=p(""),y=p("idle"),_=p(""),S=p(""),T=p(!1),C=p(pt([{role:"bot",content:"Ask me about installing Vestige, whether heavy models are required, Solo vs Team Pro, sync, pricing, or what happens after you join the June list."}]));const Fe=[{value:"Local",label:"SQLite memory, no hosted memory service"},{value:"MCP",label:"Claude Code, Cursor, Cline, Codex, Goose"},{value:"June",label:"Pro sync, backup, team memory early access"}],De=[{name:"Solo Pro",accent:"#22c55e",copy:"Multi-device sync, encrypted backups, managed updates, and a cleaner memory dashboard for developers living inside AI coding agents."},{name:"Team Pro",accent:"#06b6d4",copy:"Shared project memory, admin review, audit trails, PostgreSQL-backed deployments, and async support for engineering teams."}],Oe=["Private by default","Sync without lock-in","Team memory controls","Bot-assisted support"],ze=[{label:"Install",prompt:"How do I install Vestige and connect it to Claude Code?"},{label:"No 20GB?",prompt:"Do I need the Sanhedrin model or 20GB of RAM?"},{label:"Solo vs Team",prompt:"Should I choose Solo Pro or Team Pro?"},{label:"Sync",prompt:"How will Pro sync and backups work?"},{label:"Pricing",prompt:"How much will Vestige Pro cost?"},{label:"Human help",prompt:"When does a human get involved?"}];ct(()=>{const t=q.getContext("2d");if(!t)return;const e=t;let l=0,i=0,m=0;const d=Array.from({length:62},(b,w)=>({x:Math.random(),y:Math.random(),vx:(Math.random()-.5)*16e-5,vy:(Math.random()-.5)*16e-5,phase:Math.random()*Math.PI*2,kind:w%5}));function M(){const b=Math.min(window.devicePixelRatio||1,2);i=window.innerWidth,m=window.innerHeight,q.width=Math.floor(i*b),q.height=Math.floor(m*b),q.style.width=`${i}px`,q.style.height=`${m}px`,e.setTransform(b,0,0,b,0,0)}function Me(b){e.clearRect(0,0,i,m);const w=e.createLinearGradient(0,0,i,m);w.addColorStop(0,"#07100f"),w.addColorStop(.45,"#0b1221"),w.addColorStop(1,"#15100a"),e.fillStyle=w,e.fillRect(0,0,i,m),e.strokeStyle="rgba(148, 163, 184, 0.08)",e.lineWidth=1;for(let n=0;n.96)&&(n.vx*=-1),(n.y<.06||n.y>.94)&&(n.vy*=-1);for(let n=0;n{cancelAnimationFrame(l),window.removeEventListener("resize",M)}});function Ne(){const t=["## Vestige Pro waitlist","",`Plan: ${a(I)}`,`Priority: ${a(J)}`,a(x).trim()?`Use case: ${a(x).trim()}`:"Use case:","","Please do not include private email addresses in this public issue."].join(` -`);return`https://github.com/samvallad33/vestige/issues/new?title=${encodeURIComponent("Vestige Pro waitlist")}&body=${encodeURIComponent(t)}`}async function Ye(t){if(t.preventDefault(),c(y,"submitting"),c(_,""),a(H).trim()){c(y,"success"),c(_,"You are on the list.");return}if(!a(j).includes("@")){c(y,"error"),c(_,"Enter an email so the early-access invite can reach you.");return}a(G).trim(),a(j).trim(),a(I),a(J),a(x).trim(),new Date().toISOString();{c(y,"success"),c(_,"Email capture is ready for an endpoint. Opening the GitHub waitlist fallback with your email omitted."),window.open(Ne(),"_blank","noopener,noreferrer");return}}function Xe(t){const e=t.toLowerCase();return/(install|setup|onboard|claude|cursor|cline|codex|connect)/.test(e)?["Start with the open-source install:","1. `npm install -g vestige-mcp-server@latest`","2. Claude Code: `claude mcp add vestige vestige-mcp -s user`","3. Codex: `codex mcp add vestige -- vestige-mcp`","Then test it by asking your agent to remember a preference, opening a fresh session, and asking for that preference back."].join(` -`):/(sanhedrin|20gb|20 gb|ram|heavy|model|mlx|preflight|hook)/.test(e)?"No. The default Vestige path is the local MCP memory server. Sanhedrin, preflight hooks, and large local verifier models are optional. Pro should keep that promise: nobody should need a 20GB machine just to use memory.":/(solo|team|plan|seat|buying)/.test(e)?"Choose Solo Pro if you want your own multi-device memory, backups, smoother updates, and personal support. Choose Team Pro if multiple people need shared project memory, admin controls, PostgreSQL-backed storage, audit trails, or team onboarding.":/(sync|backup|device|dropbox|icloud|syncthing|postgres|postgresql|pg|central)/.test(e)?"Open-source Vestige should stay local-first. Pro is where guided sync, encrypted backups, conflict handling, and Team Pro PostgreSQL-backed storage belong. The important design rule: users own memory and can export it.":/(price|pricing|cost|pay|billing|stripe|lemon|subscription|monthly|yearly)/.test(e)?"Pricing is not final yet. The current plan is simple: Solo Pro for individual developers, Team Pro for engineering teams. Join the waitlist so early users can shape pricing before the June launch.":/(update|upgrade|curl|reinstall|version)/.test(e)?"Use `vestige update` for existing installs. The goal is that users should not need to keep copying curl commands just to stay current.":/(privacy|local|cloud|telemetry|data|where.*stored|sqlite)/.test(e)?"Vestige core stores memory locally in SQLite and does not need a hosted memory service. Pro should add convenience around sync, backup, and teams without turning private local memory into a black box.":/(support|bot|human|email|question|help|available|awake|discord)/.test(e)?"The support bot should answer common install, sync, plan, and onboarding questions instantly. Hard cases should escalate with context so a human teammate only handles the issues that actually need human judgment.":/(waitlist|june|early|launch|invite|after)/.test(e)?"After you join the waitlist, the June early-access flow should invite you into the right lane: Solo Pro for personal memory, Team Pro for shared memory and admin controls. The bot will keep onboarding answers available while the launch scales.":"I can help with install, updates, optional heavy models, Solo vs Team Pro, sync, backups, privacy, pricing, and support escalation. For now, the fastest next step is to join the waitlist and include your use case so the June onboarding can prioritize the right workflows."}async function pe(t,e){t==null||t.preventDefault();const l=(e??a(S)).trim();if(!(!l||a(T))){c(S,""),c(T,!0),c(C,[...a(C),{role:"user",content:l}],!0);{c(C,[...a(C),{role:"bot",content:Xe(l)}],!0),c(T,!1);return}}}var R=Mt();gt("1375qm6",t=>{var e=qt();ut(()=>{ht.title="Vestige Pro Waitlist"}),u(t,e)});var ve=r(R);yt(ve,t=>q=t,()=>q);var U=s(ve,4),ue=r(U),he=s(ue,2),Ke=s(r(he),2);Qe(2),o(he),o(U);var be=s(U,2),B=r(be),E=r(B),ye=s(r(E),8);P(ye,21,()=>Fe,k,(t,e)=>{var l=_t(),i=r(l),m=r(i,!0);o(i);var g=s(i,2),d=r(g,!0);o(g),o(l),f(()=>{v(m,a(e).value),v(d,a(e).label)}),u(t,l)}),o(ye),o(E);var F=s(E,2),D=s(r(F),2),ge=s(r(D),2);W(ge),o(D);var O=s(D,2),fe=s(r(O),2);W(fe),o(O);var z=s(O,2),N=s(r(z),2),Y=r(N);Y.value=Y.__value="solo";var qe=s(Y);qe.value=qe.__value="team",o(N),o(z);var X=s(z,2),K=s(r(X),2),Z=r(K);Z.value=Z.__value="sync";var ee=s(Z);ee.value=ee.__value="team-memory";var te=s(ee);te.value=te.__value="postgres";var _e=s(te);_e.value=_e.__value="support-bot",o(K),o(X);var ae=s(X,2),we=s(r(ae),2);bt(we),o(ae);var se=s(ae,2),Pe=s(r(se),2);W(Pe),o(se);var L=s(se,2),Ze=r(L,!0);o(L);var et=s(L,2);{var tt=t=>{var e=wt();let l;var i=r(e,!0);o(e),f(()=>{l=He(e,1,"submit-message svelte-1375qm6",null,l,{success:a(y)==="success",error:a(y)==="error"}),v(i,a(_))}),u(t,e)};We(et,t=>{a(_)&&t(tt)})}o(F),o(B);var oe=s(B,2);P(oe,21,()=>Oe,k,(t,e)=>{var l=Pt(),i=r(l,!0);o(l),f(()=>v(i,a(e))),u(t,l)}),o(oe);var le=s(oe,2),ke=s(r(le),2);P(ke,21,()=>De,k,(t,e)=>{var l=kt(),i=s(r(l),2),m=r(i,!0);o(i);var g=s(i,2),d=r(g,!0);o(g),o(l),f(()=>{ft(l,`--track-color: ${a(e).accent}`),v(m,a(e).name),v(d,a(e).copy)}),u(t,l)}),o(ke),o(le);var xe=s(le,2),Se=s(r(xe),2),re=r(Se),Te=s(r(re),4),at=r(Te,!0);o(Te),o(re);var ne=s(re,2),Ce=r(ne);P(Ce,17,()=>a(C),k,(t,e)=>{var l=St();let i;P(l,21,()=>a(e).content.split(` -`),k,(m,g)=>{var d=xt(),M=r(d,!0);o(d),f(()=>v(M,a(g))),u(m,d)}),o(l),f(()=>i=He(l,1,"svelte-1375qm6",null,i,{"bot-bubble":a(e).role==="bot","user-bubble":a(e).role==="user"})),u(t,l)});var st=s(Ce,2);{var ot=t=>{var e=Tt();u(t,e)};We(st,t=>{a(T)&&t(ot)})}o(ne);var ie=s(ne,2);P(ie,21,()=>ze,k,(t,e)=>{var l=Ct(),i=r(l,!0);o(l),f(()=>v(i,a(e).label)),mt("click",l,()=>pe(void 0,a(e).prompt)),u(t,l)}),o(ie);var ce=s(ie,2),me=r(ce);W(me);var lt=s(me,2);o(ce),o(Se),o(xe),Qe(2),o(be),o(R),f(t=>{Ge(ue,"href",`${Ue}/waitlist`),Ge(Ke,"href",`${Ue}/graph`),L.disabled=a(y)==="submitting",v(Ze,a(y)==="submitting"?"Saving...":"Join June early access"),v(at,"FAQ mode"),lt.disabled=t},[()=>a(T)||!a(S).trim()]),$e("submit",F,Ye),V(ge,()=>a(G),t=>c(G,t)),V(fe,()=>a(j),t=>c(j,t)),Re(N,()=>a(I),t=>c(I,t)),Re(K,()=>a(J),t=>c(J,t)),V(we,()=>a(x),t=>c(x,t)),V(Pe,()=>a(H),t=>c(H,t)),$e("submit",ce,pe),V(me,()=>a(S),t=>c(S,t)),u(Be,R),vt()}it(["click"]);export{Rt as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/25.CpxKI_0Q.js.br b/apps/dashboard/build/_app/immutable/nodes/25.CpxKI_0Q.js.br deleted file mode 100644 index b24ef75..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/25.CpxKI_0Q.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/25.CpxKI_0Q.js.gz b/apps/dashboard/build/_app/immutable/nodes/25.CpxKI_0Q.js.gz deleted file mode 100644 index d578196..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/25.CpxKI_0Q.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/3.C6cru0cW.js b/apps/dashboard/build/_app/immutable/nodes/3.C6cru0cW.js deleted file mode 100644 index 163d757..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/3.C6cru0cW.js +++ /dev/null @@ -1 +0,0 @@ -import"../chunks/Bzak7iHL.js";import{i as p}from"../chunks/BfiOPhbz.js";import{o as r}from"../chunks/DAau0uzT.js";import{p as t,b as a}from"../chunks/CGq8RnJq.js";import{g as m}from"../chunks/DJDK-KWF.js";function g(i,o){t(o,!1),r(()=>m("/graph",{replaceState:!0})),p(),a()}export{g as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/3.C6cru0cW.js.br b/apps/dashboard/build/_app/immutable/nodes/3.C6cru0cW.js.br deleted file mode 100644 index 84a337f..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/3.C6cru0cW.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/3.C6cru0cW.js.gz b/apps/dashboard/build/_app/immutable/nodes/3.C6cru0cW.js.gz deleted file mode 100644 index 85236b5..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/3.C6cru0cW.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/4.CIxbWFkr.js b/apps/dashboard/build/_app/immutable/nodes/4.CIxbWFkr.js deleted file mode 100644 index 84f6024..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/4.CIxbWFkr.js +++ /dev/null @@ -1 +0,0 @@ -import"../chunks/Bzak7iHL.js";import{d as k,a as M,b as m,e as R}from"../chunks/DAau0uzT.js";import{p as D,a as T,b as B,f as N,c as X,r as Y,g as s,s as _,d as A}from"../chunks/CGq8RnJq.js";import{b as E}from"../chunks/Ccqjq5DS.js";import{O as L}from"../chunks/BMB5u1EX.js";import{T as O}from"../chunks/D7ozXiSB.js";var S=N('
      ');function H(f,y){D(y,!0);let o=A(null),e=null,i=null,u=null;async function v(n){i=n;const t=new O(n);e=t,await t.init(),t.setText({id:"msdf-test-line",kind:"msdf-test",text:"hello | 5de3e41f | trust 51%",x:-.62,y:.03,size:.105,color:[.14,.78,.87,1],startFrame:0,revealSpan:20,maxWidthEm:18,depth:.51,weight:.51}),n.addPass(t),n.demoClock.reset()}function x(n){if(!s(o)||!e)return;const t=s(o).getBoundingClientRect();if(t.width<=0||t.height<=0)return;const c=(n.clientX-t.left)/t.width*2-1,h=-((n.clientY-t.top)/t.height*2-1),a=e.pickAt(c,h);a&&console.info("[msdf-test] picked",a.id)}function g(n){if(!s(o))return null;const t=s(o).getBoundingClientRect();return t.width<=0||t.height<=0?null:{x:(n.clientX-t.left)/t.width*2-1,y:-((n.clientY-t.top)/t.height*2-1)}}function w(n){if(!s(o)||!i)return;const t=g(n);if(!t)return;const c=s(o).getBoundingClientRect(),h=Math.max(1e-4,c.width/Math.max(1,c.height)),a={x:t.x*Math.max(h,1),y:t.y/Math.min(h,1)},l=u??a,d={x:l.x+(a.x-l.x)*.35,y:l.y+(a.y-l.y)*.35};u=d,i.setCursorPreNdc(d.x,d.y,d.x-l.x,d.y-l.y);const p=e==null?void 0:e.pickAt(t.x,t.y);e==null||e.setRunDepth((p==null?void 0:p.id)??null,p?1:.51)}function C(){u=null,i==null||i.setCursorPreNdc(999,999,0,0),e==null||e.setRunDepth(null,.51)}M(()=>{e==null||e.dispose(),e=null,i=null});var r=S(),b=X(r);L(b,{demo:"recall-path",seed:"msdf-test-v1",onready:v}),Y(r),E(r,n=>_(o,n),()=>s(o)),m("pointerdown",r,x),m("pointermove",r,w),R("pointerleave",r,C),T(f,r),B()}k(["pointerdown","pointermove"]);export{H as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/4.CIxbWFkr.js.br b/apps/dashboard/build/_app/immutable/nodes/4.CIxbWFkr.js.br deleted file mode 100644 index 832ea4d..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/4.CIxbWFkr.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/4.CIxbWFkr.js.gz b/apps/dashboard/build/_app/immutable/nodes/4.CIxbWFkr.js.gz deleted file mode 100644 index 1d295d4..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/4.CIxbWFkr.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/5.XKzsmb3Z.js b/apps/dashboard/build/_app/immutable/nodes/5.XKzsmb3Z.js deleted file mode 100644 index 88c39e3..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/5.XKzsmb3Z.js +++ /dev/null @@ -1 +0,0 @@ -var _=Object.defineProperty;var H=(u,o,d)=>o in u?_(u,o,{enumerable:!0,configurable:!0,writable:!0,value:d}):u[o]=d;var M=(u,o,d)=>H(u,typeof o!="symbol"?o+"":o,d);import"../chunks/Bzak7iHL.js";import{o as U,g as V}from"../chunks/DAau0uzT.js";import{p as W,d as p,e as q,b as D,s,h as Q,$ as z,g as n,u as $}from"../chunks/CGq8RnJq.js";import{h as K}from"../chunks/De_e6MzK.js";import{p as Y}from"../chunks/CbBCXwzm.js";import{a as I}from"../chunks/D35IQVqe.js";import{R as G}from"../chunks/BpEKQwpr.js";import{r as X,a as j}from"../chunks/BMB5u1EX.js";import{T as B}from"../chunks/D7ozXiSB.js";import{L as J,F as Z,l as tt}from"../chunks/DETSv_kY.js";function pt(u,o){W(o,!0);const d=[...X("#22C7DE"),1],v=36,N=40;let c=p(q([])),g=p(0),f=p(0),R=p(""),S=p(!0),A=p(null);U(()=>{k()});async function O(){var i,a,l;const t=(i=V(Y).url.searchParams.get("q"))==null?void 0:i.trim();return t||(((l=(a=(await I.memories.list({limit:"1"})).memories[0])==null?void 0:a.content)==null?void 0:l.replace(/\s+/g," ").trim())??"").slice(0,96)}async function k(){s(S,!0),s(A,null);try{const t=await O();if(s(R,t,!0),!t){s(c,[],!0),s(g,0),s(f,0);return}const e=await I.search(t,N);s(c,e.results,!0),s(g,e.total,!0),s(f,e.durationMs,!0)}catch(t){s(c,[],!0),s(g,0),s(f,0),s(A,t instanceof Error?t.message:"UNKNOWN ACTIVATION FETCH ERROR",!0)}finally{s(S,!1)}}function T(t){return t.replace(/[\u2014\u2013]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u2026/g,"...").replace(/[^\x20-\x7E]/g,"?")}function x(t){return Math.min(1,Math.max(0,Number.isFinite(t)?t:.5))}function h(t){return x(t.combinedScore??t.retrievalStrength??t.retentionStrength??.5)}function E(t){return x(t.retentionStrength??h(t))}function P(t){const e=T(t.content).replace(/\s+/g," ").trim().slice(0,54),r=Math.round(h(t)*100);return T(`${e} | ${t.id.slice(0,8)} | ${r}%`)}function C(){const t=n(c).slice(0,v),e=.72,r=1.5/Math.max(1,v-1);return t.map((i,a)=>({id:`activation:${i.id}`,kind:"activation-result",memoryId:i.id,text:P(i),x:-.88,y:e-a*r,size:.026,color:d,depth:h(i),weight:E(i),startFrame:a*2,revealSpan:20,maxWidthEm:46,hitPadX:.03,hitPadY:.015}))}let w=$(()=>({organ:"activation",nodes:n(c).slice(0,v).map((t,e)=>({source:{kind:"memory",id:t.id},index:e,label:T(t.content).replace(/\s+/g," ").trim().slice(0,54),retention:E(t),stability:t.storageStrength,lastAccessed:t.lastAccessedAt,activation:h(t),trust:h(t),tags:t.tags??[],type:t.nodeType})),edges:[],events:[],receipts:[],scalars:{total:n(g),durationMs:n(f),visibleResults:Math.min(n(c).length,v),queryLength:n(R).length},alive:n(c).length>0}));class L{constructor(e){M(this,"field");this.field=new J(e)}uploadScene(e){const i=e.nodes.map(a=>{const l=x(a.activation??.5),m=x(a.retention);return{id:a.source.id,score:l,hue:m>0?j(m):Z.recall,energy:.4+.6*l,metric2:m,kind:"activation-result",payload:a}});this.field.setCells(tt(i,{maxRadius:.92,minCellR:.012,maxCellR:.05}))}compute(e){this.field.compute(e)}render(e){this.field.render(e)}pickAt(e,r){return this.field.pickAt(e,r)}dispose(){this.field.dispose()}}function b(t,e){const r=new L(t);r.uploadScene(e);const i=new B(t);return i.init().then(()=>i.setText(C())),[r,{render:l=>i.render(l),uploadScene:()=>i.setText(C()),pickAt:(l,m)=>i.pickAt(l,m),dispose:()=>i.dispose()}]}function F(t){var r;const e=t.payload;return(e==null?void 0:e.memoryId)??((r=e==null?void 0:e.source)==null?void 0:r.id)??null}async function y(t){if(t.kind!=="activation-result")return;const e=F(t);if(e)try{const r=await I.memories.promote(e);s(c,n(c).map(i=>i.id===r.id?{...i,...r}:i),!0)}catch(r){s(A,r instanceof Error?r.message:"UNKNOWN ACTIVATION PROMOTE ERROR",!0)}}K("13cmvxk",t=>{Q(()=>{z.title="Activation · Vestige"})});{let t=$(()=>`activation-field:${n(R)}:${n(g)}:${n(f)}`);G(u,{organ:"activation",get seed(){return n(t)},get scene(){return n(w)},passes:b,get loading(){return n(S)},get error(){return n(A)},emptyLabel:"NO SEARCH ACTIVATION RESULTS",onpick:y})}D()}export{pt as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/5.XKzsmb3Z.js.br b/apps/dashboard/build/_app/immutable/nodes/5.XKzsmb3Z.js.br deleted file mode 100644 index b7f5eb1..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/5.XKzsmb3Z.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/5.XKzsmb3Z.js.gz b/apps/dashboard/build/_app/immutable/nodes/5.XKzsmb3Z.js.gz deleted file mode 100644 index 9613087..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/5.XKzsmb3Z.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/6.CNes4HHG.js b/apps/dashboard/build/_app/immutable/nodes/6.CNes4HHG.js deleted file mode 100644 index 94563d4..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/6.CNes4HHG.js +++ /dev/null @@ -1,232 +0,0 @@ -var kr=Object.defineProperty;var Pr=(t,r,l)=>r in t?kr(t,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[r]=l;var j=(t,r,l)=>Pr(t,typeof r!="symbol"?r+"":r,l);import"../chunks/Bzak7iHL.js";import{d as ir,s as u,b as Xe,o as Sr}from"../chunks/DAau0uzT.js";import{p as lr,c as s,r as a,X as n,af as Ie,Y as B,a as y,b as or,aH as xt,f as _,g as e,d as Se,e as er,j as tr,s as U,u as ge}from"../chunks/CGq8RnJq.js";import{i as O}from"../chunks/Ccqjq5DS.js";import{e as fe,s as qt,r as Br,i as rr}from"../chunks/DqfV0sZu.js";import{P as Cr,A as ar,a as we,r as xe}from"../chunks/B9l3DI-J.js";import{s as pe}from"../chunks/uCQU803Y.js";import{s as Ge}from"../chunks/HFGAk8XQ.js";import{b as Mr}from"../chunks/DGM4cicq.js";import{p as Rr,a as gt,s as Er}from"../chunks/DV6OI5iy.js";import{I as Nt}from"../chunks/CKbQrCJw.js";import{g as Gr}from"../chunks/DJDK-KWF.js";import{a as lt}from"../chunks/D35IQVqe.js";import{l as Ir,t as Ar,a as Lr,b as zr}from"../chunks/Ch9vNiEl.js";import{R as Tr}from"../chunks/BpEKQwpr.js";import{r as zt,R as Ur,I as Or,C as Vr}from"../chunks/BMB5u1EX.js";import{L as $r,F as Tt,l as Fr}from"../chunks/DETSv_kY.js";var Nr=_('
      '),Dr=_('
      Activation path
      '),Hr=_(' '),Wr=_('
      Retrieved
      '),jr=_(' '),Qr=_('
      Suppressed
      '),Xr=_(" ",1),Yr=_('
      retrieved
      suppressed
      trust floor
      ');function Kr(t,r){lr(r,!0);let l=Rr(r,"compact",3,!1);const v={low:"var(--color-recall, #10b981)",medium:"#f59e0b",high:"#f43f5e"};function b(){const _e=r.receipt.retrieved[0];if(!_e)return;const ce=r.receipt.retrieved.join(",");Gr(`/graph?center=${encodeURIComponent(_e)}&focus=${encodeURIComponent(ce)}`)}var c=Yr();let f,P;var q=s(c),E=s(q),g=s(E,!0);a(E);var I=n(E,2);let M;var G=s(I);a(I),a(q);var re=n(q,2),ae=s(re),Q=s(ae),Be=s(Q,!0);a(Q),Ie(2),a(ae);var w=n(ae,2),le=s(w),me=s(le,!0);a(le),Ie(2),a(w);var oe=n(w,2),i=s(oe),k=s(i);a(i),Ie(2),a(oe),a(re);var V=n(re,2);{var ye=_e=>{var ce=Xr(),Ye=xt(ce);{var vt=ee=>{var W=Dr(),ve=n(s(W),2);fe(ve,16,()=>r.receipt.activation_path,X=>X,(X,be)=>{var Y=Nr(),Ce=s(Y,!0);a(Y),B(()=>u(Ce,be)),y(X,Y)}),a(W),y(ee,W)};O(Ye,ee=>{r.receipt.activation_path.length&&ee(vt)})}var ut=n(Ye,2);{var dt=ee=>{var W=Wr(),ve=n(s(W),2);fe(ve,20,()=>r.receipt.retrieved,X=>X,(X,be)=>{var Y=Hr(),Ce=s(Y,!0);a(Y),B(Ke=>u(Ce,Ke),[()=>be.slice(0,8)]),y(X,Y)}),a(ve),a(W),y(ee,W)};O(ut,ee=>{r.receipt.retrieved.length&&ee(dt)})}var pt=n(ut,2);{var ft=ee=>{var W=Qr(),ve=n(s(W),2);fe(ve,21,()=>r.receipt.suppressed,X=>X.id,(X,be)=>{var Y=jr(),Ce=s(Y);a(Y),B((Ke,Je)=>{qt(Y,"title",e(be).reason),u(Ce,`${Ke??""} · ${Je??""}`)},[()=>e(be).id.slice(0,8),()=>e(be).reason.replace("_"," ")]),y(X,Y)}),a(ve),a(W),y(ee,W)};O(pt,ee=>{r.receipt.suppressed.length&&ee(ft)})}y(_e,ce)};O(V,_e=>{l()||_e(ye)})}var qe=n(V,2),ct=s(qe);Nt(ct,{name:"sparkle",size:14}),Ie(),a(qe),a(c),B(_e=>{f=pe(c,1,"receipt svelte-1wdzvwu",null,f,{compact:l()}),P=Ge(c,"",P,{"--risk":v[r.receipt.decay_risk]}),u(g,r.receipt.receipt_id),M=Ge(I,"",M,{color:v[r.receipt.decay_risk]}),u(G,`decay: ${r.receipt.decay_risk??""}`),u(Be,r.receipt.retrieved.length),u(me,r.receipt.suppressed.length),u(k,`${_e??""}%`),qe.disabled=!r.receipt.retrieved.length},[()=>(r.receipt.trust_floor*100).toFixed(0)]),Xe("click",qe,b),y(t,c),or()}ir(["click"]);function ot(t){switch(t){case"mcp.call":return"var(--color-synapse-glow, #818cf8)";case"memory.retrieve":return"var(--color-recall, #10b981)";case"memory.suppress":return"#a78bfa";case"memory.write":return"#38bdf8";case"contradiction.detected":return"#fb7185";case"sanhedrin.veto":return"#f43f5e";case"dream.patch":return"#c084fc";default:return"var(--color-synapse, #6366f1)"}}function We(t){switch(t){case"mcp.call":return"Tool Call";case"memory.retrieve":return"Retrieved";case"memory.suppress":return"Suppressed";case"memory.write":return"Wrote";case"contradiction.detected":return"Contradiction";case"sanhedrin.veto":return"Veto";case"dream.patch":return"Dream Patch";default:return t}}function Ut(t){switch(t){case"mcp.call":return"⟐";case"memory.retrieve":return"◉";case"memory.suppress":return"⊘";case"memory.write":return"✎";case"contradiction.detected":return"⚡";case"sanhedrin.veto":return"⛔";case"dream.patch":return"☾";default:return"•"}}function Ot(t){switch(t.type){case"mcp.call":return`${t.tool} · args ${t.argsHash.slice(0,8)}`;case"memory.retrieve":return`${t.ids.length} ${t.ids.length===1?"memory":"memories"} surfaced`;case"memory.suppress":return`${t.id.slice(0,8)} — ${t.reason.replace("_"," ")}`;case"memory.write":return`${t.id.slice(0,8)} — ${t.source}`;case"contradiction.detected":return t.detail;case"sanhedrin.veto":return`"${t.claim}" (conf ${(t.confidence*100).toFixed(0)}%)`;case"dream.patch":return`${t.proposalIds.length} consolidation proposal(s)`;default:return""}}function Jr(t){switch(t.type){case"memory.retrieve":return t.ids;case"memory.suppress":case"memory.write":return[t.id];case"contradiction.detected":return t.ids;case"sanhedrin.veto":return t.evidenceIds;case"dream.patch":return t.proposalIds;default:return[]}}function Zr(t){return!Number.isFinite(t)||t<=0?"—":new Date(t).toLocaleTimeString(void 0,{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function sr(t,r){return Math.max(0,t-r)}const wt=512,Vt=12,$t=8,Ft=128,je="rgba16float",cr=` -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - capture_mode: f32, - live_kind: f32, - live_frame: f32, - live_energy: f32, - projection_days: f32, -}; - -struct TraceEventCell { - // x order 0..1, y lane 0..6, z confidence, w event kind code - order_lane_conf_kind: vec4f, - // x frame start, y visible gate, z selected, w receipt flag - timing_flags: vec4f, - // x retrieved ids count, y suppress/write/veto strength, z run duration fraction, w spare - metric: vec4f, -}; - -struct ReceiptBead { - // xy NDC, z intensity, w event index - pos_energy: vec4f, - // x node-count, y receipt ordinal, zw spare - beat: vec4f, -}; -`,ea=` -${cr} - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var trace_events: array; -@group(0) @binding(2) var receipt_beads: array; - -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); - -fn lane_y(lane: f32) -> f32 { - return mix(0.66, -0.62, lane / 6.0); -} - -fn event_x(order: f32) -> f32 { - return mix(-0.84, 0.84, clamp(order, 0.0, 1.0)); -} - -fn lane_color(kind: f32, lane: f32, conf: f32) -> vec3f { - let luciferin = vec3f(0.66, 1.0, 0.37); - let cyan = vec3f(0.08, 0.78, 0.92); - let green = vec3f(0.12, 0.95, 0.56); - let scarlet = vec3f(1.0, 0.18, 0.12); - let amber = vec3f(1.0, 0.64, 0.06); - let violet = vec3f(0.45, 0.42, 1.0); - let bone = vec3f(0.88, 1.0, 0.70); - var col = cyan; - if (kind < 0.5) { col = bone; } - else if (kind < 1.5) { col = green; } - else if (kind < 2.5) { col = scarlet; } - else if (kind < 3.5) { col = luciferin; } - else if (kind < 4.5) { col = amber; } - else if (kind < 5.5) { col = scarlet; } - else { col = violet; } - return mix(col * 0.62, col, clamp(conf, 0.0, 1.0)) * (0.88 + lane * 0.025); -} - -struct VSOut { - @builtin(position) clip: vec4f, - @location(0) local_uv: vec2f, - @location(1) @interpolate(flat) misc: vec4f, - @location(2) @interpolate(flat) color_energy: vec4f, -}; - -@vertex -fn vs_impulse(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - let cell = trace_events[ii]; - let corner = QUAD[vi]; - let order = cell.order_lane_conf_kind.x; - let lane = cell.order_lane_conf_kind.y; - let conf = cell.order_lane_conf_kind.z; - let kind = cell.order_lane_conf_kind.w; - let visible = cell.timing_flags.y; - let selected = cell.timing_flags.z; - let t = params.frame - cell.timing_flags.x; - let pulse = smoothstep(0.0, 18.0, t) * (1.0 - smoothstep(92.0, 180.0, t)); - let center = vec2f(event_x(order), lane_y(lane)); - let radius = vec2f(0.028 + 0.026 * conf + 0.012 * selected, 0.026 + 0.018 * conf + 0.010 * pulse); - var out: VSOut; - out.clip = vec4f(center + corner * radius, 0.0, 1.0); - out.local_uv = corner; - out.misc = vec4f(kind, lane, selected, visible); - out.color_energy = vec4f(lane_color(kind, lane, conf), visible * (0.35 + conf * 0.75 + pulse * 0.38)); - return out; -} - -@fragment -fn fs_impulse(frag: VSOut) -> @location(0) vec4f { - let d = length(frag.local_uv); - if (d > 1.0 || frag.misc.w < 0.5) { discard; } - let core = exp(-d * d * 3.4) * frag.color_energy.a; - let ring = smoothstep(0.88, 0.62, abs(d - 0.64)) * (0.18 + frag.misc.z * 0.62); - return vec4f(frag.color_energy.rgb * (core + ring), 1.0); -} - -@vertex -fn vs_lane(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - let corner = QUAD[vi]; - let lane = f32(ii); - let center = vec2f(0.0, lane_y(lane)); - let size = vec2f(0.93, 0.012); - var out: VSOut; - out.clip = vec4f(center + corner * size, 0.0, 1.0); - out.local_uv = corner; - out.misc = vec4f(0.0, lane, 0.0, 1.0); - out.color_energy = vec4f(lane_color(lane, lane, 0.4), 0.12 + 0.03 * params.pulse); - return out; -} - -@fragment -fn fs_lane(frag: VSOut) -> @location(0) vec4f { - let fade = smoothstep(1.0, 0.08, abs(frag.local_uv.x)) * smoothstep(1.0, 0.0, abs(frag.local_uv.y)); - return vec4f(frag.color_energy.rgb * frag.color_energy.a * fade, 1.0); -} - -@vertex -fn vs_receipt(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - let bead = receipt_beads[ii]; - let corner = QUAD[vi]; - let event_i = bead.pos_energy.w; - let linked = trace_events[u32(max(0.0, event_i))]; - let center = vec2f(event_x(linked.order_lane_conf_kind.x), lane_y(linked.order_lane_conf_kind.y) - 0.05 - 0.012 * bead.beat.y); - let radius = 0.017 + 0.005 * min(5.0, bead.beat.x); - var out: VSOut; - out.clip = vec4f(center + corner * radius, 0.0, 1.0); - out.local_uv = corner; - out.misc = vec4f(0.0, linked.order_lane_conf_kind.y, 0.0, linked.timing_flags.y); - out.color_energy = vec4f(vec3f(0.90, 1.0, 0.70), bead.pos_energy.z * linked.timing_flags.y); - return out; -} - -@fragment -fn fs_receipt(frag: VSOut) -> @location(0) vec4f { - let d = length(frag.local_uv); - if (d > 1.0 || frag.misc.w < 0.5) { discard; } - let bead = smoothstep(1.0, 0.0, d) + smoothstep(0.70, 0.58, abs(d - 0.64)); - return vec4f(frag.color_energy.rgb * frag.color_energy.a * bead, 1.0); -} -`,ta=` -${cr} - -@group(0) @binding(0) var params: Params; -@group(0) @binding(3) var field_sampler: sampler; -@group(0) @binding(4) var field_tex: texture_2d; - -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); - -struct VSOut { - @builtin(position) clip: vec4f, - @location(0) uv: vec2f, -}; - -@vertex -fn vs_fullscreen(@builtin(vertex_index) vi: u32) -> VSOut { - let p = QUAD[vi]; - var out: VSOut; - out.clip = vec4f(p, 0.0, 1.0); - out.uv = p * 0.5 + vec2f(0.5); - return out; -} - -@fragment -fn fs_membrane(frag: VSOut) -> @location(0) vec4f { - let f = textureSample(field_tex, field_sampler, frag.uv); - let density = clamp(f.r, 0.0, 4.0); - let recall = clamp(f.g, 0.0, 4.0); - let immune = clamp(f.b, 0.0, 4.0); - let write_glow = clamp(f.a, 0.0, 4.0); - let centerline = smoothstep(0.44, 0.02, abs(frag.uv.y - 0.5)); - let blackwater = vec3f(0.006, 0.014, 0.016); - var color = blackwater * (0.24 + density * 0.11); - color = color + vec3f(0.62, 1.0, 0.35) * recall * 0.10; - color = color + vec3f(1.0, 0.18, 0.12) * immune * 0.16; - color = color + vec3f(0.90, 1.0, 0.70) * write_glow * 0.10; - color = color + vec3f(0.08, 0.70, 0.80) * centerline * (0.03 + 0.02 * params.pulse); - let vignette = smoothstep(0.92, 0.22, distance(frag.uv, vec2f(0.5))); - return vec4f(color * (0.45 + 0.55 * vignette) * params.brightness, 1.0); -} -`,ra=` -struct BlurDir { - dir: vec2f, - _pad: vec2f, -}; -@group(0) @binding(0) var blur_sampler: sampler; -@group(0) @binding(1) var blur_src: texture_2d; -@group(0) @binding(2) var blur_dir: BlurDir; -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); -struct VSOut { @builtin(position) clip: vec4f, @location(0) uv: vec2f }; -@vertex -fn vs_fullscreen(@builtin(vertex_index) vi: u32) -> VSOut { - let p = QUAD[vi]; - var out: VSOut; - out.clip = vec4f(p, 0.0, 1.0); - out.uv = p * 0.5 + vec2f(0.5); - return out; -} -@fragment -fn fs_blur(frag: VSOut) -> @location(0) vec4f { - let dims = vec2f(textureDimensions(blur_src, 0)); - let step = blur_dir.dir / max(dims, vec2f(1.0)); - var acc = textureSampleLevel(blur_src, blur_sampler, frag.uv - step * 2.0, 0.0) * 0.06136; - acc = acc + textureSampleLevel(blur_src, blur_sampler, frag.uv - step, 0.0) * 0.24477; - acc = acc + textureSampleLevel(blur_src, blur_sampler, frag.uv, 0.0) * 0.38774; - acc = acc + textureSampleLevel(blur_src, blur_sampler, frag.uv + step, 0.0) * 0.24477; - acc = acc + textureSampleLevel(blur_src, blur_sampler, frag.uv + step * 2.0, 0.0) * 0.06136; - return acc; -} -`;function aa(t){switch(t){case"mcp.call":return 0;case"memory.retrieve":return 1;case"memory.suppress":return 2;case"memory.write":return 3;case"sanhedrin.veto":return 4;case"contradiction.detected":return 5;case"dream.patch":return 6}}function nr(t){return["tool","retrieve","suppress","write","veto","contradiction","dream"].indexOf(t)}class sa{constructor(r,l){j(this,"engine");j(this,"scene",null);j(this,"resources",null);j(this,"sampler",null);j(this,"traceBindLayout",null);j(this,"membraneBindLayout",null);j(this,"blurBindLayout",null);j(this,"impulsePipeline",null);j(this,"lanePipeline",null);j(this,"receiptPipeline",null);j(this,"blurPipeline",null);j(this,"membranePipeline",null);j(this,"eventCount",0);j(this,"receiptCount",0);j(this,"hitRects",[]);this.engine=r,this.uploadScene(l)}uploadScene(r){this.scene=r,this.buildHitRects();const l=this.engine.gpuDevice;l&&(this.ensurePipelines(l),this.ensureResources(l),this.uploadBuffers(l))}ensurePipelines(r){if(this.impulsePipeline||!this.engine.paramsBuffer)return;const l=r.createShaderModule({label:"blackbox-trace-wgsl",code:ea}),v=r.createShaderModule({label:"blackbox-membrane-wgsl",code:ta}),b=r.createShaderModule({label:"blackbox-blur-wgsl",code:ra});this.traceBindLayout=r.createBindGroupLayout({label:"blackbox-trace-bind-layout",entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.VERTEX,buffer:{type:"read-only-storage"}},{binding:2,visibility:GPUShaderStage.VERTEX,buffer:{type:"read-only-storage"}}]}),this.membraneBindLayout=r.createBindGroupLayout({label:"blackbox-membrane-bind-layout",entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:3,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:4,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}}]}),this.blurBindLayout=r.createBindGroupLayout({label:"blackbox-blur-bind-layout",entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:2,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}}]});const c=r.createPipelineLayout({label:"blackbox-trace-layout",bindGroupLayouts:[this.traceBindLayout]}),f=r.createPipelineLayout({label:"blackbox-membrane-layout",bindGroupLayouts:[this.membraneBindLayout]}),P=r.createPipelineLayout({label:"blackbox-blur-layout",bindGroupLayouts:[this.blurBindLayout]});this.sampler=r.createSampler({magFilter:"linear",minFilter:"linear"});const q={color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}};this.impulsePipeline=r.createRenderPipeline({label:"blackbox-impulses",layout:c,vertex:{module:l,entryPoint:"vs_impulse"},fragment:{module:l,entryPoint:"fs_impulse",targets:[{format:je,blend:q}]},primitive:{topology:"triangle-list"}}),this.lanePipeline=r.createRenderPipeline({label:"blackbox-lanes",layout:c,vertex:{module:l,entryPoint:"vs_lane"},fragment:{module:l,entryPoint:"fs_lane",targets:[{format:je,blend:q}]},primitive:{topology:"triangle-list"}}),this.receiptPipeline=r.createRenderPipeline({label:"blackbox-receipt-beads",layout:c,vertex:{module:l,entryPoint:"vs_receipt"},fragment:{module:l,entryPoint:"fs_receipt",targets:[{format:je,blend:q}]},primitive:{topology:"triangle-list"}}),this.blurPipeline=r.createRenderPipeline({label:"blackbox-field-blur",layout:P,vertex:{module:b,entryPoint:"vs_fullscreen"},fragment:{module:b,entryPoint:"fs_blur",targets:[{format:je}]},primitive:{topology:"triangle-list"}}),this.membranePipeline=r.createRenderPipeline({label:"blackbox-field-membrane",layout:f,vertex:{module:v,entryPoint:"vs_fullscreen"},fragment:{module:v,entryPoint:"fs_membrane",targets:[{format:this.engine.sceneFormat,blend:q}]},primitive:{topology:"triangle-list"}})}ensureResources(r){var w,le,me,oe,i,k;if(!this.traceBindLayout||!this.blurBindLayout||!this.membraneBindLayout||!this.engine.paramsBuffer||!this.sampler)return;const l=Math.max(16,Math.floor((this.engine.params[6]||1280)/2)),v=Math.max(16,Math.floor((this.engine.params[7]||720)/2)),b=!this.resources||this.resources.fieldSize[0]!==l||this.resources.fieldSize[1]!==v;let c=(w=this.resources)==null?void 0:w.eventBuffer,f=(le=this.resources)==null?void 0:le.receiptBuffer,P=(me=this.resources)==null?void 0:me.blurHBuffer,q=(oe=this.resources)==null?void 0:oe.blurVBuffer;if(c||(c=r.createBuffer({label:"blackbox-event-cells",size:wt*Vt*4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})),f||(f=r.createBuffer({label:"blackbox-receipt-beads",size:Ft*$t*4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})),P||(P=r.createBuffer({label:"blackbox-blur-h-dir",size:16,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),r.queue.writeBuffer(P,0,new Float32Array([1,0,0,0]))),q||(q=r.createBuffer({label:"blackbox-blur-v-dir",size:16,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),r.queue.writeBuffer(q,0,new Float32Array([0,1,0,0]))),!b&&this.resources)return;(i=this.resources)==null||i.fieldA.destroy(),(k=this.resources)==null||k.fieldB.destroy();const E=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING,g=r.createTexture({label:"blackbox-field-a-rgba16float",size:[l,v],format:je,usage:E}),I=r.createTexture({label:"blackbox-field-b-rgba16float",size:[l,v],format:je,usage:E}),M=g.createView(),G=I.createView(),re=r.createBindGroup({label:"blackbox-trace-bind",layout:this.traceBindLayout,entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:c}},{binding:2,resource:{buffer:f}}]}),ae=r.createBindGroup({label:"blackbox-membrane-bind",layout:this.membraneBindLayout,entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:3,resource:this.sampler},{binding:4,resource:M}]}),Q=r.createBindGroup({label:"blackbox-blur-h-bind",layout:this.blurBindLayout,entries:[{binding:0,resource:this.sampler},{binding:1,resource:M},{binding:2,resource:{buffer:P}}]}),Be=r.createBindGroup({label:"blackbox-blur-v-bind",layout:this.blurBindLayout,entries:[{binding:0,resource:this.sampler},{binding:1,resource:G},{binding:2,resource:{buffer:q}}]});this.resources={eventBuffer:c,receiptBuffer:f,blurHBuffer:P,blurVBuffer:q,traceBindGroup:re,membraneBindGroup:ae,blurHBindGroup:Q,blurVBindGroup:Be,fieldA:g,fieldB:I,fieldAView:M,fieldBView:G,fieldSize:[l,v]}}uploadBuffers(r){if(!this.resources||!this.scene)return;const l=Math.min(wt,this.scene.visibleEventCount||this.scene.traceEvents.length),v=Math.max(1,this.scene.traceEvents.length-1),b=new Float32Array(wt*Vt);this.eventCount=Math.min(wt,this.scene.traceEvents.length);for(let f=0;f({event:b,x:-.84+1.68*(c/l),y:.66-1.28*(nr(b.lane)/6),w:.055,h:.065}))}compute(r){const l=this.engine.gpuDevice;if(!l||!this.resources||!this.impulsePipeline||!this.lanePipeline||!this.receiptPipeline||!this.blurPipeline)return;this.ensureResources(l);const v=this.resources,b=r.beginRenderPass({label:"blackbox-field-splat-pass",colorAttachments:[{view:v.fieldAView,clearValue:{r:0,g:0,b:0,a:0},loadOp:"clear",storeOp:"store"}]});b.setBindGroup(0,v.traceBindGroup),b.setPipeline(this.lanePipeline),b.draw(6,7),this.eventCount>0&&(b.setPipeline(this.impulsePipeline),b.draw(6,this.eventCount)),this.receiptCount>0&&this.eventCount>0&&(b.setPipeline(this.receiptPipeline),b.draw(6,this.receiptCount)),b.end();const c=r.beginRenderPass({label:"blackbox-field-blur-h-pass",colorAttachments:[{view:v.fieldBView,clearValue:{r:0,g:0,b:0,a:0},loadOp:"clear",storeOp:"store"}]});c.setPipeline(this.blurPipeline),c.setBindGroup(0,v.blurHBindGroup),c.draw(6,1),c.end();const f=r.beginRenderPass({label:"blackbox-field-blur-v-pass",colorAttachments:[{view:v.fieldAView,clearValue:{r:0,g:0,b:0,a:0},loadOp:"clear",storeOp:"store"}]});f.setPipeline(this.blurPipeline),f.setBindGroup(0,v.blurVBindGroup),f.draw(6,1),f.end()}render(r){!this.resources||!this.membranePipeline||!this.impulsePipeline||!this.lanePipeline||!this.receiptPipeline||(r.setPipeline(this.membranePipeline),r.setBindGroup(0,this.resources.membraneBindGroup),r.draw(6,1),r.setBindGroup(0,this.resources.traceBindGroup),r.setPipeline(this.lanePipeline),r.draw(6,7),this.eventCount>0&&(r.setPipeline(this.impulsePipeline),r.draw(6,this.eventCount)),this.receiptCount>0&&this.eventCount>0&&(r.setPipeline(this.receiptPipeline),r.draw(6,this.receiptCount)))}pickAt(r,l){for(const v of this.hitRects)if(Math.abs(r-v.x)<=v.w&&Math.abs(l-v.y)<=v.h)return{id:v.event.id,kind:"trace-event",index:v.event.index,payload:v.event};return null}dispose(){var r,l,v,b,c,f;(r=this.resources)==null||r.eventBuffer.destroy(),(l=this.resources)==null||l.receiptBuffer.destroy(),(v=this.resources)==null||v.blurHBuffer.destroy(),(b=this.resources)==null||b.blurVBuffer.destroy(),(c=this.resources)==null||c.fieldA.destroy(),(f=this.resources)==null||f.fieldB.destroy(),this.resources=null}}function na(t,r){return zt(Ur.healthy),zt(Or.veto),zt(Vr.forward),[new sa(t,r)]}function kt(t){return Math.max(0,Math.min(1,Number.isFinite(t)?t:0))}function Qe(t,r=0){return typeof t=="number"&&Number.isFinite(t)?t:r}function ia(t,r,l){return{kind:"trace",id:`${t??"trace:none"}:event:${r}:${l}`}}function la(t,r,l){return{kind:"event",id:`${t??"trace:none"}:event:${r}:${l}`}}function oa(t){return{kind:"memory",id:t}}function ca(t){switch(t){case"mcp.call":return"tool";case"memory.retrieve":return"retrieve";case"memory.suppress":return"suppress";case"memory.write":return"write";case"sanhedrin.veto":return"veto";case"contradiction.detected":return"contradiction";case"dream.patch":return"dream"}}function va(t){switch(t.type){case"memory.retrieve":return t.ids;case"memory.suppress":return[t.id];case"memory.write":return[t.id];case"contradiction.detected":return t.ids;case"sanhedrin.veto":return t.evidenceIds;case"dream.patch":return t.proposalIds;case"mcp.call":return[]}}function ua(t){switch(t.type){case"mcp.call":return t.tool;case"memory.retrieve":return`${t.ids.length} memories retrieved`;case"memory.suppress":return`suppressed ${t.id.slice(0,8)}`;case"memory.write":return`wrote ${t.id.slice(0,8)}`;case"contradiction.detected":return`contradiction ${t.ids.join(" ↔ ")}`;case"sanhedrin.veto":return"Sanhedrin veto";case"dream.patch":return`${t.proposalIds.length} dream proposals`}}function da(t){switch(t.type){case"mcp.call":return`MCP tool ${t.tool} called; args hash ${t.argsHash.slice(0,12)}`;case"memory.retrieve":return`Retrieved ${t.ids.length} memories with activation map`;case"memory.suppress":return`Suppressed ${t.id}: ${t.reason}`;case"memory.write":return`Memory write ${t.id} from ${t.source}`;case"contradiction.detected":return t.detail;case"sanhedrin.veto":return`${Math.round(kt(t.confidence)*100)}% veto confidence: ${t.claim}`;case"dream.patch":return`Dream patch proposals: ${t.proposalIds.join(", ")}`}}function pa(t){return t.type!=="memory.retrieve"?[]:Object.entries(t.activation??{}).map(([r,l])=>({id:r,activation:kt(l)})).sort((r,l)=>l.activation-r.activation)}function fa(t){if(t.type==="sanhedrin.veto")return kt(t.confidence);if(t.type==="memory.retrieve"){const r=Object.values(t.activation??{});return r.length?kt(r.reduce((l,v)=>l+v,0)/r.length):.45}return t.type==="memory.suppress"?.78:t.type==="memory.write"?.72:t.type==="contradiction.detected"?.82:t.type==="dream.patch"?.52:.62}function ma(t,r=[],l){var le,me,oe;const v=(t==null?void 0:t.runId)??null,b=(t==null?void 0:t.events)??[],c=(t==null?void 0:t.summary)??null,f=Qe(c==null?void 0:c.startedAt,((le=b[0])==null?void 0:le.at)??0),P=Qe(c==null?void 0:c.lastAt,((me=b[b.length-1])==null?void 0:me.at)??f),q=b.length?b.length-1:0,E=Math.max(0,Math.min(q,l??q)),g=b.length?E+1:0,I=b.map((i,k)=>({index:k,id:`${v??i.runId}:event:${k}:${i.type}`,type:i.type,lane:ca(i.type),runId:i.runId,at:i.at,label:ua(i),summary:da(i),memoryIds:va(i),activationPairs:pa(i),confidence:fa(i),provenance:ia(v,k,i.type),raw:i})),M=new Map;for(const i of I)for(const k of i.memoryIds){if(!k||M.has(k))continue;const V=((oe=i.activationPairs.find(ye=>ye.id===k))==null?void 0:oe.activation)??0;M.set(k,{source:oa(k),index:M.size,label:k.slice(0,12),retention:Math.max(.25,V),activation:V,trust:i.type==="memory.suppress"?.2:Math.max(.35,i.confidence),suppression:i.type==="memory.suppress"?1:0,tags:[i.lane,i.type],type:"trace-memory"})}const G=[...M.values()],re=I.slice(0,g).map(i=>{var k;return{source:la(v,i.index,i.type),type:i.type,targetIndex:i.memoryIds.length?((k=M.get(i.memoryIds[0]))==null?void 0:k.index)??-1:-1,frame:i.index*34+18,energy:Math.max(.18,i.confidence)}}),ae=I.slice(0,g).flatMap(i=>{const k=i.memoryIds.filter(V=>M.has(V));return k.length<2?[]:k.slice(1).map((V,ye)=>{var qe;return{source:{kind:"pair",id:`${i.id}:pair:${k[0]}:${V}`},sourceIndex:M.get(k[0]).index,targetIndex:M.get(V).index,weight:((qe=i.activationPairs[ye+1])==null?void 0:qe.activation)??i.confidence,kind:i.type}})}),Q=r??[],Be=Q.map(i=>{const k=[...new Set([...i.retrieved??[],...i.activation_path??[],...(i.mutations??[]).map(V=>V.id)])];return{source:{kind:"receipt",id:i.receipt_id},label:`receipt ${i.receipt_id.slice(0,10)}`,nodeIndices:k.map(V=>{var ye;return(ye=M.get(V))==null?void 0:ye.index}).filter(V=>typeof V=="number")}}),w={organ:"blackbox",nodes:G,edges:ae,events:re,receipts:Be,scalars:{eventCount:b.length,visibleEventCount:g,retrievedCount:Qe(c==null?void 0:c.retrievedCount,I.filter(i=>i.type==="memory.retrieve").length),suppressedCount:Qe(c==null?void 0:c.suppressedCount,I.filter(i=>i.type==="memory.suppress").length),writeCount:Qe(c==null?void 0:c.writeCount,I.filter(i=>i.type==="memory.write").length),vetoCount:Qe(c==null?void 0:c.vetoCount,I.filter(i=>i.type==="sanhedrin.veto").length),durationMs:Math.max(0,P-f),receiptCount:Be.length},alive:b.length>0,runId:v,traceEvents:I,visibleEventCount:g,selectedIndex:E,startedAt:f,lastAt:P,durationMs:Math.max(0,P-f),receiptRows:Q};return w.alive||(w.receipts=Q.map(i=>({source:{kind:"receipt",id:i.receipt_id},label:`receipt ${i.receipt_id.slice(0,10)}`,nodeIndices:[]})),w.scalars.eventCount=0,w.scalars.visibleEventCount=0),w}var ya=_(' ',1),_a=_(' '),ba=_('awaiting…'),ha=_('
      GPU pick
      '),ga=_(`

      No agent runs recorded yet. Make an MCP tool call — every call is - recorded here.

      `),wa=_(' '),xa=_(' '),qa=_(' '),ka=_(' '),Pa=_('
    • '),Sa=_('
        '),Ba=_('
        Loading trace…
        '),Ca=_('
        '),Ma=_('
        Select a run to replay.
        '),Ra=_(' '),Ea=_(""),Ga=_(' '),Ia=_(' '),Aa=_('
        '),La=_(' '),za=_('
        vs
        '),Ta=_(' '),Ua=_('
        '),Oa=_('

        '),Va=_('

        No memories touched yet.

        '),$a=_(' '),Fa=_('
        '),Na=_('

        Receipts — proof behind retrievals

        '),Da=_('
      • '),Ha=_('
        Step

        Memory pulse — touched this run

        Event producers — this run

        • mcp.call · memory.write · memory.retrieve · memory.suppress live
        • contradiction.detected
        • dream.patch
        • sanhedrin.veto

        Event log

          ',1),Wa=_('
          '),ja=_('
          '),Qa=_('
          trace events

          Watch the agent think. Watch memory change. Watch the receipt prove why.

          '),Xa=_('
          WebSocket
          Live runId
          Last event
          Events seen
          ',1);function fs(t,r){lr(r,!0);const l=()=>gt(Ir,"$lastTraceEvent",f),v=()=>gt(Lr,"$isConnected",f),b=()=>gt(zr,"$liveRunId",f),c=()=>gt(Ar,"$traceEvents",f),[f,P]=Er();let q=Se(er([])),E=Se(null),g=Se(null),I=Se(!1),M=Se(null),G=Se(0),re=Se(!1),ae=Se(er([])),Q=Se(null);const Be=ge(()=>e(g)?e(g).events.slice(0,e(G)+1):[]),w=ge(()=>e(g)&&e(g).events.length?e(g).events[e(G)]:null),le=ge(()=>{var o,d;return((d=(o=e(g))==null?void 0:o.events[0])==null?void 0:d.at)??0}),me=ge(()=>Array.from(new Set(e(Be).flatMap(Jr)))),oe=ge(()=>{var o;return((o=e(g))==null?void 0:o.events.some(d=>d.type==="sanhedrin.veto"))??!1}),i=ge(()=>{var o;return((o=e(g))==null?void 0:o.events.some(d=>d.type==="dream.patch"))??!1}),k=ge(()=>{var o;return((o=e(g))==null?void 0:o.events.some(d=>d.type==="contradiction.detected"))??!1}),V=ge(()=>ma(e(g),e(ae),e(G)));function ye(o){var p;if(o.kind!=="trace-event")return;const d=o.payload;U(Q,d,!0),U(G,Math.max(0,Math.min((p=e(g))!=null&&p.events.length?e(g).events.length-1:0,d.index)),!0)}async function qe(){try{const o=await lt.traces.list(100);U(q,o.runs,!0),!e(E)&&e(q).length&&ct(e(q)[0].runId)}catch(o){U(M,String(o),!0)}}async function ct(o){U(E,o,!0),U(I,!0),U(M,null);try{U(g,await lt.traces.get(o),!0),U(G,Math.max(0,(e(g).events.length||1)-1),!0),U(Q,null),U(ae,(await lt.receipts.listForRun(o,8)).receipts,!0)}catch(d){U(M,String(d),!0),U(g,null)}finally{U(I,!1)}}function _e(){e(E)&&(window.location.href=lt.traces.exportUrl(e(E)))}tr(()=>{var p;const o=l();if(!o)return;const d=(p=o.data)==null?void 0:p.run_id;d&&d===e(E)&<.traces.get(e(E)).then(A=>{U(g,A,!0),U(G,Math.max(0,A.events.length-1),!0)})}),Sr(qe);let ce=null;function Ye(){const o=Math.max(1,...e(q).map(p=>p.eventCount??0)),d=e(q).slice(0,200).map(p=>{const A=vt((p.eventCount??0)/o),S=(p.vetoCount??0)>0?Tt.scarlet:(p.suppressedCount??0)>0?Tt.caution:Tt.forward;return{id:p.runId,score:.35+.65*A,hue:S,energy:.4+.6*A,selected:p.runId===e(E),scar:(p.vetoCount??0)>0,metric2:vt((p.retrievedCount??0)/Math.max(1,p.eventCount??1)),kind:"trace-run",payload:p}});return Fr(d,{maxRadius:.95,minCellR:.016,maxCellR:.06})}function vt(o){return Math.min(1,Math.max(0,Number.isFinite(o)?o:0))}function ut(o,d){const p=new $r(o);return ce=p,p.setCells(Ye()),[{compute:S=>p.compute(S),render:S=>p.render(S),pickAt:(S,N)=>p.pickAt(S,N),dispose:()=>{p.dispose(),ce===p&&(ce=null)}},...na(o,d)]}tr(()=>{e(q).length,e(E),ce==null||ce.setCells(Ye())});var dt=Xa(),pt=xt(dt);{let o=ge(()=>`agent-flight-recorder:${e(E)??"empty"}:${e(V).visibleEventCount}`);Tr(pt,{organ:"blackbox",get seed(){return e(o)},get scene(){return e(V)},passes:ut,get loading(){return e(I)},get error(){return e(M)},emptyLabel:"NO AGENT TRACE SELECTED - RECORDER ARMED",onpick:ye})}var ft=n(pt,2),ee=s(ft);Cr(ee,{icon:"blackbox",title:"Agent Black Box",subtitle:"Watch the agent think. Watch memory change. Watch the receipt prove why.",accent:"synapse",children:(o,d)=>{var p=ya(),A=xt(p);let S;var N=s(A);Nt(N,{name:"sparkle",size:14}),Ie(),a(A);var se=n(A,2),Me=s(se);Nt(Me,{name:"feed",size:14}),Ie(),a(se),B(()=>{S=pe(A,1,"mode-toggle svelte-1ayqwv0",null,S,{on:e(re)}),se.disabled=!e(E)}),Xe("click",A,()=>U(re,!e(re))),Xe("click",se,_e),y(o,p)},$$slots:{default:!0}});var W=n(ee,2),ve=s(W),X=n(s(ve),2);let be;var Y=s(X);let Ce;var Ke=n(Y);a(X),a(ve);var Je=n(ve,2),Dt=n(s(Je),2),vr=s(Dt,!0);a(Dt),a(Je);var Pt=n(Je,2),Ht=n(s(Pt),2),ur=s(Ht);{var dr=o=>{var d=_a();let p;var A=s(d,!0);a(d),B((S,N)=>{p=Ge(d,"",p,S),u(A,N)},[()=>{var S,N;return{"--c":ot((N=(S=l().data)==null?void 0:S.event)==null?void 0:N.type)}},()=>{var S,N;return We((N=(S=l().data)==null?void 0:S.event)==null?void 0:N.type)}]),y(o,d)},pr=o=>{var d=ba();y(o,d)};O(ur,o=>{l()?o(dr):o(pr,!1)})}a(Ht),a(Pt);var Wt=n(Pt,2),jt=n(s(Wt),2),fr=s(jt);ar(fr,{get value(){return c().length}}),a(jt),a(Wt),a(W),we(W,o=>{var d;return(d=xe)==null?void 0:d(o)});var Qt=n(W,2);{var mr=o=>{var d=ha(),p=n(s(d),2),A=s(p,!0);a(p);var S=n(p,2),N=s(S,!0);a(S);var se=n(S,2),Me=s(se,!0);a(se),a(d),we(d,Ze=>{var Ae;return(Ae=xe)==null?void 0:Ae(Ze)}),B(()=>{u(A,e(Q).label),u(N,e(Q).summary),u(Me,e(Q).provenance.id)}),y(o,d)};O(Qt,o=>{e(Q)&&o(mr)})}var yr=n(Qt,2);{var _r=o=>{var d=Wa(),p=s(d),A=n(s(p),2);{var S=x=>{var R=ga();y(x,R)},N=x=>{var R=Sa();fe(R,21,()=>e(q),te=>te.runId,(te,L)=>{var ke=Pa(),ue=s(ke);let Re;var ze=s(ue),Ee=s(ze),et=s(Ee,!0);a(Ee);var z=n(Ee,2),$e=s(z,!0);a(z),a(ze);var Te=n(ze,2),Ue=s(Te),Fe=s(Ue);a(Ue);var mt=n(Ue,2);{var Bt=$=>{var T=wa(),he=s(T);a(T),B(()=>u(he,`↑${e(L).retrievedCount??""}`)),y($,T)};O(mt,$=>{e(L).retrievedCount&&$(Bt)})}var yt=n(mt,2);{var Ne=$=>{var T=xa(),he=s(T);a(T),B(()=>u(he,`⊘${e(L).suppressedCount??""}`)),y($,T)};O(yt,$=>{e(L).suppressedCount&&$(Ne)})}var tt=n(yt,2);{var De=$=>{var T=qa(),he=s(T);a(T),B(()=>u(he,`✎${e(L).writeCount??""}`)),y($,T)};O(tt,$=>{e(L).writeCount&&$(De)})}var _t=n(tt,2);{var bt=$=>{var T=ka(),he=s(T);a(T),B(()=>u(he,`⛔${e(L).vetoCount??""}`)),y($,T)};O(_t,$=>{e(L).vetoCount&&$(bt)})}a(Te),a(ue),a(ke),B($=>{Re=pe(ue,1,"run-row svelte-1ayqwv0",null,Re,{active:e(L).runId===e(E)}),u(et,$),u($e,e(L).firstTool??"—"),u(Fe,`${e(L).eventCount??""} ev`)},[()=>e(L).runId.replace("run_","").slice(0,10)]),Xe("click",ue,()=>ct(e(L).runId)),y(te,ke)}),a(R),y(x,R)};O(A,x=>{e(q).length===0?x(S):x(N,!1)})}a(p),we(p,x=>{var R;return(R=xe)==null?void 0:R(x)});var se=n(p,2),Me=s(se);{var Ze=x=>{var R=Ba();y(x,R)},Ae=x=>{var R=Ca(),te=s(R,!0);a(R),B(()=>u(te,e(M))),y(x,R)},St=x=>{var R=Ma();y(x,R)},Le=x=>{var R=Ha(),te=xt(R),L=s(te),ke=s(L),ue=n(s(ke)),Re=s(ue,!0);a(ue);var ze=n(ue);a(ke);var Ee=n(ke,2);{var et=h=>{var m=Ra(),F=s(m);a(m),B(C=>u(F,`+${C??""}ms`),[()=>sr(e(w).at,e(le))]),y(h,m)};O(Ee,h=>{e(w)&&h(et)})}a(L);var z=n(L,2);Br(z);var $e=n(z,2);fe($e,21,()=>e(g).events,rr,(h,m,F)=>{var C=Ea();let D,Pe;B((de,Oe,He)=>{D=pe(C,1,"tick svelte-1ayqwv0",null,D,{past:F<=e(G)}),qt(C,"title",de),qt(C,"aria-label",Oe),Pe=Ge(C,"",Pe,He)},[()=>We(e(m).type),()=>`Step ${F+1}: ${We(e(m).type)}`,()=>({"--c":ot(e(m).type)})]),Xe("click",C,()=>U(G,F,!0)),y(h,C)}),a($e),a(te),we(te,h=>{var m;return(m=xe)==null?void 0:m(h)});var Te=n(te,2);{var Ue=h=>{var m=Oa();let F;var C=s(m),D=s(C),Pe=s(D,!0);a(D);var de=n(D,2),Oe=s(de,!0);a(de);var He=n(de,2),rt=s(He,!0);a(He),a(C);var at=n(C,2),st=s(at,!0);a(at);var Rt=n(at,2);{var ht=K=>{var H=Aa();fe(H,20,()=>e(w).ids,J=>J,(J,ne)=>{var ie=Ia();let Z;var Ve=s(ie),nt=s(Ve,!0);a(Ve);var It=n(Ve,2);{var At=it=>{var Lt=Ga(),xr=s(Lt);a(Lt),B(qr=>u(xr,`${qr??""}%`),[()=>(e(w).activation[ne]*100).toFixed(0)]),y(it,Lt)};O(It,it=>{e(w).activation[ne]!=null&&it(At)})}a(ie),B(it=>{Z=Ge(ie,"",Z,{"--a":e(w).activation[ne]??0}),u(nt,it)},[()=>ne.slice(0,8)]),y(J,ie)}),a(H),y(K,H)},Et=K=>{var H=za(),J=s(H),ne=s(J);a(J);var ie=n(J,4);fe(ie,16,()=>e(w).ids.filter(Z=>Z!==e(w).winnerId),Z=>Z,(Z,Ve)=>{var nt=La(),It=s(nt,!0);a(nt),B(At=>u(It,At),[()=>Ve.slice(0,8)]),y(Z,nt)}),a(H),B(Z=>u(ne,`kept ${Z??""}`),[()=>{var Z;return(Z=e(w).winnerId)==null?void 0:Z.slice(0,8)}]),y(K,H)},Gt=K=>{var H=Ua();fe(H,20,()=>e(w).evidenceIds,J=>J,(J,ne)=>{var ie=Ta(),Z=s(ie,!0);a(ie),B(Ve=>u(Z,Ve),[()=>ne.slice(0,8)]),y(J,ie)}),a(H),y(K,H)};O(Rt,K=>{e(w).type==="memory.retrieve"?K(ht):e(w).type==="contradiction.detected"?K(Et,1):e(w).type==="sanhedrin.veto"&&K(Gt,2)})}a(m),we(m,K=>{var H;return(H=xe)==null?void 0:H(K)}),B((K,H,J,ne,ie)=>{F=Ge(m,"",F,K),u(Pe,H),u(Oe,J),u(rt,ne),u(st,ie)},[()=>({"--c":ot(e(w).type)}),()=>Ut(e(w).type),()=>We(e(w).type),()=>Zr(e(w).at),()=>Ot(e(w))]),y(h,m)};O(Te,h=>{e(w)&&h(Ue)})}var Fe=n(Te,2),mt=n(s(Fe),2);{var Bt=h=>{var m=Va();y(h,m)},yt=h=>{var m=Fa();fe(m,20,()=>e(me),F=>F,(F,C)=>{var D=$a(),Pe=s(D,!0);a(D),B(de=>u(Pe,de),[()=>C.slice(0,8)]),y(F,D)}),a(m),y(h,m)};O(mt,h=>{e(me).length===0?h(Bt):h(yt,!1)})}a(Fe),we(Fe,h=>{var m;return(m=xe)==null?void 0:m(h)});var Ne=n(Fe,2),tt=n(s(Ne),2),De=n(s(tt),2);let _t;var bt=n(s(De),2),$=s(bt,!0);a(bt),a(De);var T=n(De,2);let he;var Xt=n(s(T),2),hr=s(Xt,!0);a(Xt),a(T);var Ct=n(T,2);let Yt;var Kt=n(s(Ct),2),gr=s(Kt,!0);a(Kt),a(Ct),a(tt),a(Ne),we(Ne,h=>{var m;return(m=xe)==null?void 0:m(h)});var Jt=n(Ne,2);{var wr=h=>{var m=Na(),F=n(s(m),2);fe(F,21,()=>e(ae).slice(0,2),C=>C.receipt_id,(C,D)=>{Kr(C,{get receipt(){return e(D)}})}),a(F),a(m),we(m,C=>{var D;return(D=xe)==null?void 0:D(C)}),y(h,m)};O(Jt,h=>{e(ae).length&&h(wr)})}var Mt=n(Jt,2),Zt=n(s(Mt),2);fe(Zt,21,()=>e(g).events,rr,(h,m,F)=>{var C=Da();let D,Pe;var de=s(C),Oe=s(de),He=s(Oe,!0);a(Oe);var rt=n(Oe,2),at=s(rt,!0);a(rt);var st=n(rt,2),Rt=s(st,!0);a(st);var ht=n(st,2),Et=s(ht);a(ht),a(de),a(C),B((Gt,K,H,J,ne)=>{D=pe(C,1,"log-row svelte-1ayqwv0",null,D,{active:F===e(G),dim:F>e(G)}),Pe=Ge(C,"",Pe,Gt),u(He,K),u(at,H),u(Rt,J),u(Et,`+${ne??""}ms`)},[()=>({"--c":ot(e(m).type)}),()=>Ut(e(m).type),()=>We(e(m).type),()=>Ot(e(m)),()=>sr(e(m).at,e(le))]),Xe("click",de,()=>U(G,F,!0)),y(h,C)}),a(Zt),a(Mt),we(Mt,h=>{var m;return(m=xe)==null?void 0:m(h)}),B(h=>{u(Re,e(G)+1),u(ze,` / ${e(g).events.length??""}`),qt(z,"max",h),_t=pe(De,1,"producer svelte-1ayqwv0",null,_t,{ok:e(k)}),u($,e(k)?"fired this run":"no contradiction in this run"),he=pe(T,1,"producer caveat svelte-1ayqwv0",null,he,{ok:e(i)}),u(hr,e(i)?"fired this run":"No dream run in this trace"),Yt=pe(Ct,1,"producer caveat svelte-1ayqwv0",null,Yt,{ok:e(oe)}),u(gr,e(oe)?"fired this run":"No veto producer connected (optional Sanhedrin hook, off by default)")},[()=>Math.max(0,e(g).events.length-1)]),Mr(z,()=>e(G),h=>U(G,h)),y(x,R)};O(Me,x=>{e(I)?x(Ze):e(M)?x(Ae,1):e(g)?x(Le,!1):x(St,2)})}a(se),a(d),y(o,d)},br=o=>{var d=Qa(),p=s(d),A=s(p);let S;var N=n(A,2),se=s(N,!0);a(N),a(p);var Me=n(p,2);{var Ze=Le=>{const x=ge(()=>{var z;return(z=l().data)==null?void 0:z.event});var R=ja();let te;var L=s(R),ke=s(L,!0);a(L);var ue=n(L,2),Re=s(ue),ze=s(Re,!0);a(Re);var Ee=n(Re,2),et=s(Ee,!0);a(Ee),a(ue),a(R),B((z,$e,Te,Ue)=>{te=Ge(R,"",te,z),u(ke,$e),u(ze,Te),u(et,Ue)},[()=>{var z;return{"--c":ot((z=e(x))==null?void 0:z.type)}},()=>{var z;return Ut((z=e(x))==null?void 0:z.type)},()=>{var z;return We((z=e(x))==null?void 0:z.type)},()=>Ot(e(x))]),y(Le,R)};O(Me,Le=>{l()&&Le(Ze)})}var Ae=n(Me,2),St=s(Ae);ar(St,{get value(){return c().length}}),Ie(2),a(Ae),Ie(2),a(d),we(d,Le=>{var x;return(x=xe)==null?void 0:x(Le)}),B(()=>{S=pe(A,1,"dot big svelte-1ayqwv0",null,S,{live:v()}),u(se,b()??"awaiting run…")}),y(o,d)};O(yr,o=>{e(re)?o(br,!1):o(_r)})}a(ft),B(()=>{be=pe(X,1,"spine-value svelte-1ayqwv0",null,be,{live:v()}),Ce=pe(Y,1,"dot svelte-1ayqwv0",null,Ce,{live:v()}),u(Ke,` ${v()?"Connected":"Offline"}`),u(vr,b()??"—")}),y(t,dt),or(),P()}ir(["click"]);export{fs as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/6.CNes4HHG.js.br b/apps/dashboard/build/_app/immutable/nodes/6.CNes4HHG.js.br deleted file mode 100644 index 4626e7a..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/6.CNes4HHG.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/6.CNes4HHG.js.gz b/apps/dashboard/build/_app/immutable/nodes/6.CNes4HHG.js.gz deleted file mode 100644 index 997a7cc..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/6.CNes4HHG.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/7.Cs_QL9bJ.js b/apps/dashboard/build/_app/immutable/nodes/7.Cs_QL9bJ.js deleted file mode 100644 index 7e3e728..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/7.Cs_QL9bJ.js +++ /dev/null @@ -1,249 +0,0 @@ -var wr=Object.defineProperty;var Pr=(r,t,s)=>t in r?wr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s;var Q=(r,t,s)=>Pr(r,typeof t!="symbol"?t+"":t,s);import"../chunks/Bzak7iHL.js";import{d as Zt,b as ue,e as tt,s as w,o as $t}from"../chunks/DAau0uzT.js";import{p as er,c as a,X as l,aH as rt,Y as W,g as e,s as P,a as R,u as $,r as i,af as me,b as tr,d as Z,f as O,aP as jt,e as Ut}from"../chunks/CGq8RnJq.js";import{i as X}from"../chunks/Ccqjq5DS.js";import{e as De,s as h,i as Pt}from"../chunks/DqfV0sZu.js";import{P as Mr,A as je,a as Le,r as Oe}from"../chunks/B9l3DI-J.js";import{s as Vt}from"../chunks/uCQU803Y.js";import{s as be}from"../chunks/HFGAk8XQ.js";import{p as Mt,s as Br,a as Sr}from"../chunks/DV6OI5iy.js";import{D as Yt}from"../chunks/DnDQzBs4.js";import{I as Bt}from"../chunks/CKbQrCJw.js";import{R as Gr}from"../chunks/BpEKQwpr.js";import{r as ot,M as Fr,I as Ht,R as Ar,m as Wt,a as Rr}from"../chunks/BMB5u1EX.js";import{L as jr,l as Lr}from"../chunks/DETSv_kY.js";import{a as qt}from"../chunks/D35IQVqe.js";import{e as Or}from"../chunks/Ch9vNiEl.js";const rr=.7,sr=.5,Dr="#ef4444",Tr="#f59e0b",Er="#fde047";function At(r){return r>rr?Dr:r>sr?Tr:Er}function ir(r){return r>rr?"strong":r>sr?"moderate":"mild"}const Qt="#8b5cf6",Ir={fact:"#3b82f6",concept:"#8b5cf6",event:"#f59e0b",person:"#10b981",place:"#06b6d4",note:"#6b7280",pattern:"#ec4899",decision:"#ef4444"};function Xt(r){return r?Ir[r]??Qt:Qt}const Kt=5,Cr=9;function Nr(r){if(!Number.isFinite(r))return Kt;const t=r<0?0:r>1?1:r;return Kt+t*Cr}const zr=.12;function Jt(r,t){return t==null||t===r?1:zr}function ct(r,t=60){return r==null||typeof r!="string"||t<=0?"":r.length<=t?r:r.slice(0,t-1)+"…"}function $r(r){if(!r||r.length===0)return 0;const t=new Set;for(const s of r)s.memory_a_id&&t.add(s.memory_a_id),s.memory_b_id&&t.add(s.memory_b_id);return t.size}function Ur(r){if(!r||r.length===0)return 0;let t=0;for(const s of r)t+=Math.abs((s.trust_a??0)-(s.trust_b??0));return t/r.length}var Vr=jt('',1),Yr=jt(' '),Hr=jt('',1),Wr=O('
          '),qr=O('
          '),Qr=O('
          '),Xr=O('
          topic:
          '),Kr=O('
          SEVERITYstrong (>0.7)moderate (0.5-0.7)mild (0.3-0.5)
          ');function Jr(r,t){er(t,!0);let s=Mt(t,"focusedPairIndex",3,null),c=Mt(t,"width",3,800),n=Mt(t,"height",3,600);const o=$(()=>{const _=c()/2,u=n()/2,C=Math.min(c(),n())*.38;return{cx:_,cy:u,R:C}}),m=$(()=>{const _=[],u=[],C=t.contradictions.length||1;return t.contradictions.forEach((k,T)=>{const Y=T/C*Math.PI*2-Math.PI/2,M=.18+k.similarity*.22,E=Y-M,B=Y+M,se=e(o).R+Math.sin(T*2.3)*18,ie=e(o).R+Math.cos(T*1.7)*18,D={x:e(o).cx+Math.cos(E)*se,y:e(o).cy+Math.sin(E)*se,trust:k.trust_a,preview:k.memory_a_preview,type:k.memory_a_type,created:k.memory_a_created,tags:k.memory_a_tags,memoryId:k.memory_a_id,pairIndex:T,side:"a"},z={x:e(o).cx+Math.cos(B)*ie,y:e(o).cy+Math.sin(B)*ie,trust:k.trust_b,preview:k.memory_b_preview,type:k.memory_b_type,created:k.memory_b_created,tags:k.memory_b_tags,memoryId:k.memory_b_id,pairIndex:T,side:"b"};_.push(D,z);const ne=(D.x+z.x)/2,q=(D.y+z.y)/2,K=.55-k.similarity*.25,le=ne+(e(o).cx-ne)*K,xe=q+(e(o).cy-q)*K,pt=1+Math.min(k.trust_a,k.trust_b)*4;u.push({pairIndex:T,path:`M ${D.x.toFixed(1)} ${D.y.toFixed(1)} Q ${le.toFixed(1)} ${xe.toFixed(1)} ${z.x.toFixed(1)} ${z.y.toFixed(1)}`,color:At(k.similarity),thickness:pt,severity:ir(k.similarity),topic:k.topic,similarity:k.similarity,dateDiff:k.date_diff_days,aPoint:D,bPoint:z,midX:le,midY:xe})}),{nodes:_,arcs:u}});let p=Z(null),g=Z(null),F=Z(0),v=Z(0);function j(_){const u=_.currentTarget.getBoundingClientRect();P(F,_.clientX-u.left),P(v,_.clientY-u.top)}function I(_){t.onSelectPair&&t.onSelectPair(s()===_?null:_)}function U(){var _;(_=t.onSelectPair)==null||_.call(t,null)}var b=Kr(),G=a(b),V=l(a(G)),re=l(V),oe=l(re),he=l(oe);De(he,17,()=>e(m).arcs,_=>_.pairIndex,(_,u)=>{const C=$(()=>Jt(e(u).pairIndex,s())),k=$(()=>s()===e(u).pairIndex);var T=Vr(),Y=rt(T),M=l(Y),E=l(M);W(B=>{h(Y,"d",e(u).path),h(Y,"stroke",e(u).color),h(Y,"stroke-width",e(u).thickness*3),h(Y,"stroke-opacity",.08*e(C)),h(M,"d",e(u).path),h(M,"stroke",e(u).color),h(M,"stroke-width",e(u).thickness*(e(k)?1.6:1)),h(M,"stroke-opacity",(e(k)?1:.72)*e(C)),h(M,"aria-label",`contradiction ${e(u).pairIndex+1}: ${e(u).topic??""}`),h(E,"d",e(u).path),h(E,"stroke",e(u).color),h(E,"stroke-width",B),h(E,"stroke-opacity",.85*e(C)),be(E,`animation-duration: ${4+e(u).pairIndex%5}s`)},[()=>Math.max(1,e(u).thickness*.6)]),ue("click",M,B=>{B.stopPropagation(),I(e(u).pairIndex)}),tt("mouseenter",M,()=>P(g,e(u),!0)),tt("mouseleave",M,()=>P(g,null)),ue("keydown",M,B=>{B.key==="Enter"&&I(e(u).pairIndex)}),R(_,T)});var Se=l(he);De(Se,19,()=>e(m).nodes,(_,u)=>_.memoryId+"-"+_.side+"-"+u,(_,u)=>{const C=$(()=>Jt(e(u).pairIndex,s())),k=$(()=>s()===e(u).pairIndex),T=$(()=>Nr(e(u).trust)),Y=$(()=>Xt(e(u).type));var M=Hr(),E=rt(M),B=l(E),se=l(B);{var ie=D=>{var z=Yr(),ne=a(z,!0);i(z),W(q=>{h(z,"x",e(u).x),h(z,"y",e(u).y-e(T)-8),w(ne,q)},[()=>ct(e(u).preview,40)]),R(D,z)};X(se,D=>{e(k)&&D(ie)})}W(D=>{h(E,"cx",e(u).x),h(E,"cy",e(u).y),h(E,"r",e(T)*2.2),h(E,"fill",e(Y)),h(E,"opacity",.12*e(C)),h(B,"cx",e(u).x),h(B,"cy",e(u).y),h(B,"r",e(T)),h(B,"fill",e(Y)),h(B,"opacity",e(C)),h(B,"stroke-opacity",e(k)?.85:.25),h(B,"stroke-width",e(k)?2:1),h(B,"aria-label",`memory ${D??""}`)},[()=>ct(e(u).preview,40)]),tt("mouseenter",B,()=>P(p,e(u),!0)),tt("mouseleave",B,()=>P(p,null)),ue("click",B,D=>{D.stopPropagation(),I(e(u).pairIndex)}),ue("keydown",B,D=>{D.key==="Enter"&&I(e(u).pairIndex)}),R(_,M)}),me(),i(G);var Ge=l(G,2);{var ut=_=>{var u=Qr(),C=a(u),k=a(C),T=l(k,2),Y=a(T,!0);i(T);var M=l(T,2),E=a(M);i(M),i(C);var B=l(C,2),se=a(B,!0);i(B);var ie=l(B,2);{var D=q=>{var K=Wr(),le=a(K);i(K),W(()=>w(le,`created ${e(p).created??""}`)),R(q,K)};X(ie,q=>{e(p).created&&q(D)})}var z=l(ie,2);{var ne=q=>{var K=qr(),le=a(K,!0);i(K),W(xe=>w(le,xe),[()=>e(p).tags.slice(0,4).join(" · ")]),R(q,K)};X(z,q=>{e(p).tags&&e(p).tags.length>0&&q(ne)})}i(u),W((q,K,le,xe)=>{be(u,`left: ${q??""}px; top: ${K??""}px;`),be(k,`background: ${le??""}`),w(Y,e(p).type??"memory"),w(E,`trust ${xe??""}%`),w(se,e(p).preview)},[()=>Math.max(0,Math.min(e(F)+12,c()-240)),()=>Math.max(0,Math.min(e(v)-8,n()-120)),()=>Xt(e(p).type),()=>(e(p).trust*100).toFixed(0)]),R(_,u)},fe=_=>{var u=Xr(),C=a(u),k=a(C),T=l(k,2),Y=a(T);i(T),i(C);var M=l(C,2),E=l(a(M)),B=a(E,!0);i(E),i(M);var se=l(M,2),ie=a(se);i(se),i(u),W((D,z,ne)=>{be(u,`left: ${D??""}px; top: ${z??""}px;`),be(k,`background: ${e(g).color??""}`),w(Y,`${e(g).severity??""} conflict`),w(B,e(g).topic),w(ie,`similarity ${ne??""}% · ${e(g).dateDiff??""}d apart`)},[()=>Math.max(0,Math.min(e(F)+12,c()-240)),()=>Math.max(0,Math.min(e(v)-8,n()-120)),()=>(e(g).similarity*100).toFixed(0)]),R(_,u)};X(Ge,_=>{e(p)?_(ut):e(g)&&_(fe,1)})}i(b),W(()=>{be(b,`aspect-ratio: ${c()??""} / ${n()??""};`),h(G,"width",c()),h(G,"height",n()),h(G,"viewBox",`0 0 ${c()??""} ${n()??""}`),h(V,"width",c()),h(V,"height",n()),h(re,"cx",e(o).cx),h(re,"cy",e(o).cy),h(re,"r",e(o).R),h(oe,"cx",e(o).cx),h(oe,"cy",e(o).cy)}),ue("mousemove",G,j),tt("mouseleave",G,()=>{P(p,null),P(g,null)}),ue("click",G,U),R(r,b),tr()}Zt(["mousemove","click","keydown"]);const nt="rgba16float",lt=160,St=16,ar=` -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - capture_mode: f32, - live_kind: f32, - live_frame: f32, - live_energy: f32, - projection_days: f32, -}; - -struct PairCell { - // stronger.xy, stronger trust, stronger membrane width - stronger: vec4f, - // weaker.xy, weaker trust, weaker membrane width - weaker: vec4f, - // x topic overlap, y trust delta, z unresolved, w slot phase - signals: vec4f, - // x pair index, y unused, z unused, w unused - ids: vec4f, -}; -`,Zr=` -${ar} - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var pairs: array; - -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); - -struct VSOut { - @builtin(position) clip: vec4f, - @location(0) uv: vec2f, - @location(1) @interpolate(flat) misc: vec4f, -}; - -@vertex -fn vs_splat(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - var out: VSOut; - let pair_i = ii / 2u; - let side = ii % 2u; - let p = pairs[pair_i]; - let stronger_side = side == 0u; - let cell = select(p.weaker, p.stronger, stronger_side); - let trust = cell.z; - let width = cell.w; - let overlap = p.signals.x; - let unresolved = p.signals.z; - let breathing = 1.0 + 0.05 * sin(params.time * 2.2 + p.signals.w * 6.28318); - let radius = (0.105 + 0.05 * overlap + width * 1.8) * breathing; - out.clip = vec4f(cell.xy + QUAD[vi] * radius, 0.0, 1.0); - out.uv = QUAD[vi]; - out.misc = vec4f(trust, overlap, f32(side), unresolved); - return out; -} - -@fragment -fn fs_splat(in: VSOut) -> @location(0) vec4f { - let d = length(in.uv); - if (d > 1.0) { discard; } - let trust = clamp(in.misc.x, 0.0, 1.0); - let overlap = clamp(in.misc.y, 0.0, 1.0); - let side = in.misc.z; - let unresolved = in.misc.w; - let body = exp(-d * d * 3.4) * (0.42 + trust * 0.72) * (0.45 + overlap * 0.7); - let membrane = smoothstep(0.22, 0.02, abs(d - (0.62 + trust * 0.16))) * (0.18 + trust * 0.75); - let spark = unresolved * smoothstep(0.96, 0.68, d) * (0.6 + 0.4 * sin(params.time * 16.0 + in.uv.x * 7.0)); - // Dual-channel signed field: stronger splats red, weaker splats green. - let r = select(0.0, body + membrane * 0.55, side < 0.5); - let g = select(body + membrane * 0.55, 0.0, side < 0.5); - return vec4f(r, g, spark * 0.36, 1.0); -} - -@vertex -fn vs_cell(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - var out: VSOut; - let pair_i = ii / 2u; - let side = ii % 2u; - let p = pairs[pair_i]; - let stronger_side = side == 0u; - let cell = select(p.weaker, p.stronger, stronger_side); - let trust = cell.z; - let width = cell.w; - let radius = 0.028 + trust * 0.026 + width * 0.85; - out.clip = vec4f(cell.xy + QUAD[vi] * radius, 0.0, 1.0); - out.uv = QUAD[vi]; - out.misc = vec4f(trust, p.signals.x, f32(side), p.signals.z); - return out; -} - -@fragment -fn fs_cell(in: VSOut) -> @location(0) vec4f { - let d = length(in.uv); - if (d > 1.0) { discard; } - let trust = clamp(in.misc.x, 0.0, 1.0); - let side = in.misc.z; - let unresolved = in.misc.w; - let ivory = vec3f(0.96, 0.945, 0.815); - let luciferin = vec3f(0.66, 1.0, 0.37); - let redcore = vec3f(1.0, 0.23, 0.18); - let weaker_green = vec3f(0.16, 0.95, 0.66); - let core = select(weaker_green, mix(luciferin, ivory, trust), side < 0.5); - let rim = smoothstep(0.98, 0.72, d) * (1.0 - smoothstep(0.72, 0.2, d)); - let body = exp(-d*d*3.0) * (0.22 + trust * 0.42); - let flare = unresolved * smoothstep(0.18, 0.0, abs(d - 0.78)); - return vec4f(core * body + ivory * rim * (0.28 + trust * 0.52) + redcore * flare * 0.18, 1.0); -} - -@vertex -fn vs_arc(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - var out: VSOut; - let p = pairs[ii]; - let a = p.stronger.xy; - let b = p.weaker.xy; - let t = f32(vi / 2u) / 31.0; - let side = f32(vi % 2u) * 2.0 - 1.0; - let mid = (a + b) * 0.5; - let dir = normalize(b - a + vec2f(0.0001)); - let norm = vec2f(-dir.y, dir.x); - let bow = norm * sin(t * 3.14159) * (0.06 + p.signals.x * 0.12); - let pos = mix(a, b, t) + bow; - let thickness = (0.004 + min(p.stronger.z, p.weaker.z) * 0.011) * (1.0 + p.signals.z * (0.4 + 0.4 * sin(params.time * 18.0 + t * 20.0))); - out.clip = vec4f(pos + norm * side * thickness, 0.0, 1.0); - out.uv = vec2f(t, side); - out.misc = vec4f(p.signals.x, p.signals.y, p.signals.z, distance(pos, mid)); - return out; -} - -@fragment -fn fs_arc(in: VSOut) -> @location(0) vec4f { - let unresolved = in.misc.z; - let overlap = in.misc.x; - let pulse = 0.55 + 0.45 * sin(42.0 * in.uv.x - 8.0 * in.misc.w); - let scarlet = vec3f(1.0, 0.13, 0.09); - let darkred = vec3f(0.73, 0.05, 0.17); - let color = mix(darkred, scarlet, pulse * unresolved + overlap * 0.35); - return vec4f(color * (0.12 + unresolved * 0.55 + overlap * 0.26), 1.0); -} -`,es=` -${ar} - -@group(0) @binding(0) var params: Params; -@group(0) @binding(2) var field_sampler: sampler; -@group(0) @binding(3) var field_tex: texture_2d; - -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); - -struct VSOut { - @builtin(position) clip: vec4f, - @location(0) uv: vec2f, -}; - -@vertex -fn vs_fullscreen(@builtin(vertex_index) vi: u32) -> VSOut { - var out: VSOut; - let p = QUAD[vi]; - out.clip = vec4f(p, 0.0, 1.0); - out.uv = p * 0.5 + vec2f(0.5); - return out; -} - -@fragment -fn fs_membrane(in: VSOut) -> @location(0) vec4f { - let dims = vec2f(textureDimensions(field_tex, 0)); - let px = 1.0 / max(dims, vec2f(1.0)); - let f = textureSample(field_tex, field_sampler, in.uv); - let left = textureSampleLevel(field_tex, field_sampler, in.uv - vec2f(px.x, 0.0), 0.0); - let right = textureSampleLevel(field_tex, field_sampler, in.uv + vec2f(px.x, 0.0), 0.0); - let down = textureSampleLevel(field_tex, field_sampler, in.uv - vec2f(0.0, px.y), 0.0); - let up = textureSampleLevel(field_tex, field_sampler, in.uv + vec2f(0.0, px.y), 0.0); - - let strong = clamp(f.r, 0.0, 5.0); - let weak = clamp(f.g, 0.0, 5.0); - let seam = min(strong, weak); - let grad_r = vec2f(right.r - left.r, up.r - down.r); - let grad_g = vec2f(right.g - left.g, up.g - down.g); - let opposing = max(0.0, -dot(normalize(grad_r + vec2f(0.0001)), normalize(grad_g + vec2f(0.0001)))); - let fracture = smoothstep(0.11, 1.1, seam) * (0.42 + 0.9 * opposing); - let membrane = smoothstep(0.10, 0.95, max(strong, weak)) * (1.0 - smoothstep(1.75, 3.6, max(strong, weak))); - let spark = clamp(f.b, 0.0, 2.0) * (0.6 + 0.4 * params.pulse); - - let blackwater = vec3f(0.008, 0.012, 0.018); - let stronger_glow = vec3f(1.0, 0.21, 0.16); - let weaker_glow = vec3f(0.15, 0.95, 0.62); - let ivory = vec3f(0.96, 0.945, 0.815); - let scarlet = vec3f(1.0, 0.09, 0.055); - let lacquer = vec3f(0.73, 0.05, 0.17); - - var color = blackwater * (0.16 + 0.05 * max(strong, weak)); - color = color + stronger_glow * strong * 0.045 + weaker_glow * weak * 0.035; - color = color + ivory * membrane * 0.10; - color = color + mix(lacquer, scarlet, opposing) * fracture * (0.55 + seam * 0.18); - color = color + scarlet * spark * 0.28; - let vignette = smoothstep(0.96, 0.20, distance(in.uv, vec2f(0.5))); - return vec4f(color * (0.35 + 0.65 * vignette) * params.brightness, 1.0); -} -`,ts=` -struct BlurDir { - dir: vec2f, - _pad: vec2f, -}; - -@group(0) @binding(0) var blur_sampler: sampler; -@group(0) @binding(1) var blur_src: texture_2d; -@group(0) @binding(2) var blur_dir: BlurDir; - -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); - -struct VSOut { @builtin(position) clip: vec4f, @location(0) uv: vec2f }; - -@vertex -fn vs_fullscreen(@builtin(vertex_index) vi: u32) -> VSOut { - var out: VSOut; - let p = QUAD[vi]; - out.clip = vec4f(p, 0.0, 1.0); - out.uv = p * 0.5 + vec2f(0.5); - return out; -} - -@fragment -fn fs_blur(in: VSOut) -> @location(0) vec4f { - let dims = vec2f(textureDimensions(blur_src, 0)); - let stepv = blur_dir.dir / max(dims, vec2f(1.0)); - var acc = textureSampleLevel(blur_src, blur_sampler, in.uv - stepv * 2.0, 0.0) * 0.06136; - acc = acc + textureSampleLevel(blur_src, blur_sampler, in.uv - stepv, 0.0) * 0.24477; - acc = acc + textureSampleLevel(blur_src, blur_sampler, in.uv, 0.0) * 0.38774; - acc = acc + textureSampleLevel(blur_src, blur_sampler, in.uv + stepv, 0.0) * 0.24477; - acc = acc + textureSampleLevel(blur_src, blur_sampler, in.uv + stepv * 2.0, 0.0) * 0.06136; - return acc; -} -`;class rs{constructor(t,s){Q(this,"engine");Q(this,"scene",null);Q(this,"resources",null);Q(this,"sampler",null);Q(this,"splatBindLayout",null);Q(this,"blurBindLayout",null);Q(this,"membraneBindLayout",null);Q(this,"splatPipeline",null);Q(this,"blurPipeline",null);Q(this,"membranePipeline",null);Q(this,"cellPipeline",null);Q(this,"arcPipeline",null);Q(this,"pairCount",0);Q(this,"pairGeometry",[]);this.engine=t,this.uploadScene(s)}uploadScene(t){this.scene=t,this.buildPairGeometry();const s=this.engine.gpuDevice;s&&(this.ensurePipelines(s),this.ensureResources(s),this.uploadBuffers(s))}ensurePipelines(t){if(this.splatPipeline||!this.engine.paramsBuffer)return;const s=Gt(t,"contradictions-synapse-splat-wgsl",Zr),c=Gt(t,"contradictions-synapse-blur-wgsl",ts),n=Gt(t,"contradictions-synapse-membrane-wgsl",es);this.splatBindLayout=t.createBindGroupLayout({label:"contradictions-synapse-splat-bind-layout",entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.VERTEX,buffer:{type:"read-only-storage"}}]}),this.blurBindLayout=t.createBindGroupLayout({label:"contradictions-synapse-blur-bind-layout",entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:2,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}}]}),this.membraneBindLayout=t.createBindGroupLayout({label:"contradictions-synapse-membrane-bind-layout",entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:2,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:3,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}}]});const o=t.createPipelineLayout({label:"contradictions-synapse-splat-layout",bindGroupLayouts:[this.splatBindLayout]}),m=t.createPipelineLayout({label:"contradictions-synapse-blur-layout",bindGroupLayouts:[this.blurBindLayout]}),p=t.createPipelineLayout({label:"contradictions-synapse-membrane-layout",bindGroupLayouts:[this.membraneBindLayout]});this.sampler=t.createSampler({magFilter:"linear",minFilter:"linear"}),this.splatPipeline=t.createRenderPipeline({label:"contradictions-field-additive-splat",layout:o,vertex:{module:s,entryPoint:"vs_splat"},fragment:{module:s,entryPoint:"fs_splat",targets:[{format:nt,blend:{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}}]},primitive:{topology:"triangle-list"}}),this.blurPipeline=t.createRenderPipeline({label:"contradictions-field-blur-render-pass",layout:m,vertex:{module:c,entryPoint:"vs_fullscreen"},fragment:{module:c,entryPoint:"fs_blur",targets:[{format:nt}]},primitive:{topology:"triangle-list"}});const g={color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}};this.membranePipeline=t.createRenderPipeline({label:"contradictions-immune-synapse-membrane",layout:p,vertex:{module:n,entryPoint:"vs_fullscreen"},fragment:{module:n,entryPoint:"fs_membrane",targets:[{format:this.engine.sceneFormat,blend:g}]},primitive:{topology:"triangle-list"}}),this.cellPipeline=t.createRenderPipeline({label:"contradictions-memory-membrane-cells",layout:o,vertex:{module:s,entryPoint:"vs_cell"},fragment:{module:s,entryPoint:"fs_cell",targets:[{format:this.engine.sceneFormat,blend:g}]},primitive:{topology:"triangle-list"}}),this.arcPipeline=t.createRenderPipeline({label:"contradictions-scarlet-unresolved-arcs",layout:o,vertex:{module:s,entryPoint:"vs_arc"},fragment:{module:s,entryPoint:"fs_arc",targets:[{format:this.engine.sceneFormat,blend:g}]},primitive:{topology:"triangle-strip"}})}ensureResources(t){var re,oe,he,Se,Ge;if(!this.splatBindLayout||!this.blurBindLayout||!this.membraneBindLayout||!this.engine.paramsBuffer||!this.sampler)return;const s=Math.max(16,Math.floor((this.engine.params[6]||1280)/2)),c=Math.max(16,Math.floor((this.engine.params[7]||720)/2)),n=!this.resources||this.resources.fieldSize[0]!==s||this.resources.fieldSize[1]!==c;let o=(re=this.resources)==null?void 0:re.pairBuffer,m=(oe=this.resources)==null?void 0:oe.blurHBuffer,p=(he=this.resources)==null?void 0:he.blurVBuffer;if(o||(o=t.createBuffer({label:"contradictions-pairs",size:lt*St*4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})),m||(m=t.createBuffer({label:"contradictions-blur-h-dir",size:16,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),t.queue.writeBuffer(m,0,new Float32Array([1,0,0,0]))),p||(p=t.createBuffer({label:"contradictions-blur-v-dir",size:16,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),t.queue.writeBuffer(p,0,new Float32Array([0,1,0,0]))),!n&&this.resources)return;(Se=this.resources)==null||Se.fieldA.destroy(),(Ge=this.resources)==null||Ge.fieldB.destroy();const g=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING,F=t.createTexture({label:"contradictions-field-a-rgba16float",size:[s,c],format:nt,usage:g}),v=t.createTexture({label:"contradictions-field-b-rgba16float",size:[s,c],format:nt,usage:g}),j=F.createView(),I=v.createView(),U=t.createBindGroup({label:"contradictions-synapse-splat-bind",layout:this.splatBindLayout,entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:o}}]}),b=t.createBindGroup({label:"contradictions-field-blur-h-bind",layout:this.blurBindLayout,entries:[{binding:0,resource:this.sampler},{binding:1,resource:j},{binding:2,resource:{buffer:m}}]}),G=t.createBindGroup({label:"contradictions-field-blur-v-bind",layout:this.blurBindLayout,entries:[{binding:0,resource:this.sampler},{binding:1,resource:I},{binding:2,resource:{buffer:p}}]}),V=t.createBindGroup({label:"contradictions-membrane-bind",layout:this.membraneBindLayout,entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:2,resource:this.sampler},{binding:3,resource:j}]});this.resources={pairBuffer:o,blurHBuffer:m,blurVBuffer:p,splatBindGroup:U,blurHBindGroup:b,blurVBindGroup:G,membraneBindGroup:V,fieldA:F,fieldB:v,fieldAView:j,fieldBView:I,fieldSize:[s,c]}}buildPairGeometry(){var c;const t=((c=this.scene)==null?void 0:c.pairs)??[],s=Math.max(1,t.length);this.pairGeometry=t.slice(0,lt).map((n,o)=>{const m=o/s*Math.PI*2-Math.PI/2,p=.42+.1*Math.sin(o*1.7),g=Math.cos(m)*p*.72,F=Math.sin(m)*p,v=m+Math.PI/2,j=.16+n.topic_overlap*.14,I=g+Math.cos(v)*j,U=F+Math.sin(v)*j,b=g-Math.cos(v)*j,G=F-Math.sin(v)*j;return{pair:n,ax:I,ay:U,bx:b,by:G,mx:g,my:F,radius:j*.95}})}uploadBuffers(t){if(!this.resources)return;const s=new Float32Array(lt*St);this.pairCount=Math.min(lt,this.pairGeometry.length);for(let c=0;c0&&(t.setPipeline(this.arcPipeline),t.setBindGroup(0,this.resources.splatBindGroup),t.draw(64,this.pairCount),t.setPipeline(this.cellPipeline),t.draw(6,this.pairCount*2)))}pickAt(t,s){for(let c=0;c{for(const o of n.messages)console.error(`[observatory] ${t} WGSL ${o.type} ${o.lineNum}:${o.linePos} ${o.message}`)}),r.popErrorScope().then(n=>{n&&console.error(`[observatory] ${t} shader module validation: ${n.message}`)}),c}function is(r,t){return ot(Fr.blackwater),ot(Ht.veto),ot(Ht.suppressionScar),ot(Ar.recall),[new rs(r,t)]}function Ft(r){return r&&typeof r=="object"&&!Array.isArray(r)?r:{}}function te(r,t=""){return typeof r=="string"?r:r==null?t:String(r)}function Be(r,t=0){return typeof r=="number"&&Number.isFinite(r)?r:t}function Rt(r){return Math.max(0,Math.min(1,r))}function as(r){const t=Be(r,0);return Rt(t>1?t/100:t)}function dt(r,t,s){return s?{kind:r,id:t,scalar:s}:{kind:r,id:t||`${r}:unknown`}}function os(r,t){return{kind:"scalar",id:`contradictions.${r}`,scalar:{name:r,value:t}}}function Te(r,t,s=""){const c=te(r.id??r.memory_id??t),n=as(r.trust??r.trust_score??0);return{id:c,preview:te(r.preview??r.content??s??c),trust:n,date:te(r.date??r.created_at??r.createdAt??""),type:r.node_type?te(r.node_type):r.nodeType?te(r.nodeType):void 0,tags:Array.isArray(r.tags)?r.tags.map(o=>te(o)).filter(Boolean):void 0,provenance:dt("memory",c)}}function or(r,t){return`contradiction:${r}:${t}`}function ns(r,t){const s=Ft(r),c=Ft(s.stronger),n=Ft(s.weaker);let o,m,p,g,F;if(Object.keys(c).length>0||Object.keys(n).length>0)o=Te(c,""),m=Te(n,""),p=Rt(Be(s.topic_overlap??s.similarity,0)),g=te(s.topic??s.summary??"trust-weighted contradiction"),F=Be(s.date_diff_days,0);else{const I=Te({id:s.memory_a_id??s.a_id,preview:s.memory_a_preview,trust:s.trust_a,date:s.memory_a_created,node_type:s.memory_a_type,tags:s.memory_a_tags},""),U=Te({id:s.memory_b_id??s.b_id,preview:s.memory_b_preview,trust:s.trust_b,date:s.memory_b_created,node_type:s.memory_b_type,tags:s.memory_b_tags},"");[o,m]=I.trust>=U.trust?[I,U]:[U,I],p=Rt(Be(s.topic_overlap??s.similarity,0)),g=te(s.topic??"trust-weighted contradiction"),F=Be(s.date_diff_days,0)}if(!o.id||!m.id)return null;const v=or(o.id,m.id),j=Math.abs(o.trust-m.trust);return{id:v,stronger:o,weaker:m,topic_overlap:p,topic:g,trust_delta:j,date_diff_days:F,resolved:te(s.status).toLowerCase()==="resolved"||!!s.resolved,provenance:dt("pair",v),receipt:{label:`immune synapse ${t+1}: ${o.id.slice(0,8)} ↔ ${m.id.slice(0,8)}`,evidence:s}}}function ls(r,t){var c;return r.type!=="DeepReferenceCompleted"?[]:(Array.isArray((c=r.data)==null?void 0:c.contradiction_pairs)?r.data.contradiction_pairs:[]).map((n,o)=>{const m=Array.isArray(n)?n:[],p=te(m[0]),g=te(m[1]);if(!p||!g)return null;const F=Te({id:p,preview:`DeepReference contradiction side ${p.slice(0,8)}`},p),v=Te({id:g,preview:`DeepReference contradiction side ${g.slice(0,8)}`},g),j=or(p,g);return{id:j,stronger:F,weaker:v,topic_overlap:.64,topic:te(r.data.query??r.data.intent??"deep_reference contradiction"),trust_delta:0,date_diff_days:0,resolved:!1,provenance:dt("event",`DeepReferenceCompleted:${te(r.data.timestamp,String(t+o))}:${j}`),receipt:{label:`DeepReference contradiction pair ${o+1}`,evidence:{query:r.data.query,intent:r.data.intent,status:r.data.status,confidence:r.data.confidence,memories_analyzed:r.data.memories_analyzed,contradiction_pair:[p,g]}}}}).filter(n=>!!n)}function cs(r){const t=r.contradictions??[],s=(r.deepReferenceEvents??[]).filter(b=>b.type==="DeepReferenceCompleted"),c=new Map;t.forEach((b,G)=>{const V=ns(b,G);V&&c.set(V.id,V)});for(const b of s)for(const G of ls(b,c.size))c.has(G.id)||c.set(G.id,G);const n=Array.from(c.values()),o=[],m=new Map,p=(b,G)=>{if(m.has(b.id))return m.get(b.id);const V=o.length;return m.set(b.id,V),o.push({source:b.provenance,index:V,label:b.preview||b.id.slice(0,8),retention:b.trust,trust:b.trust,lastAccessed:b.date||void 0,tags:[G,...b.tags??[]],type:b.type??"memory"}),V},g=[],F=[];n.forEach(b=>{const G=p(b.stronger,"stronger"),V=p(b.weaker,"weaker");g.push({source:b.provenance,sourceIndex:G,targetIndex:V,weight:Math.max(.1,b.topic_overlap),kind:"contradiction"}),F.push({source:b.provenance,label:b.receipt.label,nodeIndices:[G,V]})});const v=n.filter(b=>!b.resolved).length,j=n.length?n.reduce((b,G)=>b+G.trust_delta,0)/n.length:0,I=v?[{source:dt("scalar","contradictions.unresolved",{name:"unresolved",value:v}),type:"ContradictionUnresolved",targetIndex:-1,frame:80,energy:v}]:[],U={organ:"contradictions",nodes:o,edges:g,events:I,receipts:F,scalars:{total:Be(r.total,n.length),memoriesAnalyzed:Be(r.memoriesAnalyzed,o.length),pairCount:n.length,unresolved:v,avgTrustDelta:j},alive:n.length>0,pairs:n,raw:{apiPairs:t,deepReferenceEvents:s}};return os("pairCount",n.length),U}var ds=O(' in view'),us=O(`
          Couldn't load contradictions
          `),ps=O('
          '),vs=O('
          ',1),ms=O('
          No contradictions found — your memory agrees with itself.
          Pairs appear here when two trusted memories about the same topic make opposing claims.
          '),fs=O(''),xs=O('

          No contradictions match this filter.

          '),gs=O('
          No pairs visible.
          '),_s=O(' '),ys=O('
          '),bs=O(' '),hs=O('
          '),ks=O('
          Full memory A
          Full memory B
          '),ws=O(''),Ps=O('
          '),Ms=O('
          '),Bs=O('
          Contradiction receipt

          Higher-trust membrane

          Opposing evidence

          topic overlap
          trust delta
          status
          provenance
          '),Ss=O('
          average trust delta
          visible in current filter
          strong conflicts
          ',1),Gs=O('
          ',1);function Hs(r,t){er(t,!0);const s=()=>Sr(Or,"$eventFeed",c),[c,n]=Br();let o=Z(Ut([])),m=Z(0),p=Z(0),g=Z(!0),F=Z(null),v=Z(null);async function j(){P(g,!0),P(F,null);try{const d=await qt.contradictions();P(o,d.contradictions,!0),P(m,d.total,!0),P(p,d.memoriesAnalyzed,!0)}catch(d){P(F,d instanceof Error?d.message:"Failed to load contradictions",!0),P(o,[],!0),P(m,0),P(p,0)}finally{P(g,!1)}}$t(()=>j());let I=Z(Ut([])),U=null;$t(()=>{qt.memories.list({limit:"90"}).then(d=>{P(I,d.memories,!0),U==null||U.setCells(b())}).catch(()=>{})});function b(){const d=e(I).map(x=>{const f=G(x.retentionStrength);return{id:x.id,score:.3+.4*f,hue:Rr(f),energy:.16+.3*f,metric2:f,kind:"immune-tissue",payload:x}});return Lr(d,{maxRadius:.95,minCellR:.012,maxCellR:.044})}function G(d){return Math.min(1,Math.max(0,Number.isFinite(d)?d:0))}function V(d,x){const f=new jr(d);return U=f,f.setCells(b()),[{compute:J=>f.compute(J),render:J=>f.render(J),pickAt:(J,Ee)=>f.pickAt(J,Ee),dispose:()=>{f.dispose(),U===f&&(U=null)}},...is(d,x)]}let re=Z("all"),oe=Z("");const he=$(()=>Array.from(new Set(e(o).map(d=>d.topic))).sort()),Se=[{value:"all",label:"All contradictions",icon:"contradictions"},{value:"recent",label:"Recent (last 7 days)",icon:"timeline"},{value:"high-trust",label:"High trust (>60%)",icon:"importance"},{value:"topic",label:"By topic",icon:"filter"}],Ge=$(()=>[{value:"",label:"All topics"},...e(he).map(d=>({value:d,label:d,badge:e(o).filter(x=>x.topic===d).length}))]);function ut(d){P(re,d,!0),P(_,null)}const fe=$(()=>{switch(e(re)){case"recent":{const d=Date.now(),x=10080*60*1e3;return e(o).filter(f=>{const N=f.memory_a_created?new Date(f.memory_a_created).getTime():0,J=f.memory_b_created?new Date(f.memory_b_created).getTime():0;return d-Math.max(N,J)<=x})}case"high-trust":return e(o).filter(d=>Math.min(d.trust_a,d.trust_b)>.6);case"topic":return e(oe)?e(o).filter(d=>d.topic===e(oe)):e(o);case"all":default:return e(o)}});let _=Z(null);function u(d){var x;P(_,d,!0),P(v,d==null?null:((x=e(M)[d])==null?void 0:x.scenePair)??null,!0)}function C(d,x,f,N){return d===f&&x===N||d===N&&x===f}const k=$(()=>$r(e(o))),T=$(()=>Ur(e(o))),Y=$(()=>cs({contradictions:e(o),total:e(m),memoriesAnalyzed:e(p),deepReferenceEvents:s()})),M=$(()=>{const d=new Map(e(o).map((x,f)=>[x.memory_a_id+"|"+x.memory_b_id,f]));return e(fe).map(x=>({orig:d.get(x.memory_a_id+"|"+x.memory_b_id)??0,c:x,scenePair:e(Y).pairs.find(f=>C(f.stronger.id,f.weaker.id,x.memory_a_id,x.memory_b_id))??null}))});function E(d){var f;const x=e(_)===d?null:d;P(_,x,!0),P(v,x==null?null:((f=e(M)[x])==null?void 0:f.scenePair)??null,!0)}function B(d){if(d.kind!=="contradiction-seam")return;const x=d.payload;P(v,x,!0);const f=e(M).findIndex(N=>C(x.stronger.id,x.weaker.id,N.c.memory_a_id,N.c.memory_b_id));P(_,f>=0?f:null,!0)}var se=Gs(),ie=rt(se);{let d=$(()=>`immune-synapse-arena:${e(m)}:${e(p)}`);Gr(ie,{organ:"contradictions",get seed(){return e(d)},get scene(){return e(Y)},passes:V,get loading(){return e(g)},get error(){return e(F)},emptyLabel:"CALM IMMUNE FIELD - NO STANDING CONTRADICTIONS",onpick:B})}var D=l(ie,2),z=a(D),ne=a(z);Mr(ne,{icon:"contradictions",title:"Immune Synapse Arena",subtitle:"Contradictory memories face each other across a scarlet trust-weighted seam. Click a fracture for the receipt.",accent:"warning",children:(d,x)=>{var f=ds(),N=a(f);je(N,{get value(){return e(fe).length}}),me(),i(f),R(d,f)},$$slots:{default:!0}}),i(z);var q=l(z,2);{var K=d=>{var x=us(),f=l(a(x),2),N=a(f,!0);i(f);var J=l(f,2);i(x),W(()=>w(N,e(F))),ue("click",J,j),R(d,x)},le=d=>{var x=vs(),f=rt(x);De(f,20,()=>Array(4),Pt,(N,J)=>{var Ee=ps();R(N,Ee)}),i(f),me(2),R(d,x)},xe=d=>{var x=ms(),f=a(x),N=a(f);Bt(N,{name:"sparkle",size:26,draw:!0}),i(f),me(4),i(x),R(d,x)},pt=d=>{var x=Ss(),f=rt(x),N=a(f),J=a(N),Ee=a(J);je(Ee,{get value(){return e(m)}}),i(J);var Lt=l(J,2),nr=a(Lt);i(Lt),i(N),Le(N,(y,S)=>{var A;return(A=Oe)==null?void 0:A(y,S)},()=>({delay:0,y:12}));var st=l(N,2),Ot=a(st),lr=a(Ot);je(lr,{get value(){return e(T)},decimals:2}),i(Ot),me(2),i(st),Le(st,(y,S)=>{var A;return(A=Oe)==null?void 0:A(y,S)},()=>({delay:60,y:12}));var it=l(st,2),Dt=a(it),cr=a(Dt);je(cr,{get value(){return e(fe).length}}),i(Dt),me(2),i(it),Le(it,(y,S)=>{var A;return(A=Oe)==null?void 0:A(y,S)},()=>({delay:120,y:12}));var vt=l(it,2),Tt=a(vt),Et=l(a(Tt),2),dr=a(Et);{let y=$(()=>e(fe).filter(S=>S.similarity>.7).length);je(dr,{get value(){return e(y)}})}i(Et),i(Tt),me(2),i(vt),Le(vt,(y,S)=>{var A;return(A=Oe)==null?void 0:A(y,S)},()=>({delay:180,y:12})),i(f);var mt=l(f,2),It=a(mt);Yt(It,{get options(){return Se},get value(){return e(re)},label:"Lens",icon:"filter",onChange:ut});var Ct=l(It,2);{var ur=y=>{Yt(y,{get options(){return e(Ge)},label:"Topic",icon:"contradictions",placeholder:"All topics",get value(){return e(oe)},set value(S){P(oe,S,!0)}})};X(Ct,y=>{e(re)==="topic"&&y(ur)})}var pr=l(Ct,2);{var vr=y=>{var S=fs(),A=a(S);Bt(A,{name:"close",size:13}),me(),i(S),ue("click",S,()=>{P(_,null),P(v,null)}),R(y,S)};X(pr,y=>{e(_)!==null&&y(vr)})}i(mt);var ft=l(mt,2),xt=a(ft),mr=a(xt);{var fr=y=>{var S=xs(),A=a(S),L=a(A);Bt(L,{name:"contradictions",size:44,strokeWidth:1.2}),i(A),me(2),i(S),R(y,S)},xr=y=>{Jr(y,{get contradictions(){return e(fe)},get focusedPairIndex(){return e(_)},onSelectPair:u,width:800,height:600})};X(mr,y=>{e(fe).length===0?y(fr):y(xr,!1)})}i(xt);var gt=l(xt,2),_t=a(gt),Nt=l(a(_t),2),gr=a(Nt);je(gr,{get value(){return e(M).length}}),i(Nt),i(_t);var zt=l(_t,2);{var _r=y=>{var S=gs();R(y,S)};X(zt,y=>{e(M).length===0&&y(_r)})}var yr=l(zt,2);De(yr,19,()=>e(M),y=>y.c.memory_a_id+"|"+y.c.memory_b_id,(y,S,A)=>{const L=$(()=>e(S).c),Ie=$(()=>e(_)===e(A));var ge=ws(),Ce=a(ge),Fe=a(Ce),_e=l(Fe,2),Ne=a(_e,!0);i(_e);var ze=l(_e,2),yt=a(ze);i(ze),i(Ce);var ke=l(Ce,2),bt=a(ke,!0);i(ke);var we=l(ke,2),$e=a(we),Ue=l(a($e),2),ht=a(Ue,!0);i(Ue);var Ve=l(Ue,2),Ye=a(Ve);i(Ve),i($e);var He=l($e,2),We=l(a(He),2),qe=a(We,!0);i(We);var at=l(We,2),Qe=a(at);i(at),i(He),i(we);var kt=l(we,2);{var wt=pe=>{var ce=ks(),ae=l(a(ce),2),Ae=a(ae,!0);i(ae);var Re=l(ae,2);{var Pe=ve=>{var de=ys();De(de,21,()=>e(L).memory_a_tags,Pt,(Me,Ze)=>{var H=_s(),ee=a(H,!0);i(H),W(()=>w(ee,e(Ze))),R(Me,H)}),i(de),R(ve,de)};X(Re,ve=>{e(L).memory_a_tags&&e(L).memory_a_tags.length>0&&ve(Pe)})}var ye=l(Re,4),Xe=a(ye,!0);i(ye);var Ke=l(ye,2);{var Je=ve=>{var de=hs();De(de,21,()=>e(L).memory_b_tags,Pt,(Me,Ze)=>{var H=bs(),ee=a(H,!0);i(H),W(()=>w(ee,e(Ze))),R(Me,H)}),i(de),R(ve,de)};X(Ke,ve=>{e(L).memory_b_tags&&e(L).memory_b_tags.length>0&&ve(Je)})}i(ce),W(()=>{w(Ae,e(L).memory_a_preview),w(Xe,e(L).memory_b_preview)}),R(pe,ce)};X(kt,pe=>{e(Ie)&&pe(wt)})}i(ge),Le(ge,(pe,ce)=>{var ae;return(ae=Oe)==null?void 0:ae(pe,ce)},()=>({delay:Math.min(e(A)*35,350),y:10})),W((pe,ce,ae,Ae,Re,Pe,ye,Xe)=>{Vt(ge,1,`w-full text-left p-3 rounded-xl border transition lift - ${e(Ie)?"bg-synapse/10 border-synapse/40 shadow-[0_0_12px_rgba(99,102,241,0.18)]":"border-subtle/20 hover:border-synapse/30 hover:bg-white/[0.02]"}`),be(Fe,`background: ${pe??""}`),be(_e,`color: ${ce??""}`),w(Ne,ae),w(yt,`${Ae??""}% sim · ${e(L).date_diff_days??""}d`),w(bt,e(L).topic),w(ht,Re),w(Ye,`${Pe??""}%`),w(qe,ye),w(Qe,`${Xe??""}%`)},[()=>At(e(L).similarity),()=>At(e(L).similarity),()=>ir(e(L).similarity),()=>(e(L).similarity*100).toFixed(0),()=>ct(e(L).memory_a_preview),()=>(e(L).trust_a*100).toFixed(0),()=>ct(e(L).memory_b_preview),()=>(e(L).trust_b*100).toFixed(0)]),ue("click",ge,()=>E(e(A))),R(y,ge)}),i(gt),Le(gt,(y,S)=>{var A;return(A=Oe)==null?void 0:A(y,S)},()=>({delay:120,y:16})),i(ft);var br=l(ft,2);{var hr=y=>{var S=Bs(),A=a(S),L=a(A),Ie=l(a(L),2),ge=a(Ie,!0);i(Ie),i(L);var Ce=l(L,2);i(A);var Fe=l(A,2),_e=a(Fe),Ne=a(_e),ze=l(a(Ne),2),yt=a(ze);i(ze),i(Ne);var ke=l(Ne,2),bt=a(ke,!0);i(ke);var we=l(ke,2),$e=a(we,!0);i(we);var Ue=l(we,2);{var ht=H=>{var ee=Ps(),et=a(ee,!0);i(ee),W(()=>w(et,e(v).stronger.date)),R(H,ee)};X(Ue,H=>{e(v).stronger.date&&H(ht)})}i(_e);var Ve=l(_e,2),Ye=a(Ve),He=l(a(Ye),2),We=a(He);i(He),i(Ye);var qe=l(Ye,2),at=a(qe,!0);i(qe);var Qe=l(qe,2),kt=a(Qe,!0);i(Qe);var wt=l(Qe,2);{var pe=H=>{var ee=Ms(),et=a(ee,!0);i(ee),W(()=>w(et,e(v).weaker.date)),R(H,ee)};X(wt,H=>{e(v).weaker.date&&H(pe)})}i(Ve),i(Fe);var ce=l(Fe,2),ae=a(ce),Ae=l(a(ae),2),Re=a(Ae);i(Ae),i(ae);var Pe=l(ae,2),ye=l(a(Pe),2),Xe=a(ye,!0);i(ye),i(Pe);var Ke=l(Pe,2),Je=l(a(Ke),2),ve=a(Je,!0);i(Je),i(Ke);var de=l(Ke,2),Me=l(a(de),2),Ze=a(Me);i(Me),i(de),i(ce),i(S),W((H,ee,et,kr)=>{w(ge,e(v).topic),w(yt,`${H??""}%`),w(bt,e(v).stronger.id),w($e,e(v).stronger.preview),w(We,`${ee??""}%`),w(at,e(v).weaker.id),w(kt,e(v).weaker.preview),w(Re,`${et??""}%`),w(Xe,kr),Vt(Je,1,`mt-1 font-mono text-lg ${e(v).resolved?"text-recall":"text-[#FF3B30]"}`),w(ve,e(v).resolved?"resolved":"unresolved"),h(Me,"title",e(v).provenance.id),w(Ze,`${e(v).provenance.kind??""}:${e(v).provenance.id??""}`)},[()=>(e(v).stronger.trust*100).toFixed(0),()=>(e(v).weaker.trust*100).toFixed(0),()=>(e(v).topic_overlap*100).toFixed(0),()=>e(v).trust_delta.toFixed(2)]),ue("click",Ce,()=>{P(v,null),P(_,null)}),R(y,S)};X(br,y=>{e(v)&&y(hr)})}W(y=>w(nr,`contradictions across ${y??""} memories`),[()=>e(k).toLocaleString()]),R(d,x)};X(q,d=>{e(F)?d(K):e(g)?d(le,1):e(o).length===0?d(xe,2):d(pt,!1)})}i(D),R(r,se),tr(),n()}Zt(["click"]);export{Hs as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/7.Cs_QL9bJ.js.br b/apps/dashboard/build/_app/immutable/nodes/7.Cs_QL9bJ.js.br deleted file mode 100644 index 194325d..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/7.Cs_QL9bJ.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/7.Cs_QL9bJ.js.gz b/apps/dashboard/build/_app/immutable/nodes/7.Cs_QL9bJ.js.gz deleted file mode 100644 index 47f4d62..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/7.Cs_QL9bJ.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/8.DYPUVn-a.js b/apps/dashboard/build/_app/immutable/nodes/8.DYPUVn-a.js deleted file mode 100644 index c88dfa1..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/8.DYPUVn-a.js +++ /dev/null @@ -1 +0,0 @@ -var de=Object.defineProperty;var ce=(g,u,f)=>u in g?de(g,u,{enumerable:!0,configurable:!0,writable:!0,value:f}):g[u]=f;var S=(g,u,f)=>ce(g,typeof u!="symbol"?u+"":u,f);import"../chunks/Bzak7iHL.js";import{o as me}from"../chunks/DAau0uzT.js";import{p as le,d as $,e as ue,b as he,h as pe,g as c,s as y,u as q,$ as ge}from"../chunks/CGq8RnJq.js";import{h as fe}from"../chunks/De_e6MzK.js";import{R as xe}from"../chunks/BpEKQwpr.js";import{r as k,C as ye,R as J,I as Ee,a as Ne}from"../chunks/BMB5u1EX.js";import{T as Re}from"../chunks/D7ozXiSB.js";import{L as Ce,F as K,l as Me}from"../chunks/DETSv_kY.js";import{a as Q}from"../chunks/D35IQVqe.js";function Fe(g,u){le(u,!0);const f=[...k(ye.forward),1],A=[...k(J.luciferin),.88],E=[...k(J.recall),.62];[...k(Ee.veto)];const Z=36,T=-1e5,ee=64;let b=$(null),N=$(!1),v=$(null),L=$(null),F=$(ue([]));const w=q(()=>re(c(b),c(L),c(N)));me(()=>{Q.memories.list({limit:"80"}).then(t=>{y(F,t.memories,!0),h==null||h.setCells(D())}).catch(()=>{})});async function te(){if(!c(N)){y(N,!0),y(v,null);try{y(b,await Q.dream(),!0),h==null||h.setCells(D(),{ambient:.5})}catch(t){y(v,t instanceof Error?t.message:String(t),!0)}finally{y(N,!1)}}}let h=null;function D(){var n;const t=((n=c(b))==null?void 0:n.insights)??[];let s;return t.length>0?s=t.slice(0,120).map((r,e)=>{var p;const a=m(Number(r.confidence??0)),d=m(Number(r.noveltyScore??a));return{id:((p=r.sourceMemories)==null?void 0:p[0])??`dream-insight:${e}`,score:.5+.5*d,hue:d>.6?K.retrograde:K.bridge,energy:.6+.4*a,metric2:a,kind:"dream-insight",payload:r}}):s=c(F).map(r=>{const e=m(r.retentionStrength);return{id:r.id,score:.3+.3*e,hue:Ne(e),energy:.12+.28*e,metric2:e,kind:"dream-dormant",payload:r}}),Me(s,{maxRadius:.92,minCellR:.014,maxCellR:.052})}function R(t){return t.replace(/[\u2014\u2013]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u2026/g,"...").replace(/[^\x20-\x7E]/g,"?")}function m(t){return Math.min(1,Math.max(0,Number.isFinite(t)?t:.5))}function O(t,s){return{kind:"scalar",id:`dreams.${t}`,scalar:{name:t,value:s}}}function se(t,s){var r;const n=((r=t.sourceMemories)==null?void 0:r[0])??`${t.type}:${s}`;return R(`${n}:${s}`).slice(0,96)}function re(t,s,n){var G,W,X,_,V;if(!t)return{organ:"dreams",nodes:[],edges:[],events:[],receipts:[],scalars:{},alive:!0,records:[],raw:null,selectedRecordId:s,busy:n};const r=Array.isArray(t.insights)?t.insights:[],e=Number(t.memoriesReplayed??0),a=Number(t.connectionsPersisted??0),d=Number(((G=t.stats)==null?void 0:G.insightsGenerated)??r.length),p=Number(((W=t.stats)==null?void 0:W.durationMs)??0),C=Number(((X=t.stats)==null?void 0:X.newConnectionsFound)??a),i=Number(((_=t.stats)==null?void 0:_.memoriesStrengthened)??0),M=Number(((V=t.stats)==null?void 0:V.memoriesCompressed)??0),I=[{id:"dreams:cycle",kind:"dream-cycle",text:[t.status,String(e),String(a),String(d),String(p)].map(o=>R(o??"")).join(" | "),depth:m(e/50),weight:m(C/Math.max(1,e)),source:O("memoriesReplayed",e)}];return t.message&&r.length===0&&I.push({id:"dreams:message",kind:"dream-cycle",text:R(t.message),depth:m(e/50),weight:m(d/Math.max(1,e)),source:O("message",e)}),r.forEach((o,x)=>{var B;const P=m(Number(o.confidence??0)),H=m(Number(o.noveltyScore??P)),j=se(o,x),oe=((B=o.sourceMemories)==null?void 0:B[0])??j;I.push({id:`dreams:insight:${j}`,kind:"dream-insight",text:`C ${Math.round(P*100)} · N ${Math.round(H*100)} | ${R(o.insight??"")}`,depth:P,weight:H,source:{kind:"memory",id:oe},insightIndex:x})}),{organ:"dreams",nodes:I.map((o,x)=>({source:o.source,index:x,label:o.text,retention:o.weight,trust:o.depth,tags:[o.kind],type:o.kind})),edges:[],events:I.map((o,x)=>({source:o.source,type:o.kind,targetIndex:x,frame:18+x*10,energy:o.weight})),receipts:[],scalars:{memoriesReplayed:e,connectionsPersisted:a,newConnectionsFound:C,insightsGenerated:d,memoriesStrengthened:i,memoriesCompressed:M,durationMs:p},alive:!0,records:I,raw:t,selectedRecordId:s,busy:n}}function U(t,s=ee){const n=R(t).split(/\s+/).filter(Boolean),r=[];let e="";for(const a of n){if(!e){e=a.slice(0,s);continue}`${e} ${a}`.length<=s?e+=` ${a}`:(r.push(e),e=a.slice(0,s))}return e&&r.push(e),r.length>0?r:[""]}function l(t,s,n,r,e={}){return{id:t,kind:s,text:n,x:-.88,y:r,size:.024,color:E,depth:.5,weight:.5,startFrame:T,revealSpan:20,maxWidthEm:64,...e}}function Y(t){var p,C;const s=t,n=s.records.slice(0,Z),r=[];let e=.76;if(r.push(l("dreams:run","dream-action",s.busy?"[ DREAMING... ]":"[ RUN DREAM CYCLE ]",e,{size:.032,color:s.busy?E:A,hitPadX:.03,hitPadY:.05})),e-=.065,r.push(l("dreams:run-note","dream-detail","strengthens memories and persists connections",e,{color:E,size:.02})),e-=.09,!s.raw)return r.push(l("dreams:dormant","dream-status","DREAM ENGINE DORMANT - RUN EXPLICIT CYCLE",e,{color:E,size:.028})),r;for(const i of n)r.push({id:i.id,kind:i.kind,text:i.text,x:-.88,y:e,size:i.kind==="dream-cycle"?.03:.024,color:i.id===s.selectedRecordId?A:i.kind==="dream-cycle"?E:f,depth:i.depth,weight:i.weight,startFrame:T,revealSpan:20,maxWidthEm:52,hitPadX:.03,hitPadY:.014,insightIndex:i.insightIndex}),e-=.052;const a=n.find(i=>i.id===s.selectedRecordId);if(!a)return r;e=.45;const d=.08;if(r.push(l("dreams:detail-heading","dream-detail","SELECTED DREAM RECEIPT",e,{x:d,color:A,maxWidthEm:34})),e-=.052,a.kind==="dream-insight"&&a.insightIndex!==void 0){const i=(p=s.raw.insights)==null?void 0:p[a.insightIndex];i&&(U(i.insight,34).forEach((M,z)=>{r.push(l(`dreams:detail:text:${z}`,"dream-detail",M,e,{x:d,color:f,maxWidthEm:34})),e-=.043}),r.push(l("dreams:detail:type","dream-detail",`TYPE: ${R(i.type)}`,e,{x:d})),e-=.043,r.push(l("dreams:detail:confidence","dream-detail",`CONFIDENCE: ${Math.round(m(i.confidence)*100)}`,e,{x:d})),e-=.043,r.push(l("dreams:detail:novelty","dream-detail",`NOVELTY: ${Math.round(m(i.noveltyScore)*100)}`,e,{x:d})),e-=.043,r.push(l("dreams:detail:sources","dream-detail",`SOURCE COUNT: ${((C=i.sourceMemories)==null?void 0:C.length)??0}`,e,{x:d})),e-=.06)}else U(a.text,34).forEach((i,M)=>{r.push(l(`dreams:detail:cycle:${M}`,"dream-detail",i,e,{x:d})),e-=.043}),e-=.017;return r.push(l("dreams:again","dream-action",s.busy?"[ DREAMING... ]":"[ DREAM AGAIN ]",e,{x:d,color:s.busy?E:A,size:.03,hitPadX:.03,hitPadY:.05})),r}class ne{constructor(s,n){S(this,"text");S(this,"scene");S(this,"engine");this.engine=s,this.scene=n,this.text=new Re(s),this.text.init().then(()=>this.text.setText(Y(this.scene)))}uploadScene(s){this.scene=s,this.text.setText(Y(s))}render(s){this.text.render(s)}pickAt(s,n){return this.text.pickAt(s,n)}dispose(){this.text.dispose(),this.engine}}function ie(t,s){const n=new Ce(t);return h=n,n.setCells(D()),[{compute:e=>n.compute(e),render:e=>n.render(e),pickAt:(e,a)=>n.pickAt(e,a),dispose:()=>{n.dispose(),h===n&&(h=null)}},new ne(t,s)]}function ae(t){if(t.kind==="dream-action"){c(N)||te();return}t.kind!=="dream-cycle"&&t.kind!=="dream-insight"||y(L,t.id,!0)}fe("1fv2vo0",t=>{pe(()=>{ge.title="Dreams · Vestige"})});{let t=q(()=>{var s;return`dreams:${((s=c(b))==null?void 0:s.status)??"pending"}:${c(w).records.length}:${c(w).scalars.durationMs??0}`});xe(g,{organ:"dreams",get seed(){return c(t)},get scene(){return c(w)},passes:ie,get loading(){return c(N)},get error(){return c(v)},onpick:ae})}he()}export{Fe as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/8.DYPUVn-a.js.br b/apps/dashboard/build/_app/immutable/nodes/8.DYPUVn-a.js.br deleted file mode 100644 index 22e668b..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/8.DYPUVn-a.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/8.DYPUVn-a.js.gz b/apps/dashboard/build/_app/immutable/nodes/8.DYPUVn-a.js.gz deleted file mode 100644 index ddca9d1..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/8.DYPUVn-a.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/9.Bc6B0Hcn.js b/apps/dashboard/build/_app/immutable/nodes/9.Bc6B0Hcn.js deleted file mode 100644 index 90b4341..0000000 --- a/apps/dashboard/build/_app/immutable/nodes/9.Bc6B0Hcn.js +++ /dev/null @@ -1,253 +0,0 @@ -var Ze=Object.defineProperty;var Je=(i,e,s)=>e in i?Ze(i,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[e]=s;var D=(i,e,s)=>Je(i,typeof e!="symbol"?e+"":e,s);import"../chunks/Bzak7iHL.js";import{d as We,s as C,b as fe,o as et,a as tt}from"../chunks/DAau0uzT.js";import{p as $e,aS as it,aH as ge,g as r,a as w,b as Ye,u as q,c as d,r as u,X as p,Y as $,s as F,f as S,d as re,e as Ne,af as we}from"../chunks/CGq8RnJq.js";import{i as J}from"../chunks/Ccqjq5DS.js";import{e as Ce,i as je,s as Se,r as rt}from"../chunks/DqfV0sZu.js";import{P as st,A as Te,a as Ie,r as nt}from"../chunks/B9l3DI-J.js";import{b as at}from"../chunks/DGM4cicq.js";import{s as Ee}from"../chunks/uCQU803Y.js";import{s as Pe}from"../chunks/HFGAk8XQ.js";import{p as lt}from"../chunks/DV6OI5iy.js";import{N as ot}from"../chunks/CcUbQ_Wl.js";import{I as ct}from"../chunks/CKbQrCJw.js";import{R as ut}from"../chunks/BpEKQwpr.js";import{r as ke,M as dt,R as Ve,I as mt,m as ft}from"../chunks/BMB5u1EX.js";import{a as pt}from"../chunks/D35IQVqe.js";function Qe(i){return i>=.92?"near-identical":i>=.8?"strong":"weak"}function De(i){const e=Qe(i);return e==="near-identical"?"var(--color-decay)":e==="strong"?"var(--color-warning)":"#fde047"}function vt(i){const e=Qe(i);return e==="near-identical"?"Near-identical":e==="strong"?"Strong match":"Weak match"}function gt(i){return i>.7?"#10b981":i>.4?"#f59e0b":"#ef4444"}function Xe(i){if(!i||i.length===0)return null;let e=i[0],s=Number.isFinite(e.retention)?e.retention:-1/0;for(let t=1;ts&&(e=a,s=n)}return e}function Ae(i){return i.map(e=>e.id).slice().sort().join("|")}function ht(i,e=80){if(!i)return"";const s=i.trim().replace(/\s+/g," ");return s.length<=e?s:s.slice(0,e)+"…"}function He(i){if(!i||typeof i!="string")return"";const e=new Date(i);return Number.isNaN(e.getTime())?"":e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function bt(i,e=4){return Array.isArray(i)?i.slice(0,e):[]}var yt=S('REVIEW REQUIRED · NOT SAFE TO MERGE'),xt=S(" "),_t=S('WINNER'),wt=S(' '),St=S('
          '),Pt=S('

          '),kt=S('
          '),Bt=S('
          ');function Mt(i,e){$e(e,!0);let s=lt(e,"oversized",3,!1),t=re(!1);const a=12,n=q(()=>Xe(e.memories)),o=q(()=>{if(e.memories.length<=a)return e.memories;const c=e.memories.filter(y=>{var T;return y.id!==((T=r(n))==null?void 0:T.id)});return r(n)?[r(n),...c.slice(0,a-1)]:c.slice(0,a)}),m=q(()=>e.memories.length-r(o).length);var v=it(),x=ge(v);{var L=c=>{var y=Bt(),T=d(y),P=d(T),H=d(P),g=d(H),h=d(g);u(g);var M=p(g,2),z=d(M,!0);u(M);var Y=p(M,2),K=d(Y);u(Y),u(H);var O=p(H,2),k=d(O);u(O),u(P);var R=p(P,2);{var te=B=>{var b=yt();w(B,b)},ee=B=>{var b=xt(),j=d(b);u(b),$(()=>{Ee(b,1,`flex-shrink-0 rounded-full border px-3 py-1 text-xs font-medium ${e.suggestedAction==="merge"?"border-recall/40 bg-recall/10 text-recall":"border-dream-glow/40 bg-dream/10 text-dream-glow"}`),C(j,`Classification: ${e.suggestedAction==="merge"?"merge candidate":"review"}`)}),w(B,b)};J(R,B=>{s()?B(te):B(ee,!1)})}u(T);var Z=p(T,2),se=d(Z);Ce(se,17,()=>r(o),B=>B.id,(B,b)=>{var j=Pt(),ae=d(j),le=p(ae,2),oe=d(le),ce=d(oe),l=d(ce,!0);u(ce);var f=p(ce,2);{var _=W=>{var X=_t();w(W,X)};J(f,W=>{r(b).id===r(n).id&&W(_)})}var A=p(f,2);Ce(A,17,()=>bt(r(b).tags,4),je,(W,X)=>{var de=wt(),Le=d(de,!0);u(de),$(()=>C(Le,r(X))),w(W,de)}),u(oe);var G=p(oe,2),N=d(G,!0);u(G);var E=p(G,2);{var I=W=>{var X=St(),de=d(X,!0);u(X),$(Le=>C(de,Le),[()=>He(r(b).createdAt)]),w(W,X)},V=q(()=>He(r(b).createdAt));J(E,W=>{r(V)&&W(I)})}u(le);var Q=p(le,2),U=d(Q),me=d(U);u(U);var _e=p(U,2),ue=d(_e);u(_e),u(Q),u(j),$((W,X,de)=>{Ee(j,1,`group flex items-start gap-3 rounded-xl border border-synapse/5 bg-white/[0.02] p-3 transition-all duration-200 hover:border-synapse/20 hover:bg-white/[0.04] ${r(b).id===r(n).id?"ring-1 ring-recall/30":""}`),Pe(ae,`background: ${(ot[r(b).nodeType]||"#8B95A5")??""}`),Se(ae,"title",r(b).nodeType),C(l,r(b).nodeType),Ee(G,1,`text-sm text-text leading-relaxed ${r(t)?"whitespace-pre-wrap":""}`),C(N,W),Pe(me,`width: ${r(b).retention*100}%; background: ${X??""}`),C(ue,`${de??""}%`)},[()=>r(t)?r(b).content:ht(r(b).content),()=>gt(r(b).retention),()=>(r(b).retention*100).toFixed(0)]),w(B,j)});var pe=p(se,2);{var ie=B=>{var b=kt(),j=d(b);u(b),$(()=>C(j,`+${r(m)??""} linked candidates — oversized similarity component. Members - chain through pairwise similarity; distant members may be unrelated. Raise - the threshold to split it.`)),w(B,b)};J(pe,B=>{r(m)>0&&B(ie)})}u(Z);var be=p(Z,2),ye=d(be),ne=p(ye,2),Re=d(ne,!0);u(ne);var xe=p(ne,2);u(be),u(y),$((B,b,j,ae,le,oe,ce)=>{Pe(g,`color: ${B??""}`),C(h,`${b??""}%`),C(z,j),C(K,`· ${e.memories.length??""} memories`),Se(O,"aria-valuenow",ae),Pe(k,`width: ${le??""}%; background: ${oe??""}; box-shadow: 0 0 12px ${ce??""}66`),Se(ye,"title",s()?"Oversized similarity component — not safe to merge":"Merge backend not shipped yet — no destructive action is taken from this screen"),Se(ne,"aria-expanded",r(t)),C(Re,r(t)?"Collapse":"Review")},[()=>De(e.similarity),()=>(e.similarity*100).toFixed(1),()=>vt(e.similarity),()=>Math.round(e.similarity*100),()=>(e.similarity*100).toFixed(1),()=>De(e.similarity),()=>De(e.similarity)]),fe("click",ne,()=>F(t,!r(t))),fe("click",xe,function(...B){var b;(b=e.onDismiss)==null||b.apply(this,B)}),w(c,y)};J(x,c=>{e.memories.length>0&&r(n)&&c(L)})}w(i,v),Ye()}We(["click"]);const Be="rgba16float",ve=512,Me=512,Oe=16,Ue=16,qe=` -struct Params { - frame: f32, - loop_phase: f32, - node_count: f32, - edge_count: f32, - path_count: f32, - pulse: f32, - viewport_w: f32, - viewport_h: f32, - brightness: f32, - demo_id: f32, - time: f32, - capture_mode: f32, - live_kind: f32, - live_frame: f32, - live_energy: f32, - projection_days: f32, -}; - -struct FusionCell { - // x/y position in NDC, z retention, w winner flag - pos_retention: vec4f, - // x similarity, y threshold, z member slot, w cluster slot - cluster_meta: vec4f, - // x mismatch intensity, y merge flag, z radius, w member count - visual_meta: vec4f, - // x cell index, y cluster index, z/w spare - ids: vec4f, -}; - -struct FusionNeck { - // x/y winner position, z winner retention, w winner radius - a: vec4f, - // x/y candidate position, z candidate retention, w candidate radius - b: vec4f, - // x similarity, y threshold, z mismatch intensity, w merge flag - signals: vec4f, - // x neck index, y cluster index, z/w spare - ids: vec4f, -}; -`,At=` -${qe} - -@group(0) @binding(0) var params: Params; -@group(0) @binding(1) var cells: array; -@group(0) @binding(2) var necks: array; - -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); - -struct VSOut { - @builtin(position) clip: vec4f, - @location(0) uv: vec2f, - @location(1) @interpolate(flat) misc: vec4f, -}; - -fn similarity_neck(similarity: f32) -> f32 { - return smoothstep(0.78, 0.98, similarity); -} - -@vertex -fn vs_splat(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - var out: VSOut; - let corner = QUAD[vi]; - let cell_count = u32(params.node_count); - if (ii < cell_count) { - let c = cells[ii]; - let merge_gate = c.visual_meta.y; - let radius = c.visual_meta.z * (1.0 + 0.045 * sin(params.time * 2.0 + c.cluster_meta.w * 6.28318)); - out.clip = vec4f(c.pos_retention.xy + corner * radius, 0.0, 1.0); - out.uv = corner; - out.misc = vec4f(c.pos_retention.z, c.cluster_meta.x, c.visual_meta.x, merge_gate); - } else { - let n = necks[ii - cell_count]; - let a = n.a.xy; - let b = n.b.xy; - let center = (a + b) * 0.5; - let dir = normalize(b - a + vec2f(0.0001, 0.0001)); - let normal = vec2f(-dir.y, dir.x); - let fused = similarity_neck(n.signals.x); - let length_half = distance(a, b) * 0.5; - let thickness = 0.035 + fused * 0.085 + n.signals.z * 0.025; - let pos = center + dir * corner.x * length_half + normal * corner.y * thickness; - out.clip = vec4f(pos, 0.0, 1.0); - out.uv = vec2f(corner.x, corner.y / max(0.001, thickness)); - out.misc = vec4f(n.signals.x, fused, n.signals.z, n.signals.w); - } - return out; -} - -@fragment -fn fs_splat(frag: VSOut) -> @location(0) vec4f { - let d = length(frag.uv); - let is_neck = f32(abs(frag.uv.y) > 1.0); - if (is_neck < 0.5 && d > 1.0) { discard; } - let retention = clamp(frag.misc.x, 0.0, 1.0); - let similarity = clamp(frag.misc.y, 0.0, 1.0); - let mismatch = clamp(frag.misc.z, 0.0, 1.0); - let merge_gate = frag.misc.w; - let cell_body = exp(-d * d * 3.15) * (0.38 + retention * 0.62) * (0.5 + similarity * 0.58); - let cell_rim = smoothstep(0.24, 0.02, abs(d - (0.58 + retention * 0.16))) * (0.2 + similarity * 0.55); - let neck_body = exp(-frag.uv.y * frag.uv.y * 4.0) * smoothstep(1.05, 0.82, abs(frag.uv.x)) * (0.35 + similarity * 0.9); - let density = max(cell_body + cell_rim, neck_body * (0.4 + similarity)); - // r=density, g=retention/luciferin, b=mismatch amber, a reserved. No storage textures. - return vec4f(density, density * (0.35 + retention * 0.65), mismatch * (0.18 + merge_gate * 0.12), 1.0); -} - -@vertex -fn vs_cell(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - var out: VSOut; - let c = cells[ii]; - let corner = QUAD[vi]; - let winner = c.pos_retention.w; - let radius = c.visual_meta.z * (0.46 + winner * 0.18); - out.clip = vec4f(c.pos_retention.xy + corner * radius, 0.0, 1.0); - out.uv = corner; - out.misc = vec4f(c.pos_retention.z, c.cluster_meta.x, c.visual_meta.x, winner); - return out; -} - -@fragment -fn fs_cell(frag: VSOut) -> @location(0) vec4f { - let d = length(frag.uv); - if (d > 1.0) { discard; } - let retention = clamp(frag.misc.x, 0.0, 1.0); - let similarity = clamp(frag.misc.y, 0.0, 1.0); - let mismatch = clamp(frag.misc.z, 0.0, 1.0); - let winner = frag.misc.w; - let sediment = vec3f(0.54, 0.29, 0.09); - let recall = vec3f(0.16, 0.95, 0.66); - let luciferin = vec3f(0.91, 1.0, 0.72); - let ivory = vec3f(0.96, 0.945, 0.815); - let amber = vec3f(1.0, 0.69, 0.08); - let core = mix(sediment, mix(recall, luciferin, retention), retention); - let rim = smoothstep(0.98, 0.72, d) * (1.0 - smoothstep(0.72, 0.22, d)); - let body = exp(-d*d*3.2) * (0.20 + retention * 0.44 + winner * 0.16); - let mismatch_ring = smoothstep(0.16, 0.0, abs(d - 0.80)) * mismatch; - return vec4f(core * body + ivory * rim * (0.16 + similarity * 0.52) + amber * mismatch_ring * 0.34, 1.0); -} - -@vertex -fn vs_neck(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - var out: VSOut; - let n = necks[ii]; - let a = n.a.xy; - let b = n.b.xy; - let t = f32(vi / 2u) / 31.0; - let side = f32(vi % 2u) * 2.0 - 1.0; - let dir = normalize(b - a + vec2f(0.0001, 0.0001)); - let normal = vec2f(-dir.y, dir.x); - let midpoint = (a + b) * 0.5; - let fused = similarity_neck(n.signals.x); - let threshold_pull = clamp(n.signals.x - n.signals.y + 0.22, 0.0, 1.0); - let bow = normal * sin(t * 3.14159) * (0.030 + n.signals.z * 0.050) * (1.0 - fused * 0.35); - let pos = mix(a, b, t) + bow; - let thickness = 0.005 + fused * 0.025 + threshold_pull * 0.010; - out.clip = vec4f(pos + normal * side * thickness, 0.0, 1.0); - out.uv = vec2f(t, side); - out.misc = vec4f(n.signals.x, n.signals.y, n.signals.z, distance(pos, midpoint)); - return out; -} - -@fragment -fn fs_neck(frag: VSOut) -> @location(0) vec4f { - let similarity = clamp(frag.misc.x, 0.0, 1.0); - let threshold = clamp(frag.misc.y, 0.0, 1.0); - let mismatch = clamp(frag.misc.z, 0.0, 1.0); - let pulse = 0.55 + 0.45 * sin(36.0 * frag.uv.x - 8.0 * frag.misc.w); - let bridge = vec3f(0.10, 0.82, 0.92); - let luciferin = vec3f(0.91, 1.0, 0.72); - let amber = vec3f(1.0, 0.69, 0.08); - let pull = smoothstep(-0.08, 0.20, similarity - threshold); - let color = mix(bridge, luciferin, pull) + amber * mismatch * pulse * 0.34; - return vec4f(color * (0.14 + similarity * 0.55 + mismatch * 0.18), 1.0); -} -`,Gt=` -${qe} - -@group(0) @binding(0) var params: Params; -@group(0) @binding(3) var field_sampler: sampler; -@group(0) @binding(4) var field_tex: texture_2d; - -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); - -struct VSOut { @builtin(position) clip: vec4f, @location(0) uv: vec2f }; - -@vertex -fn vs_fullscreen(@builtin(vertex_index) vi: u32) -> VSOut { - var out: VSOut; - let p = QUAD[vi]; - out.clip = vec4f(p, 0.0, 1.0); - out.uv = p * 0.5 + vec2f(0.5); - return out; -} - -@fragment -fn fs_membrane(frag: VSOut) -> @location(0) vec4f { - let f = textureSample(field_tex, field_sampler, frag.uv); - let density = clamp(f.r, 0.0, 5.0); - let retention = clamp(f.g, 0.0, 5.0); - let mismatch = clamp(f.b, 0.0, 3.0); - let membrane = smoothstep(0.13, 0.88, density) * (1.0 - smoothstep(1.9, 3.8, density)); - let blackwater = vec3f(0.008, 0.012, 0.018); - let bridge = vec3f(0.10, 0.82, 0.92); - let luciferin = vec3f(0.66, 1.0, 0.37); - let ivory = vec3f(0.96, 0.945, 0.815); - let amber = vec3f(1.0, 0.69, 0.08); - var color = blackwater * (0.18 + density * 0.055); - color = color + bridge * density * 0.055 + luciferin * retention * 0.080; - color = color + ivory * membrane * 0.22 + amber * mismatch * (0.20 + 0.08 * params.pulse); - let vignette = smoothstep(0.96, 0.18, distance(frag.uv, vec2f(0.5))); - return vec4f(color * (0.35 + 0.65 * vignette) * params.brightness, 1.0); -} -`,Ct=` -struct BlurDir { dir: vec2f, _pad: vec2f }; -@group(0) @binding(0) var blur_sampler: sampler; -@group(0) @binding(1) var blur_src: texture_2d; -@group(0) @binding(2) var blur_dir: BlurDir; -const QUAD = array( - vec2f(-1.0, -1.0), vec2f(1.0, -1.0), vec2f(1.0, 1.0), - vec2f(-1.0, -1.0), vec2f(1.0, 1.0), vec2f(-1.0, 1.0) -); -struct VSOut { @builtin(position) clip: vec4f, @location(0) uv: vec2f }; -@vertex -fn vs_fullscreen(@builtin(vertex_index) vi: u32) -> VSOut { - var out: VSOut; - let p = QUAD[vi]; - out.clip = vec4f(p, 0.0, 1.0); - out.uv = p * 0.5 + vec2f(0.5); - return out; -} -@fragment -fn fs_blur(frag: VSOut) -> @location(0) vec4f { - let dims = vec2f(textureDimensions(blur_src, 0)); - let stepv = blur_dir.dir / max(dims, vec2f(1.0)); - var acc = textureSampleLevel(blur_src, blur_sampler, frag.uv - stepv * 2.0, 0.0) * 0.06136; - acc = acc + textureSampleLevel(blur_src, blur_sampler, frag.uv - stepv, 0.0) * 0.24477; - acc = acc + textureSampleLevel(blur_src, blur_sampler, frag.uv, 0.0) * 0.38774; - acc = acc + textureSampleLevel(blur_src, blur_sampler, frag.uv + stepv, 0.0) * 0.24477; - acc = acc + textureSampleLevel(blur_src, blur_sampler, frag.uv + stepv * 2.0, 0.0) * 0.06136; - return acc; -} -`;class Rt{constructor(e,s){D(this,"engine");D(this,"scene",null);D(this,"resources",null);D(this,"sampler",null);D(this,"splatBindLayout",null);D(this,"blurBindLayout",null);D(this,"membraneBindLayout",null);D(this,"splatPipeline",null);D(this,"blurPipeline",null);D(this,"membranePipeline",null);D(this,"cellPipeline",null);D(this,"neckPipeline",null);D(this,"cellCount",0);D(this,"neckCount",0);D(this,"cellGeometry",[]);D(this,"neckGeometry",[]);this.engine=e,this.uploadScene(s)}uploadScene(e){this.scene=e,this.buildGeometry();const s=this.engine.gpuDevice;s&&(this.ensurePipelines(s),this.ensureResources(s),this.uploadBuffers(s))}ensurePipelines(e){if(this.splatPipeline||!this.engine.paramsBuffer)return;const s=Fe(e,"duplicates-fusion-splat-wgsl",At),t=Fe(e,"duplicates-fusion-blur-wgsl",Ct),a=Fe(e,"duplicates-fusion-membrane-wgsl",Gt);this.splatBindLayout=e.createBindGroupLayout({label:"duplicates-fusion-splat-bind-layout",entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.VERTEX,buffer:{type:"read-only-storage"}},{binding:2,visibility:GPUShaderStage.VERTEX,buffer:{type:"read-only-storage"}}]}),this.blurBindLayout=e.createBindGroupLayout({label:"duplicates-fusion-blur-bind-layout",entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:2,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}}]}),this.membraneBindLayout=e.createBindGroupLayout({label:"duplicates-fusion-membrane-bind-layout",entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:3,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:4,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}}]});const n=e.createPipelineLayout({label:"duplicates-fusion-splat-layout",bindGroupLayouts:[this.splatBindLayout]}),o=e.createPipelineLayout({label:"duplicates-fusion-blur-layout",bindGroupLayouts:[this.blurBindLayout]}),m=e.createPipelineLayout({label:"duplicates-fusion-membrane-layout",bindGroupLayouts:[this.membraneBindLayout]});this.sampler=e.createSampler({magFilter:"linear",minFilter:"linear"});const v={color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}};this.splatPipeline=e.createRenderPipeline({label:"duplicates-field-additive-splat",layout:n,vertex:{module:s,entryPoint:"vs_splat"},fragment:{module:s,entryPoint:"fs_splat",targets:[{format:Be,blend:v}]},primitive:{topology:"triangle-list"}}),this.blurPipeline=e.createRenderPipeline({label:"duplicates-field-blur-render-pass",layout:o,vertex:{module:t,entryPoint:"vs_fullscreen"},fragment:{module:t,entryPoint:"fs_blur",targets:[{format:Be}]},primitive:{topology:"triangle-list"}}),this.membranePipeline=e.createRenderPipeline({label:"duplicates-synaptic-fusion-membrane",layout:m,vertex:{module:a,entryPoint:"vs_fullscreen"},fragment:{module:a,entryPoint:"fs_membrane",targets:[{format:this.engine.sceneFormat,blend:v}]},primitive:{topology:"triangle-list"}}),this.cellPipeline=e.createRenderPipeline({label:"duplicates-memory-nuclei",layout:n,vertex:{module:s,entryPoint:"vs_cell"},fragment:{module:s,entryPoint:"fs_cell",targets:[{format:this.engine.sceneFormat,blend:v}]},primitive:{topology:"triangle-list"}}),this.neckPipeline=e.createRenderPipeline({label:"duplicates-mismatch-filaments",layout:n,vertex:{module:s,entryPoint:"vs_neck"},fragment:{module:s,entryPoint:"fs_neck",targets:[{format:this.engine.sceneFormat,blend:v}]},primitive:{topology:"triangle-strip"}})}ensureResources(e){var M,z,Y,K,O,k;if(!this.splatBindLayout||!this.blurBindLayout||!this.membraneBindLayout||!this.engine.paramsBuffer||!this.sampler)return;const s=Math.max(16,Math.floor((this.engine.params[6]||1280)/2)),t=Math.max(16,Math.floor((this.engine.params[7]||720)/2)),a=!this.resources||this.resources.fieldSize[0]!==s||this.resources.fieldSize[1]!==t;let n=(M=this.resources)==null?void 0:M.cellBuffer,o=(z=this.resources)==null?void 0:z.neckBuffer,m=(Y=this.resources)==null?void 0:Y.blurHBuffer,v=(K=this.resources)==null?void 0:K.blurVBuffer;if(n||(n=e.createBuffer({label:"duplicates-cells",size:ve*Oe*4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})),o||(o=e.createBuffer({label:"duplicates-necks",size:Me*Ue*4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})),m||(m=e.createBuffer({label:"duplicates-blur-h-dir",size:16,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),e.queue.writeBuffer(m,0,new Float32Array([1,0,0,0]))),v||(v=e.createBuffer({label:"duplicates-blur-v-dir",size:16,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),e.queue.writeBuffer(v,0,new Float32Array([0,1,0,0]))),!a&&this.resources)return;(O=this.resources)==null||O.fieldA.destroy(),(k=this.resources)==null||k.fieldB.destroy();const x=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING,L=e.createTexture({label:"duplicates-field-a-rgba16float",size:[s,t],format:Be,usage:x}),c=e.createTexture({label:"duplicates-field-b-rgba16float",size:[s,t],format:Be,usage:x}),y=L.createView(),T=c.createView(),P=e.createBindGroup({label:"duplicates-fusion-splat-bind",layout:this.splatBindLayout,entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:n}},{binding:2,resource:{buffer:o}}]}),H=e.createBindGroup({label:"duplicates-field-blur-h-bind",layout:this.blurBindLayout,entries:[{binding:0,resource:this.sampler},{binding:1,resource:y},{binding:2,resource:{buffer:m}}]}),g=e.createBindGroup({label:"duplicates-field-blur-v-bind",layout:this.blurBindLayout,entries:[{binding:0,resource:this.sampler},{binding:1,resource:T},{binding:2,resource:{buffer:v}}]}),h=e.createBindGroup({label:"duplicates-membrane-bind",layout:this.membraneBindLayout,entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:3,resource:this.sampler},{binding:4,resource:y}]});this.resources={cellBuffer:n,neckBuffer:o,blurHBuffer:m,blurVBuffer:v,splatBindGroup:P,blurHBindGroup:H,blurVBindGroup:g,membraneBindGroup:h,fieldA:L,fieldB:c,fieldAView:y,fieldBView:T,fieldSize:[s,t]}}buildGeometry(){var x,L;const e=((x=this.scene)==null?void 0:x.clusters)??[],s=Math.max(1,e.length),t=[],a=[],n=12,o=new Array(e.length).fill(0);let m=ve;for(let c=0;c0;c++)o[c]=1,m-=1;for(let c=0;c0;c++)o[c]===1&&e[c].memories.length>=2&&(o[c]=2,m-=1);let v=!0;for(;m>0&&v;){v=!1;for(let c=0;c0;c++)o[c]>0&&o[c]k.id===y.winnerId)??y.memories[0],z=[M,...y.memories.filter(k=>k.id!==M.id)].slice(0,o[c]),Y=Math.max(1,z.length),K=new Map;for(let k=0;k=Me||k.id===M.id)continue;const R=K.get(k.id);R&&a.push({cluster:y,winnerId:M.id,candidateId:k.id,ax:O.x,ay:O.y,bx:R.x,by:R.y,winnerRetention:O.retention,candidateRetention:R.retention,winnerRadius:O.radius,candidateRadius:R.radius,mismatch:Math.max(R.mismatch,Math.min(1,y.mismatchTokens.length/12))})}}this.cellGeometry=t,this.neckGeometry=a}uploadBuffers(e){if(!this.resources)return;const s=new Float32Array(ve*Oe),t=new Float32Array(Me*Ue);this.cellCount=Math.min(ve,this.cellGeometry.length),this.neckCount=Math.min(Me,this.neckGeometry.length);for(let a=0;a0&&(e.setPipeline(this.neckPipeline),e.setBindGroup(0,this.resources.splatBindGroup),e.draw(64,this.neckCount)),this.cellCount>0&&(e.setPipeline(this.cellPipeline),e.setBindGroup(0,this.resources.splatBindGroup),e.draw(6,this.cellCount)))}pickAt(e,s){for(let t=0;t{for(const n of a.messages)console.error(`[observatory] ${e} WGSL ${n.type} ${n.lineNum}:${n.linePos} ${n.message}`)}),i.popErrorScope().then(a=>{a&&console.error(`[observatory] ${e} shader module validation: ${a.message}`)}),t}function Tt(i,e){return ke(dt.blackwater),ke(Ve.recall),ke(Ve.luciferin),ke(mt.trustMembrane),[new Rt(i,e)]}function he(i){return Math.max(0,Math.min(1,Number.isFinite(i)?i:0))}function Ge(i,e,s){return s?{kind:i,id:e,scalar:s}:{kind:i,id:e||`${i}:unknown`}}function Et(i,e){return{kind:"scalar",id:`duplicates.${i}`,scalar:{name:i,value:e}}}function Dt(i,e=84){const s=(i||"").trim().replace(/\s+/g," ");return s.length<=e?s:`${s.slice(0,e)}…`}function Ke(i){return(i||"").toLowerCase().replace(/[^a-z0-9_\s-]/g," ").split(/\s+/).filter(e=>e.length>=4).slice(0,80)}function Ot(i){if(i.length<2)return[];const e=i.map(t=>new Set(Ke(t.content))),s=new Map;for(const t of e)for(const a of t)s.set(a,(s.get(a)??0)+1);return Array.from(s.entries()).filter(([,t])=>t>0&&ta[1]-t[1]||t[0].localeCompare(a[0])).slice(0,12).map(([t])=>t)}function Ut(i,e,s){const t=Array.isArray(i.memories)?i.memories.filter(m=>m.id):[];if(t.length<2)return null;const a=Ae(t),n=Xe(t),o=Ot(t);return{id:a,index:e,similarity:he(i.similarity),threshold:he(s),suggestedAction:i.suggestedAction==="merge"?"merge":"review",winnerId:(n==null?void 0:n.id)??t[0].id,memories:t.map((m,v)=>({...m,index:v,preview:Dt(m.content),winner:m.id===((n==null?void 0:n.id)??t[0].id),mismatchTokens:o.filter(x=>Ke(m.content).includes(x)).slice(0,8)})),mismatchTokens:o,source:Ge("pair",a)}}function Ft(i){var H;const e=he(i.threshold??.8),t=(Array.isArray(i.clusters)?i.clusters:[]).map((g,h)=>Ut(g,h,e)).filter(g=>g!==null);let a=0;const n=[],o=new Map;for(const g of t)for(const h of g.memories){if(o.has(h.id))continue;const M=a++;o.set(h.id,M),n.push({source:Ge("memory",h.id),index:M,label:h.preview||h.id.slice(0,8),retention:he(h.retention),trust:he(g.similarity),lastAccessed:h.createdAt,tags:[h.nodeType,...h.tags,h.winner?"winner":"candidate"].filter(Boolean),type:h.nodeType||"memory"})}const m=[];for(const g of t){const h=o.get(g.winnerId);if(h!=null)for(const M of g.memories){const z=o.get(M.id);z==null||z===h||m.push({source:Ge("pair",`${g.id}:${g.winnerId}:${M.id}`),sourceIndex:h,targetIndex:z,weight:Math.max(.05,g.similarity),kind:g.suggestedAction==="merge"?"fusion-candidate":"review-candidate"})}}const v=t.map((g,h)=>({source:Ge("event",`duplicates.cluster.${g.id}`),type:g.suggestedAction==="merge"?"DuplicateMergeCandidate":"DuplicateReviewCandidate",targetIndex:-1,frame:20+h*14,energy:Math.max(.1,g.similarity-e+.1)})),x=Number.isFinite(i.total)?i.total:t.length,L=n.length,c=t.reduce((g,h)=>Math.max(g,h.similarity),0),y=t.filter(g=>g.suggestedAction==="merge").length,T=t.length-y;return{organ:"duplicates",nodes:n,edges:m,events:v,receipts:[],scalars:{threshold:((H=Et("threshold",e).scalar)==null?void 0:H.value)??e,clusterCount:t.length,memoryCount:L,maxSimilarity:c,mergeCandidates:y,reviewCandidates:T,total:x},alive:t.length>0,threshold:e,total:x,clusters:t,raw:i}}const zt=()=>{var i;return typeof window<"u"&&((i=window.matchMedia)==null?void 0:i.call(window,"(prefers-reduced-motion: reduce)").matches)};function ze(i){if(zt())return{};let e=0;function s(a){const n=i.getBoundingClientRect();cancelAnimationFrame(e),e=requestAnimationFrame(()=>{i.style.setProperty("--spot-x",`${a.clientX-n.left}px`),i.style.setProperty("--spot-y",`${a.clientY-n.top}px`),i.style.setProperty("--spot-o","1")})}function t(){i.style.setProperty("--spot-o","0")}return i.addEventListener("pointermove",s),i.addEventListener("pointerleave",t),{destroy(){i.removeEventListener("pointermove",s),i.removeEventListener("pointerleave",t),cancelAnimationFrame(e)}}}var Nt=S(' Live',1),It=S(' Detecting…',1),Vt=S(' Error',1),Ht=S(" ",1),Wt=S(" ",1),$t=S(' · memories implicated',1),Yt=S('
          Synaptic neck selected
          '),jt=S(`
          Couldn't detect duplicates
          `),Qt=S('
          '),Xt=S('
          '),qt=S('
          No duplicates found — your memory is clean.
          '),Kt=S('
          '),Zt=S('
          '),Jt=S('
          '),ei=S('
          ',1);function hi(i,e){$e(e,!0);let s=re(.8),t=re(Ne([])),a=re(0);const n=12;let o=re(Ne(new Set)),m=re(!0),v=re(null),x=re(null),L;async function c(){F(m,!0),F(v,null),F(x,null);try{const l=await pt.duplicates(r(s));F(t,l.clusters,!0),F(a,l.total??l.clusters.length,!0);const f=new Set(r(t).map(A=>Ae(A.memories))),_=new Set;for(const A of r(o))f.has(A)&&_.add(A);F(o,_,!0)}catch(l){F(v,l instanceof Error?l.message:"Failed to detect duplicates",!0),F(t,[],!0)}finally{F(m,!1)}}function y(){clearTimeout(L),L=setTimeout(c,250)}function T(l){const f=new Set(r(o));f.add(l),F(o,f,!0),r(x)&&Ae(r(x).memories)===l&&F(x,null)}const P=q(()=>r(t).map(l=>({c:l,key:Ae(l.memories)})).filter(({key:l})=>!r(o).has(l))),H=q(()=>r(t).reduce((l,f)=>l+f.memories.length,0)),g=50,h=q(()=>r(P).length>g),M=q(()=>r(h)?r(P).slice(0,g):r(P)),z=q(()=>Ft({threshold:r(s),total:r(P).length,clusters:r(P).map(({c:l})=>l)}));function Y(l){l.kind!=="duplicate-neck"&&l.kind!=="duplicate-memory"||F(x,l.payload,!0)}et(()=>c()),tt(()=>clearTimeout(L));var K=ei(),O=ge(K);{let l=q(()=>`synaptic-fusion:${r(s)}:${r(P).length}:${r(H)}`),f=q(()=>`NO DUPLICATES ABOVE ${(r(s)*100).toFixed(0)}% SIMILARITY`);ut(O,{organ:"duplicates",get seed(){return r(l)},get scene(){return r(z)},get passes(){return Tt},get loading(){return r(m)},get error(){return r(v)},get emptyLabel(){return r(f)},onpick:Y})}var k=p(O,2),R=d(k);st(R,{icon:"duplicates",title:"Memory Hygiene — Duplicate Detection",subtitle:"Cosine-similarity clustering over embeddings. Oversized similarity components are quarantined for review — they chain through pairwise similarity and are not safe to merge. Dismissed clusters are hidden for this session only.",accent:"synapse",children:(l,f)=>{var _=Nt();we(2),w(l,_)},$$slots:{default:!0}});var te=p(R,2),ee=d(te),Z=p(d(ee),2);rt(Z);var se=p(Z,2),pe=d(se);u(se),u(ee);var ie=p(ee,2),be=d(ie);{var ye=l=>{var f=It();we(2),w(l,f)},ne=l=>{var f=Vt();we(2),w(l,f)},Re=l=>{var f=$t(),_=p(ge(f),2),A=d(_);{var G=I=>{var V=Ht(),Q=ge(V);Te(Q,{get value(){return r(P).length}});var U=p(Q);$(()=>C(U,` visible of ${r(a)??""} clusters`)),w(I,V)},N=I=>{var V=Wt(),Q=ge(V);Te(Q,{get value(){return r(P).length}});var U=p(Q);$(()=>C(U,` ${r(P).length===1?"cluster":"clusters"}`)),w(I,V)};J(A,I=>{r(P).length{r(m)?l(ye):r(v)?l(ne,1):l(Re,!1)})}u(ie);var xe=p(ie,2);u(te);var B=p(te,2);{var b=l=>{var f=Yt(),_=d(f),A=d(_),G=p(d(A),2),N=d(G);u(G);var E=p(G,2),I=d(E);u(E),u(A);var V=p(A,2);u(_),u(f),$((Q,U,me)=>{C(N,`${r(x).memories.length??""} memories · ${Q??""}% similar · winner ${U??""}`),C(I,`Real pair key: ${r(x).id??""}. Mismatch filaments: ${me??""}.`)},[()=>(r(x).similarity*100).toFixed(1),()=>r(x).winnerId.slice(0,8),()=>r(x).mismatchTokens.length?r(x).mismatchTokens.join(", "):"none exposed"]),fe("click",V,()=>F(x,null)),w(l,f)};J(B,l=>{r(x)&&l(b)})}var j=p(B,2);{var ae=l=>{var f=jt(),_=p(d(f),2),A=d(_,!0);u(_);var G=p(_,2);u(f),$(()=>C(A,r(v))),fe("click",G,c),w(l,f)},le=l=>{var f=Xt();Ce(f,20,()=>Array(3),je,(_,A)=>{var G=Qt();w(_,G)}),u(f),w(l,f)},oe=l=>{var f=qt(),_=d(f),A=d(_);ct(A,{name:"sparkle",size:26,draw:!0}),u(_);var G=p(_,4),N=d(G);u(G),u(f),$(E=>C(N,`Nothing clusters above ${E??""}% similarity. Lower the threshold to - surface looser matches.`),[()=>(r(s)*100).toFixed(0)]),w(l,f)},ce=l=>{var f=Jt(),_=d(f);{var A=N=>{var E=Kt(),I=d(E);u(E),$(()=>C(I,`Showing first 50 of ${r(P).length??""} clusters. Raise the - threshold to narrow results.`)),w(N,E)};J(_,N=>{r(h)&&N(A)})}var G=p(_,2);Ce(G,19,()=>r(M),({c:N,key:E})=>E,(N,E,I)=>{let V=()=>r(E).c,Q=()=>r(E).key;var U=Zt(),me=d(U),_e=d(me);{let ue=q(()=>V().memories.length>n);Mt(_e,{get similarity(){return V().similarity},get memories(){return V().memories},get suggestedAction(){return V().suggestedAction},get oversized(){return r(ue)},onDismiss:()=>T(Q())})}u(me),u(U),Ie(U,(ue,W)=>{var X;return(X=nt)==null?void 0:X(ue,W)},()=>({delay:Math.min(r(I)*40,400),y:14})),Ie(U,ue=>ze==null?void 0:ze(ue)),w(N,U)}),u(f),w(l,f)};J(j,l=>{r(v)?l(ae):r(m)?l(le,1):r(P).length===0?l(oe,2):l(ce,!1)})}u(k),$(l=>{C(pe,`${l??""}%`),xe.disabled=r(m)},[()=>(r(s)*100).toFixed(0)]),fe("input",Z,y),at(Z,()=>r(s),l=>F(s,l)),fe("click",xe,c),w(i,K),Ye()}We(["input","click"]);export{hi as component}; diff --git a/apps/dashboard/build/_app/immutable/nodes/9.Bc6B0Hcn.js.br b/apps/dashboard/build/_app/immutable/nodes/9.Bc6B0Hcn.js.br deleted file mode 100644 index e38011c..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/9.Bc6B0Hcn.js.br and /dev/null differ diff --git a/apps/dashboard/build/_app/immutable/nodes/9.Bc6B0Hcn.js.gz b/apps/dashboard/build/_app/immutable/nodes/9.Bc6B0Hcn.js.gz deleted file mode 100644 index 83b2263..0000000 Binary files a/apps/dashboard/build/_app/immutable/nodes/9.Bc6B0Hcn.js.gz and /dev/null differ diff --git a/apps/dashboard/build/_app/version.json b/apps/dashboard/build/_app/version.json deleted file mode 100644 index 0786b5d..0000000 --- a/apps/dashboard/build/_app/version.json +++ /dev/null @@ -1 +0,0 @@ -{"version":"2.2.0"} \ No newline at end of file diff --git a/apps/dashboard/build/_app/version.json.br b/apps/dashboard/build/_app/version.json.br deleted file mode 100644 index 93ade17..0000000 --- a/apps/dashboard/build/_app/version.json.br +++ /dev/null @@ -1 +0,0 @@ - {"version":"2.2.0"} \ No newline at end of file diff --git a/apps/dashboard/build/_app/version.json.gz b/apps/dashboard/build/_app/version.json.gz deleted file mode 100644 index 19e86d0..0000000 Binary files a/apps/dashboard/build/_app/version.json.gz and /dev/null differ diff --git a/apps/dashboard/build/favicon.svg b/apps/dashboard/build/favicon.svg deleted file mode 100644 index b6aa582..0000000 --- a/apps/dashboard/build/favicon.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/dashboard/build/favicon.svg.br b/apps/dashboard/build/favicon.svg.br deleted file mode 100644 index eaa33da..0000000 Binary files a/apps/dashboard/build/favicon.svg.br and /dev/null differ diff --git a/apps/dashboard/build/favicon.svg.gz b/apps/dashboard/build/favicon.svg.gz deleted file mode 100644 index 61b0904..0000000 Binary files a/apps/dashboard/build/favicon.svg.gz and /dev/null differ diff --git a/apps/dashboard/build/index.html b/apps/dashboard/build/index.html deleted file mode 100644 index ddcf19b..0000000 --- a/apps/dashboard/build/index.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - Vestige - - -
          - -
          - - diff --git a/apps/dashboard/build/index.html.br b/apps/dashboard/build/index.html.br deleted file mode 100644 index 0acefe5..0000000 Binary files a/apps/dashboard/build/index.html.br and /dev/null differ diff --git a/apps/dashboard/build/index.html.gz b/apps/dashboard/build/index.html.gz deleted file mode 100644 index a606243..0000000 Binary files a/apps/dashboard/build/index.html.gz and /dev/null differ diff --git a/apps/dashboard/build/manifest.json b/apps/dashboard/build/manifest.json deleted file mode 100644 index 92e55e6..0000000 --- a/apps/dashboard/build/manifest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "Vestige Memory Dashboard", - "short_name": "Vestige", - "description": "Cognitive memory visualization for AI agents", - "start_url": "/", - "display": "standalone", - "background_color": "#050510", - "theme_color": "#050510", - "icons": [ - { - "src": "/favicon.svg", - "sizes": "any", - "type": "image/svg+xml", - "purpose": "any maskable" - } - ], - "categories": ["developer", "utilities"], - "orientation": "any" -} diff --git a/apps/dashboard/build/manifest.json.br b/apps/dashboard/build/manifest.json.br deleted file mode 100644 index 6801932..0000000 Binary files a/apps/dashboard/build/manifest.json.br and /dev/null differ diff --git a/apps/dashboard/build/manifest.json.gz b/apps/dashboard/build/manifest.json.gz deleted file mode 100644 index d01868a..0000000 Binary files a/apps/dashboard/build/manifest.json.gz and /dev/null differ diff --git a/apps/dashboard/build/msdf/jetbrains-mono.json b/apps/dashboard/build/msdf/jetbrains-mono.json deleted file mode 100644 index e498b4a..0000000 --- a/apps/dashboard/build/msdf/jetbrains-mono.json +++ /dev/null @@ -1 +0,0 @@ -{"atlas":{"type":"mtsdf","distanceRange":4,"distanceRangeMiddle":0,"size":48,"width":512,"height":512,"yOrigin":"bottom"},"metrics":{"emSize":1,"lineHeight":1.3200000000000001,"ascender":1.02,"descender":-0.29999999999999999,"underlineY":-0.17999999999999999,"underlineThickness":0.050000000000000003},"glyphs":[{"unicode":32,"advance":0.59999999999999998},{"unicode":33,"advance":0.59999999999999998,"planeBounds":{"left":0.17500000000000002,"bottom":-0.052083333333333336,"right":0.42499999999999999,"top":0.78125},"atlasBounds":{"left":495.5,"bottom":471.5,"right":507.5,"top":511.5}},{"unicode":34,"advance":0.59999999999999998,"planeBounds":{"left":0.091666666666666716,"bottom":0.38541666666666669,"right":0.50833333333333341,"top":0.78125},"atlasBounds":{"left":489.5,"bottom":354.5,"right":509.5,"top":373.5}},{"unicode":35,"advance":0.59999999999999998,"planeBounds":{"left":-0.012500000000000023,"bottom":-0.052083333333333336,"right":0.61249999999999993,"top":0.78125},"atlasBounds":{"left":157.5,"bottom":416.5,"right":187.5,"top":456.5}},{"unicode":36,"advance":0.59999999999999998,"planeBounds":{"left":0.02916666666666665,"bottom":-0.19791666666666669,"right":0.5708333333333333,"top":0.92708333333333326},"atlasBounds":{"left":0.5,"bottom":457.5,"right":26.5,"top":511.5}},{"unicode":37,"advance":0.59999999999999998,"planeBounds":{"left":-0.033333333333333381,"bottom":-0.052083333333333336,"right":0.6333333333333333,"top":0.78125},"atlasBounds":{"left":188.5,"bottom":416.5,"right":220.5,"top":456.5}},{"unicode":38,"advance":0.59999999999999998,"planeBounds":{"left":-0.023749999999999993,"bottom":-0.052083333333333336,"right":0.66375000000000006,"top":0.80208333333333326},"atlasBounds":{"left":325.5,"bottom":470.5,"right":358.5,"top":511.5}},{"unicode":39,"advance":0.59999999999999998,"planeBounds":{"left":0.20625000000000002,"bottom":0.38541666666666669,"right":0.39374999999999999,"top":0.78125},"atlasBounds":{"left":248.5,"bottom":313.5,"right":257.5,"top":332.5}},{"unicode":40,"advance":0.59999999999999998,"planeBounds":{"left":0.13708333333333328,"bottom":-0.17708333333333334,"right":0.53291666666666659,"top":0.88541666666666663},"atlasBounds":{"left":27.5,"bottom":460.5,"right":46.5,"top":511.5}},{"unicode":41,"advance":0.59999999999999998,"planeBounds":{"left":0.06708333333333337,"bottom":-0.17708333333333334,"right":0.4629166666666667,"top":0.88541666666666663},"atlasBounds":{"left":47.5,"bottom":460.5,"right":66.5,"top":511.5}},{"unicode":42,"advance":0.59999999999999998,"planeBounds":{"left":-0.012500000000000023,"bottom":0.052083333333333329,"right":0.61249999999999993,"top":0.67708333333333326},"atlasBounds":{"left":136.5,"bottom":302.5,"right":166.5,"top":332.5}},{"unicode":43,"advance":0.59999999999999998,"planeBounds":{"left":0.018749999999999951,"bottom":0.052083333333333329,"right":0.58124999999999993,"top":0.61458333333333326},"atlasBounds":{"left":167.5,"bottom":305.5,"right":194.5,"top":332.5}},{"unicode":44,"advance":0.59999999999999998,"planeBounds":{"left":0.16650000000000001,"bottom":-0.21875,"right":0.41649999999999998,"top":0.19791666666666666},"atlasBounds":{"left":496.5,"bottom":423.5,"right":508.5,"top":443.5}},{"unicode":45,"advance":0.59999999999999998,"planeBounds":{"left":0.091666666666666716,"bottom":0.23958333333333331,"right":0.50833333333333341,"top":0.42708333333333331},"atlasBounds":{"left":489.5,"bottom":344.5,"right":509.5,"top":353.5}},{"unicode":46,"advance":0.59999999999999998,"planeBounds":{"left":0.17500000000000002,"bottom":-0.052083333333333336,"right":0.42499999999999999,"top":0.19791666666666666},"atlasBounds":{"left":286.5,"bottom":320.5,"right":298.5,"top":332.5}},{"unicode":47,"advance":0.59999999999999998,"planeBounds":{"left":0.029166666666666643,"bottom":-0.15625,"right":0.5708333333333333,"top":0.88541666666666663},"atlasBounds":{"left":126.5,"bottom":461.5,"right":152.5,"top":511.5}},{"unicode":48,"advance":0.59999999999999998,"planeBounds":{"left":0.029166666666666643,"bottom":-0.052083333333333336,"right":0.5708333333333333,"top":0.80208333333333326},"atlasBounds":{"left":385.5,"bottom":470.5,"right":411.5,"top":511.5}},{"unicode":49,"advance":0.59999999999999998,"planeBounds":{"left":0.044166666666666646,"bottom":-0.052083333333333336,"right":0.58583333333333332,"top":0.78125},"atlasBounds":{"left":276.5,"bottom":416.5,"right":302.5,"top":456.5}},{"unicode":50,"advance":0.59999999999999998,"planeBounds":{"left":0.03066666666666663,"bottom":-0.052083333333333336,"right":0.57233333333333325,"top":0.80208333333333326},"atlasBounds":{"left":412.5,"bottom":470.5,"right":438.5,"top":511.5}},{"unicode":51,"advance":0.59999999999999998,"planeBounds":{"left":0.019166666666666644,"bottom":-0.052083333333333336,"right":0.56083333333333329,"top":0.78125},"atlasBounds":{"left":303.5,"bottom":416.5,"right":329.5,"top":456.5}},{"unicode":52,"advance":0.59999999999999998,"planeBounds":{"left":0.019583333333333335,"bottom":-0.052083333333333336,"right":0.54041666666666666,"top":0.78125},"atlasBounds":{"left":330.5,"bottom":416.5,"right":355.5,"top":456.5}},{"unicode":53,"advance":0.59999999999999998,"planeBounds":{"left":0.024166666666666642,"bottom":-0.052083333333333336,"right":0.5658333333333333,"top":0.78125},"atlasBounds":{"left":356.5,"bottom":416.5,"right":382.5,"top":456.5}},{"unicode":54,"advance":0.59999999999999998,"planeBounds":{"left":0.018749999999999951,"bottom":-0.052083333333333336,"right":0.58124999999999993,"top":0.78125},"atlasBounds":{"left":383.5,"bottom":416.5,"right":410.5,"top":456.5}},{"unicode":55,"advance":0.59999999999999998,"planeBounds":{"left":0.032749999999999987,"bottom":-0.052083333333333336,"right":0.59525000000000006,"top":0.78125},"atlasBounds":{"left":411.5,"bottom":416.5,"right":438.5,"top":456.5}},{"unicode":56,"advance":0.59999999999999998,"planeBounds":{"left":0.018749999999999985,"bottom":-0.052083333333333336,"right":0.58125000000000004,"top":0.80208333333333326},"atlasBounds":{"left":439.5,"bottom":470.5,"right":466.5,"top":511.5}},{"unicode":57,"advance":0.59999999999999998,"planeBounds":{"left":0.018749999999999951,"bottom":-0.052083333333333336,"right":0.58124999999999993,"top":0.80208333333333326},"atlasBounds":{"left":467.5,"bottom":470.5,"right":494.5,"top":511.5}},{"unicode":58,"advance":0.59999999999999998,"planeBounds":{"left":0.17500000000000002,"bottom":-0.052083333333333336,"right":0.42499999999999999,"top":0.61458333333333326},"atlasBounds":{"left":233.5,"bottom":341.5,"right":245.5,"top":373.5}},{"unicode":59,"advance":0.59999999999999998,"planeBounds":{"left":0.15958333333333338,"bottom":-0.21875,"right":0.43041666666666667,"top":0.61458333333333326},"atlasBounds":{"left":165.5,"bottom":333.5,"right":178.5,"top":373.5}},{"unicode":60,"advance":0.59999999999999998,"planeBounds":{"left":0.039583333333333304,"bottom":0.010416666666666666,"right":0.56041666666666667,"top":0.65625},"atlasBounds":{"left":55.5,"bottom":301.5,"right":80.5,"top":332.5}},{"unicode":61,"advance":0.59999999999999998,"planeBounds":{"left":0.039583333333333304,"bottom":0.11458333333333334,"right":0.56041666666666667,"top":0.55208333333333326},"atlasBounds":{"left":222.5,"bottom":311.5,"right":247.5,"top":332.5}},{"unicode":62,"advance":0.59999999999999998,"planeBounds":{"left":0.039583333333333304,"bottom":0.010416666666666666,"right":0.56041666666666667,"top":0.65625},"atlasBounds":{"left":432.5,"bottom":342.5,"right":457.5,"top":373.5}},{"unicode":63,"advance":0.59999999999999998,"planeBounds":{"left":0.078333333333333297,"bottom":-0.052083333333333336,"right":0.53666666666666663,"top":0.78125},"atlasBounds":{"left":489.5,"bottom":374.5,"right":511.5,"top":414.5}},{"unicode":64,"advance":0.59999999999999998,"planeBounds":{"left":0.00041666666666661991,"bottom":-0.23958333333333334,"right":0.60458333333333325,"top":0.80208333333333326},"atlasBounds":{"left":153.5,"bottom":461.5,"right":182.5,"top":511.5}},{"unicode":65,"advance":0.59999999999999998,"planeBounds":{"left":0.0083333333333332985,"bottom":-0.052083333333333336,"right":0.59166666666666667,"top":0.78125},"atlasBounds":{"left":52.5,"bottom":333.5,"right":80.5,"top":373.5}},{"unicode":66,"advance":0.59999999999999998,"planeBounds":{"left":0.051083333333333286,"bottom":-0.052083333333333336,"right":0.57191666666666663,"top":0.78125},"atlasBounds":{"left":26.5,"bottom":333.5,"right":51.5,"top":373.5}},{"unicode":67,"advance":0.59999999999999998,"planeBounds":{"left":0.046583333333333303,"bottom":-0.052083333333333336,"right":0.56741666666666668,"top":0.80208333333333326},"atlasBounds":{"left":0.5,"bottom":415.5,"right":25.5,"top":456.5}},{"unicode":68,"advance":0.59999999999999998,"planeBounds":{"left":0.041583333333333333,"bottom":-0.052083333333333336,"right":0.56241666666666668,"top":0.78125},"atlasBounds":{"left":0.5,"bottom":333.5,"right":25.5,"top":373.5}},{"unicode":69,"advance":0.59999999999999998,"planeBounds":{"left":0.049583333333333333,"bottom":-0.052083333333333336,"right":0.57041666666666668,"top":0.78125},"atlasBounds":{"left":463.5,"bottom":374.5,"right":488.5,"top":414.5}},{"unicode":70,"advance":0.59999999999999998,"planeBounds":{"left":0.049583333333333299,"bottom":-0.052083333333333336,"right":0.57041666666666668,"top":0.78125},"atlasBounds":{"left":437.5,"bottom":374.5,"right":462.5,"top":414.5}},{"unicode":71,"advance":0.59999999999999998,"planeBounds":{"left":0.042583333333333299,"bottom":-0.052083333333333336,"right":0.56341666666666668,"top":0.80208333333333326},"atlasBounds":{"left":52.5,"bottom":415.5,"right":77.5,"top":456.5}},{"unicode":72,"advance":0.59999999999999998,"planeBounds":{"left":0.050000000000000003,"bottom":-0.052083333333333336,"right":0.55000000000000004,"top":0.78125},"atlasBounds":{"left":384.5,"bottom":374.5,"right":408.5,"top":414.5}},{"unicode":73,"advance":0.59999999999999998,"planeBounds":{"left":0.06041666666666666,"bottom":-0.052083333333333336,"right":0.5395833333333333,"top":0.78125},"atlasBounds":{"left":360.5,"bottom":374.5,"right":383.5,"top":414.5}},{"unicode":74,"advance":0.59999999999999998,"planeBounds":{"left":-0.00083333333333335344,"bottom":-0.052083333333333336,"right":0.54083333333333328,"top":0.78125},"atlasBounds":{"left":333.5,"bottom":374.5,"right":359.5,"top":414.5}},{"unicode":75,"advance":0.59999999999999998,"planeBounds":{"left":0.044749999999999984,"bottom":-0.052083333333333336,"right":0.60725000000000007,"top":0.78125},"atlasBounds":{"left":305.5,"bottom":374.5,"right":332.5,"top":414.5}},{"unicode":76,"advance":0.59999999999999998,"planeBounds":{"left":0.079583333333333311,"bottom":-0.052083333333333336,"right":0.6004166666666666,"top":0.78125},"atlasBounds":{"left":279.5,"bottom":374.5,"right":304.5,"top":414.5}},{"unicode":77,"advance":0.59999999999999998,"planeBounds":{"left":0.02916666666666665,"bottom":-0.052083333333333336,"right":0.5708333333333333,"top":0.78125},"atlasBounds":{"left":252.5,"bottom":374.5,"right":278.5,"top":414.5}},{"unicode":78,"advance":0.59999999999999998,"planeBounds":{"left":0.039583333333333338,"bottom":-0.052083333333333336,"right":0.56041666666666667,"top":0.78125},"atlasBounds":{"left":226.5,"bottom":374.5,"right":251.5,"top":414.5}},{"unicode":79,"advance":0.59999999999999998,"planeBounds":{"left":0.039583333333333338,"bottom":-0.052083333333333336,"right":0.56041666666666667,"top":0.80208333333333326},"atlasBounds":{"left":104.5,"bottom":415.5,"right":129.5,"top":456.5}},{"unicode":80,"advance":0.59999999999999998,"planeBounds":{"left":0.050166666666666651,"bottom":-0.052083333333333336,"right":0.59183333333333332,"top":0.78125},"atlasBounds":{"left":169.5,"bottom":374.5,"right":195.5,"top":414.5}},{"unicode":81,"advance":0.59999999999999998,"planeBounds":{"left":0.032166666666666642,"bottom":-0.23958333333333334,"right":0.57383333333333331,"top":0.80208333333333326},"atlasBounds":{"left":183.5,"bottom":461.5,"right":209.5,"top":511.5}},{"unicode":82,"advance":0.59999999999999998,"planeBounds":{"left":0.048166666666666642,"bottom":-0.052083333333333336,"right":0.58983333333333332,"top":0.78125},"atlasBounds":{"left":113.5,"bottom":374.5,"right":139.5,"top":414.5}},{"unicode":83,"advance":0.59999999999999998,"planeBounds":{"left":0.02916666666666665,"bottom":-0.052083333333333336,"right":0.5708333333333333,"top":0.80208333333333326},"atlasBounds":{"left":130.5,"bottom":415.5,"right":156.5,"top":456.5}},{"unicode":84,"advance":0.59999999999999998,"planeBounds":{"left":0.0083333333333332951,"bottom":-0.052083333333333336,"right":0.59166666666666667,"top":0.78125},"atlasBounds":{"left":58.5,"bottom":374.5,"right":86.5,"top":414.5}},{"unicode":85,"advance":0.59999999999999998,"planeBounds":{"left":0.039583333333333338,"bottom":-0.052083333333333336,"right":0.56041666666666667,"top":0.78125},"atlasBounds":{"left":32.5,"bottom":374.5,"right":57.5,"top":414.5}},{"unicode":86,"advance":0.59999999999999998,"planeBounds":{"left":0.0083333333333332985,"bottom":-0.052083333333333336,"right":0.59166666666666667,"top":0.78125},"atlasBounds":{"left":140.5,"bottom":374.5,"right":168.5,"top":414.5}},{"unicode":87,"advance":0.59999999999999998,"planeBounds":{"left":-0.022916666666666714,"bottom":-0.052083333333333336,"right":0.62291666666666667,"top":0.78125},"atlasBounds":{"left":0.5,"bottom":374.5,"right":31.5,"top":414.5}},{"unicode":88,"advance":0.59999999999999998,"planeBounds":{"left":-0.0020833333333333589,"bottom":-0.052083333333333336,"right":0.6020833333333333,"top":0.78125},"atlasBounds":{"left":196.5,"bottom":374.5,"right":225.5,"top":414.5}},{"unicode":89,"advance":0.59999999999999998,"planeBounds":{"left":-0.012500000000000023,"bottom":-0.052083333333333336,"right":0.61249999999999993,"top":0.78125},"atlasBounds":{"left":465.5,"bottom":416.5,"right":495.5,"top":456.5}},{"unicode":90,"advance":0.59999999999999998,"planeBounds":{"left":0.039583333333333304,"bottom":-0.052083333333333336,"right":0.56041666666666667,"top":0.78125},"atlasBounds":{"left":439.5,"bottom":416.5,"right":464.5,"top":456.5}},{"unicode":91,"advance":0.59999999999999998,"planeBounds":{"left":0.16083333333333336,"bottom":-0.15625,"right":0.4941666666666667,"top":0.88541666666666663},"atlasBounds":{"left":210.5,"bottom":461.5,"right":226.5,"top":511.5}},{"unicode":92,"advance":0.59999999999999998,"planeBounds":{"left":0.029166666666666643,"bottom":-0.15625,"right":0.5708333333333333,"top":0.88541666666666663},"atlasBounds":{"left":227.5,"bottom":461.5,"right":253.5,"top":511.5}},{"unicode":93,"advance":0.59999999999999998,"planeBounds":{"left":0.10583333333333336,"bottom":-0.15625,"right":0.43916666666666671,"top":0.88541666666666663},"atlasBounds":{"left":254.5,"bottom":461.5,"right":270.5,"top":511.5}},{"unicode":94,"advance":0.59999999999999998,"planeBounds":{"left":0.029166666666666643,"bottom":0.28125,"right":0.5708333333333333,"top":0.78125},"atlasBounds":{"left":195.5,"bottom":308.5,"right":221.5,"top":332.5}},{"unicode":95,"advance":0.59999999999999998,"planeBounds":{"left":0.0083333333333332916,"bottom":-0.15625,"right":0.59166666666666667,"top":0.03125},"atlasBounds":{"left":299.5,"bottom":323.5,"right":327.5,"top":332.5}},{"unicode":96,"advance":0.59999999999999998,"planeBounds":{"left":0.11075000000000004,"bottom":0.59375,"right":0.42325000000000002,"top":0.84375},"atlasBounds":{"left":496.5,"bottom":444.5,"right":511.5,"top":456.5}},{"unicode":97,"advance":0.59999999999999998,"planeBounds":{"left":0.016666666666666621,"bottom":-0.052083333333333336,"right":0.55833333333333324,"top":0.61458333333333326},"atlasBounds":{"left":272.5,"bottom":341.5,"right":298.5,"top":373.5}},{"unicode":98,"advance":0.59999999999999998,"planeBounds":{"left":0.04208333333333332,"bottom":-0.052083333333333336,"right":0.56291666666666662,"top":0.78125},"atlasBounds":{"left":221.5,"bottom":416.5,"right":246.5,"top":456.5}},{"unicode":99,"advance":0.59999999999999998,"planeBounds":{"left":0.045083333333333288,"bottom":-0.052083333333333336,"right":0.56591666666666662,"top":0.61458333333333326},"atlasBounds":{"left":246.5,"bottom":341.5,"right":271.5,"top":373.5}},{"unicode":100,"advance":0.59999999999999998,"planeBounds":{"left":0.037083333333333322,"bottom":-0.052083333333333336,"right":0.55791666666666662,"top":0.78125},"atlasBounds":{"left":87.5,"bottom":374.5,"right":112.5,"top":414.5}},{"unicode":101,"advance":0.59999999999999998,"planeBounds":{"left":0.039583333333333311,"bottom":-0.052083333333333336,"right":0.56041666666666667,"top":0.61458333333333326},"atlasBounds":{"left":325.5,"bottom":341.5,"right":350.5,"top":373.5}},{"unicode":102,"advance":0.59999999999999998,"planeBounds":{"left":0.011249999999999972,"bottom":-0.052083333333333336,"right":0.57374999999999987,"top":0.78125},"atlasBounds":{"left":409.5,"bottom":374.5,"right":436.5,"top":414.5}},{"unicode":103,"advance":0.59999999999999998,"planeBounds":{"left":0.037083333333333322,"bottom":-0.23958333333333334,"right":0.55791666666666662,"top":0.61458333333333326},"atlasBounds":{"left":78.5,"bottom":415.5,"right":103.5,"top":456.5}},{"unicode":104,"advance":0.59999999999999998,"planeBounds":{"left":0.040583333333333339,"bottom":-0.052083333333333336,"right":0.56141666666666667,"top":0.78125},"atlasBounds":{"left":111.5,"bottom":333.5,"right":136.5,"top":373.5}},{"unicode":105,"advance":0.59999999999999998,"planeBounds":{"left":0.038749999999999951,"bottom":-0.052083333333333336,"right":0.60124999999999995,"top":0.82291666666666663},"atlasBounds":{"left":297.5,"bottom":469.5,"right":324.5,"top":511.5}},{"unicode":106,"advance":0.59999999999999998,"planeBounds":{"left":0.038833333333333352,"bottom":-0.23958333333333334,"right":0.4971666666666667,"top":0.82291666666666663},"atlasBounds":{"left":67.5,"bottom":460.5,"right":89.5,"top":511.5}},{"unicode":107,"advance":0.59999999999999998,"planeBounds":{"left":0.046749999999999979,"bottom":-0.052083333333333336,"right":0.60924999999999996,"top":0.78125},"atlasBounds":{"left":137.5,"bottom":333.5,"right":164.5,"top":373.5}},{"unicode":108,"advance":0.59999999999999998,"planeBounds":{"left":-0.012083333333333359,"bottom":-0.052083333333333336,"right":0.59208333333333329,"top":0.78125},"atlasBounds":{"left":81.5,"bottom":333.5,"right":110.5,"top":373.5}},{"unicode":109,"advance":0.59999999999999998,"planeBounds":{"left":0.0083333333333332916,"bottom":-0.052083333333333336,"right":0.59166666666666667,"top":0.61458333333333326},"atlasBounds":{"left":403.5,"bottom":341.5,"right":431.5,"top":373.5}},{"unicode":110,"advance":0.59999999999999998,"planeBounds":{"left":0.040583333333333339,"bottom":-0.052083333333333336,"right":0.56141666666666667,"top":0.61458333333333326},"atlasBounds":{"left":351.5,"bottom":341.5,"right":376.5,"top":373.5}},{"unicode":111,"advance":0.59999999999999998,"planeBounds":{"left":0.039583333333333311,"bottom":-0.052083333333333336,"right":0.56041666666666667,"top":0.61458333333333326},"atlasBounds":{"left":299.5,"bottom":341.5,"right":324.5,"top":373.5}},{"unicode":112,"advance":0.59999999999999998,"planeBounds":{"left":0.04208333333333332,"bottom":-0.23958333333333334,"right":0.56291666666666662,"top":0.61458333333333326},"atlasBounds":{"left":359.5,"bottom":470.5,"right":384.5,"top":511.5}},{"unicode":113,"advance":0.59999999999999998,"planeBounds":{"left":0.037083333333333322,"bottom":-0.23958333333333334,"right":0.55791666666666662,"top":0.61458333333333326},"atlasBounds":{"left":26.5,"bottom":415.5,"right":51.5,"top":456.5}},{"unicode":114,"advance":0.59999999999999998,"planeBounds":{"left":0.060583333333333309,"bottom":-0.052083333333333336,"right":0.58141666666666669,"top":0.61458333333333326},"atlasBounds":{"left":207.5,"bottom":341.5,"right":232.5,"top":373.5}},{"unicode":115,"advance":0.59999999999999998,"planeBounds":{"left":0.039583333333333304,"bottom":-0.052083333333333336,"right":0.56041666666666667,"top":0.61458333333333326},"atlasBounds":{"left":377.5,"bottom":341.5,"right":402.5,"top":373.5}},{"unicode":116,"advance":0.59999999999999998,"planeBounds":{"left":0.0022499999999999716,"bottom":-0.052083333333333336,"right":0.56474999999999986,"top":0.76041666666666663},"atlasBounds":{"left":179.5,"bottom":334.5,"right":206.5,"top":373.5}},{"unicode":117,"advance":0.59999999999999998,"planeBounds":{"left":0.039583333333333338,"bottom":-0.052083333333333336,"right":0.56041666666666667,"top":0.59375},"atlasBounds":{"left":29.5,"bottom":301.5,"right":54.5,"top":332.5}},{"unicode":118,"advance":0.59999999999999998,"planeBounds":{"left":0.0083333333333332951,"bottom":-0.052083333333333336,"right":0.59166666666666667,"top":0.59375},"atlasBounds":{"left":107.5,"bottom":301.5,"right":135.5,"top":332.5}},{"unicode":119,"advance":0.59999999999999998,"planeBounds":{"left":-0.01250000000000002,"bottom":-0.052083333333333336,"right":0.61250000000000004,"top":0.59375},"atlasBounds":{"left":458.5,"bottom":342.5,"right":488.5,"top":373.5}},{"unicode":120,"advance":0.59999999999999998,"planeBounds":{"left":0.0083333333333332985,"bottom":-0.052083333333333336,"right":0.59166666666666667,"top":0.59375},"atlasBounds":{"left":0.5,"bottom":301.5,"right":28.5,"top":332.5}},{"unicode":121,"advance":0.59999999999999998,"planeBounds":{"left":0.0083333333333332951,"bottom":-0.23958333333333334,"right":0.59166666666666667,"top":0.59375},"atlasBounds":{"left":247.5,"bottom":416.5,"right":275.5,"top":456.5}},{"unicode":122,"advance":0.59999999999999998,"planeBounds":{"left":0.039583333333333338,"bottom":-0.052083333333333336,"right":0.56041666666666667,"top":0.59375},"atlasBounds":{"left":81.5,"bottom":301.5,"right":106.5,"top":332.5}},{"unicode":123,"advance":0.59999999999999998,"planeBounds":{"left":0.029583333333333302,"bottom":-0.15625,"right":0.55041666666666667,"top":0.88541666666666663},"atlasBounds":{"left":271.5,"bottom":461.5,"right":296.5,"top":511.5}},{"unicode":124,"advance":0.59999999999999998,"planeBounds":{"left":0.20625000000000002,"bottom":-0.15625,"right":0.39374999999999999,"top":0.88541666666666663},"atlasBounds":{"left":116.5,"bottom":461.5,"right":125.5,"top":511.5}},{"unicode":125,"advance":0.59999999999999998,"planeBounds":{"left":0.049583333333333299,"bottom":-0.15625,"right":0.57041666666666668,"top":0.88541666666666663},"atlasBounds":{"left":90.5,"bottom":461.5,"right":115.5,"top":511.5}},{"unicode":126,"advance":0.59999999999999998,"planeBounds":{"left":0.018749999999999985,"bottom":0.19791666666666666,"right":0.58125000000000004,"top":0.51041666666666663},"atlasBounds":{"left":258.5,"bottom":317.5,"right":285.5,"top":332.5}}],"kerning":[]} diff --git a/apps/dashboard/build/msdf/jetbrains-mono.json.br b/apps/dashboard/build/msdf/jetbrains-mono.json.br deleted file mode 100644 index 8801ac6..0000000 Binary files a/apps/dashboard/build/msdf/jetbrains-mono.json.br and /dev/null differ diff --git a/apps/dashboard/build/msdf/jetbrains-mono.json.gz b/apps/dashboard/build/msdf/jetbrains-mono.json.gz deleted file mode 100644 index 51d409e..0000000 Binary files a/apps/dashboard/build/msdf/jetbrains-mono.json.gz and /dev/null differ diff --git a/apps/dashboard/build/msdf/jetbrains-mono.png b/apps/dashboard/build/msdf/jetbrains-mono.png deleted file mode 100644 index c8d7428..0000000 Binary files a/apps/dashboard/build/msdf/jetbrains-mono.png and /dev/null differ diff --git a/apps/dashboard/package.json b/apps/dashboard/package.json index fb43122..074f5ff 100644 --- a/apps/dashboard/package.json +++ b/apps/dashboard/package.json @@ -1,6 +1,6 @@ { "name": "@vestige/dashboard", - "version": "2.2.0", + "version": "2.2.1", "private": true, "type": "module", "scripts": { diff --git a/apps/dashboard/src/lib/stores/websocket.ts b/apps/dashboard/src/lib/stores/websocket.ts index 2e591ac..578c43b 100644 --- a/apps/dashboard/src/lib/stores/websocket.ts +++ b/apps/dashboard/src/lib/stores/websocket.ts @@ -74,8 +74,19 @@ function createWebSocketStore() { } function disconnect() { - if (reconnectTimer) clearTimeout(reconnectTimer); - ws?.close(); + if (reconnectTimer) { + clearTimeout(reconnectTimer); + reconnectTimer = null; + } + if (ws) { + // Detach onclose BEFORE closing: otherwise close() fires the handler, + // which calls scheduleReconnect and resurrects the socket we just + // asked to tear down. + ws.onclose = null; + ws.onerror = null; + ws.onmessage = null; + ws.close(); + } ws = null; set({ connected: false, reconnecting: false, events: [], lastHeartbeat: null, error: null }); } diff --git a/crates/vestige-core/Cargo.toml b/crates/vestige-core/Cargo.toml index 5255f31..e794089 100644 --- a/crates/vestige-core/Cargo.toml +++ b/crates/vestige-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vestige-core" -version = "2.2.0" +version = "2.2.1" edition = "2024" rust-version = "1.91" authors = ["Vestige Team"] diff --git a/crates/vestige-core/src/advanced/chains.rs b/crates/vestige-core/src/advanced/chains.rs index 6926c56..eaba514 100644 --- a/crates/vestige-core/src/advanced/chains.rs +++ b/crates/vestige-core/src/advanced/chains.rs @@ -534,13 +534,17 @@ impl MemoryChainBuilder { }); } - // Calculate overall confidence + // Calculate overall confidence as the geometric mean of the CONNECTION + // strengths. The root must be the number of connections (the count of + // factors in the product), not memories.len() (= connections + 1), which + // systematically inflated the reported confidence. + let n = path.connections.len().max(1) as f64; let confidence = path .connections .iter() .map(|c| c.strength) .fold(1.0, |acc, s| acc * s) - .powf(1.0 / path.memories.len() as f64); // Geometric mean + .powf(1.0 / n); // Geometric mean over connections // Generate explanation let explanation = self.generate_explanation(&steps); diff --git a/crates/vestige-core/src/advanced/dreams.rs b/crates/vestige-core/src/advanced/dreams.rs index 81d9039..7e32547 100644 --- a/crates/vestige-core/src/advanced/dreams.rs +++ b/crates/vestige-core/src/advanced/dreams.rs @@ -1600,15 +1600,20 @@ impl MemoryDreamer { memories: &[&DreamMemory], common_tags: &[String], ) -> (String, InsightType) { - // Determine insight type based on memory characteristics - let time_range = memories + // Determine insight type based on memory characteristics. Seed the + // (min, max) fold from the ACTUAL first timestamp, not (now, now-365d) + // sentinels: those sentinels leaked into the span for clusters of old + // memories (all created > 365d ago), where min stayed pinned near `now` + // and inflated time_span_days past 30, fabricating a TemporalTrend. + let time_span_days = memories .iter() .map(|m| m.created_at) - .fold((Utc::now(), Utc::now() - Duration::days(365)), |acc, t| { - (acc.0.min(t), acc.1.max(t)) - }); - - let time_span_days = (time_range.1 - time_range.0).num_days(); + .fold(None::<(DateTime, DateTime)>, |acc, t| match acc { + None => Some((t, t)), + Some((lo, hi)) => Some((lo.min(t), hi.max(t))), + }) + .map(|(lo, hi)| (hi - lo).num_days()) + .unwrap_or(0); if time_span_days > 30 { // Temporal trend diff --git a/crates/vestige-core/src/advanced/prediction_error.rs b/crates/vestige-core/src/advanced/prediction_error.rs index 17277db..7d79cd6 100644 --- a/crates/vestige-core/src/advanced/prediction_error.rs +++ b/crates/vestige-core/src/advanced/prediction_error.rs @@ -550,23 +550,28 @@ impl PredictionErrorGate { let new_lower = new_content.to_lowercase(); let old_lower = old_content.to_lowercase(); - // Check for explicit negation patterns + // Check for explicit negation patterns — a real polarity FLIP, not the + // mere presence of a negation word. We require the negation term in the + // new content AND its paired positive term in the old content (old: "use + // X"; new: "avoid X"). The previous logic fired whenever the new content + // merely contained a negation word the old one lacked, so ordinary + // additive notes ("Do not forget to configure X" — contains "not ") were + // misread as corrections and demoted a correct memory. Bare triggers with + // no paired positive term ("not ", "instead of", "rather than") are + // dropped for the same reason: they match complementary phrasing. let negation_pairs = [ + ("don't use", "use"), ("don't", "do"), ("never", "always"), ("avoid", "use"), ("wrong", "right"), - ("bad", "good"), ("incorrect", "correct"), ("deprecated", "recommended"), ("outdated", "current"), - ("instead of", ""), - ("rather than", ""), - ("not ", ""), ]; - for (neg, _pos) in negation_pairs.iter() { - if new_lower.contains(neg) && !old_lower.contains(neg) { + for (neg, pos) in negation_pairs.iter() { + if new_lower.contains(neg) && old_lower.contains(pos) && !old_lower.contains(neg) { return true; } } @@ -835,6 +840,24 @@ mod tests { "Use async/await for performance", "Use async patterns when needed" )); + + // Regression: a benign ADDITIVE note that merely contains a negation word + // ("do not", "cannot") must NOT be flagged as a contradiction. Previously + // the bare "not " substring fired here and demoted the correct memory. + assert!( + !gate.detect_contradiction( + "Do not forget to configure the async runtime for the worker pool", + "Use the async runtime for the worker pool" + ), + "additive 'do not forget' note must not read as a contradiction" + ); + assert!( + !gate.detect_contradiction( + "You cannot skip the migration step", + "Run the migration step before deploying" + ), + "'cannot' in complementary guidance must not read as a contradiction" + ); } #[test] diff --git a/crates/vestige-core/src/advanced/retroactive_backfill.rs b/crates/vestige-core/src/advanced/retroactive_backfill.rs index b5b7a48..d298b3c 100644 --- a/crates/vestige-core/src/advanced/retroactive_backfill.rs +++ b/crates/vestige-core/src/advanced/retroactive_backfill.rs @@ -52,7 +52,12 @@ pub const MIN_SHARED_ENTITIES: usize = 1; pub const FAILURE_MARKERS: &[&str] = &[ "error", "bug", "crash", "crashed", "regression", "broke", "broken", "failure", "failed", "panic", "exception", "fault", "outage", "incident", - "500", "timeout", "deadlock", "leak", "corrupt", "stack overflow", + // NOTE: bare "500" was removed — it matched benign content like "$500", + // "500 users", or "line 500" and wrongly flagged a quiet CAUSE memory as a + // failure, excluding it from the backward reach. The specific HTTP error + // codes 502/503/504 below stay; a genuine "HTTP 500" is still caught by + // "error"/"failed"/"exception" in any real incident note. + "timeout", "deadlock", "leak", "corrupt", "stack overflow", // performance/degradation failures (an agent should backfill from these too) "spiked", "latency", "degraded", "slow", "hang", "hung", "throttled", "oom", "502", "503", "504", "rejected", "denied", "flaky", @@ -139,21 +144,22 @@ pub fn extract_entities(content: &str, tags: &[String]) -> Vec { /// hits "$500" — which wrongly flags a quiet CAUSE as a failure and excludes it /// from the backward reach. fn contains_marker_word(hay: &str, marker: &str) -> bool { - let bytes = hay.as_bytes(); let mut from = 0usize; while let Some(pos) = hay[from..].find(marker) { let start = from + pos; let end = start + marker.len(); - let before_ok = start == 0 - || !{ - let c = bytes[start - 1] as char; - c.is_alphanumeric() || c == '_' - }; - let after_ok = end >= bytes.len() - || !{ - let c = bytes[end] as char; - c.is_alphanumeric() || c == '_' - }; + // Inspect the actual char before/after the match, not a raw byte cast to + // char: for a multibyte UTF-8 boundary the raw byte is a continuation + // byte (0x80-0xBF), which `as char` misreads as a non-alphanumeric and + // wrongly passes the word-boundary check. char iteration is boundary-safe. + let before_ok = hay[..start] + .chars() + .next_back() + .is_none_or(|c| !(c.is_alphanumeric() || c == '_')); + let after_ok = hay[end..] + .chars() + .next() + .is_none_or(|c| !(c.is_alphanumeric() || c == '_')); if before_ok && after_ok { return true; } diff --git a/crates/vestige-core/src/advanced/speculative.rs b/crates/vestige-core/src/advanced/speculative.rs index 9de3df5..3adaa41 100644 --- a/crates/vestige-core/src/advanced/speculative.rs +++ b/crates/vestige-core/src/advanced/speculative.rs @@ -432,7 +432,12 @@ impl SpeculativeRetriever { let mut time_counts: HashMap = HashMap::new(); for event in sequence.iter() { - if (event.timestamp.hour() as i32 - hour as i32).abs() <= 1 { + // Circular hour distance so the ±1h window wraps around midnight: + // 23:00 is 1 hour from 00:00, not 23. Without this, same-time + // predictions straddling midnight were silently dropped. + let raw = (event.timestamp.hour() as i32 - hour as i32).abs(); + let circular = raw.min(24 - raw); + if circular <= 1 { *time_counts.entry(event.memory_id.clone()).or_insert(0) += 1; } } diff --git a/crates/vestige-core/src/connectors/redmine.rs b/crates/vestige-core/src/connectors/redmine.rs index 4162edc..9ae9d18 100644 --- a/crates/vestige-core/src/connectors/redmine.rs +++ b/crates/vestige-core/src/connectors/redmine.rs @@ -243,7 +243,14 @@ impl RedmineConnector { }) .collect(); journals.sort_by_key(|j| j.id); - journals.truncate(self.config.max_journals); + // Keep the NEWEST max_journals, not the oldest: on a capped thread the + // latest activity is what signals the record changed. Truncating from the + // front (keeping oldest) meant new comments were dropped, the content_hash + // never moved, and the memory never re-indexed with fresh activity. + if journals.len() > self.config.max_journals { + let drop = journals.len() - self.config.max_journals; + journals.drain(0..drop); + } // Human-readable content. let mut content = format!("[{}#{}] {}\n", self.scope, issue.id, issue.subject); @@ -455,14 +462,23 @@ impl Connector for RedmineConnector { .map_err(|e| ConnectorError::Transport(e.to_string()))?; // Per-issue detail fetch for journals (list endpoint omits them). + // + // A detail-fetch failure must NOT silently fall back to the journal-less + // list summary: that persists a record with incomplete content and the + // WRONG content_hash, and because the offset cursor still advances past + // it, the issue is never revisited — a permanent silent gap. Instead we + // abort the page with the transport error. The driver returns without + // advancing the persisted cursor (fetch_updated is called with `?`), so + // the next run re-fetches this same window; the idempotent upsert makes + // reprocessing safe once the detail endpoint recovers. let mut records = Vec::new(); for summary in &page.issues { - let detailed = match self.fetch_detail(summary.id).await { - Ok(d) => d, - // A single issue failing detail-fetch should not abort the page; - // fall back to the list-level fields (no journals). - Err(_) => summary.clone(), - }; + let detailed = self.fetch_detail(summary.id).await.map_err(|e| { + ConnectorError::Transport(format!( + "detail fetch failed for issue {}; not advancing cursor to avoid a silent gap: {e}", + summary.id + )) + })?; records.push(self.normalize(&detailed)); } diff --git a/crates/vestige-core/src/fts.rs b/crates/vestige-core/src/fts.rs index 66e2299..e3de7bc 100644 --- a/crates/vestige-core/src/fts.rs +++ b/crates/vestige-core/src/fts.rs @@ -28,26 +28,18 @@ pub fn sanitize_fts5_terms(query: &str) -> Option { }) .collect(); - for op in FTS5_OPERATORS { - let pattern = format!(" {} ", op); - sanitized = sanitized.replace(&pattern, " "); - sanitized = sanitized.replace(&pattern.to_lowercase(), " "); - let upper = sanitized.to_uppercase(); - let start_pattern = format!("{} ", op); - if upper.starts_with(&start_pattern) { - sanitized = sanitized.chars().skip(op.len()).collect(); - } - let end_pattern = format!(" {}", op); - if upper.ends_with(&end_pattern) { - let char_count = sanitized.chars().count(); - sanitized = sanitized - .chars() - .take(char_count.saturating_sub(op.len())) - .collect(); - } - } - - let terms: Vec<&str> = sanitized.split_whitespace().collect(); + // Drop any token that IS a bare FTS5 boolean operator (AND/OR/NOT/NEAR), + // case-insensitively. Token-level filtering is complete and repetition-proof. + // The previous string-replace approach was single-pass and non-overlapping, + // so a doubled operator ("foo AND AND AND") left a bare operator at the edge + // or interior that leaked into the raw MATCH — either aborting with an FTS5 + // syntax error, or silently flipping implicit-AND to boolean-OR + // ("foo OR bar"). Filtering tokens cannot leak an operator regardless of how + // many are chained. + let terms: Vec<&str> = sanitized + .split_whitespace() + .filter(|t| !FTS5_OPERATORS.iter().any(|op| t.eq_ignore_ascii_case(op))) + .collect(); if terms.is_empty() { return None; } @@ -237,4 +229,26 @@ mod tests { let q2 = sanitize_fts5_or_query(&longtok).unwrap(); assert!(q2.len() <= 66, "single token capped at 64 + quotes, got {}", q2.len()); } + + #[test] + fn terms_strips_all_bare_operators_even_when_doubled() { + // Regression: doubled/chained operators must never leak a bare operator + // into the raw MATCH (which aborts with a syntax error or silently flips + // implicit-AND to boolean-OR). + for op in FTS5_OPERATORS { + let doubled = format!("foo {op} {op} {op} bar"); + let out = sanitize_fts5_terms(&doubled).unwrap(); + for tok in out.split_whitespace() { + assert!( + !FTS5_OPERATORS.iter().any(|o| tok.eq_ignore_ascii_case(o)), + "operator {op} leaked into output {out:?}" + ); + } + assert_eq!(out, "foo bar", "only real terms should survive: {out:?}"); + } + // Lowercase + leading/trailing operators are stripped too. + assert_eq!(sanitize_fts5_terms("or foo and bar or").unwrap(), "foo bar"); + // Operator-only input yields nothing. + assert_eq!(sanitize_fts5_terms("AND OR NOT").map(|_| ()), None); + } } diff --git a/crates/vestige-core/src/neuroscience/hippocampal_index.rs b/crates/vestige-core/src/neuroscience/hippocampal_index.rs index 378ae9e..e66f074 100644 --- a/crates/vestige-core/src/neuroscience/hippocampal_index.rs +++ b/crates/vestige-core/src/neuroscience/hippocampal_index.rs @@ -1146,7 +1146,14 @@ impl ContentStore { } } - cache.insert(key.to_string(), data.to_vec()); + // insert() returns the previous value when the key already existed; + // subtract its size so the counter reflects a REPLACE, not an ADD. + // Without this the counter drifts monotonically upward on every + // overwrite and evicts far too aggressively. + let replaced = cache.insert(key.to_string(), data.to_vec()); + if let Some(old) = replaced { + *size = size.saturating_sub(old.len()); + } *size += data_size; } } @@ -1292,6 +1299,13 @@ impl HippocampalIndex { } /// Index a new memory + /// + /// If `memory_id` is already indexed (a smart_ingest update/reinforce/replace + /// re-indexes the same node), the existing entry's barcode, association links, + /// and access history are PRESERVED — only the content-derived fields (preview, + /// semantic summary) are refreshed. Previously this always minted a new barcode + /// and inserted a fresh `MemoryIndex`, silently dropping every accumulated + /// association and the node's history on each re-index. pub fn index_memory( &self, memory_id: &str, @@ -1300,7 +1314,27 @@ impl HippocampalIndex { created_at: DateTime, semantic_embedding: Option>, ) -> Result { - // Generate barcode + let preview: String = content.chars().take(100).collect(); + let new_summary = semantic_embedding + .as_ref() + .map(|e| self.compress_embedding(e)); + + // Re-index path: refresh content fields in place, keep barcode + links. + { + let mut indices = self + .indices + .write() + .map_err(|e| HippocampalIndexError::LockError(e.to_string()))?; + if let Some(existing) = indices.get_mut(memory_id) { + existing.preview = preview; + if let Some(summary) = new_summary { + existing.semantic_summary = summary; + } + return Ok(existing.barcode); + } + } + + // First-time index: mint a barcode and create a fresh entry. let barcode = { let mut generator = self .barcode_generator @@ -1309,10 +1343,6 @@ impl HippocampalIndex { generator.generate(content, created_at) }; - // Create preview - let preview: String = content.chars().take(100).collect(); - - // Create index entry let mut index = MemoryIndex::new( barcode, memory_id.to_string(), @@ -1321,9 +1351,7 @@ impl HippocampalIndex { preview, ); - // Compress embedding if provided - if let Some(embedding) = semantic_embedding { - let summary = self.compress_embedding(&embedding); + if let Some(summary) = new_summary { index.semantic_summary = summary; } diff --git a/crates/vestige-core/src/neuroscience/importance_signals.rs b/crates/vestige-core/src/neuroscience/importance_signals.rs index e0a5123..69ba428 100644 --- a/crates/vestige-core/src/neuroscience/importance_signals.rs +++ b/crates/vestige-core/src/neuroscience/importance_signals.rs @@ -1365,7 +1365,12 @@ impl RewardPattern { fn matches(&self, tags: &[String]) -> bool { let tag_set: HashSet<_> = tags.iter().cloned().collect(); let overlap = self.tags.intersection(&tag_set).count(); - overlap >= self.tags.len().min(tag_set.len()).max(1) / 2 + // Require at least one shared tag AND at least half of the smaller set to + // overlap. The previous integer-division threshold + // (`min(a,b).max(1) / 2`) evaluated to 0 for small sets, so `overlap >= 0` + // matched EVERY pattern — including disjoint or empty tag sets. + let smaller = self.tags.len().min(tag_set.len()); + overlap >= 1 && overlap * 2 >= smaller } fn update(&mut self, reward: f64) { diff --git a/crates/vestige-core/src/neuroscience/predictive_retrieval.rs b/crates/vestige-core/src/neuroscience/predictive_retrieval.rs index da56f48..bb26ec3 100644 --- a/crates/vestige-core/src/neuroscience/predictive_retrieval.rs +++ b/crates/vestige-core/src/neuroscience/predictive_retrieval.rs @@ -844,6 +844,17 @@ impl PredictiveMemory { .write() .map_err(|e| PredictiveMemoryError::LockPoisoned(e.to_string()))?; + // Bound the metadata cache like every sibling cache in this module. + // Without a cap it grows unbounded (one entry per memory ever ingested), + // a slow leak in a long-running process. This is a best-effort prediction + // cache, so evicting an arbitrary entry when over the limit is fine. + const MAX_METADATA_ENTRIES: usize = 10_000; + if metadata.len() >= MAX_METADATA_ENTRIES + && !metadata.contains_key(memory_id) + && let Some(evict) = metadata.keys().next().cloned() + { + metadata.remove(&evict); + } metadata.insert( memory_id.to_string(), (content_preview.to_string(), tags.to_vec()), @@ -1291,13 +1302,26 @@ impl PredictiveMemory { fn merge_predictions(&self, predictions: Vec) -> Vec { let mut merged: HashMap = HashMap::new(); + let min_conf = self.config.min_confidence; for pred in predictions { merged .entry(pred.memory_id.clone()) .and_modify(|existing| { - // Combine confidence scores (taking max, with a small boost for multiple signals) - existing.confidence = (existing.confidence.max(pred.confidence) * 1.1).min(1.0); + // Combine confidence scores: take the max, with a small boost + // for multiple corroborating signals. The boost must NOT + // manufacture a threshold crossing — two individually + // sub-min_confidence signals should stay sub-threshold rather + // than combining (via *1.1) into a passing score. So the boost + // is capped at min_confidence when the strongest signal is + // itself below it. + let best = existing.confidence.max(pred.confidence); + let boosted = (best * 1.1).min(1.0); + existing.confidence = if best < min_conf { + boosted.min(min_conf - f64::EPSILON).max(best) + } else { + boosted + }; }) .or_insert(pred); } diff --git a/crates/vestige-core/src/neuroscience/prospective_memory.rs b/crates/vestige-core/src/neuroscience/prospective_memory.rs index 7adf31b..6793780 100644 --- a/crates/vestige-core/src/neuroscience/prospective_memory.rs +++ b/crates/vestige-core/src/neuroscience/prospective_memory.rs @@ -412,6 +412,35 @@ impl IntentionTrigger { } } + /// Advance a recurring trigger to its next occurrence after it fires, so it + /// re-arms instead of staying perpetually triggered. Returns true if the + /// trigger is recurring and was advanced (the intention should return to + /// Active), false for one-shot triggers (which stay fulfilled/triggered). + /// Recurs into Compound so a recurring sub-trigger inside a compound re-arms. + pub fn re_arm(&mut self, now: DateTime) -> bool { + match self { + Self::Recurring { + recurrence, + next_occurrence, + .. + } => { + // Advance from the later of "now" and the slot that just fired, + // so we never re-arm into an already-past occurrence. + let from = next_occurrence.map(|t| t.max(now)).unwrap_or(now); + *next_occurrence = Some(recurrence.next_occurrence(from)); + true + } + Self::Compound { all_of, any_of } => { + let mut any = false; + for t in all_of.iter_mut().chain(any_of.iter_mut()) { + any |= t.re_arm(now); + } + any + } + _ => false, + } + } + /// Get a human-readable description of the trigger pub fn description(&self) -> String { match self { @@ -708,9 +737,18 @@ impl Intention { /// Mark as triggered pub fn mark_triggered(&mut self) { - self.status = IntentionStatus::Triggered; + let now = Utc::now(); self.reminder_count += 1; - self.last_reminded_at = Some(Utc::now()); + self.last_reminded_at = Some(now); + // A recurring intention re-arms to its next occurrence and returns to + // Active so it fires again; a one-shot intention stays Triggered. + // Previously recurring intentions never advanced next_occurrence, so they + // fired once and never again (or stayed perpetually triggered). + if self.trigger.re_arm(now) { + self.status = IntentionStatus::Active; + } else { + self.status = IntentionStatus::Triggered; + } } /// Mark as fulfilled @@ -988,10 +1026,21 @@ impl IntentionParser { } } - // Check for "at X" time pattern. Split using the byte index found in the - // lowercased text so the case-insensitive contains() and the split agree - // (otherwise "Meeting AT 5pm" passes the check but fails the split). - if let Some(idx) = text_lower.find(" at ") { + // Check for "at X" time pattern. Find " at " case-insensitively but with a + // byte index that is valid in `original`: to_lowercase() can change byte + // length (e.g. 'ẞ' U+1E9E 3 bytes -> 'ß' U+00DF 2 bytes), so an index into + // `text_lower` can land mid-char in `original` and panic when used to slice + // it. Scanning `original`'s own char indices keeps the split boundary valid. + // Match on raw bytes to stay boundary-safe: " at " is pure ASCII, so a + // byte-window match is guaranteed to fall on char boundaries in `original`. + let bytes = original.as_bytes(); + let at_idx = bytes.windows(4).position(|w| { + (w[0] == b' ') + && (w[1] == b'a' || w[1] == b'A') + && (w[2] == b't' || w[2] == b'T') + && (w[3] == b' ') + }); + if let Some(idx) = at_idx { let parts: Vec<&str> = vec![&original[..idx], &original[idx + 4..]]; if parts.len() == 2 { let part0_lower = parts[0].to_lowercase(); @@ -1685,6 +1734,33 @@ mod tests { assert!((next - now) == Duration::hours(2)); } + #[test] + fn test_recurring_intention_re_arms_after_firing() { + // Regression (#124): a recurring intention must re-arm (advance + // next_occurrence + return to Active) each time it fires, not fire once + // and stay Triggered forever. + let now = Utc::now(); + let trigger = IntentionTrigger::Recurring { + base: Box::new(IntentionTrigger::at_time(now - Duration::minutes(1))), + recurrence: RecurrencePattern::EveryHours(2), + next_occurrence: Some(now - Duration::minutes(1)), // already due + }; + let mut intention = Intention::new("recurring task", trigger); + + // Due now, so it triggers. + assert!(intention.trigger.is_triggered(&Context::default(), &[])); + intention.mark_triggered(); + + // After firing it must be Active again (re-armed), not stuck Triggered. + assert_eq!(intention.status, IntentionStatus::Active); + // And next_occurrence must have advanced into the future so it is no + // longer immediately due. + assert!( + !intention.trigger.is_triggered(&Context::default(), &[]), + "recurring trigger must not stay perpetually due after re-arming" + ); + } + #[test] fn test_stats() { let pm = ProspectiveMemory::new(); diff --git a/crates/vestige-core/src/neuroscience/synaptic_tagging.rs b/crates/vestige-core/src/neuroscience/synaptic_tagging.rs index c5e9ca1..0bd3339 100644 --- a/crates/vestige-core/src/neuroscience/synaptic_tagging.rs +++ b/crates/vestige-core/src/neuroscience/synaptic_tagging.rs @@ -369,14 +369,25 @@ impl CaptureWindow { } } - /// Get the start of the capture window + /// Get the start of the capture window. + /// + /// Uses checked Duration + subtraction: `Duration::minutes` panics for an + /// out-of-range magnitude and the subtraction can overflow the DateTime + /// range, so an unbounded caller-supplied `backward_hours` (via the + /// `trigger_importance` MCP tool) would otherwise abort the server. On + /// overflow we saturate to the minimum representable time. pub fn window_start(&self, event_time: DateTime) -> DateTime { - event_time - Duration::minutes((self.backward_hours * 60.0) as i64) + Duration::try_minutes((self.backward_hours * 60.0) as i64) + .and_then(|d| event_time.checked_sub_signed(d)) + .unwrap_or(DateTime::::MIN_UTC) } - /// Get the end of the capture window + /// Get the end of the capture window. See `window_start` for the overflow + /// rationale; on overflow we saturate to the maximum representable time. pub fn window_end(&self, event_time: DateTime) -> DateTime { - event_time + Duration::minutes((self.forward_hours * 60.0) as i64) + Duration::try_minutes((self.forward_hours * 60.0) as i64) + .and_then(|d| event_time.checked_add_signed(d)) + .unwrap_or(DateTime::::MAX_UTC) } /// Check if a time is within the capture window diff --git a/crates/vestige-core/src/storage/migrations.rs b/crates/vestige-core/src/storage/migrations.rs index b42541c..3440f61 100644 --- a/crates/vestige-core/src/storage/migrations.rs +++ b/crates/vestige-core/src/storage/migrations.rs @@ -94,6 +94,11 @@ pub const MIGRATIONS: &[Migration] = &[ description: "Agent Black Box + Memory Receipts + Memory PRs: replayable run traces, retrieval receipts, risk-gated brain-change review queue", up: MIGRATION_V18_UP, }, + Migration { + version: 19, + description: "Scope the source idempotency key by source_project so same-system sources with overlapping ids no longer clobber each other", + up: MIGRATION_V19_UP, + }, ]; /// A database migration @@ -1133,7 +1138,33 @@ CREATE INDEX IF NOT EXISTS idx_memory_prs_created_at ON memory_prs(created_at DE UPDATE schema_version SET version = 18, applied_at = datetime('now'); "#; +const MIGRATION_V19_UP: &str = r#" +-- Scope the source idempotency key by source_project. The V17 index keyed only +-- on (source_system, source_id), so two sources of the same system (e.g. github +-- repos octocat/repoA + octocat/repoB, or two Redmine instances) with the same +-- bare per-project id ("5") collided and overwrote each other's memory in place. +-- Include source_project so each (system, project, id) gets its own row. +-- COALESCE keeps legacy rows (source_project NULL) sharing a single bucket, +-- matching the upsert lookup's `source_project IS ?` semantics. +DROP INDEX IF EXISTS idx_nodes_source_key; + +CREATE UNIQUE INDEX IF NOT EXISTS idx_nodes_source_key + ON knowledge_nodes(source_system, COALESCE(source_project, ''), source_id) + WHERE source_system IS NOT NULL AND source_id IS NOT NULL; + +UPDATE schema_version SET version = 19, applied_at = datetime('now'); +"#; + /// Apply pending migrations +/// +/// Each migration is applied inside an explicit transaction so its schema +/// change and its trailing `UPDATE schema_version` commit atomically. If a +/// migration fails partway (crash-free error, lock, disk-full), the whole +/// migration rolls back and `schema_version` stays behind — so the next run +/// replays it from a clean state instead of hitting a fatal +/// `duplicate column name` on a half-applied `ADD COLUMN` (which previously +/// bricked the DB permanently). VACUUM (V7) cannot run inside a transaction, +/// so it runs after the transaction commits. pub fn apply_migrations(conn: &rusqlite::Connection) -> rusqlite::Result { let current_version = get_current_version(conn)?; let mut applied = 0; @@ -1146,47 +1177,62 @@ pub fn apply_migrations(conn: &rusqlite::Connection) -> rusqlite::Result { migration.description ); - // V14: add the two bitemporal/protect columns BEFORE the batch (the - // batch's indexes reference them). SQLite lacks - // `ADD COLUMN IF NOT EXISTS`, so swallow the "duplicate column" - // error to stay idempotent on replay. - if migration.version == 14 { - add_column_if_missing( - conn, - "ALTER TABLE knowledge_nodes ADD COLUMN protected INTEGER NOT NULL DEFAULT 0", - )?; - add_column_if_missing( - conn, - "ALTER TABLE knowledge_nodes ADD COLUMN superseded_by TEXT", - )?; - } + // Atomic per-migration: schema change + version bump commit together + // or roll back together. On rollback, schema_version is unchanged so + // the migration cleanly re-applies next run. + { + let tx = conn.unchecked_transaction()?; - // V16 adds columns via ALTER TABLE, which SQLite does not support - // with IF NOT EXISTS. Run them individually and ignore duplicate - // column errors so replay stays idempotent. - if migration.version == 16 { - for stmt in MIGRATION_V16_ALTER_COLUMNS { - add_column_if_missing(conn, stmt)?; + // V14: add the two bitemporal/protect columns BEFORE the batch (the + // batch's indexes reference them). SQLite lacks + // `ADD COLUMN IF NOT EXISTS`, so swallow the "duplicate column" + // error to stay idempotent on replay. + if migration.version == 14 { + add_column_if_missing( + &tx, + "ALTER TABLE knowledge_nodes ADD COLUMN protected INTEGER NOT NULL DEFAULT 0", + )?; + add_column_if_missing( + &tx, + "ALTER TABLE knowledge_nodes ADD COLUMN superseded_by TEXT", + )?; } - } - // V17 (#57) adds the source-envelope columns. Same idempotent - // ALTER handling as V16 — the unique index in the V17 batch - // references these columns, so they must exist before the batch. - if migration.version == 17 { - for stmt in MIGRATION_V17_ALTER_COLUMNS { - add_column_if_missing(conn, stmt)?; + // V16 adds columns via ALTER TABLE, which SQLite does not support + // with IF NOT EXISTS. Run them individually and ignore duplicate + // column errors so replay stays idempotent. + if migration.version == 16 { + for stmt in MIGRATION_V16_ALTER_COLUMNS { + add_column_if_missing(&tx, stmt)?; + } } + + // V17 (#57) adds the source-envelope columns. Same idempotent + // ALTER handling as V16 — the unique index in the V17 batch + // references these columns, so they must exist before the batch. + if migration.version == 17 { + for stmt in MIGRATION_V17_ALTER_COLUMNS { + add_column_if_missing(&tx, stmt)?; + } + } + + // Use execute_batch to handle multi-statement SQL including triggers + tx.execute_batch(migration.up)?; + + tx.commit()?; } - // Use execute_batch to handle multi-statement SQL including triggers - conn.execute_batch(migration.up)?; - - // V7: Upgrade page_size to 8192 (10-30% faster large-row reads) - // VACUUM rewrites the DB with the new page size — can't run inside execute_batch + // V7: Upgrade page_size to 8192 (10-30% faster large-row reads). + // VACUUM rewrites the DB with the new page size — it cannot run + // inside a transaction, so it runs after the migration commits. + // Under WAL, changing page_size + VACUUM is silently ignored; SQLite + // requires a non-WAL journal mode to repage. Drop to DELETE, repage, + // then restore WAL so the performance upgrade actually takes effect. if migration.version == 7 { + conn.pragma_update(None, "journal_mode", "DELETE")?; conn.pragma_update(None, "page_size", 8192)?; conn.execute_batch("VACUUM;")?; + conn.pragma_update(None, "journal_mode", "WAL")?; tracing::info!("Database page_size upgraded to 8192 via VACUUM"); } @@ -1201,6 +1247,54 @@ pub fn apply_migrations(conn: &rusqlite::Connection) -> rusqlite::Result { mod tests { use super::*; + /// Regression: a migration that is interrupted after its `ADD COLUMN` + /// commits but before `schema_version` advances must NOT permanently brick + /// the DB on replay with `duplicate column name`. Because each migration now + /// runs in a transaction, an interrupted migration rolls back atomically and + /// replays cleanly. + /// + /// We simulate the pre-fix corrupt state directly: run all migrations, then + /// hand-apply one of V2's `ADD COLUMN`s again on a DB whose version we roll + /// back, and confirm `apply_migrations` still succeeds (the transaction + /// makes the whole migration atomic, so a real interruption can never leave + /// the half-applied state the old code could). + #[test] + fn test_interrupted_migration_replays_without_duplicate_column_brick() { + // A fresh DB migrates cleanly and reaches the latest version. + let conn = rusqlite::Connection::open_in_memory().expect("open in-memory"); + apply_migrations(&conn).expect("initial migrations succeed"); + let latest = MIGRATIONS.last().unwrap().version; + assert_eq!(get_current_version(&conn).expect("version"), latest); + + // Running apply_migrations again on an already-migrated DB is a no-op and + // must never error (idempotent) — the previous brick surfaced here. + let applied = apply_migrations(&conn).expect("replay must not brick"); + assert_eq!(applied, 0, "no migrations should re-apply on a current DB"); + + // Directly prove atomicity: an ADD COLUMN inside a rolled-back + // transaction leaves no trace, so a retried migration sees a clean slate. + let conn2 = rusqlite::Connection::open_in_memory().expect("open in-memory 2"); + conn2 + .execute_batch( + "CREATE TABLE t (id INTEGER); + CREATE TABLE schema_version (version INTEGER, applied_at TEXT); + INSERT INTO schema_version (version, applied_at) VALUES (0, datetime('now'));", + ) + .expect("seed"); + { + let tx = conn2.unchecked_transaction().expect("tx"); + tx.execute_batch("ALTER TABLE t ADD COLUMN c INTEGER;") + .expect("add column in tx"); + // Simulate mid-migration failure: drop the tx without committing. + drop(tx); + } + // The column must be gone (rolled back), so re-adding it succeeds — the + // exact operation that previously failed with "duplicate column name". + conn2 + .execute_batch("ALTER TABLE t ADD COLUMN c INTEGER;") + .expect("column must not survive a rolled-back transaction"); + } + /// A fresh in-memory DB must end up at schema_version = highest migration /// version after `apply_migrations` runs all migrations end-to-end, and /// neither of the dead tables V11 drops must exist afterwards. @@ -1565,3 +1659,4 @@ mod tests { assert_eq!(domain_scores, "{}"); } } + diff --git a/crates/vestige-core/src/storage/sqlite.rs b/crates/vestige-core/src/storage/sqlite.rs index 6148a5b..c48fcec 100644 --- a/crates/vestige-core/src/storage/sqlite.rs +++ b/crates/vestige-core/src/storage/sqlite.rs @@ -17,7 +17,8 @@ use std::sync::Mutex; use uuid::Uuid; use crate::fsrs::{ - DEFAULT_DECAY, FSRSScheduler, FSRSState, LearningState, Rating, retrievability_with_decay, + DEFAULT_DECAY, FSRSScheduler, FSRSState, LearningState, MAX_STABILITY, Rating, + retrievability_with_decay, }; use crate::fts::{sanitize_fts5_or_query, sanitize_fts5_query}; use crate::memory::{ @@ -723,7 +724,10 @@ impl SqliteMemoryStore { now.to_rfc3339(), now.to_rfc3339(), now.to_rfc3339(), - fsrs_state.stability * sentiment_boost, + // Clamp to MAX_STABILITY: the sentiment boost is otherwise + // persisted unbounded, letting an emotional memory's stability + // exceed the FSRS-6 ceiling every other write path respects. + (fsrs_state.stability * sentiment_boost).min(MAX_STABILITY), fsrs_state.difficulty, fsrs_state.reps, fsrs_state.lapses, @@ -1118,9 +1122,23 @@ impl SqliteMemoryStore { { let _ = index.remove(id); } - // Generate new embedding - if let Err(e) = self.generate_embedding_for_node(id, new_content) { - tracing::warn!("Failed to regenerate embedding for {}: {}", id, e); + // Generate new embedding. If the embedder isn't ready yet (e.g. the + // model is still downloading on first run), generate_embedding_for_node + // is a no-op — which previously left the OLD, now-stale embedding row + // with has_embedding = 1, so semantic search kept matching the old + // content and the consolidation regeneration query (which only selects + // has_embedding = 0 / missing rows / model mismatch) never refreshed + // it. Flip has_embedding to 0 on the not-ready path so the stale vector + // is picked up and rebuilt once the embedder comes online. + if self.embedding_service.is_ready() { + if let Err(e) = self.generate_embedding_for_node(id, new_content) { + tracing::warn!("Failed to regenerate embedding for {}: {}", id, e); + } + } else if let Ok(writer) = self.writer.lock() { + let _ = writer.execute( + "UPDATE knowledge_nodes SET has_embedding = 0 WHERE id = ?1", + params![id], + ); } } @@ -1656,6 +1674,42 @@ impl SqliteMemoryStore { .ok_or_else(|| StorageError::NotFound(id.to_string())) } + /// Backfill-specific promote: identical retrieval/retention boost to + /// `promote_memory`, but the stability multiply is CAPPED at an additive + /// +365-day ceiling: `MIN(stability * 1.5, stability + 365.0)`. The `1.5` + /// factor preserves the multiplier `promote_memory` already applied; the + /// `+365` ceiling is the same additive bound `retroactive_backfill.rs` + /// uses for its reason string (that module pairs +365 with a 2.5 factor + /// for display only — this DB write intentionally keeps 1.5 so backfill + /// promotion strength is unchanged, just bounded). Repeated per-(cause, + /// failure) backfill promotions therefore cannot inflate stability without + /// bound. Used by the step-8.5 auto-fire path and the manual `backfill` tool. + pub fn promote_memory_backfill(&self, id: &str) -> Result { + let now = Utc::now(); + + { + let writer = self + .writer + .lock() + .map_err(|_| StorageError::Init("Writer lock poisoned".into()))?; + writer.execute( + "UPDATE knowledge_nodes SET + last_accessed = ?1, + retrieval_strength = MIN(1.0, retrieval_strength + 0.20), + retention_strength = MIN(1.0, retention_strength + 0.10), + stability = MIN(stability * 1.5, stability + 365.0) + WHERE id = ?2", + params![now.to_rfc3339(), id], + )?; + } + + let _ = self.log_access(id, "promote"); + let _ = self.set_waking_tag(id); + + self.get_node(id)? + .ok_or_else(|| StorageError::NotFound(id.to_string())) + } + /// Demote a memory (thumbs down) - used when a memory led to a bad outcome /// Significantly reduces retrieval strength so better alternatives surface /// Does NOT delete - the memory stays for reference but ranks lower @@ -1764,6 +1818,15 @@ impl SqliteMemoryStore { .writer .lock() .map_err(|_| StorageError::Init("Writer lock poisoned".into()))?; + // True inverse of suppress_memory (which applies stability * 0.4, + // retrieval - 0.35, retention - 0.20). Dividing by 0.4 exactly undoes + // the * 0.4, and adding back the same 0.35 / 0.20 deltas (clamped to + // 1.0) undoes the subtraction. Previously this used non-inverse deltas + // (* 1.25, + 0.15, + 0.10), so suppress-then-reverse left stability + // permanently halved (0.4 * 1.25 = 0.5) while reporting a full undo. + // Note: where the forward pass hit the MAX(0.05) floor, the exact + // pre-value is unrecoverable without a snapshot — that clip aside, + // this restores the pre-suppression FSRS state. writer.execute( "UPDATE knowledge_nodes SET suppression_count = MAX(0, COALESCE(suppression_count, 0) - 1), @@ -1771,9 +1834,9 @@ impl SqliteMemoryStore { WHEN COALESCE(suppression_count, 0) - 1 <= 0 THEN NULL ELSE suppressed_at END, - retrieval_strength = MIN(1.0, retrieval_strength + 0.15), - retention_strength = MIN(1.0, retention_strength + 0.10), - stability = stability * 1.25 + retrieval_strength = MIN(1.0, retrieval_strength + 0.35), + retention_strength = MIN(1.0, retention_strength + 0.20), + stability = stability / 0.4 WHERE id = ?1", params![id], )?; @@ -2943,18 +3006,18 @@ impl SqliteMemoryStore { (false, false) => MatchType::Keyword, }; - let weighted_score = match (keyword_score, semantic_score) { - (Some(kw), Some(sem)) => kw * keyword_weight + sem * semantic_weight, - (Some(kw), None) => kw * keyword_weight, - (None, Some(sem)) => sem * semantic_weight, - (None, None) => combined_score, - }; - + // Carry the RRF fused score as the relevance signal, NOT a linear + // kw*w + sem*w recomputation. RRF is what selected these candidates + // and rewards both-list agreement; overwriting it with the linear + // weighted_score made the final ranking diverge from RRF order + // (a both-list paraphrase could rank below a keyword-only hit). + // The min-max normalization in the rerank below then operates on + // RRF scores, so final relevance ordering matches RRF ordering. results.push(SearchResult { node, keyword_score, semantic_score, - combined_score: weighted_score, + combined_score, match_type, }); } @@ -2962,6 +3025,20 @@ impl SqliteMemoryStore { // Three-signal reranking (Park et al. Generative Agents 2023) // final_score = 0.2*recency + 0.3*importance + 0.5*relevance + // + // relevance MUST live in [0,1] for the weights to balance. The raw + // weighted_score does not: keyword-only results max out at + // `1.0 * keyword_weight` (0.3 by default), so the strongest match's + // relevance term was capped at 0.5*0.3 = 0.15 and lost to recency (up to + // 0.2) or importance (up to 0.3) — a fresh, weakly-relevant node could + // outrank the best match. Min-max normalize relevance across the result + // set so the best match scores ~1.0 regardless of the weight scaling. + let (min_rel, max_rel) = results.iter().fold( + (f32::INFINITY, f32::NEG_INFINITY), + |(mn, mx), r| (mn.min(r.combined_score), mx.max(r.combined_score)), + ); + let rel_span = (max_rel - min_rel) as f64; + let now = Utc::now(); for result in &mut results { let hours_since = (now - result.node.last_accessed).num_seconds() as f64 / 3600.0; @@ -2983,7 +3060,13 @@ impl SqliteMemoryStore { // Normalize ACT-R activation [-2, 5] → [0, 1] let importance = ((activation + 2.0) / 7.0).clamp(0.0, 1.0); - let relevance = result.combined_score as f64; + // Min-max normalized relevance in [0,1]. When every result ties + // (span 0), fall back to 1.0 so relevance still dominates ranking. + let relevance = if rel_span > f64::EPSILON { + (result.combined_score - min_rel) as f64 / rel_span + } else { + 1.0 + }; let final_score = 0.2 * recency + 0.3 * importance + 0.5 * relevance; result.combined_score = final_score as f32; @@ -3659,10 +3742,30 @@ impl SqliteMemoryStore { // consolidation pass IS the offline window. Bounded on every axis so a // noisy day cannot trigger a promotion storm, and idempotent across cycles // via a durable causal edge (so the same cause is promoted once per - // failure, not every cycle — promote_memory's stability boost is capped - // but would still inflate without this guard). + // failure, not every cycle). + // + // OPT-OUT (backfill-safety, v2.2.1): auto-fire is ON by default — it shipped + // and was documented in v2.2.0, so we keep the behavior — but is now bounded + // and disableable. It mutates FSRS scores on the canonical store and can lift + // a memory across a downstream consolidation floor, so a consumer that reads + // `stability` as a durability gate can turn it off with + // VESTIGE_BACKFILL_AUTOFIRE=0 (or false/off/no). The `backfill` MCP tool + CLI + // remain available for on-demand, operator-driven backfill regardless of the + // gate. The promote is bounded: both the auto-fire and manual paths call + // promote_memory_backfill (stability = MIN(stability*1.5, stability+365)) so + // repeated per-(cause, failure) promotions cannot inflate without bound (the + // prior comment claimed promote_memory was capped — it was not). + let backfill_autofire = std::env::var("VESTIGE_BACKFILL_AUTOFIRE") + .map(|v| { + let v = v.trim(); + !(v.eq_ignore_ascii_case("false") + || v.eq_ignore_ascii_case("off") + || v.eq_ignore_ascii_case("no") + || v == "0") + }) + .unwrap_or(true); let mut backfilled_causes = 0i64; - { + if backfill_autofire { use crate::advanced::retroactive_backfill::{ self as rb, BackfillCandidate, FailureEvent, RetroactiveBackfill, }; @@ -3755,7 +3858,7 @@ impl SqliteMemoryStore { if self.save_connection(&conn).is_err() { continue; } - if self.promote_memory(&cause.memory_id).is_ok() { + if self.promote_memory_backfill(&cause.memory_id).is_ok() { backfilled_causes += 1; } } @@ -3950,10 +4053,35 @@ impl SqliteMemoryStore { /// Auto-deduplicate similar memories during consolidation (episodic → semantic merge) /// - /// Finds clusters with cosine similarity > 0.85, keeps the strongest node, + /// Finds clusters with cosine similarity >= 0.85, keeps the strongest node, /// appends unique content from weaker nodes, and deletes duplicates. + /// Honors the `VESTIGE_AUTO_CONSOLIDATE_MERGE` opt-out (unset → on) and + /// never merges away or deletes protected (pinned) nodes (#142). #[cfg(all(feature = "embeddings", feature = "vector-search"))] fn auto_dedup_consolidation(&self) -> Result { + // OPT-OUT (auto-consolidate-merge, #142): this pass concat-merges + // near-duplicate memories and HARD-DELETES the weaker ones with no + // reflog. It is ON by default (behavior unchanged), but a consumer that + // does not want unattended, no-audit merges can turn it off with + // VESTIGE_AUTO_CONSOLIDATE_MERGE=0 (or false/off/no). Parsed exactly like + // the sibling VESTIGE_BACKFILL_AUTOFIRE: unset or any other/malformed + // value → on (fail-open to the documented default). The `dedup` MCP tool + // remains available for on-demand, previewable, reversible merges + // regardless of the gate. Gate here (not the caller) so it stays with the + // pin filter and self-protects against a future second caller. + let auto_merge = std::env::var("VESTIGE_AUTO_CONSOLIDATE_MERGE") + .map(|v| { + let v = v.trim(); + !(v.eq_ignore_ascii_case("false") + || v.eq_ignore_ascii_case("off") + || v.eq_ignore_ascii_case("no") + || v == "0") + }) + .unwrap_or(true); + if !auto_merge { + return Ok(0); + } + let all_embeddings = self.get_all_embeddings()?; let n = all_embeddings.len(); @@ -3961,19 +4089,35 @@ impl SqliteMemoryStore { return Ok(0); } + // Protected (pinned) memories must never be touched by this unattended, + // no-audit pass — mirroring the interactive contract that a protected + // node may only survive a merge, never be absorbed (see `plan_merge`). + // Fetch the set ONCE here, before the per-cluster reader lock is taken: + // both `protected_node_ids()` and `is_protected()` take their OWN reader + // lock, so calling either inside the lock window below would self-deadlock + // the non-reentrant Mutex. Skipping protected ids at BOTH the outer + // (anchor) and inner (member) loops guarantees a protected node is never + // an anchor and never a cluster member — so it can never be the keeper nor + // land in weak_ids, and is thus never merged into and never deleted. Fails + // SAFE via `?`: on a poisoned lock the caller's unwrap_or(0) skips the + // merge this cycle rather than risk absorbing a pin. #142 + let protected = self.protected_node_ids()?; + const SIMILARITY_THRESHOLD: f32 = 0.85; let mut merged_count = 0i64; let mut consumed: std::collections::HashSet = std::collections::HashSet::new(); for i in 0..n { - if consumed.contains(&all_embeddings[i].0) { + if consumed.contains(&all_embeddings[i].0) || protected.contains(&all_embeddings[i].0) { continue; } let mut cluster: Vec<(usize, f32)> = Vec::new(); for j in (i + 1)..n { - if consumed.contains(&all_embeddings[j].0) { + if consumed.contains(&all_embeddings[j].0) + || protected.contains(&all_embeddings[j].0) + { continue; } let sim = crate::embeddings::cosine_similarity( @@ -5780,6 +5924,25 @@ impl SqliteMemoryStore { Ok(result) } + /// The most recently created connections, capped at `limit`. Used by polling + /// surfaces (e.g. the dashboard changelog) that only need recent activity and + /// must not load the entire `memory_connections` table on every request. + pub fn get_recent_connections(&self, limit: usize) -> Result> { + let reader = self + .reader + .lock() + .map_err(|_| StorageError::Init("Reader lock poisoned".into()))?; + let mut stmt = reader.prepare( + "SELECT * FROM memory_connections ORDER BY created_at DESC LIMIT ?1", + )?; + let rows = stmt.query_map([limit as i64], Self::row_to_connection)?; + let mut result = Vec::new(); + for row in rows { + result.push(row?); + } + Ok(result) + } + /// Strengthen a connection pub fn strengthen_connection( &self, @@ -8117,6 +8280,16 @@ impl SqliteMemoryStore { .unwrap_or_else(|| member_ids[0].clone()) } }; + // The survivor MUST be one of the members. A caller-supplied survivor_id + // that isn't in member_ids (a typo/mixup through the plan_merge tool) + // otherwise sails through and panics at the `.find(...).unwrap()` below, + // taking down the request. Reject it with a clear error instead. + if !nodes.iter().any(|n| n.id == survivor) { + return Err(StorageError::Init(format!( + "survivor_id {survivor} is not among the member_ids being merged" + ))); + } + for node in &nodes { if node.id != survivor && self.is_protected(&node.id)? { return Err(StorageError::Init(format!( @@ -9807,6 +9980,13 @@ impl SqliteMemoryStore { let source_system = env.source_system.clone().unwrap_or_default(); let source_id = env.source_id.clone().unwrap_or_default(); + // Scope the idempotency key by source_project too: two sources of the + // same system (e.g. github repos octocat/repoA and octocat/repoB, or two + // Redmine instances) reuse bare per-project ids ("5"), so keying on + // (source_system, source_id) alone made repoB's issue #5 overwrite + // repoA's row in place. `IS NOT DISTINCT FROM` matches NULL==NULL so + // legacy rows without a project still resolve. + let source_project = env.source_project.clone(); let now = Utc::now(); // Look up the existing memory for this external record, if any. @@ -9818,8 +9998,9 @@ impl SqliteMemoryStore { reader .query_row( "SELECT id, content_hash FROM knowledge_nodes \ - WHERE source_system = ?1 AND source_id = ?2 LIMIT 1", - params![source_system, source_id], + WHERE source_system = ?1 AND source_id = ?2 \ + AND source_project IS ?3 LIMIT 1", + params![source_system, source_id, source_project], |row| Ok((row.get::<_, String>(0)?, row.get::<_, Option>(1)?)), ) .optional()? @@ -12857,6 +13038,376 @@ mod tests { assert!(cands.iter().all(|c| c.has_protected_member)); } + // ======================================================================== + // Auto-consolidation merge: opt-out gate + protected-pin exclusion (#142) + // + // These exercise `auto_dedup_consolidation` directly — the unattended, + // no-audit pass the 6h background consolidation cycle runs. seed_node/ + // axis_vector give deterministic same-axis clusters (cosine ~1.0 >> the 0.85 + // threshold); set_retention pins down which node wins the keeper tiebreak. + // ======================================================================== + + /// Force a node's retention_strength so the keeper tiebreak in + /// `auto_dedup_consolidation` is deterministic regardless of insertion order. + #[cfg(all(feature = "embeddings", feature = "vector-search"))] + fn set_retention(storage: &Storage, id: &str, value: f64) { + let writer = storage.writer.lock().unwrap(); + writer + .execute( + "UPDATE knowledge_nodes SET retention_strength = ?1 WHERE id = ?2", + rusqlite::params![value, id], + ) + .unwrap(); + } + + /// Run `f` with VESTIGE_AUTO_CONSOLIDATE_MERGE pinned to `value` + /// (None = pinned-unset, i.e. the documented ON default), serialized via + /// ENV_LOCK and restored afterward (process env is global + unsafe under + /// Rust 2024). Sibling of `with_vector_search_disabled`. + #[cfg(all(feature = "embeddings", feature = "vector-search"))] + fn with_auto_merge_env(value: Option<&str>, f: impl FnOnce() -> T) -> T { + const KEY: &str = "VESTIGE_AUTO_CONSOLIDATE_MERGE"; + let _guard = ENV_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let previous = std::env::var_os(KEY); + unsafe { + match value { + Some(v) => std::env::set_var(KEY, v), + None => std::env::remove_var(KEY), + } + } + let result = catch_unwind(AssertUnwindSafe(f)); + unsafe { + if let Some(prev) = previous { + std::env::set_var(KEY, prev); + } else { + std::env::remove_var(KEY); + } + } + match result { + Ok(value) => value, + Err(payload) => resume_unwind(payload), + } + } + + // --- A. Default (flag unset): near-duplicates still merge (regression) --- + #[cfg(all(feature = "embeddings", feature = "vector-search"))] + #[test] + fn test_auto_dedup_default_on_merges_near_duplicates() { + with_auto_merge_env(None, || { + let storage = create_test_storage(); + let keeper = seed_node( + &storage, + "Rate limiting uses a token bucket per client API key", + &["api"], + axis_vector(21, 0.02), + ); + let dup = seed_node( + &storage, + "Rate limiting uses a token-bucket algorithm per client API key, refilled steadily", + &["api"], + axis_vector(21, 0.01), + ); + // Make `keeper` win the retention tiebreak deterministically. + set_retention(&storage, &keeper, 0.9); + set_retention(&storage, &dup, 0.3); + + let merged = storage.auto_dedup_consolidation().unwrap(); + assert_eq!(merged, 1, "one weak node folded into the keeper"); + assert!( + storage.get_node(&dup).unwrap().is_none(), + "weak duplicate is hard-deleted" + ); + let survivor = storage.get_node(&keeper).unwrap().unwrap(); + assert!( + survivor.content.contains("[MERGED]"), + "keeper carries the folded-in [MERGED] block" + ); + }); + } + + // --- B. Flag off suppresses the merge (parametrized) --------------------- + #[cfg(all(feature = "embeddings", feature = "vector-search"))] + #[test] + fn test_auto_dedup_env_off_suppresses_merge() { + // trimmed + case-insensitive false/off/no/0 all disable. + for value in ["false", "off", "no", "0", " OFF ", "False"] { + with_auto_merge_env(Some(value), || { + let storage = create_test_storage(); + let a = seed_node( + &storage, + "Prometheus scrapes its targets every 15 seconds", + &["obs"], + axis_vector(23, 0.02), + ); + let b = seed_node( + &storage, + "Prometheus scrapes its configured targets every 15s by default", + &["obs"], + axis_vector(23, 0.01), + ); + + let merged = storage.auto_dedup_consolidation().unwrap(); + assert_eq!(merged, 0, "value {value:?} must suppress the merge"); + // Both nodes survive, content byte-identical (no [MERGED] block). + assert_eq!( + storage.get_node(&a).unwrap().unwrap().content, + "Prometheus scrapes its targets every 15 seconds" + ); + assert_eq!( + storage.get_node(&b).unwrap().unwrap().content, + "Prometheus scrapes its configured targets every 15s by default" + ); + }); + } + } + + // --- B (cont). A malformed value fails OPEN to the ON default ------------ + #[cfg(all(feature = "embeddings", feature = "vector-search"))] + #[test] + fn test_auto_dedup_env_garbage_fails_open_and_merges() { + with_auto_merge_env(Some("banana"), || { + let storage = create_test_storage(); + let keeper = seed_node( + &storage, + "Cache entries expire after a five minute TTL", + &["cache"], + axis_vector(25, 0.02), + ); + let dup = seed_node( + &storage, + "Cache entries expire after a five-minute TTL window by default", + &["cache"], + axis_vector(25, 0.01), + ); + set_retention(&storage, &keeper, 0.9); + set_retention(&storage, &dup, 0.3); + + let merged = storage.auto_dedup_consolidation().unwrap(); + assert_eq!(merged, 1, "malformed value fails open to the ON default"); + assert!(storage.get_node(&dup).unwrap().is_none()); + }); + } + + // --- C(a). Protected would-be keeper: untouched; others merge ----------- + #[cfg(all(feature = "embeddings", feature = "vector-search"))] + #[test] + fn test_auto_dedup_protected_would_be_keeper_untouched_others_merge() { + with_auto_merge_env(None, || { + let storage = create_test_storage(); + // P has the highest retention, so absent protection it would be the + // keeper. Protected → skipped entirely; the two unprotected merge alone. + let pinned = seed_node( + &storage, + "Deploys are gated on a green CI run and one approval", + &["ci"], + axis_vector(27, 0.02), + ); + let keeper = seed_node( + &storage, + "Deploys are gated on a green CI pipeline plus one reviewer approval", + &["ci"], + axis_vector(27, 0.01), + ); + let member = seed_node( + &storage, + "Deploys require a green CI run and at least one approving review", + &["ci"], + axis_vector(27, 0.015), + ); + set_retention(&storage, &pinned, 0.95); + set_retention(&storage, &keeper, 0.80); + set_retention(&storage, &member, 0.30); + storage.set_protected(&pinned, true).unwrap(); + let pinned_content = storage.get_node(&pinned).unwrap().unwrap().content; + + let merged = storage.auto_dedup_consolidation().unwrap(); + assert_eq!( + merged, + 1, + "the two unprotected near-dups merge among themselves" + ); + + // Protected node byte-for-byte untouched and still protected. + let p = storage.get_node(&pinned).unwrap().unwrap(); + assert_eq!(p.content, pinned_content, "protected keeper not absorbed"); + assert!(!p.content.contains("[MERGED]")); + assert!(storage.is_protected(&pinned).unwrap()); + // Unprotected pair merged: `member` gone, `keeper` carries [MERGED]. + assert!(storage.get_node(&member).unwrap().is_none()); + let keeper_node = storage.get_node(&keeper).unwrap().unwrap(); + assert!(keeper_node.content.contains("[MERGED]")); + }); + } + + // --- C(b) / Regression (#142): protected weak member is never absorbed -- + #[cfg(all(feature = "embeddings", feature = "vector-search"))] + #[test] + fn auto_dedup_regression_142_protected_weak_member_not_absorbed() { + with_auto_merge_env(None, || { + let storage = create_test_storage(); + // Regression (#142): before the fix this pinned node — the weaker + // member of the cluster — was silently absorbed into the stronger + // unprotected keeper and hard-deleted by the unattended pass. The + // PINNED-CANARY-142 marker makes accidental absorption detectable. + let pinned = seed_node( + &storage, + "Feature flags default to off in production PINNED-CANARY-142", + &["flags"], + axis_vector(29, 0.02), + ); + let keeper = seed_node( + &storage, + "Feature flags default to off in the production environment", + &["flags"], + axis_vector(29, 0.01), + ); + let member = seed_node( + &storage, + "Feature flags are off by default in production deployments", + &["flags"], + axis_vector(29, 0.015), + ); + // Pinned is the LOWEST-retention member — pre-fix it would land in + // weak_ids and be deleted + absorbed by the keeper. + set_retention(&storage, &pinned, 0.10); + set_retention(&storage, &keeper, 0.80); + set_retention(&storage, &member, 0.30); + storage.set_protected(&pinned, true).unwrap(); + let pinned_content = storage.get_node(&pinned).unwrap().unwrap().content; + + let merged = storage.auto_dedup_consolidation().unwrap(); + assert_eq!(merged, 1, "only the two unprotected near-dups merge"); + + // Invariant 1: the protected node still exists, byte-identical. + let p = storage.get_node(&pinned).unwrap(); + assert!(p.is_some(), "protected node must not be deleted"); + assert_eq!( + p.unwrap().content, + pinned_content, + "protected node not absorbed" + ); + assert!(storage.is_protected(&pinned).unwrap()); + + // Invariant 2: the keeper did NOT gain the protected node's content. + let keeper_node = storage.get_node(&keeper).unwrap().unwrap(); + assert!( + !keeper_node.content.contains("PINNED-CANARY-142"), + "keeper must not absorb the protected node's content" + ); + // The legitimate unprotected pair still merged (member folded in). + assert!(storage.get_node(&member).unwrap().is_none()); + assert!(keeper_node.content.contains("[MERGED]")); + }); + } + + // --- C(c). Two protected near-dups: neither merges ---------------------- + #[cfg(all(feature = "embeddings", feature = "vector-search"))] + #[test] + fn test_auto_dedup_two_protected_near_dups_neither_merges() { + with_auto_merge_env(None, || { + let storage = create_test_storage(); + let a = seed_node( + &storage, + "Backups run nightly and are retained for thirty days", + &["backup"], + axis_vector(31, 0.02), + ); + let b = seed_node( + &storage, + "Backups run every night and are kept for thirty days", + &["backup"], + axis_vector(31, 0.01), + ); + storage.set_protected(&a, true).unwrap(); + storage.set_protected(&b, true).unwrap(); + let (ca, cb) = ( + storage.get_node(&a).unwrap().unwrap().content, + storage.get_node(&b).unwrap().unwrap().content, + ); + + let merged = storage.auto_dedup_consolidation().unwrap(); + assert_eq!(merged, 0, "two protected near-dups: nothing merges"); + assert_eq!(storage.get_node(&a).unwrap().unwrap().content, ca); + assert_eq!(storage.get_node(&b).unwrap().unwrap().content, cb); + }); + } + + // --- C(d). Protected + a single unprotected near-dup: no merge ---------- + #[cfg(all(feature = "embeddings", feature = "vector-search"))] + #[test] + fn test_auto_dedup_protected_plus_single_unprotected_no_merge() { + with_auto_merge_env(None, || { + let storage = create_test_storage(); + let pinned = seed_node( + &storage, + "Secrets are stored in the vault, never in the repo", + &["sec"], + axis_vector(33, 0.02), + ); + let other = seed_node( + &storage, + "Secrets live in the vault and are never committed to the repo", + &["sec"], + axis_vector(33, 0.01), + ); + storage.set_protected(&pinned, true).unwrap(); + let (cp, co) = ( + storage.get_node(&pinned).unwrap().unwrap().content, + storage.get_node(&other).unwrap().unwrap().content, + ); + + let merged = storage.auto_dedup_consolidation().unwrap(); + assert_eq!(merged, 0, "a lone unprotected node cannot form a cluster"); + assert_eq!(storage.get_node(&pinned).unwrap().unwrap().content, cp); + assert_eq!(storage.get_node(&other).unwrap().unwrap().content, co); + }); + } + + // --- D. Liveness: protected + two unprotected → the two merge ----------- + #[cfg(all(feature = "embeddings", feature = "vector-search"))] + #[test] + fn test_auto_dedup_protected_plus_two_unprotected_liveness() { + with_auto_merge_env(None, || { + let storage = create_test_storage(); + // The pin exclusion must not block a legitimate merge of the others. + let pinned = seed_node( + &storage, + "The API returns ISO-8601 timestamps in UTC", + &["api"], + axis_vector(35, 0.02), + ); + let keeper = seed_node( + &storage, + "The API returns ISO 8601 timestamps in UTC by convention", + &["api"], + axis_vector(35, 0.01), + ); + let member = seed_node( + &storage, + "All API timestamps are returned as ISO-8601 in the UTC timezone", + &["api"], + axis_vector(35, 0.015), + ); + set_retention(&storage, &pinned, 0.50); + set_retention(&storage, &keeper, 0.80); + set_retention(&storage, &member, 0.30); + storage.set_protected(&pinned, true).unwrap(); + let pinned_content = storage.get_node(&pinned).unwrap().unwrap().content; + + let merged = storage.auto_dedup_consolidation().unwrap(); + assert_eq!(merged, 1, "the two unprotected near-dups still merge"); + assert!(storage.get_node(&member).unwrap().is_none()); + let keeper_node = storage.get_node(&keeper).unwrap().unwrap(); + assert!(keeper_node.content.contains("[MERGED]")); + // Protected node untouched. + assert_eq!( + storage.get_node(&pinned).unwrap().unwrap().content, + pinned_content + ); + assert!(storage.is_protected(&pinned).unwrap()); + }); + } + #[cfg(all(feature = "embeddings", feature = "vector-search"))] #[test] fn test_apply_requires_confirm_for_low_confidence() { @@ -13230,4 +13781,141 @@ mod tests { ); }); } + + // Seed a node's stability directly via the scheduling seam so the +365 cap + // in promote_memory_backfill is actually exercised (a freshly ingested node + // has low stability where the *1.5 multiply, not the additive ceiling, wins). + fn seed_stability(s: &Storage, id: &str, stability: f64) { + use crate::storage::memory_store::{MemoryStoreSend, SchedulingState}; + rt().block_on(async { + let state = SchedulingState { + memory_id: uuid::Uuid::parse_str(id).unwrap(), + stability, + difficulty: 0.4, + retrievability: 0.8, + last_review: Some(chrono::Utc::now()), + next_review: Some(chrono::Utc::now() + chrono::Duration::days(7)), + reps: 3, + lapses: 0, + }; + MemoryStoreSend::update_scheduling(s, &state) + .await + .unwrap(); + }); + } + + #[test] + fn promote_memory_backfill_caps_stability_at_plus_365() { + // Above the crossover (stability=730) the additive +365 ceiling must win + // over the *1.5 multiply, so repeated backfill promotions cannot inflate + // stability without bound. This is the bound issue #103 asked us to apply. + let s = create_test_storage(); + let node = s + .ingest(IngestInput { + content: "high-stability cause memory".to_string(), + node_type: "fact".to_string(), + ..Default::default() + }) + .unwrap(); + seed_stability(&s, &node.id, 1000.0); + + let promoted = s.promote_memory_backfill(&node.id).unwrap(); + // 1000 * 1.5 = 1500 (uncapped) vs 1000 + 365 = 1365 (capped). Cap wins. + assert!( + (promoted.stability - 1365.0).abs() < 1e-6, + "expected additive +365 cap (1365.0), got {} (uncapped would be 1500.0)", + promoted.stability + ); + } + + #[test] + fn promote_memory_backfill_uses_multiply_below_crossover() { + // Below the crossover the *1.5 multiply wins (the cap never binds), so + // backfill promotion strength is unchanged from the old promote_memory. + let s = create_test_storage(); + let node = s + .ingest(IngestInput { + content: "low-stability cause memory".to_string(), + node_type: "fact".to_string(), + ..Default::default() + }) + .unwrap(); + seed_stability(&s, &node.id, 10.0); + + let promoted = s.promote_memory_backfill(&node.id).unwrap(); + // 10 * 1.5 = 15 (multiply) vs 10 + 365 = 375 (cap). Multiply wins. + assert!( + (promoted.stability - 15.0).abs() < 1e-6, + "expected *1.5 multiply (15.0) below crossover, got {}", + promoted.stability + ); + } + + #[test] + fn suppress_then_reverse_restores_fsrs_state() { + // reverse_suppression must be a TRUE inverse of suppress_memory. Suppress + // applies stability*0.4, retrieval-0.35, retention-0.20; reverse now undoes + // exactly that (stability/0.4, retrieval+0.35, retention+0.20). Previously + // reverse used non-inverse deltas and left stability permanently halved. + let s = create_test_storage(); + let node = s + .ingest(IngestInput { + content: "a memory to suppress then un-suppress".to_string(), + node_type: "fact".to_string(), + ..Default::default() + }) + .unwrap(); + // Seed above the 0.05 floor so the forward pass never clips (making the + // round-trip exactly recoverable). + seed_stability(&s, &node.id, 20.0); + let before = s.get_node(&node.id).unwrap().unwrap(); + + s.suppress_memory(&node.id).unwrap(); + let suppressed = s.get_node(&node.id).unwrap().unwrap(); + assert!( + (suppressed.stability - before.stability * 0.4).abs() < 1e-6, + "suppress must multiply stability by 0.4" + ); + + let reversed = s.reverse_suppression(&node.id, 24).unwrap(); + // stability: 20 * 0.4 / 0.4 = 20 (fully restored, not 0.5x) + assert!( + (reversed.stability - before.stability).abs() < 1e-6, + "reverse must restore stability to {} (got {})", + before.stability, + reversed.stability + ); + assert!( + (reversed.retrieval_strength - before.retrieval_strength).abs() < 1e-6, + "reverse must restore retrieval_strength" + ); + assert!( + (reversed.retention_strength - before.retention_strength).abs() < 1e-6, + "reverse must restore retention_strength" + ); + } + + #[test] + fn backfill_autofire_gate_defaults_on_and_reads_opt_out() { + // v2.2.1 opt-out semantics: unset => ON (preserves shipped v2.2.0 + // behavior); explicit 0/false/off/no => OFF; anything else => ON. + fn parse(v: Option<&str>) -> bool { + v.map(|v| { + let v = v.trim(); + !(v.eq_ignore_ascii_case("false") + || v.eq_ignore_ascii_case("off") + || v.eq_ignore_ascii_case("no") + || v == "0") + }) + .unwrap_or(true) + } + assert!(parse(None), "unset must default ON"); + assert!(parse(Some("1")), "1 is ON"); + assert!(parse(Some("true")), "true is ON"); + assert!(parse(Some("anything")), "unrecognized is ON"); + assert!(!parse(Some("0")), "0 is OFF"); + assert!(!parse(Some("false")), "false is OFF"); + assert!(!parse(Some("OFF")), "OFF (case-insensitive) is OFF"); + assert!(!parse(Some(" no ")), "whitespace-padded no is OFF (trim)"); + } } diff --git a/crates/vestige-core/src/storage/trace_store.rs b/crates/vestige-core/src/storage/trace_store.rs index ee39751..fcac379 100644 --- a/crates/vestige-core/src/storage/trace_store.rs +++ b/crates/vestige-core/src/storage/trace_store.rs @@ -77,13 +77,15 @@ impl SqliteMemoryStore { .lock() .map_err(|_| StorageError::Init("Writer lock poisoned".into()))?; - let seq: i64 = writer - .query_row( - "SELECT COALESCE(MAX(seq), -1) + 1 FROM agent_traces WHERE run_id = ?1", - params![run_id], - |r| r.get(0), - ) - .unwrap_or(0); + // Propagate a seq-query failure instead of defaulting to 0: swallowing + // the error with unwrap_or(0) could write a duplicate seq=0 for a run + // that already has events, corrupting Black Box replay ordering. On an + // empty run COALESCE(...,-1)+1 already yields 0 correctly. + let seq: i64 = writer.query_row( + "SELECT COALESCE(MAX(seq), -1) + 1 FROM agent_traces WHERE run_id = ?1", + params![run_id], + |r| r.get(0), + )?; writer.execute( "INSERT INTO agent_traces (id, run_id, seq, event_type, tool, payload, at, created_at) @@ -435,12 +437,25 @@ impl SqliteMemoryStore { .writer .lock() .map_err(|_| StorageError::Init("Writer lock poisoned".into()))?; + // Only a still-pending PR may be decided. The `AND status = 'pending'` + // guard makes decisions final: re-POSTing an action on an already + // promoted/forgotten/merged PR cannot flip its status, re-run its + // side effects (e.g. release_quarantine resurrecting a rejected + // memory), or overwrite the audit ledger (decision/decided_at). let changed = writer.execute( - "UPDATE memory_prs SET status = ?1, decision = ?2, decided_at = ?3 WHERE id = ?4", + "UPDATE memory_prs SET status = ?1, decision = ?2, decided_at = ?3 + WHERE id = ?4 AND status = 'pending'", params![new_status.as_str(), decision, now, id], )?; if changed == 0 { - return Err(StorageError::NotFound(id.to_string())); + // Distinguish "no such PR" from "already decided" so callers get + // a truthful error instead of a misleading NotFound. + return Err(match self.get_memory_pr(id)? { + Some(_) => StorageError::Init(format!( + "memory PR {id} is already decided and cannot be re-decided" + )), + None => StorageError::NotFound(id.to_string()), + }); } } self.get_memory_pr(id)? diff --git a/crates/vestige-mcp/Cargo.toml b/crates/vestige-mcp/Cargo.toml index d068921..e55b586 100644 --- a/crates/vestige-mcp/Cargo.toml +++ b/crates/vestige-mcp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vestige-mcp" -version = "2.2.0" +version = "2.2.1" edition = "2024" description = "Cognitive memory MCP server for AI agents - FSRS-6, spreading activation, synaptic tagging, 3D dashboard, and 130 years of memory research" authors = ["samvallad33"] @@ -60,7 +60,7 @@ path = "src/bin/cli.rs" # Only `bundled-sqlite` is always on. `embeddings` and `vector-search` are # toggled via vestige-mcp's own feature flags below so `--no-default-features` # actually works (previously hardcoded here, which silently defeated the flag). -vestige-core = { version = "2.2.0", path = "../vestige-core", default-features = false, features = ["bundled-sqlite"] } +vestige-core = { version = "2.2.1", path = "../vestige-core", default-features = false, features = ["bundled-sqlite"] } # ============================================================================ # MCP Server Dependencies diff --git a/crates/vestige-mcp/src/bin/cli.rs b/crates/vestige-mcp/src/bin/cli.rs index fb847f3..15df46e 100644 --- a/crates/vestige-mcp/src/bin/cli.rs +++ b/crates/vestige-mcp/src/bin/cli.rs @@ -2006,10 +2006,16 @@ fn run_backup(output: PathBuf) -> anyhow::Result<()> { let _ = storage.get_stats()?; } - // Also flush WAL directly via a separate connection for safety + // Also flush WAL directly via a separate connection for extra safety. This + // is a raw, UN-keyed connection, so on a SQLCipher-encrypted DB it cannot + // read the header and the checkpoint fails with "file is not a database". + // The keyed `storage` opened above already flushed the WAL on drop, so this + // is redundant belt-and-suspenders — make it best-effort instead of letting + // it abort the whole backup on encrypted databases. { - let conn = rusqlite::Connection::open(&db_path)?; - conn.execute_batch("PRAGMA wal_checkpoint(TRUNCATE);")?; + if let Ok(conn) = rusqlite::Connection::open(&db_path) { + let _ = conn.execute_batch("PRAGMA wal_checkpoint(TRUNCATE);"); + } } // Create parent directories if needed @@ -2592,7 +2598,16 @@ fn run_ingest( { let result = storage.smart_ingest(input)?; if let Some(days) = ago_days { - let when = chrono::Utc::now() - chrono::Duration::days(days); + // Duration::days panics on overflow for extreme inputs; try_days + // returns None instead. The subtraction itself can ALSO overflow the + // DateTime range, so use checked_sub_signed rather than `-` (which + // panics). Both the construction and the subtraction are guarded. + let delta = chrono::Duration::try_days(days).ok_or_else(|| { + anyhow::anyhow!("--ago-days value {days} is out of the supported range") + })?; + let when = chrono::Utc::now().checked_sub_signed(delta).ok_or_else(|| { + anyhow::anyhow!("--ago-days value {days} is out of the supported range") + })?; storage.set_created_at(&result.node.id, when)?; } println!("{}", "=== Vestige Ingest ===".cyan().bold()); @@ -2622,7 +2637,16 @@ fn run_ingest( { let node = storage.ingest(input)?; if let Some(days) = ago_days { - let when = chrono::Utc::now() - chrono::Duration::days(days); + // Duration::days panics on overflow for extreme inputs; try_days + // returns None instead. The subtraction itself can ALSO overflow the + // DateTime range, so use checked_sub_signed rather than `-` (which + // panics). Both the construction and the subtraction are guarded. + let delta = chrono::Duration::try_days(days).ok_or_else(|| { + anyhow::anyhow!("--ago-days value {days} is out of the supported range") + })?; + let when = chrono::Utc::now().checked_sub_signed(delta).ok_or_else(|| { + anyhow::anyhow!("--ago-days value {days} is out of the supported range") + })?; storage.set_created_at(&node.id, when)?; } println!("{}", "=== Vestige Ingest ===".cyan().bold()); diff --git a/crates/vestige-mcp/src/dashboard/handlers.rs b/crates/vestige-mcp/src/dashboard/handlers.rs index 1f48835..37260b5 100644 --- a/crates/vestige-mcp/src/dashboard/handlers.rs +++ b/crates/vestige-mcp/src/dashboard/handlers.rs @@ -58,6 +58,22 @@ pub async fn list_memories( true } }) + // Honor node_type/tag filters on the search path too. Previously + // these were applied only in the no-query branch, so a filtered + // search (?q=foo&node_type=decision&tag=x) silently returned + // non-matching rows. + .filter(|r| { + params + .node_type + .as_ref() + .is_none_or(|nt| &r.node.node_type == nt) + }) + .filter(|r| { + params + .tag + .as_ref() + .is_none_or(|tag| r.node.tags.iter().any(|t| t == tag)) + }) .map(|r| { serde_json::json!({ "id": r.node.id, @@ -1025,10 +1041,12 @@ pub async fn get_changelog( } // Connections are currently persisted as graph edges rather than as audit - // rows, so filter by created_at from the connection table. + // rows, so filter by created_at from the connection table. Fetch only the + // most recent `fetch_limit` connections (not the entire table) — this + // endpoint is polled once per wake and must stay cheap on a large graph. let connections = state .storage - .get_all_connections() + .get_recent_connections(fetch_limit as usize) .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; for conn in connections { if changelog_window_contains(conn.created_at, start.as_ref(), end.as_ref()) { diff --git a/crates/vestige-mcp/src/protocol/http.rs b/crates/vestige-mcp/src/protocol/http.rs index 8bb788c..ac5b325 100644 --- a/crates/vestige-mcp/src/protocol/http.rs +++ b/crates/vestige-mcp/src/protocol/http.rs @@ -174,10 +174,17 @@ fn validate_auth(headers: &HeaderMap, expected: &str) -> Result<(), (StatusCode, .and_then(|v| v.to_str().ok()) .ok_or((StatusCode::UNAUTHORIZED, "Missing Authorization header"))?; - let token = header.strip_prefix("Bearer ").ok_or(( - StatusCode::UNAUTHORIZED, - "Invalid Authorization scheme (expected Bearer)", - ))?; + // The auth-scheme token is case-insensitive per RFC 7235/6750, so match + // "Bearer" case-insensitively (accepting "bearer", "BEARER", ...) while + // preserving the token's original case. + let token = header + .split_once(' ') + .filter(|(scheme, _)| scheme.eq_ignore_ascii_case("Bearer")) + .map(|(_, token)| token.trim_start()) + .ok_or(( + StatusCode::UNAUTHORIZED, + "Invalid Authorization scheme (expected Bearer)", + ))?; // Constant-time comparison: prevents timing side-channel attacks. // We first check lengths match (length itself is not secret since UUIDs @@ -242,8 +249,12 @@ fn validate_accept(headers: &HeaderMap) -> Result<(), (StatusCode, &'static str) .split(',') .map(|part| part.trim().split(';').next().unwrap_or("").trim()) { - accepts_json |= mime == "application/json"; - accepts_sse |= mime == "text/event-stream"; + // `*/*` accepts anything; `application/*` / `text/*` accept a whole type. + // Honoring these lets generic HTTP clients (curl's default Accept: */*) + // reach /mcp instead of getting a hard 406. + accepts_json |= + mime == "application/json" || mime == "application/*" || mime == "*/*"; + accepts_sse |= mime == "text/event-stream" || mime == "text/*" || mime == "*/*"; } if accepts_json && accepts_sse { diff --git a/crates/vestige-mcp/src/server.rs b/crates/vestige-mcp/src/server.rs index 571e2c6..b47d561 100644 --- a/crates/vestige-mcp/src/server.rs +++ b/crates/vestige-mcp/src/server.rs @@ -464,12 +464,25 @@ impl McpServer { cog.consolidation_scheduler.record_activity(); } - // Save args for event emission (tool dispatch consumes request.arguments) - let saved_args = if self.event_tx.is_some() { - request.arguments.clone() - } else { - None - }; + // Capture the args for tracing/event emission BEFORE tool dispatch + // consumes request.arguments. The Black Box must populate even in pure + // stdio mode (no dashboard socket), so this is NOT gated on event_tx — + // only the WebSocket broadcast inside record()/emit is. + let saved_args = request.arguments.clone(); + + // Agent Black Box: record the opening mcp.call event for this tool + // invocation. run_id groups the events of one agent turn; it is derived + // from the args (an explicit runId, or a fresh id) so record_result below + // can attach the downstream memory events (retrieve/suppress/veto) to the + // same run. + let trace_run_id = crate::trace_recorder::run_id_for(&saved_args); + crate::trace_recorder::record_call( + &self.storage, + self.event_tx.as_ref(), + &trace_run_id, + &request.name, + &saved_args, + ); let result = match request.name.as_str() { // ================================================================ @@ -1129,6 +1142,17 @@ impl McpServer { // ================================================================ if let Ok(ref content) = result { self.emit_tool_event(&request.name, &saved_args, content); + // Agent Black Box: inspect the successful result and record the + // downstream memory events (retrieve/suppress/veto/dream) under the + // same run_id as the opening mcp.call, so /api/traces, /api/receipts + // and the trace:// resource are actually populated. + crate::trace_recorder::record_result( + &self.storage, + self.event_tx.as_ref(), + &trace_run_id, + &request.name, + content, + ); } let response = match result { @@ -2449,6 +2473,35 @@ mod tests { assert_eq!(response.error.unwrap().code, -32602); // InvalidParams } + #[tokio::test] + async fn test_tool_call_populates_agent_black_box_trace() { + // Regression (#117): the trace recorder was dead code — no production + // caller — so agent_traces/receipts/memory_prs never populated. A tool + // call must now record at least the opening mcp.call event under the + // supplied runId. + let (mut server, _dir) = test_server().await; + server + .handle_request(make_request("initialize", Some(init_params()))) + .await; + + let run_id = "test-run-blackbox"; + let request = make_request( + "tools/call", + Some(serde_json::json!({ + "name": "search", + "arguments": { "query": "anything", "runId": run_id } + })), + ); + let response = server.handle_request(request).await.unwrap(); + assert!(response.error.is_none(), "tool call should succeed"); + + let events = server.storage.get_trace(run_id).expect("read trace"); + assert!( + !events.is_empty(), + "the Black Box must record at least the mcp.call event for this run" + ); + } + #[tokio::test] async fn test_tools_call_invalid_params_returns_error() { let (mut server, _dir) = test_server().await; diff --git a/crates/vestige-mcp/src/tools/backfill.rs b/crates/vestige-mcp/src/tools/backfill.rs index d7c6e69..c6850ff 100644 --- a/crates/vestige-mcp/src/tools/backfill.rs +++ b/crates/vestige-mcp/src/tools/backfill.rs @@ -188,8 +188,10 @@ pub async fn execute(storage: &Arc, args: Option) -> Result, args: Option) -> Result + // process abort under panic=abort) and a huge value overflows `limit * 2`. + let limit = args["limit"].as_i64().unwrap_or(10).clamp(1, 200) as i32; let now = Utc::now(); // Get candidate memories let recall_input = RecallInput { query: query.to_string(), - limit: limit * 2, // Get more, then filter + limit: limit.saturating_mul(2), // Get more, then filter min_retention: 0.0, search_mode: SearchMode::Hybrid, valid_at: None, @@ -105,7 +108,11 @@ pub async fn execute(storage: &Arc, args: Option) -> Result predicted). Without this call the speculative + // retriever's co-access prediction channel stays permanently empty. + if filtered_results.len() >= 2 { + let accessed: Vec = + filtered_results.iter().map(|r| r.node.id.clone()).collect(); + cog.speculative_retriever.record_usage(&[], &accessed); + } } // ==================================================================== diff --git a/crates/vestige-mcp/src/tools/smart_ingest.rs b/crates/vestige-mcp/src/tools/smart_ingest.rs index 60828fc..77c1afe 100644 --- a/crates/vestige-mcp/src/tools/smart_ingest.rs +++ b/crates/vestige-mcp/src/tools/smart_ingest.rs @@ -152,9 +152,11 @@ pub async fn execute( } }; let global_force = match args.force_create { - Some(true) => true, - Some(false) if batch_merge_policy == "smart" => false, - Some(false) => default_force_create, + // An EXPLICIT forceCreate is authoritative and must be honored in both + // policies. Previously `Some(false)` under the default 'force_create' + // policy fell through to `default_force_create` (= true), silently + // inverting the caller's explicit false into a force-create. + Some(explicit) => explicit, None => default_force_create, }; return execute_batch(storage, cognitive, items, global_force, &batch_merge_policy).await; @@ -857,12 +859,13 @@ mod tests { #[tokio::test] async fn test_batch_defaults_to_force_create_for_caller_separated_items() { + // Default policy (no explicit forceCreate) force-creates each + // caller-separated item so they stay separate. let (storage, _dir) = test_storage().await; let result = execute( &storage, &test_cognitive(), Some(serde_json::json!({ - "forceCreate": false, "items": [ { "content": "Jira tickets should not auto-assign sprint fields." }, { "content": "Sprint planning summaries should not append Jira status labels." } @@ -881,6 +884,36 @@ mod tests { } } + #[tokio::test] + async fn test_batch_explicit_force_create_false_is_honored() { + // Regression (#130): an EXPLICIT forceCreate:false must NOT be silently + // inverted to force-create by the default policy. Distinct/novel items are + // still created (PE gating creates novel content), but NOT via the + // "Forced creation" path. + let (storage, _dir) = test_storage().await; + let result = execute( + &storage, + &test_cognitive(), + Some(serde_json::json!({ + "forceCreate": false, + "items": [ + { "content": "Jira tickets should not auto-assign sprint fields." }, + { "content": "Sprint planning summaries should not append Jira status labels." } + ] + })), + ) + .await; + + let value = result.unwrap(); + assert_eq!(value["summary"]["created"], 2, "novel items still created"); + for item in value["results"].as_array().unwrap() { + assert!( + !item["reason"].as_str().unwrap().contains("Forced creation"), + "explicit forceCreate:false must not force-create" + ); + } + } + #[tokio::test] async fn test_batch_rejects_invalid_merge_policy() { let (storage, _dir) = test_storage().await; diff --git a/crates/vestige-mcp/src/tools/source_sync.rs b/crates/vestige-mcp/src/tools/source_sync.rs index a6c0232..ec9f284 100644 --- a/crates/vestige-mcp/src/tools/source_sync.rs +++ b/crates/vestige-mcp/src/tools/source_sync.rs @@ -111,7 +111,10 @@ pub async fn execute(storage: &Arc, args: Option) -> Result return Err("Missing arguments".to_string()), }; - let max_pages = args.max_pages.unwrap_or(10); + // Clamp to the schema's advertised maximum (1000). The JSON-schema `maximum` + // is advisory only — a client can still send a larger value — so enforce it + // here to bound the paginated fetch loop. + let max_pages = args.max_pages.unwrap_or(10).clamp(1, 1000); match args.source.as_str() { "github" => { diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index 450cb71..382eff4 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -45,6 +45,8 @@ Qwen3 currently uses Hugging Face Hub's Candle loader directly, so use the stand | `VESTIGE_AUTH_TOKEN` | auto-generated | Dashboard + MCP HTTP bearer auth | | `VESTIGE_DASHBOARD_ENABLED` | `false` | Set `true` or `1` to enable the web dashboard | | `VESTIGE_CONSOLIDATION_INTERVAL_HOURS` | `6` | FSRS-6 decay cycle cadence | +| `VESTIGE_BACKFILL_AUTOFIRE` | `on` | Retroactive Salience Backfill auto-fire during consolidation. On by default; set `0`/`false`/`off`/`no` to disable. The manual `backfill` tool + CLI stay available either way. When on, promotion is bounded (`stability = MIN(stability * 1.5, stability + 365)`) | +| `VESTIGE_AUTO_CONSOLIDATE_MERGE` | `on` | Auto concat-merge of near-duplicate memories during consolidation (keeps the strongest, folds the rest in as `[MERGED]` blocks, deletes the originals). On by default; set `0`/`false`/`off`/`no` to disable. Protected (`dedup protect`) memories are never absorbed or deleted by this pass, on or off. | > **Storage location precedence:** `--data-dir ` wins over `VESTIGE_DATA_DIR`; if neither is set, Vestige uses your OS's per-user data directory: `~/Library/Application Support/com.vestige.core/` on macOS, `~/.local/share/vestige/core/` on Linux, `%APPDATA%\vestige\core\` on Windows. Custom paths are directories, are created if missing, expand a leading `~`, and store the database at `/vestige.db`. diff --git a/docs/GETTING-STARTED.md b/docs/GETTING-STARTED.md new file mode 100644 index 0000000..eeccbd6 --- /dev/null +++ b/docs/GETTING-STARTED.md @@ -0,0 +1,126 @@ +# Getting Started with Vestige + +Your first 30 minutes, start to finish. By the end you'll have Vestige installed, +connected to your agent, storing memories, and you'll know how to look at exactly +what it kept. + +Vestige is local-first: one binary, your data on your disk, no account, no cloud. + +--- + +## 1. Install and connect (5 minutes) + +Install is one command and connecting is one JSON block. The canonical, always-current +steps live in the README so this guide never drifts from them: + +- **[Install + connect →](../README.md#-get-it-running-in-60-seconds)** +- Using a specific editor? Pick your per-agent guide — + [Cursor](integrations/cursor.md), [VS Code](integrations/vscode.md), + [Windsurf](integrations/windsurf.md), [JetBrains](integrations/jetbrains.md), + [Xcode](integrations/xcode.md), [OpenCode](integrations/opencode.md), + [Codex](integrations/codex.md) — or the + **[Claude Desktop 2-minute setup](CONFIGURATION.md#claude-desktop-macos)**. + +Confirm it's alive: + +```bash +vestige-mcp --version # prints the installed version +vestige stats # 0 memories on a fresh install +``` + +--- + +## 2. What Vestige saves (and what it doesn't) + +This is the thing most people get wrong on day one, so it's worth 60 seconds. + +**Vestige does not record everything you type.** It is not a transcript logger. A +memory is written when: + +- **You ask your agent to remember something** ("remember: we disable SimSIMD on + release builds"), or +- **Your agent decides a fact is worth keeping** and calls the memory tool, or +- **You ingest deliberately** from the CLI: `vestige ingest "..."`. + +Every write goes through **prediction-error gating** — near-duplicates of what you +already know are down-weighted, so the store doesn't fill with restatements of the +same fact. What you get is a curated set of durable facts, decisions, and the +occasional "this didn't work," not a firehose of your chat history. + +If you want the deeper model (FSRS-6 decay, spreading activation, the science), see +**[The Science](SCIENCE.md)**. You don't need it to start. + +--- + +## 3. Try the one thing nothing else does + +The headline feature is a backward reach through time. Store a decision, then later +store a failure, and Vestige can surface the earlier decision as the *cause* — even +though the two share no words. + +```bash +vestige ingest "We switched the prod cache from Redis to an in-memory LRU to cut costs." +# ...later... +vestige ingest "Prod is dropping sessions under load and users are getting logged out." + +vestige backfill --contrast +``` + +`--contrast` shows you, side by side, what a plain similarity search returns versus +the real causal cause. That contrast is the whole pitch — more on the mechanism in +**[the README](../README.md#-the-thing-nothing-else-does-memory-with-hindsight)**. + +You can also just talk to your agent normally; it will write and recall memories for +you through MCP. The CLI is for when you want to drive it directly. + +--- + +## 4. Inspect what's stored + +Vestige is built to be looked at. Nothing is hidden in an opaque index. + +- **Quick counts:** `vestige stats` +- **Health check** (coverage, warnings): `vestige health` +- **Recall + reasoning** over your memories: `vestige recall "your question"` +- **Full export** to JSON/JSONL (grep it, diff it, back it up): + `vestige export memories.jsonl --format jsonl` +- **The 3D dashboard** — watch your memory as a living graph: + + ```bash + vestige dashboard # opens http://localhost:3927 + ``` + + (When running as the MCP server, enable it with `VESTIGE_DASHBOARD_ENABLED=1`.) + +Because the store is a single SQLite database, you can also open it with any SQLite +browser if you want the raw truth. + +--- + +## 5. Scope it: global vs per-project + +By default Vestige uses one global memory in your OS data directory. For a +project-local memory that lives with the repo, point it at a directory: + +```bash +vestige stats --data-dir ./.vestige # this project's memory +VESTIGE_DATA_DIR=./.vestige vestige-mcp # run the server against it +``` + +Precedence is `--data-dir` > `VESTIGE_DATA_DIR` > OS per-user default. Full details, +including multi-instance setups, are in **[Storage Modes](STORAGE.md)** and +**[Configuration](CONFIGURATION.md)**. + +--- + +## Where to go next + +| Want to… | Read | +|---|---| +| Understand a specific feature or the research | [The Science](SCIENCE.md) | +| Tune knobs, env vars, ports | [Configuration](CONFIGURATION.md) | +| Global vs per-project vs multi-instance | [Storage Modes](STORAGE.md) | +| Make your agent use memory automatically | [README → automatic memory](../README.md#-make-your-ai-use-memory-automatically) | +| Ask a real question | [FAQ](FAQ.md) | + +Welcome. Vestige gets more useful the longer you use it — that's the point. diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 6578cef..b435271 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -126,6 +126,68 @@ Target: turn "I have 300 notes" into a reliable workflow. | Review queue | Users can approve, edit, split, merge, or reject proposed memories. | | Post-import health pass | Vestige recommends consolidation, duplicate review, or tag cleanup after import. | +## Tracked Issues (Consolidated 2026-07-02) + +The following roadmap issues were consolidated here and closed so the issue tracker +reflects active work, not a standing backlog. Nothing is lost — each entry keeps its +scope, the backend anchors that already exist, and why it is deferred. Most are +deferred behind the dashboard focus; several are security/data-integrity boundaries +that are deliberately *not* shipped half-done. + +### A. Reliability & Trust surfaces + +- **Agent Reliability Record** (was #84) — Unify traces, receipts, contradictions, + and composed-graph events into one per-run record with 5 evidence states + (supported / missing / stale / contradicted / suppressed) + Markdown export. + Backend already exists (`crates/vestige-core/src/trace/`). Remaining work is the + dashboard record view — see the dashboard Discussion. +- **Trust Zones + Memory Quarantine** (was #85) — Provenance/trust class on nodes, + score-capping for weak-provenance content, quarantine of untrusted sources. + Security boundary; unsafe half-done, and depends on ACL Memory primitives that + don't exist yet. Deferred post-dashboard. +- **ComposeBench** (was #86) — Reliability benchmark across 8 scenarios. Will reuse + the existing `benchmarks/causebench/` harness pattern; the ACL scenario is gated + on ACL Memory. Deferred. + +### B. Access & Governance boundary + +- **ACL Memory for source-aware connectors** (was #82) — Source-authorization-aware + memory: connector-ingested memories preserve upstream access rules and retrieval + fails closed for unauthorized callers. A hard security boundary with no foundation + today (no per-caller identity model; `search()` takes no subject). Must be designed + as one deliberate pass, not sliced. Design + user-permission-shape input welcome in + the Discussion. +- **Team Pro Reliability Foundation** (was #92) — Commercial team tier (RBAC/SSO/SCIM, + admin review, audit export, team lanes, Postgres, hosted backups). A product-strategy + meta-issue, upstream of coding; depends on ACL Memory + HTTP/Postgres plans. + +### C. Ingest & Projection integrity + +- **Markdown + Rules Projection** (was #87) — Project memories into client-native + rule files (AGENTS.md, CLAUDE.md, `.cursor/rules`, Windsurf, Cline) with provenance + and an optional bidirectional re-import. The re-import leg is a data-integrity + boundary (must never silently overwrite user files). Target-format priorities are an + open user question — Discussion. +- **Code Memory Workflow** (was #88) — First-class, inspectable code memory + (patterns/decisions with file+line provenance) kept separate from prose. The typed + model exists (`crates/vestige-core/src/codebase/`) but is unpersisted/unwired; needs + schema + a review/prune dashboard surface. +- **Guided Import + Review Queue** (was #89) — Dry-run import → proposed memories → + approve/edit/split/merge/reject queue → post-import health pass. Ingest/corruption + boundary; needs a real no-write dry run + review-queue state machine. +- **Goals + Milestones** (was #90) — A durable, non-decaying goal/milestone primitive + (paralleling the intentions subsystem) with lifecycle states and evidence/blockers. + A create-only slice would ship the primitive without its defining non-decay + guarantee, so it waits for the full build. + +### D. Dashboard productization + +- **ComposedGraph Productization** (was #91) — The MCP/CLI/storage backend already + ships in v2.2 (`crates/vestige-mcp/src/tools/composed_graph.rs`, all 7 modes). The + remaining slice is the dashboard surface: composition history, the never-composed + frontier, and closed doors. This is the natural first move in the dashboard focus — + shape it in the Discussion. + ## Non-Goals - Do not auto-store every conversation turn by default. diff --git a/package.json b/package.json index 9fd787d..c88eb52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vestige", - "version": "2.2.0", + "version": "2.2.1", "private": true, "description": "Cognitive memory for AI - MCP server with FSRS-6 spaced repetition", "author": "Sam Valladares", diff --git a/packages/vestige-init/package.json b/packages/vestige-init/package.json index 2ff1f73..a91245e 100644 --- a/packages/vestige-init/package.json +++ b/packages/vestige-init/package.json @@ -1,6 +1,6 @@ { "name": "@vestige/init", - "version": "2.2.0", + "version": "2.2.1", "description": "Configure Vestige local memory for MCP-compatible AI agents", "bin": { "vestige-init": "bin/init.js" diff --git a/packages/vestige-mcp-npm/package.json b/packages/vestige-mcp-npm/package.json index ec6477d..6aff1a4 100644 --- a/packages/vestige-mcp-npm/package.json +++ b/packages/vestige-mcp-npm/package.json @@ -1,6 +1,6 @@ { "name": "vestige-mcp-server", - "version": "2.2.0", + "version": "2.2.1", "mcpName": "io.github.samvallad33/vestige", "description": "Vestige MCP Server — local cognitive memory for MCP-compatible AI agents", "bin": {