Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.
JavaScript 3d3d-assets3d-modelingagent-skillsagent-toolsai-agentsasset-pipelinecligame-assetsglbgltfmcpmcp-servermodel-context-protocolprocedural-generationprocedural-modelingtext-to-3dthreejstypescript
feat(export): runtime texture manifest, external textures and KTX2 through an optional peer (#213, #201) (#235)
Matthew Kissinger2301165ba9da
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 13addfac..88f4faf6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,24 @@ does not publish a package.## Unreleased+- Encode KTX2 through an optional `ktx2-encoder` peer+ ([#201](https://github.com/instruktlabs/kiln/issues/201)). `export --target three --ktx2`+ (or `ktx2Encoder: await createKtx2Encoder()`) uses ETC1S for base colour and emissive and+ UASTC for normal and other linear maps, refuses an image shared by both kinds of slot, and+ records the encoder name, version, Basis WebAssembly hash and settings in+ `delivery.ktx2.encoder` and the `--json` receipt. Kiln does not install or bundle the+ peer: run `npm install [email protected]` (MIT; its bundled Basis Universal encoder is+ Apache-2.0 with its notice in the package). The KTX2 hook now receives the slot, requires+ the KTX2 identifier in its output, and rebinds atlas provenance to the encoded bytes, so+ an encoded atlas passes import validation.+- Add an opt-in runtime texture manifest and content-addressed external textures+ ([#213](https://github.com/instruktlabs/kiln/issues/213)). `export --profile runtime+ --textures manifest` adds sidecar `textures[]` naming each image's exact `sha256`, size,+ colour space and, when its bytes equal a saved library map, that material pin.+ `--target three --textures external --out x.gltf` writes JSON glTF whose images are shared+ `textures/<sha256>.<ext>` files: an identical existing file is reused, a different one+ stops the export, and rollback never removes a texture. Without `--textures`, runtime GLB,+ sidecar and receipt bytes are unchanged; MCP does not offer the options.- Name the rule in material validation errors ([#198](https://github.com/instruktlabs/kiln/issues/198)).Sampler, procedural V3 and atlas checks now report the canonicalizer's reason (forexample "stamps are supported only for color usages albedo and emissive") instead of adiff --git a/README.md b/README.mdindex 06bcb547..c65d742c 100644--- a/README.md+++ b/README.md@@ -153,6 +153,12 @@ kiln discover --capabilities --jsonkiln render my-asset.kiln.js --out my-asset.glb --views sheet.png```+KTX2 texture compression for the three.js runtime export (`export --target three --ktx2`)+uses an optional peer that Kiln does not install or bundle. Add it to the same installation+when you need it: `npm install [email protected]`. It is MIT-licensed and ships its own+notice for the bundled Basis Universal encoder (Apache-2.0); see+[KTX2 textures](docs/export-profiles.md#ktx2-textures).+With a project-local installation, use `npx --no -- kiln discover --capabilities --json`from that project. The [CLI installation guide](docs/install.md#run-the-cli) covers PATHand the equivalent `npm exec` command.diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.mdindex cdbd80dd..9d849e40 100644--- a/THIRD_PARTY_NOTICES.md+++ b/THIRD_PARTY_NOTICES.md@@ -51,6 +51,7 @@ and are not required for CLI/MCP authoring.| `@img/[email protected]` | Apache-2.0 AND LGPL-3.0-or-later | package `LICENSE` and `versions.json`; the inspected binary includes libvips 8.18.7 and additional native libraries || `[email protected]` | Apache-2.0 | `manifold-3d/LICENSE`, JavaScript and WASM distribution || `[email protected]` | MIT | `xatlasjs/LICENSE`, copyright Jonathan Young; JavaScript and WASM distribution |+| `[email protected]` (optional peer, inspected October 22, 2026) | MIT | `ktx2-encoder/LICENSE` and `ktx2-encoder/THIRD_PARTY_NOTICES.md`: bundled Basis Universal encoder WASM under Apache-2.0 with its NOTICE reproduced, linking Zstandard (BSD-3-Clause) and MIT image loaders. Not installed by Kiln; the user installs it for `--ktx2` |Sharp selects platform-specific binaries during installation; consult the[upstream installation documentation](https://sharp.pixelplumbing.com/install/)diff --git a/bun.lock b/bun.lockindex 1c4387ca..544a47fc 100644--- a/bun.lock+++ b/bun.lock@@ -37,6 +37,7 @@"@strands-agents/sdk": "1.21.0","@types/bun": "^1.4.2","ai": "^6.0.300",+ "ktx2-encoder": "0.6.0","openai": "^6.49.0","typescript": "^7.0.2",},@@ -48,11 +49,13 @@"@ai-sdk/provider": "^3.0.0","@openrouter/ai-sdk-provider": "^2.10.0","@strands-agents/sdk": "^1.18.0",+ "ktx2-encoder": "0.6.0",},"optionalPeers": ["@ai-sdk/provider","@openrouter/ai-sdk-provider","@strands-agents/sdk",+ "ktx2-encoder",],},},@@ -432,6 +435,8 @@"ktx-parse": ["[email protected]", "", {}, "sha512-mKp3y+FaYgR7mXWAbyyzpa/r1zDWeaunH+INJO4fou3hb45XuNSwar+7llrRyvpMWafxSIi99RNFJ05MHedaJQ=="],+ "ktx2-encoder": ["[email protected]", "", { "dependencies": { "ktx-parse": "^1.1.0" } }, "sha512-gEWkw2YUlhKO4hXhqVLQQWJ+fGJObsXIwz0pGjJMclnQ4MQU3SAtN1MzutjFxO3ejWvxHyvFk5kr8+RtLmHiTA=="],+"long": ["[email protected]", "", {}, "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA=="],"magic-string": ["[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="],diff --git a/dist/agent-run.mjs b/dist/agent-run.mjsindex 95d69bfa..5d8bf6fa 100644--- a/dist/agent-run.mjs+++ b/dist/agent-run.mjs@@ -37791,12 +37791,186 @@ var init_protocol = __esm(() => {};});+// src/runtime-textures.ts+async function sha256Hex3(bytes) {+ const digest = await crypto.subtle.digest("SHA-256", Uint8Array.from(bytes));+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");+}+function imageDimensions(bytes) {+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);+ const fail = () => {+ throw new Error("Texture manifest cannot read image dimensions");+ };+ const at = (offset, length) => {+ if (offset + length > bytes.byteLength)+ fail();+ };+ if (bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71) {+ at(16, 8);+ return { width: view.getUint32(16), height: view.getUint32(20) };+ }+ if (isKtx2(bytes)) {+ at(20, 8);+ return { width: view.getUint32(20, true), height: view.getUint32(24, true) };+ }+ if (bytes[0] === 255 && bytes[1] === 216) {+ let offset = 2;+ while (offset + 4 <= bytes.byteLength) {+ if (bytes[offset] !== 255)+ fail();+ const marker = bytes[offset + 1];+ if (marker === 255) {+ offset++;+ continue;+ }+ if (marker === 216 || marker === 1 || marker >= 208 && marker <= 215) {+ offset += 2;+ continue;+ }+ const length = view.getUint16(offset + 2);+ if (marker >= 192 && marker <= 207 && ![196, 200, 204].includes(marker)) {+ at(offset + 5, 4);+ return { width: view.getUint16(offset + 7), height: view.getUint16(offset + 5) };+ }+ offset += 2 + length;+ }+ fail();+ }+ const text = (offset) => String.fromCharCode(...bytes.subarray(offset, Math.min(offset + 4, bytes.byteLength)));+ if (text(0) === "RIFF" && text(8) === "WEBP") {+ at(12, 19);+ const chunk = text(12);+ if (chunk === "VP8X")+ return {+ width: 1 + (view.getUint32(24, true) & 16777215),+ height: 1 + (view.getUint32(27, true) & 16777215)+ };+ if (chunk === "VP8L") {+ const bits = view.getUint32(21, true);+ return { width: 1 + (bits & 16383), height: 1 + (bits >> 14 & 16383) };+ }+ if (chunk === "VP8 ") {+ at(26, 4);+ return {+ width: view.getUint16(26, true) & 16383,+ height: view.getUint16(28, true) & 16383+ };+ }+ }+ return fail();+}+function textureSource(texture) {+ if (!object2(texture))+ return;+ const extensions = object2(texture.extensions) ? texture.extensions : {};+ for (const name of ["KHR_texture_basisu", "EXT_texture_webp", "EXT_texture_avif"]) {+ const extension = extensions[name];+ if (object2(extension) && index(extension.source) !== undefined)+ return index(extension.source);+ }+ return index(texture.source);+}+function srgbImages(json) {+ const textures = Array.isArray(json.textures) ? json.textures : [];+ const result = new Set;+ for (const material of Array.isArray(json.materials) ? json.materials : []) {+ if (!object2(material))+ continue;+ const pbr = object2(material.pbrMetallicRoughness) ? material.pbrMetallicRoughness : {};+ for (const info of [pbr.baseColorTexture, material.emissiveTexture]) {+ const texture = object2(info) ? index(info.index) : undefined;+ const image = texture === undefined ? undefined : textureSource(textures[texture]);+ if (image !== undefined)+ result.add(image);+ }+ }+ return result;+}+function base64(text) {+ const binary = atob(text);+ return Uint8Array.from(binary, (character) => character.charCodeAt(0));+}+function embeddedImages(json, binary) {+ const views = Array.isArray(json.bufferViews) ? json.bufferViews : [];+ return (Array.isArray(json.images) ? json.images : []).map((image) => {+ if (!object2(image))+ throw new Error("Invalid glTF image");+ const view = index(image.bufferView);+ if (view !== undefined) {+ const def = views[view];+ if (!object2(def) || index(def.buffer) !== 0 || !binary)+ throw new Error("Texture manifest requires images embedded in the GLB binary chunk");+ const offset = index(def.byteOffset) ?? 0;+ const length = index(def.byteLength);+ if (length === undefined || offset + length > binary.byteLength)+ throw new Error("Invalid glTF image buffer view");+ if (typeof image.mimeType !== "string")+ throw new Error("Embedded image needs a mimeType");+ return { bytes: binary.subarray(offset, offset + length), mimeType: image.mimeType };+ }+ const match = typeof image.uri === "string" ? /^data:([^;,]+);base64,(.*)$/s.exec(image.uri) : null;+ if (!match)+ throw new Error("Texture manifest requires embedded image bytes");+ return { bytes: base64(match[2]), mimeType: match[1] };+ });+}+async function runtimeTextureManifest(json, binary, options = {}) {+ const srgb = srgbImages(json);+ const entries = [];+ for (const [image, { bytes, mimeType }] of embeddedImages(json, binary).entries()) {+ const sha256 = `sha256:${await sha256Hex3(bytes)}`;+ const sourceSha256 = options.sources?.get(image);+ const original = sourceSha256 ?? sha256;+ const map = options.maps?.find((candidate) => candidate.sha256 === original);+ entries.push({+ image,+ sha256,+ bytes: bytes.byteLength,+ mimeType,+ ...imageDimensions(bytes),+ colorSpace: srgb.has(image) ? "srgb" : "linear",+ ...sourceSha256 && sourceSha256 !== sha256 ? { sourceSha256 } : {},+ ...map ? { material: { pin: { ...map.pin }, slot: map.slot } } : {}+ });+ }+ return entries;+}+function textureFileExtension(mimeType) {+ const extension = {+ "image/png": "png",+ "image/jpeg": "jpg",+ "image/webp": "webp",+ "image/ktx2": "ktx2"+ }[mimeType];+ if (!extension)+ throw new Error(`External textures do not support ${mimeType}`);+ return extension;+}+var object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), index = (value) => Number.isInteger(value) && value >= 0 ? value : undefined, KTX2_IDENTIFIER, isKtx2 = (bytes) => bytes.byteLength >= 12 && KTX2_IDENTIFIER.every((value, at) => bytes[at] === value);+var init_runtime_textures = __esm(() => {+ KTX2_IDENTIFIER = Object.freeze([+ 171,+ 75,+ 84,+ 88,+ 32,+ 50,+ 48,+ 187,+ 13,+ 10,+ 26,+ 10+ ]);+});+// src/runtime-three.tsvar exports_runtime_three = {};__export(exports_runtime_three, {deliverRuntimeThreeGlb: () => deliverRuntimeThreeGlb});import {+ Format,Logger as Logger2,PropertyType as PropertyType5} from "@gltf-transform/core";@@ -37881,7 +38055,7 @@ function splitColliderProxies(doc) {}return report;}-async function encodeKtx2(doc, encoder) {+async function encodeKtx2(doc, encoder, sources) {const textures = doc.getRoot().listTextures().filter((texture) => texture.getMimeType() !== "image/ktx2" && texture.getImage());if (!encoder)return {@@ -37889,29 +38063,62 @@ async function encodeKtx2(doc, encoder) {textures: textures.length,reason: "No KTX2 encoder was supplied; textures stay PNG or JPEG."};- const srgb = new Set;+ const slots = new Map;+ const use = (texture, slot) => {+ if (texture)+ slots.set(texture, (slots.get(texture) ?? new Set).add(slot));+ };for (const material of doc.getRoot().listMaterials()) {- for (const texture of [material.getBaseColorTexture(), material.getEmissiveTexture()])- if (texture)- srgb.add(texture);+ use(material.getBaseColorTexture(), "baseColor");+ use(material.getEmissiveTexture(), "emissive");+ use(material.getNormalTexture(), "normal");+ use(material.getMetallicRoughnessTexture(), "metallicRoughness");+ use(material.getOcclusionTexture(), "occlusion");}+ const order = [+ "baseColor",+ "emissive",+ "normal",+ "metallicRoughness",+ "occlusion"+ ];for (const texture of textures) {+ const used = slots.get(texture) ?? new Set;+ const srgb = used.has("baseColor") || used.has("emissive");+ const other = texture.listParents().some((parent) => parent.propertyType !== PropertyType5.ROOT && !isCoreMaterialUse(parent));+ const linear = [...used].some((slot) => slot !== "baseColor" && slot !== "emissive") || other;+ if (srgb && linear)+ throw new Error(`Texture ${JSON.stringify(texture.getName())} is used by both sRGB and linear material slots; one KTX2 encoding cannot serve both. Use separate images.`);+ const original = texture.getImage();const image = await encoder({- image: texture.getImage(),+ image: original,mimeType: texture.getMimeType(),name: texture.getName(),- colorSpace: srgb.has(texture) ? "srgb" : "linear"+ colorSpace: srgb ? "srgb" : "linear",+ slot: order.find((slot) => used.has(slot)) ?? "other"});- if (!(image instanceof Uint8Array) || image.byteLength < 12)- throw new Error("ktx2Encoder must return KTX2 bytes");+ if (!(image instanceof Uint8Array) || !isKtx2(image))+ throw new Error("ktx2Encoder must return KTX2 bytes starting with the KTX2 identifier");+ sources.set(texture, `sha256:${await sha256Hex3(original)}`);texture.setImage(image).setMimeType("image/ktx2");const uri = texture.getURI();if (uri)texture.setURI(uri.replace(/\.(png|jpe?g)$/i, ".ktx2"));}- if (textures.length)+ if (textures.length) {doc.createExtension(KHRTextureBasisu2).setRequired(true);- return { status: "encoded", textures: textures.length };+ await Promise.resolve().then(() => init_atlas_provenance());+ await refreshAtlasDocumentProvenance(doc);+ await validateAtlasDocumentProvenance(doc);+ }+ return {+ status: "encoded",+ textures: textures.length,+ ...encoder.identity ? { encoder: structuredClone(encoder.identity) } : {}+ };+}+function isCoreMaterialUse(parent) {+ return parent.propertyType === PropertyType5.MATERIAL;}function decomposeDelta(before, after) {const delta = new THREE55.Matrix4().fromArray(before).invert().multiply(new THREE55.Matrix4().fromArray(after));@@ -37922,7 +38129,7 @@ function decomposeDelta(before, after) {offset: [position.x, position.y, position.z]};}-async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}) {+async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}, layout = {}) {const compression = options.compression ?? "meshopt";if (compression !== "meshopt" && compression !== "none")throw new Error("Runtime three compression must be meshopt or none");@@ -37950,7 +38157,8 @@ async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}) {}));if (compression === "meshopt")doc.createExtension(EXTMeshoptCompression).setRequired(true).setEncoderOptions({ method: EXTMeshoptCompression.EncoderMethod.QUANTIZE });- const ktx2 = await encodeKtx2(doc, options.ktx2Encoder);+ const encodedSources = new Map;+ const ktx2 = await encodeKtx2(doc, options.ktx2Encoder, encodedSources);for (const node of doc.getRoot().listNodes()) {const mesh = node.getMesh();if (!mesh || matrices.has(node) || node.getName())@@ -38009,6 +38217,13 @@ async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}) {const all = doc.getRoot().listNodes();const glb = await io.writeBinary(doc);const json = (await io.binaryToJSON(glb)).json;+ const imageSources = new Map;+ doc.getRoot().listTextures().forEach((texture, image) => {+ const source = encodedSources.get(texture);+ if (source)+ imageSources.set(image, source);+ });+ const gltf = layout.gltfBasename ? await io.writeJSON(doc, { format: Format.GLTF, basename: layout.gltfBasename }) : undefined;const delivery = {target: "three",extensionsUsed: [...json.extensionsUsed ?? []].sort(),@@ -38048,7 +38263,17 @@ async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}) {kitModules: all.filter((node) => rolesOf4(node).includes(KILN_SEMANTIC_ROLES.kitModule)).length}};- return { glb, delivery };+ return {+ glb,+ delivery,+ imageSources,+ ...gltf ? {+ gltf: {+ json: gltf.json,+ resources: gltf.resources+ }+ } : {}+ };}var RUNTIME_THREE_QUANTIZATION, QUANTIZED_SEMANTICS, customRank = (name) => name === "_EDGE" ? 0 : name === "_CAVITY" ? 1 : 2, rolesOf4 = (node) => readSemanticMetadataV1FromExtras(node.getExtras())?.roles ?? [], isCollider = (node) => rolesOf4(node).some((role) => role.startsWith(`${KILN_SEMANTIC_ROLES.collider}.`));var init_runtime_three = __esm(() => {@@ -38057,6 +38282,7 @@ var init_runtime_three = __esm(() => {init_delivery_inspect();init_delivery();init_metrics();+ init_runtime_textures();RUNTIME_THREE_QUANTIZATION = Object.freeze({volume: "mesh",position: 14,@@ -38081,6 +38307,36 @@ function validateMetadataFileName(name) {if (name.length > 200 || !/^[a-z0-9][a-z0-9._-]*\.kiln-metadata\.json$/i.test(name) || /^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(name))throw new Error("Runtime metadata filename must be a portable sibling *.kiln-metadata.json filename");}+function validateGltfFileName(name) {+ if (name.length > 200 || !/^[a-z0-9][a-z0-9._-]*\.gltf$/i.test(name) || /^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(name))+ throw new Error("External texture output must be a portable sibling *.gltf filename");+}+function readGlbBinary(bytes, jsonEnd) {+ if (jsonEnd + 8 > bytes.length)+ return;+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);+ if (view.getUint32(jsonEnd + 4, true) !== 5130562)+ return;+ return bytes.subarray(jsonEnd + 8, jsonEnd + 8 + view.getUint32(jsonEnd, true));+}+function closureMaps(record) {+ const manifests = new Map;+ for (const manifest of [+ ...assetMaterialRootManifests(record),+ ...(record.materialResources?.records ?? []).map(({ manifest }) => manifest)+ ])+ manifests.set(`${manifest.materialId}/${manifest.revisionId}`, manifest);+ const order = (value, other) => value < other ? -1 : value > other ? 1 : 0;+ return [...manifests.values()].flatMap((manifest) => manifest.maps.map((map) => ({+ sha256: map.sha256,+ pin: {+ resourceId: manifest.materialId,+ revisionId: manifest.revisionId,+ sha256: manifest.revisionId+ },+ slot: map.slot+ }))).sort((a, b) => order(a.pin.resourceId, b.pin.resourceId) || order(a.pin.revisionId, b.pin.revisionId) || order(a.slot, b.slot));+}function readGlbJson(bytes) {const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);let end = 12;@@ -38094,7 +38350,7 @@ function readGlbJson(bytes) {}const jsonEnd = 20 + view.getUint32(12, true);const json = JSON.parse(decoder.decode(bytes.subarray(20, jsonEnd)));- if (!object2(json) || !object2(json.asset) || json.asset.version !== "2.0")+ if (!object3(json) || !object3(json.asset) || json.asset.version !== "2.0")throw new Error("Invalid glTF asset");return { json, jsonEnd };}@@ -38113,13 +38369,13 @@ function writeGlbJson(bytes, jsonEnd, json) {result.set(bytes.subarray(jsonEnd), 20 + length);return result;}-async function deliverThreeRuntimeGlb(glb, options = {}) {+async function deriveThree(glb, options, layout = {}) {const [{ deliverRuntimeThreeGlb }, { MeshoptEncoder }] = await Promise.all([Promise.resolve().then(() => (init_runtime_three(), exports_runtime_three)),import("meshoptimizer")]);await MeshoptEncoder.ready;- const result = await deliverRuntimeThreeGlb(glb, MeshoptEncoder, options);+ const result = await deliverRuntimeThreeGlb(glb, MeshoptEncoder, options, layout);if (result.glb.byteLength > ASSET_LIMIT)throw new Error("Runtime export exceeds 64 MiB");return result;@@ -38134,6 +38390,16 @@ async function exportAssetGlb(record, options = {}) {throw new Error("A runtime export target requires the runtime profile");if (options.compression !== undefined && options.target !== "three")throw new Error("Runtime compression requires the three runtime target");+ const textures = options.textures;+ if (textures !== undefined && textures !== "manifest" && textures !== "external")+ throw new Error("Unknown runtime texture option");+ if (textures !== undefined && profile !== "runtime")+ throw new Error("A texture manifest requires the runtime profile");+ if (textures === "external" && options.target !== "three")+ throw new Error("External textures require target three");+ const gltfName = options.gltfFileName ?? "runtime.gltf";+ if (textures === "external")+ validateGltfFileName(gltfName);validateRecordShape(record);const bytes = record.files["asset.glb"];if (profile === "editable")@@ -38146,7 +38412,7 @@ async function exportAssetGlb(record, options = {}) {}const { json, jsonEnd } = readGlbJson(bytes);const asset = json.asset;- if (owns(asset, "extras") && !object2(asset.extras))+ if (owns(asset, "extras") && !object3(asset.extras))throw new Error("Cannot add provenance to non-object asset extras");const extras = asset.extras ?? {};if (owns(extras, "kilnProvenanceV1"))@@ -38155,10 +38421,10 @@ async function exportAssetGlb(record, options = {}) {if (json.scenes !== undefined && !Array.isArray(json.scenes))throw new Error("Invalid glTF scenes");for (const [index, scene] of (json.scenes ?? []).entries()) {- if (!object2(scene) || !object2(scene.extras) || !owns(scene.extras, "kilnReviewClipsV1"))+ if (!object3(scene) || !object3(scene.extras) || !owns(scene.extras, "kilnReviewClipsV1"))continue;const review = scene.extras.kilnReviewClipsV1;- if (!object2(review) || review.version !== 1 && review.version !== 2 || !Array.isArray(review.clips))+ if (!object3(review) || review.version !== 1 && review.version !== 2 || !Array.isArray(review.clips))throw new Error("Unsupported scenes[].extras.kilnReviewClipsV1");scenes.push({ index, kilnReviewClipsV1: review });delete scene.extras.kilnReviewClipsV1;@@ -38173,36 +38439,89 @@ async function exportAssetGlb(record, options = {}) {},scenes};- let base = bytes, baseJson = json, baseJsonEnd = jsonEnd;+ let base = bytes, baseJson = json, baseJsonEnd = jsonEnd, imageSources, gltf;if (options.target === "three") {- const derived = await deliverThreeRuntimeGlb(writeGlbJson(bytes, jsonEnd, json), {+ const derived = await deriveThree(writeGlbJson(bytes, jsonEnd, json), {...options.ktx2Encoder ? { ktx2Encoder: options.ktx2Encoder } : {},...options.compression ? { compression: options.compression } : {}- });+ }, textures === "external" ? { gltfBasename: gltfName.slice(0, -".gltf".length) } : {});metadata.target = "three";metadata.delivery = derived.delivery;base = derived.glb;+ imageSources = derived.imageSources;+ gltf = derived.gltf;({ json: baseJson, jsonEnd: baseJsonEnd } = readGlbJson(base));}+ if (textures !== undefined)+ metadata.textures = await runtimeTextureManifest(baseJson, readGlbBinary(base, baseJsonEnd), {+ ...imageSources ? { sources: imageSources } : {},+ maps: closureMaps(record)+ });+ const external = gltf ? await externalLayout(gltf, metadata.textures ?? []) : undefined;const metadataBytes = encoder2.encode(JSON.stringify(metadata));if (metadataBytes.length > ASSET_LIMIT)throw new Error("Runtime export exceeds 64 MiB");+ const provenance = {+ version: "kiln.provenance.v1",+ profile: "runtime",+ ...options.target ? { target: options.target } : {},+ metadata: { uri: name, sha256: await sha2562(metadataBytes) }+ };const baseAsset = baseJson.asset;baseAsset.extras = {...baseAsset.extras ?? extras,- kilnProvenanceV1: {- version: "kiln.provenance.v1",- profile: "runtime",- ...options.target ? { target: options.target } : {},- metadata: { uri: name, sha256: await sha2562(metadataBytes) }- }+ kilnProvenanceV1: provenance};const result = writeGlbJson(base, baseJsonEnd, baseJson);- return { profile, glb: result, metadata: { name, bytes: metadataBytes } };+ if (!external)+ return { profile, glb: result, metadata: { name, bytes: metadataBytes } };+ const gltfAsset = external.json.asset;+ gltfAsset.extras = {+ ...gltfAsset.extras ?? extras,+ kilnProvenanceV1: provenance+ };+ const gltfBytes = encoder2.encode(JSON.stringify(external.json));+ if (gltfBytes.length > ASSET_LIMIT)+ throw new Error("Runtime export exceeds 64 MiB");+ return {+ profile,+ layout: "gltf",+ glb: result,+ gltf: { name: gltfName, bytes: gltfBytes },+ buffers: external.buffers,+ textures: external.textures,+ metadata: { name, bytes: metadataBytes }+ };+}+async function externalLayout(gltf, manifest) {+ const json = structuredClone(gltf.json);+ const resources = new Map(Object.entries(gltf.resources));+ const images = Array.isArray(json.images) ? json.images : [];+ if (images.length !== manifest.length)+ throw new Error("External texture layout mismatch");+ const textures = new Map;+ for (const [index, image] of images.entries()) {+ const entry = manifest[index];+ const written = typeof image.uri === "string" ? image.uri : "";+ const bytes = resources.get(written);+ if (!bytes || `sha256:${await sha256Hex3(bytes)}` !== entry.sha256)+ throw new Error("External texture bytes differ from the delivered GLB");+ resources.delete(written);+ const uri = `textures/${entry.sha256.slice("sha256:".length)}.${textureFileExtension(entry.mimeType)}`;+ image.uri = uri;+ entry.uri = uri;+ textures.set(uri, { uri, sha256: entry.sha256, bytes });+ }+ const buffers = [...resources].map(([uri, bytes]) => ({ uri, bytes }));+ for (const { uri } of buffers)+ if (!/^[a-z0-9][a-z0-9._-]*\.bin$/i.test(uri))+ throw new Error(`Unexpected external glTF resource ${uri}`);+ return { json, buffers, textures: [...textures.values()] };}-var encoder2, decoder, object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), owns = (value, key) => Object.hasOwn(value, key);+var encoder2, decoder, object3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), owns = (value, key) => Object.hasOwn(value, key);var init_asset_export = __esm(() => {init_assets();+ init_runtime_textures();encoder2 = new TextEncoder;decoder = new TextDecoder;});@@ -39569,7 +39888,7 @@ var init_assets_resources = __esm(() => {// src/widget-transfer.tsimport { deflateSync as deflateSync2, inflateSync as inflateSync2 } from "three/addons/libs/fflate.module.js";-function base64(bytes) {+function base642(bytes) {let binary = "";for (let index = 0;index < bytes.length; index += 8192)binary += String.fromCharCode(...bytes.subarray(index, index + 8192));@@ -39579,8 +39898,8 @@ function encodeWidgetFiles(files) {if (Object.values(files).reduce((total, bytes) => total + bytes.length, 0) > WIDGET_TRANSFER_LIMIT)invalid("exceeds the decoded size limit");return Object.fromEntries(Object.entries(files).map(([name, bytes]) => {- const plain = base64(bytes);- const compressed = base64(deflateSync2(bytes, { level: 6 }));+ const plain = base642(bytes);+ const compressed = base642(deflateSync2(bytes, { level: 6 }));return [name,compressed.length + 64 < plain.length ? { encoding: "kiln.deflate-base64.v1", data: compressed } : plaindiff --git a/dist/build.json b/dist/build.jsonindex 0e1a4b91..d0f0dc66 100644--- a/dist/build.json+++ b/dist/build.json@@ -2,12 +2,12 @@"schemaVersion": 1,"entries": {"worker": {- "identity": "sha256:a9d192f91e1e95b12632695341dda15867120f57f7b7b3aa68cee64fd11d4006",+ "identity": "sha256:3f5b7bae30b5a22807b99ee8a5282c6d7d54e5049806602448881316d397a8f1","engineVersion": "1.3.1","toolchain": "[email protected]",- "sourceHash": "4f6b8ae26e6f2abdbe2ecb58b51f3c401175d70fd8ba63fe4880dae50511565c",+ "sourceHash": "1a29293d5311ba47404f494bf2504898d2d38130cbbf1f9bf5c24c10e6107125","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",- "dependencyHash": "20b5b45a138ab83d340e78729d1a427bdc9b8aeadc47c5f7acf907eab43377f3",+ "dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10","dependencies": {"@gltf-transform/core": "4.5.1","@gltf-transform/extensions": "4.5.1",@@ -40,12 +40,12 @@"bundleHash": "sha256:326aaf15bc9181bc8ef5b2cf02861c33cc7848347e50830f288330121c0d1f0e"},"agent-run": {- "identity": "sha256:a9d192f91e1e95b12632695341dda15867120f57f7b7b3aa68cee64fd11d4006",+ "identity": "sha256:3f5b7bae30b5a22807b99ee8a5282c6d7d54e5049806602448881316d397a8f1","engineVersion": "1.3.1","toolchain": "[email protected]",- "sourceHash": "4f6b8ae26e6f2abdbe2ecb58b51f3c401175d70fd8ba63fe4880dae50511565c",+ "sourceHash": "1a29293d5311ba47404f494bf2504898d2d38130cbbf1f9bf5c24c10e6107125","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",- "dependencyHash": "20b5b45a138ab83d340e78729d1a427bdc9b8aeadc47c5f7acf907eab43377f3",+ "dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10","dependencies": {"@gltf-transform/core": "4.5.1","@gltf-transform/extensions": "4.5.1",@@ -75,15 +75,15 @@},"target": "node","file": "agent-run.mjs",- "bundleHash": "sha256:40e510f17106f36cc81195e1ea3309deb743ba601f0081d6744685d4f297a32e"+ "bundleHash": "sha256:da18b3f185be4da1105c2336ad7646c95ab67f195da5c2eb977b54e66a4b6f89"},"agent-providers": {- "identity": "sha256:a9d192f91e1e95b12632695341dda15867120f57f7b7b3aa68cee64fd11d4006",+ "identity": "sha256:3f5b7bae30b5a22807b99ee8a5282c6d7d54e5049806602448881316d397a8f1","engineVersion": "1.3.1","toolchain": "[email protected]",- "sourceHash": "4f6b8ae26e6f2abdbe2ecb58b51f3c401175d70fd8ba63fe4880dae50511565c",+ "sourceHash": "1a29293d5311ba47404f494bf2504898d2d38130cbbf1f9bf5c24c10e6107125","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",- "dependencyHash": "20b5b45a138ab83d340e78729d1a427bdc9b8aeadc47c5f7acf907eab43377f3",+ "dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10","dependencies": {"@gltf-transform/core": "4.5.1","@gltf-transform/extensions": "4.5.1",@@ -116,12 +116,12 @@"bundleHash": "sha256:9d6faf03d307321bc2e3bd5ce5bdee0bbbf61e0ebed8bfebfa1fb072287b83fa"},"mcp": {- "identity": "sha256:a9d192f91e1e95b12632695341dda15867120f57f7b7b3aa68cee64fd11d4006",+ "identity": "sha256:3f5b7bae30b5a22807b99ee8a5282c6d7d54e5049806602448881316d397a8f1","engineVersion": "1.3.1","toolchain": "[email protected]",- "sourceHash": "4f6b8ae26e6f2abdbe2ecb58b51f3c401175d70fd8ba63fe4880dae50511565c",+ "sourceHash": "1a29293d5311ba47404f494bf2504898d2d38130cbbf1f9bf5c24c10e6107125","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",- "dependencyHash": "20b5b45a138ab83d340e78729d1a427bdc9b8aeadc47c5f7acf907eab43377f3",+ "dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10","dependencies": {"@gltf-transform/core": "4.5.1","@gltf-transform/extensions": "4.5.1",@@ -154,12 +154,12 @@"bundleHash": "sha256:a246b2c79d629a332cef4430dbe742b0c4a0d2f04f0281e673c3c60ff22706da"},"cli": {- "identity": "sha256:a9d192f91e1e95b12632695341dda15867120f57f7b7b3aa68cee64fd11d4006",+ "identity": "sha256:3f5b7bae30b5a22807b99ee8a5282c6d7d54e5049806602448881316d397a8f1","engineVersion": "1.3.1","toolchain": "[email protected]",- "sourceHash": "4f6b8ae26e6f2abdbe2ecb58b51f3c401175d70fd8ba63fe4880dae50511565c",+ "sourceHash": "1a29293d5311ba47404f494bf2504898d2d38130cbbf1f9bf5c24c10e6107125","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",- "dependencyHash": "20b5b45a138ab83d340e78729d1a427bdc9b8aeadc47c5f7acf907eab43377f3",+ "dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10","dependencies": {"@gltf-transform/core": "4.5.1","@gltf-transform/extensions": "4.5.1",@@ -189,15 +189,15 @@},"target": "node","file": "cli.mjs",- "bundleHash": "sha256:d81bc1f41df8bae96caa68af5ba692f2414038bb25827ebc3d5d6875fbcd2819"+ "bundleHash": "sha256:74b24e3e30e1189870d4f16b75036cd4810d9a4ee1135f0b6315ffddbbee69ce"},"engine": {- "identity": "sha256:a9d192f91e1e95b12632695341dda15867120f57f7b7b3aa68cee64fd11d4006",+ "identity": "sha256:3f5b7bae30b5a22807b99ee8a5282c6d7d54e5049806602448881316d397a8f1","engineVersion": "1.3.1","toolchain": "[email protected]",- "sourceHash": "4f6b8ae26e6f2abdbe2ecb58b51f3c401175d70fd8ba63fe4880dae50511565c",+ "sourceHash": "1a29293d5311ba47404f494bf2504898d2d38130cbbf1f9bf5c24c10e6107125","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",- "dependencyHash": "20b5b45a138ab83d340e78729d1a427bdc9b8aeadc47c5f7acf907eab43377f3",+ "dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10","dependencies": {"@gltf-transform/core": "4.5.1","@gltf-transform/extensions": "4.5.1",@@ -227,7 +227,7 @@},"target": "node","file": "mcp-engine.mjs",- "bundleHash": "sha256:4c28e9a7f4eb98ff72e5f5592e8b906fcf951034152458b85cbc12aacd2067f8"+ "bundleHash": "sha256:79792e69aabd5ff5e75b32603e004b910fc5fddb30fd990d8cdb95ac68af88df"}}}diff --git a/dist/cli.mjs b/dist/cli.mjsindex 7c33e499..762159ce 100644--- a/dist/cli.mjs+++ b/dist/cli.mjs@@ -26,20 +26,21 @@ var __esm = (fn, res, err) => () => {};// src/cli-output.ts-import { randomUUID } from "node:crypto";+import { createHash, randomUUID } from "node:crypto";import {chmod,lstat,link,mkdir,open,+ readFile,realpath,rename,stat,unlink,writeFile} from "node:fs/promises";-import { dirname, join, resolve } from "node:path";+import { basename, dirname, join, resolve } from "node:path";async function prepareDestination(path) {await mkdir(dirname(path), { recursive: true });return path;@@ -120,6 +121,67 @@ async function writeNewDestinationsAtomic(outputs) {await Promise.all(staged.map(({ temporary }) => unlink(temporary).catch(() => {})));}}+async function writeContentAddressedFiles(files) {+ const hex = (data) => createHash("sha256").update(data).digest("hex");+ for (const { path, data } of files) {+ const name = basename(path);+ if (!/^[a-f0-9]{64}\.[a-z0-9]+$/.test(name) || name.slice(0, 64) !== hex(data))+ throw new Error(`${path} is not the content address of its bytes`);+ }+ const published = [];+ const same = async (path, data) => {+ const existing = await readFile(path);+ if (hex(existing) !== hex(data))+ throw Object.assign(new Error(`${path} already exists with different bytes; a content-addressed file is never replaced.`), { code: "EEXIST" });+ };+ for (const { path, data } of files) {+ try {+ await same(path, data);+ published.push({ path, reused: true });+ continue;+ } catch (error) {+ if (error.code !== "ENOENT")+ throw error;+ }+ await prepareDestination(path);+ const temporary = join(dirname(path), `.kiln-write-${randomUUID()}.tmp`);+ const file = await open(temporary, "wx");+ try {+ try {+ await writeFile(file, data);+ } finally {+ await file.close();+ }+ try {+ await link(temporary, path);+ published.push({ path, reused: false });+ } catch (error) {+ if (error.code !== "EEXIST")+ throw error;+ await same(path, data);+ published.push({ path, reused: true });+ }+ } finally {+ await unlink(temporary).catch(() => {});+ }+ }+ return published;+}+async function writeExternalTextureExport(textures, outputs) {+ for (const { path } of outputs) {+ try {+ await lstat(path);+ } catch (error) {+ if (error.code === "ENOENT")+ continue;+ throw error;+ }+ throw Object.assign(new Error(`${path} already exists and is never replaced; choose a new output path or remove the file.`), { code: "EEXIST" });+ }+ const published = await writeContentAddressedFiles(textures);+ await writeNewDestinationsAtomic(outputs);+ return published;+}var init_cli_output = () => {};// src/evaluator/authoring-diagnostic.ts@@ -258,7 +320,7 @@ var init_solid_diagnostic = __esm(() => {});// src/qa/registry.ts-import { createHash } from "node:crypto";+import { createHash as createHash2 } from "node:crypto";function canonicalCalibrationReportEvidence(report) {return JSON.stringify({schemaVersion: report.schemaVersion,@@ -291,7 +353,7 @@ function canonicalCalibrationReportEvidence(report) {});}function calibrationReportEvidenceSha256(report) {- return createHash("sha256").update(canonicalCalibrationReportEvidence(report)).digest("hex");+ return createHash2("sha256").update(canonicalCalibrationReportEvidence(report)).digest("hex");}function conformancePromotionAuthorization(fixtureSetId, fixturePath, evidenceSha256, owner = KILN_ENGINE_QA_OWNER, frozenAt = "2026-07-09T00:00:00.000Z", authorizedMode = "enforce", rendererId = LEGACY_CPU_RASTER_RENDERER_ID) {return {@@ -14517,7 +14579,7 @@ var init_requirements = __esm(() => {});// src/requirements-identity.ts-import { createHash as createHash2 } from "node:crypto";+import { createHash as createHash3 } from "node:crypto";function canonical(value) {if (Array.isArray(value))return `[${value.map(canonical).join(",")}]`;@@ -14537,7 +14599,7 @@ function assetRequirementsPolicyHash(input) {..."value" in value ? { value: value.value } : {}});const effective = Object.fromEntries(Object.entries(requirements.requirements).filter(([, value]) => value !== undefined).map(([key, value]) => [key, withoutReason(value)]));- return createHash2("sha256").update(canonical({+ return createHash3("sha256").update(canonical({kind: requirements.kind,schemaVersion: requirements.schemaVersion,frame,@@ -14598,7 +14660,7 @@ var init_requirements_json = __esm(() => {});// src/requirements-context.ts-import { createHash as createHash3 } from "node:crypto";+import { createHash as createHash4 } from "node:crypto";import { z as z2 } from "zod";function canonical2(value) {if (Array.isArray(value))@@ -14618,7 +14680,7 @@ function contextHash(requirements, kind) {...requirements.scope && includes(requirements.scope.state) ? { scope: statement(requirements.scope) } : {},requirements: Object.fromEntries(Object.entries(requirements.requirements).filter(([, value]) => value && includes(value.state)).map(([key, value]) => [key, statement(value)]))};- return `sha256:${createHash3("sha256").update(`kiln.requirements-${kind}.v1`).update(canonical2(semantic)).digest("hex")}`;+ return `sha256:${createHash4("sha256").update(`kiln.requirements-${kind}.v1`).update(canonical2(semantic)).digest("hex")}`;}function validateRequirementsBinding(input) {const parsed = RequirementsBindingSchema.safeParse(input);@@ -18218,7 +18280,7 @@ var init_material_recipes = __esm(() => {});// src/material-resources.ts-import { createHash as createHash4 } from "node:crypto";+import { createHash as createHash5 } from "node:crypto";function provenance(descriptor, hash) {return {schemaVersion: 1,@@ -18479,7 +18541,7 @@ function collectMaterialResourceProvenance(root) {});return [...records.values()].sort((a, b) => `${a.resourceId}:${a.usage}`.localeCompare(`${b.resourceId}:${b.usage}`));}-var TEXTURE_RESOLVER_LIMITS_V1, ApprovedTextureResourceUnavailableError, EMBEDDED_RESOURCE_BASE64, isApprovedId = (value) => APPROVED_TEXTURE_RESOURCE_IDS.includes(value), bytesFromBase64 = (value) => new Uint8Array(Buffer.from(value, "base64")), sha256 = (bytes) => createHash4("sha256").update(bytes).digest("hex"), DEFAULT_APPROVED_TEXTURE_CACHE, materialTextures2 = (material) => {+var TEXTURE_RESOLVER_LIMITS_V1, ApprovedTextureResourceUnavailableError, EMBEDDED_RESOURCE_BASE64, isApprovedId = (value) => APPROVED_TEXTURE_RESOURCE_IDS.includes(value), bytesFromBase64 = (value) => new Uint8Array(Buffer.from(value, "base64")), sha256 = (bytes) => createHash5("sha256").update(bytes).digest("hex"), DEFAULT_APPROVED_TEXTURE_CACHE, materialTextures2 = (material) => {const standard = material;const candidates = [standard.map,@@ -18808,8 +18870,8 @@ var init_procedural_material_v3 = __esm(() => {});// src/material-library-node.ts-import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypto";-import { lstat as lstat3, mkdir as mkdir2, readFile, readdir, realpath as realpath2, rm, writeFile as writeFile2 } from "node:fs/promises";+import { createHash as createHash6, randomUUID as randomUUID2 } from "node:crypto";+import { lstat as lstat3, mkdir as mkdir2, readFile as readFile2, readdir, realpath as realpath2, rm, writeFile as writeFile2 } from "node:fs/promises";import { dirname as dirname2, join as join2, relative, resolve as resolve4, sep } from "node:path";import sharp from "sharp";import { DataTexture as DataTexture3 } from "three";@@ -19148,7 +19210,7 @@ class FileMaterialLibrary {const stat = await lstat3(path);if (!stat.isFile() || stat.isSymbolicLink() || stat.size > limit)throw new Error("Invalid material library file");- return new Uint8Array(await readFile(path));+ return new Uint8Array(await readFile2(path));}async readManifest(materialId, revisionId) {materialLibraryIdSchema.parse(materialId);@@ -19758,7 +19820,7 @@ async function createMaterialRecordV2(draft, options) {await verifyMaterialRecord(record, { materials: [...records, record] });return record;}-var digest = (bytes) => `sha256:${createHash5("sha256").update(bytes).digest("hex")}`, encoder, normalDerivationBudget = (texels) => ({ work: texels * 16, allocation: texels * 8 }), identity = (manifest) => `${manifest.materialId}/${manifest.revisionId}`;+var digest = (bytes) => `sha256:${createHash6("sha256").update(bytes).digest("hex")}`, encoder, normalDerivationBudget = (texels) => ({ work: texels * 16, allocation: texels * 8 }), identity = (manifest) => `${manifest.materialId}/${manifest.revisionId}`;var init_material_library_node = __esm(() => {init_atomic_directory();init_material_library();@@ -32324,7 +32386,7 @@ var init_kit = __esm(() => {});// src/texture-bake.ts-import { createHash as createHash6 } from "node:crypto";+import { createHash as createHash7 } from "node:crypto";import * as THREE49 from "three";function readPixels(texture) {const image = texture.image;@@ -32424,7 +32486,7 @@ async function bakeSceneTextures(root, warnings) {if (encoded) {const delivery = readValidatedAtlasDelivery(entry.texture);if (delivery) {- if (delivery.id !== atlasRef.id || delivery.finalMime !== encoded.mime || delivery.finalImageSha256 !== `sha256:${createHash6("sha256").update(encoded.bytes).digest("hex")}`)+ if (delivery.id !== atlasRef.id || delivery.finalMime !== encoded.mime || delivery.finalImageSha256 !== `sha256:${createHash7("sha256").update(encoded.bytes).digest("hex")}`)throw stale();} else {const sharp = (await import("sharp")).default;@@ -32435,10 +32497,10 @@ async function bakeSceneTextures(root, warnings) {if (metadata.width !== atlasRecord.spec.width || metadata.height !== atlasRecord.spec.height)throw stale();const decoded = await image.ensureAlpha().raw().toBuffer();- if (`sha256:${createHash6("sha256").update(decoded).digest("hex")}` !== atlasRecord.manifest.decodedPixelHash)+ if (`sha256:${createHash7("sha256").update(decoded).digest("hex")}` !== atlasRecord.manifest.decodedPixelHash)throw stale();}- } else if (raw.width !== atlasRecord.spec.width || raw.height !== atlasRecord.spec.height || raw.channels !== 4 || `sha256:${createHash6("sha256").update(raw.data).digest("hex")}` !== atlasRecord.manifest.decodedPixelHash)+ } else if (raw.width !== atlasRecord.spec.width || raw.height !== atlasRecord.spec.height || raw.channels !== 4 || `sha256:${createHash7("sha256").update(raw.data).digest("hex")}` !== atlasRecord.manifest.decodedPixelHash)throw stale();}let bytes;@@ -32463,8 +32525,8 @@ async function bakeSceneTextures(root, warnings) {height: raw.height,hasAlpha: hasTranslucentPixel(raw)};- const sha1 = createHash6("sha1").update(bytes).digest("hex");- const imageSha256 = `sha256:${createHash6("sha256").update(bytes).digest("hex")}`;+ const sha1 = createHash7("sha1").update(bytes).digest("hex");+ const imageSha256 = `sha256:${createHash7("sha256").update(bytes).digest("hex")}`;baked.push({schemaVersion: 1,texture: name,@@ -35166,7 +35228,7 @@ __export(exports_capture_cache, {captureCpuCell: () => captureCpuCell,createCachedRenderPort: () => createCachedRenderPort});-import { createHash as createHash7 } from "node:crypto";+import { createHash as createHash8 } from "node:crypto";function clone(entry) {const result = structuredClone(entry);if (result.kind === "cpu")@@ -35371,7 +35433,7 @@ async function captureCpuCell(cache, identity, produce) {await cache.put(key, { kind: "cpu", result }).catch(() => {});return { ...result, png: Buffer.from(result.png), captureCache: { hit: false } };}-var text4 = (value) => JSON.stringify(canonical4(value)), digest2 = (value) => `sha256:${createHash7("sha256").update(value).digest("hex")}`;+var text4 = (value) => JSON.stringify(canonical4(value)), digest2 = (value) => `sha256:${createHash8("sha256").update(value).digest("hex")}`;var init_capture_cache = __esm(() => {init_render_port();init_png();@@ -38846,7 +38908,7 @@ var init_render = __esm(() => {});// src/evaluator/protocol.ts-import { createHash as createHash8 } from "node:crypto";+import { createHash as createHash9 } from "node:crypto";function evaluatorOutcomeMessage(code) {return EVALUATOR_OUTCOME_MESSAGES[code];}@@ -38999,7 +39061,7 @@ function decodeEvaluatorResultV2(json, maxGlbBytes, expectedRequestId) {fail9("result");if (!isSha256(value.render.artifactGlbSha256))fail9("result");- const actualHash = `sha256:${createHash8("sha256").update(glb).digest("hex")}`;+ const actualHash = `sha256:${createHash9("sha256").update(glb).digest("hex")}`;if (actualHash !== value.render.artifactGlbSha256)fail9("result");const diagnosticViews = value.render.diagnosticViews;@@ -39397,7 +39459,7 @@ __export(exports_program_store_node, {FileProgramStore: () => FileProgramStore,localProgramStore: () => localProgramStore});-import { link as link2, lstat as lstat4, mkdir as mkdir3, readFile as readFile2, readdir as readdir2, stat as stat2, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";+import { link as link2, lstat as lstat4, mkdir as mkdir3, readFile as readFile3, readdir as readdir2, stat as stat2, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";import { randomUUID as randomUUID3 } from "node:crypto";import { join as join4 } from "node:path";@@ -39438,7 +39500,7 @@ class FileProgramStore {try {if ((await stat2(path)).size > MAX_PROGRAM_BYTES)throw new Error("Stored program exceeds the 1 MiB source limit.");- code = await readFile2(path, "utf8");+ code = await readFile3(path, "utf8");} catch (error) {if (error.code === "ENOENT")throw this.notFound(ref);@@ -39457,7 +39519,7 @@ class FileProgramStore {const info = await lstat4(path);if (!info.isFile() || info.size !== 71)throw new Error(`Program handle integrity check failed: ${handle}`);- const canonical = await readFile2(path, "utf8");+ const canonical = await readFile3(path, "utf8");if (!canonicalProgramRefPattern.test(canonical) || !canonical.slice(7).startsWith(handle.slice(2)))throw new Error(`Program handle integrity check failed: ${handle}`);return canonical;@@ -39526,7 +39588,7 @@ var init_program_store_node = __esm(() => {});// src/build-cache.ts-import { createHash as createHash9 } from "node:crypto";+import { createHash as createHash10 } from "node:crypto";import * as acorn2 from "acorn";import * as walk5 from "acorn-walk";function sourceHasAmbientInputs(code) {@@ -39672,7 +39734,7 @@ function createCachedEvaluatorPort(evaluator, options) {} catch {return evaluator.render(code, renderOptions, controls);}- const key = `sha256:${createHash9("sha256").update(serialized).digest("hex")}`;+ const key = `sha256:${createHash10("sha256").update(serialized).digest("hex")}`;const cached = await options.cache.get(key).catch(() => {return;});@@ -39723,10 +39785,10 @@ var init_build_cache = __esm(() => {});// src/build-cache-node.ts-import { createHash as createHash10, randomUUID as randomUUID4 } from "node:crypto";+import { createHash as createHash11, randomUUID as randomUUID4 } from "node:crypto";import {mkdir as mkdir4,- readFile as readFile3,+ readFile as readFile4,readdir as readdir3,rename as rename3,stat as stat3,@@ -39756,7 +39818,7 @@ class FileBuildCache {const entry = await stat3(path);if (entry.size > this.maxBytes || entry.size > 96 * 1024 * 1024)return;- const envelope = JSON.parse(await readFile3(path, "utf8"));+ const envelope = JSON.parse(await readFile4(path, "utf8"));if (envelope.version !== 1 || envelope.key !== key || typeof envelope.payload !== "string" || envelope.checksum !== digest3(envelope.payload))return;const decoded = decodeEvaluatorResultV2(envelope.payload, 64 * 1024 * 1024);@@ -39806,7 +39868,7 @@ class FileBuildCache {}}}-var keyPattern, filePattern, digest3 = (text) => createHash10("sha256").update(text).digest("hex");+var keyPattern, filePattern, digest3 = (text) => createHash11("sha256").update(text).digest("hex");var init_build_cache_node = __esm(() => {init_protocol();keyPattern = /^sha256:[a-f0-9]{64}$/;@@ -39814,8 +39876,8 @@ var init_build_cache_node = __esm(() => {});// src/runtime-identity.ts-import { createHash as createHash11 } from "node:crypto";-import { lstat as lstat5, readFile as readFile4, readdir as readdir4, realpath as realpath3, stat as stat4 } from "node:fs/promises";+import { createHash as createHash12 } from "node:crypto";+import { lstat as lstat5, readFile as readFile5, readdir as readdir4, realpath as realpath3, stat as stat4 } from "node:fs/promises";import { createRequire } from "node:module";import { dirname as dirname4, join as join6, relative as relative2 } from "node:path";async function installedRuntimeIdentity(root, limits = {}) {@@ -39824,7 +39886,7 @@ async function installedRuntimeIdentity(root, limits = {}) {const absentPackages = [];const maxBytes = limits.maxBytes ?? 512 * 1024 * 1024;const maxFiles = limits.maxFiles ?? 40000;- const manifest = async (directory) => JSON.parse(await readFile4(join6(directory, "package.json"), "utf8"));+ const manifest = async (directory) => JSON.parse(await readFile5(join6(directory, "package.json"), "utf8"));let readers = 0;const waiting = [];const read = async (path) => {@@ -39837,7 +39899,7 @@ async function installedRuntimeIdentity(root, limits = {}) {if (++files > maxFiles || bytes + info.size > maxBytes)throw new Error("Installed runtime fingerprint exceeds its scan budget.");bytes += info.size;- return await readFile4(path);+ return await readFile5(path);} finally {const next = waiting.shift();if (next)@@ -39850,7 +39912,7 @@ async function installedRuntimeIdentity(root, limits = {}) {const pkg = await manifest(root);if (pkg.name !== "@instruktlabs/kiln")throw new Error("Not a Kiln installation.");- const build = JSON.parse(await readFile4(join6(root, "dist", "build.json"), "utf8"));+ const build = JSON.parse(await readFile5(join6(root, "dist", "build.json"), "utf8"));const worker = build.entries?.worker;if (build.schemaVersion !== 1 || worker?.file !== "evaluator-worker.mjs" || !/^sha256:[a-f0-9]{64}$/.test(worker.identity))throw new Error("No valid packaged worker identity.");@@ -39976,7 +40038,7 @@ async function installedRuntimeIdentity(root, limits = {}) {};}}-var digest4 = (bytes) => createHash11("sha256").update(bytes).digest("hex"), compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;+var digest4 = (bytes) => createHash12("sha256").update(bytes).digest("hex"), compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;var init_runtime_identity = () => {};// src/projects.ts@@ -40148,7 +40210,7 @@ var init_projects = __esm(() => {});// src/projects-node.ts-import { createHash as createHash12, randomUUID as randomUUID5 } from "node:crypto";+import { createHash as createHash13, randomUUID as randomUUID5 } from "node:crypto";import { link as link3, lstat as lstat6, mkdir as mkdir5, open as open3, readdir as readdir5, realpath as realpath4, unlink as unlink4 } from "node:fs/promises";import { join as join7, relative as relative3, resolve as resolve7, sep as sep2 } from "node:path";function sequenceOf(revisionId) {@@ -40160,7 +40222,7 @@ function sequenceOf(revisionId) {}function digest5(record) {const { revisionId: _, ...payload } = record;- return createHash12("sha256").update(JSON.stringify(payload)).digest("hex");+ return createHash13("sha256").update(JSON.stringify(payload)).digest("hex");}class FileProjectStore {@@ -40681,13 +40743,13 @@ var init_assets = __esm(() => {// src/live-review-node.tsimport { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";-import { createHash as createHash13, randomUUID as randomUUID6 } from "node:crypto";+import { createHash as createHash14, randomUUID as randomUUID6 } from "node:crypto";import {link as link4,mkdir as mkdir6,lstat as lstat7,readdir as readdir6,- readFile as readFile5,+ readFile as readFile6,rename as rename4,rm as rm2,unlink as unlink5,@@ -40916,7 +40978,7 @@ class FileLiveReview {const info = await lstat7(path);if (!info.isFile() || info.isSymbolicLink() || info.size > limit)throw new Error("Invalid live file");- const data = new Uint8Array(await readFile5(path));+ const data = new Uint8Array(await readFile6(path));if (data.length !== info.size || data.length > limit)throw new Error("Live file changed while reading");return data;@@ -41475,7 +41537,7 @@ class FileLiveReview {});}}-var operationPattern, filePattern2, hash5 = (value) => `sha256:${createHash13("sha256").update(value).digest("hex")}`, metadataLimit, evaluationLimit, staleMs = 120000, terminal = (op) => !["running", "evaluated"].includes(op.status), missing2 = (error) => error.code === "ENOENT", collision = (error) => error.code === "EEXIST", fileLimit = (name) => name === "asset.glb" ? ASSET_LIMIT : name === "source.kiln.js" ? 1024 * 1024 : name === "evaluation.json" ? evaluationLimit : 16 * 1024 * 1024, descriptorSchema, operationSchema, stateSchema;+var operationPattern, filePattern2, hash5 = (value) => `sha256:${createHash14("sha256").update(value).digest("hex")}`, metadataLimit, evaluationLimit, staleMs = 120000, terminal = (op) => !["running", "evaluated"].includes(op.status), missing2 = (error) => error.code === "ENOENT", collision = (error) => error.code === "EEXIST", fileLimit = (name) => name === "asset.glb" ? ASSET_LIMIT : name === "source.kiln.js" ? 1024 * 1024 : name === "evaluation.json" ? evaluationLimit : 16 * 1024 * 1024, descriptorSchema, operationSchema, stateSchema;var init_live_review_node = __esm(() => {init_assets();operationPattern = /^op_[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;@@ -41581,9 +41643,9 @@ __export(exports_assets_node, {localAssetLibrary: () => localAssetLibrary,verifyAssetRecord: () => verifyAssetRecord});-import { createHash as createHash14, randomUUID as randomUUID7 } from "node:crypto";+import { createHash as createHash15, randomUUID as randomUUID7 } from "node:crypto";import { readFileSync as readFileSync2 } from "node:fs";-import { link as link5, lstat as lstat8, mkdir as mkdir7, readFile as readFile6, readdir as readdir7, realpath as realpath6, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";+import { link as link5, lstat as lstat8, mkdir as mkdir7, readFile as readFile7, readdir as readdir7, realpath as realpath6, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";import { homedir, platform } from "node:os";import { dirname as dirname5, join as join10, relative as relative5, resolve as resolve9, sep as sep4, win32 } from "node:path";function assertMaterialAllocation(records) {@@ -41685,7 +41747,7 @@ class FileAssetLibrary {const info = await lstat8(path);if (!info.isFile() || info.isSymbolicLink() || info.size > limit)throw new Error("Invalid collection file");- return new Uint8Array(await readFile6(path));+ return new Uint8Array(await readFile7(path));}async read(collection, assetId, revisionId) {const dir = await this.path(collection, assetId, "revisions", revisionId);@@ -41891,7 +41953,7 @@ function localAssetLibrary(env = process.env, operatingSystem = platform()) {library: defaultUserLibraryRoot(env, homedir(), operatingSystem)}, materials);}-var digest6 = (bytes) => `sha256:${createHash14("sha256").update(bytes).digest("hex")}`, windowsDrivePath, windowsSharePath;+var digest6 = (bytes) => `sha256:${createHash15("sha256").update(bytes).digest("hex")}`, windowsDrivePath, windowsSharePath;var init_assets_node = __esm(() => {init_workspace_location();init_assets();@@ -41904,12 +41966,292 @@ var init_assets_node = __esm(() => {windowsSharePath = /^[\\/]{2}[^\\/]+[\\/][^\\/]+/;});+// src/runtime-textures.ts+async function sha256Hex3(bytes) {+ const digest = await crypto.subtle.digest("SHA-256", Uint8Array.from(bytes));+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");+}+function imageDimensions(bytes) {+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);+ const fail = () => {+ throw new Error("Texture manifest cannot read image dimensions");+ };+ const at = (offset, length) => {+ if (offset + length > bytes.byteLength)+ fail();+ };+ if (bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71) {+ at(16, 8);+ return { width: view.getUint32(16), height: view.getUint32(20) };+ }+ if (isKtx2(bytes)) {+ at(20, 8);+ return { width: view.getUint32(20, true), height: view.getUint32(24, true) };+ }+ if (bytes[0] === 255 && bytes[1] === 216) {+ let offset = 2;+ while (offset + 4 <= bytes.byteLength) {+ if (bytes[offset] !== 255)+ fail();+ const marker = bytes[offset + 1];+ if (marker === 255) {+ offset++;+ continue;+ }+ if (marker === 216 || marker === 1 || marker >= 208 && marker <= 215) {+ offset += 2;+ continue;+ }+ const length = view.getUint16(offset + 2);+ if (marker >= 192 && marker <= 207 && ![196, 200, 204].includes(marker)) {+ at(offset + 5, 4);+ return { width: view.getUint16(offset + 7), height: view.getUint16(offset + 5) };+ }+ offset += 2 + length;+ }+ fail();+ }+ const text = (offset) => String.fromCharCode(...bytes.subarray(offset, Math.min(offset + 4, bytes.byteLength)));+ if (text(0) === "RIFF" && text(8) === "WEBP") {+ at(12, 19);+ const chunk = text(12);+ if (chunk === "VP8X")+ return {+ width: 1 + (view.getUint32(24, true) & 16777215),+ height: 1 + (view.getUint32(27, true) & 16777215)+ };+ if (chunk === "VP8L") {+ const bits = view.getUint32(21, true);+ return { width: 1 + (bits & 16383), height: 1 + (bits >> 14 & 16383) };+ }+ if (chunk === "VP8 ") {+ at(26, 4);+ return {+ width: view.getUint16(26, true) & 16383,+ height: view.getUint16(28, true) & 16383+ };+ }+ }+ return fail();+}+function textureSource(texture) {+ if (!object2(texture))+ return;+ const extensions = object2(texture.extensions) ? texture.extensions : {};+ for (const name of ["KHR_texture_basisu", "EXT_texture_webp", "EXT_texture_avif"]) {+ const extension = extensions[name];+ if (object2(extension) && index(extension.source) !== undefined)+ return index(extension.source);+ }+ return index(texture.source);+}+function srgbImages(json) {+ const textures = Array.isArray(json.textures) ? json.textures : [];+ const result = new Set;+ for (const material of Array.isArray(json.materials) ? json.materials : []) {+ if (!object2(material))+ continue;+ const pbr = object2(material.pbrMetallicRoughness) ? material.pbrMetallicRoughness : {};+ for (const info of [pbr.baseColorTexture, material.emissiveTexture]) {+ const texture = object2(info) ? index(info.index) : undefined;+ const image = texture === undefined ? undefined : textureSource(textures[texture]);+ if (image !== undefined)+ result.add(image);+ }+ }+ return result;+}+function base64(text) {+ const binary = atob(text);+ return Uint8Array.from(binary, (character) => character.charCodeAt(0));+}+function embeddedImages(json, binary) {+ const views = Array.isArray(json.bufferViews) ? json.bufferViews : [];+ return (Array.isArray(json.images) ? json.images : []).map((image) => {+ if (!object2(image))+ throw new Error("Invalid glTF image");+ const view = index(image.bufferView);+ if (view !== undefined) {+ const def = views[view];+ if (!object2(def) || index(def.buffer) !== 0 || !binary)+ throw new Error("Texture manifest requires images embedded in the GLB binary chunk");+ const offset = index(def.byteOffset) ?? 0;+ const length = index(def.byteLength);+ if (length === undefined || offset + length > binary.byteLength)+ throw new Error("Invalid glTF image buffer view");+ if (typeof image.mimeType !== "string")+ throw new Error("Embedded image needs a mimeType");+ return { bytes: binary.subarray(offset, offset + length), mimeType: image.mimeType };+ }+ const match = typeof image.uri === "string" ? /^data:([^;,]+);base64,(.*)$/s.exec(image.uri) : null;+ if (!match)+ throw new Error("Texture manifest requires embedded image bytes");+ return { bytes: base64(match[2]), mimeType: match[1] };+ });+}+async function runtimeTextureManifest(json, binary, options = {}) {+ const srgb = srgbImages(json);+ const entries = [];+ for (const [image, { bytes, mimeType }] of embeddedImages(json, binary).entries()) {+ const sha256 = `sha256:${await sha256Hex3(bytes)}`;+ const sourceSha256 = options.sources?.get(image);+ const original = sourceSha256 ?? sha256;+ const map = options.maps?.find((candidate) => candidate.sha256 === original);+ entries.push({+ image,+ sha256,+ bytes: bytes.byteLength,+ mimeType,+ ...imageDimensions(bytes),+ colorSpace: srgb.has(image) ? "srgb" : "linear",+ ...sourceSha256 && sourceSha256 !== sha256 ? { sourceSha256 } : {},+ ...map ? { material: { pin: { ...map.pin }, slot: map.slot } } : {}+ });+ }+ return entries;+}+function textureFileExtension(mimeType) {+ const extension = {+ "image/png": "png",+ "image/jpeg": "jpg",+ "image/webp": "webp",+ "image/ktx2": "ktx2"+ }[mimeType];+ if (!extension)+ throw new Error(`External textures do not support ${mimeType}`);+ return extension;+}+var object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), index = (value) => Number.isInteger(value) && value >= 0 ? value : undefined, KTX2_IDENTIFIER, isKtx2 = (bytes) => bytes.byteLength >= 12 && KTX2_IDENTIFIER.every((value, at) => bytes[at] === value);+var init_runtime_textures = __esm(() => {+ KTX2_IDENTIFIER = Object.freeze([+ 171,+ 75,+ 84,+ 88,+ 32,+ 50,+ 48,+ 187,+ 13,+ 10,+ 26,+ 10+ ]);+});++// src/ktx2-basis.ts+import { createHash as createHash16 } from "node:crypto";+import { readFile as readFile8 } from "node:fs/promises";+import { dirname as dirname6, join as join11 } from "node:path";+import { fileURLToPath as fileURLToPath4, pathToFileURL } from "node:url";+async function packageDirectory() {+ let directory = dirname6(fileURLToPath4(import.meta.resolve(KTX2_ENCODER_PACKAGE.name)));+ for (let depth = 0;depth < 6; depth++) {+ try {+ const manifest = JSON.parse(await readFile8(join11(directory, "package.json"), "utf8"));+ if (manifest.name === KTX2_ENCODER_PACKAGE.name)+ return directory;+ } catch {}+ directory = dirname6(directory);+ }+ throw new Error(`Cannot locate the installed ${KTX2_ENCODER_PACKAGE.name} package`);+}+async function loadKtx2Encoder(importer = () => import("ktx2-encoder")) {+ let module;+ try {+ module = await importer();+ } catch (error) {+ throw new Error(`KTX2 encoding needs the optional peer ${KTX2_ENCODER_PACKAGE.name}@${KTX2_ENCODER_PACKAGE.version}. Install it with: ${INSTALL}`, { cause: error });+ }+ if (typeof module?.encodeToKTX2 !== "function")+ throw new Error(`${KTX2_ENCODER_PACKAGE.name} has no encodeToKTX2 export. ${INSTALL}`);+ const directory = await packageDirectory();+ const { version } = JSON.parse(await readFile8(join11(directory, "package.json"), "utf8"));+ if (version !== KTX2_ENCODER_PACKAGE.version)+ throw new Error(`${KTX2_ENCODER_PACKAGE.name} ${version} is installed; Kiln's KTX2 settings are qualified on ${KTX2_ENCODER_PACKAGE.version}. ${INSTALL}`);+ let basisWasmSha256;+ try {+ basisWasmSha256 = `sha256:${hex2(await readFile8(join11(directory, "dist", "basis", "basis_encoder.wasm")))}`;+ } catch {}+ const internal = (path) => import(pathToFileURL(join11(directory, "dist", path)).href);+ const [factory, core] = await Promise.all([+ internal("basis/basis_encoder.js"),+ internal("encodeCore.js")+ ]);+ if (typeof factory.default !== "function" || typeof core.encodeWithModule !== "function")+ throw new Error(`${KTX2_ENCODER_PACKAGE.name} ${version} has an unexpected layout. ${INSTALL}`);+ basis ??= factory.default({ print: () => {}, printErr: () => {} }).then((instance) => {+ instance.initializeBasis();+ return instance;+ });+ const instance = basis;+ return {+ encode: async (image, options) => core.encodeWithModule(await instance, image, options),+ version,+ ...basisWasmSha256 ? { basisWasmSha256 } : {}+ };+}+async function createKtx2Encoder(options = {}) {+ const { encode: run, version, basisWasmSha256 } = await loadKtx2Encoder(options.importer);+ const identity = {+ name: KTX2_ENCODER_PACKAGE.name,+ version,+ ...basisWasmSha256 ? { basisWasmSha256 } : {},+ settings: structuredClone({ ...SETTINGS })+ };+ const encode = async (input) => {+ const { mode: _mode, ...settings } = profile(input);+ return run(input.image, { ...settings, imageDecoder: decode });+ };+ return Object.assign(encode, { identity });+}+var KTX2_ENCODER_PACKAGE, INSTALL, SETTINGS, profile = (input) => input.colorSpace === "srgb" ? SETTINGS.srgb : input.slot === "normal" ? SETTINGS.normal : SETTINGS.linear, hex2 = (bytes) => createHash16("sha256").update(bytes).digest("hex"), basis, decode = async (buffer) => {+ const { default: sharp } = await import("sharp");+ const { data, info } = await sharp(buffer).ensureAlpha().raw().toBuffer({ resolveWithObject: true });+ return { data: new Uint8Array(data), width: info.width, height: info.height };+};+var init_ktx2_basis = __esm(() => {+ KTX2_ENCODER_PACKAGE = Object.freeze({ name: "ktx2-encoder", version: "0.6.0" });+ INSTALL = `npm install ${KTX2_ENCODER_PACKAGE.name}@${KTX2_ENCODER_PACKAGE.version}`;+ SETTINGS = Object.freeze({+ srgb: Object.freeze({+ mode: "etc1s",+ isUASTC: false,+ qualityLevel: 128,+ compressionLevel: 2,+ generateMipmap: true,+ isSetKTX2SRGBTransferFunc: true,+ isPerceptual: true+ }),+ linear: Object.freeze({+ mode: "uastc",+ isUASTC: true,+ uastcLDRQualityLevel: 2,+ needSupercompression: true,+ generateMipmap: true,+ isSetKTX2SRGBTransferFunc: false,+ isPerceptual: false+ }),+ normal: Object.freeze({+ mode: "uastc",+ isUASTC: true,+ uastcLDRQualityLevel: 2,+ needSupercompression: true,+ generateMipmap: true,+ isSetKTX2SRGBTransferFunc: false,+ isPerceptual: false,+ isNormalMap: true+ })+ });+});+// src/runtime-three.tsvar exports_runtime_three = {};__export(exports_runtime_three, {deliverRuntimeThreeGlb: () => deliverRuntimeThreeGlb});import {+ Format,Logger as Logger2,PropertyType as PropertyType5} from "@gltf-transform/core";@@ -41994,7 +42336,7 @@ function splitColliderProxies(doc) {}return report;}-async function encodeKtx2(doc, encoder) {+async function encodeKtx2(doc, encoder, sources) {const textures = doc.getRoot().listTextures().filter((texture) => texture.getMimeType() !== "image/ktx2" && texture.getImage());if (!encoder)return {@@ -42002,29 +42344,62 @@ async function encodeKtx2(doc, encoder) {textures: textures.length,reason: "No KTX2 encoder was supplied; textures stay PNG or JPEG."};- const srgb = new Set;+ const slots = new Map;+ const use = (texture, slot) => {+ if (texture)+ slots.set(texture, (slots.get(texture) ?? new Set).add(slot));+ };for (const material of doc.getRoot().listMaterials()) {- for (const texture of [material.getBaseColorTexture(), material.getEmissiveTexture()])- if (texture)- srgb.add(texture);+ use(material.getBaseColorTexture(), "baseColor");+ use(material.getEmissiveTexture(), "emissive");+ use(material.getNormalTexture(), "normal");+ use(material.getMetallicRoughnessTexture(), "metallicRoughness");+ use(material.getOcclusionTexture(), "occlusion");}+ const order = [+ "baseColor",+ "emissive",+ "normal",+ "metallicRoughness",+ "occlusion"+ ];for (const texture of textures) {+ const used = slots.get(texture) ?? new Set;+ const srgb = used.has("baseColor") || used.has("emissive");+ const other = texture.listParents().some((parent) => parent.propertyType !== PropertyType5.ROOT && !isCoreMaterialUse(parent));+ const linear = [...used].some((slot) => slot !== "baseColor" && slot !== "emissive") || other;+ if (srgb && linear)+ throw new Error(`Texture ${JSON.stringify(texture.getName())} is used by both sRGB and linear material slots; one KTX2 encoding cannot serve both. Use separate images.`);+ const original = texture.getImage();const image = await encoder({- image: texture.getImage(),+ image: original,mimeType: texture.getMimeType(),name: texture.getName(),- colorSpace: srgb.has(texture) ? "srgb" : "linear"+ colorSpace: srgb ? "srgb" : "linear",+ slot: order.find((slot) => used.has(slot)) ?? "other"});- if (!(image instanceof Uint8Array) || image.byteLength < 12)- throw new Error("ktx2Encoder must return KTX2 bytes");+ if (!(image instanceof Uint8Array) || !isKtx2(image))+ throw new Error("ktx2Encoder must return KTX2 bytes starting with the KTX2 identifier");+ sources.set(texture, `sha256:${await sha256Hex3(original)}`);texture.setImage(image).setMimeType("image/ktx2");const uri = texture.getURI();if (uri)texture.setURI(uri.replace(/\.(png|jpe?g)$/i, ".ktx2"));}- if (textures.length)+ if (textures.length) {doc.createExtension(KHRTextureBasisu2).setRequired(true);- return { status: "encoded", textures: textures.length };+ await Promise.resolve().then(() => init_atlas_provenance());+ await refreshAtlasDocumentProvenance(doc);+ await validateAtlasDocumentProvenance(doc);+ }+ return {+ status: "encoded",+ textures: textures.length,+ ...encoder.identity ? { encoder: structuredClone(encoder.identity) } : {}+ };+}+function isCoreMaterialUse(parent) {+ return parent.propertyType === PropertyType5.MATERIAL;}function decomposeDelta(before, after) {const delta = new THREE55.Matrix4().fromArray(before).invert().multiply(new THREE55.Matrix4().fromArray(after));@@ -42035,7 +42410,7 @@ function decomposeDelta(before, after) {offset: [position.x, position.y, position.z]};}-async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}) {+async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}, layout = {}) {const compression = options.compression ?? "meshopt";if (compression !== "meshopt" && compression !== "none")throw new Error("Runtime three compression must be meshopt or none");@@ -42063,7 +42438,8 @@ async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}) {}));if (compression === "meshopt")doc.createExtension(EXTMeshoptCompression).setRequired(true).setEncoderOptions({ method: EXTMeshoptCompression.EncoderMethod.QUANTIZE });- const ktx2 = await encodeKtx2(doc, options.ktx2Encoder);+ const encodedSources = new Map;+ const ktx2 = await encodeKtx2(doc, options.ktx2Encoder, encodedSources);for (const node of doc.getRoot().listNodes()) {const mesh = node.getMesh();if (!mesh || matrices.has(node) || node.getName())@@ -42122,6 +42498,13 @@ async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}) {const all = doc.getRoot().listNodes();const glb = await io.writeBinary(doc);const json = (await io.binaryToJSON(glb)).json;+ const imageSources = new Map;+ doc.getRoot().listTextures().forEach((texture, image) => {+ const source = encodedSources.get(texture);+ if (source)+ imageSources.set(image, source);+ });+ const gltf = layout.gltfBasename ? await io.writeJSON(doc, { format: Format.GLTF, basename: layout.gltfBasename }) : undefined;const delivery = {target: "three",extensionsUsed: [...json.extensionsUsed ?? []].sort(),@@ -42161,7 +42544,17 @@ async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}) {kitModules: all.filter((node) => rolesOf4(node).includes(KILN_SEMANTIC_ROLES.kitModule)).length}};- return { glb, delivery };+ return {+ glb,+ delivery,+ imageSources,+ ...gltf ? {+ gltf: {+ json: gltf.json,+ resources: gltf.resources+ }+ } : {}+ };}var RUNTIME_THREE_QUANTIZATION, QUANTIZED_SEMANTICS, customRank = (name) => name === "_EDGE" ? 0 : name === "_CAVITY" ? 1 : 2, rolesOf4 = (node) => readSemanticMetadataV1FromExtras(node.getExtras())?.roles ?? [], isCollider = (node) => rolesOf4(node).some((role) => role.startsWith(`${KILN_SEMANTIC_ROLES.collider}.`));var init_runtime_three = __esm(() => {@@ -42170,6 +42563,7 @@ var init_runtime_three = __esm(() => {init_delivery_inspect();init_delivery();init_metrics();+ init_runtime_textures();RUNTIME_THREE_QUANTIZATION = Object.freeze({volume: "mesh",position: 14,@@ -42184,6 +42578,7 @@ var init_runtime_three = __esm(() => {// src/asset-export.tsvar exports_asset_export = {};__export(exports_asset_export, {+ createKtx2Encoder: () => createKtx2Encoder2,exportAssetGlb: () => exportAssetGlb});async function sha2562(bytes) {@@ -42194,6 +42589,36 @@ function validateMetadataFileName(name) {if (name.length > 200 || !/^[a-z0-9][a-z0-9._-]*\.kiln-metadata\.json$/i.test(name) || /^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(name))throw new Error("Runtime metadata filename must be a portable sibling *.kiln-metadata.json filename");}+function validateGltfFileName(name) {+ if (name.length > 200 || !/^[a-z0-9][a-z0-9._-]*\.gltf$/i.test(name) || /^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(name))+ throw new Error("External texture output must be a portable sibling *.gltf filename");+}+function readGlbBinary(bytes, jsonEnd) {+ if (jsonEnd + 8 > bytes.length)+ return;+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);+ if (view.getUint32(jsonEnd + 4, true) !== 5130562)+ return;+ return bytes.subarray(jsonEnd + 8, jsonEnd + 8 + view.getUint32(jsonEnd, true));+}+function closureMaps(record) {+ const manifests = new Map;+ for (const manifest of [+ ...assetMaterialRootManifests(record),+ ...(record.materialResources?.records ?? []).map(({ manifest }) => manifest)+ ])+ manifests.set(`${manifest.materialId}/${manifest.revisionId}`, manifest);+ const order = (value, other) => value < other ? -1 : value > other ? 1 : 0;+ return [...manifests.values()].flatMap((manifest) => manifest.maps.map((map) => ({+ sha256: map.sha256,+ pin: {+ resourceId: manifest.materialId,+ revisionId: manifest.revisionId,+ sha256: manifest.revisionId+ },+ slot: map.slot+ }))).sort((a, b) => order(a.pin.resourceId, b.pin.resourceId) || order(a.pin.revisionId, b.pin.revisionId) || order(a.slot, b.slot));+}function readGlbJson(bytes) {const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);let end = 12;@@ -42207,7 +42632,7 @@ function readGlbJson(bytes) {}const jsonEnd = 20 + view.getUint32(12, true);const json = JSON.parse(decoder.decode(bytes.subarray(20, jsonEnd)));- if (!object2(json) || !object2(json.asset) || json.asset.version !== "2.0")+ if (!object3(json) || !object3(json.asset) || json.asset.version !== "2.0")throw new Error("Invalid glTF asset");return { json, jsonEnd };}@@ -42226,13 +42651,17 @@ function writeGlbJson(bytes, jsonEnd, json) {result.set(bytes.subarray(jsonEnd), 20 + length);return result;}-async function deliverThreeRuntimeGlb(glb, options = {}) {+async function createKtx2Encoder2() {+ await Promise.resolve().then(() => init_ktx2_basis());+ return createKtx2Encoder();+}+async function deriveThree(glb, options, layout = {}) {const [{ deliverRuntimeThreeGlb }, { MeshoptEncoder }] = await Promise.all([Promise.resolve().then(() => (init_runtime_three(), exports_runtime_three)),import("meshoptimizer")]);await MeshoptEncoder.ready;- const result = await deliverRuntimeThreeGlb(glb, MeshoptEncoder, options);+ const result = await deliverRuntimeThreeGlb(glb, MeshoptEncoder, options, layout);if (result.glb.byteLength > ASSET_LIMIT)throw new Error("Runtime export exceeds 64 MiB");return result;@@ -42247,6 +42676,16 @@ async function exportAssetGlb(record, options = {}) {throw new Error("A runtime export target requires the runtime profile");if (options.compression !== undefined && options.target !== "three")throw new Error("Runtime compression requires the three runtime target");+ const textures = options.textures;+ if (textures !== undefined && textures !== "manifest" && textures !== "external")+ throw new Error("Unknown runtime texture option");+ if (textures !== undefined && profile !== "runtime")+ throw new Error("A texture manifest requires the runtime profile");+ if (textures === "external" && options.target !== "three")+ throw new Error("External textures require target three");+ const gltfName = options.gltfFileName ?? "runtime.gltf";+ if (textures === "external")+ validateGltfFileName(gltfName);validateRecordShape(record);const bytes = record.files["asset.glb"];if (profile === "editable")@@ -42259,7 +42698,7 @@ async function exportAssetGlb(record, options = {}) {}const { json, jsonEnd } = readGlbJson(bytes);const asset = json.asset;- if (owns(asset, "extras") && !object2(asset.extras))+ if (owns(asset, "extras") && !object3(asset.extras))throw new Error("Cannot add provenance to non-object asset extras");const extras = asset.extras ?? {};if (owns(extras, "kilnProvenanceV1"))@@ -42268,10 +42707,10 @@ async function exportAssetGlb(record, options = {}) {if (json.scenes !== undefined && !Array.isArray(json.scenes))throw new Error("Invalid glTF scenes");for (const [index, scene] of (json.scenes ?? []).entries()) {- if (!object2(scene) || !object2(scene.extras) || !owns(scene.extras, "kilnReviewClipsV1"))+ if (!object3(scene) || !object3(scene.extras) || !owns(scene.extras, "kilnReviewClipsV1"))continue;const review = scene.extras.kilnReviewClipsV1;- if (!object2(review) || review.version !== 1 && review.version !== 2 || !Array.isArray(review.clips))+ if (!object3(review) || review.version !== 1 && review.version !== 2 || !Array.isArray(review.clips))throw new Error("Unsupported scenes[].extras.kilnReviewClipsV1");scenes.push({ index, kilnReviewClipsV1: review });delete scene.extras.kilnReviewClipsV1;@@ -42286,36 +42725,89 @@ async function exportAssetGlb(record, options = {}) {},scenes};- let base = bytes, baseJson = json, baseJsonEnd = jsonEnd;+ let base = bytes, baseJson = json, baseJsonEnd = jsonEnd, imageSources, gltf;if (options.target === "three") {- const derived = await deliverThreeRuntimeGlb(writeGlbJson(bytes, jsonEnd, json), {+ const derived = await deriveThree(writeGlbJson(bytes, jsonEnd, json), {...options.ktx2Encoder ? { ktx2Encoder: options.ktx2Encoder } : {},...options.compression ? { compression: options.compression } : {}- });+ }, textures === "external" ? { gltfBasename: gltfName.slice(0, -".gltf".length) } : {});metadata.target = "three";metadata.delivery = derived.delivery;base = derived.glb;+ imageSources = derived.imageSources;+ gltf = derived.gltf;({ json: baseJson, jsonEnd: baseJsonEnd } = readGlbJson(base));}+ if (textures !== undefined)+ metadata.textures = await runtimeTextureManifest(baseJson, readGlbBinary(base, baseJsonEnd), {+ ...imageSources ? { sources: imageSources } : {},+ maps: closureMaps(record)+ });+ const external = gltf ? await externalLayout(gltf, metadata.textures ?? []) : undefined;const metadataBytes = encoder2.encode(JSON.stringify(metadata));if (metadataBytes.length > ASSET_LIMIT)throw new Error("Runtime export exceeds 64 MiB");+ const provenance = {+ version: "kiln.provenance.v1",+ profile: "runtime",+ ...options.target ? { target: options.target } : {},+ metadata: { uri: name, sha256: await sha2562(metadataBytes) }+ };const baseAsset = baseJson.asset;baseAsset.extras = {...baseAsset.extras ?? extras,- kilnProvenanceV1: {- version: "kiln.provenance.v1",- profile: "runtime",- ...options.target ? { target: options.target } : {},- metadata: { uri: name, sha256: await sha2562(metadataBytes) }- }+ kilnProvenanceV1: provenance};const result = writeGlbJson(base, baseJsonEnd, baseJson);- return { profile, glb: result, metadata: { name, bytes: metadataBytes } };+ if (!external)+ return { profile, glb: result, metadata: { name, bytes: metadataBytes } };+ const gltfAsset = external.json.asset;+ gltfAsset.extras = {+ ...gltfAsset.extras ?? extras,+ kilnProvenanceV1: provenance+ };+ const gltfBytes = encoder2.encode(JSON.stringify(external.json));+ if (gltfBytes.length > ASSET_LIMIT)+ throw new Error("Runtime export exceeds 64 MiB");+ return {+ profile,+ layout: "gltf",+ glb: result,+ gltf: { name: gltfName, bytes: gltfBytes },+ buffers: external.buffers,+ textures: external.textures,+ metadata: { name, bytes: metadataBytes }+ };+}+async function externalLayout(gltf, manifest) {+ const json = structuredClone(gltf.json);+ const resources = new Map(Object.entries(gltf.resources));+ const images = Array.isArray(json.images) ? json.images : [];+ if (images.length !== manifest.length)+ throw new Error("External texture layout mismatch");+ const textures = new Map;+ for (const [index, image] of images.entries()) {+ const entry = manifest[index];+ const written = typeof image.uri === "string" ? image.uri : "";+ const bytes = resources.get(written);+ if (!bytes || `sha256:${await sha256Hex3(bytes)}` !== entry.sha256)+ throw new Error("External texture bytes differ from the delivered GLB");+ resources.delete(written);+ const uri = `textures/${entry.sha256.slice("sha256:".length)}.${textureFileExtension(entry.mimeType)}`;+ image.uri = uri;+ entry.uri = uri;+ textures.set(uri, { uri, sha256: entry.sha256, bytes });+ }+ const buffers = [...resources].map(([uri, bytes]) => ({ uri, bytes }));+ for (const { uri } of buffers)+ if (!/^[a-z0-9][a-z0-9._-]*\.bin$/i.test(uri))+ throw new Error(`Unexpected external glTF resource ${uri}`);+ return { json, buffers, textures: [...textures.values()] };}-var encoder2, decoder, object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), owns = (value, key) => Object.hasOwn(value, key);+var encoder2, decoder, object3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), owns = (value, key) => Object.hasOwn(value, key);var init_asset_export = __esm(() => {init_assets();+ init_runtime_textures();encoder2 = new TextEncoder;decoder = new TextDecoder;});@@ -42641,8 +43133,8 @@ var init_project_bundle = __esm(() => {// src/project-bundle-node.tsimport { randomUUID as randomUUID8 } from "node:crypto";-import { link as link6, lstat as lstat9, mkdir as mkdir8, readFile as readFile7, realpath as realpath7, unlink as unlink6, writeFile as writeFile7 } from "node:fs/promises";-import { join as join11, relative as relative6, resolve as resolve10, sep as sep5 } from "node:path";+import { link as link6, lstat as lstat9, mkdir as mkdir8, readFile as readFile9, realpath as realpath7, unlink as unlink6, writeFile as writeFile7 } from "node:fs/promises";+import { join as join12, relative as relative6, resolve as resolve10, sep as sep5 } from "node:path";async function assetMaterials(workspace, asset) {return resolveSavedAssetMaterials(asset, workspace.materials);}@@ -42739,7 +43231,7 @@ async function retainArchive(workspace, bytes, digest) {const canonical = await realpath7(root);let directory = root;for (const part of [".kiln", "imports"]) {- directory = join11(directory, part);+ directory = join12(directory, part);await mkdir8(directory).catch((error) => {if (error.code !== "EEXIST")throw error;@@ -42749,8 +43241,8 @@ async function retainArchive(workspace, bytes, digest) {if (!info.isDirectory() || info.isSymbolicLink() || rel === ".." || rel.startsWith(`..${sep5}`))throw new Error("Unsafe project import directory");}- const file = join11(directory, `${digest.slice(7)}.zip`);- const temporary = join11(directory, `.import-${randomUUID8()}.tmp`);+ const file = join12(directory, `${digest.slice(7)}.zip`);+ const temporary = join12(directory, `.import-${randomUUID8()}.tmp`);await writeFile7(temporary, bytes, { flag: "wx", mode: 384 });try {try {@@ -42759,7 +43251,7 @@ async function retainArchive(workspace, bytes, digest) {if (error.code !== "EEXIST")throw error;const info = await lstat9(file);- if (!info.isFile() || info.isSymbolicLink() || info.size !== bytes.length || await projectBundleHash(new Uint8Array(await readFile7(file))) !== digest)+ if (!info.isFile() || info.isSymbolicLink() || info.size !== bytes.length || await projectBundleHash(new Uint8Array(await readFile9(file))) !== digest)throw new Error("Imported archive integrity mismatch");}} finally {@@ -42907,9 +43399,9 @@ var init_source_check = __esm(() => {});// src/local-runtime.ts-import { readFile as readFile8, stat as stat5 } from "node:fs/promises";-import { dirname as dirname6, isAbsolute, join as join12, resolve as resolve11 } from "node:path";-import { fileURLToPath as fileURLToPath4 } from "node:url";+import { readFile as readFile10, stat as stat5 } from "node:fs/promises";+import { dirname as dirname7, isAbsolute, join as join13, resolve as resolve11 } from "node:path";+import { fileURLToPath as fileURLToPath5 } from "node:url";import { Console } from "node:console";function workspaceSourceReader(root) {return async (file) => {@@ -42924,7 +43416,7 @@ function workspaceSourceReader(root) {throw new Error(`file ${file} was not found inside the workspace. Check the relative path, or pass code or programRef.`);if (info.size > MAX_PROGRAM_BYTES)throw new Error(`file ${file} exceeds the ${MAX_PROGRAM_BYTES / (1024 * 1024)} MiB source limit.`);- return readFile8(path, "utf8");+ return readFile10(path, "utf8");};}function integer4(env, name, fallback, min, max) {@@ -42934,7 +43426,7 @@ function integer4(env, name, fallback, min, max) {return value;}function createLocalToolContext(base = {}, env = process.env) {- const workspaceRoot = env.KILN_WORKSPACE ? resolve11(env.KILN_WORKSPACE) : base.programStore instanceof FileProgramStore ? dirname6(dirname6(base.programStore.directory)) : localWorkspaceRoot(env);+ const workspaceRoot = env.KILN_WORKSPACE ? resolve11(env.KILN_WORKSPACE) : base.programStore instanceof FileProgramStore ? dirname7(dirname7(base.programStore.directory)) : localWorkspaceRoot(env);const workspace = base.workspace ?? new FileWorkspace(workspaceRoot, env.KILN_PROJECT);const projectStore = base.projectStore ?? (workspace instanceof FileWorkspace ? workspace.projects : undefined);const liveReview = base.liveReview ?? (env.KILN_LIVE_REVIEW === "off" ? undefined : new FileLiveReview(workspaceRoot, {@@ -43044,7 +43536,7 @@ function createLocalToolContext(base = {}, env = process.env) {localExecution};}-async function createPackagedLocalToolContext(base = {}, env = process.env, installationRoot = fileURLToPath4(new URL("../", import.meta.url))) {+async function createPackagedLocalToolContext(base = {}, env = process.env, installationRoot = fileURLToPath5(new URL("../", import.meta.url))) {const context = createLocalToolContext(base, env);const managed = () => {const identity = context.evaluatorCacheIdentity;@@ -43099,7 +43591,7 @@ async function createPackagedLocalToolContext(base = {}, env = process.env, inst}const cacheBytes = integer4(env, "KILN_BUILD_CACHE_MB", 128, 0, 1024) * 1024 * 1024;const store = context.programStore;- const directory = resolve11(env.KILN_BUILD_CACHE_DIR ?? join12(store instanceof FileProgramStore ? dirname6(store.directory) : ".kiln", "cache", "builds"));+ const directory = resolve11(env.KILN_BUILD_CACHE_DIR ?? join13(store instanceof FileProgramStore ? dirname7(store.directory) : ".kiln", "cache", "builds"));context.buildCache = new FileBuildCache(directory, cacheBytes);context.evaluatorCacheIdentity = `${identity.identity}:${JSON.stringify({execution: context.localExecution,@@ -50893,7 +51385,7 @@ var init_assets_resources = __esm(() => {// src/widget-transfer.tsimport { deflateSync as deflateSync2, inflateSync as inflateSync2 } from "three/addons/libs/fflate.module.js";-function base64(bytes) {+function base642(bytes) {let binary = "";for (let index = 0;index < bytes.length; index += 8192)binary += String.fromCharCode(...bytes.subarray(index, index + 8192));@@ -50903,8 +51395,8 @@ function encodeWidgetFiles(files) {if (Object.values(files).reduce((total, bytes) => total + bytes.length, 0) > WIDGET_TRANSFER_LIMIT)invalid("exceeds the decoded size limit");return Object.fromEntries(Object.entries(files).map(([name, bytes]) => {- const plain = base64(bytes);- const compressed = base64(deflateSync2(bytes, { level: 6 }));+ const plain = base642(bytes);+ const compressed = base642(deflateSync2(bytes, { level: 6 }));return [name,compressed.length + 64 < plain.length ? { encoding: "kiln.deflate-base64.v1", data: compressed } : plain@@ -52588,18 +53080,18 @@ var init_registry2 = __esm(() => {});// render-service/src/instance.mjs-import { createHash as createHash15 } from "node:crypto";+import { createHash as createHash17 } from "node:crypto";import { readFileSync as readFileSync3, readdirSync, statSync } from "node:fs";-import { join as join13, relative as relative7 } from "node:path";+import { join as join14, relative as relative7 } from "node:path";function fingerprintSourceDir(dir) {- const hash = createHash15("sha256");+ const hash = createHash17("sha256");hash.update("kiln.render-service-source.v1");const visit = (path) => {if (statSync(path).isDirectory()) {for (const name of readdirSync(path).sort()) {if (name === "node_modules")continue;- visit(join13(path, name));+ visit(join14(path, name));}return;}@@ -52613,9 +53105,9 @@ function fingerprintSourceDir(dir) {var init_instance = () => {};// render-service/src/build-identity.mjs-import { createHash as createHash16 } from "node:crypto";+import { createHash as createHash18 } from "node:crypto";import { readFileSync as readFileSync4 } from "node:fs";-import { dirname as dirname7, join as join14 } from "node:path";+import { dirname as dirname8, join as join15 } from "node:path";import { createRequire as createRequire2 } from "node:module";function compatibilityFingerprint({ sourceFingerprint, dependencies }) {if (typeof sourceFingerprint !== "string" || !/^sha256:[a-f0-9]{64}$/.test(sourceFingerprint))@@ -52625,7 +53117,7 @@ function compatibilityFingerprint({ sourceFingerprint, dependencies }) {throw new Error(`Missing renderer dependency identity: ${name}`);return [name, dependencies[name]];}));- return `sha256:${createHash16("sha256").update(JSON.stringify({+ return `sha256:${createHash18("sha256").update(JSON.stringify({version: "kiln.render-service-build.v1",sourceFingerprint,dependencies: pins@@ -52636,20 +53128,20 @@ function resolvedRendererDependencies(anchorUrl = import.meta.url) {return Object.fromEntries(Object.entries(RENDER_SERVICE_DEPENDENCIES).map(([name, expected]) => {let dir;try {- dir = dirname7(require2.resolve(name));+ dir = dirname8(require2.resolve(name));} catch {throw new Error(`Renderer dependency ${name}@${expected} is not installed`);}let found;for (;; ) {try {- const pkg = JSON.parse(readFileSync4(join14(dir, "package.json"), "utf8"));+ const pkg = JSON.parse(readFileSync4(join15(dir, "package.json"), "utf8"));if (pkg.name === name) {found = pkg.version;break;}} catch {}- const parent = dirname7(dir);+ const parent = dirname8(dir);if (parent === dir)break;dir = parent;@@ -52675,11 +53167,11 @@ var init_build_identity = __esm(() => {});// src/render-service-client.ts-import { createHash as createHash17 } from "node:crypto";+import { createHash as createHash19 } from "node:crypto";import { existsSync as existsSync2 } from "node:fs";-import { fileURLToPath as fileURLToPath5 } from "node:url";+import { fileURLToPath as fileURLToPath6 } from "node:url";function packagedRendererSourceFingerprint() {- const source = fileURLToPath5(new URL("../render-service/src/", import.meta.url));+ const source = fileURLToPath6(new URL("../render-service/src/", import.meta.url));return existsSync2(source) ? fingerprintSourceDir(source) : undefined;}function validateRenderServiceHealth(value) {@@ -52764,7 +53256,7 @@ function makeRemoteRenderPort(url, token, sourceFingerprint) {return async (req, execution) => {const health = await verifiedHealth(url, token, sourceFingerprint, execution?.signal);execution?.signal?.throwIfAborted();- const inputGlbSha256 = `sha256:${createHash17("sha256").update(req.glb).digest("hex")}`;+ const inputGlbSha256 = `sha256:${createHash19("sha256").update(req.glb).digest("hex")}`;const body = {glb_base64: Buffer.from(req.glb).toString("base64"),input_glb_sha256: inputGlbSha256,@@ -52820,7 +53312,7 @@ var init_render_service_client = __esm(() => {// src/render-service-windows.tsimport { spawn as spawn2 } from "node:child_process";-import { join as join15 } from "node:path";+import { join as join16 } from "node:path";function powerShellLiteral(value) {return `'${value.replaceAll("'", "''")}'`;}@@ -52835,7 +53327,7 @@ function launchWindowsRenderService(executable, args, directory, env) {].join(``);const systemRoot = env.SystemRoot ?? env.SYSTEMROOT;- const powerShell = systemRoot ? join15(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe") : "powershell.exe";+ const powerShell = systemRoot ? join16(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe") : "powershell.exe";const child = spawn2(powerShell, ["-NoProfile","-NonInteractive",@@ -52885,8 +53377,8 @@ var init_render_service_windows = () => {};// src/render-service-host.tsimport { spawn as spawn3, spawnSync } from "node:child_process";import { existsSync as existsSync3 } from "node:fs";-import { fileURLToPath as fileURLToPath6, pathToFileURL } from "node:url";-import { join as join16 } from "node:path";+import { fileURLToPath as fileURLToPath7, pathToFileURL as pathToFileURL2 } from "node:url";+import { join as join17 } from "node:path";function localRenderServicePort(env = process.env) {const raw = Number(env["KILN_RENDER_SERVICE_PORT"]);return Number.isInteger(raw) && raw > 0 && raw < 65536 ? raw : DEFAULT_LOCAL_RENDER_SERVICE_PORT;@@ -52904,18 +53396,18 @@ function namesLocalRenderService(url, env = process.env) {function renderServiceNodeArguments(dir) {return ["--import",- pathToFileURL(join16(dir, "src/register-hooks.mjs")).href,- join16(dir, "src/server.mjs")+ pathToFileURL2(join17(dir, "src/register-hooks.mjs")).href,+ join17(dir, "src/server.mjs")];}function renderServiceDir() {- return process.env["KILN_RENDER_SERVICE_DIR"] || fileURLToPath6(new URL("../render-service", import.meta.url));+ return process.env["KILN_RENDER_SERVICE_DIR"] || fileURLToPath7(new URL("../render-service", import.meta.url));}function localRenderServiceState(dir = renderServiceDir()) {- if (!existsSync3(join16(dir, "src/server.mjs")) || !existsSync3(join16(dir, "package.json")))+ if (!existsSync3(join17(dir, "src/server.mjs")) || !existsSync3(join17(dir, "package.json")))return "not-packaged";try {- const anchor = pathToFileURL(join16(dir, "src/server.mjs")).href;+ const anchor = pathToFileURL2(join17(dir, "src/server.mjs")).href;if (process.versions.bun) {const moduleUrl = new URL("../render-service/src/build-identity.mjs", import.meta.url).href;const result = spawnSync(nodeBinary(), [@@ -52946,7 +53438,7 @@ function explainRenderServiceState(state, dir) {return "renderer dependencies are missing; reinstall the official Kiln package with optional dependencies enabled";}function renderServiceSourceFingerprint(dir) {- const source = join16(dir, "src");+ const source = join17(dir, "src");return existsSync3(source) ? fingerprintSourceDir(source) : undefined;}async function inspectLocalRenderService(url, dir = renderServiceDir(), timeoutMs = 1500) {@@ -53559,9 +54051,9 @@ var init_workspace_http = __esm(() => {// src/asset-viewer.tsimport { createServer } from "node:http";-import { readFile as readFile9 } from "node:fs/promises";-import { dirname as dirname8, join as join17 } from "node:path";-import { fileURLToPath as fileURLToPath7 } from "node:url";+import { readFile as readFile11 } from "node:fs/promises";+import { dirname as dirname9, join as join18 } from "node:path";+import { fileURLToPath as fileURLToPath8 } from "node:url";function quoted(value) {if (value === undefined)return "(none)";@@ -53573,7 +54065,7 @@ function refuse(res, message) {`);}async function startAssetViewer(library, options = {}) {- const staticDirectory = options.staticDirectory ?? (!import.meta.url.endsWith(".mjs") ? join17(dirname8(fileURLToPath7(import.meta.url)), "..", "dist", "viewer") : join17(dirname8(fileURLToPath7(import.meta.url)), "viewer"));+ const staticDirectory = options.staticDirectory ?? (!import.meta.url.endsWith(".mjs") ? join18(dirname9(fileURLToPath8(import.meta.url)), "..", "dist", "viewer") : join18(dirname9(fileURLToPath8(import.meta.url)), "viewer"));const server = createServer(async (req, res) => {res.setHeader("X-Content-Type-Options", "nosniff");res.setHeader("Referrer-Policy", "no-referrer");@@ -53643,7 +54135,7 @@ async function startAssetViewer(library, options = {}) {return;}res.setHeader("Content-Security-Policy", "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' blob: data:; connect-src 'self' blob: data:; worker-src 'self' blob:; object-src 'none'; base-uri 'none'; frame-ancestors 'none'");- return send(await readFile9(join17(staticDirectory, file[0])), file[1]);+ return send(await readFile11(join18(staticDirectory, file[0])), file[1]);} catch (error) {res.statusCode = error instanceof WorkspaceHttpError ? error.status : error && typeof error === "object" && ("code" in error) && error.code === "PROJECT_CONFLICT" ? 409 : 400;send(JSON.stringify({ error: error instanceof Error ? error.message : "Asset unavailable" }));@@ -53712,10 +54204,10 @@ __export(exports_asset_cli, {ASSET_USAGE: () => ASSET_USAGE,assetMain: () => assetMain});-import { readFile as readFile10, writeFile as writeFile8, stat as stat6, mkdir as mkdir9, rename as rename5 } from "node:fs/promises";-import { basename, resolve as resolve13, dirname as dirname9, isAbsolute as isAbsolute2 } from "node:path";+import { readFile as readFile12, writeFile as writeFile8, stat as stat6, mkdir as mkdir9, rename as rename5 } from "node:fs/promises";+import { basename as basename2, resolve as resolve13, dirname as dirname10, isAbsolute as isAbsolute2 } from "node:path";import { randomUUID as randomUUID9 } from "node:crypto";-import { createHash as createHash18 } from "node:crypto";+import { createHash as createHash20 } from "node:crypto";async function assetMain(argv) {const command = argv[0];const positional = [];@@ -53739,6 +54231,7 @@ async function assetMain(argv) {"profile","target","compression",+ "textures","port","render","backdrop",@@ -53772,6 +54265,10 @@ async function assetMain(argv) {flags.json = "true";continue;}+ if (arg === "--ktx2" && command === "export") {+ flags.ktx2 = "true";+ continue;+ }if (arg === "--restore" || arg === "--rebuild" || arg === "--no-project") {flags[arg.slice(2)] = "true";continue;@@ -53802,7 +54299,7 @@ async function assetMain(argv) {const fileBytes = async (path) => {if ((await stat6(path)).size > ASSET_LIMIT)throw new Error("File exceeds 64 MiB");- return new Uint8Array(await readFile10(path));+ return new Uint8Array(await readFile12(path));};if (command === "collections") {if (positional[0] === "add") {@@ -53818,7 +54315,7 @@ async function assetMain(argv) {throw new Error("Collection name already points to another directory");roots[name] = resolve13(directory);const path = collectionConfigPath();- await mkdir9(dirname9(path), { recursive: true });+ await mkdir9(dirname10(path), { recursive: true });const temporary = `${path}.${randomUUID9()}.tmp`;await writeFile8(temporary, JSON.stringify(roots, null, 2), { flag: "wx" });await rename5(temporary, path);@@ -53946,31 +54443,76 @@ async function assetMain(argv) {throw new Error("--compression must be meshopt or none");if (compression !== undefined && target !== "three")throw new Error("--compression requires --target three");- const format = flags.format ?? (profile === "runtime" ? "glb" : "bundle");- if (!["bundle", "glb", "source"].includes(format))+ const textures = flags.textures;+ if (textures !== undefined && textures !== "manifest" && textures !== "external")+ throw new Error("Unknown --textures value; use manifest or external");+ if (textures !== undefined && profile !== "runtime")+ throw new Error("--textures requires --profile runtime");+ if (textures === "external" && target !== "three")+ throw new Error("--textures external requires --target three");+ if (flags.ktx2 && (target !== "three" || profile !== "runtime"))+ throw new Error("--ktx2 requires --target three with --profile runtime");+ const gltfLayout = textures === "external";+ const format = flags.format ?? (profile === "runtime" ? gltfLayout ? "gltf" : "glb" : "bundle");+ if (!["bundle", "glb", "source", "gltf"].includes(format))throw new Error("Unknown export format");+ if (format === "gltf" && !gltfLayout)+ throw new Error("gltf format requires --textures external");const written = [];+ let drawGlb;+ let ktx2Receipt;if (profile === "runtime") {- if (format !== "glb")- throw new Error("Runtime profile requires GLB format; use editable for source or bundle");+ if (format !== (gltfLayout ? "gltf" : "glb"))+ throw new Error(gltfLayout ? "--textures external writes gltf format" : "Runtime profile requires GLB format; use editable for source or bundle");const destination = resolve13(flags.out);- if (!destination.toLowerCase().endsWith(".glb"))- throw new Error("Runtime output must end in .glb");- const metadataFileName = `${basename(destination).slice(0, -4)}.kiln-metadata.json`;+ const extension = gltfLayout ? ".gltf" : ".glb";+ if (!destination.toLowerCase().endsWith(extension))+ throw new Error(`Runtime output must end in ${extension}`);+ const stem = basename2(destination).slice(0, -extension.length);+ const metadataFileName = `${stem}.kiln-metadata.json`;const output = await exportAssetGlb(record, {profile,metadataFileName,...target ? { target } : {},- ...compression ? { compression } : {}+ ...compression ? { compression } : {},+ ...textures ? { textures } : {},+ ...gltfLayout ? { gltfFileName: basename2(destination) } : {},+ ...flags.ktx2 ? { ktx2Encoder: await createKtx2Encoder2() } : {}});if (output.profile !== "runtime")throw new Error("Expected runtime export");- const metadataPath = resolve13(dirname9(destination), output.metadata.name);- await writeNewDestinationsAtomic([- { path: metadataPath, data: output.metadata.bytes },- { path: destination, data: output.glb }- ]);- written.push({ kind: "glb", path: destination, data: output.glb }, { kind: "metadata", path: metadataPath, data: output.metadata.bytes });+ const metadataPath = resolve13(dirname10(destination), output.metadata.name);+ drawGlb = output.glb;+ if (flags.ktx2)+ ktx2Receipt = JSON.parse(new TextDecoder().decode(output.metadata.bytes)).delivery?.ktx2;+ if (output.layout === "gltf") {+ const directory = dirname10(destination);+ const files = output.textures.map(({ uri, bytes }) => ({+ path: resolve13(directory, ...uri.split("/")),+ data: bytes+ }));+ const buffers = output.buffers.map(({ uri, bytes }) => ({+ path: resolve13(directory, uri),+ data: bytes+ }));+ const published = await writeExternalTextureExport(files, [+ { path: metadataPath, data: output.metadata.bytes },+ ...buffers,+ { path: destination, data: output.gltf.bytes }+ ]);+ written.push({ kind: "gltf", path: destination, data: output.gltf.bytes }, ...buffers.map(({ path, data }) => ({ kind: "bin", path, data })), { kind: "metadata", path: metadataPath, data: output.metadata.bytes }, ...files.map(({ path, data }, index) => ({+ kind: "texture",+ path,+ data,+ reused: published[index].reused+ })));+ } else {+ await writeNewDestinationsAtomic([+ { path: metadataPath, data: output.metadata.bytes },+ { path: destination, data: output.glb }+ ]);+ written.push({ kind: "glb", path: destination, data: output.glb }, { kind: "metadata", path: metadataPath, data: output.metadata.bytes });+ }} else {const bytes = format === "bundle" ? await library.exportBundle([record]) : record.files[format === "glb" ? "asset.glb" : "source.kiln.js"];if (!bytes)@@ -53980,7 +54522,7 @@ async function assetMain(argv) {written.push({ kind: format, path: destination, data: bytes });}if (!flags.json)- console.log(written.map(({ path }) => `Saved ${path}`).join(`+ console.log(written.map(({ path, reused }) => `${reused ? "Reused" : "Saved"} ${path}`).join(``));elseconsole.log(JSON.stringify({@@ -53992,14 +54534,16 @@ async function assetMain(argv) {...target ? { target } : {},...compression ? { compression } : {},format,+ ...ktx2Receipt ? { ktx2: ktx2Receipt } : {},...format !== "source" ? {- drawDiagnostics: await inspectDrawDiagnostics(written.find(({ kind }) => kind === "glb")?.data ?? record.files["asset.glb"])+ drawDiagnostics: await inspectDrawDiagnostics(drawGlb ?? written.find(({ kind }) => kind === "glb")?.data ?? record.files["asset.glb"])} : {},- files: written.map(({ kind, path, data }) => ({+ files: written.map(({ kind, path, data, reused }) => ({kind,path,bytes: data.byteLength,- sha256: `sha256:${createHash18("sha256").update(data).digest("hex")}`+ sha256: `sha256:${createHash20("sha256").update(data).digest("hex")}`,+ ...reused === undefined ? {} : { reused }}))}, null, 2));}@@ -54008,7 +54552,7 @@ async function assetMain(argv) {if (!file)throw new Error("import requires a ZIP or GLB file");const bytes = await fileBytes(file);- const assets = file.toLowerCase().endsWith(".glb") ? [await library.save(collection, { name: flags.name ?? basename(file, ".glb"), glb: bytes })] : await library.import(collection, decodeAssetBundle(bytes));+ const assets = file.toLowerCase().endsWith(".glb") ? [await library.save(collection, { name: flags.name ?? basename2(file, ".glb"), glb: bytes })] : await library.import(collection, decodeAssetBundle(bytes));const directory = library.directory(collection);console.log(JSON.stringify({collection,@@ -54027,7 +54571,7 @@ async function assetMain(argv) {await Promise.resolve().then(() => init_assets_node());target = new FileAssetLibrary({ project: resolve13(file) });} else- standalone = { name: basename(file), bytes: await fileBytes(file) };+ standalone = { name: basename2(file), bytes: await fileBytes(file) };}const port = flags.port === undefined ? 4318 : Number(flags.port);if (!Number.isInteger(port) || port < 0 || port > 65535)@@ -54044,8 +54588,8 @@ async function assetMain(argv) {const canonical = await realpath(path);if (canonical === currentRoot)continue;- const id = `w_${createHash18("sha256").update(canonical).digest("hex").slice(0, 16)}`;- reviewSources[id] = { label: basename(canonical), review: new FileLiveReview(canonical) };+ const id = `w_${createHash20("sha256").update(canonical).digest("hex").slice(0, 16)}`;+ reviewSources[id] = { label: basename2(canonical), review: new FileLiveReview(canonical) };}const viewer = await startAssetViewer(target, {port,@@ -54112,9 +54656,14 @@ ${SAVE_LINES}kiln export <id> <revision> --out asset.zip [--format bundle|glb|source][--profile editable|runtime] runtime writes GLB + sibling metadata JSON[--target three] runtime only: meshopt + quantization, repeatInstances GPU- instancing, KTX2 skipped (no encoder); sidecar states node scales+ instancing; sidecar states node scales; KTX2 skipped unless --ktx2[--compression meshopt|none] with --target three: none writes plain buffersfor loaders without a Meshopt decoder (default meshopt)+ [--ktx2] with --target three: KTX2 through the optional [email protected] peer+ (npm install [email protected]), ETC1S colour, UASTC data maps+ [--textures manifest] runtime only: the sidecar names each image's exact bytes+ [--textures external] with --target three and --out x.gltf: x.gltf, x.bin and+ shared textures/<sha256>.<ext> files that are never replaced[--json] receipt naming each file with its bytes and sha256export never replaces an existing file: an export hands off one exactsaved revision, while render --out replaces its own working output@@ -54735,7 +55284,7 @@ __export(exports_animation_cli, {ANIMATION_USAGE: () => ANIMATION_USAGE,animationMain: () => animationMain});-import { open as open6, readFile as readFile11 } from "node:fs/promises";+import { open as open6, readFile as readFile13 } from "node:fs/promises";import { extname, resolve as resolve15 } from "node:path";async function readReviewJson(path, option) {const file = await open6(resolve15(path), "r");@@ -54859,7 +55408,7 @@ async function animationMain(argv) {...await buildRenderPort(args.render, args.renderPort),requirements});- const source = programRefPattern.test(args.source) ? { programRef: args.source } : { code: await readFile11(resolve15(args.source), "utf8") };+ const source = programRefPattern.test(args.source) ? { programRef: args.source } : { code: await readFile13(resolve15(args.source), "utf8") };const tool = createKilnProgramToolRegistry(context).find((t) => t.name === "kiln_screenshot_animation");let output;try {@@ -55081,7 +55630,7 @@ __export(exports_inspect_cli, {INSPECT_USAGE: () => INSPECT_USAGE,inspectMain: () => inspectMain});-import { open as open8, readFile as readFile12 } from "node:fs/promises";+import { open as open8, readFile as readFile14 } from "node:fs/promises";import { resolve as resolve17 } from "node:path";async function readControls(path) {const file = await open8(resolve17(path), "r");@@ -55178,7 +55727,7 @@ async function inspectMain(argv) {...controls.image === false ? {} : await buildRenderPort(args.render, args.renderPort),requirements});- const source = programRefPattern.test(args.source) ? { programRef: args.source } : { code: await readFile12(resolve17(args.source), "utf8") };+ const source = programRefPattern.test(args.source) ? { programRef: args.source } : { code: await readFile14(resolve17(args.source), "utf8") };const tool = createKilnProgramToolRegistry(context).find((t) => t.name === "kiln_inspect");let output;try {@@ -55662,7 +56211,7 @@ __export(exports_migration_rebuild, {migrationRebuildMain: () => migrationRebuildMain});import { open as open9 } from "node:fs/promises";-import { createHash as createHash19 } from "node:crypto";+import { createHash as createHash21 } from "node:crypto";import { resolve as resolve18 } from "node:path";function parse6(argv) {if (argv.length === 1 && ["--help", "-h"].includes(argv[0]))@@ -55752,7 +56301,7 @@ async function rebuildLegacyAsset(context, input) {authority,original: structuredClone(record.manifest),...conversion.recoveredIntent ? { recoveredIntent: conversion.recoveredIntent } : {},- originalManifestCanonicalSha256: `sha256:${createHash19("sha256").update(canonical6(record.manifest)).digest("hex")}`,+ originalManifestCanonicalSha256: `sha256:${createHash21("sha256").update(canonical6(record.manifest)).digest("hex")}`,proposedRequirements: conversion.proposal.requirements,policyChanges: changes,ruleDispositions: resolved.filter((issue) => issue.code === "RULE_MIGRATION_UNQUALIFIED").map((issue) => ({@@ -55762,7 +56311,7 @@ async function rebuildLegacyAsset(context, input) {})),retainedBuildOptions: conversion.proposal.retainedBuildOptions,sourceChanged: code !== originalCode,- rebuiltSourceSha256: `sha256:${createHash19("sha256").update(code, "utf8").digest("hex")}`+ rebuiltSourceSha256: `sha256:${createHash21("sha256").update(code, "utf8").digest("hex")}`};const draft = await buildProgramAssetDraft(code, currentContext, record.manifest.preview?.backdrop);const asset = await library.save(input.collection, {@@ -55875,7 +56424,7 @@ __export(exports_migration_cli, {});import { open as open10 } from "node:fs/promises";import { resolve as resolve19 } from "node:path";-import { createHash as createHash20 } from "node:crypto";+import { createHash as createHash22 } from "node:crypto";function parse7(argv) {if (argv.length === 1 && ["--help", "-h"].includes(argv[0]))return { help: true };@@ -55944,7 +56493,7 @@ async function migrationMain(argv) {input: {path,bytes: bytes.length,- sha256: `sha256:${createHash20("sha256").update(bytes).digest("hex")}`+ sha256: `sha256:${createHash22("sha256").update(bytes).digest("hex")}`},conversion};@@ -55979,7 +56528,7 @@ var init_migration_cli = __esm(() => {// src/cli.tsinit_cli_output();-import { open as open11, readFile as readFile13 } from "node:fs/promises";+import { open as open11, readFile as readFile15 } from "node:fs/promises";import { resolve as resolvePath, extname as extname2 } from "node:path";// src/direct-entry.ts@@ -56434,7 +56983,7 @@ async function cmdRender(args) {const receipt = { files: [] };let context;try {- const code = file.startsWith("sha256:") || programRefPattern.test(file) ? await localProgramStore().get(file) : await readFile13(resolvePath(file), "utf8");+ const code = file.startsWith("sha256:") || programRefPattern.test(file) ? await localProgramStore().get(file) : await readFile15(resolvePath(file), "utf8");context = await createPackagedLocalToolContext({...await buildRenderPort(args.render, args.renderPort),requirements: args.requirements@@ -56482,7 +57031,7 @@ ${USAGE3}`);const def = createKilnProgramToolRegistry({ programStore: store }).find((d) => d.name === "kiln_validate");if (!def)throw new Error("kiln_validate is missing from the MCP tool surface");- const result = await def.run(isRef ? { programRef: input } : { code: await readFile13(resolvePath(input), "utf8") });+ const result = await def.run(isRef ? { programRef: input } : { code: await readFile15(resolvePath(input), "utf8") });if (args.json)console.log(JSON.stringify(result));else {@@ -56605,10 +57154,10 @@ async function cmdSource(args) {if (isRef)process.stdout.write(await store.get(input));else- console.log(await retainProgram(store, await readFile13(resolvePath(input), "utf8")));+ console.log(await retainProgram(store, await readFile15(resolvePath(input), "utf8")));return 0;}- const programRef = isRef ? input : await retainProgram(store, await readFile13(resolvePath(input), "utf8"));+ const programRef = isRef ? input : await retainProgram(store, await readFile15(resolvePath(input), "utf8"));const offset = integerOption("--offset", args.offset);const limit = integerOption("--limit", args.limit);const result = await createKilnSourceDef(store).run({diff --git a/dist/mcp-engine.mjs b/dist/mcp-engine.mjsindex a735b688..139f7c79 100644--- a/dist/mcp-engine.mjs+++ b/dist/mcp-engine.mjs@@ -6765,6 +6765,179 @@ var init_material_library_node = __esm(() => {encoder = { name: "sharp", version: sharp.versions.sharp };});+// src/runtime-textures.ts+async function sha256Hex2(bytes) {+ const digest = await crypto.subtle.digest("SHA-256", Uint8Array.from(bytes));+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");+}+function imageDimensions(bytes) {+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);+ const fail = () => {+ throw new Error("Texture manifest cannot read image dimensions");+ };+ const at = (offset, length) => {+ if (offset + length > bytes.byteLength)+ fail();+ };+ if (bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71) {+ at(16, 8);+ return { width: view.getUint32(16), height: view.getUint32(20) };+ }+ if (isKtx2(bytes)) {+ at(20, 8);+ return { width: view.getUint32(20, true), height: view.getUint32(24, true) };+ }+ if (bytes[0] === 255 && bytes[1] === 216) {+ let offset = 2;+ while (offset + 4 <= bytes.byteLength) {+ if (bytes[offset] !== 255)+ fail();+ const marker = bytes[offset + 1];+ if (marker === 255) {+ offset++;+ continue;+ }+ if (marker === 216 || marker === 1 || marker >= 208 && marker <= 215) {+ offset += 2;+ continue;+ }+ const length = view.getUint16(offset + 2);+ if (marker >= 192 && marker <= 207 && ![196, 200, 204].includes(marker)) {+ at(offset + 5, 4);+ return { width: view.getUint16(offset + 7), height: view.getUint16(offset + 5) };+ }+ offset += 2 + length;+ }+ fail();+ }+ const text = (offset) => String.fromCharCode(...bytes.subarray(offset, Math.min(offset + 4, bytes.byteLength)));+ if (text(0) === "RIFF" && text(8) === "WEBP") {+ at(12, 19);+ const chunk = text(12);+ if (chunk === "VP8X")+ return {+ width: 1 + (view.getUint32(24, true) & 16777215),+ height: 1 + (view.getUint32(27, true) & 16777215)+ };+ if (chunk === "VP8L") {+ const bits = view.getUint32(21, true);+ return { width: 1 + (bits & 16383), height: 1 + (bits >> 14 & 16383) };+ }+ if (chunk === "VP8 ") {+ at(26, 4);+ return {+ width: view.getUint16(26, true) & 16383,+ height: view.getUint16(28, true) & 16383+ };+ }+ }+ return fail();+}+function textureSource(texture) {+ if (!object(texture))+ return;+ const extensions = object(texture.extensions) ? texture.extensions : {};+ for (const name of ["KHR_texture_basisu", "EXT_texture_webp", "EXT_texture_avif"]) {+ const extension = extensions[name];+ if (object(extension) && index(extension.source) !== undefined)+ return index(extension.source);+ }+ return index(texture.source);+}+function srgbImages(json) {+ const textures = Array.isArray(json.textures) ? json.textures : [];+ const result = new Set;+ for (const material of Array.isArray(json.materials) ? json.materials : []) {+ if (!object(material))+ continue;+ const pbr = object(material.pbrMetallicRoughness) ? material.pbrMetallicRoughness : {};+ for (const info of [pbr.baseColorTexture, material.emissiveTexture]) {+ const texture = object(info) ? index(info.index) : undefined;+ const image = texture === undefined ? undefined : textureSource(textures[texture]);+ if (image !== undefined)+ result.add(image);+ }+ }+ return result;+}+function base64(text) {+ const binary = atob(text);+ return Uint8Array.from(binary, (character) => character.charCodeAt(0));+}+function embeddedImages(json, binary) {+ const views = Array.isArray(json.bufferViews) ? json.bufferViews : [];+ return (Array.isArray(json.images) ? json.images : []).map((image) => {+ if (!object(image))+ throw new Error("Invalid glTF image");+ const view = index(image.bufferView);+ if (view !== undefined) {+ const def = views[view];+ if (!object(def) || index(def.buffer) !== 0 || !binary)+ throw new Error("Texture manifest requires images embedded in the GLB binary chunk");+ const offset = index(def.byteOffset) ?? 0;+ const length = index(def.byteLength);+ if (length === undefined || offset + length > binary.byteLength)+ throw new Error("Invalid glTF image buffer view");+ if (typeof image.mimeType !== "string")+ throw new Error("Embedded image needs a mimeType");+ return { bytes: binary.subarray(offset, offset + length), mimeType: image.mimeType };+ }+ const match = typeof image.uri === "string" ? /^data:([^;,]+);base64,(.*)$/s.exec(image.uri) : null;+ if (!match)+ throw new Error("Texture manifest requires embedded image bytes");+ return { bytes: base64(match[2]), mimeType: match[1] };+ });+}+async function runtimeTextureManifest(json, binary, options = {}) {+ const srgb = srgbImages(json);+ const entries = [];+ for (const [image, { bytes, mimeType }] of embeddedImages(json, binary).entries()) {+ const sha256 = `sha256:${await sha256Hex2(bytes)}`;+ const sourceSha256 = options.sources?.get(image);+ const original = sourceSha256 ?? sha256;+ const map = options.maps?.find((candidate) => candidate.sha256 === original);+ entries.push({+ image,+ sha256,+ bytes: bytes.byteLength,+ mimeType,+ ...imageDimensions(bytes),+ colorSpace: srgb.has(image) ? "srgb" : "linear",+ ...sourceSha256 && sourceSha256 !== sha256 ? { sourceSha256 } : {},+ ...map ? { material: { pin: { ...map.pin }, slot: map.slot } } : {}+ });+ }+ return entries;+}+function textureFileExtension(mimeType) {+ const extension = {+ "image/png": "png",+ "image/jpeg": "jpg",+ "image/webp": "webp",+ "image/ktx2": "ktx2"+ }[mimeType];+ if (!extension)+ throw new Error(`External textures do not support ${mimeType}`);+ return extension;+}+var object = (value) => value !== null && typeof value === "object" && !Array.isArray(value), index = (value) => Number.isInteger(value) && value >= 0 ? value : undefined, KTX2_IDENTIFIER, isKtx2 = (bytes) => bytes.byteLength >= 12 && KTX2_IDENTIFIER.every((value, at) => bytes[at] === value);+var init_runtime_textures = __esm(() => {+ KTX2_IDENTIFIER = Object.freeze([+ 171,+ 75,+ 84,+ 88,+ 32,+ 50,+ 48,+ 187,+ 13,+ 10,+ 26,+ 10+ ]);+});+// src/contracts/semantic.tsfunction semanticRole(base, ...segments) {const tail = segments.map((segment) => String(segment).trim()).filter((segment) => segment !== "");@@ -8839,12 +9012,466 @@ var init_delivery_inspect = __esm(() => {init_node_visibility();});+// src/gltf-texture-binding.ts+import * as THREE7 from "three";+function restoreGltfTextureBinding(texture, info) {+ texture.minFilter = MIN[info.getMinFilter() ?? 9729];+ texture.magFilter = info.getMagFilter() === 9728 ? THREE7.NearestFilter : THREE7.LinearFilter;+ texture.wrapS = WRAP[info.getWrapS()];+ texture.wrapT = WRAP[info.getWrapT()];+ texture.generateMipmaps = [9984, 9985, 9986, 9987].includes(info.getMinFilter() ?? 9729);+ texture.flipY = false;+ const transform = info.getExtension("KHR_texture_transform");+ texture.channel = transform?.getTexCoord() ?? info.getTexCoord();+ if (transform) {+ texture.offset.fromArray(transform.getOffset());+ texture.repeat.fromArray(transform.getScale());+ texture.rotation = transform.getRotation();+ const c = Math.cos(texture.rotation), s = Math.sin(texture.rotation);+ const [sx, sy] = transform.getScale(), [x, y] = transform.getOffset();+ texture.matrix.set(sx * c, sy * s, x, -sx * s, sy * c, y, 0, 0, 1);+ texture.matrixAutoUpdate = false;+ }+}+function gltfTextureBindingKey(info) {+ if (!info)+ return "";+ const transform = info.getExtension("KHR_texture_transform");+ return JSON.stringify([+ info.getMinFilter(),+ info.getMagFilter(),+ info.getWrapS(),+ info.getWrapT(),+ info.getTexCoord(),+ transform?.getTexCoord(),+ transform?.getOffset(),+ transform?.getScale(),+ transform?.getRotation(),+ info.getExtras()["kilnAtlasReference"]+ ]);+}+var MIN, WRAP;+var init_gltf_texture_binding = __esm(() => {+ MIN = {+ 9728: THREE7.NearestFilter,+ 9729: THREE7.LinearFilter,+ 9984: THREE7.NearestMipmapNearestFilter,+ 9985: THREE7.LinearMipmapNearestFilter,+ 9986: THREE7.NearestMipmapLinearFilter,+ 9987: THREE7.LinearMipmapLinearFilter+ };+ WRAP = {+ 33071: THREE7.ClampToEdgeWrapping,+ 33648: THREE7.MirroredRepeatWrapping,+ 10497: THREE7.RepeatWrapping+ };+});++// src/atlas-provenance.ts+import * as THREE8 from "three";+function fail4(message) {+ throw new TypeError(`atlas provenance: ${message}`);+}+function field(input, key) {+ if (!input || typeof input !== "object" || Array.isArray(input))+ fail4("plain metadata object required.");+ const proto = Object.getPrototypeOf(input);+ if (proto !== null && proto !== Object.prototype)+ fail4("plain metadata prototype required.");+ const d = Object.getOwnPropertyDescriptor(input, key);+ if (!d)+ return;+ if (!d.enumerable || !("value" in d))+ fail4("metadata accessors/hidden fields are unsupported.");+ return d.value;+}+function closed(input, keys) {+ for (const key of Reflect.ownKeys(input))+ if (typeof key !== "string" || !keys.includes(key))+ fail4("unsupported metadata field.");+ for (const key of keys)+ field(input, key);+ return input;+}+function normalize(input) {+ canonicalAtlasMetadataJsonV1(input);+ const r = closed(input, ["spec", "manifest"]);+ const spec = canonicalizeTextureAtlasSpecV1(r["spec"]);+ return { spec, manifest: validateTextureAtlasManifestV1(r["manifest"], spec) };+}+function textureCandidates(texture) {+ const direct = field(texture.userData, "kilnAtlas"), resource = field(texture.userData, "kilnMaterialResource");+ const map = resource === undefined ? undefined : field(resource, "map"), recipe = map === undefined ? undefined : field(map, "recipe");+ const candidates = [];+ if (direct !== undefined)+ candidates.push(direct);+ if (recipe !== undefined && field(recipe, "kind") === "atlas")+ candidates.push({ spec: field(recipe, "spec"), manifest: field(recipe, "manifest") });+ return candidates;+}+function normalizeCandidates(candidates) {+ let result;+ for (const candidate of candidates) {+ const p = normalize(candidate);+ if (result && canonicalAtlasMetadataJsonV1(result) !== canonicalAtlasMetadataJsonV1(p))+ fail4("direct and saved atlas identities disagree.");+ result = p;+ }+ return result;+}+function readAtlasTextureProvenance(texture) {+ return normalizeCandidates(textureCandidates(texture));+}+function admitTable(input) {+ const r = closed(input, ["version", "atlases"]);+ if (r["version"] !== ATLAS_PROVENANCE_VERSION)+ fail4("unsupported version.");+ const entries = r["atlases"];+ if (!Array.isArray(entries) || Object.getPrototypeOf(entries) !== Array.prototype)+ fail4("dense atlas array required.");+ const n = Object.getOwnPropertyDescriptor(entries, "length").value;+ if (n > ATLAS_PROVENANCE_LIMITS.atlases || Reflect.ownKeys(entries).length !== n + 1)+ fail4("atlas count/density budget exceeded.");+ let bytes = TABLE_ENVELOPE_BYTES;+ const admitted = [];+ for (let i = 0;i < n; i++) {+ const d = Object.getOwnPropertyDescriptor(entries, String(i));+ if (!d?.enumerable || !("value" in d))+ fail4("atlas array accessors are unsupported.");+ const json = canonicalAtlasMetadataJsonV1(d.value);+ bytes += new TextEncoder().encode(json).length + (i > 0 ? 1 : 0);+ if (bytes > ATLAS_PROVENANCE_LIMITS.bytes)+ fail4("aggregate metadata byte budget exceeded.");+ admitted.push(closed(d.value, ["id", "spec", "manifest"]));+ }+ return admitted;+}+function validateAtlasProvenanceTable(input) {+ const admitted = admitTable(input), ids = new Set, atlases = [];+ for (const e of admitted) {+ const p = normalize({ spec: e["spec"], manifest: e["manifest"] });+ if (e["id"] !== p.manifest.manifestHash || ids.has(e["id"]))+ fail4("duplicate or mismatched atlas identity.");+ ids.add(e["id"]);+ atlases.push({ id: e["id"], ...p });+ }+ return { version: ATLAS_PROVENANCE_VERSION, atlases };+}+function lookup(table, id) {+ const found = table.atlases.find((a) => a.id === id);+ if (!found)+ fail4("unknown atlas reference.");+ return found;+}+function derivedBinding(p, regionName, origin, mode) {+ if (!["top-left", "bottom-left"].includes(origin) || !["content-boundary", "texel-center"].includes(mode))+ fail4("explicit binding origin/mode required.");+ const r = p.manifest.regions.find((r) => r.name === regionName);+ if (!r)+ fail4("unknown named region.");+ const { x, y, width: w, height: h } = r.content, center = mode === "texel-center", bottom = origin === "bottom-left";+ return {+ manifestHash: p.manifest.manifestHash,+ specHash: p.manifest.specHash,+ layoutHash: p.manifest.layoutHash,+ region: r.name,+ content: structuredClone(r.content),+ allocation: structuredClone(r.allocation),+ inputOrigin: origin,+ mode,+ scale: [+ (w - (center ? 1 : 0)) / p.manifest.width,+ (bottom ? -1 : 1) * (h - (center ? 1 : 0)) / p.manifest.height+ ],+ offset: [+ (x + (center ? 0.5 : 0)) / p.manifest.width,+ (y + (bottom ? h - (center ? 0.5 : 0) : center ? 0.5 : 0)) / p.manifest.height+ ]+ };+}+function expandAtlasBinding(input, table) {+ canonicalAtlasMetadataJsonV1(input);+ const r = closed(input, ["version", "atlasId", "region", "inputOrigin", "mode"]);+ if (r["version"] !== ATLAS_PROVENANCE_VERSION)+ fail4("unsupported binding version.");+ return derivedBinding(lookup(table, r["atlasId"]), r["region"], r["inputOrigin"], r["mode"]);+}+function readAtlasGeometryBinding(geometry, provenance) {+ const stamp = field(geometry.userData, "kilnAtlasBinding");+ if (stamp === undefined)+ return;+ canonicalAtlasMetadataJsonV1(stamp);+ const r = stamp, derived = derivedBinding(provenance, r["region"], r["inputOrigin"], r["mode"]);+ if (canonicalAtlasMetadataJsonV1(stamp) !== canonicalAtlasMetadataJsonV1(derived))+ fail4("named binding identity or remap formula mismatch.");+ return {+ version: ATLAS_PROVENANCE_VERSION,+ atlasId: provenance.manifest.manifestHash,+ region: r["region"],+ inputOrigin: r["inputOrigin"],+ mode: r["mode"]+ };+}+function collectAtlasProvenance(root) {+ const textures = new Map, geometries = new Map, candidates = new Map, sizes = new Map, pendingGeometry = new Map;+ let total = TABLE_ENVELOPE_BYTES, pixelBytes = 0, bindings = 0;+ root.traverse((node) => {+ const mesh = node;+ if (!mesh.isMesh && !node.isSprite)+ return;+ const meshIds = new Set, mats = Array.isArray(mesh.material) ? mesh.material : [mesh.material];+ for (const mat of mats)+ for (const slot of [+ "map",+ "normalMap",+ "roughnessMap",+ "metalnessMap",+ "emissiveMap",+ "aoMap"+ ]) {+ const texture = mat[slot];+ if (!(texture instanceof THREE8.Texture))+ continue;+ let ref = textures.get(texture);+ if (!ref) {+ const raw = textureCandidates(texture);+ if (!raw.length)+ continue;+ for (const candidate of raw) {+ canonicalAtlasMetadataJsonV1(candidate);+ const r = closed(candidate, ["spec", "manifest"]), id = field(r["manifest"], "manifestHash");+ if (typeof id !== "string" || !/^sha256:[0-9a-f]{64}$/.test(id))+ fail4("invalid atlas identity.");+ const bytes = new TextEncoder().encode(canonicalAtlasMetadataJsonV1({ ...r, id })).length;+ const prior = sizes.get(id) ?? 0;+ total += Math.max(0, bytes - prior) + (prior === 0 && sizes.size > 0 ? 1 : 0);+ sizes.set(id, Math.max(prior, bytes));+ if (total > ATLAS_PROVENANCE_LIMITS.bytes || sizes.size > ATLAS_PROVENANCE_LIMITS.atlases)+ fail4("aggregate metadata budget exceeded.");+ ref ??= { version: ATLAS_PROVENANCE_VERSION, id };+ }+ const spec = field(raw[0], "spec"), width = field(spec, "width"), height = field(spec, "height");+ if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width < 1 || height < 1)+ fail4("invalid atlas image dimensions.");+ pixelBytes += width * height * 4;+ if (pixelBytes > ATLAS_PROVENANCE_LIMITS.bakeDecodedBytes)+ fail4("aggregate atlas bake pixel budget exceeded.");+ candidates.set(texture, raw);+ textures.set(texture, ref);+ }+ if (++bindings > ATLAS_PROVENANCE_LIMITS.bindings)+ fail4("texture binding budget exceeded.");+ meshIds.add(ref.id);+ }+ if (!mesh.isMesh)+ return;+ const stamp = field(mesh.geometry.userData, "kilnAtlasBinding");+ if (stamp === undefined)+ return;+ if (++bindings > ATLAS_PROVENANCE_LIMITS.bindings)+ fail4("primitive binding budget exceeded.");+ canonicalAtlasMetadataJsonV1(stamp);+ const id = field(stamp, "manifestHash");+ if (typeof id !== "string" || !meshIds.has(id))+ fail4("named binding has no matching primary atlas texture on this mesh.");+ pendingGeometry.set(mesh.geometry, id);+ });+ const identities = new Map;+ for (const [texture, raw] of candidates) {+ const p = normalizeCandidates(raw), id = p.manifest.manifestHash, prior = identities.get(id);+ if (prior && canonicalAtlasMetadataJsonV1(prior) !== canonicalAtlasMetadataJsonV1(p))+ fail4("conflicting atlas identity.");+ identities.set(id, p);+ textures.set(texture, { version: ATLAS_PROVENANCE_VERSION, id });+ }+ for (const [geometry, id] of pendingGeometry)+ geometries.set(geometry, readAtlasGeometryBinding(geometry, identities.get(id)));+ const table = identities.size ? {+ version: ATLAS_PROVENANCE_VERSION,+ atlases: [...identities].map(([id, p]) => ({ id, ...p }))+ } : undefined;+ return { table, texture: (t) => textures.get(t), binding: (g) => geometries.get(g) };+}+function rawDocumentTable(doc) {+ const scene = doc.getRoot().getDefaultScene() ?? doc.getRoot().listScenes()[0];+ return scene ? field(scene.getExtras(), "kilnAtlasProvenance") : undefined;+}+function atlasDocumentTable(doc) {+ const raw = rawDocumentTable(doc);+ return raw === undefined ? undefined : validateAtlasProvenanceTable(raw);+}+function atlasMaterialUses(doc) {+ const uses = [];+ for (const mat of doc.getRoot().listMaterials())+ for (const [texture, info] of [+ [mat.getBaseColorTexture(), mat.getBaseColorTextureInfo()],+ [mat.getNormalTexture(), mat.getNormalTextureInfo()],+ [mat.getMetallicRoughnessTexture(), mat.getMetallicRoughnessTextureInfo()],+ [mat.getEmissiveTexture(), mat.getEmissiveTextureInfo()],+ [mat.getOcclusionTexture(), mat.getOcclusionTextureInfo()]+ ])+ if (texture && info && field(info.getExtras(), "kilnAtlasReference") !== undefined) {+ if (uses.length >= ATLAS_PROVENANCE_LIMITS.bindings)+ fail4("document binding budget exceeded.");+ uses.push({ texture, info });+ }+ return uses;+}+async function imageHash(texture) {+ const bytes = texture.getImage();+ if (!bytes || bytes.byteLength > ATLAS_PROVENANCE_LIMITS.encodedBytes)+ fail4("encoded image missing or over budget.");+ const result = await crypto.subtle.digest("SHA-256", bytes);+ return `sha256:${[...new Uint8Array(result)].map((v) => v.toString(16).padStart(2, "0")).join("")}`;+}+function sampler(info) {+ const value = {+ minFilter: info.getMinFilter(),+ magFilter: info.getMagFilter(),+ wrapS: info.getWrapS(),+ wrapT: info.getWrapT()+ };+ if (![null, 9728, 9729, 9984, 9985, 9986, 9987].includes(value.minFilter) || ![null, 9728, 9729].includes(value.magFilter) || ![33071, 33648, 10497].includes(value.wrapS) || ![33071, 33648, 10497].includes(value.wrapT))+ fail4("unsupported effective sampler.");+ return value;+}+function reference(input, table) {+ canonicalAtlasMetadataJsonV1(input);+ const r = closed(input, ["version", "id", "effectiveSampler", "finalMime", "finalImageSha256"]);+ if (r["version"] !== ATLAS_PROVENANCE_VERSION)+ fail4("unsupported texture reference version.");+ lookup(table, r["id"]);+ return r;+}+function admitEncodedImages(uses) {+ const seen = new Set;+ let total = 0;+ for (const { texture } of uses) {+ if (seen.has(texture))+ continue;+ seen.add(texture);+ const bytes = texture.getImage();+ if (!bytes || bytes.byteLength > ATLAS_PROVENANCE_LIMITS.encodedBytes)+ fail4("encoded image missing or over budget.");+ total += bytes.byteLength;+ if (total > ATLAS_PROVENANCE_LIMITS.aggregateEncodedBytes)+ fail4("aggregate encoded image hash budget exceeded.");+ }+}+async function refreshAtlasDocumentProvenance(doc) {+ const table = atlasDocumentTable(doc), uses = atlasMaterialUses(doc);+ if (!uses.length)+ return;+ if (!table)+ fail4("atlas table missing.");+ admitEncodedImages(uses);+ const hashes = new Map;+ for (const { texture, info } of uses) {+ const r = reference(field(info.getExtras(), "kilnAtlasReference"), table);+ let hash = hashes.get(texture);+ if (!hash) {+ hash = await imageHash(texture);+ hashes.set(texture, hash);+ }+ info.setExtras({+ ...info.getExtras(),+ kilnAtlasReference: {+ version: ATLAS_PROVENANCE_VERSION,+ id: r.id,+ effectiveSampler: sampler(info),+ finalMime: texture.getMimeType(),+ finalImageSha256: hash+ }+ });+ }+}+async function validateAtlasDocumentProvenance(doc) {+ const table = atlasDocumentTable(doc), uses = atlasMaterialUses(doc);+ if (uses.length && !table)+ fail4("atlas table missing.");+ if (!table) {+ for (const mesh of doc.getRoot().listMeshes())+ for (const primitive of mesh.listPrimitives())+ if (field(primitive.getExtras(), "kilnAtlasBinding") !== undefined)+ fail4("atlas table missing.");+ return;+ }+ admitEncodedImages(uses);+ const hashes = new Map;+ for (const { texture, info } of uses) {+ const r = reference(field(info.getExtras(), "kilnAtlasReference"), table);+ let hash = hashes.get(texture);+ if (!hash) {+ hash = await imageHash(texture);+ hashes.set(texture, hash);+ }+ if (r.finalImageSha256 !== hash || r.finalMime !== texture.getMimeType() || canonicalAtlasMetadataJsonV1(r.effectiveSampler) !== canonicalAtlasMetadataJsonV1(sampler(info)))+ fail4("final image or effective sampler identity mismatch.");+ }+ let bindings = 0;+ for (const mesh of doc.getRoot().listMeshes())+ for (const prim of mesh.listPrimitives()) {+ const binding = field(prim.getExtras(), "kilnAtlasBinding");+ if (binding !== undefined) {+ if (++bindings > ATLAS_PROVENANCE_LIMITS.bindings)+ fail4("primitive budget exceeded.");+ expandAtlasBinding(binding, table);+ const material = prim.getMaterial(), id = field(binding, "atlasId");+ const infos = material ? [+ material.getBaseColorTextureInfo(),+ material.getNormalTextureInfo(),+ material.getMetallicRoughnessTextureInfo(),+ material.getEmissiveTextureInfo(),+ material.getOcclusionTextureInfo()+ ] : [];+ if (!infos.some((info) => info && field(info.getExtras(), "kilnAtlasReference") !== undefined && field(field(info.getExtras(), "kilnAtlasReference"), "id") === id))+ fail4("named binding has no matching material atlas reference.");+ }+ }+}+function readValidatedAtlasDelivery(texture) {+ const ref = validatedDeliveries.get(texture);+ return ref ? structuredClone(ref) : undefined;+}+function readAtlasEncodedTexture(texture) {+ const encoded = field(texture.userData, "encoded");+ if (encoded === undefined)+ return;+ const r = closed(encoded, ["mime", "bytes"]);+ if (r["mime"] !== "image/png" || !(r["bytes"] instanceof Uint8Array) || r["bytes"].byteLength > ATLAS_PROVENANCE_LIMITS.encodedBytes)+ fail4("bounded PNG encoding required.");+ return { mime: "image/png", bytes: r["bytes"] };+}+function restoreAtlasTextureProvenance(texture, info, table) {+ const r = reference(field(info.getExtras(), "kilnAtlasReference"), table), p = lookup(table, r.id);+ texture.userData.kilnAtlas = structuredClone({ spec: p.spec, manifest: p.manifest });+ validatedDeliveries.set(texture, Object.freeze(structuredClone(r)));+ restoreGltfTextureBinding(texture, info);+}+var ATLAS_PROVENANCE_VERSION = "kiln.atlas-provenance.v1", TABLE_ENVELOPE_BYTES, ATLAS_PROVENANCE_LIMITS, validatedDeliveries;+var init_atlas_provenance = __esm(() => {+ init_gltf_texture_binding();+ init_texture_atlas_contract();+ TABLE_ENVELOPE_BYTES = new TextEncoder().encode(JSON.stringify({ version: ATLAS_PROVENANCE_VERSION, atlases: [] })).length;+ ATLAS_PROVENANCE_LIMITS = Object.freeze({+ atlases: 128,+ bytes: 4194304,+ bindings: 1024,+ entryBytes: 262144,+ encodedBytes: 16777216,+ aggregateEncodedBytes: 67108864,+ bakeDecodedBytes: 67108864+ });+ validatedDeliveries = new WeakMap;+});+// src/runtime-three.tsvar exports_runtime_three = {};__export(exports_runtime_three, {deliverRuntimeThreeGlb: () => deliverRuntimeThreeGlb});import {+ Format,Logger,PropertyType as PropertyType3} from "@gltf-transform/core";@@ -8854,7 +9481,7 @@ import {KHRTextureBasisu} from "@gltf-transform/extensions";import { dedup, quantize, reorder } from "@gltf-transform/functions";-import * as THREE7 from "three";+import * as THREE9 from "three";function meshSignature(mesh, ids) {const id = (property) => {if (!property)@@ -8929,7 +9556,7 @@ function splitColliderProxies(doc) {}return report;}-async function encodeKtx2(doc, encoder) {+async function encodeKtx2(doc, encoder, sources) {const textures = doc.getRoot().listTextures().filter((texture) => texture.getMimeType() !== "image/ktx2" && texture.getImage());if (!encoder)return {@@ -8937,40 +9564,73 @@ async function encodeKtx2(doc, encoder) {textures: textures.length,reason: "No KTX2 encoder was supplied; textures stay PNG or JPEG."};- const srgb = new Set;+ const slots = new Map;+ const use = (texture, slot) => {+ if (texture)+ slots.set(texture, (slots.get(texture) ?? new Set).add(slot));+ };for (const material of doc.getRoot().listMaterials()) {- for (const texture of [material.getBaseColorTexture(), material.getEmissiveTexture()])- if (texture)- srgb.add(texture);+ use(material.getBaseColorTexture(), "baseColor");+ use(material.getEmissiveTexture(), "emissive");+ use(material.getNormalTexture(), "normal");+ use(material.getMetallicRoughnessTexture(), "metallicRoughness");+ use(material.getOcclusionTexture(), "occlusion");}+ const order = [+ "baseColor",+ "emissive",+ "normal",+ "metallicRoughness",+ "occlusion"+ ];for (const texture of textures) {+ const used = slots.get(texture) ?? new Set;+ const srgb = used.has("baseColor") || used.has("emissive");+ const other = texture.listParents().some((parent) => parent.propertyType !== PropertyType3.ROOT && !isCoreMaterialUse(parent));+ const linear = [...used].some((slot) => slot !== "baseColor" && slot !== "emissive") || other;+ if (srgb && linear)+ throw new Error(`Texture ${JSON.stringify(texture.getName())} is used by both sRGB and linear material slots; one KTX2 encoding cannot serve both. Use separate images.`);+ const original = texture.getImage();const image = await encoder({- image: texture.getImage(),+ image: original,mimeType: texture.getMimeType(),name: texture.getName(),- colorSpace: srgb.has(texture) ? "srgb" : "linear"+ colorSpace: srgb ? "srgb" : "linear",+ slot: order.find((slot) => used.has(slot)) ?? "other"});- if (!(image instanceof Uint8Array) || image.byteLength < 12)- throw new Error("ktx2Encoder must return KTX2 bytes");+ if (!(image instanceof Uint8Array) || !isKtx2(image))+ throw new Error("ktx2Encoder must return KTX2 bytes starting with the KTX2 identifier");+ sources.set(texture, `sha256:${await sha256Hex2(original)}`);texture.setImage(image).setMimeType("image/ktx2");const uri = texture.getURI();if (uri)texture.setURI(uri.replace(/\.(png|jpe?g)$/i, ".ktx2"));}- if (textures.length)+ if (textures.length) {doc.createExtension(KHRTextureBasisu).setRequired(true);- return { status: "encoded", textures: textures.length };+ await Promise.resolve().then(() => init_atlas_provenance());+ await refreshAtlasDocumentProvenance(doc);+ await validateAtlasDocumentProvenance(doc);+ }+ return {+ status: "encoded",+ textures: textures.length,+ ...encoder.identity ? { encoder: structuredClone(encoder.identity) } : {}+ };+}+function isCoreMaterialUse(parent) {+ return parent.propertyType === PropertyType3.MATERIAL;}function decomposeDelta(before, after) {- const delta = new THREE7.Matrix4().fromArray(before).invert().multiply(new THREE7.Matrix4().fromArray(after));- const position = new THREE7.Vector3, quaternion = new THREE7.Quaternion, scale = new THREE7.Vector3;+ const delta = new THREE9.Matrix4().fromArray(before).invert().multiply(new THREE9.Matrix4().fromArray(after));+ const position = new THREE9.Vector3, quaternion = new THREE9.Quaternion, scale = new THREE9.Vector3;delta.decompose(position, quaternion, scale);return {scale: scale.x,offset: [position.x, position.y, position.z]};}-async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}) {+async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}, layout = {}) {const compression = options.compression ?? "meshopt";if (compression !== "meshopt" && compression !== "none")throw new Error("Runtime three compression must be meshopt or none");@@ -8998,7 +9658,8 @@ async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}) {}));if (compression === "meshopt")doc.createExtension(EXTMeshoptCompression).setRequired(true).setEncoderOptions({ method: EXTMeshoptCompression.EncoderMethod.QUANTIZE });- const ktx2 = await encodeKtx2(doc, options.ktx2Encoder);+ const encodedSources = new Map;+ const ktx2 = await encodeKtx2(doc, options.ktx2Encoder, encodedSources);for (const node of doc.getRoot().listNodes()) {const mesh = node.getMesh();if (!mesh || matrices.has(node) || node.getName())@@ -9020,7 +9681,7 @@ async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}) {const original = matrices.get(node);const moved = original === undefined;const split = moved || proxyNodes.has(node);- const reference = moved ? new THREE7.Matrix4().identity().toArray() : original;+ const reference = moved ? new THREE9.Matrix4().identity().toArray() : original;const current = [...node.getMatrix()];const { scale, offset } = decomposeDelta(reference, current);if (!moved && Math.abs(scale - 1) < 0.000000000001 && offset.every((v) => v === 0))@@ -9057,6 +9718,13 @@ async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}) {const all = doc.getRoot().listNodes();const glb = await io.writeBinary(doc);const json = (await io.binaryToJSON(glb)).json;+ const imageSources = new Map;+ doc.getRoot().listTextures().forEach((texture, image) => {+ const source = encodedSources.get(texture);+ if (source)+ imageSources.set(image, source);+ });+ const gltf = layout.gltfBasename ? await io.writeJSON(doc, { format: Format.GLTF, basename: layout.gltfBasename }) : undefined;const delivery = {target: "three",extensionsUsed: [...json.extensionsUsed ?? []].sort(),@@ -9096,7 +9764,17 @@ async function deliverRuntimeThreeGlb(bytes, meshoptEncoder, options = {}) {kitModules: all.filter((node) => rolesOf(node).includes(KILN_SEMANTIC_ROLES.kitModule)).length}};- return { glb, delivery };+ return {+ glb,+ delivery,+ imageSources,+ ...gltf ? {+ gltf: {+ json: gltf.json,+ resources: gltf.resources+ }+ } : {}+ };}var RUNTIME_THREE_QUANTIZATION, QUANTIZED_SEMANTICS, customRank = (name) => name === "_EDGE" ? 0 : name === "_CAVITY" ? 1 : 2, rolesOf = (node) => readSemanticMetadataV1FromExtras(node.getExtras())?.roles ?? [], isCollider = (node) => rolesOf(node).some((role) => role.startsWith(`${KILN_SEMANTIC_ROLES.collider}.`));var init_runtime_three = __esm(() => {@@ -9105,6 +9783,7 @@ var init_runtime_three = __esm(() => {init_delivery_inspect();init_delivery();init_metrics();+ init_runtime_textures();RUNTIME_THREE_QUANTIZATION = Object.freeze({volume: "mesh",position: 14,@@ -9129,6 +9808,36 @@ function validateMetadataFileName(name) {if (name.length > 200 || !/^[a-z0-9][a-z0-9._-]*\.kiln-metadata\.json$/i.test(name) || /^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(name))throw new Error("Runtime metadata filename must be a portable sibling *.kiln-metadata.json filename");}+function validateGltfFileName(name) {+ if (name.length > 200 || !/^[a-z0-9][a-z0-9._-]*\.gltf$/i.test(name) || /^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(name))+ throw new Error("External texture output must be a portable sibling *.gltf filename");+}+function readGlbBinary(bytes, jsonEnd) {+ if (jsonEnd + 8 > bytes.length)+ return;+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);+ if (view.getUint32(jsonEnd + 4, true) !== 5130562)+ return;+ return bytes.subarray(jsonEnd + 8, jsonEnd + 8 + view.getUint32(jsonEnd, true));+}+function closureMaps(record) {+ const manifests = new Map;+ for (const manifest of [+ ...assetMaterialRootManifests(record),+ ...(record.materialResources?.records ?? []).map(({ manifest }) => manifest)+ ])+ manifests.set(`${manifest.materialId}/${manifest.revisionId}`, manifest);+ const order = (value, other) => value < other ? -1 : value > other ? 1 : 0;+ return [...manifests.values()].flatMap((manifest) => manifest.maps.map((map) => ({+ sha256: map.sha256,+ pin: {+ resourceId: manifest.materialId,+ revisionId: manifest.revisionId,+ sha256: manifest.revisionId+ },+ slot: map.slot+ }))).sort((a, b) => order(a.pin.resourceId, b.pin.resourceId) || order(a.pin.revisionId, b.pin.revisionId) || order(a.slot, b.slot));+}function readGlbJson(bytes) {const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);let end = 12;@@ -9142,7 +9851,7 @@ function readGlbJson(bytes) {}const jsonEnd = 20 + view.getUint32(12, true);const json = JSON.parse(decoder.decode(bytes.subarray(20, jsonEnd)));- if (!object(json) || !object(json.asset) || json.asset.version !== "2.0")+ if (!object2(json) || !object2(json.asset) || json.asset.version !== "2.0")throw new Error("Invalid glTF asset");return { json, jsonEnd };}@@ -9161,13 +9870,13 @@ function writeGlbJson(bytes, jsonEnd, json) {result.set(bytes.subarray(jsonEnd), 20 + length);return result;}-async function deliverThreeRuntimeGlb(glb, options = {}) {+async function deriveThree(glb, options, layout = {}) {const [{ deliverRuntimeThreeGlb }, { MeshoptEncoder }] = await Promise.all([Promise.resolve().then(() => (init_runtime_three(), exports_runtime_three)),import("meshoptimizer")]);await MeshoptEncoder.ready;- const result = await deliverRuntimeThreeGlb(glb, MeshoptEncoder, options);+ const result = await deliverRuntimeThreeGlb(glb, MeshoptEncoder, options, layout);if (result.glb.byteLength > ASSET_LIMIT)throw new Error("Runtime export exceeds 64 MiB");return result;@@ -9182,6 +9891,16 @@ async function exportAssetGlb(record, options = {}) {throw new Error("A runtime export target requires the runtime profile");if (options.compression !== undefined && options.target !== "three")throw new Error("Runtime compression requires the three runtime target");+ const textures = options.textures;+ if (textures !== undefined && textures !== "manifest" && textures !== "external")+ throw new Error("Unknown runtime texture option");+ if (textures !== undefined && profile !== "runtime")+ throw new Error("A texture manifest requires the runtime profile");+ if (textures === "external" && options.target !== "three")+ throw new Error("External textures require target three");+ const gltfName = options.gltfFileName ?? "runtime.gltf";+ if (textures === "external")+ validateGltfFileName(gltfName);validateRecordShape(record);const bytes = record.files["asset.glb"];if (profile === "editable")@@ -9194,7 +9913,7 @@ async function exportAssetGlb(record, options = {}) {}const { json, jsonEnd } = readGlbJson(bytes);const asset = json.asset;- if (owns(asset, "extras") && !object(asset.extras))+ if (owns(asset, "extras") && !object2(asset.extras))throw new Error("Cannot add provenance to non-object asset extras");const extras = asset.extras ?? {};if (owns(extras, "kilnProvenanceV1"))@@ -9203,10 +9922,10 @@ async function exportAssetGlb(record, options = {}) {if (json.scenes !== undefined && !Array.isArray(json.scenes))throw new Error("Invalid glTF scenes");for (const [index, scene] of (json.scenes ?? []).entries()) {- if (!object(scene) || !object(scene.extras) || !owns(scene.extras, "kilnReviewClipsV1"))+ if (!object2(scene) || !object2(scene.extras) || !owns(scene.extras, "kilnReviewClipsV1"))continue;const review = scene.extras.kilnReviewClipsV1;- if (!object(review) || review.version !== 1 && review.version !== 2 || !Array.isArray(review.clips))+ if (!object2(review) || review.version !== 1 && review.version !== 2 || !Array.isArray(review.clips))throw new Error("Unsupported scenes[].extras.kilnReviewClipsV1");scenes.push({ index, kilnReviewClipsV1: review });delete scene.extras.kilnReviewClipsV1;@@ -9221,36 +9940,89 @@ async function exportAssetGlb(record, options = {}) {},scenes};- let base = bytes, baseJson = json, baseJsonEnd = jsonEnd;+ let base = bytes, baseJson = json, baseJsonEnd = jsonEnd, imageSources, gltf;if (options.target === "three") {- const derived = await deliverThreeRuntimeGlb(writeGlbJson(bytes, jsonEnd, json), {+ const derived = await deriveThree(writeGlbJson(bytes, jsonEnd, json), {...options.ktx2Encoder ? { ktx2Encoder: options.ktx2Encoder } : {},...options.compression ? { compression: options.compression } : {}- });+ }, textures === "external" ? { gltfBasename: gltfName.slice(0, -".gltf".length) } : {});metadata.target = "three";metadata.delivery = derived.delivery;base = derived.glb;+ imageSources = derived.imageSources;+ gltf = derived.gltf;({ json: baseJson, jsonEnd: baseJsonEnd } = readGlbJson(base));}+ if (textures !== undefined)+ metadata.textures = await runtimeTextureManifest(baseJson, readGlbBinary(base, baseJsonEnd), {+ ...imageSources ? { sources: imageSources } : {},+ maps: closureMaps(record)+ });+ const external = gltf ? await externalLayout(gltf, metadata.textures ?? []) : undefined;const metadataBytes = encoder2.encode(JSON.stringify(metadata));if (metadataBytes.length > ASSET_LIMIT)throw new Error("Runtime export exceeds 64 MiB");+ const provenance = {+ version: "kiln.provenance.v1",+ profile: "runtime",+ ...options.target ? { target: options.target } : {},+ metadata: { uri: name, sha256: await sha2562(metadataBytes) }+ };const baseAsset = baseJson.asset;baseAsset.extras = {...baseAsset.extras ?? extras,- kilnProvenanceV1: {- version: "kiln.provenance.v1",- profile: "runtime",- ...options.target ? { target: options.target } : {},- metadata: { uri: name, sha256: await sha2562(metadataBytes) }- }+ kilnProvenanceV1: provenance};const result = writeGlbJson(base, baseJsonEnd, baseJson);- return { profile, glb: result, metadata: { name, bytes: metadataBytes } };+ if (!external)+ return { profile, glb: result, metadata: { name, bytes: metadataBytes } };+ const gltfAsset = external.json.asset;+ gltfAsset.extras = {+ ...gltfAsset.extras ?? extras,+ kilnProvenanceV1: provenance+ };+ const gltfBytes = encoder2.encode(JSON.stringify(external.json));+ if (gltfBytes.length > ASSET_LIMIT)+ throw new Error("Runtime export exceeds 64 MiB");+ return {+ profile,+ layout: "gltf",+ glb: result,+ gltf: { name: gltfName, bytes: gltfBytes },+ buffers: external.buffers,+ textures: external.textures,+ metadata: { name, bytes: metadataBytes }+ };+}+async function externalLayout(gltf, manifest) {+ const json = structuredClone(gltf.json);+ const resources = new Map(Object.entries(gltf.resources));+ const images = Array.isArray(json.images) ? json.images : [];+ if (images.length !== manifest.length)+ throw new Error("External texture layout mismatch");+ const textures = new Map;+ for (const [index, image] of images.entries()) {+ const entry = manifest[index];+ const written = typeof image.uri === "string" ? image.uri : "";+ const bytes = resources.get(written);+ if (!bytes || `sha256:${await sha256Hex2(bytes)}` !== entry.sha256)+ throw new Error("External texture bytes differ from the delivered GLB");+ resources.delete(written);+ const uri = `textures/${entry.sha256.slice("sha256:".length)}.${textureFileExtension(entry.mimeType)}`;+ image.uri = uri;+ entry.uri = uri;+ textures.set(uri, { uri, sha256: entry.sha256, bytes });+ }+ const buffers = [...resources].map(([uri, bytes]) => ({ uri, bytes }));+ for (const { uri } of buffers)+ if (!/^[a-z0-9][a-z0-9._-]*\.bin$/i.test(uri))+ throw new Error(`Unexpected external glTF resource ${uri}`);+ return { json, buffers, textures: [...textures.values()] };}-var encoder2, decoder, object = (value) => value !== null && typeof value === "object" && !Array.isArray(value), owns = (value, key) => Object.hasOwn(value, key);+var encoder2, decoder, object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), owns = (value, key) => Object.hasOwn(value, key);var init_asset_export = __esm(() => {init_assets();+ init_runtime_textures();encoder2 = new TextEncoder;decoder = new TextDecoder;});@@ -9728,459 +10500,6 @@ var init_registry = __esm(() => {RENDERER_ID_PATTERN = /^[a-z0-9-]+:/;});-// src/gltf-texture-binding.ts-import * as THREE8 from "three";-function restoreGltfTextureBinding(texture, info) {- texture.minFilter = MIN[info.getMinFilter() ?? 9729];- texture.magFilter = info.getMagFilter() === 9728 ? THREE8.NearestFilter : THREE8.LinearFilter;- texture.wrapS = WRAP[info.getWrapS()];- texture.wrapT = WRAP[info.getWrapT()];- texture.generateMipmaps = [9984, 9985, 9986, 9987].includes(info.getMinFilter() ?? 9729);- texture.flipY = false;- const transform = info.getExtension("KHR_texture_transform");- texture.channel = transform?.getTexCoord() ?? info.getTexCoord();- if (transform) {- texture.offset.fromArray(transform.getOffset());- texture.repeat.fromArray(transform.getScale());- texture.rotation = transform.getRotation();- const c = Math.cos(texture.rotation), s = Math.sin(texture.rotation);- const [sx, sy] = transform.getScale(), [x, y] = transform.getOffset();- texture.matrix.set(sx * c, sy * s, x, -sx * s, sy * c, y, 0, 0, 1);- texture.matrixAutoUpdate = false;- }-}-function gltfTextureBindingKey(info) {- if (!info)- return "";- const transform = info.getExtension("KHR_texture_transform");- return JSON.stringify([- info.getMinFilter(),- info.getMagFilter(),- info.getWrapS(),- info.getWrapT(),- info.getTexCoord(),- transform?.getTexCoord(),- transform?.getOffset(),- transform?.getScale(),- transform?.getRotation(),- info.getExtras()["kilnAtlasReference"]- ]);-}-var MIN, WRAP;-var init_gltf_texture_binding = __esm(() => {- MIN = {- 9728: THREE8.NearestFilter,- 9729: THREE8.LinearFilter,- 9984: THREE8.NearestMipmapNearestFilter,- 9985: THREE8.LinearMipmapNearestFilter,- 9986: THREE8.NearestMipmapLinearFilter,- 9987: THREE8.LinearMipmapLinearFilter- };- WRAP = {- 33071: THREE8.ClampToEdgeWrapping,- 33648: THREE8.MirroredRepeatWrapping,- 10497: THREE8.RepeatWrapping- };-});--// src/atlas-provenance.ts-import * as THREE9 from "three";-function fail4(message) {- throw new TypeError(`atlas provenance: ${message}`);-}-function field(input, key) {- if (!input || typeof input !== "object" || Array.isArray(input))- fail4("plain metadata object required.");- const proto = Object.getPrototypeOf(input);- if (proto !== null && proto !== Object.prototype)- fail4("plain metadata prototype required.");- const d = Object.getOwnPropertyDescriptor(input, key);- if (!d)- return;- if (!d.enumerable || !("value" in d))- fail4("metadata accessors/hidden fields are unsupported.");- return d.value;-}-function closed(input, keys) {- for (const key of Reflect.ownKeys(input))- if (typeof key !== "string" || !keys.includes(key))- fail4("unsupported metadata field.");- for (const key of keys)- field(input, key);- return input;-}-function normalize(input) {- canonicalAtlasMetadataJsonV1(input);- const r = closed(input, ["spec", "manifest"]);- const spec = canonicalizeTextureAtlasSpecV1(r["spec"]);- return { spec, manifest: validateTextureAtlasManifestV1(r["manifest"], spec) };-}-function textureCandidates(texture) {- const direct = field(texture.userData, "kilnAtlas"), resource = field(texture.userData, "kilnMaterialResource");- const map = resource === undefined ? undefined : field(resource, "map"), recipe = map === undefined ? undefined : field(map, "recipe");- const candidates = [];- if (direct !== undefined)- candidates.push(direct);- if (recipe !== undefined && field(recipe, "kind") === "atlas")- candidates.push({ spec: field(recipe, "spec"), manifest: field(recipe, "manifest") });- return candidates;-}-function normalizeCandidates(candidates) {- let result;- for (const candidate of candidates) {- const p = normalize(candidate);- if (result && canonicalAtlasMetadataJsonV1(result) !== canonicalAtlasMetadataJsonV1(p))- fail4("direct and saved atlas identities disagree.");- result = p;- }- return result;-}-function readAtlasTextureProvenance(texture) {- return normalizeCandidates(textureCandidates(texture));-}-function admitTable(input) {- const r = closed(input, ["version", "atlases"]);- if (r["version"] !== ATLAS_PROVENANCE_VERSION)- fail4("unsupported version.");- const entries = r["atlases"];- if (!Array.isArray(entries) || Object.getPrototypeOf(entries) !== Array.prototype)- fail4("dense atlas array required.");- const n = Object.getOwnPropertyDescriptor(entries, "length").value;- if (n > ATLAS_PROVENANCE_LIMITS.atlases || Reflect.ownKeys(entries).length !== n + 1)- fail4("atlas count/density budget exceeded.");- let bytes = TABLE_ENVELOPE_BYTES;- const admitted = [];- for (let i = 0;i < n; i++) {- const d = Object.getOwnPropertyDescriptor(entries, String(i));- if (!d?.enumerable || !("value" in d))- fail4("atlas array accessors are unsupported.");- const json = canonicalAtlasMetadataJsonV1(d.value);- bytes += new TextEncoder().encode(json).length + (i > 0 ? 1 : 0);- if (bytes > ATLAS_PROVENANCE_LIMITS.bytes)- fail4("aggregate metadata byte budget exceeded.");- admitted.push(closed(d.value, ["id", "spec", "manifest"]));- }- return admitted;-}-function validateAtlasProvenanceTable(input) {- const admitted = admitTable(input), ids = new Set, atlases = [];- for (const e of admitted) {- const p = normalize({ spec: e["spec"], manifest: e["manifest"] });- if (e["id"] !== p.manifest.manifestHash || ids.has(e["id"]))- fail4("duplicate or mismatched atlas identity.");- ids.add(e["id"]);- atlases.push({ id: e["id"], ...p });- }- return { version: ATLAS_PROVENANCE_VERSION, atlases };-}-function lookup(table, id) {- const found = table.atlases.find((a) => a.id === id);- if (!found)- fail4("unknown atlas reference.");- return found;-}-function derivedBinding(p, regionName, origin, mode) {- if (!["top-left", "bottom-left"].includes(origin) || !["content-boundary", "texel-center"].includes(mode))- fail4("explicit binding origin/mode required.");- const r = p.manifest.regions.find((r) => r.name === regionName);- if (!r)- fail4("unknown named region.");- const { x, y, width: w, height: h } = r.content, center = mode === "texel-center", bottom = origin === "bottom-left";- return {- manifestHash: p.manifest.manifestHash,- specHash: p.manifest.specHash,- layoutHash: p.manifest.layoutHash,- region: r.name,- content: structuredClone(r.content),- allocation: structuredClone(r.allocation),- inputOrigin: origin,- mode,- scale: [- (w - (center ? 1 : 0)) / p.manifest.width,- (bottom ? -1 : 1) * (h - (center ? 1 : 0)) / p.manifest.height- ],- offset: [- (x + (center ? 0.5 : 0)) / p.manifest.width,- (y + (bottom ? h - (center ? 0.5 : 0) : center ? 0.5 : 0)) / p.manifest.height- ]- };-}-function expandAtlasBinding(input, table) {- canonicalAtlasMetadataJsonV1(input);- const r = closed(input, ["version", "atlasId", "region", "inputOrigin", "mode"]);- if (r["version"] !== ATLAS_PROVENANCE_VERSION)- fail4("unsupported binding version.");- return derivedBinding(lookup(table, r["atlasId"]), r["region"], r["inputOrigin"], r["mode"]);-}-function readAtlasGeometryBinding(geometry, provenance) {- const stamp = field(geometry.userData, "kilnAtlasBinding");- if (stamp === undefined)- return;- canonicalAtlasMetadataJsonV1(stamp);- const r = stamp, derived = derivedBinding(provenance, r["region"], r["inputOrigin"], r["mode"]);- if (canonicalAtlasMetadataJsonV1(stamp) !== canonicalAtlasMetadataJsonV1(derived))- fail4("named binding identity or remap formula mismatch.");- return {- version: ATLAS_PROVENANCE_VERSION,- atlasId: provenance.manifest.manifestHash,- region: r["region"],- inputOrigin: r["inputOrigin"],- mode: r["mode"]- };-}-function collectAtlasProvenance(root) {- const textures = new Map, geometries = new Map, candidates = new Map, sizes = new Map, pendingGeometry = new Map;- let total = TABLE_ENVELOPE_BYTES, pixelBytes = 0, bindings = 0;- root.traverse((node) => {- const mesh = node;- if (!mesh.isMesh && !node.isSprite)- return;- const meshIds = new Set, mats = Array.isArray(mesh.material) ? mesh.material : [mesh.material];- for (const mat of mats)- for (const slot of [- "map",- "normalMap",- "roughnessMap",- "metalnessMap",- "emissiveMap",- "aoMap"- ]) {- const texture = mat[slot];- if (!(texture instanceof THREE9.Texture))- continue;- let ref = textures.get(texture);- if (!ref) {- const raw = textureCandidates(texture);- if (!raw.length)- continue;- for (const candidate of raw) {- canonicalAtlasMetadataJsonV1(candidate);- const r = closed(candidate, ["spec", "manifest"]), id = field(r["manifest"], "manifestHash");- if (typeof id !== "string" || !/^sha256:[0-9a-f]{64}$/.test(id))- fail4("invalid atlas identity.");- const bytes = new TextEncoder().encode(canonicalAtlasMetadataJsonV1({ ...r, id })).length;- const prior = sizes.get(id) ?? 0;- total += Math.max(0, bytes - prior) + (prior === 0 && sizes.size > 0 ? 1 : 0);- sizes.set(id, Math.max(prior, bytes));- if (total > ATLAS_PROVENANCE_LIMITS.bytes || sizes.size > ATLAS_PROVENANCE_LIMITS.atlases)- fail4("aggregate metadata budget exceeded.");- ref ??= { version: ATLAS_PROVENANCE_VERSION, id };- }- const spec = field(raw[0], "spec"), width = field(spec, "width"), height = field(spec, "height");- if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width < 1 || height < 1)- fail4("invalid atlas image dimensions.");- pixelBytes += width * height * 4;- if (pixelBytes > ATLAS_PROVENANCE_LIMITS.bakeDecodedBytes)- fail4("aggregate atlas bake pixel budget exceeded.");- candidates.set(texture, raw);- textures.set(texture, ref);- }- if (++bindings > ATLAS_PROVENANCE_LIMITS.bindings)- fail4("texture binding budget exceeded.");- meshIds.add(ref.id);- }- if (!mesh.isMesh)- return;- const stamp = field(mesh.geometry.userData, "kilnAtlasBinding");- if (stamp === undefined)- return;- if (++bindings > ATLAS_PROVENANCE_LIMITS.bindings)- fail4("primitive binding budget exceeded.");- canonicalAtlasMetadataJsonV1(stamp);- const id = field(stamp, "manifestHash");- if (typeof id !== "string" || !meshIds.has(id))- fail4("named binding has no matching primary atlas texture on this mesh.");- pendingGeometry.set(mesh.geometry, id);- });- const identities = new Map;- for (const [texture, raw] of candidates) {- const p = normalizeCandidates(raw), id = p.manifest.manifestHash, prior = identities.get(id);- if (prior && canonicalAtlasMetadataJsonV1(prior) !== canonicalAtlasMetadataJsonV1(p))- fail4("conflicting atlas identity.");- identities.set(id, p);- textures.set(texture, { version: ATLAS_PROVENANCE_VERSION, id });- }- for (const [geometry, id] of pendingGeometry)- geometries.set(geometry, readAtlasGeometryBinding(geometry, identities.get(id)));- const table = identities.size ? {- version: ATLAS_PROVENANCE_VERSION,- atlases: [...identities].map(([id, p]) => ({ id, ...p }))- } : undefined;- return { table, texture: (t) => textures.get(t), binding: (g) => geometries.get(g) };-}-function rawDocumentTable(doc) {- const scene = doc.getRoot().getDefaultScene() ?? doc.getRoot().listScenes()[0];- return scene ? field(scene.getExtras(), "kilnAtlasProvenance") : undefined;-}-function atlasDocumentTable(doc) {- const raw = rawDocumentTable(doc);- return raw === undefined ? undefined : validateAtlasProvenanceTable(raw);-}-function atlasMaterialUses(doc) {- const uses = [];- for (const mat of doc.getRoot().listMaterials())- for (const [texture, info] of [- [mat.getBaseColorTexture(), mat.getBaseColorTextureInfo()],- [mat.getNormalTexture(), mat.getNormalTextureInfo()],- [mat.getMetallicRoughnessTexture(), mat.getMetallicRoughnessTextureInfo()],- [mat.getEmissiveTexture(), mat.getEmissiveTextureInfo()],- [mat.getOcclusionTexture(), mat.getOcclusionTextureInfo()]- ])- if (texture && info && field(info.getExtras(), "kilnAtlasReference") !== undefined) {- if (uses.length >= ATLAS_PROVENANCE_LIMITS.bindings)- fail4("document binding budget exceeded.");- uses.push({ texture, info });- }- return uses;-}-async function imageHash(texture) {- const bytes = texture.getImage();- if (!bytes || bytes.byteLength > ATLAS_PROVENANCE_LIMITS.encodedBytes)- fail4("encoded image missing or over budget.");- const result = await crypto.subtle.digest("SHA-256", bytes);- return `sha256:${[...new Uint8Array(result)].map((v) => v.toString(16).padStart(2, "0")).join("")}`;-}-function sampler(info) {- const value = {- minFilter: info.getMinFilter(),- magFilter: info.getMagFilter(),- wrapS: info.getWrapS(),- wrapT: info.getWrapT()- };- if (![null, 9728, 9729, 9984, 9985, 9986, 9987].includes(value.minFilter) || ![null, 9728, 9729].includes(value.magFilter) || ![33071, 33648, 10497].includes(value.wrapS) || ![33071, 33648, 10497].includes(value.wrapT))- fail4("unsupported effective sampler.");- return value;-}-function reference(input, table) {- canonicalAtlasMetadataJsonV1(input);- const r = closed(input, ["version", "id", "effectiveSampler", "finalMime", "finalImageSha256"]);- if (r["version"] !== ATLAS_PROVENANCE_VERSION)- fail4("unsupported texture reference version.");- lookup(table, r["id"]);- return r;-}-function admitEncodedImages(uses) {- const seen = new Set;- let total = 0;- for (const { texture } of uses) {- if (seen.has(texture))- continue;- seen.add(texture);- const bytes = texture.getImage();- if (!bytes || bytes.byteLength > ATLAS_PROVENANCE_LIMITS.encodedBytes)- fail4("encoded image missing or over budget.");- total += bytes.byteLength;- if (total > ATLAS_PROVENANCE_LIMITS.aggregateEncodedBytes)- fail4("aggregate encoded image hash budget exceeded.");- }-}-async function refreshAtlasDocumentProvenance(doc) {- const table = atlasDocumentTable(doc), uses = atlasMaterialUses(doc);- if (!uses.length)- return;- if (!table)- fail4("atlas table missing.");- admitEncodedImages(uses);- const hashes = new Map;- for (const { texture, info } of uses) {- const r = reference(field(info.getExtras(), "kilnAtlasReference"), table);- let hash = hashes.get(texture);- if (!hash) {- hash = await imageHash(texture);- hashes.set(texture, hash);- }- info.setExtras({- ...info.getExtras(),- kilnAtlasReference: {- version: ATLAS_PROVENANCE_VERSION,- id: r.id,- effectiveSampler: sampler(info),- finalMime: texture.getMimeType(),- finalImageSha256: hash- }- });- }-}-async function validateAtlasDocumentProvenance(doc) {- const table = atlasDocumentTable(doc), uses = atlasMaterialUses(doc);- if (uses.length && !table)- fail4("atlas table missing.");- if (!table) {- for (const mesh of doc.getRoot().listMeshes())- for (const primitive of mesh.listPrimitives())- if (field(primitive.getExtras(), "kilnAtlasBinding") !== undefined)- fail4("atlas table missing.");- return;- }- admitEncodedImages(uses);- const hashes = new Map;- for (const { texture, info } of uses) {- const r = reference(field(info.getExtras(), "kilnAtlasReference"), table);- let hash = hashes.get(texture);- if (!hash) {- hash = await imageHash(texture);- hashes.set(texture, hash);- }- if (r.finalImageSha256 !== hash || r.finalMime !== texture.getMimeType() || canonicalAtlasMetadataJsonV1(r.effectiveSampler) !== canonicalAtlasMetadataJsonV1(sampler(info)))- fail4("final image or effective sampler identity mismatch.");- }- let bindings = 0;- for (const mesh of doc.getRoot().listMeshes())- for (const prim of mesh.listPrimitives()) {- const binding = field(prim.getExtras(), "kilnAtlasBinding");- if (binding !== undefined) {- if (++bindings > ATLAS_PROVENANCE_LIMITS.bindings)- fail4("primitive budget exceeded.");- expandAtlasBinding(binding, table);- const material = prim.getMaterial(), id = field(binding, "atlasId");- const infos = material ? [- material.getBaseColorTextureInfo(),- material.getNormalTextureInfo(),- material.getMetallicRoughnessTextureInfo(),- material.getEmissiveTextureInfo(),- material.getOcclusionTextureInfo()- ] : [];- if (!infos.some((info) => info && field(info.getExtras(), "kilnAtlasReference") !== undefined && field(field(info.getExtras(), "kilnAtlasReference"), "id") === id))- fail4("named binding has no matching material atlas reference.");- }- }-}-function readValidatedAtlasDelivery(texture) {- const ref = validatedDeliveries.get(texture);- return ref ? structuredClone(ref) : undefined;-}-function readAtlasEncodedTexture(texture) {- const encoded = field(texture.userData, "encoded");- if (encoded === undefined)- return;- const r = closed(encoded, ["mime", "bytes"]);- if (r["mime"] !== "image/png" || !(r["bytes"] instanceof Uint8Array) || r["bytes"].byteLength > ATLAS_PROVENANCE_LIMITS.encodedBytes)- fail4("bounded PNG encoding required.");- return { mime: "image/png", bytes: r["bytes"] };-}-function restoreAtlasTextureProvenance(texture, info, table) {- const r = reference(field(info.getExtras(), "kilnAtlasReference"), table), p = lookup(table, r.id);- texture.userData.kilnAtlas = structuredClone({ spec: p.spec, manifest: p.manifest });- validatedDeliveries.set(texture, Object.freeze(structuredClone(r)));- restoreGltfTextureBinding(texture, info);-}-var ATLAS_PROVENANCE_VERSION = "kiln.atlas-provenance.v1", TABLE_ENVELOPE_BYTES, ATLAS_PROVENANCE_LIMITS, validatedDeliveries;-var init_atlas_provenance = __esm(() => {- init_gltf_texture_binding();- init_texture_atlas_contract();- TABLE_ENVELOPE_BYTES = new TextEncoder().encode(JSON.stringify({ version: ATLAS_PROVENANCE_VERSION, atlases: [] })).length;- ATLAS_PROVENANCE_LIMITS = Object.freeze({- atlases: 128,- bytes: 4194304,- bindings: 1024,- entryBytes: 262144,- encodedBytes: 16777216,- aggregateEncodedBytes: 67108864,- bakeDecodedBytes: 67108864- });- validatedDeliveries = new WeakMap;-});-// src/qa/atlas.tsimport * as THREE10 from "three";function own(value, key) {@@ -23311,7 +23630,7 @@ function canonicalJson2(value) {const sort = (entry) => {if (Array.isArray(entry))return entry.map(sort);- if (object2(entry))+ if (object3(entry))return Object.fromEntries(Object.keys(entry).sort().map((key) => [key, sort(entry[key])]));return entry;};@@ -23375,7 +23694,7 @@ function census(root) {if (materials.length === 0 || materials.some((material) => !(material instanceof THREE33.Material)))throw new Error("Assembly mesh materials must be Material instances.");}- if (!object2(node.userData))+ if (!object3(node.userData))throw new Error("Assembly node metadata must be an object.");jsonData(node.userData, node.name);if (!Array.isArray(node.animations) || node.animations.some((clip) => !(clip instanceof THREE33.AnimationClip)))@@ -23410,7 +23729,7 @@ function census(root) {return { nodes, matrices, semantics, joints, rigs };}function describeAssembly(root, options = {}) {- if (!object2(options))+ if (!object3(options))throw new Error("Assembly description options must be an object.");if (Object.keys(options).some((key) => key !== "clips"))throw new Error("Unknown describeAssembly option.");@@ -23505,7 +23824,7 @@ function describeAssembly(root, options = {}) {function replicateAssembly(source, options) {if (source?.version !== "kiln.assembly.v1")throw new Error("replicateAssembly requires a describeAssembly result.");- if (!object2(options) || typeof options.namespace !== "string" || options.namespace.length > 64 || !/^[a-z][a-z0-9]*(?:[_-][a-z0-9]+)*$/.test(options.namespace))+ if (!object3(options) || typeof options.namespace !== "string" || options.namespace.length > 64 || !/^[a-z][a-z0-9]*(?:[_-][a-z0-9]+)*$/.test(options.namespace))throw new Error("Assembly namespace must be 1-64 lowercase letters/digits with single internal underscores or hyphens, starting with a letter.");const allowedOptions = new Set(["namespace",@@ -23795,7 +24114,7 @@ function replicateAssembly(source, options) {}};}-var ASSEMBLY_LIMITS, metadataKeys, threeConstructors, object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);+var ASSEMBLY_LIMITS, metadataKeys, threeConstructors, object3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);var init_assembly = __esm(() => {init_assembly_transform();init_semantic();@@ -37185,7 +37504,7 @@ function ensureDefaultScene(doc) {root.setDefaultScene(scene);return scene;}-async function sha256Hex2(bytes) {+async function sha256Hex3(bytes) {const digest = await globalThis.crypto.subtle.digest("SHA-256", new Uint8Array(bytes).buffer);return [...new Uint8Array(digest)].map((value) => value.toString(16).padStart(2, "0")).join("");}@@ -37217,7 +37536,7 @@ async function inspectGlbIntegration(bytes, opts = {}) {return {schemaVersion: "kiln.integration-manifest.v1",analyzerVersion: 1,- artifactSha256: await sha256Hex2(bytes),+ artifactSha256: await sha256Hex3(bytes),units: "m",axes: { forward: "+X", up: "+Y", right: "+Z" },bounds: {@@ -37997,7 +38316,7 @@ async function renderSceneToGLB(root, opts = {}) {await refreshAtlasDocumentProvenance(doc);await validateAtlasDocumentProvenance(doc);const bytes = await io.writeBinary(doc);- const artifactGlbSha256 = `sha256:${await sha256Hex2(bytes)}`;+ const artifactGlbSha256 = `sha256:${await sha256Hex3(bytes)}`;const boundBakedTextures = bakedTextures.map((entry) => ({...entry,artifactGlbSha256@@ -40507,7 +40826,7 @@ var init_draw_diagnostics = __esm(() => {// src/widget-transfer.tsimport { deflateSync as deflateSync2, inflateSync as inflateSync2 } from "three/addons/libs/fflate.module.js";-function base64(bytes) {+function base642(bytes) {let binary = "";for (let index = 0;index < bytes.length; index += 8192)binary += String.fromCharCode(...bytes.subarray(index, index + 8192));@@ -40517,8 +40836,8 @@ function encodeWidgetFiles(files) {if (Object.values(files).reduce((total, bytes) => total + bytes.length, 0) > WIDGET_TRANSFER_LIMIT)invalid("exceeds the decoded size limit");return Object.fromEntries(Object.entries(files).map(([name, bytes]) => {- const plain = base64(bytes);- const compressed = base64(deflateSync2(bytes, { level: 6 }));+ const plain = base642(bytes);+ const compressed = base642(deflateSync2(bytes, { level: 6 }));return [name,compressed.length + 64 < plain.length ? { encoding: "kiln.deflate-base64.v1", data: compressed } : plaindiff --git a/dist/viewer/app.js b/dist/viewer/app.jsindex 241efe7f..bbdc0828 100644--- a/dist/viewer/app.js+++ b/dist/viewer/app.js@@ -1,8 +1,12 @@-var _R=Object.create;var{getPrototypeOf:vR,defineProperty:gf,getOwnPropertyNames:ER}=Object;var hb=Object.prototype.hasOwnProperty;function TR(e){return this[e]}var AR,SR,bf=(e,t,n)=>{var i=e!=null&&typeof e==="object";if(i){var r=t?AR??=new WeakMap:SR??=new WeakMap,s=r.get(e);if(s)return s}n=e!=null?_R(vR(e)):{};let a=t||!e||!e.__esModule||!hb.call(e,"default")?gf(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let o of ER(e))if(!hb.call(a,o))gf(a,o,{get:TR.bind(e,o),enumerable:!0})}if(i)r.set(e,a);return a};var Xr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var wR=(e)=>e;function MR(e,t){this[e]=wR.bind(null,t)}var pb=(e,t)=>{for(var n in t)gf(e,n,{get:t[n],enumerable:!0,configurable:!0,set:MR.bind(t,n)})};var Ft=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(i){n=[i]}if(n)throw n[0];return t};function eC(e){if(e==="PORTABLE_MATERIAL_V3_CONTRACT")return'compilePortableMaterialSpecV3 requires schemaVersion 3, model pbrMetallicRoughness, typed V3 procedural or injected resource references, and complete minFilter/magFilter/wrapS/wrapT samplers. Match texture usage to its slot and split work exceeding the material budget. Resource bindings need a host with verified-byte admission. V2 remains available unchanged. Shader code, paths, raw textures and V3 height derivation are unsupported. Read kiln_discover ids ["compilePortableMaterialSpecV3"] for the exact contract.';if(e==="TEXTURE_ATLAS_CONTRACT")return'textureAtlas requires bounded named integer content rectangles with nonoverlapping gutter allocations, matching source crops and usage, and explicit portable sampling. Sources are V3 recipes or exact host-injected library map pins. Split atlases exceeding aggregate work or allocation budgets. remapUVToAtlas requires finite unit UV0, a named content region, inputOrigin and mapping mode; it preserves topology and does not unwrap or tile a region. Read kiln_discover ids ["textureAtlas", "remapUVToAtlas"] for the exact contracts.';if(e==="PROCEDURAL_TEXTURE_V3_CONTRACT")return'proceduralTexture schemaVersion 3 requires bounded JSON: width/height 4..1024, byte RGBA, integer pixel shapes and at most 64 operations. Palette/dither and seeded stamps support only albedo/emissive. Work includes polygon edges and periodic copies. Read kiln_discover ids ["proceduralTexture"] for the V3 contract; keep schemaVersion 2 for existing opaque patterns.';if(e==="BONE_CHAIN_ARGUMENT")return'createBoneChain requires 1..1024 valid local joint descriptors with unique roles and animation-safe names across the parent hierarchy. Use normalized perpendicular forward/bend axes and finite rest transforms; an explicit parentRole must match the declared parent. Read the retained source and kiln_discover ids ["createBoneChain"] for the exact contract.';if(e==="SKIN_BINDING_ARGUMENT")return'createSkinnedPart requires four valid bone indices and finite nonnegative weights per vertex, summing to one unless normalizeWeights:true is explicit. Zero sums are rejected. Assemble distinct named Bones and the parent in one rest-pose hierarchy before binding. Use unbound geometry within the documented budgets and finite invertible transforms. Read the retained source and kiln_discover ids ["createSkinnedPart"] for the exact contract; the Three exporter is required for skin delivery.';if(e==="EXPORT_MATERIAL_SIDE_UNSUPPORTED")return"EXPORT_MATERIAL_SIDE_UNSUPPORTED: A used material has BackSide, which glTF cannot encode directly. Author inward-facing triangles with FrontSide, or choose DoubleSide when both faces are intended. Neither adds missing geometry. Read the retained program with kiln_source query BackSide to locate the material; source names and exception text do not cross the evaluator boundary.";if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="DELIVERY_CONTRACT")return'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].';if(e==="REQUIRE_SOLID")return'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}var ja;var ou=Ft(()=>{ja=class ja extends Error{diagnostic;constructor(e,t=eC(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}});function DC(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function LC(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ho(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function ET(){let e=ho("canvas");return e.style.display="block",e}function Oc(...e){let t="THREE."+e.shift();if(po)po("log",t,...e);else console.log(t,...e)}function TT(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function je(...e){e=TT(e);let t="THREE."+e.shift();if(po)po("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Ze(...e){e=TT(e);let t="THREE."+e.shift();if(po)po("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function fa(...e){let t=e.join(" ");if(t in $v)return;$v[t]=!0,je(...e)}function AT(e,t,n){return new Promise(function(i,r){function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}class Bi{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}function Di(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Cn[e&255]+Cn[e>>8&255]+Cn[e>>16&255]+Cn[e>>24&255]+"-"+Cn[t&255]+Cn[t>>8&255]+"-"+Cn[t>>16&15|64]+Cn[t>>24&255]+"-"+Cn[n&63|128]+Cn[n>>8&255]+"-"+Cn[n>>16&255]+Cn[n>>24&255]+Cn[i&255]+Cn[i>>8&255]+Cn[i>>16&255]+Cn[i>>24&255]).toLowerCase()}function ct(e,t,n){return Math.max(t,Math.min(n,e))}function pm(e,t){return(e%t+t)%t}function FC(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function UC(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function Pc(e,t,n){return(1-n)*e+n*t}function BC(e,t,n,i){return Pc(e,t,1-Math.exp(-n*i))}function zC(e,t=1){return t-Math.abs(pm(e,t*2)-t)}function VC(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*(3-2*e)}function jC(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10)}function HC(e,t){return e+Math.floor(Math.random()*(t-e+1))}function GC(e,t){return e+Math.random()*(t-e)}function $C(e){return e*(0.5-Math.random())}function KC(e){if(e!==void 0)Kv=e;let t=Kv+=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 WC(e){return e*Nc}function XC(e){return e*ha}function qC(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function JC(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function ZC(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function YC(e,t,n,i,r){let{cos:s,sin:a}=Math,o=s(n/2),c=a(n/2),l=s((t+i)/2),u=a((t+i)/2),d=s((t-i)/2),f=a((t-i)/2),h=s((i-t)/2),y=a((i-t)/2);switch(r){case"XYX":e.set(o*u,c*d,c*f,o*l);break;case"YZY":e.set(c*f,o*u,c*d,o*l);break;case"ZXZ":e.set(c*d,c*f,o*u,o*l);break;case"XZX":e.set(o*u,c*y,c*h,o*l);break;case"YXY":e.set(c*h,o*u,c*y,o*l);break;case"ZYZ":e.set(c*y,c*h,o*u,o*l);break;default:je("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ki(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function Ct(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}function QC(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,a){if(this.enabled===!1||s===a||!s||!a)return r;if(this.spaces[s].transfer==="srgb")r.r=Lr(r.r),r.g=Lr(r.g),r.b=Lr(r.b);if(this.spaces[s].primaries!==this.spaces[a].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ);if(this.spaces[a].transfer==="srgb")r.r=fo(r.r),r.g=fo(r.g),r.b=fo(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return fa("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return fa("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(r,s)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:Xv,fromXYZ:qv,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Xv,fromXYZ:qv,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}function Lr(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function fo(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}class mm{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(Za===void 0)Za=ho("canvas");Za.width=e.width,Za.height=e.height;let i=Za.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=Za}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=ho("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Lr(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Lr(t[n]/255)*255);else t[n]=Lr(t[n]);return{data:t,width:e.width,height:e.height}}else return je("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}class Vc{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:eN++}),this.uuid=Di(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,a=i.length;s<a;s++)if(i[s].isDataTexture)r.push(Kh(i[s].image));else r.push(Kh(i[s]))}else r=Kh(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Kh(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return mm.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return je("Texture: Unable to serialize Texture."),{}}class od{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}class jc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new ar,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new ar,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new j,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new j;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new ar,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new j,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new j,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,a=this._targetRay,o=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let y of e.hand.values()){let g=t.getJointPose(y,n),m=this._getHandJoint(c,y);if(g!==null)m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius;m.visible=g!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=l.position.distanceTo(u.position),f=0.02,h=0.005;if(c.inputState.pinching&&d>f+h)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&d<=f-h)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(o!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity);else o.hasLinearVelocity=!1;if(r.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity);else o.hasAngularVelocity=!1;if(o.eventsEnabled)o.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(a!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity);else a.hasLinearVelocity=!1;if(i.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity);else a.hasAngularVelocity=!1;this.dispatchEvent(cN)}}}if(a!==null)a.visible=i!==null;if(o!==null)o.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new ar;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}function qh(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class yi{constructor(e=new j,t=new j,n=new j){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Pi.subVectors(e,t),i.cross(Pi);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Pi.subVectors(i,t),Nr.subVectors(n,t),Jh.subVectors(e,t);let s=Pi.dot(Pi),a=Pi.dot(Nr),o=Pi.dot(Jh),c=Nr.dot(Nr),l=Nr.dot(Jh),u=s*c-a*a;if(u===0)return r.set(0,0,0),null;let d=1/u,f=(c*o-a*l)*d,h=(s*l-a*o)*d;return r.set(1-f-h,h,f)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,Pr)===null)return!1;return Pr.x>=0&&Pr.y>=0&&Pr.x+Pr.y<=1}static getInterpolation(e,t,n,i,r,s,a,o){if(this.getBarycoord(e,t,n,i,Pr)===null){if(o.x=0,o.y=0,"z"in o)o.z=0;if("w"in o)o.w=0;return null}return o.setScalar(0),o.addScaledVector(r,Pr.x),o.addScaledVector(s,Pr.y),o.addScaledVector(a,Pr.z),o}static getInterpolatedAttribute(e,t,n,i,r,s){return ep.setScalar(0),tp.setScalar(0),np.setScalar(0),ep.fromBufferAttribute(e,t),tp.fromBufferAttribute(e,n),np.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(ep,r.x),s.addScaledVector(tp,r.y),s.addScaledVector(np,r.z),s}static isFrontFacing(e,t,n,i){return Pi.subVectors(n,t),Nr.subVectors(e,t),Pi.cross(Nr).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Pi.subVectors(this.c,this.b),Nr.subVectors(this.a,this.b),Pi.cross(Nr).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return yi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return yi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return yi.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return yi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return yi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,a;to.subVectors(i,n),no.subVectors(r,n),Zh.subVectors(e,n);let o=to.dot(Zh),c=no.dot(Zh);if(o<=0&&c<=0)return t.copy(n);Yh.subVectors(e,i);let l=to.dot(Yh),u=no.dot(Yh);if(l>=0&&u<=l)return t.copy(i);let d=o*u-l*c;if(d<=0&&o>=0&&l<=0)return s=o/(o-l),t.copy(n).addScaledVector(to,s);Qh.subVectors(e,r);let f=to.dot(Qh),h=no.dot(Qh);if(h>=0&&f<=h)return t.copy(r);let y=f*c-o*h;if(y<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(n).addScaledVector(no,a);let g=l*h-f*u;if(g<=0&&u-l>=0&&f-h>=0)return iE.subVectors(r,i),a=(u-l)/(u-l+(f-h)),t.copy(i).addScaledVector(iE,a);let m=1/(g+y+d);return s=y*m,a=d*m,t.copy(n).addScaledVector(to,s).addScaledVector(no,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class hn{constructor(e=new j(1/0,1/0,1/0),t=new j(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Oi.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Oi.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Oi.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,a=r.count;s<a;s++){if(e.isMesh===!0)e.getVertexPosition(s,Oi);else Oi.fromBufferAttribute(r,s);Oi.applyMatrix4(e.matrixWorld),this.expandByPoint(Oi)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();Eu.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Eu.copy(n.boundingBox)}Eu.applyMatrix4(e.matrixWorld),this.union(Eu)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Oi),Oi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ac),Tu.subVectors(this.max,Ac),io.subVectors(e.a,Ac),ro.subVectors(e.b,Ac),so.subVectors(e.c,Ac),is.subVectors(ro,io),rs.subVectors(so,ro),ca.subVectors(io,so);let t=[0,-is.z,is.y,0,-rs.z,rs.y,0,-ca.z,ca.y,is.z,0,-is.x,rs.z,0,-rs.x,ca.z,0,-ca.x,-is.y,is.x,0,-rs.y,rs.x,0,-ca.y,ca.x,0];if(!ip(t,io,ro,so,Tu))return!1;if(t=[1,0,0,0,1,0,0,0,1],!ip(t,io,ro,so,Tu))return!1;return Au.crossVectors(is,rs),t=[Au.x,Au.y,Au.z],ip(t,io,ro,so,Tu)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Oi).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(Oi).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return Or[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Or[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Or[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Or[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Or[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Or[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Or[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Or[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Or),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}function ip(e,t,n,i,r){for(let s=0,a=e.length-3;s<=a;s+=3){la.fromArray(e,s);let o=r.x*Math.abs(la.x)+r.y*Math.abs(la.y)+r.z*Math.abs(la.z),c=t.dot(la),l=n.dot(la),u=i.dot(la);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>o)return!1}return!0}class oi{constructor(e=new j,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;if(t!==void 0)n.copy(t);else uN.setFromPoints(e).getCenter(n);let i=0;for(let r=0,s=e.length;r<s;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return e.set(this.center,this.center),e.expandByScalar(this.radius),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Sc.subVectors(e,this.center);let t=Sc.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Sc,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else rp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Sc.copy(e.center).add(rp)),this.expandByPoint(Sc.copy(e.center).sub(rp));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}class Hc{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=Di()}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Di();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Di();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}class So{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Vn.fromBufferAttribute(this,t),Vn.applyMatrix4(e),this.setXYZ(t,Vn.x,Vn.y,Vn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Vn.fromBufferAttribute(this,t),Vn.applyNormalMatrix(e),this.setXYZ(t,Vn.x,Vn.y,Vn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Vn.fromBufferAttribute(this,t),Vn.transformDirection(e),this.setXYZ(t,Vn.x,Vn.y,Vn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=ki(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=Ct(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=Ct(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=Ct(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=Ct(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=Ct(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=ki(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=ki(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=ki(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=ki(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=Ct(t,this.array),n=Ct(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=Ct(t,this.array),n=Ct(n,this.array),i=Ct(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=Ct(t,this.array),n=Ct(n,this.array),i=Ct(i,this.array),r=Ct(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Oc("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new vn(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new So(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){Oc("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}class bi{constructor(e=new j(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=ap.subVectors(n,t).cross(fN.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let i=e.delta(ap),r=this.normal.dot(i);if(r===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let s=-(e.start.dot(this.normal)+this.constant)/r;if(n===!0&&(s<0||s>1))return null;return t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||hN.getNormalMatrix(e),i=this.coplanarPoint(ap).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}class hs{constructor(e=new j,t=new j(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,kr)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=kr.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return kr.copy(this.origin).addScaledVector(this.direction,t),kr.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){op.copy(e).add(t).multiplyScalar(0.5),wu.copy(t).sub(e).normalize(),Mu.copy(this.origin).sub(op);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(wu),a=Mu.dot(this.direction),o=-Mu.dot(wu),c=Mu.lengthSq(),l=Math.abs(1-s*s),u,d,f,h;if(l>0)if(u=s*o-a,d=s*a-o,h=r*l,u>=0)if(d>=-h)if(d<=h){let y=1/l;u*=y,d*=y,f=u*(u+s*d+2*a)+d*(s*u+d+2*o)+c}else d=r,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*o)+c;else d=-r,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*o)+c;else if(d<=-h)u=Math.max(0,-(-s*r+a)),d=u>0?-r:Math.min(Math.max(-r,-o),r),f=-u*u+d*(d+2*o)+c;else if(d<=h)u=0,d=Math.min(Math.max(-r,-o),r),f=d*(d+2*o)+c;else u=Math.max(0,-(s*r+a)),d=u>0?r:Math.min(Math.max(-r,-o),r),f=-u*u+d*(d+2*o)+c;else d=s>0?-r:r,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*o)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(op).addScaledVector(wu,d);return f}intersectSphere(e,t){if(e.radius<0)return null;kr.subVectors(e.center,this.origin);let n=kr.dot(this.direction),i=kr.dot(kr)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),a=n-s,o=n+s;if(o<0)return null;if(a<0)return this.at(o,t);return this.at(a,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,a,o,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;if(c>=0)n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c;else n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c;if(l>=0)r=(e.min.y-d.y)*l,s=(e.max.y-d.y)*l;else r=(e.max.y-d.y)*l,s=(e.min.y-d.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)a=(e.min.z-d.z)*u,o=(e.max.z-d.z)*u;else a=(e.max.z-d.z)*u,o=(e.min.z-d.z)*u;if(n>o||a>i)return null;if(a>n||n!==n)n=a;if(o<i||i!==i)i=o;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,kr)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,a=this.direction,{x:o,y:c,z:l}=a,u=e.x-s.x,d=e.y-s.y,f=e.z-s.z,h=t.x-s.x,y=t.y-s.y,g=t.z-s.z,m=n.x-s.x,p=n.y-s.y,b=n.z-s.z,_=Math.abs(o),x=Math.abs(c),v=Math.abs(l),E,S,T,A,P,w,I,F,N,U,D,O;if(_>=x&&_>=v)if(T=o,w=u,N=h,O=m,o>=0)E=c,S=l,A=d,P=f,I=y,F=g,U=p,D=b;else E=l,S=c,A=f,P=d,I=g,F=y,U=b,D=p;else if(x>=v)if(T=c,w=d,N=y,O=p,c>=0)E=l,S=o,A=f,P=u,I=g,F=h,U=b,D=m;else E=o,S=l,A=u,P=f,I=h,F=g,U=m,D=b;else if(T=l,w=f,N=g,O=b,l>=0)E=o,S=c,A=u,P=d,I=h,F=y,U=m,D=p;else E=c,S=o,A=d,P=u,I=y,F=h,U=p,D=m;if(T===0)return null;let K=E/T,B=S/T,X=1/T,q=A-K*w,le=P-B*w,de=I-K*N,Me=F-B*N,pe=U-K*O,J=D-B*O,L=pe*Me-J*de,W=q*J-le*pe,te=de*le-Me*q;if(i){if(L<0||W<0||te<0)return null}else if((L<0||W<0||te<0)&&(L>0||W>0||te>0))return null;let ie=L+W+te;if(ie===0)return null;let ce=X*(L*w+W*N+te*O);if(ie>0?ce<0:ce>0)return null;return this.at(ce/ie,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}function mN(e,t,n,i,r,s,a,o){let c;if(t.side===1)c=i.intersectTriangle(a,s,r,!0,o);else c=i.intersectTriangle(r,s,a,t.side===0,o);if(c===null)return null;Ou.copy(o),Ou.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Ou);if(l<n.near||l>n.far)return null;return{distance:l,point:Ou.clone(),object:e}}function ku(e,t,n,i,r,s,a,o,c,l){e.getVertexPosition(o,Iu),e.getVertexPosition(c,Cu),e.getVertexPosition(l,Nu);let u=mN(e,t,n,i,Iu,Cu,Nu,aE);if(u){let d=new j;if(yi.getBarycoord(aE,Iu,Cu,Nu,d),r)u.uv=yi.getInterpolatedAttribute(r,o,c,l,d,new Ke);if(s)u.uv1=yi.getInterpolatedAttribute(s,o,c,l,d,new Ke);if(a){if(u.normal=yi.getInterpolatedAttribute(a,o,c,l,d,new j),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let f={a:o,b:c,c:l,normal:new j,materialIndex:0};yi.getNormal(Iu,Cu,Nu,f.normal),u.face=f,u.barycoord=d}return u}class Kc{constructor(e=[],t=[]){this.uuid=Di(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){je("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Qe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Qe;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let a=e[r]?e[r].matrixWorld:bN;dE.multiplyMatrices(a,t[r]),dE.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Kc(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new $c(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)je("Skeleton: No bone found with UUID:",r),s=new Gc;this.bones.push(s),this.boneInverses.push(new Qe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let a=n[i];e.boneInverses.push(a.toArray())}return e}}class Wc{constructor(e=new bi,t=new bi,n=new bi,i=new bi,r=new bi,s=new bi){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],a=r[1],o=r[2],c=r[3],l=r[4],u=r[5],d=r[6],f=r[7],h=r[8],y=r[9],g=r[10],m=r[11],p=r[12],b=r[13],_=r[14],x=r[15];if(i[0].setComponents(c-s,f-l,m-h,x-p).normalize(),i[1].setComponents(c+s,f+l,m+h,x+p).normalize(),i[2].setComponents(c+a,f+u,m+y,x+b).normalize(),i[3].setComponents(c-a,f-u,m-y,x-b).normalize(),n)i[4].setComponents(o,d,g,_).normalize(),i[5].setComponents(c-o,f-d,m-g,x-_).normalize();else if(i[4].setComponents(c-o,f-d,m-g,x-_).normalize(),t===2000)i[5].setComponents(c+o,f+d,m+g,x+_).normalize();else if(t===2001)i[5].setComponents(o,d,g,_).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();da.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();da.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(da)}intersectsSprite(e){da.center.set(0,0,0);let t=xN.distanceTo(e.center);return da.radius=0.7071067811865476+t,da.applyMatrix4(e.matrixWorld),this.intersectsSphere(da)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(Fu.x=i.normal.x>0?e.max.x:e.min.x,Fu.y=i.normal.y>0?e.max.y:e.min.y,Fu.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Fu)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Bu(e,t,n,i,r,s,a){let o=e.geometry.attributes.position;if($u.fromBufferAttribute(o,r),Ku.fromBufferAttribute(o,s),n.distanceSqToSegment($u,Ku,dp,mE)>i)return;dp.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(dp);if(l<t.near||l>t.far)return;return{distance:l,point:mE.clone().applyMatrix4(e.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:e}}function xE(e,t,n,i,r,s,a){let o=pp.distanceSqToPoint(e);if(o<n){let c=new j;pp.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}function va(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(_E(r))if(r.isRenderTargetTexture)je("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(_E(r[0])){let s=[];for(let a=0,o=r.length;a<o;a++)s[a]=r[a].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function kn(e){let t={};for(let n=0;n<e.length;n++){let i=va(e[n]);for(let r in i)t[r]=i[r]}return t}function _E(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function _N(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function xm(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return ot.workingColorSpace}function as(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function Gu(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function TN(e){function t(r,s){return e[r]-e[s]}let n=e.length,i=Array(n);for(let r=0;r!==n;++r)i[r]=r;return i.sort(t),i}function vE(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,a=0;a!==i;++s){let o=n[s]*t;for(let c=0;c!==t;++c)r[a++]=e[o+c]}return r}function AN(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let a=s[i];if(a===void 0)return;if(Array.isArray(a))do{if(a=s[i],a!==void 0)t.push(s.time),n.push(...a);s=e[r++]}while(s!==void 0);else if(a.toArray!==void 0)do{if(a=s[i],a!==void 0)t.push(s.time),a.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(a=s[i],a!==void 0)t.push(s.time),n.push(a);s=e[r++]}while(s!==void 0)}class Br{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let a=t[1];if(e<a)n=2,r=a;for(let o=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===o)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let a=n+s>>>1;if(e<t[a])s=a;else n=a+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}function RT(e,t,n,i,r){let s=1-e;return s*s*s*t+3*s*s*e*n+3*s*e*e*i+e*e*e*r}function SN(e,t,n,i,r){let s=1-e;return 3*s*s*(n-t)+6*s*e*(i-n)+3*e*e*(r-i)}function wN(e,t,n,i,r){let s=(e-t)/(r-t);for(let a=0;a<8;a++){let o=RT(s,t,n,i,r)-e;if(Math.abs(o)<0.0000000001)break;let c=SN(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-o/c))}return s}class li{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=as(t,this.TimeBufferType),this.values=as(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:as(e.times,Array),values:as(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Gu(e.settings))n.settings={inTangents:as(e.settings.inTangents,Array),outTangents:as(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Am(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new gd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Tm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Sm(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return je("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(Gu(this.settings))EE(this.settings.inTangents,e),EE(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let a=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*a,s*a)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Ze("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Ze("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let a=0;a!==r;a++){let o=n[a];if(typeof o==="number"&&isNaN(o)){Ze("KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(s!==null&&s>o){Ze("KeyframeTrack: Out of order keys.",this,a,o,s),e=!1;break}s=o}if(i!==void 0){if(LC(i))for(let a=0,o=i.length;a!==o;++a){let c=i[a];if(isNaN(c)){Ze("KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let a=1;a<r;++a){let o=!1,c=e[a],l=e[a+1];if(c!==l&&(a!==1||c!==e[0]))if(!i){let u=a*n,d=u-n,f=u+n;for(let h=0;h!==n;++h){let y=t[u+h];if(y!==t[d+h]||y!==t[f+h]){o=!0;break}}}else o=!0;if(o){if(a!==s){e[s]=e[a];let u=a*n,d=s*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++s}}if(r>0){e[s]=e[r];for(let a=r*n,o=s*n,c=0;c!==n;++c)t[o+c]=t[a+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,Gu(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function EE(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}class mo{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Di(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,a=n.length;s!==a;++s)t.push(RN(n[s]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=n.length;r!==s;++r)t.push(li.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let a=0;a<r;a++){let o=[],c=[];o.push((a+r-1)%r,a,(a+1)%r),c.push(0,1,0);let l=TN(o);if(o=vE(o,1,l),c=vE(c,1,l),!i&&o[0]===0)o.push(r),c.push(c[0]);s.push(new bs(".morphTargetInfluences["+t[a].name+"]",o,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,o=e.length;a<o;a++){let c=e[a],l=c.name.match(r);if(l&&l.length>1){let u=l[1],d=i[u];if(!d)i[u]=d=[];d.push(c)}}let s=[];for(let a in i)s.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function MN(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return bs;case"vector":case"vector2":case"vector3":case"vector4":return Ea;case"color":return bd;case"quaternion":return ys;case"bool":case"boolean":return gs;case"string":return xs}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function RN(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=MN(e.type);if(e.times===void 0){let i=[],r=[];AN(e.keys,i,r,"value"),e.times=i,e.values=r}let n;if(t.parse!==void 0)n=t.parse(e);else n=new t(e.name,e.times,e.values,e.interpolation);if(Gu(e.settings))n.settings={inTangents:as(e.settings.inTangents,Float32Array),outTangents:as(e.settings.outTangents,Float32Array)};return n}function TE(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class Zc{constructor(e,t,n){let i=this,r=!1,s=0,a=0,o=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(a++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,a)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,a);if(s===a){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),o)return o(l);return l},this.setURLModifier=function(l){return o=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,d=c.length;u<d;u+=2){let f=c[u],h=c[u+1];if(f.global)f.lastIndex=0;if(f.test(l))return h}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}class zr{constructor(e){if(this.manager=e!==void 0?e:IT,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}class Qc{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ke(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Qe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Wc,this._frameExtents=new Ke(1,1),this._viewportCount=1,this._viewports=[new Nt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;AE.setFromMatrixPosition(e.matrixWorld),t.position.copy(AE),SE.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(SE),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){fp.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(fp,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,a=i?i.w/r.y:1,o=i?i.x/r.x:0,c=i?i.y/r.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*s,0,0,0.5*s+o,0,0.5*a,0,0.5*a+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+o,0,0.5*a,0,0.5*a+c,0,0,0.5,0.5,0,0,0,1);t.multiply(fp)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class _s{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}class Cm{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let a=0;a!==i;++a)n[r+a]=n[a];s=t}else{s+=t;let a=t/s;this._mixBufferRegion(n,r,0,a,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let o=t*this._origIndex;this._mixBufferRegion(n,i,o,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let o=t,c=t+t;o!==c;++o)if(n[o]!==n[o+t]){a.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){ln.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;ln.multiplyQuaternionsFlat(e,s,e,t,e,n),ln.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let a=0;a!==r;++a){let o=t+a;e[o]=e[o]*s+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let a=t+s;e[a]=e[a]+e[n+s]*i}}}class kT{constructor(e,t,n){let i=n||Et.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class Et{constructor(e,t,n){this.path=t,this.parsedPath=n||Et.parseTrackName(t),this.node=Et.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new Et(e,t,n);else return new Et.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(IN,"")}static parseTrackName(e){let t=DN.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);if(LN.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let a=r[s];if(a.name===t||a.uuid===t)return a;let o=n(a.children);if(o)return o}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=Et.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){je("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ze("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Ze("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ze("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Ze("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Ze("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;Ze("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)a=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)a=this.Versioning.MatrixWorldNeedsUpdate;let o=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)o=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))o=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}class Om{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,s=r.length,a=Array(s),o={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);a[c]=l,l.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,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(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,r=e._clip.duration,s=r/i,a=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;if(e!==null)this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,s=this.timeScale,a=this._timeScaleInterpolant;if(a===null)a=i._lendControlInterpolant(),this._timeScaleInterpolant=a;let o=a.parameterPositions,c=a.sampleValues;return o[0]=r,o[1]=r+n,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;if(e!==null)this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}let r=this._startTime;if(r!==null){let o=(e-r)*n;if(o<0||n===0)t=0;else this._startTime=null,t=n*o}t*=this._updateTimeScale(e);let s=this._updateTime(t),a=this._updateWeight(e);if(a>0){let o=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=o.length;l!==u;++l)o[l].evaluate(s),c[l].accumulateAdditive(a);break;case 2500:default:for(let l=0,u=o.length;l!==u;++l)o[l].evaluate(s),c[l].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(this.stopFading(),i===0)this.enabled=!1}}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(t===0)this.paused=!0;else{if(this._restoreTimeScale!==null)t=this._restoreTimeScale;this.timeScale=t}this.stopWarping()}}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,s=n===2202;if(e===0){if(r===-1)return i;return s&&(r&1)===1?t-i:i}if(n===2200){if(r===-1)this._loopCount=0,this._setEndings(!0,!0,!1);e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1)if(e>=0)r=0,this._setEndings(!0,this.repetitions===0,s);else this._setEndings(this.repetitions===0,!0,s);if(i>=t||i<0){let a=Math.floor(i/t);i-=t*a,r+=Math.abs(a);let o=this.repetitions-r;if(o<=0){if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1})}else{if(o===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this._loopCount=r,this.time=i;if(s&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;if(n)i.endingStart=2401,i.endingEnd=2401;else{if(e)i.endingStart=this.zeroSlopeAtStart?2401:2400;else i.endingStart=2402;if(t)i.endingEnd=this.zeroSlopeAtEnd?2401:2400;else i.endingEnd=2402}}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,s=this._weightInterpolant;if(s===null)s=i._lendControlInterpolant(),this._weightInterpolant=s;let a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=t,a[1]=r+e,o[1]=n,this}}class el{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=ct(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(ct(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}function Dm(e,t,n,i){let r=UN(i);switch(n){case 1021:return e*t;case 1028:return e*t/r.components*r.byteLength;case 1029:return e*t/r.components*r.byteLength;case 1030:return e*t*2/r.components*r.byteLength;case 1031:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case 1023:return e*t*4/r.components*r.byteLength;case 1033:return e*t*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function UN(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}var RE="186",cs,ls,IE=0,mp=1,CE=2,kc=1,NE=2,go=3,us=0,Pn=1,xi=2,lr=0,Dc=1,gp=2,bp=3,yp=4,PE=5,bo=100,OE=101,kE=102,DE=103,LE=104,FE=200,UE=201,BE=202,zE=203,VE=204,jE=205,HE=206,GE=207,$E=208,KE=209,WE=210,XE=211,qE=212,JE=213,ZE=214,YE=0,QE=1,eT=2,xp=3,tT=4,nT=5,iT=6,rT=7,sT=0,aT=1,oT=2,Li=0,_p=1,vp=2,Ep=3,Lc=4,Tp=5,Ap=6,Sp=7,yo=301,pa=302,Wu=303,Xu=304,Fc=306,xo=1000,_o=1001,qu=1002,Fi=1003,Ju=1004,ma=1005,En=1006,vo=1007,ur=1008,Ui=1009,cT=1010,lT=1011,Uc=1012,wp=1013,ds=1014,Fr=1015,dr=1016,Mp=1017,Rp=1018,Eo=1020,uT=35902,dT=35899,fT=1021,hT=1022,fr=1023,ga=1026,ba=1027,pT=1028,Ip=1029,ya=1030,Cp=1031,Np=1033,Zu=33776,Yu=33777,Qu=33778,ed=33779,Pp=35840,Op=35841,kp=35842,Dp=35843,Lp=36196,Fp=37492,Up=37496,Bp=37488,zp=37489,td=37490,Vp=37491,jp=37808,Hp=37809,Gp=37810,$p=37811,Kp=37812,Wp=37813,Xp=37814,qp=37815,Jp=37816,Zp=37817,Yp=37818,Qp=37819,em=37820,tm=37821,nm=36492,im=36494,rm=36495,sm=36283,am=36284,nd=36285,om=36286,cm=2300,id=2301,lm=0,Bc=1,To=2,um=0,mT=1,xa="",fs="srgb",si="srgb-linear",dm="linear",Bt="srgb",gT=512,bT=513,yT=514,rd=515,xT=516,_T=517,sd=518,vT=519,fm="300 es",hm=2000,$v,po=null,ST,Cn,Kv=1234567,Nc,ha,zc,Ke,ln,j,Gh,Wv,tt,$h,Xv,qv,ot,Za,eN=0,tN=0,Wh,Qt,Nt,gm,ai,ad,bm,Qe,Ya,Ni,nN,iN,ts,xu,ii,Jv,Zv,cr,rN=0,Yv,Qa,Cr,_u,Tc,sN,aN,Qv,eE,tE,nE,oN,eo,Xh,kt,ar,cN,wT,ns,vu,qe,Nn,Ao,Pi,Nr,Jh,Pr,to,no,iE,Zh,Yh,Qh,ep,tp,np,Or,Oi,Eu,io,ro,so,is,rs,ca,Ac,Tu,Au,la,cn,Su,lN=0,vn,cd,ld,Gn,uN,Sc,rp,dN=0,gi,sp,ao,ri,wc,_n,On,Vn,ap,fN,hN,pN=0,$n,kr,op,wu,Mu,hr,rE,ua,Ru,sE,Iu,Cu,Nu,cp,Pu,aE,Ou,jt,Mc,oE,cE,gN,lE,Du,lp,uE,up,ud,Gc,$c,dE,bN,os,oo,fE,Lu,hE,yN,Rc,Ic,wo,da,xN,Fu,Xc,$u,Ku,pE,Cc,Uu,dp,mE,ps,gE,bE,dd,fd,qc,yE,pp,zu,Vu,Mo,hd,_a,ym,pd,ms,Jc,MT,vN=`void main() {+var QR=Object.create;var{getPrototypeOf:eI,defineProperty:Of,getOwnPropertyNames:tI}=Object;var Nb=Object.prototype.hasOwnProperty;function nI(e){return this[e]}var iI,rI,kf=(e,t,n)=>{var i=e!=null&&typeof e==="object";if(i){var r=t?iI??=new WeakMap:rI??=new WeakMap,s=r.get(e);if(s)return s}n=e!=null?QR(eI(e)):{};let a=t||!e||!e.__esModule||!Nb.call(e,"default")?Of(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let o of tI(e))if(!Nb.call(a,o))Of(a,o,{get:nI.bind(e,o),enumerable:!0})}if(i)r.set(e,a);return a};var Jr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var sI=(e)=>e;function aI(e,t){this[e]=sI.bind(null,t)}var Pb=(e,t)=>{for(var n in t)Of(e,n,{get:t[n],enumerable:!0,configurable:!0,set:aI.bind(t,n)})};var mt=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(i){n=[i]}if(n)throw n[0];return t};var ir;var Ec=mt(()=>{ir=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"]});function OC(e){if(e==="PORTABLE_MATERIAL_V3_CONTRACT")return'compilePortableMaterialSpecV3 requires schemaVersion 3, model pbrMetallicRoughness, typed V3 procedural or injected resource references, and complete minFilter/magFilter/wrapS/wrapT samplers. Match texture usage to its slot and split work exceeding the material budget. Resource bindings need a host with verified-byte admission. V2 remains available unchanged. Shader code, paths, raw textures and V3 height derivation are unsupported. Read kiln_discover ids ["compilePortableMaterialSpecV3"] for the exact contract.';if(e==="TEXTURE_ATLAS_CONTRACT")return'textureAtlas requires bounded named integer content rectangles with nonoverlapping gutter allocations, matching source crops and usage, and explicit portable sampling. Sources are V3 recipes or exact host-injected library map pins. Split atlases exceeding aggregate work or allocation budgets. remapUVToAtlas requires finite unit UV0, a named content region, inputOrigin and mapping mode; it preserves topology and does not unwrap or tile a region. Read kiln_discover ids ["textureAtlas", "remapUVToAtlas"] for the exact contracts.';if(e==="PROCEDURAL_TEXTURE_V3_CONTRACT")return'proceduralTexture schemaVersion 3 requires bounded JSON: width/height 4..1024, byte RGBA, integer pixel shapes and at most 64 operations. Palette/dither supports only albedo/emissive; seeded stamps accept every usage. Work includes polygon edges and periodic copies. Read kiln_discover ids ["proceduralTexture"] for the V3 contract; keep schemaVersion 2 for existing opaque patterns.';if(e==="BONE_CHAIN_ARGUMENT")return'createBoneChain requires 1..1024 valid local joint descriptors with unique roles and animation-safe names across the parent hierarchy. Use normalized perpendicular forward/bend axes and finite rest transforms; an explicit parentRole must match the declared parent. Read the retained source and kiln_discover ids ["createBoneChain"] for the exact contract.';if(e==="SKIN_BINDING_ARGUMENT")return'createSkinnedPart requires four valid bone indices and finite nonnegative weights per vertex, summing to one unless normalizeWeights:true is explicit. Zero sums are rejected. Assemble distinct named Bones and the parent in one rest-pose hierarchy before binding. Use unbound geometry within the documented budgets and finite invertible transforms. Read the retained source and kiln_discover ids ["createSkinnedPart"] for the exact contract; the Three exporter is required for skin delivery.';if(e==="EXPORT_MATERIAL_SIDE_UNSUPPORTED")return"EXPORT_MATERIAL_SIDE_UNSUPPORTED: A used material has BackSide, which glTF cannot encode directly. Author inward-facing triangles with FrontSide, or choose DoubleSide when both faces are intended. Neither adds missing geometry. Read the retained program with kiln_source query BackSide to locate the material; source names and exception text do not cross the evaluator boundary.";if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="DELIVERY_CONTRACT")return'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].';if(e==="REQUIRE_SOLID")return'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="PROCEDURAL_TEXTURE_USAGE")return'proceduralTexture usage is one of albedo (the default), emissive, normal, roughness, metalness, metallicRoughness or occlusion; there is no data or height usage. Match it to the slot it fills: portable material baseColor takes albedo, normal takes normal, metallicRoughness takes metallicRoughness (G roughness, B metalness), emissive takes emissive and occlusion takes occlusion; pbrMaterial albedo, normal, roughness, metalness, metallicRoughness, emissive and aoMap take the matching usage. Call kiln_discover with ids ["proceduralTexture"].';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}var Xa;var vu=mt(()=>{Xa=class Xa extends Error{diagnostic;constructor(e,t=OC(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}});function wu(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new yt(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new yt(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new yt(`${t} must not contain symbol keys.`);if(kC.has(i))throw new yt(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new yt(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new yt(`${t}.${i} must be a plain JSON data field.`)}return e}function DC(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new yt(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new yt(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new yt(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new yt(`${t} must be a dense JSON array (missing index ${n}).`);return e}function ts(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new yt(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function Ni(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new yt(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function la(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new yt(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function kv(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new yt(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function Gh(e,t,n){return kv(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function LC(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>Cv||n)throw new yt(`${t} must be 1..${Cv} visible characters.`);return e}function FC(e,t,n){if(e===void 0)return n;if(!ir.includes(e))throw new yt(`${t} must be one of ${ir.join(", ")}, got ${JSON.stringify(e)}.`,"PROCEDURAL_TEXTURE_USAGE");return e}function Ov(e,t){let i=(kv(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function UC(e,t){let n=e.blend??"normal";if(!Pv.includes(n))throw new yt(`${t}.blend ${JSON.stringify(n)} is not one of ${Pv.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function BC(e,t){let n=`proceduralTexture.layers[${t}]`,i=wu(e,n),r=i.op;if(!Nv.includes(r))throw new yt(`${n}.op ${JSON.stringify(r)} is not one of ${Nv.join(", ")}.`);let s=UC(i,n),a=Gh(i.opacity,`${n}.opacity`,1),o={blend:t===0?"normal":s,opacity:t===0?1:a};switch(r){case"solid":return ts(i,["op","color","blend","opacity"],n),{op:r,color:Ni(i.color,`${n}.color`),...o};case"checker":return ts(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:Ni(i.colorA,`${n}.colorA`),colorB:Ni(i.colorB,`${n}.colorB`),squares:la(i.squares,`${n}.squares`,8,1,ua),...o};case"stripes":return ts(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:Ni(i.colorA,`${n}.colorA`),colorB:Ni(i.colorB,`${n}.colorB`),count:la(i.count,`${n}.count`,8,1,ua),angleDeg:Ov(i.angleDeg,`${n}.angleDeg`),...o};case"gradient":return ts(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:Ni(i.from,`${n}.from`),to:Ni(i.to,`${n}.to`),angleDeg:Ov(i.angleDeg,`${n}.angleDeg`),...o};case"bricks":return ts(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:Ni(i.brick,`${n}.brick`),mortar:Ni(i.mortar,`${n}.mortar`),rows:la(i.rows,`${n}.rows`,8,1,ua),cols:la(i.cols,`${n}.cols`,4,1,ua),mortarWidth:Gh(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:Gh(i.stagger,`${n}.stagger`,0.5),...o};case"noise":return ts(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:Ni(i.colorA,`${n}.colorA`),colorB:Ni(i.colorB,`${n}.colorB`),scale:la(i.scale,`${n}.scale`,8,1,ua),octaves:la(i.octaves,`${n}.octaves`,3,1,$h),seed:la(i.seed,`${n}.seed`,0,-2147483648,2147483647),...o};default:throw new yt(`${n}.op is unsupported.`)}}function zC(e){let t=wu(e,"proceduralTexture");if(ts(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new yt(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function Tc(e){let t=wu(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?wu(zC(t),"proceduralTexture"):t;if(ts(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new yt(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<Tu||i>Eu||(i&i-1)!==0)throw new yt(`proceduralTexture.size must be a power of two between ${Tu} and ${Eu}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new yt("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=DC(r,"proceduralTexture.layers");if(s.length>Au)throw new yt(`proceduralTexture: ${s.length} layers exceeds the maximum of ${Au}.`);let a=LC(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:FC(n.usage,"proceduralTexture.usage","albedo"),...a!==void 0?{name:a}:{},layers:s.map(BC)}}function qa(e){let t=new TextEncoder().encode(e),n=t.length*8,i=Math.ceil((t.length+9)/64)*64,r=new Uint8Array(i);r.set(t),r[t.length]=128;let s=new DataView(r.buffer);s.setUint32(i-8,Math.floor(n/4294967296),!1),s.setUint32(i-4,n>>>0,!1);let a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),o=new Uint32Array(64);for(let c=0;c<r.length;c+=64){for(let x=0;x<16;x++)o[x]=s.getUint32(c+x*4,!1);for(let x=16;x<64;x++){let _=o[x-15],y=o[x-2],v=rr(_,7)^rr(_,18)^_>>>3,T=rr(y,17)^rr(y,19)^y>>>10;o[x]=o[x-16]+v+o[x-7]+T>>>0}let[l,u,d,f,h,b,m,g]=a;for(let x=0;x<64;x++){let _=rr(h,6)^rr(h,11)^rr(h,25),y=h&b^~h&m,v=g+_+y+VC[x]+o[x]>>>0,T=rr(l,2)^rr(l,13)^rr(l,22),A=l&u^l&d^u&d,E=T+A>>>0;g=m,m=b,b=h,h=f+v>>>0,f=d,d=u,u=l,l=v+E>>>0}let p=[l,u,d,f,h,b,m,g];for(let x=0;x<8;x++)a[x]=a[x]+p[x]>>>0}return[...a].map((c)=>c.toString(16).padStart(8,"0")).join("")}var Eu=1024,Tu=4,Au=8,$h=6,Cv=80,ua=256,yt,Nv,Pv,kC,VC,rr=(e,t)=>e>>>t|e<<32-t;var Ja=mt(()=>{Ec();vu();yt=class yt extends Xa{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}};Nv=["solid","checker","stripes","gradient","bricks","noise"],Pv=["normal","multiply","screen","overlay"],kC=new Set(["__proto__","prototype","constructor"]);VC=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298])});function bt(e,t="PROCEDURAL_TEXTURE_V3_CONTRACT"){throw new yt(`proceduralTexture V3: ${e}`,t)}function $C(e){let t=0,n=(i,r,s)=>{if(++t>16384||s>10)bt(`${r} exceeds the JSON size/depth budget.`);if(i===null||typeof i==="boolean")return;if(typeof i==="string"){if(i.length>4096)bt(`${r} string is too long.`);return}if(typeof i==="number"){if(!Number.isFinite(i))bt(`${r} must be finite.`);return}if(typeof i!=="object")bt(`${r} must contain only JSON data.`);let a=Array.isArray(i),o=Object.getPrototypeOf(i);if(a?o!==Array.prototype:o!==Object.prototype&&o!==null)bt(`${r} must be a plain JSON ${a?"array":"object"}.`);let c=a?Object.getOwnPropertyDescriptor(i,"length")?.value:void 0;if(a&&(typeof c!=="number"||c>1024))bt(`${r} array is too long.`);let l=Reflect.ownKeys(i);if(l.length>1024)bt(`${r} has too many fields.`);let u=Object.getOwnPropertyDescriptors(i);for(let d of l){if(typeof d!=="string"||GC.has(d))bt(`${r} has a forbidden key.`);if(a&&d==="length")continue;let f=u[d];if(!f.enumerable||!("value"in f))bt(`${r}.${d} must be an enumerable JSON data field, never an accessor.`);if(a&&(!/^(0|[1-9][0-9]*)$/.test(d)||Number(d)>=c))bt(`${r} has an invalid array key.`)}if(a&&l.length!==c+1)bt(`${r} must be a dense JSON array.`);for(let d of l)if(d!=="length"||!a)n(u[d].value,`${r}.${String(d)}`,s+1)};n(e,"recipe",0)}function bi(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))bt(`${n} must be a JSON object.`);let i=e;for(let r of Object.keys(i))if(!t.includes(r))bt(`${n} has unknown field ${r}.`);return i}function Vn(e,t,n,i,r){if(e===void 0&&r!==void 0)return r;if(typeof e!=="number"||!Number.isInteger(e)||e<t||e>n)bt(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function Lv(e,t){if(e===void 0)return!1;if(typeof e!=="boolean")bt(`${t} must be boolean.`);return e}function Su(e,t,n,i,r){if(!Array.isArray(e)||e.length!==t)bt(`${n} must be a ${t}-element array.`);return e.map((s,a)=>Vn(s,i,r,`${n}[${a}]`))}function Fv(e,t){let n=Su(e,4,t,0,255);return n[3]===0?[0,0,0,0]:n}function Uv(e,t,n){let i=bi(e,["x","y","width","height",...n?["kind"]:[]],t);return{x:Vn(i.x,-4096,4096,`${t}.x`),y:Vn(i.y,-4096,4096,`${t}.y`),width:Vn(i.width,1,2048,`${t}.width`),height:Vn(i.height,1,2048,`${t}.height`)}}function KC(e,t){let n=bi(e,["kind","x","y","width","height","from","to","points"],t);if(n.kind==="rectangle"||n.kind==="ellipse")return{kind:n.kind,...Uv(n,t,n.kind)};if(n.kind==="polygon"){bi(n,["kind","points"],t);let i=n.points;if(!Array.isArray(i)||i.length<3||i.length>Mu)bt(`${t}.points requires 3..${Mu} vertices.`);return{kind:"polygon",points:i.map((r,s)=>Su(r,2,`${t}.points[${s}]`,-4096,4096))}}if(n.kind==="line")return bi(n,["kind","from","to","width"],t),{kind:"line",from:Su(n.from,2,`${t}.from`,-4096,4096),to:Su(n.to,2,`${t}.to`,-4096,4096),width:Vn(n.width,1,2048,`${t}.width`)};return bt(`${t}.kind must be rectangle, ellipse, polygon or line.`)}function Bv(e){if(e.kind==="rectangle"||e.kind==="ellipse")return[e.x,e.y,e.x+e.width,e.y+e.height];let t=e.kind==="polygon"?e.points:[e.from,e.to],n=e.kind==="line"?e.width/2:0;return[Math.min(...t.map((i)=>i[0]))-n,Math.min(...t.map((i)=>i[1]))-n,Math.max(...t.map((i)=>i[0]))+n,Math.max(...t.map((i)=>i[1]))+n]}function WC(e){return e.kind==="polygon"?e.points.length+1:e.kind==="line"?4:e.kind==="ellipse"?3:1}function XC(e,t,n,i=0,r=0){let[s,a,o,c]=Bv(e);return[Math.max(0,Math.ceil(s+i-0.5)),Math.max(0,Math.ceil(a+r-0.5)),Math.min(t,Math.floor(o+i-0.5)+1),Math.min(n,Math.floor(c+r-0.5)+1)]}function Iu(e){$C(e);let t=bi(e,["schemaVersion","width","height","usage","name","background","operations","palette"],"recipe");if(t.schemaVersion!==3)bt("schemaVersion must be 3.");let n=Vn(t.width,4,wc,"width"),i=Vn(t.height,4,wc,"height"),r=n*i;if(r>jC)bt("output texel budget exceeded.");let s=t.usage===void 0?"albedo":t.usage;if(!ir.includes(s))bt("usage must be a known texture usage.","PROCEDURAL_TEXTURE_USAGE");let a=s==="albedo"||s==="emissive",o=t.name;if(o!==void 0&&(typeof o!=="string"||!o.length||o.length>80||[...o].some((g)=>g.charCodeAt(0)<32||g.charCodeAt(0)===127)))bt("name must be 1..80 visible characters.");let c=t.operations;if(!Array.isArray(c)||c.length>Sc)bt(`operations must be an array with at most ${Sc} entries.`);let l=r,u=0,d=0,f=c.map((g,p)=>{let x=`operations[${p}]`,_=bi(g,["op","shape","rgba","opacity","alpha","invert","spec","count","seed","area","periodic"],x);if(_.op==="legacy-v2"){bi(_,["op","spec","alpha","opacity"],x);let K=bi(_.spec,["schemaVersion","size","usage","name","layers"],`${x}.spec`);if(K.schemaVersion!==2)bt(`${x}.spec requires explicit schemaVersion 2.`);let B=Tc(K);if(B.size!==n||B.size!==i||B.usage!==s)bt(`${x} legacy-v2 dimensions and usage must match the V3 surface.`);return l+=r*(1+B.layers.reduce((X,q)=>X+(q.op==="noise"?q.octaves*16:4),0)),d+=r*4,{op:"legacy-v2",spec:B,alpha:Vn(_.alpha,0,255,`${x}.alpha`,255),opacity:Vn(_.opacity,0,255,`${x}.opacity`,255)}}let y=KC(_.shape,`${x}.shape`),v=WC(y),[T,A,E,w]=XC(y,n,i),P=Math.max(0,E-T)*Math.max(0,w-A);if(_.op==="mask")return bi(_,["op","shape","alpha","invert"],x),l+=r+P*v,{op:"mask",shape:y,alpha:Vn(_.alpha,0,255,`${x}.alpha`,255),invert:Lv(_.invert,`${x}.invert`)};if(_.op!=="paint"&&_.op!=="stamps")return bt(`${x}.op must be paint, mask, stamps or legacy-v2.`);let S={shape:y,rgba:Fv(_.rgba,`${x}.rgba`),opacity:Vn(_.opacity,0,255,`${x}.opacity`,255)};if(_.op==="paint")return bi(_,["op","shape","rgba","opacity"],x),l+=P*(v+1),{op:"paint",...S};bi(_,["op","shape","rgba","opacity","count","seed","area","periodic"],x);let I=Vn(_.count,1,Ac,`${x}.count`),U=Lv(_.periodic,`${x}.periodic`),[N,F,D,O]=Bv(y);if(U&&(D-N>n||O-F>i))bt(`${x} periodic shape bounds must fit one surface period.`);if(u+=I*(U?9:1),u>Ac)bt(`expanded stamps budget exceeds ${Ac}.`);return l+=I*(U?9:1)*Math.min(n,Math.ceil(D-N)+1)*Math.min(i,Math.ceil(O-F)+1)*(v+1),{op:"stamps",...S,count:I,seed:Vn(_.seed,0,4294967295,`${x}.seed`),area:Uv(_.area,`${x}.area`),periodic:U}}),h;if(t.palette!==void 0){if(!a)bt("palette and dither are supported only for color usages albedo and emissive.");let g=bi(t.palette,["colors","dither"],"palette"),p=g.colors;if(!Array.isArray(p)||p.length<1||p.length>Ru)bt(`palette.colors requires 1..${Ru} entries.`);let x=g.dither===void 0?"none":g.dither;if(x!=="none"&&x!=="bayer4")bt("palette.dither must be none or bayer4.");h={colors:p.map((_,y)=>Vn(_,0,16777215,`palette.colors[${y}]`)),dither:x},l+=r*(p.length+1)}if(l>Dv)bt(`estimated work budget ${l} exceeds ${Dv}.`);if(r*4+d>HC)bt("transient allocation budget exceeded.");let b={schemaVersion:3,width:n,height:i,usage:s,...o!==void 0?{name:o}:{},background:t.background===void 0?[0,0,0,0]:Fv(t.background,"background"),operations:f,...h?{palette:h}:{}},m=JSON.stringify(b);if(m.length>262144)bt("canonical JSON byte budget exceeded.");return{spec:b,canonicalJson:m,estimatedWorkUnits:l,conservativePixelAllocationBytes:r*4+d}}function Kh(e){return Iu(e).spec}function qC(e){return Iu(e).canonicalJson}function Wh(e){return`sha256:${qa(`${Za}+${qC(e)}`)}`}var Za="kiln.procedural-rgba.v3.1",wc=1024,jC=1048576,Sc=64,Mu=64,Ac=256,Ru=32,Dv=64000000,HC=67108864,GC;var Cu=mt(()=>{Ja();Ec();GC=new Set(["__proto__","prototype","constructor"])});function Nu(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new yt("portableSampler requires a complete JSON object.");let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new yt("portableSampler must be plain JSON data.");for(let r of Reflect.ownKeys(e)){let s=Object.getOwnPropertyDescriptor(e,r);if(typeof r!=="string"||!s.enumerable||!("value"in s))throw new yt("portableSampler requires enumerable JSON data fields, never accessors.")}let n=e,i={minFilter:Xh,magFilter:qh,wrapS:Mc,wrapT:Mc};if(Object.keys(n).some((r)=>!Object.hasOwn(i,r)))throw new yt("portableSampler contains an unsupported field.");for(let[r,s]of Object.entries(i))if(!s.includes(n[r]))throw new yt(`portableSampler.${r} requires one of ${s.join(", ")}.`);return{minFilter:n.minFilter,magFilter:n.magFilter,wrapS:n.wrapS,wrapT:n.wrapT}}var Xh,qh,Mc;var Pu=mt(()=>{Ja();Xh=["nearest","linear","nearest-mipmap-nearest","linear-mipmap-nearest","nearest-mipmap-linear","linear-mipmap-linear"],qh=["nearest","linear"],Mc=["repeat","clamp-to-edge","mirrored-repeat"]});function Gv(e){return e.pack===void 0?jv:Hv}function JC(e){return e.pack===void 0?da:Nr}function He(e){throw new $v(e)}function Yh(e){let t=0,n=0,i=new TextEncoder,r=(a)=>{if(n+=a,n>da.jsonBytes)He("JSON byte budget exceeded.")},s=(a,o)=>{if(++t>65536||o>16)He("JSON node/depth budget exceeded.");if(a===null||typeof a==="boolean"){r(a===!1?5:4);return}if(typeof a==="number"){if(!Number.isFinite(a))He("JSON numbers must be finite.");r(JSON.stringify(a).length);return}if(typeof a==="string"){if(a.length>4096)He("JSON string budget exceeded.");r(i.encode(JSON.stringify(a)).length);return}if(typeof a!=="object")He("plain JSON data is required.");let c=Array.isArray(a),l=Object.getPrototypeOf(a);if(c?l!==Array.prototype:l!==null&&l!==Object.prototype)He("plain JSON prototypes are required.");let u=c?Object.getOwnPropertyDescriptor(a,"length")?.value:void 0;if(c&&(!Number.isSafeInteger(u)||u>1024))He("JSON array budget exceeded.");let d=Reflect.ownKeys(a);if(d.length>1024||c&&d.length!==u+1)He("dense bounded JSON fields are required.");r(2+Math.max(0,d.length-(c?1:0)-1));for(let f of d){if(c&&f==="length")continue;if(typeof f!=="string"||["__proto__","prototype","constructor"].includes(f))He("forbidden JSON field.");if(f.length>4096)He("JSON field name budget exceeded.");if(!c)r(i.encode(JSON.stringify(f)).length+1);let h=Object.getOwnPropertyDescriptor(a,f);if(!h.enumerable||!("value"in h))He("JSON accessors/hidden fields are unsupported.");if(c&&(!/^(0|[1-9][0-9]*)$/.test(f)||Number(f)>=u))He("invalid JSON array key.");s(h.value,o+1)}};s(e,0)}function jn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))He(`${n} must be a JSON object.`);let i=e;if(Object.keys(i).some((r)=>!t.includes(r)))He(`${n} has an unknown field.`);return i}function ri(e,t,n,i){if(typeof e!=="number"||!Number.isSafeInteger(e)||e<t||e>n)He(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function ns(e,t){if(typeof e!=="string"||!/^sha256:[a-f0-9]{64}$/.test(e))He(`${t} must be an exact SHA-256 hash.`);return e}function zv(e,t){let n=jn(e,["x","y","width","height"],t);return{x:ri(n.x,0,4096,`${t}.x`),y:ri(n.y,0,4096,`${t}.y`),width:ri(n.width,1,4096,`${t}.width`),height:ri(n.height,1,4096,`${t}.height`)}}function Ya(e){let{content:t,gutter:n}=e;return{x:t.x-n,y:t.y-n,width:t.width+2*n,height:t.height+2*n}}function Kv(e,t,n,i){if(e.x+e.width>n||e.y+e.height>i)He("source crop is out of bounds.");if(e.width!==t.width||e.height!==t.height)He("source crop/content dimensions must match; resampling is unsupported.")}function Jh(e){return e.kind==="procedural"?`procedural:${Wh(e.spec)}`:`resource:${e.pin.resourceId}:${e.pin.revisionId}:${e.resourceId}`}function YC(e,t,n,i){let r=[{x:0,y:0,width:e,height:t}],s=(o)=>{let c=[];for(let l of r){if(!ZC(l,o)){c.push(l);continue}if(o.x>l.x)c.push({x:l.x,y:l.y,width:o.x-l.x,height:l.height});if(o.x+o.width<l.x+l.width)c.push({x:o.x+o.width,y:l.y,width:l.x+l.width-o.x-o.width,height:l.height});if(o.y>l.y)c.push({x:l.x,y:l.y,width:l.width,height:o.y-l.y});if(o.y+o.height<l.y+l.height)c.push({x:l.x,y:o.y+o.height,width:l.width,height:l.y+l.height-o.y-o.height})}if(r=c.filter((l,u)=>!c.some((d,f)=>f!==u&&Vv(d,l)&&(!Vv(l,d)||f<u))),r.length>16384)He("pack: free-space bookkeeping budget exceeded.")};for(let o of n)s(o);let a=[...i].sort((o,c)=>c.width*c.height-o.width*o.height||(o.region.name<c.region.name?-1:o.region.name>c.region.name?1:0));for(let o of a){let c,l;for(let u of r){if(u.width<o.width||u.height<o.height)continue;let d=u.width-o.width,f=u.height-o.height,h=[Math.min(d,f),Math.max(d,f),u.y,u.x];if(!l||h[0]<l[0]||h[0]===l[0]&&(h[1]<l[1]||h[1]===l[1]&&(h[2]<l[2]||h[2]===l[2]&&h[3]<l[3])))c=u,l=h}if(!c)He(`pack: region ${o.region.name} (${o.width}x${o.height} texels with its gutter) does not fit in the ${e}x${t} atlas beside the regions already placed.`);o.region.content={x:c.x+o.region.gutter,y:c.y+o.region.gutter,width:o.region.content.width,height:o.region.content.height},s({x:c.x,y:c.y,width:o.width,height:o.height})}}function fa(e){Yh(e);let t=jn(e,["schemaVersion","width","height","usage","sampler","regions","pack"],"atlas");if(t.schemaVersion!==1)He("schemaVersion must be 1.");let n;if(t.pack!==void 0){let f=jn(t.pack,["edge","gutter","algorithm"],"pack");if(!Zh.includes(f.edge))He("pack.edge must be 1024 or 2048.");if(f.algorithm!==void 0&&f.algorithm!=="maxrects")He("pack.algorithm must be 'maxrects'.");n={edge:f.edge,gutter:f.gutter===void 0?2:ri(f.gutter,0,32,"pack.gutter"),algorithm:"maxrects"}}let i=n?Nr:da,r=n?n.edge:i.edge,s=n&&t.width===void 0?n.edge:ri(t.width,4,r,"width"),a=n&&t.height===void 0?n.edge:ri(t.height,4,r,"height");if(s*a>i.outputTexels)He("output texel budget exceeded.");if(!ir.includes(t.usage))He("usage must be a texture usage.");let o=t.usage;if(!Array.isArray(t.regions)||!t.regions.length||t.regions.length>i.regions)He(`regions must contain 1..${i.regions} entries.`);let c=[],l=t.regions.map((f,h)=>{let b=jn(f,["name","content","gutter","edgeMode","source","crop","packed"],`regions[${h}]`);if(typeof b.name!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(b.name))He("region name must be a stable lowercase identifier.");let m=b.content!==void 0;if(!m&&!n)He(`region ${b.name}: content is required unless the atlas sets pack.`);if(b.packed!==void 0&&(b.packed!==!0||!n||!m))He("packed is the resolved-placement marker: true, with content, in an atlas that sets pack.");let g=m?zv(b.content,"content"):void 0,p=b.gutter===void 0?n?.gutter??2:ri(b.gutter,0,32,"gutter"),x=b.edgeMode===void 0?"copy-edge":b.edgeMode;if(!["copy-edge","mask-rgb-dilate"].includes(x))He("unsupported edgeMode.");if(x==="mask-rgb-dilate"&&o!=="albedo"&&o!=="emissive")He("mask RGB dilation requires color usage.");let _=jn(b.source,["kind","spec","resourceId","pin","expected"],"source"),y,v=b.crop===void 0?void 0:zv(b.crop,"crop");if(_.kind==="procedural"){jn(_,["kind","spec"],"procedural source");let A=Iu(_.spec);if(A.spec.usage!==o)He("source usage does not match atlas usage.");y={kind:"procedural",spec:A.spec},v??={x:0,y:0,width:A.spec.width,height:A.spec.height},g??={x:0,y:0,width:v.width,height:v.height},Kv(v,g,A.spec.width,A.spec.height)}else if(_.kind==="resource"){if(jn(_,["kind","resourceId","pin","expected"],"resource source"),typeof _.resourceId!=="string"||!/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/.test(_.resourceId))He("source resourceId must be an exact returned map ID.");let A=jn(_.pin,["resourceId","revisionId","sha256"],"source pin");if(typeof A.resourceId!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(A.resourceId))He("pin resourceId must be a material ID.");let E=ns(A.revisionId,"pin revisionId"),w=ns(A.sha256,"pin sha256");if(E!==w)He("source pin revision/hash mismatch.");let P;if(_.expected!==void 0){let S=jn(_.expected,["width","height","imageSha256","decodedPixelHash"],"source expected");P={...S.width===void 0?{}:{width:ri(S.width,1,4096,"expected.width")},...S.height===void 0?{}:{height:ri(S.height,1,4096,"expected.height")},...S.imageSha256===void 0?{}:{imageSha256:ns(S.imageSha256,"expected.imageSha256")},...S.decodedPixelHash===void 0?{}:{decodedPixelHash:ns(S.decodedPixelHash,"expected.decodedPixelHash")}}}if(y={kind:"resource",resourceId:_.resourceId,pin:{resourceId:A.resourceId,revisionId:E,sha256:w},...P?{expected:P}:{}},!g){let S=v??(P?.width!==void 0&&P.height!==void 0?{width:P.width,height:P.height}:He(`region ${b.name}: a packed resource region needs a crop or expected width and height (its size).`));g={x:0,y:0,width:S.width,height:S.height}}if(v&&(v.width!==g.width||v.height!==g.height))He("source crop/content dimensions must match; resampling is unsupported.")}else He("source kind must be procedural or pinned resource.");let T={name:b.name,content:g,gutter:p,edgeMode:x,source:y,...v?{crop:v}:{},...n&&(!m||b.packed===!0)?{packed:!0}:{}};if(!m)c.push({region:T,width:T.content.width+2*p,height:T.content.height+2*p});return T}).sort((f,h)=>f.name<h.name?-1:f.name>h.name?1:0);if(new Set(l.map((f)=>f.name)).size!==l.length)He("duplicate region name.");if(c.length){let f=new Set(c.map((h)=>h.region));YC(s,a,l.filter((h)=>!f.has(h)).map((h)=>Ya(h)),c)}for(let f of l){let h=Ya(f);if(h.x<0||h.y<0||h.x+h.width>s||h.y+h.height>a)He("padded allocation is out of bounds.")}for(let f=0;f<l.length;f++)for(let h=f+1;h<l.length;h++){let b=Ya(l[f]),m=Ya(l[h]);if(b.x<m.x+m.width&&m.x<b.x+b.width&&b.y<m.y+m.height&&m.y<b.y+b.height)He(`padded allocations overlap: ${l[f].name}, ${l[h].name}.`)}if(new Set(l.map((f)=>Jh(f.source))).size>i.sources)He(`distinct source budget exceeds ${i.sources}.`);let u;try{u=Nu(t.sampler===void 0?{minFilter:"linear-mipmap-linear",magFilter:"linear",wrapS:"clamp-to-edge",wrapT:"clamp-to-edge"}:t.sampler)}catch(f){He(`sampler: ${f.message}`)}let d={schemaVersion:1,width:s,height:a,usage:o,sampler:u,regions:l,...n?{pack:n}:{}};if(new TextEncoder().encode(JSON.stringify(d)).length>da.jsonBytes)He("canonical JSON byte budget exceeded.");return d}function QC(e){let t=fa(e);return`sha256:${qa(`${Gv(t)}+${JSON.stringify(t)}`)}`}function Mn(e){Yh(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function eN(e){return`sha256:${qa(`kiln.atlas-layout.v1+${Mn({width:e.width,height:e.height,origin:"top-left",regions:e.regions.map((t)=>({name:t.name,content:t.content,allocation:Ya(t)}))})}`)}`}function Rc(e,t){Yh(e);let n=fa(t),i=jn(e,["version","compilerId","width","height","usage","origin","sampler","specHash","layoutHash","decodedPixelHash","atlasPixelHash","sources","regions","manifestHash"],"manifest");if(i.version!=="kiln.atlas-manifest.v1"||i.compilerId!==Gv(n)||i.width!==n.width||i.height!==n.height||i.usage!==n.usage||i.origin!=="top-left")He("manifest version/compiler/dimensions/usage/origin mismatch.");if(Mn(i.sampler)!==Mn(n.sampler)||i.specHash!==QC(n)||i.layoutHash!==eN(n))He("manifest sampler/spec/layout identity mismatch.");ns(i.decodedPixelHash,"manifest decodedPixelHash"),ns(i.atlasPixelHash,"manifest atlasPixelHash");let r=new Map(n.regions.map((c)=>[Jh(c.source),c.source]));if(!Array.isArray(i.sources)||i.sources.length!==r.size||!Array.isArray(i.regions)||i.regions.length!==n.regions.length)He("manifest source/region inventory mismatch.");let s=new Map;for(let c of i.sources){let l=jn(c,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId","descriptor"],"manifest source");if(typeof l.id!=="string"||s.has(l.id))He("duplicate/invalid manifest source identity.");let u=r.get(l.id);if(!u||l.kind!==u.kind)He("manifest source identity mismatch.");let d=ri(l.width,1,4096,"manifest source width"),f=ri(l.height,1,4096,"manifest source height");if(ns(l.decodedPixelHash,"manifest source decodedPixelHash"),u.kind==="procedural"){if(jn(l,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId"],"manifest procedural source"),d!==u.spec.width||f!==u.spec.height||l.recipeHash!==Wh(u.spec)||l.compilerId!=="kiln.procedural-rgba.v3.1")He("manifest procedural source identity mismatch.")}else{jn(l,["id","kind","width","height","decodedPixelHash","descriptor"],"manifest resource source");let h=jn(l.descriptor,["materialId","revisionId","resourceId","slot","usage","colorSpace","width","height","encodedByteLength","imageSha256","decodedPixelHash"],"manifest source descriptor"),b={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};if(h.materialId!==u.pin.resourceId||h.revisionId!==u.pin.revisionId||h.resourceId!==u.resourceId||h.width!==d||h.height!==f||h.usage!==n.usage||typeof h.slot!=="string"||b[h.slot]!==n.usage||h.colorSpace!==(n.usage==="albedo"||n.usage==="emissive"?"srgb":"linear"))He("manifest pinned resource descriptor mismatch.");if(ns(h.imageSha256,"manifest source imageSha256"),ri(h.encodedByteLength,1,JC(n).encodedSourceBytes,"manifest encodedByteLength"),h.decodedPixelHash!==void 0&&h.decodedPixelHash!==l.decodedPixelHash)He("manifest source decodedPixelHash mismatch.");for(let m of["width","height","imageSha256","decodedPixelHash"]){let g=u.expected?.[m];if(g!==void 0&&g!==(m==="decodedPixelHash"?l[m]:h[m]))He("manifest source expectation mismatch.")}}s.set(l.id,{width:d,height:f})}for(let c=0;c<n.regions.length;c++){let l=n.regions[c],u=jn(i.regions[c],["name","content","allocation","crop","sourceId"],"manifest region"),d=Jh(l.source),f=s.get(d),h=l.crop??{x:0,y:0,width:f.width,height:f.height};if(Kv(h,l.content,f.width,f.height),u.name!==l.name||u.sourceId!==d||Mn(u.content)!==Mn(l.content)||Mn(u.allocation)!==Mn(Ya(l))||Mn(u.crop)!==Mn(h))He("manifest named region/crop/allocation identity mismatch.")}let{manifestHash:a,...o}=i;if(a!==`sha256:${qa(`kiln.atlas-manifest.v1+${Mn(o)}`)}`)He("manifest hash mismatch.");return structuredClone(e)}var jv="kiln.texture-atlas.v1.1",Hv="kiln.texture-atlas.v1.2",Ou,da,Nr,Zh,$v,ZC=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,Vv=(e,t)=>t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height;var ku=mt(()=>{Pu();Cu();Ja();Ec();vu();Ou=Object.freeze([jv,Hv]),da=Object.freeze({edge:1024,outputTexels:1048576,regions:64,sources:16,sourceTexels:4194304,encodedSourceBytes:8388608,encodedBytes:16777216,jsonBytes:262144,work:64000000,allocatedBytes:67108864,uvVertices:262144,uvAttributeBytes:134217728}),Nr=Object.freeze({...da,edge:2048,outputTexels:4194304,regions:128,sources:32,work:192000000,allocatedBytes:134217728}),Zh=Object.freeze([1024,2048]);$v=class $v extends Xa{constructor(e){super("TEXTURE_ATLAS_CONTRACT",`textureAtlas: ${e}`);this.name="TextureAtlasError"}}});function pN(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function mN(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function vo(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function VT(){let e=vo("canvas");return e.style.display="block",e}function $c(...e){let t="THREE."+e.shift();if(Eo)Eo("log",t,...e);else console.log(t,...e)}function jT(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function je(...e){e=jT(e);let t="THREE."+e.shift();if(Eo)Eo("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Ze(...e){e=jT(e);let t="THREE."+e.shift();if(Eo)Eo("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function ba(...e){let t=e.join(" ");if(t in uE)return;uE[t]=!0,je(...e)}function HT(e,t,n){return new Promise(function(i,r){function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}class Vi{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}function Fi(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Pn[e&255]+Pn[e>>8&255]+Pn[e>>16&255]+Pn[e>>24&255]+"-"+Pn[t&255]+Pn[t>>8&255]+"-"+Pn[t>>16&15|64]+Pn[t>>24&255]+"-"+Pn[n&63|128]+Pn[n>>8&255]+"-"+Pn[n>>16&255]+Pn[n>>24&255]+Pn[i&255]+Pn[i>>8&255]+Pn[i>>16&255]+Pn[i>>24&255]).toLowerCase()}function ct(e,t,n){return Math.max(t,Math.min(n,e))}function Im(e,t){return(e%t+t)%t}function gN(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function bN(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function Gc(e,t,n){return(1-n)*e+n*t}function xN(e,t,n,i){return Gc(e,t,1-Math.exp(-n*i))}function yN(e,t=1){return t-Math.abs(Im(e,t*2)-t)}function _N(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*(3-2*e)}function vN(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10)}function EN(e,t){return e+Math.floor(Math.random()*(t-e+1))}function TN(e,t){return e+Math.random()*(t-e)}function AN(e){return e*(0.5-Math.random())}function wN(e){if(e!==void 0)dE=e;let t=dE+=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 SN(e){return e*Hc}function MN(e){return e*xa}function RN(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function IN(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function CN(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function NN(e,t,n,i,r){let{cos:s,sin:a}=Math,o=s(n/2),c=a(n/2),l=s((t+i)/2),u=a((t+i)/2),d=s((t-i)/2),f=a((t-i)/2),h=s((i-t)/2),b=a((i-t)/2);switch(r){case"XYX":e.set(o*u,c*d,c*f,o*l);break;case"YZY":e.set(c*f,o*u,c*d,o*l);break;case"ZXZ":e.set(c*d,c*f,o*u,o*l);break;case"XZX":e.set(o*u,c*b,c*h,o*l);break;case"YXY":e.set(c*h,o*u,c*b,o*l);break;case"ZYZ":e.set(c*b,c*h,o*u,o*l);break;default:je("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Li(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function Nt(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}function PN(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,a){if(this.enabled===!1||s===a||!s||!a)return r;if(this.spaces[s].transfer==="srgb")r.r=Ur(r.r),r.g=Ur(r.g),r.b=Ur(r.b);if(this.spaces[s].primaries!==this.spaces[a].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ);if(this.spaces[a].transfer==="srgb")r.r=_o(r.r),r.g=_o(r.g),r.b=_o(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return ba("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return ba("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(r,s)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:hE,fromXYZ:pE,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:hE,fromXYZ:pE,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}function Ur(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function _o(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}class Cm{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(so===void 0)so=vo("canvas");so.width=e.width,so.height=e.height;let i=so.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=so}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=vo("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Ur(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Ur(t[n]/255)*255);else t[n]=Ur(t[n]);return{data:t,width:e.width,height:e.height}}else return je("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}class Qc{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:ON++}),this.uuid=Fi(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,a=i.length;s<a;s++)if(i[s].isDataTexture)r.push(op(i[s].image));else r.push(op(i[s]))}else r=op(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function op(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return Cm.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return je("Texture: Unable to serialize Texture."),{}}class Ad{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}class el{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new cr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new cr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new j,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new j;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new cr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new j,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new j,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,a=this._targetRay,o=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let b of e.hand.values()){let m=t.getJointPose(b,n),g=this._getHandJoint(c,b);if(m!==null)g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius;g.visible=m!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=l.position.distanceTo(u.position),f=0.02,h=0.005;if(c.inputState.pinching&&d>f+h)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&d<=f-h)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(o!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity);else o.hasLinearVelocity=!1;if(r.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity);else o.hasAngularVelocity=!1;if(o.eventsEnabled)o.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(a!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity);else a.hasLinearVelocity=!1;if(i.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity);else a.hasAngularVelocity=!1;this.dispatchEvent(VN)}}}if(a!==null)a.visible=i!==null;if(o!==null)o.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new cr;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}function up(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class _i{constructor(e=new j,t=new j,n=new j){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),ki.subVectors(e,t),i.cross(ki);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){ki.subVectors(i,t),Or.subVectors(n,t),dp.subVectors(e,t);let s=ki.dot(ki),a=ki.dot(Or),o=ki.dot(dp),c=Or.dot(Or),l=Or.dot(dp),u=s*c-a*a;if(u===0)return r.set(0,0,0),null;let d=1/u,f=(c*o-a*l)*d,h=(s*l-a*o)*d;return r.set(1-f-h,h,f)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,kr)===null)return!1;return kr.x>=0&&kr.y>=0&&kr.x+kr.y<=1}static getInterpolation(e,t,n,i,r,s,a,o){if(this.getBarycoord(e,t,n,i,kr)===null){if(o.x=0,o.y=0,"z"in o)o.z=0;if("w"in o)o.w=0;return null}return o.setScalar(0),o.addScaledVector(r,kr.x),o.addScaledVector(s,kr.y),o.addScaledVector(a,kr.z),o}static getInterpolatedAttribute(e,t,n,i,r,s){return mp.setScalar(0),gp.setScalar(0),bp.setScalar(0),mp.fromBufferAttribute(e,t),gp.fromBufferAttribute(e,n),bp.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(mp,r.x),s.addScaledVector(gp,r.y),s.addScaledVector(bp,r.z),s}static isFrontFacing(e,t,n,i){return ki.subVectors(n,t),Or.subVectors(e,t),ki.cross(Or).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ki.subVectors(this.c,this.b),Or.subVectors(this.a,this.b),ki.cross(Or).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return _i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return _i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return _i.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return _i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return _i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,a;lo.subVectors(i,n),uo.subVectors(r,n),fp.subVectors(e,n);let o=lo.dot(fp),c=uo.dot(fp);if(o<=0&&c<=0)return t.copy(n);hp.subVectors(e,i);let l=lo.dot(hp),u=uo.dot(hp);if(l>=0&&u<=l)return t.copy(i);let d=o*u-l*c;if(d<=0&&o>=0&&l<=0)return s=o/(o-l),t.copy(n).addScaledVector(lo,s);pp.subVectors(e,r);let f=lo.dot(pp),h=uo.dot(pp);if(h>=0&&f<=h)return t.copy(r);let b=f*c-o*h;if(b<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(n).addScaledVector(uo,a);let m=l*h-f*u;if(m<=0&&u-l>=0&&f-h>=0)return EE.subVectors(r,i),a=(u-l)/(u-l+(f-h)),t.copy(i).addScaledVector(EE,a);let g=1/(m+b+d);return s=b*g,a=d*g,t.copy(n).addScaledVector(lo,s).addScaledVector(uo,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class hn{constructor(e=new j(1/0,1/0,1/0),t=new j(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Di.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Di.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Di.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,a=r.count;s<a;s++){if(e.isMesh===!0)e.getVertexPosition(s,Di);else Di.fromBufferAttribute(r,s);Di.applyMatrix4(e.matrixWorld),this.expandByPoint(Di)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();Bu.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Bu.copy(n.boundingBox)}Bu.applyMatrix4(e.matrixWorld),this.union(Bu)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Di),Di.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Lc),zu.subVectors(this.max,Lc),fo.subVectors(e.a,Lc),ho.subVectors(e.b,Lc),po.subVectors(e.c,Lc),ss.subVectors(ho,fo),as.subVectors(po,ho),ha.subVectors(fo,po);let t=[0,-ss.z,ss.y,0,-as.z,as.y,0,-ha.z,ha.y,ss.z,0,-ss.x,as.z,0,-as.x,ha.z,0,-ha.x,-ss.y,ss.x,0,-as.y,as.x,0,-ha.y,ha.x,0];if(!xp(t,fo,ho,po,zu))return!1;if(t=[1,0,0,0,1,0,0,0,1],!xp(t,fo,ho,po,zu))return!1;return Vu.crossVectors(ss,as),t=[Vu.x,Vu.y,Vu.z],xp(t,fo,ho,po,zu)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Di).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(Di).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return Dr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Dr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Dr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Dr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Dr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Dr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Dr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Dr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Dr),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}function xp(e,t,n,i,r){for(let s=0,a=e.length-3;s<=a;s+=3){pa.fromArray(e,s);let o=r.x*Math.abs(pa.x)+r.y*Math.abs(pa.y)+r.z*Math.abs(pa.z),c=t.dot(pa),l=n.dot(pa),u=i.dot(pa);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>o)return!1}return!0}class li{constructor(e=new j,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;if(t!==void 0)n.copy(t);else HN.setFromPoints(e).getCenter(n);let i=0;for(let r=0,s=e.length;r<s;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return e.set(this.center,this.center),e.expandByScalar(this.radius),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Fc.subVectors(e,this.center);let t=Fc.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Fc,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else yp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Fc.copy(e.center).add(yp)),this.expandByPoint(Fc.copy(e.center).sub(yp));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}class tl{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=Fi()}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Fi();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Fi();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}class Oo{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Hn.fromBufferAttribute(this,t),Hn.applyMatrix4(e),this.setXYZ(t,Hn.x,Hn.y,Hn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Hn.fromBufferAttribute(this,t),Hn.applyNormalMatrix(e),this.setXYZ(t,Hn.x,Hn.y,Hn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Hn.fromBufferAttribute(this,t),Hn.transformDirection(e),this.setXYZ(t,Hn.x,Hn.y,Hn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Li(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=Nt(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=Nt(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=Nt(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=Nt(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=Nt(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=Li(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Li(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Li(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Li(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=Nt(t,this.array),n=Nt(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=Nt(t,this.array),n=Nt(n,this.array),i=Nt(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=Nt(t,this.array),n=Nt(n,this.array),i=Nt(i,this.array),r=Nt(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){$c("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new vn(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new Oo(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){$c("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}class yi{constructor(e=new j(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=vp.subVectors(n,t).cross($N.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let i=e.delta(vp),r=this.normal.dot(i);if(r===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let s=-(e.start.dot(this.normal)+this.constant)/r;if(n===!0&&(s<0||s>1))return null;return t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||KN.getNormalMatrix(e),i=this.coplanarPoint(vp).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}class ms{constructor(e=new j,t=new j(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Lr)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Lr.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return Lr.copy(this.origin).addScaledVector(this.direction,t),Lr.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){Ep.copy(e).add(t).multiplyScalar(0.5),Hu.copy(t).sub(e).normalize(),Gu.copy(this.origin).sub(Ep);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(Hu),a=Gu.dot(this.direction),o=-Gu.dot(Hu),c=Gu.lengthSq(),l=Math.abs(1-s*s),u,d,f,h;if(l>0)if(u=s*o-a,d=s*a-o,h=r*l,u>=0)if(d>=-h)if(d<=h){let b=1/l;u*=b,d*=b,f=u*(u+s*d+2*a)+d*(s*u+d+2*o)+c}else d=r,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*o)+c;else d=-r,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*o)+c;else if(d<=-h)u=Math.max(0,-(-s*r+a)),d=u>0?-r:Math.min(Math.max(-r,-o),r),f=-u*u+d*(d+2*o)+c;else if(d<=h)u=0,d=Math.min(Math.max(-r,-o),r),f=d*(d+2*o)+c;else u=Math.max(0,-(s*r+a)),d=u>0?r:Math.min(Math.max(-r,-o),r),f=-u*u+d*(d+2*o)+c;else d=s>0?-r:r,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*o)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(Ep).addScaledVector(Hu,d);return f}intersectSphere(e,t){if(e.radius<0)return null;Lr.subVectors(e.center,this.origin);let n=Lr.dot(this.direction),i=Lr.dot(Lr)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),a=n-s,o=n+s;if(o<0)return null;if(a<0)return this.at(o,t);return this.at(a,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,a,o,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;if(c>=0)n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c;else n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c;if(l>=0)r=(e.min.y-d.y)*l,s=(e.max.y-d.y)*l;else r=(e.max.y-d.y)*l,s=(e.min.y-d.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)a=(e.min.z-d.z)*u,o=(e.max.z-d.z)*u;else a=(e.max.z-d.z)*u,o=(e.min.z-d.z)*u;if(n>o||a>i)return null;if(a>n||n!==n)n=a;if(o<i||i!==i)i=o;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Lr)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,a=this.direction,{x:o,y:c,z:l}=a,u=e.x-s.x,d=e.y-s.y,f=e.z-s.z,h=t.x-s.x,b=t.y-s.y,m=t.z-s.z,g=n.x-s.x,p=n.y-s.y,x=n.z-s.z,_=Math.abs(o),y=Math.abs(c),v=Math.abs(l),T,A,E,w,P,S,I,U,N,F,D,O;if(_>=y&&_>=v)if(E=o,S=u,N=h,O=g,o>=0)T=c,A=l,w=d,P=f,I=b,U=m,F=p,D=x;else T=l,A=c,w=f,P=d,I=m,U=b,F=x,D=p;else if(y>=v)if(E=c,S=d,N=b,O=p,c>=0)T=l,A=o,w=f,P=u,I=m,U=h,F=x,D=g;else T=o,A=l,w=u,P=f,I=h,U=m,F=g,D=x;else if(E=l,S=f,N=m,O=x,l>=0)T=o,A=c,w=u,P=d,I=h,U=b,F=g,D=p;else T=c,A=o,w=d,P=u,I=b,U=h,F=p,D=g;if(E===0)return null;let K=T/E,B=A/E,X=1/E,q=w-K*S,le=P-B*S,de=I-K*N,Me=U-B*N,pe=F-K*O,J=D-B*O,L=pe*Me-J*de,W=q*J-le*pe,ne=de*le-Me*q;if(i){if(L<0||W<0||ne<0)return null}else if((L<0||W<0||ne<0)&&(L>0||W>0||ne>0))return null;let ie=L+W+ne;if(ie===0)return null;let ce=X*(L*S+W*N+ne*O);if(ie>0?ce<0:ce>0)return null;return this.at(ce/ie,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}function XN(e,t,n,i,r,s,a,o){let c;if(t.side===1)c=i.intersectTriangle(a,s,r,!0,o);else c=i.intersectTriangle(r,s,a,t.side===0,o);if(c===null)return null;Ju.copy(o),Ju.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Ju);if(l<n.near||l>n.far)return null;return{distance:l,point:Ju.clone(),object:e}}function Zu(e,t,n,i,r,s,a,o,c,l){e.getVertexPosition(o,Ku),e.getVertexPosition(c,Wu),e.getVertexPosition(l,Xu);let u=XN(e,t,n,i,Ku,Wu,Xu,wE);if(u){let d=new j;if(_i.getBarycoord(wE,Ku,Wu,Xu,d),r)u.uv=_i.getInterpolatedAttribute(r,o,c,l,d,new Ke);if(s)u.uv1=_i.getInterpolatedAttribute(s,o,c,l,d,new Ke);if(a){if(u.normal=_i.getInterpolatedAttribute(a,o,c,l,d,new j),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let f={a:o,b:c,c:l,normal:new j,materialIndex:0};_i.getNormal(Ku,Wu,Xu,f.normal),u.face=f,u.barycoord=d}return u}class rl{constructor(e=[],t=[]){this.uuid=Fi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){je("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Qe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Qe;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let a=e[r]?e[r].matrixWorld:JN;CE.multiplyMatrices(a,t[r]),CE.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new rl(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new il(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)je("Skeleton: No bone found with UUID:",r),s=new nl;this.bones.push(s),this.boneInverses.push(new Qe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let a=n[i];e.boneInverses.push(a.toArray())}return e}}class sl{constructor(e=new yi,t=new yi,n=new yi,i=new yi,r=new yi,s=new yi){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],a=r[1],o=r[2],c=r[3],l=r[4],u=r[5],d=r[6],f=r[7],h=r[8],b=r[9],m=r[10],g=r[11],p=r[12],x=r[13],_=r[14],y=r[15];if(i[0].setComponents(c-s,f-l,g-h,y-p).normalize(),i[1].setComponents(c+s,f+l,g+h,y+p).normalize(),i[2].setComponents(c+a,f+u,g+b,y+x).normalize(),i[3].setComponents(c-a,f-u,g-b,y-x).normalize(),n)i[4].setComponents(o,d,m,_).normalize(),i[5].setComponents(c-o,f-d,g-m,y-_).normalize();else if(i[4].setComponents(c-o,f-d,g-m,y-_).normalize(),t===2000)i[5].setComponents(c+o,f+d,g+m,y+_).normalize();else if(t===2001)i[5].setComponents(o,d,m,_).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();ga.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();ga.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ga)}intersectsSprite(e){ga.center.set(0,0,0);let t=YN.distanceTo(e.center);return ga.radius=0.7071067811865476+t,ga.applyMatrix4(e.matrixWorld),this.intersectsSphere(ga)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(ed.x=i.normal.x>0?e.max.x:e.min.x,ed.y=i.normal.y>0?e.max.y:e.min.y,ed.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ed)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function nd(e,t,n,i,r,s,a){let o=e.geometry.attributes.position;if(cd.fromBufferAttribute(o,r),ld.fromBufferAttribute(o,s),n.distanceSqToSegment(cd,ld,Sp,kE)>i)return;Sp.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(Sp);if(l<t.near||l>t.far)return;return{distance:l,point:kE.clone().applyMatrix4(e.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:e}}function UE(e,t,n,i,r,s,a){let o=Ip.distanceSqToPoint(e);if(o<n){let c=new j;Ip.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}function Sa(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(BE(r))if(r.isRenderTargetTexture)je("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(BE(r[0])){let s=[];for(let a=0,o=r.length;a<o;a++)s[a]=r[a].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function Ln(e){let t={};for(let n=0;n<e.length;n++){let i=Sa(e[n]);for(let r in i)t[r]=i[r]}return t}function BE(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function QN(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function km(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return ot.workingColorSpace}function cs(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function od(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function nP(e){function t(r,s){return e[r]-e[s]}let n=e.length,i=Array(n);for(let r=0;r!==n;++r)i[r]=r;return i.sort(t),i}function zE(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,a=0;a!==i;++s){let o=n[s]*t;for(let c=0;c!==t;++c)r[a++]=e[o+c]}return r}function iP(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let a=s[i];if(a===void 0)return;if(Array.isArray(a))do{if(a=s[i],a!==void 0)t.push(s.time),n.push(...a);s=e[r++]}while(s!==void 0);else if(a.toArray!==void 0)do{if(a=s[i],a!==void 0)t.push(s.time),a.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(a=s[i],a!==void 0)t.push(s.time),n.push(a);s=e[r++]}while(s!==void 0)}class Vr{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let a=t[1];if(e<a)n=2,r=a;for(let o=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===o)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let a=n+s>>>1;if(e<t[a])s=a;else n=a+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}function WT(e,t,n,i,r){let s=1-e;return s*s*s*t+3*s*s*e*n+3*s*e*e*i+e*e*e*r}function rP(e,t,n,i,r){let s=1-e;return 3*s*s*(n-t)+6*s*e*(i-n)+3*e*e*(r-i)}function sP(e,t,n,i,r){let s=(e-t)/(r-t);for(let a=0;a<8;a++){let o=WT(s,t,n,i,r)-e;if(Math.abs(o)<0.0000000001)break;let c=rP(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-o/c))}return s}class di{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=cs(t,this.TimeBufferType),this.values=cs(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:cs(e.times,Array),values:cs(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(od(e.settings))n.settings={inTangents:cs(e.settings.inTangents,Array),outTangents:cs(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Bm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Od(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Um(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new zm(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return je("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(od(this.settings))VE(this.settings.inTangents,e),VE(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let a=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*a,s*a)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Ze("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Ze("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let a=0;a!==r;a++){let o=n[a];if(typeof o==="number"&&isNaN(o)){Ze("KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(s!==null&&s>o){Ze("KeyframeTrack: Out of order keys.",this,a,o,s),e=!1;break}s=o}if(i!==void 0){if(mN(i))for(let a=0,o=i.length;a!==o;++a){let c=i[a];if(isNaN(c)){Ze("KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let a=1;a<r;++a){let o=!1,c=e[a],l=e[a+1];if(c!==l&&(a!==1||c!==e[0]))if(!i){let u=a*n,d=u-n,f=u+n;for(let h=0;h!==n;++h){let b=t[u+h];if(b!==t[d+h]||b!==t[f+h]){o=!0;break}}}else o=!0;if(o){if(a!==s){e[s]=e[a];let u=a*n,d=s*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++s}}if(r>0){e[s]=e[r];for(let a=r*n,o=s*n,c=0;c!==n;++c)t[o+c]=t[a+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,od(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function VE(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}class To{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Fi(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,a=n.length;s!==a;++s)t.push(oP(n[s]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=n.length;r!==s;++r)t.push(di.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let a=0;a<r;a++){let o=[],c=[];o.push((a+r-1)%r,a,(a+1)%r),c.push(0,1,0);let l=nP(o);if(o=zE(o,1,l),c=zE(c,1,l),!i&&o[0]===0)o.push(r),c.push(c[0]);s.push(new ys(".morphTargetInfluences["+t[a].name+"]",o,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,o=e.length;a<o;a++){let c=e[a],l=c.name.match(r);if(l&&l.length>1){let u=l[1],d=i[u];if(!d)i[u]=d=[];d.push(c)}}let s=[];for(let a in i)s.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function aP(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ys;case"vector":case"vector2":case"vector3":case"vector4":return Ma;case"color":return kd;case"quaternion":return _s;case"bool":case"boolean":return xs;case"string":return vs}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function oP(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=aP(e.type);if(e.times===void 0){let i=[],r=[];iP(e.keys,i,r,"value"),e.times=i,e.values=r}let n;if(t.parse!==void 0)n=t.parse(e);else n=new t(e.name,e.times,e.values,e.interpolation);if(od(e.settings))n.settings={inTangents:cs(e.settings.inTangents,Float32Array),outTangents:cs(e.settings.outTangents,Float32Array)};return n}function jE(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class ll{constructor(e,t,n){let i=this,r=!1,s=0,a=0,o=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(a++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,a)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,a);if(s===a){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),o)return o(l);return l},this.setURLModifier=function(l){return o=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,d=c.length;u<d;u+=2){let f=c[u],h=c[u+1];if(f.global)f.lastIndex=0;if(f.test(l))return h}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}class jr{constructor(e){if(this.manager=e!==void 0?e:XT,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}class dl{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ke(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Qe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new sl,this._frameExtents=new Ke(1,1),this._viewportCount=1,this._viewports=[new Pt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;HE.setFromMatrixPosition(e.matrixWorld),t.position.copy(HE),GE.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(GE),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){Mp.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(Mp,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,a=i?i.w/r.y:1,o=i?i.x/r.x:0,c=i?i.y/r.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*s,0,0,0.5*s+o,0,0.5*a,0,0.5*a+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+o,0,0.5*a,0,0.5*a+c,0,0,0.5,0.5,0,0,0,1);t.multiply(Mp)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Es{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}class $m{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let a=0;a!==i;++a)n[r+a]=n[a];s=t}else{s+=t;let a=t/s;this._mixBufferRegion(n,r,0,a,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let o=t*this._origIndex;this._mixBufferRegion(n,i,o,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let o=t,c=t+t;o!==c;++o)if(n[o]!==n[o+t]){a.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){ln.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;ln.multiplyQuaternionsFlat(e,s,e,t,e,n),ln.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let a=0;a!==r;++a){let o=t+a;e[o]=e[o]*s+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let a=t+s;e[a]=e[a]+e[n+s]*i}}}class QT{constructor(e,t,n){let i=n||Tt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class Tt{constructor(e,t,n){this.path=t,this.parsedPath=n||Tt.parseTrackName(t),this.node=Tt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new Tt(e,t,n);else return new Tt.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(cP,"")}static parseTrackName(e){let t=pP.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);if(mP.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let a=r[s];if(a.name===t||a.uuid===t)return a;let o=n(a.children);if(o)return o}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=Tt.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){je("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ze("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Ze("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ze("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Ze("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Ze("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;Ze("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)a=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)a=this.Versioning.MatrixWorldNeedsUpdate;let o=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)o=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))o=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}class Xm{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,s=r.length,a=Array(s),o={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);a[c]=l,l.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,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(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,r=e._clip.duration,s=r/i,a=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;if(e!==null)this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,s=this.timeScale,a=this._timeScaleInterpolant;if(a===null)a=i._lendControlInterpolant(),this._timeScaleInterpolant=a;let o=a.parameterPositions,c=a.sampleValues;return o[0]=r,o[1]=r+n,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;if(e!==null)this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}let r=this._startTime;if(r!==null){let o=(e-r)*n;if(o<0||n===0)t=0;else this._startTime=null,t=n*o}t*=this._updateTimeScale(e);let s=this._updateTime(t),a=this._updateWeight(e);if(a>0){let o=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=o.length;l!==u;++l)o[l].evaluate(s),c[l].accumulateAdditive(a);break;case 2500:default:for(let l=0,u=o.length;l!==u;++l)o[l].evaluate(s),c[l].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(this.stopFading(),i===0)this.enabled=!1}}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(t===0)this.paused=!0;else{if(this._restoreTimeScale!==null)t=this._restoreTimeScale;this.timeScale=t}this.stopWarping()}}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,s=n===2202;if(e===0){if(r===-1)return i;return s&&(r&1)===1?t-i:i}if(n===2200){if(r===-1)this._loopCount=0,this._setEndings(!0,!0,!1);e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1)if(e>=0)r=0,this._setEndings(!0,this.repetitions===0,s);else this._setEndings(this.repetitions===0,!0,s);if(i>=t||i<0){let a=Math.floor(i/t);i-=t*a,r+=Math.abs(a);let o=this.repetitions-r;if(o<=0){if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1})}else{if(o===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this._loopCount=r,this.time=i;if(s&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;if(n)i.endingStart=2401,i.endingEnd=2401;else{if(e)i.endingStart=this.zeroSlopeAtStart?2401:2400;else i.endingStart=2402;if(t)i.endingEnd=this.zeroSlopeAtEnd?2401:2400;else i.endingEnd=2402}}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,s=this._weightInterpolant;if(s===null)s=i._lendControlInterpolant(),this._weightInterpolant=s;let a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=t,a[1]=r+e,o[1]=n,this}}class fl{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=ct(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(ct(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}function Jm(e,t,n,i){let r=bP(i);switch(n){case 1021:return e*t;case 1028:return e*t/r.components*r.byteLength;case 1029:return e*t/r.components*r.byteLength;case 1030:return e*t*2/r.components*r.byteLength;case 1031:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case 1023:return e*t*4/r.components*r.byteLength;case 1033:return e*t*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function bP(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}var WE="186",us,ds,XE=0,Cp=1,qE=2,Kc=1,JE=2,Ao=3,fs=0,kn=1,vi=2,dr=0,Wc=1,Np=2,Pp=3,Op=4,ZE=5,wo=100,YE=101,QE=102,eT=103,tT=104,nT=200,iT=201,rT=202,sT=203,aT=204,oT=205,cT=206,lT=207,uT=208,dT=209,fT=210,hT=211,pT=212,mT=213,gT=214,bT=0,xT=1,yT=2,kp=3,_T=4,vT=5,ET=6,TT=7,AT=0,wT=1,ST=2,Ui=0,Dp=1,Lp=2,Fp=3,Xc=4,Up=5,Bp=6,zp=7,So=301,ya=302,ud=303,dd=304,qc=306,Mo=1000,Ro=1001,fd=1002,Bi=1003,hd=1004,_a=1005,En=1006,Io=1007,fr=1008,zi=1009,MT=1010,RT=1011,Jc=1012,Vp=1013,hs=1014,Br=1015,hr=1016,jp=1017,Hp=1018,Co=1020,IT=35902,CT=35899,NT=1021,PT=1022,pr=1023,va=1026,Ea=1027,OT=1028,Gp=1029,Ta=1030,$p=1031,Kp=1033,pd=33776,md=33777,gd=33778,bd=33779,Wp=35840,Xp=35841,qp=35842,Jp=35843,Zp=36196,Yp=37492,Qp=37496,em=37488,tm=37489,xd=37490,nm=37491,im=37808,rm=37809,sm=37810,am=37811,om=37812,cm=37813,lm=37814,um=37815,dm=37816,fm=37817,hm=37818,pm=37819,mm=37820,gm=37821,bm=36492,xm=36494,ym=36495,_m=36283,vm=36284,yd=36285,Em=36286,Tm=2300,_d=2301,Am=0,Zc=1,No=2,wm=0,kT=1,Aa="",ps="srgb",oi="srgb-linear",Sm="linear",Bt="srgb",DT=512,LT=513,FT=514,vd=515,UT=516,BT=517,Ed=518,zT=519,Mm="300 es",Rm=2000,uE,Eo=null,GT,Pn,dE=1234567,Hc,xa,Yc,Ke,ln,j,sp,fE,tt,ap,hE,pE,ot,so,ON=0,kN=0,cp,en,Pt,Nm,ci,Td,Pm,Qe,ao,Oi,DN,LN,is,Lu,si,mE,gE,ur,FN=0,bE,oo,Pr,Fu,Dc,UN,BN,xE,yE,_E,vE,zN,co,lp,Dt,cr,VN,$T,rs,Uu,qe,On,Po,ki,Or,dp,kr,lo,uo,EE,fp,hp,pp,mp,gp,bp,Dr,Di,Bu,fo,ho,po,ss,as,ha,Lc,zu,Vu,pa,cn,ju,jN=0,vn,wd,Sd,Wn,HN,Fc,yp,GN=0,xi,_p,mo,ai,Uc,_n,Dn,Hn,vp,$N,KN,WN=0,Xn,Lr,Ep,Hu,Gu,mr,TE,ma,$u,AE,Ku,Wu,Xu,Tp,qu,wE,Ju,jt,Bc,SE,ME,qN,RE,Yu,Ap,IE,wp,Md,nl,il,CE,JN,ls,go,NE,Qu,PE,ZN,zc,Vc,ko,ga,YN,ed,al,cd,ld,OE,jc,td,Sp,kE,gs,DE,LE,Rd,Id,ol,FE,Ip,id,rd,Do,Cd,wa,Om,Nd,bs,cl,KT,eP=`void main() {gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );-}`,EN=`void main() {+}`,tP=`void main() {gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );-}`,_i,_m,Ur,ci,md,vm,Em,Tm,gd,Am,Sm,gs,bd,bs,wm,ys,xs,Ea,or,IT,Dr,CT,Yc,co,Mm,Ro,Io,yd,fp,AE,SE,ju,Hu,sr,xd,ss,wE,ME,fn,NT,_d,PT,Co,Ta,OT,No,hp,vd,lo=-90,uo=1,Rm,Im,Nm="\\[\\]\\.:\\/",IN,Pm,CN,NN,PN,ON,kN,DN,LN,FN,Ed,km,Td;var Lm=Ft(()=>{cs={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ls={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3};$v={};ST={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};Cn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Nc=Math.PI/180,ha=180/Math.PI;zc={DEG2RAD:Nc,RAD2DEG:ha,generateUUID:Di,clamp:ct,euclideanModulo:pm,mapLinear:FC,inverseLerp:UC,lerp:Pc,damp:BC,pingpong:zC,smoothstep:VC,smootherstep:jC,randInt:HC,randFloat:GC,randFloatSpread:$C,seededRandom:KC,degToRad:WC,radToDeg:XC,isPowerOfTwo:qC,ceilPowerOfTwo:JC,floorPowerOfTwo:ZC,setQuaternionFromProperEuler:YC,normalize:Ct,denormalize:ki};Ke=class Ke{static{Ke.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ct(this.x,e.x,t.x),this.y=ct(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ct(this.x,e,t),this.y=ct(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ct(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(ct(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};ln=class ln{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,a){let o=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],d=r[s+0],f=r[s+1],h=r[s+2],y=r[s+3];if(u!==y||o!==d||c!==f||l!==h){let g=o*d+c*f+l*h+u*y;if(g<0)d=-d,f=-f,h=-h,y=-y,g=-g;let m=1-a;if(g<0.9995){let p=Math.acos(g),b=Math.sin(p);m=Math.sin(m*p)/b,a=Math.sin(a*p)/b,o=o*m+d*a,c=c*m+f*a,l=l*m+h*a,u=u*m+y*a}else{o=o*m+d*a,c=c*m+f*a,l=l*m+h*a,u=u*m+y*a;let p=1/Math.sqrt(o*o+c*c+l*l+u*u);o*=p,c*=p,l*=p,u*=p}}e[t]=o,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let a=n[i],o=n[i+1],c=n[i+2],l=n[i+3],u=r[s],d=r[s+1],f=r[s+2],h=r[s+3];return e[t]=a*h+l*u+o*f-c*d,e[t+1]=o*h+l*d+c*u-a*f,e[t+2]=c*h+l*f+a*d-o*u,e[t+3]=l*h-a*u-o*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:a,sin:o}=Math,c=a(n/2),l=a(i/2),u=a(r/2),d=o(n/2),f=o(i/2),h=o(r/2);switch(s){case"XYZ":this._x=d*l*u+c*f*h,this._y=c*f*u-d*l*h,this._z=c*l*h+d*f*u,this._w=c*l*u-d*f*h;break;case"YXZ":this._x=d*l*u+c*f*h,this._y=c*f*u-d*l*h,this._z=c*l*h-d*f*u,this._w=c*l*u+d*f*h;break;case"ZXY":this._x=d*l*u-c*f*h,this._y=c*f*u+d*l*h,this._z=c*l*h+d*f*u,this._w=c*l*u-d*f*h;break;case"ZYX":this._x=d*l*u-c*f*h,this._y=c*f*u+d*l*h,this._z=c*l*h-d*f*u,this._w=c*l*u+d*f*h;break;case"YZX":this._x=d*l*u+c*f*h,this._y=c*f*u+d*l*h,this._z=c*l*h-d*f*u,this._w=c*l*u-d*f*h;break;case"XZY":this._x=d*l*u-c*f*h,this._y=c*f*u-d*l*h,this._z=c*l*h+d*f*u,this._w=c*l*u+d*f*h;break;default:je("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],a=t[5],o=t[9],c=t[2],l=t[6],u=t[10],d=n+a+u;if(d>0){let f=0.5/Math.sqrt(d+1);this._w=0.25/f,this._x=(l-o)*f,this._y=(r-c)*f,this._z=(s-i)*f}else if(n>a&&n>u){let f=2*Math.sqrt(1+n-a-u);this._w=(l-o)/f,this._x=0.25*f,this._y=(i+s)/f,this._z=(r+c)/f}else if(a>u){let f=2*Math.sqrt(1+a-n-u);this._w=(r-c)/f,this._x=(i+s)/f,this._y=0.25*f,this._z=(o+l)/f}else{let f=2*Math.sqrt(1+u-n-a);this._w=(s-i)/f,this._x=(r+c)/f,this._y=(o+l)/f,this._z=0.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ct(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:a,_y:o,_z:c,_w:l}=t;return this._x=n*l+s*a+i*c-r*o,this._y=i*l+s*o+r*a-n*c,this._z=r*l+s*c+n*o-i*a,this._w=s*l-n*a-i*o-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,a=this.dot(e);if(a<0)n=-n,i=-i,r=-r,s=-s,a=-a;let o=1-t;if(a<0.9995){let c=Math.acos(a),l=Math.sin(c);o=Math.sin(o*c)/l,t=Math.sin(t*c)/l,this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+s*t,this._onChangeCallback()}else this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}};j=class j{static{j.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Wv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Wv.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:a,w:o}=e,c=2*(s*i-a*n),l=2*(a*t-r*i),u=2*(r*n-s*t);return this.x=t+o*c+s*u-a*l,this.y=n+o*l+a*c-r*u,this.z=i+o*u+r*l-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ct(this.x,e.x,t.x),this.y=ct(this.y,e.y,t.y),this.z=ct(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ct(this.x,e,t),this.y=ct(this.y,e,t),this.z=ct(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ct(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:a,z:o}=t;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Gh.copy(this).projectOnVector(e),this.sub(Gh)}reflect(e){return this.sub(Gh.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(ct(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Gh=new j,Wv=new ln;tt=class tt{static{tt.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,a,o,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,a,o,c)}set(e,t,n,i,r,s,a,o,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=a,l[3]=t,l[4]=r,l[5]=o,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[3],o=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],h=n[8],y=i[0],g=i[3],m=i[6],p=i[1],b=i[4],_=i[7],x=i[2],v=i[5],E=i[8];return r[0]=s*y+a*p+o*x,r[3]=s*g+a*b+o*v,r[6]=s*m+a*_+o*E,r[1]=c*y+l*p+u*x,r[4]=c*g+l*b+u*v,r[7]=c*m+l*_+u*E,r[2]=d*y+f*p+h*x,r[5]=d*g+f*b+h*v,r[8]=d*m+f*_+h*E,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],c=e[7],l=e[8];return t*s*l-t*a*c-n*r*l+n*a*o+i*r*c-i*s*o}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],c=e[7],l=e[8],u=l*s-a*c,d=a*o-l*r,f=c*r-s*o,h=t*u+n*d+i*f;if(h===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/h;return e[0]=u*y,e[1]=(i*c-l*n)*y,e[2]=(a*n-i*s)*y,e[3]=d*y,e[4]=(l*t-i*o)*y,e[5]=(i*r-a*t)*y,e[6]=f*y,e[7]=(n*o-c*t)*y,e[8]=(s*t-n*r)*y,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,a){let o=Math.cos(r),c=Math.sin(r);return this.set(n*o,n*c,-n*(o*s+c*a)+s+e,-i*c,i*o,-i*(-c*s+o*a)+a+t,0,0,1),this}scale(e,t){return fa("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply($h.makeScale(e,t)),this}rotate(e){return fa("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply($h.makeRotation(-e)),this}translate(e,t){return fa("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply($h.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};$h=new tt,Xv=new tt().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),qv=new tt().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);ot=QC();Wh=new j;Qt=class Qt extends Bi{constructor(e=Qt.DEFAULT_IMAGE,t=Qt.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,a=1023,o=1009,c=Qt.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:tN++}),this.uuid=Di(),this.name="",this.source=new Vc(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=o,this.offset=new Ke(0,0),this.repeat=new Ke(1,1),this.center=new Ke(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new tt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Wh).x}get height(){return this.source.getSize(Wh).y}get depth(){return this.source.getSize(Wh).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){je(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){je(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}};Qt.DEFAULT_IMAGE=null;Qt.DEFAULT_MAPPING=300;Qt.DEFAULT_ANISOTROPY=1;Nt=class Nt{static{Nt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,a=0.1,o=e.elements,c=o[0],l=o[4],u=o[8],d=o[1],f=o[5],h=o[9],y=o[2],g=o[6],m=o[10];if(Math.abs(l-d)<0.01&&Math.abs(u-y)<0.01&&Math.abs(h-g)<0.01){if(Math.abs(l+d)<0.1&&Math.abs(u+y)<0.1&&Math.abs(h+g)<0.1&&Math.abs(c+f+m-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let b=(c+1)/2,_=(f+1)/2,x=(m+1)/2,v=(l+d)/4,E=(u+y)/4,S=(h+g)/4;if(b>_&&b>x)if(b<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(b),i=v/n,r=E/n;else if(_>x)if(_<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(_),n=v/i,r=S/i;else if(x<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(x),n=E/r,i=S/r;return this.set(n,i,r,t),this}let p=Math.sqrt((g-h)*(g-h)+(u-y)*(u-y)+(d-l)*(d-l));if(Math.abs(p)<0.001)p=1;return this.x=(g-h)/p,this.y=(u-y)/p,this.z=(d-l)/p,this.w=Math.acos((c+f+m-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ct(this.x,e.x,t.x),this.y=ct(this.y,e.y,t.y),this.z=ct(this.z,e.z,t.z),this.w=ct(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ct(this.x,e,t),this.y=ct(this.y,e,t),this.z=ct(this.z,e,t),this.w=ct(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ct(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};gm=class gm extends Bi{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Nt(0,0,e,t),this.scissorTest=!1,this.viewport=new Nt(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Qt(i),s=n.count;for(let a=0;a<s;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new Vc(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}};ai=class ai extends gm{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}};ad=class ad extends Qt{constructor(e=null,t=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};bm=class bm extends Qt{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}};Qe=class Qe{static{Qe.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,a,o,c,l,u,d,f,h,y,g){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,a,o,c,l,u,d,f,h,y,g)}set(e,t,n,i,r,s,a,o,c,l,u,d,f,h,y,g){let m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=r,m[5]=s,m[9]=a,m[13]=o,m[2]=c,m[6]=l,m[10]=u,m[14]=d,m[3]=f,m[7]=h,m[11]=y,m[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 Qe().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/Ya.setFromMatrixColumn(e,0).length(),r=1/Ya.setFromMatrixColumn(e,1).length(),s=1/Ya.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let d=s*l,f=s*u,h=a*l,y=a*u;t[0]=o*l,t[4]=-o*u,t[8]=c,t[1]=f+h*c,t[5]=d-y*c,t[9]=-a*o,t[2]=y-d*c,t[6]=h+f*c,t[10]=s*o}else if(e.order==="YXZ"){let d=o*l,f=o*u,h=c*l,y=c*u;t[0]=d+y*a,t[4]=h*a-f,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-a,t[2]=f*a-h,t[6]=y+d*a,t[10]=s*o}else if(e.order==="ZXY"){let d=o*l,f=o*u,h=c*l,y=c*u;t[0]=d-y*a,t[4]=-s*u,t[8]=h+f*a,t[1]=f+h*a,t[5]=s*l,t[9]=y-d*a,t[2]=-s*c,t[6]=a,t[10]=s*o}else if(e.order==="ZYX"){let d=s*l,f=s*u,h=a*l,y=a*u;t[0]=o*l,t[4]=h*c-f,t[8]=d*c+y,t[1]=o*u,t[5]=y*c+d,t[9]=f*c-h,t[2]=-c,t[6]=a*o,t[10]=s*o}else if(e.order==="YZX"){let d=s*o,f=s*c,h=a*o,y=a*c;t[0]=o*l,t[4]=y-d*u,t[8]=h*u+f,t[1]=u,t[5]=s*l,t[9]=-a*l,t[2]=-c*l,t[6]=f*u+h,t[10]=d-y*u}else if(e.order==="XZY"){let d=s*o,f=s*c,h=a*o,y=a*c;t[0]=o*l,t[4]=-u,t[8]=c*l,t[1]=d*u+y,t[5]=s*l,t[9]=f*u-h,t[2]=h*u-f,t[6]=a*l,t[10]=y*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(nN,e,iN)}lookAt(e,t,n){let i=this.elements;if(ii.subVectors(e,t),ii.lengthSq()===0)ii.z=1;if(ii.normalize(),ts.crossVectors(n,ii),ts.lengthSq()===0){if(Math.abs(n.z)===1)ii.x+=0.0001;else ii.z+=0.0001;ii.normalize(),ts.crossVectors(n,ii)}return ts.normalize(),xu.crossVectors(ii,ts),i[0]=ts.x,i[4]=xu.x,i[8]=ii.x,i[1]=ts.y,i[5]=xu.y,i[9]=ii.y,i[2]=ts.z,i[6]=xu.z,i[10]=ii.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[4],o=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],h=n[2],y=n[6],g=n[10],m=n[14],p=n[3],b=n[7],_=n[11],x=n[15],v=i[0],E=i[4],S=i[8],T=i[12],A=i[1],P=i[5],w=i[9],I=i[13],F=i[2],N=i[6],U=i[10],D=i[14],O=i[3],K=i[7],B=i[11],X=i[15];return r[0]=s*v+a*A+o*F+c*O,r[4]=s*E+a*P+o*N+c*K,r[8]=s*S+a*w+o*U+c*B,r[12]=s*T+a*I+o*D+c*X,r[1]=l*v+u*A+d*F+f*O,r[5]=l*E+u*P+d*N+f*K,r[9]=l*S+u*w+d*U+f*B,r[13]=l*T+u*I+d*D+f*X,r[2]=h*v+y*A+g*F+m*O,r[6]=h*E+y*P+g*N+m*K,r[10]=h*S+y*w+g*U+m*B,r[14]=h*T+y*I+g*D+m*X,r[3]=p*v+b*A+_*F+x*O,r[7]=p*E+b*P+_*N+x*K,r[11]=p*S+b*w+_*U+x*B,r[15]=p*T+b*I+_*D+x*X,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],a=e[5],o=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],h=e[3],y=e[7],g=e[11],m=e[15],p=o*f-c*d,b=a*f-c*u,_=a*d-o*u,x=s*f-c*l,v=s*d-o*l,E=s*u-a*l;return t*(y*p-g*b+m*_)-n*(h*p-g*x+m*v)+i*(h*b-y*x+m*E)-r*(h*_-y*v+g*E)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],a=e[9],o=e[2],c=e[6],l=e[10];return t*(s*l-a*c)-n*(r*l-a*o)+i*(r*c-s*o)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],h=e[12],y=e[13],g=e[14],m=e[15],p=t*a-n*s,b=t*o-i*s,_=t*c-r*s,x=n*o-i*a,v=n*c-r*a,E=i*c-r*o,S=l*y-u*h,T=l*g-d*h,A=l*m-f*h,P=u*g-d*y,w=u*m-f*y,I=d*m-f*g,F=p*I-b*w+_*P+x*A-v*T+E*S;if(F===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let N=1/F;return e[0]=(a*I-o*w+c*P)*N,e[1]=(i*w-n*I-r*P)*N,e[2]=(y*E-g*v+m*x)*N,e[3]=(d*v-u*E-f*x)*N,e[4]=(o*A-s*I-c*T)*N,e[5]=(t*I-i*A+r*T)*N,e[6]=(g*_-h*E-m*b)*N,e[7]=(l*E-d*_+f*b)*N,e[8]=(s*w-a*A+c*S)*N,e[9]=(n*A-t*w-r*S)*N,e[10]=(h*v-y*_+m*p)*N,e[11]=(u*_-l*v-f*p)*N,e[12]=(a*T-s*P-o*S)*N,e[13]=(t*P-n*T+i*S)*N,e[14]=(y*b-h*x-g*p)*N,e[15]=(l*x-u*b+d*p)*N,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:a,z:o}=e,c=r*s,l=r*a;return this.set(c*s+n,c*a-i*o,c*o+i*a,0,c*a+i*o,l*a+n,l*o-i*s,0,c*o-i*a,l*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:a,_w:o}=t,c=r+r,l=s+s,u=a+a,d=r*c,f=r*l,h=r*u,y=s*l,g=s*u,m=a*u,p=o*c,b=o*l,_=o*u,{x,y:v,z:E}=n;return i[0]=(1-(y+m))*x,i[1]=(f+_)*x,i[2]=(h-b)*x,i[3]=0,i[4]=(f-_)*v,i[5]=(1-(d+m))*v,i[6]=(g+p)*v,i[7]=0,i[8]=(h+b)*E,i[9]=(g-p)*E,i[10]=(1-(d+y))*E,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=Ya.set(i[0],i[1],i[2]).length(),a=Ya.set(i[4],i[5],i[6]).length(),o=Ya.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Ni.copy(this);let c=1/s,l=1/a,u=1/o;return Ni.elements[0]*=c,Ni.elements[1]*=c,Ni.elements[2]*=c,Ni.elements[4]*=l,Ni.elements[5]*=l,Ni.elements[6]*=l,Ni.elements[8]*=u,Ni.elements[9]*=u,Ni.elements[10]*=u,t.setFromRotationMatrix(Ni),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,r,s,a=2000,o=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),d=(t+e)/(t-e),f=(n+i)/(n-i),h,y;if(o)h=r/(s-r),y=s*r/(s-r);else if(a===2000)h=-(s+r)/(s-r),y=-2*s*r/(s-r);else if(a===2001)h=-s/(s-r),y=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=h,c[14]=y,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,a=2000,o=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),d=-(t+e)/(t-e),f=-(n+i)/(n-i),h,y;if(o)h=1/(s-r),y=s/(s-r);else if(a===2000)h=-2/(s-r),y=-(s+r)/(s-r);else if(a===2001)h=-1/(s-r),y=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=h,c[14]=y,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};Ya=new j,Ni=new Qe,nN=new j(0,0,0),iN=new j(1,1,1),ts=new j,xu=new j,ii=new j,Jv=new Qe,Zv=new ln;cr=class cr{constructor(e=0,t=0,n=0,i=cr.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],a=i[8],o=i[1],c=i[5],l=i[9],u=i[2],d=i[6],f=i[10];switch(t){case"XYZ":if(this._y=Math.asin(ct(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,f),this._z=Math.atan2(-s,r);else this._x=Math.atan2(d,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-ct(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(a,f),this._z=Math.atan2(o,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(ct(d,-1,1)),Math.abs(d)<0.9999999)this._y=Math.atan2(-u,f),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(o,r);break;case"ZYX":if(this._y=Math.asin(-ct(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(d,f),this._z=Math.atan2(o,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(ct(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(a,f);break;case"XZY":if(this._z=Math.asin(-ct(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(d,c),this._y=Math.atan2(a,r);else this._x=Math.atan2(-l,f),this._y=0;break;default:je("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return Jv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Jv,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Zv.setFromEuler(this),this.setFromQuaternion(Zv,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};cr.DEFAULT_ORDER="XYZ";Yv=new j,Qa=new ln,Cr=new Qe,_u=new j,Tc=new j,sN=new j,aN=new ln,Qv=new j(1,0,0),eE=new j(0,1,0),tE=new j(0,0,1),nE={type:"added"},oN={type:"removed"},eo={type:"childadded",child:null},Xh={type:"childremoved",child:null};kt=class kt extends Bi{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:rN++}),this.uuid=Di(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=kt.DEFAULT_UP.clone();let e=new j,t=new cr,n=new ln,i=new j(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Qe},normalMatrix:{value:new tt}}),this.matrix=new Qe,this.matrixWorld=new Qe,this.matrixAutoUpdate=kt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=kt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new od,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Qa.setFromAxisAngle(e,t),this.quaternion.multiply(Qa),this}rotateOnWorldAxis(e,t){return Qa.setFromAxisAngle(e,t),this.quaternion.premultiply(Qa),this}rotateX(e){return this.rotateOnAxis(Qv,e)}rotateY(e){return this.rotateOnAxis(eE,e)}rotateZ(e){return this.rotateOnAxis(tE,e)}translateOnAxis(e,t){return Yv.copy(e).applyQuaternion(this.quaternion),this.position.add(Yv.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Qv,e)}translateY(e){return this.translateOnAxis(eE,e)}translateZ(e){return this.translateOnAxis(tE,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Cr.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)_u.copy(e);else _u.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Tc.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Cr.lookAt(Tc,_u,this.up);else Cr.lookAt(_u,Tc,this.up);if(this.quaternion.setFromRotationMatrix(Cr),i)Cr.extractRotation(i.matrixWorld),Qa.setFromRotationMatrix(Cr),this.quaternion.premultiply(Qa.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return Ze("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(nE),eo.child=e,this.dispatchEvent(eo),eo.child=null;else Ze("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(oN),Xh.child=e,this.dispatchEvent(Xh),Xh.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),Cr.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Cr.multiply(e.parent.matrixWorld);return e.applyMatrix4(Cr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(nE),eo.child=e,this.dispatchEvent(eo),eo.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Tc,e,sN),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Tc,aN,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((a)=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((a)=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(a,o){if(a[o.uuid]===void 0)a[o.uuid]=o.toJSON(e);return o.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let o=a.shapes;if(Array.isArray(o))for(let c=0,l=o.length;c<l;c++){let u=o[c];r(e.shapes,u)}else r(e.shapes,o)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let o=0,c=this.material.length;o<c;o++)a.push(r(e.materials,this.material[o]));i.material=a}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let o=this.animations[a];i.animations.push(r(e.animations,o))}}if(t){let a=s(e.geometries),o=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),d=s(e.skeletons),f=s(e.animations),h=s(e.nodes);if(a.length>0)n.geometries=a;if(o.length>0)n.materials=o;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(d.length>0)n.skeletons=d;if(f.length>0)n.animations=f;if(h.length>0)n.nodes=h}return n.object=i,n;function s(a){let o=[];for(let c in a){let l=a[c];delete l.metadata,o.push(l)}return o}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}};kt.DEFAULT_UP=new j(0,1,0);kt.DEFAULT_MATRIX_AUTO_UPDATE=!0;kt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;ar=class ar extends kt{constructor(){super();this.isGroup=!0,this.type="Group"}};cN={type:"move"};wT={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},ns={h:0,s:0,l:0},vu={h:0,s:0,l:0};qe=class qe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ot.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=ot.workingColorSpace){return this.r=e,this.g=t,this.b=n,ot.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=ot.workingColorSpace){if(e=pm(e,1),t=ct(t,0,1),n=ct(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=qh(s,r,e+0.3333333333333333),this.g=qh(s,r,e),this.b=qh(s,r,e-0.3333333333333333)}return ot.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)je("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:je("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else je("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=wT[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else je("Color: Unknown color "+e);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Lr(e.r),this.g=Lr(e.g),this.b=Lr(e.b),this}copyLinearToSRGB(e){return this.r=fo(e.r),this.g=fo(e.g),this.b=fo(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return ot.workingToColorSpace(Nn.copy(this),e),Math.round(ct(Nn.r*255,0,255))*65536+Math.round(ct(Nn.g*255,0,255))*256+Math.round(ct(Nn.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ot.workingColorSpace){ot.workingToColorSpace(Nn.copy(this),t);let{r:n,g:i,b:r}=Nn,s=Math.max(n,i,r),a=Math.min(n,i,r),o,c,l=(a+s)/2;if(a===s)o=0,c=0;else{let u=s-a;switch(c=l<=0.5?u/(s+a):u/(2-s-a),s){case n:o=(i-r)/u+(i<r?6:0);break;case i:o=(r-n)/u+2;break;case r:o=(n-i)/u+4;break}o/=6}return e.h=o,e.s=c,e.l=l,e}getRGB(e,t=ot.workingColorSpace){return ot.workingToColorSpace(Nn.copy(this),t),e.r=Nn.r,e.g=Nn.g,e.b=Nn.b,e}getStyle(e="srgb"){ot.workingToColorSpace(Nn.copy(this),e);let{r:t,g:n,b:i}=Nn;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(ns),this.setHSL(ns.h+e,ns.s+t,ns.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(ns),e.getHSL(vu);let n=Pc(ns.h,vu.h,t),i=Pc(ns.s,vu.s,t),r=Pc(ns.l,vu.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};Nn=new qe;qe.NAMES=wT;Ao=class Ao extends kt{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new cr,this.environmentIntensity=1,this.environmentRotation=new cr,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null)this.overrideMaterial=e.overrideMaterial.clone();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}};Pi=new j,Nr=new j,Jh=new j,Pr=new j,to=new j,no=new j,iE=new j,Zh=new j,Yh=new j,Qh=new j,ep=new Nt,tp=new Nt,np=new Nt;Or=[new j,new j,new j,new j,new j,new j,new j,new j],Oi=new j,Eu=new hn,io=new j,ro=new j,so=new j,is=new j,rs=new j,ca=new j,Ac=new j,Tu=new j,Au=new j,la=new j;cn=new j,Su=new Ke;vn=class vn extends Bi{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:lN++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Su.fromBufferAttribute(this,t),Su.applyMatrix3(e),this.setXY(t,Su.x,Su.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyMatrix3(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyMatrix4(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyNormalMatrix(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.transformDirection(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=ki(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=Ct(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=ki(t,this.array);return t}setX(e,t){if(this.normalized)t=Ct(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=ki(t,this.array);return t}setY(e,t){if(this.normalized)t=Ct(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=ki(t,this.array);return t}setZ(e,t){if(this.normalized)t=Ct(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=ki(t,this.array);return t}setW(e,t){if(this.normalized)t=Ct(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=Ct(t,this.array),n=Ct(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=Ct(t,this.array),n=Ct(n,this.array),i=Ct(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=Ct(t,this.array),n=Ct(n,this.array),i=Ct(i,this.array),r=Ct(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}};cd=class cd extends vn{constructor(e,t,n){super(new Uint16Array(e),t,n)}};ld=class ld extends vn{constructor(e,t,n){super(new Uint32Array(e),t,n)}};Gn=class Gn extends vn{constructor(e,t,n){super(new Float32Array(e),t,n)}};uN=new hn,Sc=new j,rp=new j;gi=new Qe,sp=new kt,ao=new j,ri=new hn,wc=new hn,_n=new j;On=class On extends Bi{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:dN++}),this.uuid=Di(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){if(Array.isArray(e))this.index=new((DC(e))?ld:cd)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new tt().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return gi.makeRotationFromQuaternion(e),this.applyMatrix4(gi),this}rotateX(e){return gi.makeRotationX(e),this.applyMatrix4(gi),this}rotateY(e){return gi.makeRotationY(e),this.applyMatrix4(gi),this}rotateZ(e){return gi.makeRotationZ(e),this.applyMatrix4(gi),this}translate(e,t,n){return gi.makeTranslation(e,t,n),this.applyMatrix4(gi),this}scale(e,t,n){return gi.makeScale(e,t,n),this.applyMatrix4(gi),this}lookAt(e){return sp.lookAt(e),sp.updateMatrix(),this.applyMatrix4(sp.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ao).negate(),this.translate(ao.x,ao.y,ao.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new Gn(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)je("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new hn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ze("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new j(-1/0,-1/0,-1/0),new j(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(ri.setFromBufferAttribute(r),this.morphTargetsRelative)_n.addVectors(this.boundingBox.min,ri.min),this.boundingBox.expandByPoint(_n),_n.addVectors(this.boundingBox.max,ri.max),this.boundingBox.expandByPoint(_n);else this.boundingBox.expandByPoint(ri.min),this.boundingBox.expandByPoint(ri.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Ze('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new oi;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ze("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new j,1/0);return}if(e){let n=this.boundingSphere.center;if(ri.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let a=t[r];if(wc.setFromBufferAttribute(a),this.morphTargetsRelative)_n.addVectors(ri.min,wc.min),ri.expandByPoint(_n),_n.addVectors(ri.max,wc.max),ri.expandByPoint(_n);else ri.expandByPoint(wc.min),ri.expandByPoint(wc.max)}ri.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)_n.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(_n));if(t)for(let r=0,s=t.length;r<s;r++){let a=t[r],o=this.morphTargetsRelative;for(let c=0,l=a.count;c<l;c++){if(_n.fromBufferAttribute(a,c),o)ao.fromBufferAttribute(e,c),_n.add(ao);i=Math.max(i,n.distanceToSquared(_n))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ze('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ze("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new vn(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let a=[],o=[];for(let S=0;S<n.count;S++)a[S]=new j,o[S]=new j;let c=new j,l=new j,u=new j,d=new Ke,f=new Ke,h=new Ke,y=new j,g=new j;function m(S,T,A){c.fromBufferAttribute(n,S),l.fromBufferAttribute(n,T),u.fromBufferAttribute(n,A),d.fromBufferAttribute(r,S),f.fromBufferAttribute(r,T),h.fromBufferAttribute(r,A),l.sub(c),u.sub(c),f.sub(d),h.sub(d);let P=1/(f.x*h.y-h.x*f.y);if(!isFinite(P))return;y.copy(l).multiplyScalar(h.y).addScaledVector(u,-f.y).multiplyScalar(P),g.copy(u).multiplyScalar(f.x).addScaledVector(l,-h.x).multiplyScalar(P),a[S].add(y),a[T].add(y),a[A].add(y),o[S].add(g),o[T].add(g),o[A].add(g)}let p=this.groups;if(p.length===0)p=[{start:0,count:e.count}];for(let S=0,T=p.length;S<T;++S){let A=p[S],{start:P,count:w}=A;for(let I=P,F=P+w;I<F;I+=3)m(e.getX(I+0),e.getX(I+1),e.getX(I+2))}let b=new j,_=new j,x=new j,v=new j;function E(S){x.fromBufferAttribute(i,S),v.copy(x);let T=a[S];b.copy(T),b.sub(x.multiplyScalar(x.dot(T))).normalize(),_.crossVectors(v,T);let P=_.dot(o[S])<0?-1:1;s.setXYZW(S,b.x,b.y,b.z,P)}for(let S=0,T=p.length;S<T;++S){let A=p[S],{start:P,count:w}=A;for(let I=P,F=P+w;I<F;I+=3)E(e.getX(I+0)),E(e.getX(I+1)),E(e.getX(I+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new vn(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);let i=new j,r=new j,s=new j,a=new j,o=new j,c=new j,l=new j,u=new j;if(e)for(let d=0,f=e.count;d<f;d+=3){let h=e.getX(d+0),y=e.getX(d+1),g=e.getX(d+2);i.fromBufferAttribute(t,h),r.fromBufferAttribute(t,y),s.fromBufferAttribute(t,g),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),a.fromBufferAttribute(n,h),o.fromBufferAttribute(n,y),c.fromBufferAttribute(n,g),a.add(l),o.add(l),c.add(l),n.setXYZ(h,a.x,a.y,a.z),n.setXYZ(y,o.x,o.y,o.z),n.setXYZ(g,c.x,c.y,c.z)}else for(let d=0,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),s.fromBufferAttribute(t,d+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(d+0,l.x,l.y,l.z),n.setXYZ(d+1,l.x,l.y,l.z),n.setXYZ(d+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)_n.fromBufferAttribute(e,t),_n.normalize(),e.setXYZ(t,_n.x,_n.y,_n.z)}toNonIndexed(){function e(a,o){let{array:c,itemSize:l,normalized:u}=a,d=new c.constructor(o.length*l),f=0,h=0;for(let y=0,g=o.length;y<g;y++){if(a.isInterleavedBufferAttribute)f=o[y]*a.data.stride+a.offset;else f=o[y]*l;for(let m=0;m<l;m++)d[h++]=c[f++]}return new vn(d,l,u)}if(this.index===null)return je("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new On,n=this.index.array,i=this.attributes;for(let a in i){let o=i[a],c=e(o,n);t.setAttribute(a,c)}let r=this.morphAttributes;for(let a in r){let o=[],c=r[a];for(let l=0,u=c.length;l<u;l++){let d=c[l],f=e(d,n);o.push(f)}t.morphAttributes[a]=o}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let a=0,o=s.length;a<o;a++){let c=s[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let o=this.parameters;for(let c in o)if(o[c]!==void 0)e[c]=o[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let o in n){let c=n[o];e.data.attributes[o]=c.toJSON(e.data)}let i={},r=!1;for(let o in this.morphAttributes){let c=this.morphAttributes[o],l=[];for(let u=0,d=c.length;u<d;u++){let f=c[u];l.push(f.toJSON(e.data))}if(l.length>0)i[o]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let a=this.boundingSphere;if(a!==null)e.data.boundingSphere=a.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let d=0,f=u.length;d<f;d++)l.push(u[d].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let a=e.boundingBox;if(a!==null)this.boundingBox=a.clone();let o=e.boundingSphere;if(o!==null)this.boundingSphere=o.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}};Vn=new j;ap=new j,fN=new j,hN=new tt;$n=class $n extends Bi{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:pN++}),this.uuid=Di(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new qe(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){je(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){je(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let a in r){let o=r[a];delete o.metadata,s.push(o)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new qe().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new bi().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Ke().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Ke().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}};kr=new j,op=new j,wu=new j,Mu=new j;hr=class hr extends $n{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new qe(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 cr,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};rE=new Qe,ua=new hs,Ru=new oi,sE=new j,Iu=new j,Cu=new j,Nu=new j,cp=new j,Pu=new j,aE=new j,Ou=new j;jt=class jt extends kt{constructor(e=new On,t=new hr){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let a=this.morphTargetInfluences;if(r&&a){Pu.set(0,0,0);for(let o=0,c=r.length;o<c;o++){let l=a[o],u=r[o];if(l===0)continue;if(cp.fromBufferAttribute(u,e),s)Pu.addScaledVector(cp,l);else Pu.addScaledVector(cp.sub(t),l)}t.add(Pu)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(Ru.copy(n.boundingSphere),Ru.applyMatrix4(r),ua.copy(e.ray).recast(e.near),Ru.containsPoint(ua.origin)===!1){if(ua.intersectSphere(Ru,sE)===null)return;if(ua.origin.distanceToSquared(sE)>(e.far-e.near)**2)return}if(rE.copy(r).invert(),ua.copy(e.ray).applyMatrix4(rE),n.boundingBox!==null){if(ua.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,ua)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:d,drawRange:f}=r;if(a!==null)if(Array.isArray(s))for(let h=0,y=d.length;h<y;h++){let g=d[h],m=s[g.materialIndex],p=Math.max(g.start,f.start),b=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let _=p,x=b;_<x;_+=3){let v=a.getX(_),E=a.getX(_+1),S=a.getX(_+2);if(i=ku(this,m,e,n,c,l,u,v,E,S),i)i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,t.push(i)}}else{let h=Math.max(0,f.start),y=Math.min(a.count,f.start+f.count);for(let g=h,m=y;g<m;g+=3){let p=a.getX(g),b=a.getX(g+1),_=a.getX(g+2);if(i=ku(this,s,e,n,c,l,u,p,b,_),i)i.faceIndex=Math.floor(g/3),t.push(i)}}else if(o!==void 0)if(Array.isArray(s))for(let h=0,y=d.length;h<y;h++){let g=d[h],m=s[g.materialIndex],p=Math.max(g.start,f.start),b=Math.min(o.count,Math.min(g.start+g.count,f.start+f.count));for(let _=p,x=b;_<x;_+=3){let v=_,E=_+1,S=_+2;if(i=ku(this,m,e,n,c,l,u,v,E,S),i)i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,t.push(i)}}else{let h=Math.max(0,f.start),y=Math.min(o.count,f.start+f.count);for(let g=h,m=y;g<m;g+=3){let p=g,b=g+1,_=g+2;if(i=ku(this,s,e,n,c,l,u,p,b,_),i)i.faceIndex=Math.floor(g/3),t.push(i)}}}};Mc=new Nt,oE=new Nt,cE=new Nt,gN=new Nt,lE=new Qe,Du=new j,lp=new oi,uE=new Qe,up=new hs;ud=class ud extends jt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Qe,this.bindMatrixInverse=new Qe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new hn;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Du),this.boundingBox.expandByPoint(Du)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new oi;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Du),this.boundingSphere.expandByPoint(Du)}copy(e,t){if(super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(lp.copy(this.boundingSphere),lp.applyMatrix4(i),e.ray.intersectsSphere(lp)===!1)return;if(uE.copy(i).invert(),up.copy(e.ray).applyMatrix4(uE),this.boundingBox!==null){if(up.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,up)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new Nt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else je("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(oE.fromBufferAttribute(i.attributes.skinIndex,e),cE.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)Mc.copy(t),t.set(0,0,0,0);else Mc.set(...t,1),t.set(0,0,0);Mc.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=cE.getComponent(r);if(s!==0){let a=oE.getComponent(r);lE.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(gN.copy(Mc).applyMatrix4(lE),s)}}if(t.isVector4)t.w=Mc.w;return t.applyMatrix4(this.bindMatrixInverse)}};Gc=class Gc extends kt{constructor(){super();this.isBone=!0,this.type="Bone"}};$c=class $c extends Qt{constructor(e=null,t=1,n=1,i,r,s,a,o,c=1003,l=1003,u,d){super(null,s,a,o,c,l,i,r,u,d);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};dE=new Qe,bN=new Qe;os=class os extends vn{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};oo=new Qe,fE=new Qe,Lu=[],hE=new hn,yN=new Qe,Rc=new jt,Ic=new oi;wo=class wo extends jt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new os(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,yN)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new hn;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,oo),hE.copy(e.boundingBox).applyMatrix4(oo),this.boundingBox.union(hE)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new oi;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,oo),Ic.copy(e.boundingSphere).applyMatrix4(oo),this.boundingSphere.union(Ic)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let a=0;a<n.length;a++)n[a]=i[s+a]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(Rc.geometry=this.geometry,Rc.material=this.material,Rc.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Ic.copy(this.boundingSphere),Ic.applyMatrix4(n),e.ray.intersectsSphere(Ic)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,oo),fE.multiplyMatrices(n,oo),Rc.matrixWorld=fE,Rc.raycast(e,Lu);for(let s=0,a=Lu.length;s<a;s++){let o=Lu[s];o.instanceId=r,o.object=this,t.push(o)}Lu.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new os(new Float32Array(this.instanceMatrix.count*3).fill(1),3);return t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;if(this.morphTexture===null)this.morphTexture=new $c(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let a=this.geometry.morphTargetsRelative?1:1-s,o=i*e;return r[o]=a,r.set(n,o+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}};da=new oi,xN=new Ke(0.5,0.5),Fu=new j;Xc=class Xc extends $n{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new qe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}};$u=new j,Ku=new j,pE=new Qe,Cc=new hs,Uu=new oi,dp=new j,mE=new j;ps=class ps extends kt{constructor(e=new On,t=new Xc){super();this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)$u.fromBufferAttribute(t,i-1),Ku.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=$u.distanceTo(Ku);e.setAttribute("lineDistance",new Gn(n,1))}else je("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Uu.copy(n.boundingSphere),Uu.applyMatrix4(i),Uu.radius+=r,e.ray.intersectsSphere(Uu)===!1)return;pE.copy(i).invert(),Cc.copy(e.ray).applyMatrix4(pE);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,c=this.isLineSegments?2:1,l=n.index,d=n.attributes.position;if(l!==null){let f=Math.max(0,s.start),h=Math.min(l.count,s.start+s.count);for(let y=f,g=h-1;y<g;y+=c){let m=l.getX(y),p=l.getX(y+1),b=Bu(this,e,Cc,o,m,p,y);if(b)t.push(b)}if(this.isLineLoop){let y=l.getX(h-1),g=l.getX(f),m=Bu(this,e,Cc,o,y,g,h-1);if(m)t.push(m)}}else{let f=Math.max(0,s.start),h=Math.min(d.count,s.start+s.count);for(let y=f,g=h-1;y<g;y+=c){let m=Bu(this,e,Cc,o,y,y+1,y);if(m)t.push(m)}if(this.isLineLoop){let y=Bu(this,e,Cc,o,h-1,f,h-1);if(y)t.push(y)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};gE=new j,bE=new j;dd=class dd extends ps{constructor(e,t){super(e,t);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)gE.fromBufferAttribute(t,i),bE.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+gE.distanceTo(bE);e.setAttribute("lineDistance",new Gn(n,1))}else je("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};fd=class fd extends ps{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}};qc=class qc extends $n{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new qe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}};yE=new Qe,pp=new hs,zu=new oi,Vu=new j;Mo=class Mo extends kt{constructor(e=new On,t=new qc){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(zu.copy(n.boundingSphere),zu.applyMatrix4(i),zu.radius+=r,e.ray.intersectsSphere(zu)===!1)return;yE.copy(i).invert(),pp.copy(e.ray).applyMatrix4(yE);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,c=n.index,u=n.attributes.position;if(c!==null){let d=Math.max(0,s.start),f=Math.min(c.count,s.start+s.count);for(let h=d,y=f;h<y;h++){let g=c.getX(h);Vu.fromBufferAttribute(u,g),xE(Vu,g,o,i,e,t,this)}}else{let d=Math.max(0,s.start),f=Math.min(u.count,s.start+s.count);for(let h=d,y=f;h<y;h++)Vu.fromBufferAttribute(u,h),xE(Vu,h,o,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};hd=class hd extends Qt{constructor(e=[],t=301,n,i,r,s,a,o,c,l){super(e,t,n,i,r,s,a,o,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};_a=class _a extends Qt{constructor(e,t,n=1014,i,r,s,a=1003,o=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:u};super(d,i,r,s,a,o,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Vc(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}};ym=class ym extends _a{constructor(e,t=1014,n=301,i,r,s=1003,a=1003,o,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,a,o,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}};pd=class pd extends Qt{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}};ms=class ms extends On{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let o=[],c=[],l=[],u=[],d=0,f=0;h("z","y","x",-1,-1,n,t,e,s,r,0),h("z","y","x",1,-1,n,t,-e,s,r,1),h("x","z","y",1,1,e,n,t,i,s,2),h("x","z","y",1,-1,e,n,-t,i,s,3),h("x","y","z",1,-1,e,t,n,i,r,4),h("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(o),this.setAttribute("position",new Gn(c,3)),this.setAttribute("normal",new Gn(l,3)),this.setAttribute("uv",new Gn(u,2));function h(y,g,m,p,b,_,x,v,E,S,T){let A=_/E,P=x/S,w=_/2,I=x/2,F=v/2,N=E+1,U=S+1,D=0,O=0,K=new j;for(let B=0;B<U;B++){let X=B*P-I;for(let q=0;q<N;q++){let le=q*A-w;K[y]=le*p,K[g]=X*b,K[m]=F,c.push(K.x,K.y,K.z),K[y]=0,K[g]=0,K[m]=v>0?1:-1,l.push(K.x,K.y,K.z),u.push(q/E),u.push(1-B/S),D+=1}}for(let B=0;B<S;B++)for(let X=0;X<E;X++){let q=d+X+N*B,le=d+X+N*(B+1),de=d+(X+1)+N*(B+1),Me=d+(X+1)+N*B;o.push(q,le,Me),o.push(le,de,Me),O+=6}a.addGroup(f,O,T),f+=O,d+=D}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ms(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};Jc=class Jc extends On{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,a=Math.floor(n),o=Math.floor(i),c=a+1,l=o+1,u=e/a,d=t/o,f=[],h=[],y=[],g=[];for(let m=0;m<l;m++){let p=m*d-s;for(let b=0;b<c;b++){let _=b*u-r;h.push(_,-p,0),y.push(0,0,1),g.push(b/a),g.push(1-m/o)}}for(let m=0;m<o;m++)for(let p=0;p<a;p++){let b=p+c*m,_=p+c*(m+1),x=p+1+c*(m+1),v=p+1+c*m;f.push(b,_,v),f.push(_,x,v)}this.setIndex(f),this.setAttribute("position",new Gn(h,3)),this.setAttribute("normal",new Gn(y,3)),this.setAttribute("uv",new Gn(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Jc(e.width,e.height,e.widthSegments,e.heightSegments)}};MT={clone:va,merge:kn};_i=class _i extends $n{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=vN,this.fragmentShader=EN,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0)this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=va(e.uniforms),this.uniformsGroups=_N(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new qe().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ke().fromArray(i.value);break;case"v3":this.uniforms[n].value=new j().fromArray(i.value);break;case"v4":this.uniforms[n].value=new Nt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new tt().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Qe().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}};_m=class _m extends _i{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};Ur=class Ur extends $n{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new qe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new cr,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}};ci=class ci extends Ur{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ke(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ct(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new qe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new qe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new qe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}};md=class md extends $n{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new qe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new cr,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}};vm=class vm extends $n{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}};Em=class Em extends $n{constructor(e){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};Tm=class Tm extends Br{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,a=i[r],o=i[s];if(a===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,a=2*t-n;break;case 2402:r=i.length-2,a=t+i[r]-i[r+1];break;default:r=e,a=n}if(o===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,o=2*n-t;break;case 2402:s=1,o=n+i[1]-i[0];break;default:s=e-1,o=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(o-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,c=o-a,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,h=(n-t)/(i-t),y=h*h,g=y*h,m=-d*g+2*d*y-d*h,p=(1+d)*g+(-1.5-2*d)*y+(-0.5+d)*h+1,b=(-1-f)*g+(1.5+f)*y+0.5*h,_=f*g-f*y;for(let x=0;x!==a;++x)r[x]=m*s[l+x]+p*s[c+x]+b*s[o+x]+_*s[u+x];return r}};gd=class gd extends Br{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,c=o-a,l=(n-t)/(i-t),u=1-l;for(let d=0;d!==a;++d)r[d]=s[c+d]*u+s[o+d]*l;return r}};Am=class Am extends Br{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}};Sm=class Sm extends Br{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,c=o-a,l=this.inTangents,u=this.outTangents;if(!l||!u){let h=(n-t)/(i-t),y=1-h;for(let g=0;g!==a;++g)r[g]=s[c+g]*y+s[o+g]*h;return r}let d=a*2,f=e-1;for(let h=0;h!==a;++h){let y=s[c+h],g=s[o+h],m=f*d+h*2,p=u[m],b=u[m+1],_=e*d+h*2,x=l[_],v=l[_+1],E=wN(n,t,p,x,i);r[h]=RT(E,y,b,v,g)}return r}};li.prototype.ValueTypeName="";li.prototype.TimeBufferType=Float32Array;li.prototype.ValueBufferType=Float32Array;li.prototype.DefaultInterpolation=2301;gs=class gs extends li{constructor(e,t,n){super(e,t,n)}};gs.prototype.ValueTypeName="bool";gs.prototype.ValueBufferType=Array;gs.prototype.DefaultInterpolation=2300;gs.prototype.InterpolantFactoryMethodLinear=void 0;gs.prototype.InterpolantFactoryMethodSmooth=void 0;bd=class bd extends li{constructor(e,t,n,i){super(e,t,n,i)}};bd.prototype.ValueTypeName="color";bs=class bs extends li{constructor(e,t,n,i){super(e,t,n,i)}};bs.prototype.ValueTypeName="number";wm=class wm extends Br{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-t)/(i-t),c=e*a;for(let l=c+a;c!==l;c+=4)ln.slerpFlat(r,0,s,c-a,s,c,o);return r}};ys=class ys extends li{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new wm(this.times,this.values,this.getValueSize(),e)}};ys.prototype.ValueTypeName="quaternion";ys.prototype.InterpolantFactoryMethodSmooth=void 0;xs=class xs extends li{constructor(e,t,n){super(e,t,n)}};xs.prototype.ValueTypeName="string";xs.prototype.ValueBufferType=Array;xs.prototype.DefaultInterpolation=2300;xs.prototype.InterpolantFactoryMethodLinear=void 0;xs.prototype.InterpolantFactoryMethodSmooth=void 0;Ea=class Ea extends li{constructor(e,t,n,i){super(e,t,n,i)}};Ea.prototype.ValueTypeName="vector";or={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(TE(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(TE(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};IT=new Zc;zr.DEFAULT_MATERIAL_NAME="__DEFAULT";Dr={};CT=class CT extends Error{constructor(e,t){super(e);this.response=t}};Yc=class Yc extends zr{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=or.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Dr[e]!==void 0){Dr[e].push({onLoad:t,onProgress:n,onError:i});return}Dr[e]=[],Dr[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,o=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)je("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Dr[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,h=f!==0,y=0,g=new ReadableStream({start(m){p();function p(){u.read().then(({done:b,value:_})=>{if(b)m.close();else{y+=_.byteLength;let x=new ProgressEvent("progress",{lengthComputable:h,loaded:y,total:f});for(let v=0,E=l.length;v<E;v++){let S=l[v];if(S.onProgress)S.onProgress(x)}m.enqueue(_),p()}},(b)=>{m.error(b)})}}});return new Response(g)}else throw new CT(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(o){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,a));case"json":return c.json();default:if(a==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(a),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then((h)=>f.decode(h))}}}).then((c)=>{or.add(`file:${e}`,c);let l=Dr[e];delete Dr[e];for(let u=0,d=l.length;u<d;u++){let f=l[u];if(f.onLoad)f.onLoad(c)}}).catch((c)=>{let l=Dr[e];if(l===void 0)throw this.manager.itemError(e),c;delete Dr[e];for(let u=0,d=l.length;u<d;u++){let f=l[u];if(f.onError)f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};co=new WeakMap;Mm=class Mm extends zr{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=or.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);else{let u=co.get(s);if(u===void 0)u=[],co.set(s,u);u.push({onLoad:t,onError:i})}return s}let a=ho("img");function o(){if(l(),t)t(this);let u=co.get(this)||[];for(let d=0;d<u.length;d++){let f=u[d];if(f.onLoad)f.onLoad(this)}co.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);or.remove(`image:${e}`);let d=co.get(this)||[];for(let f=0;f<d.length;f++){let h=d[f];if(h.onError)h.onError(u)}co.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){a.removeEventListener("load",o,!1),a.removeEventListener("error",c,!1)}if(a.addEventListener("load",o,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)a.crossOrigin=this.crossOrigin}return or.add(`image:${e}`,a),r.manager.itemStart(e),a.src=e,a}};Ro=class Ro extends zr{constructor(e){super(e)}load(e,t,n,i){let r=new Qt,s=new Mm(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(a){if(r.image=a,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}};Io=class Io extends kt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new qe(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}};yd=class yd extends Io{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(kt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new qe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}};fp=new Qe,AE=new j,SE=new j;ju=new j,Hu=new ln,sr=new j;xd=class xd extends kt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Qe,this.projectionMatrix=new Qe,this.projectionMatrixInverse=new Qe,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(ju,Hu,sr),sr.x===1&&sr.y===1&&sr.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(ju,Hu,sr.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(ju,Hu,sr),sr.x===1&&sr.y===1&&sr.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(ju,Hu,sr.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}};ss=new j,wE=new Ke,ME=new Ke;fn=class fn extends xd{constructor(e=50,t=1,n=0.1,i=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=0.5*this.getFilmHeight()/e;this.fov=ha*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Nc*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return ha*2*Math.atan(Math.tan(Nc*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){ss.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(ss.x,ss.y).multiplyScalar(-e/ss.z),ss.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(ss.x,ss.y).multiplyScalar(-e/ss.z)}getViewSize(e,t){return this.getViewBounds(e,wE,ME),t.subVectors(ME,wE)}setViewOffset(e,t,n,i,r,s){if(this.aspect=e/t,this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Nc*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:o,fullHeight:c}=s;r+=s.offsetX*i/o,t-=s.offsetY*n/c,i*=s.width/o,n*=s.height/c}let a=this.filmOffset;if(a!==0)r+=e*a/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null)t.object.view=Object.assign({},this.view);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};NT=class NT extends Qc{constructor(){super(new fn(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=ha*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;if(n!==t.fov||i!==t.aspect||r!==t.far)t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix();super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}};_d=class _d extends Io{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(kt.DEFAULT_UP),this.updateMatrix(),this.target=new kt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new NT}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);if(t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture)t.object.map=this.map.toJSON(e).uuid;return t.object.shadow=this.shadow.toJSON(),t}};PT=class PT extends Qc{constructor(){super(new fn(90,1,0.5,500));this.isPointLightShadow=!0}};Co=class Co extends Io{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new PT}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}};Ta=class Ta extends xd{constructor(e=-1,t=1,n=1,i=-1,r=0.1,s=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){if(this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,s=n+e,a=i+t,o=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,a-=l*this.view.offsetY,o=a-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null)t.object.view=Object.assign({},this.view);return t}};OT=class OT extends Qc{constructor(){super(new Ta(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}};No=class No extends Io{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(kt.DEFAULT_UP),this.updateMatrix(),this.target=new kt,this.shadow=new OT}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}};hp=new WeakMap;vd=class vd extends zr{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")je("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")je("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=or.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(hp.has(s)===!0){if(i)i(hp.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,a.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let o=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(or.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);hp.set(o,c),or.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});or.add(`image-bitmap:${e}`,o),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};Rm=class Rm extends kt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new fn(lo,uo,e,t);i.layers=this.layers,this.add(i);let r=new fn(lo,uo,e,t);r.layers=this.layers,this.add(r);let s=new fn(lo,uo,e,t);s.layers=this.layers,this.add(s);let a=new fn(lo,uo,e,t);a.layers=this.layers,this.add(a);let o=new fn(lo,uo,e,t);o.layers=this.layers,this.add(o);let c=new fn(lo,uo,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,a,o]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.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(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.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 Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,a,o,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),h=e.xr.enabled;e.xr.enabled=!1;let y=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let g=!1;if(e.isWebGLRenderer===!0)g=e.state.buffers.depth.getReversed();else g=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),g&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),g&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),g&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,3,i),g&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,4,i),g&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=y,e.setRenderTarget(n,5,i),g&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=h,n.texture.needsPMREMUpdate=!0}};Im=class Im extends fn{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};IN=new RegExp("["+Nm+"]","g"),Pm="[^"+Nm+"]",CN="[^"+Nm.replace("\\.","")+"]",NN=/((?:WC+[\/:])*)/.source.replace("WC",Pm),PN=/(WCOD+)?/.source.replace("WCOD",CN),ON=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Pm),kN=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Pm),DN=new RegExp("^"+NN+PN+ON+kN+"$"),LN=["material","materials","bones","map"];Et.Composite=kT;Et.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Et.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Et.prototype.GetterByBindingType=[Et.prototype._getValue_direct,Et.prototype._getValue_array,Et.prototype._getValue_arrayElement,Et.prototype._getValue_toArray];Et.prototype.SetterByBindingTypeAndVersioning=[[Et.prototype._setValue_direct,Et.prototype._setValue_direct_setNeedsUpdate,Et.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Et.prototype._setValue_array,Et.prototype._setValue_array_setNeedsUpdate,Et.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Et.prototype._setValue_arrayElement,Et.prototype._setValue_arrayElement_setNeedsUpdate,Et.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Et.prototype._setValue_fromArray,Et.prototype._setValue_fromArray_setNeedsUpdate,Et.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];FN=new Float32Array(1);Ed=class Ed extends Bi{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:a}=e,o=n.uuid,c=this._bindingsByRootAndName,l=c[o];if(l===void 0)l={},c[o]=l;for(let u=0;u!==r;++u){let d=i[u],f=d.name,h=l[f];if(h!==void 0)++h.referenceCount,s[u]=h;else{if(h=s[u],h!==void 0){if(h._cacheIndex===null)++h.referenceCount,this._addInactiveBinding(h,o,f);continue}let y=t&&t._propertyBindings[u].binding.parsedPath;h=new Cm(Et.create(n,f,y),d.ValueTypeName,d.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,f),s[u]=h}a[u].resultBuffer=h.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let a=s.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,a=s[r],o=a.knownActions,c=o[o.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,o[l]=c,o.pop(),e._byClipCacheIndex=null;let u=a.actionByRoot,d=(e._localRoot||this._root).uuid;if(delete u[d],o.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,a=s[i],o=t[t.length-1],c=e._cacheIndex;if(o._cacheIndex=c,t[c]=o,t.pop(),delete a[r],Object.keys(a).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new gd(new Float32Array(2),new Float32Array(2),1,FN),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,s=typeof e==="string"?mo.findByName(i,e):e,a=s!==null?s.uuid:e,o=this._actionsByClip[a],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(o!==void 0){let u=o.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=o.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new Om(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,a,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?mo.findByName(n,e):e,s=r?r.uuid:e,a=this._actionsByClip[s];if(a!==void 0)return a.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let a=this._bindings,o=this._nActiveBindings;for(let c=0;c!==o;++c)a[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let a=0,o=s.length;a!==o;++a){let c=s[a];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let a=n[s].actionByRoot,o=a[t];if(o!==void 0)this._deactivateAction(o),this._removeInactiveAction(o)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let a=r[s];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}};km=class km{static{km.prototype.isMatrix2=!0}constructor(e,t,n,i){if(this.elements=[1,0,0,1],e!==void 0)this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}};Td=class Td extends Bi{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}};if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)je("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186"});function nA(){let e=null,t=!1,n=null,i=null;function r(s,a){i=e.requestAnimationFrame(r),n(s,a)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(r),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(s){n=s},setContext:function(s){e=s}}}function BN(e){let t=new WeakMap;function n(o,c){let{array:l,usage:u}=o,d=l.byteLength,f=e.createBuffer();e.bindBuffer(c,f),e.bufferData(c,l,u),o.onUploadCallback();let h;if(l instanceof Float32Array)h=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)h=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(o.isFloat16BufferAttribute)h=e.HALF_FLOAT;else h=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)h=e.SHORT;else if(l instanceof Uint32Array)h=e.UNSIGNED_INT;else if(l instanceof Int32Array)h=e.INT;else if(l instanceof Int8Array)h=e.BYTE;else if(l instanceof Uint8Array)h=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)h=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:f,type:h,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,c,l){let{array:u,updateRanges:d}=c;if(e.bindBuffer(l,o),d.length===0)e.bufferSubData(l,0,u);else{d.sort((h,y)=>h.start-y.start);let f=0;for(let h=1;h<d.length;h++){let y=d[f],g=d[h];if(g.start<=y.start+y.count+1)y.count=Math.max(y.count,g.start+g.count-y.start);else++f,d[f]=g}d.length=f+1;for(let h=0,y=d.length;h<y;h++){let g=d[h];e.bufferSubData(l,g.start*u.BYTES_PER_ELEMENT,u,g.start,g.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(o){if(o.isInterleavedBufferAttribute)o=o.data;return t.get(o)}function s(o){if(o.isInterleavedBufferAttribute)o=o.data;let c=t.get(o);if(c)e.deleteBuffer(c.buffer),t.delete(o)}function a(o,c){if(o.isInterleavedBufferAttribute)o=o.data;if(o.isGLBufferAttribute){let u=t.get(o);if(!u||u.version<o.version)t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let l=t.get(o);if(l===void 0)t.set(o,n(o,c));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,o,c),l.version=o.version}}return{get:r,remove:s,update:a}}function vk(e,t,n,i,r,s){let a=new qe(0),o=r===!0?0:1,c,l,u=null,d=0,f=null;function h(b){let _=b.isScene===!0?b.background:null;if(_&&_.isTexture){let x=b.backgroundBlurriness>0;_=t.get(_,x)}return _}function y(b){let _=!1,x=h(b);if(x===null)m(a,o);else if(x&&x.isColor)m(x,1),_=!0;let v=e.xr.getEnvironmentBlendMode();if(v==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(v==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||_)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function g(b,_){let x=h(_);if(x&&(x.isCubeTexture||x.mapping===Fc)){if(l===void 0)l=new jt(new ms(1,1,1),new _i({name:"BackgroundCubeMaterial",uniforms:va(mr.backgroundCube.uniforms),vertexShader:mr.backgroundCube.vertexShader,fragmentShader:mr.backgroundCube.fragmentShader,side:Pn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(v,E,S){this.matrixWorld.copyPosition(S.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=x,l.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(_k.makeRotationFromEuler(_.backgroundRotation)).transpose(),x.isCubeTexture&&x.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(iA);if(l.material.toneMapped=ot.getTransfer(x.colorSpace)!==Bt,u!==x||d!==x.version||f!==e.toneMapping)l.material.needsUpdate=!0,u=x,d=x.version,f=e.toneMapping;l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null)}else if(x&&x.isTexture){if(c===void 0)c=new jt(new Jc(2,2),new _i({name:"BackgroundMaterial",uniforms:va(mr.background.uniforms),vertexShader:mr.background.vertexShader,fragmentShader:mr.background.fragmentShader,side:us,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=x,c.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,c.material.toneMapped=ot.getTransfer(x.colorSpace)!==Bt,x.matrixAutoUpdate===!0)x.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(x.matrix),u!==x||d!==x.version||f!==e.toneMapping)c.material.needsUpdate=!0,u=x,d=x.version,f=e.toneMapping;c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)}}function m(b,_){b.getRGB(Ad,xm(e)),n.buffers.color.setClear(Ad.r,Ad.g,Ad.b,_,s)}function p(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return a},setClearColor:function(b,_=1){a.set(b),o=_,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:y,addToRenderList:g,dispose:p}}function Ek(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=f(null),s=r,a=!1;function o(w,I,F,N,U){let D=!1,O=d(w,N,F,I);if(s!==O)s=O,l(s.object);if(D=h(w,N,F,U),D)y(w,N,F,U);if(U!==null)t.update(U,e.ELEMENT_ARRAY_BUFFER);if(D||a){if(a=!1,x(w,I,F,N),U!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(U).buffer)}}function c(){return e.createVertexArray()}function l(w){return e.bindVertexArray(w)}function u(w){return e.deleteVertexArray(w)}function d(w,I,F,N){let U=N.wireframe===!0,D=i[I.id];if(D===void 0)D={},i[I.id]=D;let O=w.isInstancedMesh===!0?w.id:0,K=D[O];if(K===void 0)K={},D[O]=K;let B=K[F.id];if(B===void 0)B={},K[F.id]=B;let X=B[U];if(X===void 0)X=f(c()),B[U]=X;return X}function f(w){let I=[],F=[],N=[];for(let U=0;U<n;U++)I[U]=0,F[U]=0,N[U]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:F,attributeDivisors:N,object:w,attributes:{},index:null}}function h(w,I,F,N){let U=s.attributes,D=I.attributes,O=0,K=F.getAttributes();for(let B in K)if(K[B].location>=0){let q=U[B],le=D[B];if(le===void 0){if(B==="instanceMatrix"&&w.instanceMatrix)le=w.instanceMatrix;if(B==="instanceColor"&&w.instanceColor)le=w.instanceColor}if(q===void 0)return!0;if(q.attribute!==le)return!0;if(le&&q.data!==le.data)return!0;O++}if(s.attributesNum!==O)return!0;if(s.index!==N)return!0;return!1}function y(w,I,F,N){let U={},D=I.attributes,O=0,K=F.getAttributes();for(let B in K)if(K[B].location>=0){let q=D[B];if(q===void 0){if(B==="instanceMatrix"&&w.instanceMatrix)q=w.instanceMatrix;if(B==="instanceColor"&&w.instanceColor)q=w.instanceColor}let le={};if(le.attribute=q,q&&q.data)le.data=q.data;U[B]=le,O++}s.attributes=U,s.attributesNum=O,s.index=N}function g(){let w=s.newAttributes;for(let I=0,F=w.length;I<F;I++)w[I]=0}function m(w){p(w,0)}function p(w,I){let F=s.newAttributes,N=s.enabledAttributes,U=s.attributeDivisors;if(F[w]=1,N[w]===0)e.enableVertexAttribArray(w),N[w]=1;if(U[w]!==I)e.vertexAttribDivisor(w,I),U[w]=I}function b(){let w=s.newAttributes,I=s.enabledAttributes;for(let F=0,N=I.length;F<N;F++)if(I[F]!==w[F])e.disableVertexAttribArray(F),I[F]=0}function _(w,I,F,N,U,D,O){if(O===!0)e.vertexAttribIPointer(w,I,F,U,D);else e.vertexAttribPointer(w,I,F,N,U,D)}function x(w,I,F,N){g();let U=N.attributes,D=F.getAttributes(),O=I.defaultAttributeValues;for(let K in D){let B=D[K];if(B.location>=0){let X=U[K];if(X===void 0){if(K==="instanceMatrix"&&w.instanceMatrix)X=w.instanceMatrix;if(K==="instanceColor"&&w.instanceColor)X=w.instanceColor}if(X!==void 0){let q=X.normalized,le=X.itemSize,de=t.get(X);if(de===void 0)continue;let{buffer:Me,type:pe,bytesPerElement:J}=de,L=pe===e.INT||pe===e.UNSIGNED_INT||X.gpuType===wp;if(X.isInterleavedBufferAttribute){let W=X.data,te=W.stride,ie=X.offset;if(W.isInstancedInterleavedBuffer){for(let ce=0;ce<B.locationSize;ce++)p(B.location+ce,W.meshPerAttribute);if(w.isInstancedMesh!==!0&&N._maxInstanceCount===void 0)N._maxInstanceCount=W.meshPerAttribute*W.count}else for(let ce=0;ce<B.locationSize;ce++)m(B.location+ce);e.bindBuffer(e.ARRAY_BUFFER,Me);for(let ce=0;ce<B.locationSize;ce++)_(B.location+ce,le/B.locationSize,pe,q,te*J,(ie+le/B.locationSize*ce)*J,L)}else{if(X.isInstancedBufferAttribute){for(let W=0;W<B.locationSize;W++)p(B.location+W,X.meshPerAttribute);if(w.isInstancedMesh!==!0&&N._maxInstanceCount===void 0)N._maxInstanceCount=X.meshPerAttribute*X.count}else for(let W=0;W<B.locationSize;W++)m(B.location+W);e.bindBuffer(e.ARRAY_BUFFER,Me);for(let W=0;W<B.locationSize;W++)_(B.location+W,le/B.locationSize,pe,q,le*J,le/B.locationSize*W*J,L)}}else if(O!==void 0){let q=O[K];if(q!==void 0)switch(q.length){case 2:e.vertexAttrib2fv(B.location,q);break;case 3:e.vertexAttrib3fv(B.location,q);break;case 4:e.vertexAttrib4fv(B.location,q);break;default:e.vertexAttrib1fv(B.location,q)}}}}b()}function v(){A();for(let w in i){let I=i[w];for(let F in I){let N=I[F];for(let U in N){let D=N[U];for(let O in D)u(D[O].object),delete D[O];delete N[U]}}delete i[w]}}function E(w){if(i[w.id]===void 0)return;let I=i[w.id];for(let F in I){let N=I[F];for(let U in N){let D=N[U];for(let O in D)u(D[O].object),delete D[O];delete N[U]}}delete i[w.id]}function S(w){for(let I in i){let F=i[I];for(let N in F){let U=F[N];if(U[w.id]===void 0)continue;let D=U[w.id];for(let O in D)u(D[O].object),delete D[O];delete U[w.id]}}}function T(w){for(let I in i){let F=i[I],N=w.isInstancedMesh===!0?w.id:0,U=F[N];if(U===void 0)continue;for(let D in U){let O=U[D];for(let K in O)u(O[K].object),delete O[K];delete U[D]}if(delete F[N],Object.keys(F).length===0)delete i[I]}}function A(){if(P(),a=!0,s===r)return;s=r,l(s.object)}function P(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:A,resetDefaultState:P,dispose:v,releaseStatesOfGeometry:E,releaseStatesOfObject:T,releaseStatesOfProgram:S,initAttributes:g,enableAttribute:m,disableUnusedAttributes:b}}function Tk(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function a(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function o(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let f=0;for(let h=0;h<u;h++)f+=l[h];n.update(f,i,1)}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o}function Ak(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let S=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(S.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(S){if(S!==fr&&i.convert(S)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function o(S){let T=S===dr&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(S!==Ui&&S!==Fr&&!T&&i.convert(S)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(S){if(S==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";S="mediump"}if(S==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)je("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let d=n.logarithmicDepthBuffer===!0,f=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&f===!1)je("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),y=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),g=e.getParameter(e.MAX_TEXTURE_SIZE),m=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),p=e.getParameter(e.MAX_VERTEX_ATTRIBS),b=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),_=e.getParameter(e.MAX_VARYING_VECTORS),x=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),v=e.getParameter(e.MAX_SAMPLES),E=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:f,maxTextures:h,maxVertexTextures:y,maxTextureSize:g,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:b,maxVaryings:_,maxFragmentUniforms:x,maxSamples:v,samples:E}}function Sk(e){let t=this,n=null,i=0,r=!1,s=!1,a=new bi,o=new tt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,f){let h=d.length!==0||f||i!==0||r;return r=f,i=d.length,h},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,f){n=u(d,f,0)},this.setState=function(d,f,h){let{clippingPlanes:y,clipIntersection:g,clipShadows:m}=d,p=e.get(d);if(!r||y===null||y.length===0||s&&!m)if(s)u(null);else l();else{let b=s?0:i,_=b*4,x=p.clippingState||null;c.value=x,x=u(y,f,_,h);for(let v=0;v!==_;++v)x[v]=n[v];p.clippingState=x,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=b}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(d,f,h,y){let g=d!==null?d.length:0,m=null;if(g!==0){if(m=c.value,y!==!0||m===null){let p=h+g*4,b=f.matrixWorldInverse;if(o.getNormalMatrix(b),m===null||m.length<p)m=new Float32Array(p);for(let _=0,x=h;_!==g;++_,x+=4)a.copy(d[_]).applyMatrix4(b,o),a.normal.toArray(m,x),m[x+3]=a.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=g,t.numIntersection=0,m}}class sl{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=0.1,i=100,r={}){let{size:s=256,position:a=Ik}=r;Fm=this._renderer.getRenderTarget(),Um=this._renderer.getActiveCubeFace(),Bm=this._renderer.getActiveMipmapLevel(),zm=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let o=this._allocateTargets();if(o.depthBuffer=!0,this._sceneToCubeUV(e,n,i,o,a),t>0)this._blur(o,0,0,t);return this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=UT(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=FT(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Fm,Um,Bm),this._renderer.xr.enabled=zm,e.scissorTest=!1,Po(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===yo||e.mapping===pa)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Fm=this._renderer.getRenderTarget(),Um=this._renderer.getActiveCubeFace(),Bm=this._renderer.getActiveMipmapLevel(),zm=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:En,minFilter:En,generateMipmaps:!1,type:dr,format:fr,colorSpace:si,depthBuffer:!1},i=LT(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=LT(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=Ck(r)),this._blurMaterial=Pk(r,e,t),this._ggxMaterial=Nk(r,e,t)}return i}_compileMaterial(e){let t=new jt(new On,e);this._renderer.compile(t,tl)}_sceneToCubeUV(e,t,n,i,r){let o=new fn(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:d,toneMapping:f}=u;if(u.getClearColor(DT),u.toneMapping=Li,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new jt(new ms,new hr({name:"PMREM.Background",side:Pn,depthWrite:!1,depthTest:!1}));let y=this._backgroundBox,g=y.material,m=!1,p=e.background;if(p){if(p.isColor)g.color.copy(p),e.background=null,m=!0}else g.color.copy(DT),m=!0;for(let b=0;b<6;b++){let _=b%3;if(_===0)o.up.set(0,c[b],0),o.position.set(r.x,r.y,r.z),o.lookAt(r.x+l[b],r.y,r.z);else if(_===1)o.up.set(0,0,c[b]),o.position.set(r.x,r.y,r.z),o.lookAt(r.x,r.y+l[b],r.z);else o.up.set(0,c[b],0),o.position.set(r.x,r.y,r.z),o.lookAt(r.x,r.y,r.z+l[b]);let x=this._cubeSize;if(Po(i,_*x,b>2?x:0,x,x),u.setRenderTarget(i),m)u.render(y,o);u.render(e,o)}u.toneMapping=f,u.autoClear=d,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===yo||e.mapping===pa;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=UT();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=FT();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let a=r.uniforms;a.envMap.value=e;let o=this._cubeSize;Po(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(s,tl)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,a=this._lodMeshes[n];a.material=s;let o=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),d=c*1.25,f=u*d,{_lodMax:h}=this,y=this._sizeLods[n],g=3*y*(n>h-Oo?n-h+Oo:0),m=4*(this._cubeSize-y);o.envMap.value=e.texture,o.roughness.value=f,o.mipInt.value=h-t,Po(r,g,m,3*y,2*y),i.setRenderTarget(r),i.render(a,tl),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=h-n,Po(e,g,m,3*y,2*y),i.setRenderTarget(e),i.render(a,tl)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,a=this._blurMaterial,o=this._lodMeshes[i];o.material=a;let c=a.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-Oo?i-this._lodMax+Oo:0),d=4*(this._cubeSize-l);Po(t,u,d,3*l,2*l),s.setRenderTarget(t),s.render(o,tl)}}function Ck(e){let t=[],n=[],i=e,r=e-Oo+1+wk;for(let s=0;s<r;s++){let a=Math.pow(2,i);t.push(a);let o=1/(a-2),c=-o,l=1+o,u=[c,c,l,c,l,l,c,c,l,l,c,l],d=6,f=6,h=3,y=new Float32Array(h*f*d),g=new Float32Array(h*f*d);for(let p=0;p<d;p++){let b=p%3*2/3-1,_=p>2?0:-1,x=[b,_,0,b+0.6666666666666666,_,0,b+0.6666666666666666,_+1,0,b,_,0,b+0.6666666666666666,_+1,0,b,_+1,0];y.set(x,h*f*p);for(let v=0;v<f;v++){let E=u[v*2]*2-1,S=u[v*2+1]*2-1;if(p===0)Aa.set(1,S,E);else if(p===1)Aa.set(-E,1,-S);else if(p===2)Aa.set(-E,S,1);else if(p===3)Aa.set(-1,S,-E);else if(p===4)Aa.set(-E,-1,S);else Aa.set(E,S,-1);Aa.toArray(g,(p*f+v)*h)}}let m=new On;if(m.setAttribute("position",new vn(y,h)),m.setAttribute("outputDirection",new vn(g,h)),n.push(new jt(m,null)),i>Oo)i--}return{lodMeshes:n,sizeLods:t}}function LT(e,t,n){let i=new ai(e,t,n);return i.texture.mapping=Fc,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Po(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function Nk(e,t,n){return new _i({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Rk,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:wd(),fragmentShader:`+}`,Ei,Dm,zr,ui,Pd,Lm,Fm,Um,Od,Bm,zm,xs,kd,ys,Vm,_s,vs,Ma,lr,XT,Fr,qT,ul,bo,jm,Lo,Fo,Dd,Mp,HE,GE,sd,ad,or,Ld,os,$E,KE,fn,JT,Fd,ZT,Uo,Ra,YT,Bo,Rp,Ud,xo=-90,yo=1,Hm,Gm,Km="\\[\\]\\.:\\/",cP,Wm,lP,uP,dP,fP,hP,pP,mP,gP,Bd,qm,zd;var Zm=mt(()=>{us={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ds={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3};uE={};GT={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};Pn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Hc=Math.PI/180,xa=180/Math.PI;Yc={DEG2RAD:Hc,RAD2DEG:xa,generateUUID:Fi,clamp:ct,euclideanModulo:Im,mapLinear:gN,inverseLerp:bN,lerp:Gc,damp:xN,pingpong:yN,smoothstep:_N,smootherstep:vN,randInt:EN,randFloat:TN,randFloatSpread:AN,seededRandom:wN,degToRad:SN,radToDeg:MN,isPowerOfTwo:RN,ceilPowerOfTwo:IN,floorPowerOfTwo:CN,setQuaternionFromProperEuler:NN,normalize:Nt,denormalize:Li};Ke=class Ke{static{Ke.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ct(this.x,e.x,t.x),this.y=ct(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ct(this.x,e,t),this.y=ct(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ct(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(ct(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};ln=class ln{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,a){let o=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],d=r[s+0],f=r[s+1],h=r[s+2],b=r[s+3];if(u!==b||o!==d||c!==f||l!==h){let m=o*d+c*f+l*h+u*b;if(m<0)d=-d,f=-f,h=-h,b=-b,m=-m;let g=1-a;if(m<0.9995){let p=Math.acos(m),x=Math.sin(p);g=Math.sin(g*p)/x,a=Math.sin(a*p)/x,o=o*g+d*a,c=c*g+f*a,l=l*g+h*a,u=u*g+b*a}else{o=o*g+d*a,c=c*g+f*a,l=l*g+h*a,u=u*g+b*a;let p=1/Math.sqrt(o*o+c*c+l*l+u*u);o*=p,c*=p,l*=p,u*=p}}e[t]=o,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let a=n[i],o=n[i+1],c=n[i+2],l=n[i+3],u=r[s],d=r[s+1],f=r[s+2],h=r[s+3];return e[t]=a*h+l*u+o*f-c*d,e[t+1]=o*h+l*d+c*u-a*f,e[t+2]=c*h+l*f+a*d-o*u,e[t+3]=l*h-a*u-o*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:a,sin:o}=Math,c=a(n/2),l=a(i/2),u=a(r/2),d=o(n/2),f=o(i/2),h=o(r/2);switch(s){case"XYZ":this._x=d*l*u+c*f*h,this._y=c*f*u-d*l*h,this._z=c*l*h+d*f*u,this._w=c*l*u-d*f*h;break;case"YXZ":this._x=d*l*u+c*f*h,this._y=c*f*u-d*l*h,this._z=c*l*h-d*f*u,this._w=c*l*u+d*f*h;break;case"ZXY":this._x=d*l*u-c*f*h,this._y=c*f*u+d*l*h,this._z=c*l*h+d*f*u,this._w=c*l*u-d*f*h;break;case"ZYX":this._x=d*l*u-c*f*h,this._y=c*f*u+d*l*h,this._z=c*l*h-d*f*u,this._w=c*l*u+d*f*h;break;case"YZX":this._x=d*l*u+c*f*h,this._y=c*f*u+d*l*h,this._z=c*l*h-d*f*u,this._w=c*l*u-d*f*h;break;case"XZY":this._x=d*l*u-c*f*h,this._y=c*f*u-d*l*h,this._z=c*l*h+d*f*u,this._w=c*l*u+d*f*h;break;default:je("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],a=t[5],o=t[9],c=t[2],l=t[6],u=t[10],d=n+a+u;if(d>0){let f=0.5/Math.sqrt(d+1);this._w=0.25/f,this._x=(l-o)*f,this._y=(r-c)*f,this._z=(s-i)*f}else if(n>a&&n>u){let f=2*Math.sqrt(1+n-a-u);this._w=(l-o)/f,this._x=0.25*f,this._y=(i+s)/f,this._z=(r+c)/f}else if(a>u){let f=2*Math.sqrt(1+a-n-u);this._w=(r-c)/f,this._x=(i+s)/f,this._y=0.25*f,this._z=(o+l)/f}else{let f=2*Math.sqrt(1+u-n-a);this._w=(s-i)/f,this._x=(r+c)/f,this._y=(o+l)/f,this._z=0.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ct(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:a,_y:o,_z:c,_w:l}=t;return this._x=n*l+s*a+i*c-r*o,this._y=i*l+s*o+r*a-n*c,this._z=r*l+s*c+n*o-i*a,this._w=s*l-n*a-i*o-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,a=this.dot(e);if(a<0)n=-n,i=-i,r=-r,s=-s,a=-a;let o=1-t;if(a<0.9995){let c=Math.acos(a),l=Math.sin(c);o=Math.sin(o*c)/l,t=Math.sin(t*c)/l,this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+s*t,this._onChangeCallback()}else this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}};j=class j{static{j.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(fE.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(fE.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:a,w:o}=e,c=2*(s*i-a*n),l=2*(a*t-r*i),u=2*(r*n-s*t);return this.x=t+o*c+s*u-a*l,this.y=n+o*l+a*c-r*u,this.z=i+o*u+r*l-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ct(this.x,e.x,t.x),this.y=ct(this.y,e.y,t.y),this.z=ct(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ct(this.x,e,t),this.y=ct(this.y,e,t),this.z=ct(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ct(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:a,z:o}=t;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return sp.copy(this).projectOnVector(e),this.sub(sp)}reflect(e){return this.sub(sp.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(ct(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};sp=new j,fE=new ln;tt=class tt{static{tt.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,a,o,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,a,o,c)}set(e,t,n,i,r,s,a,o,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=a,l[3]=t,l[4]=r,l[5]=o,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[3],o=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],h=n[8],b=i[0],m=i[3],g=i[6],p=i[1],x=i[4],_=i[7],y=i[2],v=i[5],T=i[8];return r[0]=s*b+a*p+o*y,r[3]=s*m+a*x+o*v,r[6]=s*g+a*_+o*T,r[1]=c*b+l*p+u*y,r[4]=c*m+l*x+u*v,r[7]=c*g+l*_+u*T,r[2]=d*b+f*p+h*y,r[5]=d*m+f*x+h*v,r[8]=d*g+f*_+h*T,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],c=e[7],l=e[8];return t*s*l-t*a*c-n*r*l+n*a*o+i*r*c-i*s*o}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],c=e[7],l=e[8],u=l*s-a*c,d=a*o-l*r,f=c*r-s*o,h=t*u+n*d+i*f;if(h===0)return this.set(0,0,0,0,0,0,0,0,0);let b=1/h;return e[0]=u*b,e[1]=(i*c-l*n)*b,e[2]=(a*n-i*s)*b,e[3]=d*b,e[4]=(l*t-i*o)*b,e[5]=(i*r-a*t)*b,e[6]=f*b,e[7]=(n*o-c*t)*b,e[8]=(s*t-n*r)*b,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,a){let o=Math.cos(r),c=Math.sin(r);return this.set(n*o,n*c,-n*(o*s+c*a)+s+e,-i*c,i*o,-i*(-c*s+o*a)+a+t,0,0,1),this}scale(e,t){return ba("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(ap.makeScale(e,t)),this}rotate(e){return ba("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(ap.makeRotation(-e)),this}translate(e,t){return ba("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(ap.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};ap=new tt,hE=new tt().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),pE=new tt().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);ot=PN();cp=new j;en=class en extends Vi{constructor(e=en.DEFAULT_IMAGE,t=en.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,a=1023,o=1009,c=en.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:kN++}),this.uuid=Fi(),this.name="",this.source=new Qc(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=o,this.offset=new Ke(0,0),this.repeat=new Ke(1,1),this.center=new Ke(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new tt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(cp).x}get height(){return this.source.getSize(cp).y}get depth(){return this.source.getSize(cp).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){je(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){je(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}};en.DEFAULT_IMAGE=null;en.DEFAULT_MAPPING=300;en.DEFAULT_ANISOTROPY=1;Pt=class Pt{static{Pt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,a=0.1,o=e.elements,c=o[0],l=o[4],u=o[8],d=o[1],f=o[5],h=o[9],b=o[2],m=o[6],g=o[10];if(Math.abs(l-d)<0.01&&Math.abs(u-b)<0.01&&Math.abs(h-m)<0.01){if(Math.abs(l+d)<0.1&&Math.abs(u+b)<0.1&&Math.abs(h+m)<0.1&&Math.abs(c+f+g-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let x=(c+1)/2,_=(f+1)/2,y=(g+1)/2,v=(l+d)/4,T=(u+b)/4,A=(h+m)/4;if(x>_&&x>y)if(x<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(x),i=v/n,r=T/n;else if(_>y)if(_<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(_),n=v/i,r=A/i;else if(y<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(y),n=T/r,i=A/r;return this.set(n,i,r,t),this}let p=Math.sqrt((m-h)*(m-h)+(u-b)*(u-b)+(d-l)*(d-l));if(Math.abs(p)<0.001)p=1;return this.x=(m-h)/p,this.y=(u-b)/p,this.z=(d-l)/p,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ct(this.x,e.x,t.x),this.y=ct(this.y,e.y,t.y),this.z=ct(this.z,e.z,t.z),this.w=ct(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ct(this.x,e,t),this.y=ct(this.y,e,t),this.z=ct(this.z,e,t),this.w=ct(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ct(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};Nm=class Nm extends Vi{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Pt(0,0,e,t),this.scissorTest=!1,this.viewport=new Pt(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new en(i),s=n.count;for(let a=0;a<s;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new Qc(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}};ci=class ci extends Nm{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}};Td=class Td extends en{constructor(e=null,t=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};Pm=class Pm extends en{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}};Qe=class Qe{static{Qe.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,a,o,c,l,u,d,f,h,b,m){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,a,o,c,l,u,d,f,h,b,m)}set(e,t,n,i,r,s,a,o,c,l,u,d,f,h,b,m){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=h,g[11]=b,g[15]=m,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 Qe().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/ao.setFromMatrixColumn(e,0).length(),r=1/ao.setFromMatrixColumn(e,1).length(),s=1/ao.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let d=s*l,f=s*u,h=a*l,b=a*u;t[0]=o*l,t[4]=-o*u,t[8]=c,t[1]=f+h*c,t[5]=d-b*c,t[9]=-a*o,t[2]=b-d*c,t[6]=h+f*c,t[10]=s*o}else if(e.order==="YXZ"){let d=o*l,f=o*u,h=c*l,b=c*u;t[0]=d+b*a,t[4]=h*a-f,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-a,t[2]=f*a-h,t[6]=b+d*a,t[10]=s*o}else if(e.order==="ZXY"){let d=o*l,f=o*u,h=c*l,b=c*u;t[0]=d-b*a,t[4]=-s*u,t[8]=h+f*a,t[1]=f+h*a,t[5]=s*l,t[9]=b-d*a,t[2]=-s*c,t[6]=a,t[10]=s*o}else if(e.order==="ZYX"){let d=s*l,f=s*u,h=a*l,b=a*u;t[0]=o*l,t[4]=h*c-f,t[8]=d*c+b,t[1]=o*u,t[5]=b*c+d,t[9]=f*c-h,t[2]=-c,t[6]=a*o,t[10]=s*o}else if(e.order==="YZX"){let d=s*o,f=s*c,h=a*o,b=a*c;t[0]=o*l,t[4]=b-d*u,t[8]=h*u+f,t[1]=u,t[5]=s*l,t[9]=-a*l,t[2]=-c*l,t[6]=f*u+h,t[10]=d-b*u}else if(e.order==="XZY"){let d=s*o,f=s*c,h=a*o,b=a*c;t[0]=o*l,t[4]=-u,t[8]=c*l,t[1]=d*u+b,t[5]=s*l,t[9]=f*u-h,t[2]=h*u-f,t[6]=a*l,t[10]=b*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(DN,e,LN)}lookAt(e,t,n){let i=this.elements;if(si.subVectors(e,t),si.lengthSq()===0)si.z=1;if(si.normalize(),is.crossVectors(n,si),is.lengthSq()===0){if(Math.abs(n.z)===1)si.x+=0.0001;else si.z+=0.0001;si.normalize(),is.crossVectors(n,si)}return is.normalize(),Lu.crossVectors(si,is),i[0]=is.x,i[4]=Lu.x,i[8]=si.x,i[1]=is.y,i[5]=Lu.y,i[9]=si.y,i[2]=is.z,i[6]=Lu.z,i[10]=si.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[4],o=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],h=n[2],b=n[6],m=n[10],g=n[14],p=n[3],x=n[7],_=n[11],y=n[15],v=i[0],T=i[4],A=i[8],E=i[12],w=i[1],P=i[5],S=i[9],I=i[13],U=i[2],N=i[6],F=i[10],D=i[14],O=i[3],K=i[7],B=i[11],X=i[15];return r[0]=s*v+a*w+o*U+c*O,r[4]=s*T+a*P+o*N+c*K,r[8]=s*A+a*S+o*F+c*B,r[12]=s*E+a*I+o*D+c*X,r[1]=l*v+u*w+d*U+f*O,r[5]=l*T+u*P+d*N+f*K,r[9]=l*A+u*S+d*F+f*B,r[13]=l*E+u*I+d*D+f*X,r[2]=h*v+b*w+m*U+g*O,r[6]=h*T+b*P+m*N+g*K,r[10]=h*A+b*S+m*F+g*B,r[14]=h*E+b*I+m*D+g*X,r[3]=p*v+x*w+_*U+y*O,r[7]=p*T+x*P+_*N+y*K,r[11]=p*A+x*S+_*F+y*B,r[15]=p*E+x*I+_*D+y*X,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],a=e[5],o=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],h=e[3],b=e[7],m=e[11],g=e[15],p=o*f-c*d,x=a*f-c*u,_=a*d-o*u,y=s*f-c*l,v=s*d-o*l,T=s*u-a*l;return t*(b*p-m*x+g*_)-n*(h*p-m*y+g*v)+i*(h*x-b*y+g*T)-r*(h*_-b*v+m*T)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],a=e[9],o=e[2],c=e[6],l=e[10];return t*(s*l-a*c)-n*(r*l-a*o)+i*(r*c-s*o)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],h=e[12],b=e[13],m=e[14],g=e[15],p=t*a-n*s,x=t*o-i*s,_=t*c-r*s,y=n*o-i*a,v=n*c-r*a,T=i*c-r*o,A=l*b-u*h,E=l*m-d*h,w=l*g-f*h,P=u*m-d*b,S=u*g-f*b,I=d*g-f*m,U=p*I-x*S+_*P+y*w-v*E+T*A;if(U===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let N=1/U;return e[0]=(a*I-o*S+c*P)*N,e[1]=(i*S-n*I-r*P)*N,e[2]=(b*T-m*v+g*y)*N,e[3]=(d*v-u*T-f*y)*N,e[4]=(o*w-s*I-c*E)*N,e[5]=(t*I-i*w+r*E)*N,e[6]=(m*_-h*T-g*x)*N,e[7]=(l*T-d*_+f*x)*N,e[8]=(s*S-a*w+c*A)*N,e[9]=(n*w-t*S-r*A)*N,e[10]=(h*v-b*_+g*p)*N,e[11]=(u*_-l*v-f*p)*N,e[12]=(a*E-s*P-o*A)*N,e[13]=(t*P-n*E+i*A)*N,e[14]=(b*x-h*y-m*p)*N,e[15]=(l*y-u*x+d*p)*N,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:a,z:o}=e,c=r*s,l=r*a;return this.set(c*s+n,c*a-i*o,c*o+i*a,0,c*a+i*o,l*a+n,l*o-i*s,0,c*o-i*a,l*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:a,_w:o}=t,c=r+r,l=s+s,u=a+a,d=r*c,f=r*l,h=r*u,b=s*l,m=s*u,g=a*u,p=o*c,x=o*l,_=o*u,{x:y,y:v,z:T}=n;return i[0]=(1-(b+g))*y,i[1]=(f+_)*y,i[2]=(h-x)*y,i[3]=0,i[4]=(f-_)*v,i[5]=(1-(d+g))*v,i[6]=(m+p)*v,i[7]=0,i[8]=(h+x)*T,i[9]=(m-p)*T,i[10]=(1-(d+b))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=ao.set(i[0],i[1],i[2]).length(),a=ao.set(i[4],i[5],i[6]).length(),o=ao.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Oi.copy(this);let c=1/s,l=1/a,u=1/o;return Oi.elements[0]*=c,Oi.elements[1]*=c,Oi.elements[2]*=c,Oi.elements[4]*=l,Oi.elements[5]*=l,Oi.elements[6]*=l,Oi.elements[8]*=u,Oi.elements[9]*=u,Oi.elements[10]*=u,t.setFromRotationMatrix(Oi),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,r,s,a=2000,o=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),d=(t+e)/(t-e),f=(n+i)/(n-i),h,b;if(o)h=r/(s-r),b=s*r/(s-r);else if(a===2000)h=-(s+r)/(s-r),b=-2*s*r/(s-r);else if(a===2001)h=-s/(s-r),b=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=h,c[14]=b,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,a=2000,o=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),d=-(t+e)/(t-e),f=-(n+i)/(n-i),h,b;if(o)h=1/(s-r),b=s/(s-r);else if(a===2000)h=-2/(s-r),b=-(s+r)/(s-r);else if(a===2001)h=-1/(s-r),b=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=h,c[14]=b,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};ao=new j,Oi=new Qe,DN=new j(0,0,0),LN=new j(1,1,1),is=new j,Lu=new j,si=new j,mE=new Qe,gE=new ln;ur=class ur{constructor(e=0,t=0,n=0,i=ur.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],a=i[8],o=i[1],c=i[5],l=i[9],u=i[2],d=i[6],f=i[10];switch(t){case"XYZ":if(this._y=Math.asin(ct(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,f),this._z=Math.atan2(-s,r);else this._x=Math.atan2(d,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-ct(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(a,f),this._z=Math.atan2(o,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(ct(d,-1,1)),Math.abs(d)<0.9999999)this._y=Math.atan2(-u,f),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(o,r);break;case"ZYX":if(this._y=Math.asin(-ct(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(d,f),this._z=Math.atan2(o,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(ct(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(a,f);break;case"XZY":if(this._z=Math.asin(-ct(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(d,c),this._y=Math.atan2(a,r);else this._x=Math.atan2(-l,f),this._y=0;break;default:je("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return mE.makeRotationFromQuaternion(e),this.setFromRotationMatrix(mE,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return gE.setFromEuler(this),this.setFromQuaternion(gE,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ur.DEFAULT_ORDER="XYZ";bE=new j,oo=new ln,Pr=new Qe,Fu=new j,Dc=new j,UN=new j,BN=new ln,xE=new j(1,0,0),yE=new j(0,1,0),_E=new j(0,0,1),vE={type:"added"},zN={type:"removed"},co={type:"childadded",child:null},lp={type:"childremoved",child:null};Dt=class Dt extends Vi{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:FN++}),this.uuid=Fi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Dt.DEFAULT_UP.clone();let e=new j,t=new ur,n=new ln,i=new j(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Qe},normalMatrix:{value:new tt}}),this.matrix=new Qe,this.matrixWorld=new Qe,this.matrixAutoUpdate=Dt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ad,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return oo.setFromAxisAngle(e,t),this.quaternion.multiply(oo),this}rotateOnWorldAxis(e,t){return oo.setFromAxisAngle(e,t),this.quaternion.premultiply(oo),this}rotateX(e){return this.rotateOnAxis(xE,e)}rotateY(e){return this.rotateOnAxis(yE,e)}rotateZ(e){return this.rotateOnAxis(_E,e)}translateOnAxis(e,t){return bE.copy(e).applyQuaternion(this.quaternion),this.position.add(bE.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(xE,e)}translateY(e){return this.translateOnAxis(yE,e)}translateZ(e){return this.translateOnAxis(_E,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Pr.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)Fu.copy(e);else Fu.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Dc.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Pr.lookAt(Dc,Fu,this.up);else Pr.lookAt(Fu,Dc,this.up);if(this.quaternion.setFromRotationMatrix(Pr),i)Pr.extractRotation(i.matrixWorld),oo.setFromRotationMatrix(Pr),this.quaternion.premultiply(oo.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return Ze("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(vE),co.child=e,this.dispatchEvent(co),co.child=null;else Ze("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(zN),lp.child=e,this.dispatchEvent(lp),lp.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),Pr.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Pr.multiply(e.parent.matrixWorld);return e.applyMatrix4(Pr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(vE),co.child=e,this.dispatchEvent(co),co.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Dc,e,UN),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Dc,BN,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((a)=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((a)=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(a,o){if(a[o.uuid]===void 0)a[o.uuid]=o.toJSON(e);return o.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let o=a.shapes;if(Array.isArray(o))for(let c=0,l=o.length;c<l;c++){let u=o[c];r(e.shapes,u)}else r(e.shapes,o)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let o=0,c=this.material.length;o<c;o++)a.push(r(e.materials,this.material[o]));i.material=a}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let o=this.animations[a];i.animations.push(r(e.animations,o))}}if(t){let a=s(e.geometries),o=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),d=s(e.skeletons),f=s(e.animations),h=s(e.nodes);if(a.length>0)n.geometries=a;if(o.length>0)n.materials=o;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(d.length>0)n.skeletons=d;if(f.length>0)n.animations=f;if(h.length>0)n.nodes=h}return n.object=i,n;function s(a){let o=[];for(let c in a){let l=a[c];delete l.metadata,o.push(l)}return o}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}};Dt.DEFAULT_UP=new j(0,1,0);Dt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;cr=class cr extends Dt{constructor(){super();this.isGroup=!0,this.type="Group"}};VN={type:"move"};$T={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},rs={h:0,s:0,l:0},Uu={h:0,s:0,l:0};qe=class qe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ot.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=ot.workingColorSpace){return this.r=e,this.g=t,this.b=n,ot.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=ot.workingColorSpace){if(e=Im(e,1),t=ct(t,0,1),n=ct(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=up(s,r,e+0.3333333333333333),this.g=up(s,r,e),this.b=up(s,r,e-0.3333333333333333)}return ot.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)je("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:je("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else je("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=$T[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else je("Color: Unknown color "+e);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ur(e.r),this.g=Ur(e.g),this.b=Ur(e.b),this}copyLinearToSRGB(e){return this.r=_o(e.r),this.g=_o(e.g),this.b=_o(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return ot.workingToColorSpace(On.copy(this),e),Math.round(ct(On.r*255,0,255))*65536+Math.round(ct(On.g*255,0,255))*256+Math.round(ct(On.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ot.workingColorSpace){ot.workingToColorSpace(On.copy(this),t);let{r:n,g:i,b:r}=On,s=Math.max(n,i,r),a=Math.min(n,i,r),o,c,l=(a+s)/2;if(a===s)o=0,c=0;else{let u=s-a;switch(c=l<=0.5?u/(s+a):u/(2-s-a),s){case n:o=(i-r)/u+(i<r?6:0);break;case i:o=(r-n)/u+2;break;case r:o=(n-i)/u+4;break}o/=6}return e.h=o,e.s=c,e.l=l,e}getRGB(e,t=ot.workingColorSpace){return ot.workingToColorSpace(On.copy(this),t),e.r=On.r,e.g=On.g,e.b=On.b,e}getStyle(e="srgb"){ot.workingToColorSpace(On.copy(this),e);let{r:t,g:n,b:i}=On;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(rs),this.setHSL(rs.h+e,rs.s+t,rs.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(rs),e.getHSL(Uu);let n=Gc(rs.h,Uu.h,t),i=Gc(rs.s,Uu.s,t),r=Gc(rs.l,Uu.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};On=new qe;qe.NAMES=$T;Po=class Po extends Dt{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ur,this.environmentIntensity=1,this.environmentRotation=new ur,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null)this.overrideMaterial=e.overrideMaterial.clone();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}};ki=new j,Or=new j,dp=new j,kr=new j,lo=new j,uo=new j,EE=new j,fp=new j,hp=new j,pp=new j,mp=new Pt,gp=new Pt,bp=new Pt;Dr=[new j,new j,new j,new j,new j,new j,new j,new j],Di=new j,Bu=new hn,fo=new j,ho=new j,po=new j,ss=new j,as=new j,ha=new j,Lc=new j,zu=new j,Vu=new j,pa=new j;cn=new j,ju=new Ke;vn=class vn extends Vi{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:jN++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)ju.fromBufferAttribute(this,t),ju.applyMatrix3(e),this.setXY(t,ju.x,ju.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyMatrix3(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyMatrix4(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyNormalMatrix(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.transformDirection(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=Li(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=Nt(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=Li(t,this.array);return t}setX(e,t){if(this.normalized)t=Nt(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=Li(t,this.array);return t}setY(e,t){if(this.normalized)t=Nt(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=Li(t,this.array);return t}setZ(e,t){if(this.normalized)t=Nt(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=Li(t,this.array);return t}setW(e,t){if(this.normalized)t=Nt(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=Nt(t,this.array),n=Nt(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=Nt(t,this.array),n=Nt(n,this.array),i=Nt(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=Nt(t,this.array),n=Nt(n,this.array),i=Nt(i,this.array),r=Nt(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}};wd=class wd extends vn{constructor(e,t,n){super(new Uint16Array(e),t,n)}};Sd=class Sd extends vn{constructor(e,t,n){super(new Uint32Array(e),t,n)}};Wn=class Wn extends vn{constructor(e,t,n){super(new Float32Array(e),t,n)}};HN=new hn,Fc=new j,yp=new j;xi=new Qe,_p=new Dt,mo=new j,ai=new hn,Uc=new hn,_n=new j;Dn=class Dn extends Vi{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:GN++}),this.uuid=Fi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){if(Array.isArray(e))this.index=new((pN(e))?Sd:wd)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new tt().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return xi.makeRotationFromQuaternion(e),this.applyMatrix4(xi),this}rotateX(e){return xi.makeRotationX(e),this.applyMatrix4(xi),this}rotateY(e){return xi.makeRotationY(e),this.applyMatrix4(xi),this}rotateZ(e){return xi.makeRotationZ(e),this.applyMatrix4(xi),this}translate(e,t,n){return xi.makeTranslation(e,t,n),this.applyMatrix4(xi),this}scale(e,t,n){return xi.makeScale(e,t,n),this.applyMatrix4(xi),this}lookAt(e){return _p.lookAt(e),_p.updateMatrix(),this.applyMatrix4(_p.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(mo).negate(),this.translate(mo.x,mo.y,mo.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new Wn(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)je("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new hn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ze("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new j(-1/0,-1/0,-1/0),new j(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(ai.setFromBufferAttribute(r),this.morphTargetsRelative)_n.addVectors(this.boundingBox.min,ai.min),this.boundingBox.expandByPoint(_n),_n.addVectors(this.boundingBox.max,ai.max),this.boundingBox.expandByPoint(_n);else this.boundingBox.expandByPoint(ai.min),this.boundingBox.expandByPoint(ai.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Ze('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new li;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ze("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new j,1/0);return}if(e){let n=this.boundingSphere.center;if(ai.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let a=t[r];if(Uc.setFromBufferAttribute(a),this.morphTargetsRelative)_n.addVectors(ai.min,Uc.min),ai.expandByPoint(_n),_n.addVectors(ai.max,Uc.max),ai.expandByPoint(_n);else ai.expandByPoint(Uc.min),ai.expandByPoint(Uc.max)}ai.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)_n.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(_n));if(t)for(let r=0,s=t.length;r<s;r++){let a=t[r],o=this.morphTargetsRelative;for(let c=0,l=a.count;c<l;c++){if(_n.fromBufferAttribute(a,c),o)mo.fromBufferAttribute(e,c),_n.add(mo);i=Math.max(i,n.distanceToSquared(_n))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ze('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ze("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new vn(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let a=[],o=[];for(let A=0;A<n.count;A++)a[A]=new j,o[A]=new j;let c=new j,l=new j,u=new j,d=new Ke,f=new Ke,h=new Ke,b=new j,m=new j;function g(A,E,w){c.fromBufferAttribute(n,A),l.fromBufferAttribute(n,E),u.fromBufferAttribute(n,w),d.fromBufferAttribute(r,A),f.fromBufferAttribute(r,E),h.fromBufferAttribute(r,w),l.sub(c),u.sub(c),f.sub(d),h.sub(d);let P=1/(f.x*h.y-h.x*f.y);if(!isFinite(P))return;b.copy(l).multiplyScalar(h.y).addScaledVector(u,-f.y).multiplyScalar(P),m.copy(u).multiplyScalar(f.x).addScaledVector(l,-h.x).multiplyScalar(P),a[A].add(b),a[E].add(b),a[w].add(b),o[A].add(m),o[E].add(m),o[w].add(m)}let p=this.groups;if(p.length===0)p=[{start:0,count:e.count}];for(let A=0,E=p.length;A<E;++A){let w=p[A],{start:P,count:S}=w;for(let I=P,U=P+S;I<U;I+=3)g(e.getX(I+0),e.getX(I+1),e.getX(I+2))}let x=new j,_=new j,y=new j,v=new j;function T(A){y.fromBufferAttribute(i,A),v.copy(y);let E=a[A];x.copy(E),x.sub(y.multiplyScalar(y.dot(E))).normalize(),_.crossVectors(v,E);let P=_.dot(o[A])<0?-1:1;s.setXYZW(A,x.x,x.y,x.z,P)}for(let A=0,E=p.length;A<E;++A){let w=p[A],{start:P,count:S}=w;for(let I=P,U=P+S;I<U;I+=3)T(e.getX(I+0)),T(e.getX(I+1)),T(e.getX(I+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new vn(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);let i=new j,r=new j,s=new j,a=new j,o=new j,c=new j,l=new j,u=new j;if(e)for(let d=0,f=e.count;d<f;d+=3){let h=e.getX(d+0),b=e.getX(d+1),m=e.getX(d+2);i.fromBufferAttribute(t,h),r.fromBufferAttribute(t,b),s.fromBufferAttribute(t,m),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),a.fromBufferAttribute(n,h),o.fromBufferAttribute(n,b),c.fromBufferAttribute(n,m),a.add(l),o.add(l),c.add(l),n.setXYZ(h,a.x,a.y,a.z),n.setXYZ(b,o.x,o.y,o.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),s.fromBufferAttribute(t,d+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(d+0,l.x,l.y,l.z),n.setXYZ(d+1,l.x,l.y,l.z),n.setXYZ(d+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)_n.fromBufferAttribute(e,t),_n.normalize(),e.setXYZ(t,_n.x,_n.y,_n.z)}toNonIndexed(){function e(a,o){let{array:c,itemSize:l,normalized:u}=a,d=new c.constructor(o.length*l),f=0,h=0;for(let b=0,m=o.length;b<m;b++){if(a.isInterleavedBufferAttribute)f=o[b]*a.data.stride+a.offset;else f=o[b]*l;for(let g=0;g<l;g++)d[h++]=c[f++]}return new vn(d,l,u)}if(this.index===null)return je("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new Dn,n=this.index.array,i=this.attributes;for(let a in i){let o=i[a],c=e(o,n);t.setAttribute(a,c)}let r=this.morphAttributes;for(let a in r){let o=[],c=r[a];for(let l=0,u=c.length;l<u;l++){let d=c[l],f=e(d,n);o.push(f)}t.morphAttributes[a]=o}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let a=0,o=s.length;a<o;a++){let c=s[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let o=this.parameters;for(let c in o)if(o[c]!==void 0)e[c]=o[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let o in n){let c=n[o];e.data.attributes[o]=c.toJSON(e.data)}let i={},r=!1;for(let o in this.morphAttributes){let c=this.morphAttributes[o],l=[];for(let u=0,d=c.length;u<d;u++){let f=c[u];l.push(f.toJSON(e.data))}if(l.length>0)i[o]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let a=this.boundingSphere;if(a!==null)e.data.boundingSphere=a.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let d=0,f=u.length;d<f;d++)l.push(u[d].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let a=e.boundingBox;if(a!==null)this.boundingBox=a.clone();let o=e.boundingSphere;if(o!==null)this.boundingSphere=o.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}};Hn=new j;vp=new j,$N=new j,KN=new tt;Xn=class Xn extends Vi{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:WN++}),this.uuid=Fi(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new qe(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){je(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){je(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let a in r){let o=r[a];delete o.metadata,s.push(o)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new qe().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new yi().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Ke().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Ke().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}};Lr=new j,Ep=new j,Hu=new j,Gu=new j;mr=class mr extends Xn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new qe(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 ur,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};TE=new Qe,ma=new ms,$u=new li,AE=new j,Ku=new j,Wu=new j,Xu=new j,Tp=new j,qu=new j,wE=new j,Ju=new j;jt=class jt extends Dt{constructor(e=new Dn,t=new mr){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let a=this.morphTargetInfluences;if(r&&a){qu.set(0,0,0);for(let o=0,c=r.length;o<c;o++){let l=a[o],u=r[o];if(l===0)continue;if(Tp.fromBufferAttribute(u,e),s)qu.addScaledVector(Tp,l);else qu.addScaledVector(Tp.sub(t),l)}t.add(qu)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if($u.copy(n.boundingSphere),$u.applyMatrix4(r),ma.copy(e.ray).recast(e.near),$u.containsPoint(ma.origin)===!1){if(ma.intersectSphere($u,AE)===null)return;if(ma.origin.distanceToSquared(AE)>(e.far-e.near)**2)return}if(TE.copy(r).invert(),ma.copy(e.ray).applyMatrix4(TE),n.boundingBox!==null){if(ma.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,ma)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:d,drawRange:f}=r;if(a!==null)if(Array.isArray(s))for(let h=0,b=d.length;h<b;h++){let m=d[h],g=s[m.materialIndex],p=Math.max(m.start,f.start),x=Math.min(a.count,Math.min(m.start+m.count,f.start+f.count));for(let _=p,y=x;_<y;_+=3){let v=a.getX(_),T=a.getX(_+1),A=a.getX(_+2);if(i=Zu(this,g,e,n,c,l,u,v,T,A),i)i.faceIndex=Math.floor(_/3),i.face.materialIndex=m.materialIndex,t.push(i)}}else{let h=Math.max(0,f.start),b=Math.min(a.count,f.start+f.count);for(let m=h,g=b;m<g;m+=3){let p=a.getX(m),x=a.getX(m+1),_=a.getX(m+2);if(i=Zu(this,s,e,n,c,l,u,p,x,_),i)i.faceIndex=Math.floor(m/3),t.push(i)}}else if(o!==void 0)if(Array.isArray(s))for(let h=0,b=d.length;h<b;h++){let m=d[h],g=s[m.materialIndex],p=Math.max(m.start,f.start),x=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let _=p,y=x;_<y;_+=3){let v=_,T=_+1,A=_+2;if(i=Zu(this,g,e,n,c,l,u,v,T,A),i)i.faceIndex=Math.floor(_/3),i.face.materialIndex=m.materialIndex,t.push(i)}}else{let h=Math.max(0,f.start),b=Math.min(o.count,f.start+f.count);for(let m=h,g=b;m<g;m+=3){let p=m,x=m+1,_=m+2;if(i=Zu(this,s,e,n,c,l,u,p,x,_),i)i.faceIndex=Math.floor(m/3),t.push(i)}}}};Bc=new Pt,SE=new Pt,ME=new Pt,qN=new Pt,RE=new Qe,Yu=new j,Ap=new li,IE=new Qe,wp=new ms;Md=class Md extends jt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Qe,this.bindMatrixInverse=new Qe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new hn;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Yu),this.boundingBox.expandByPoint(Yu)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new li;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Yu),this.boundingSphere.expandByPoint(Yu)}copy(e,t){if(super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Ap.copy(this.boundingSphere),Ap.applyMatrix4(i),e.ray.intersectsSphere(Ap)===!1)return;if(IE.copy(i).invert(),wp.copy(e.ray).applyMatrix4(IE),this.boundingBox!==null){if(wp.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,wp)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new Pt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else je("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(SE.fromBufferAttribute(i.attributes.skinIndex,e),ME.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)Bc.copy(t),t.set(0,0,0,0);else Bc.set(...t,1),t.set(0,0,0);Bc.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=ME.getComponent(r);if(s!==0){let a=SE.getComponent(r);RE.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(qN.copy(Bc).applyMatrix4(RE),s)}}if(t.isVector4)t.w=Bc.w;return t.applyMatrix4(this.bindMatrixInverse)}};nl=class nl extends Dt{constructor(){super();this.isBone=!0,this.type="Bone"}};il=class il extends en{constructor(e=null,t=1,n=1,i,r,s,a,o,c=1003,l=1003,u,d){super(null,s,a,o,c,l,i,r,u,d);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};CE=new Qe,JN=new Qe;ls=class ls extends vn{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};go=new Qe,NE=new Qe,Qu=[],PE=new hn,ZN=new Qe,zc=new jt,Vc=new li;ko=class ko extends jt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new ls(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,ZN)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new hn;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,go),PE.copy(e.boundingBox).applyMatrix4(go),this.boundingBox.union(PE)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new li;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,go),Vc.copy(e.boundingSphere).applyMatrix4(go),this.boundingSphere.union(Vc)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let a=0;a<n.length;a++)n[a]=i[s+a]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(zc.geometry=this.geometry,zc.material=this.material,zc.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Vc.copy(this.boundingSphere),Vc.applyMatrix4(n),e.ray.intersectsSphere(Vc)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,go),NE.multiplyMatrices(n,go),zc.matrixWorld=NE,zc.raycast(e,Qu);for(let s=0,a=Qu.length;s<a;s++){let o=Qu[s];o.instanceId=r,o.object=this,t.push(o)}Qu.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new ls(new Float32Array(this.instanceMatrix.count*3).fill(1),3);return t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;if(this.morphTexture===null)this.morphTexture=new il(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let a=this.geometry.morphTargetsRelative?1:1-s,o=i*e;return r[o]=a,r.set(n,o+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}};ga=new li,YN=new Ke(0.5,0.5),ed=new j;al=class al extends Xn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new qe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}};cd=new j,ld=new j,OE=new Qe,jc=new ms,td=new li,Sp=new j,kE=new j;gs=class gs extends Dt{constructor(e=new Dn,t=new al){super();this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)cd.fromBufferAttribute(t,i-1),ld.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=cd.distanceTo(ld);e.setAttribute("lineDistance",new Wn(n,1))}else je("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(td.copy(n.boundingSphere),td.applyMatrix4(i),td.radius+=r,e.ray.intersectsSphere(td)===!1)return;OE.copy(i).invert(),jc.copy(e.ray).applyMatrix4(OE);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,c=this.isLineSegments?2:1,l=n.index,d=n.attributes.position;if(l!==null){let f=Math.max(0,s.start),h=Math.min(l.count,s.start+s.count);for(let b=f,m=h-1;b<m;b+=c){let g=l.getX(b),p=l.getX(b+1),x=nd(this,e,jc,o,g,p,b);if(x)t.push(x)}if(this.isLineLoop){let b=l.getX(h-1),m=l.getX(f),g=nd(this,e,jc,o,b,m,h-1);if(g)t.push(g)}}else{let f=Math.max(0,s.start),h=Math.min(d.count,s.start+s.count);for(let b=f,m=h-1;b<m;b+=c){let g=nd(this,e,jc,o,b,b+1,b);if(g)t.push(g)}if(this.isLineLoop){let b=nd(this,e,jc,o,h-1,f,h-1);if(b)t.push(b)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};DE=new j,LE=new j;Rd=class Rd extends gs{constructor(e,t){super(e,t);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)DE.fromBufferAttribute(t,i),LE.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+DE.distanceTo(LE);e.setAttribute("lineDistance",new Wn(n,1))}else je("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};Id=class Id extends gs{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}};ol=class ol extends Xn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new qe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}};FE=new Qe,Ip=new ms,id=new li,rd=new j;Do=class Do extends Dt{constructor(e=new Dn,t=new ol){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(id.copy(n.boundingSphere),id.applyMatrix4(i),id.radius+=r,e.ray.intersectsSphere(id)===!1)return;FE.copy(i).invert(),Ip.copy(e.ray).applyMatrix4(FE);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,c=n.index,u=n.attributes.position;if(c!==null){let d=Math.max(0,s.start),f=Math.min(c.count,s.start+s.count);for(let h=d,b=f;h<b;h++){let m=c.getX(h);rd.fromBufferAttribute(u,m),UE(rd,m,o,i,e,t,this)}}else{let d=Math.max(0,s.start),f=Math.min(u.count,s.start+s.count);for(let h=d,b=f;h<b;h++)rd.fromBufferAttribute(u,h),UE(rd,h,o,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};Cd=class Cd extends en{constructor(e=[],t=301,n,i,r,s,a,o,c,l){super(e,t,n,i,r,s,a,o,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};wa=class wa extends en{constructor(e,t,n=1014,i,r,s,a=1003,o=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:u};super(d,i,r,s,a,o,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Qc(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}};Om=class Om extends wa{constructor(e,t=1014,n=301,i,r,s=1003,a=1003,o,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,a,o,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}};Nd=class Nd extends en{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}};bs=class bs extends Dn{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let o=[],c=[],l=[],u=[],d=0,f=0;h("z","y","x",-1,-1,n,t,e,s,r,0),h("z","y","x",1,-1,n,t,-e,s,r,1),h("x","z","y",1,1,e,n,t,i,s,2),h("x","z","y",1,-1,e,n,-t,i,s,3),h("x","y","z",1,-1,e,t,n,i,r,4),h("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(o),this.setAttribute("position",new Wn(c,3)),this.setAttribute("normal",new Wn(l,3)),this.setAttribute("uv",new Wn(u,2));function h(b,m,g,p,x,_,y,v,T,A,E){let w=_/T,P=y/A,S=_/2,I=y/2,U=v/2,N=T+1,F=A+1,D=0,O=0,K=new j;for(let B=0;B<F;B++){let X=B*P-I;for(let q=0;q<N;q++){let le=q*w-S;K[b]=le*p,K[m]=X*x,K[g]=U,c.push(K.x,K.y,K.z),K[b]=0,K[m]=0,K[g]=v>0?1:-1,l.push(K.x,K.y,K.z),u.push(q/T),u.push(1-B/A),D+=1}}for(let B=0;B<A;B++)for(let X=0;X<T;X++){let q=d+X+N*B,le=d+X+N*(B+1),de=d+(X+1)+N*(B+1),Me=d+(X+1)+N*B;o.push(q,le,Me),o.push(le,de,Me),O+=6}a.addGroup(f,O,E),f+=O,d+=D}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bs(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};cl=class cl extends Dn{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,a=Math.floor(n),o=Math.floor(i),c=a+1,l=o+1,u=e/a,d=t/o,f=[],h=[],b=[],m=[];for(let g=0;g<l;g++){let p=g*d-s;for(let x=0;x<c;x++){let _=x*u-r;h.push(_,-p,0),b.push(0,0,1),m.push(x/a),m.push(1-g/o)}}for(let g=0;g<o;g++)for(let p=0;p<a;p++){let x=p+c*g,_=p+c*(g+1),y=p+1+c*(g+1),v=p+1+c*g;f.push(x,_,v),f.push(_,y,v)}this.setIndex(f),this.setAttribute("position",new Wn(h,3)),this.setAttribute("normal",new Wn(b,3)),this.setAttribute("uv",new Wn(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new cl(e.width,e.height,e.widthSegments,e.heightSegments)}};KT={clone:Sa,merge:Ln};Ei=class Ei extends Xn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=eP,this.fragmentShader=tP,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0)this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Sa(e.uniforms),this.uniformsGroups=QN(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new qe().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ke().fromArray(i.value);break;case"v3":this.uniforms[n].value=new j().fromArray(i.value);break;case"v4":this.uniforms[n].value=new Pt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new tt().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Qe().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}};Dm=class Dm extends Ei{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};zr=class zr extends Xn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new qe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ur,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}};ui=class ui extends zr{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ke(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ct(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new qe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new qe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new qe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}};Pd=class Pd extends Xn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new qe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ur,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}};Lm=class Lm extends Xn{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}};Fm=class Fm extends Xn{constructor(e){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};Um=class Um extends Vr{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,a=i[r],o=i[s];if(a===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,a=2*t-n;break;case 2402:r=i.length-2,a=t+i[r]-i[r+1];break;default:r=e,a=n}if(o===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,o=2*n-t;break;case 2402:s=1,o=n+i[1]-i[0];break;default:s=e-1,o=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(o-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,c=o-a,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,h=(n-t)/(i-t),b=h*h,m=b*h,g=-d*m+2*d*b-d*h,p=(1+d)*m+(-1.5-2*d)*b+(-0.5+d)*h+1,x=(-1-f)*m+(1.5+f)*b+0.5*h,_=f*m-f*b;for(let y=0;y!==a;++y)r[y]=g*s[l+y]+p*s[c+y]+x*s[o+y]+_*s[u+y];return r}};Od=class Od extends Vr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,c=o-a,l=(n-t)/(i-t),u=1-l;for(let d=0;d!==a;++d)r[d]=s[c+d]*u+s[o+d]*l;return r}};Bm=class Bm extends Vr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}};zm=class zm extends Vr{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,c=o-a,l=this.inTangents,u=this.outTangents;if(!l||!u){let h=(n-t)/(i-t),b=1-h;for(let m=0;m!==a;++m)r[m]=s[c+m]*b+s[o+m]*h;return r}let d=a*2,f=e-1;for(let h=0;h!==a;++h){let b=s[c+h],m=s[o+h],g=f*d+h*2,p=u[g],x=u[g+1],_=e*d+h*2,y=l[_],v=l[_+1],T=sP(n,t,p,y,i);r[h]=WT(T,b,x,v,m)}return r}};di.prototype.ValueTypeName="";di.prototype.TimeBufferType=Float32Array;di.prototype.ValueBufferType=Float32Array;di.prototype.DefaultInterpolation=2301;xs=class xs extends di{constructor(e,t,n){super(e,t,n)}};xs.prototype.ValueTypeName="bool";xs.prototype.ValueBufferType=Array;xs.prototype.DefaultInterpolation=2300;xs.prototype.InterpolantFactoryMethodLinear=void 0;xs.prototype.InterpolantFactoryMethodSmooth=void 0;kd=class kd extends di{constructor(e,t,n,i){super(e,t,n,i)}};kd.prototype.ValueTypeName="color";ys=class ys extends di{constructor(e,t,n,i){super(e,t,n,i)}};ys.prototype.ValueTypeName="number";Vm=class Vm extends Vr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-t)/(i-t),c=e*a;for(let l=c+a;c!==l;c+=4)ln.slerpFlat(r,0,s,c-a,s,c,o);return r}};_s=class _s extends di{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new Vm(this.times,this.values,this.getValueSize(),e)}};_s.prototype.ValueTypeName="quaternion";_s.prototype.InterpolantFactoryMethodSmooth=void 0;vs=class vs extends di{constructor(e,t,n){super(e,t,n)}};vs.prototype.ValueTypeName="string";vs.prototype.ValueBufferType=Array;vs.prototype.DefaultInterpolation=2300;vs.prototype.InterpolantFactoryMethodLinear=void 0;vs.prototype.InterpolantFactoryMethodSmooth=void 0;Ma=class Ma extends di{constructor(e,t,n,i){super(e,t,n,i)}};Ma.prototype.ValueTypeName="vector";lr={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(jE(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(jE(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};XT=new ll;jr.DEFAULT_MATERIAL_NAME="__DEFAULT";Fr={};qT=class qT extends Error{constructor(e,t){super(e);this.response=t}};ul=class ul extends jr{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=lr.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Fr[e]!==void 0){Fr[e].push({onLoad:t,onProgress:n,onError:i});return}Fr[e]=[],Fr[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,o=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)je("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Fr[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,h=f!==0,b=0,m=new ReadableStream({start(g){p();function p(){u.read().then(({done:x,value:_})=>{if(x)g.close();else{b+=_.byteLength;let y=new ProgressEvent("progress",{lengthComputable:h,loaded:b,total:f});for(let v=0,T=l.length;v<T;v++){let A=l[v];if(A.onProgress)A.onProgress(y)}g.enqueue(_),p()}},(x)=>{g.error(x)})}}});return new Response(m)}else throw new qT(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(o){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,a));case"json":return c.json();default:if(a==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(a),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then((h)=>f.decode(h))}}}).then((c)=>{lr.add(`file:${e}`,c);let l=Fr[e];delete Fr[e];for(let u=0,d=l.length;u<d;u++){let f=l[u];if(f.onLoad)f.onLoad(c)}}).catch((c)=>{let l=Fr[e];if(l===void 0)throw this.manager.itemError(e),c;delete Fr[e];for(let u=0,d=l.length;u<d;u++){let f=l[u];if(f.onError)f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};bo=new WeakMap;jm=class jm extends jr{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=lr.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);else{let u=bo.get(s);if(u===void 0)u=[],bo.set(s,u);u.push({onLoad:t,onError:i})}return s}let a=vo("img");function o(){if(l(),t)t(this);let u=bo.get(this)||[];for(let d=0;d<u.length;d++){let f=u[d];if(f.onLoad)f.onLoad(this)}bo.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);lr.remove(`image:${e}`);let d=bo.get(this)||[];for(let f=0;f<d.length;f++){let h=d[f];if(h.onError)h.onError(u)}bo.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){a.removeEventListener("load",o,!1),a.removeEventListener("error",c,!1)}if(a.addEventListener("load",o,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)a.crossOrigin=this.crossOrigin}return lr.add(`image:${e}`,a),r.manager.itemStart(e),a.src=e,a}};Lo=class Lo extends jr{constructor(e){super(e)}load(e,t,n,i){let r=new en,s=new jm(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(a){if(r.image=a,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}};Fo=class Fo extends Dt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new qe(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}};Dd=class Dd extends Fo{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new qe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}};Mp=new Qe,HE=new j,GE=new j;sd=new j,ad=new ln,or=new j;Ld=class Ld extends Dt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Qe,this.projectionMatrix=new Qe,this.projectionMatrixInverse=new Qe,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(sd,ad,or),or.x===1&&or.y===1&&or.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(sd,ad,or.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(sd,ad,or),or.x===1&&or.y===1&&or.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(sd,ad,or.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}};os=new j,$E=new Ke,KE=new Ke;fn=class fn extends Ld{constructor(e=50,t=1,n=0.1,i=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=0.5*this.getFilmHeight()/e;this.fov=xa*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Hc*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return xa*2*Math.atan(Math.tan(Hc*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){os.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(os.x,os.y).multiplyScalar(-e/os.z),os.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(os.x,os.y).multiplyScalar(-e/os.z)}getViewSize(e,t){return this.getViewBounds(e,$E,KE),t.subVectors(KE,$E)}setViewOffset(e,t,n,i,r,s){if(this.aspect=e/t,this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Hc*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:o,fullHeight:c}=s;r+=s.offsetX*i/o,t-=s.offsetY*n/c,i*=s.width/o,n*=s.height/c}let a=this.filmOffset;if(a!==0)r+=e*a/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null)t.object.view=Object.assign({},this.view);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};JT=class JT extends dl{constructor(){super(new fn(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=xa*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;if(n!==t.fov||i!==t.aspect||r!==t.far)t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix();super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}};Fd=class Fd extends Fo{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.target=new Dt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new JT}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);if(t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture)t.object.map=this.map.toJSON(e).uuid;return t.object.shadow=this.shadow.toJSON(),t}};ZT=class ZT extends dl{constructor(){super(new fn(90,1,0.5,500));this.isPointLightShadow=!0}};Uo=class Uo extends Fo{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new ZT}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}};Ra=class Ra extends Ld{constructor(e=-1,t=1,n=1,i=-1,r=0.1,s=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){if(this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,s=n+e,a=i+t,o=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,a-=l*this.view.offsetY,o=a-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null)t.object.view=Object.assign({},this.view);return t}};YT=class YT extends dl{constructor(){super(new Ra(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}};Bo=class Bo extends Fo{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.target=new Dt,this.shadow=new YT}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}};Rp=new WeakMap;Ud=class Ud extends jr{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")je("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")je("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=lr.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(Rp.has(s)===!0){if(i)i(Rp.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,a.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let o=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(lr.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);Rp.set(o,c),lr.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});lr.add(`image-bitmap:${e}`,o),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};Hm=class Hm extends Dt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new fn(xo,yo,e,t);i.layers=this.layers,this.add(i);let r=new fn(xo,yo,e,t);r.layers=this.layers,this.add(r);let s=new fn(xo,yo,e,t);s.layers=this.layers,this.add(s);let a=new fn(xo,yo,e,t);a.layers=this.layers,this.add(a);let o=new fn(xo,yo,e,t);o.layers=this.layers,this.add(o);let c=new fn(xo,yo,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,a,o]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.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(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.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 Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,a,o,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),h=e.xr.enabled;e.xr.enabled=!1;let b=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;if(e.isWebGLRenderer===!0)m=e.state.buffers.depth.getReversed();else m=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),m&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),m&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),m&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,3,i),m&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,4,i),m&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=b,e.setRenderTarget(n,5,i),m&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=h,n.texture.needsPMREMUpdate=!0}};Gm=class Gm extends fn{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};cP=new RegExp("["+Km+"]","g"),Wm="[^"+Km+"]",lP="[^"+Km.replace("\\.","")+"]",uP=/((?:WC+[\/:])*)/.source.replace("WC",Wm),dP=/(WCOD+)?/.source.replace("WCOD",lP),fP=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Wm),hP=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Wm),pP=new RegExp("^"+uP+dP+fP+hP+"$"),mP=["material","materials","bones","map"];Tt.Composite=QT;Tt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Tt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Tt.prototype.GetterByBindingType=[Tt.prototype._getValue_direct,Tt.prototype._getValue_array,Tt.prototype._getValue_arrayElement,Tt.prototype._getValue_toArray];Tt.prototype.SetterByBindingTypeAndVersioning=[[Tt.prototype._setValue_direct,Tt.prototype._setValue_direct_setNeedsUpdate,Tt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_array,Tt.prototype._setValue_array_setNeedsUpdate,Tt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_arrayElement,Tt.prototype._setValue_arrayElement_setNeedsUpdate,Tt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_fromArray,Tt.prototype._setValue_fromArray_setNeedsUpdate,Tt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];gP=new Float32Array(1);Bd=class Bd extends Vi{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:a}=e,o=n.uuid,c=this._bindingsByRootAndName,l=c[o];if(l===void 0)l={},c[o]=l;for(let u=0;u!==r;++u){let d=i[u],f=d.name,h=l[f];if(h!==void 0)++h.referenceCount,s[u]=h;else{if(h=s[u],h!==void 0){if(h._cacheIndex===null)++h.referenceCount,this._addInactiveBinding(h,o,f);continue}let b=t&&t._propertyBindings[u].binding.parsedPath;h=new $m(Tt.create(n,f,b),d.ValueTypeName,d.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,f),s[u]=h}a[u].resultBuffer=h.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let a=s.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,a=s[r],o=a.knownActions,c=o[o.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,o[l]=c,o.pop(),e._byClipCacheIndex=null;let u=a.actionByRoot,d=(e._localRoot||this._root).uuid;if(delete u[d],o.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,a=s[i],o=t[t.length-1],c=e._cacheIndex;if(o._cacheIndex=c,t[c]=o,t.pop(),delete a[r],Object.keys(a).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new Od(new Float32Array(2),new Float32Array(2),1,gP),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,s=typeof e==="string"?To.findByName(i,e):e,a=s!==null?s.uuid:e,o=this._actionsByClip[a],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(o!==void 0){let u=o.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=o.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new Xm(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,a,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?To.findByName(n,e):e,s=r?r.uuid:e,a=this._actionsByClip[s];if(a!==void 0)return a.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let a=this._bindings,o=this._nActiveBindings;for(let c=0;c!==o;++c)a[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let a=0,o=s.length;a!==o;++a){let c=s[a];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let a=n[s].actionByRoot,o=a[t];if(o!==void 0)this._deactivateAction(o),this._removeInactiveAction(o)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let a=r[s];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}};qm=class qm{static{qm.prototype.isMatrix2=!0}constructor(e,t,n,i){if(this.elements=[1,0,0,1],e!==void 0)this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}};zd=class zd extends Vi{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}};if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)je("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186"});function vA(){let e=null,t=!1,n=null,i=null;function r(s,a){i=e.requestAnimationFrame(r),n(s,a)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(r),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(s){n=s},setContext:function(s){e=s}}}function xP(e){let t=new WeakMap;function n(o,c){let{array:l,usage:u}=o,d=l.byteLength,f=e.createBuffer();e.bindBuffer(c,f),e.bufferData(c,l,u),o.onUploadCallback();let h;if(l instanceof Float32Array)h=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)h=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(o.isFloat16BufferAttribute)h=e.HALF_FLOAT;else h=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)h=e.SHORT;else if(l instanceof Uint32Array)h=e.UNSIGNED_INT;else if(l instanceof Int32Array)h=e.INT;else if(l instanceof Int8Array)h=e.BYTE;else if(l instanceof Uint8Array)h=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)h=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:f,type:h,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,c,l){let{array:u,updateRanges:d}=c;if(e.bindBuffer(l,o),d.length===0)e.bufferSubData(l,0,u);else{d.sort((h,b)=>h.start-b.start);let f=0;for(let h=1;h<d.length;h++){let b=d[f],m=d[h];if(m.start<=b.start+b.count+1)b.count=Math.max(b.count,m.start+m.count-b.start);else++f,d[f]=m}d.length=f+1;for(let h=0,b=d.length;h<b;h++){let m=d[h];e.bufferSubData(l,m.start*u.BYTES_PER_ELEMENT,u,m.start,m.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(o){if(o.isInterleavedBufferAttribute)o=o.data;return t.get(o)}function s(o){if(o.isInterleavedBufferAttribute)o=o.data;let c=t.get(o);if(c)e.deleteBuffer(c.buffer),t.delete(o)}function a(o,c){if(o.isInterleavedBufferAttribute)o=o.data;if(o.isGLBufferAttribute){let u=t.get(o);if(!u||u.version<o.version)t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let l=t.get(o);if(l===void 0)t.set(o,n(o,c));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,o,c),l.version=o.version}}return{get:r,remove:s,update:a}}function eD(e,t,n,i,r,s){let a=new qe(0),o=r===!0?0:1,c,l,u=null,d=0,f=null;function h(x){let _=x.isScene===!0?x.background:null;if(_&&_.isTexture){let y=x.backgroundBlurriness>0;_=t.get(_,y)}return _}function b(x){let _=!1,y=h(x);if(y===null)g(a,o);else if(y&&y.isColor)g(y,1),_=!0;let v=e.xr.getEnvironmentBlendMode();if(v==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(v==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||_)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function m(x,_){let y=h(_);if(y&&(y.isCubeTexture||y.mapping===qc)){if(l===void 0)l=new jt(new bs(1,1,1),new Ei({name:"BackgroundCubeMaterial",uniforms:Sa(br.backgroundCube.uniforms),vertexShader:br.backgroundCube.vertexShader,fragmentShader:br.backgroundCube.fragmentShader,side:kn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(v,T,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=y,l.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Qk.makeRotationFromEuler(_.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(EA);if(l.material.toneMapped=ot.getTransfer(y.colorSpace)!==Bt,u!==y||d!==y.version||f!==e.toneMapping)l.material.needsUpdate=!0,u=y,d=y.version,f=e.toneMapping;l.layers.enableAll(),x.unshift(l,l.geometry,l.material,0,0,null)}else if(y&&y.isTexture){if(c===void 0)c=new jt(new cl(2,2),new Ei({name:"BackgroundMaterial",uniforms:Sa(br.background.uniforms),vertexShader:br.background.vertexShader,fragmentShader:br.background.fragmentShader,side:fs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=y,c.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,c.material.toneMapped=ot.getTransfer(y.colorSpace)!==Bt,y.matrixAutoUpdate===!0)y.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(y.matrix),u!==y||d!==y.version||f!==e.toneMapping)c.material.needsUpdate=!0,u=y,d=y.version,f=e.toneMapping;c.layers.enableAll(),x.unshift(c,c.geometry,c.material,0,0,null)}}function g(x,_){x.getRGB(Vd,km(e)),n.buffers.color.setClear(Vd.r,Vd.g,Vd.b,_,s)}function p(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return a},setClearColor:function(x,_=1){a.set(x),o=_,g(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(x){o=x,g(a,o)},render:b,addToRenderList:m,dispose:p}}function tD(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=f(null),s=r,a=!1;function o(S,I,U,N,F){let D=!1,O=d(S,N,U,I);if(s!==O)s=O,l(s.object);if(D=h(S,N,U,F),D)b(S,N,U,F);if(F!==null)t.update(F,e.ELEMENT_ARRAY_BUFFER);if(D||a){if(a=!1,y(S,I,U,N),F!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(F).buffer)}}function c(){return e.createVertexArray()}function l(S){return e.bindVertexArray(S)}function u(S){return e.deleteVertexArray(S)}function d(S,I,U,N){let F=N.wireframe===!0,D=i[I.id];if(D===void 0)D={},i[I.id]=D;let O=S.isInstancedMesh===!0?S.id:0,K=D[O];if(K===void 0)K={},D[O]=K;let B=K[U.id];if(B===void 0)B={},K[U.id]=B;let X=B[F];if(X===void 0)X=f(c()),B[F]=X;return X}function f(S){let I=[],U=[],N=[];for(let F=0;F<n;F++)I[F]=0,U[F]=0,N[F]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:U,attributeDivisors:N,object:S,attributes:{},index:null}}function h(S,I,U,N){let F=s.attributes,D=I.attributes,O=0,K=U.getAttributes();for(let B in K)if(K[B].location>=0){let q=F[B],le=D[B];if(le===void 0){if(B==="instanceMatrix"&&S.instanceMatrix)le=S.instanceMatrix;if(B==="instanceColor"&&S.instanceColor)le=S.instanceColor}if(q===void 0)return!0;if(q.attribute!==le)return!0;if(le&&q.data!==le.data)return!0;O++}if(s.attributesNum!==O)return!0;if(s.index!==N)return!0;return!1}function b(S,I,U,N){let F={},D=I.attributes,O=0,K=U.getAttributes();for(let B in K)if(K[B].location>=0){let q=D[B];if(q===void 0){if(B==="instanceMatrix"&&S.instanceMatrix)q=S.instanceMatrix;if(B==="instanceColor"&&S.instanceColor)q=S.instanceColor}let le={};if(le.attribute=q,q&&q.data)le.data=q.data;F[B]=le,O++}s.attributes=F,s.attributesNum=O,s.index=N}function m(){let S=s.newAttributes;for(let I=0,U=S.length;I<U;I++)S[I]=0}function g(S){p(S,0)}function p(S,I){let U=s.newAttributes,N=s.enabledAttributes,F=s.attributeDivisors;if(U[S]=1,N[S]===0)e.enableVertexAttribArray(S),N[S]=1;if(F[S]!==I)e.vertexAttribDivisor(S,I),F[S]=I}function x(){let S=s.newAttributes,I=s.enabledAttributes;for(let U=0,N=I.length;U<N;U++)if(I[U]!==S[U])e.disableVertexAttribArray(U),I[U]=0}function _(S,I,U,N,F,D,O){if(O===!0)e.vertexAttribIPointer(S,I,U,F,D);else e.vertexAttribPointer(S,I,U,N,F,D)}function y(S,I,U,N){m();let F=N.attributes,D=U.getAttributes(),O=I.defaultAttributeValues;for(let K in D){let B=D[K];if(B.location>=0){let X=F[K];if(X===void 0){if(K==="instanceMatrix"&&S.instanceMatrix)X=S.instanceMatrix;if(K==="instanceColor"&&S.instanceColor)X=S.instanceColor}if(X!==void 0){let q=X.normalized,le=X.itemSize,de=t.get(X);if(de===void 0)continue;let{buffer:Me,type:pe,bytesPerElement:J}=de,L=pe===e.INT||pe===e.UNSIGNED_INT||X.gpuType===Vp;if(X.isInterleavedBufferAttribute){let W=X.data,ne=W.stride,ie=X.offset;if(W.isInstancedInterleavedBuffer){for(let ce=0;ce<B.locationSize;ce++)p(B.location+ce,W.meshPerAttribute);if(S.isInstancedMesh!==!0&&N._maxInstanceCount===void 0)N._maxInstanceCount=W.meshPerAttribute*W.count}else for(let ce=0;ce<B.locationSize;ce++)g(B.location+ce);e.bindBuffer(e.ARRAY_BUFFER,Me);for(let ce=0;ce<B.locationSize;ce++)_(B.location+ce,le/B.locationSize,pe,q,ne*J,(ie+le/B.locationSize*ce)*J,L)}else{if(X.isInstancedBufferAttribute){for(let W=0;W<B.locationSize;W++)p(B.location+W,X.meshPerAttribute);if(S.isInstancedMesh!==!0&&N._maxInstanceCount===void 0)N._maxInstanceCount=X.meshPerAttribute*X.count}else for(let W=0;W<B.locationSize;W++)g(B.location+W);e.bindBuffer(e.ARRAY_BUFFER,Me);for(let W=0;W<B.locationSize;W++)_(B.location+W,le/B.locationSize,pe,q,le*J,le/B.locationSize*W*J,L)}}else if(O!==void 0){let q=O[K];if(q!==void 0)switch(q.length){case 2:e.vertexAttrib2fv(B.location,q);break;case 3:e.vertexAttrib3fv(B.location,q);break;case 4:e.vertexAttrib4fv(B.location,q);break;default:e.vertexAttrib1fv(B.location,q)}}}}x()}function v(){w();for(let S in i){let I=i[S];for(let U in I){let N=I[U];for(let F in N){let D=N[F];for(let O in D)u(D[O].object),delete D[O];delete N[F]}}delete i[S]}}function T(S){if(i[S.id]===void 0)return;let I=i[S.id];for(let U in I){let N=I[U];for(let F in N){let D=N[F];for(let O in D)u(D[O].object),delete D[O];delete N[F]}}delete i[S.id]}function A(S){for(let I in i){let U=i[I];for(let N in U){let F=U[N];if(F[S.id]===void 0)continue;let D=F[S.id];for(let O in D)u(D[O].object),delete D[O];delete F[S.id]}}}function E(S){for(let I in i){let U=i[I],N=S.isInstancedMesh===!0?S.id:0,F=U[N];if(F===void 0)continue;for(let D in F){let O=F[D];for(let K in O)u(O[K].object),delete O[K];delete F[D]}if(delete U[N],Object.keys(U).length===0)delete i[I]}}function w(){if(P(),a=!0,s===r)return;s=r,l(s.object)}function P(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:w,resetDefaultState:P,dispose:v,releaseStatesOfGeometry:T,releaseStatesOfObject:E,releaseStatesOfProgram:A,initAttributes:m,enableAttribute:g,disableUnusedAttributes:x}}function nD(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function a(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function o(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let f=0;for(let h=0;h<u;h++)f+=l[h];n.update(f,i,1)}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o}function iD(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let A=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(A){if(A!==pr&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function o(A){let E=A===hr&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(A!==zi&&A!==Br&&!E&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(A){if(A==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";A="mediump"}if(A==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)je("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let d=n.logarithmicDepthBuffer===!0,f=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&f===!1)je("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),b=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_TEXTURE_SIZE),g=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),p=e.getParameter(e.MAX_VERTEX_ATTRIBS),x=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),_=e.getParameter(e.MAX_VARYING_VECTORS),y=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),v=e.getParameter(e.MAX_SAMPLES),T=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:f,maxTextures:h,maxVertexTextures:b,maxTextureSize:m,maxCubemapSize:g,maxAttributes:p,maxVertexUniforms:x,maxVaryings:_,maxFragmentUniforms:y,maxSamples:v,samples:T}}function rD(e){let t=this,n=null,i=0,r=!1,s=!1,a=new yi,o=new tt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,f){let h=d.length!==0||f||i!==0||r;return r=f,i=d.length,h},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,f){n=u(d,f,0)},this.setState=function(d,f,h){let{clippingPlanes:b,clipIntersection:m,clipShadows:g}=d,p=e.get(d);if(!r||b===null||b.length===0||s&&!g)if(s)u(null);else l();else{let x=s?0:i,_=x*4,y=p.clippingState||null;c.value=y,y=u(b,f,_,h);for(let v=0;v!==_;++v)y[v]=n[v];p.clippingState=y,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=x}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(d,f,h,b){let m=d!==null?d.length:0,g=null;if(m!==0){if(g=c.value,b!==!0||g===null){let p=h+m*4,x=f.matrixWorldInverse;if(o.getNormalMatrix(x),g===null||g.length<p)g=new Float32Array(p);for(let _=0,y=h;_!==m;++_,y+=4)a.copy(d[_]).applyMatrix4(x,o),a.normal.toArray(g,y),g[y+3]=a.constant}c.value=g,c.needsUpdate=!0}return t.numPlanes=m,t.numIntersection=0,g}}class bl{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=0.1,i=100,r={}){let{size:s=256,position:a=cD}=r;Ym=this._renderer.getRenderTarget(),Qm=this._renderer.getActiveCubeFace(),eg=this._renderer.getActiveMipmapLevel(),tg=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let o=this._allocateTargets();if(o.depthBuffer=!0,this._sceneToCubeUV(e,n,i,o,a),t>0)this._blur(o,0,0,t);return this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=iA(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=nA(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Ym,Qm,eg),this._renderer.xr.enabled=tg,e.scissorTest=!1,zo(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===So||e.mapping===ya)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Ym=this._renderer.getRenderTarget(),Qm=this._renderer.getActiveCubeFace(),eg=this._renderer.getActiveMipmapLevel(),tg=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:En,minFilter:En,generateMipmaps:!1,type:hr,format:pr,colorSpace:oi,depthBuffer:!1},i=tA(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=tA(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=lD(r)),this._blurMaterial=dD(r,e,t),this._ggxMaterial=uD(r,e,t)}return i}_compileMaterial(e){let t=new jt(new Dn,e);this._renderer.compile(t,hl)}_sceneToCubeUV(e,t,n,i,r){let o=new fn(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:d,toneMapping:f}=u;if(u.getClearColor(eA),u.toneMapping=Ui,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new jt(new bs,new mr({name:"PMREM.Background",side:kn,depthWrite:!1,depthTest:!1}));let b=this._backgroundBox,m=b.material,g=!1,p=e.background;if(p){if(p.isColor)m.color.copy(p),e.background=null,g=!0}else m.color.copy(eA),g=!0;for(let x=0;x<6;x++){let _=x%3;if(_===0)o.up.set(0,c[x],0),o.position.set(r.x,r.y,r.z),o.lookAt(r.x+l[x],r.y,r.z);else if(_===1)o.up.set(0,0,c[x]),o.position.set(r.x,r.y,r.z),o.lookAt(r.x,r.y+l[x],r.z);else o.up.set(0,c[x],0),o.position.set(r.x,r.y,r.z),o.lookAt(r.x,r.y,r.z+l[x]);let y=this._cubeSize;if(zo(i,_*y,x>2?y:0,y,y),u.setRenderTarget(i),g)u.render(b,o);u.render(e,o)}u.toneMapping=f,u.autoClear=d,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===So||e.mapping===ya;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=iA();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=nA();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let a=r.uniforms;a.envMap.value=e;let o=this._cubeSize;zo(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(s,hl)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,a=this._lodMeshes[n];a.material=s;let o=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),d=c*1.25,f=u*d,{_lodMax:h}=this,b=this._sizeLods[n],m=3*b*(n>h-Vo?n-h+Vo:0),g=4*(this._cubeSize-b);o.envMap.value=e.texture,o.roughness.value=f,o.mipInt.value=h-t,zo(r,m,g,3*b,2*b),i.setRenderTarget(r),i.render(a,hl),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=h-n,zo(e,m,g,3*b,2*b),i.setRenderTarget(e),i.render(a,hl)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,a=this._blurMaterial,o=this._lodMeshes[i];o.material=a;let c=a.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-Vo?i-this._lodMax+Vo:0),d=4*(this._cubeSize-l);zo(t,u,d,3*l,2*l),s.setRenderTarget(t),s.render(o,hl)}}function lD(e){let t=[],n=[],i=e,r=e-Vo+1+sD;for(let s=0;s<r;s++){let a=Math.pow(2,i);t.push(a);let o=1/(a-2),c=-o,l=1+o,u=[c,c,l,c,l,l,c,c,l,l,c,l],d=6,f=6,h=3,b=new Float32Array(h*f*d),m=new Float32Array(h*f*d);for(let p=0;p<d;p++){let x=p%3*2/3-1,_=p>2?0:-1,y=[x,_,0,x+0.6666666666666666,_,0,x+0.6666666666666666,_+1,0,x,_,0,x+0.6666666666666666,_+1,0,x,_+1,0];b.set(y,h*f*p);for(let v=0;v<f;v++){let T=u[v*2]*2-1,A=u[v*2+1]*2-1;if(p===0)Ia.set(1,A,T);else if(p===1)Ia.set(-T,1,-A);else if(p===2)Ia.set(-T,A,1);else if(p===3)Ia.set(-1,A,-T);else if(p===4)Ia.set(-T,-1,A);else Ia.set(T,A,-1);Ia.toArray(m,(p*f+v)*h)}}let g=new Dn;if(g.setAttribute("position",new vn(b,h)),g.setAttribute("outputDirection",new vn(m,h)),n.push(new jt(g,null)),i>Vo)i--}return{lodMeshes:n,sizeLods:t}}function tA(e,t,n){let i=new ci(e,t,n);return i.texture.mapping=qc,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function zo(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function uD(e,t,n){return new Ei({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:oD,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Hd(),fragmentShader:`precision highp float;precision highp int;@@ -106,7 +110,7 @@ var _R=Object.create;var{getPrototypeOf:vR,defineProperty:gf,getOwnPropertyNamesgl_FragColor = vec4(prefilteredColor, 1.0);}- `,blending:lr,depthTest:!1,depthWrite:!1})}function Pk(e,t,n){return new _i({name:"SphericalGaussianBlur",defines:{SAMPLES:Mk,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:wd(),fragmentShader:`+ `,blending:dr,depthTest:!1,depthWrite:!1})}function dD(e,t,n){return new Ei({name:"SphericalGaussianBlur",defines:{SAMPLES:aD,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:Hd(),fragmentShader:`precision highp float;precision highp int;@@ -166,7 +170,7 @@ var _R=Object.create;var{getPrototypeOf:vR,defineProperty:gf,getOwnPropertyNamesgl_FragColor = vec4( accumColor / accumWeight, 1.0 );}- `,blending:lr,depthTest:!1,depthWrite:!1})}function FT(){return new _i({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:wd(),fragmentShader:`+ `,blending:dr,depthTest:!1,depthWrite:!1})}function nA(){return new Ei({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Hd(),fragmentShader:`precision mediump float;precision mediump int;@@ -185,7 +189,7 @@ var _R=Object.create;var{getPrototypeOf:vR,defineProperty:gf,getOwnPropertyNamesgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );}- `,blending:lr,depthTest:!1,depthWrite:!1})}function UT(){return new _i({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:wd(),fragmentShader:`+ `,blending:dr,depthTest:!1,depthWrite:!1})}function iA(){return new Ei({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Hd(),fragmentShader:`precision mediump float;precision mediump int;@@ -201,7 +205,7 @@ var _R=Object.create;var{getPrototypeOf:vR,defineProperty:gf,getOwnPropertyNamesgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );}- `,blending:lr,depthTest:!1,depthWrite:!1})}function wd(){return`+ `,blending:dr,depthTest:!1,depthWrite:!1})}function Hd(){return`precision mediump float;precision mediump int;@@ -216,7 +220,7 @@ var _R=Object.create;var{getPrototypeOf:vR,defineProperty:gf,getOwnPropertyNamesgl_Position = vec4( position, 1.0 );}- `}function Ok(e){let t=new WeakMap,n=new WeakMap,i=null;function r(f,h=!1){if(f===null||f===void 0)return null;if(h)return a(f);return s(f)}function s(f){if(f&&f.isTexture){let h=f.mapping;if(h===Wu||h===Xu)if(t.has(f)){let y=t.get(f).texture;return o(y,f.mapping)}else{let y=f.image;if(y&&y.height>0){let g=new $m(y.height);return g.fromEquirectangularTexture(e,f),t.set(f,g),f.addEventListener("dispose",l),o(g.texture,f.mapping)}else return null}}return f}function a(f){if(f&&f.isTexture){let h=f.mapping,y=h===Wu||h===Xu,g=h===yo||h===pa;if(y||g){let m=n.get(f),p=m!==void 0?m.texture.pmremVersion:0;if(f.isRenderTargetTexture&&f.pmremVersion!==p){if(i===null)i=new sl(e);return m=y?i.fromEquirectangular(f,m):i.fromCubemap(f,m),m.texture.pmremVersion=f.pmremVersion,n.set(f,m),m.texture}else if(m!==void 0)return m.texture;else{let b=f.image;if(y&&b&&b.height>0||g&&b&&c(b)){if(i===null)i=new sl(e);return m=y?i.fromEquirectangular(f):i.fromCubemap(f),m.texture.pmremVersion=f.pmremVersion,n.set(f,m),f.addEventListener("dispose",u),m.texture}else return null}}}return f}function o(f,h){if(h===Wu)f.mapping=yo;else if(h===Xu)f.mapping=pa;return f}function c(f){let h=0,y=6;for(let g=0;g<y;g++)if(f[g]!==void 0)h++;return h===y}function l(f){let h=f.target;h.removeEventListener("dispose",l);let y=t.get(h);if(y!==void 0)t.delete(h),y.dispose()}function u(f){let h=f.target;h.removeEventListener("dispose",u);let y=n.get(h);if(y!==void 0)n.delete(h),y.dispose()}function d(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:d}}function kk(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let r=e.getExtension(i);return t[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let r=n(i);if(r===null)fa("WebGLRenderer: "+i+" extension not supported.");return r}}}function Dk(e,t,n,i){let r={},s=new WeakMap;function a(d){let f=d.target;if(f.index!==null)t.remove(f.index);for(let y in f.attributes)t.remove(f.attributes[y]);f.removeEventListener("dispose",a),delete r[f.id];let h=s.get(f);if(h)t.remove(h),s.delete(f);if(i.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0)delete f._maxInstanceCount;n.memory.geometries--}function o(d,f){if(r[f.id]===!0)return f;return f.addEventListener("dispose",a),r[f.id]=!0,n.memory.geometries++,f}function c(d){let f=d.attributes;for(let h in f)t.update(f[h],e.ARRAY_BUFFER)}function l(d){let f=[],h=d.index,y=d.attributes.position,g=0;if(y===void 0)return;if(h!==null){let b=h.array;g=h.version;for(let _=0,x=b.length;_<x;_+=3){let v=b[_+0],E=b[_+1],S=b[_+2];f.push(v,E,E,S,S,v)}}else{let b=y.array;g=y.version;for(let _=0,x=b.length/3-1;_<x;_+=3){let v=_+0,E=_+1,S=_+2;f.push(v,E,E,S,S,v)}}let m=new(y.count>=65535?ld:cd)(f,1);m.version=g;let p=s.get(d);if(p)t.remove(p);s.set(d,m)}function u(d){let f=s.get(d);if(f){let h=d.index;if(h!==null){if(f.version<h.version)l(d)}}else l(d);return s.get(d)}return{get:o,update:c,getWireframeAttribute:u}}function Lk(e,t,n){let i;function r(d){i=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function c(d,f){e.drawElements(i,f,s,d*a),n.update(f,i,1)}function l(d,f,h){if(h===0)return;e.drawElementsInstanced(i,f,s,d*a,h),n.update(f,i,h)}function u(d,f,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,f,0,s,d,0,h);let g=0;for(let m=0;m<h;m++)g+=f[m];n.update(g,i,1)}this.setMode=r,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function Fk(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,a,o){switch(n.calls++,a){case e.TRIANGLES:n.triangles+=o*(s/3);break;case e.LINES:n.lines+=o*(s/2);break;case e.LINE_STRIP:n.lines+=o*(s-1);break;case e.LINE_LOOP:n.lines+=o*s;break;case e.POINTS:n.points+=o*s;break;default:Ze("WebGLInfo: Unknown draw mode:",a);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function Uk(e,t,n){let i=new WeakMap,r=new Nt;function s(a,o,c){let l=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=u!==void 0?u.length:0,f=i.get(o);if(f===void 0||f.count!==d){let A=function(){S.dispose(),i.delete(o),o.removeEventListener("dispose",A)};if(f!==void 0)f.texture.dispose();let h=o.morphAttributes.position!==void 0,y=o.morphAttributes.normal!==void 0,g=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],b=o.morphAttributes.color||[],_=0;if(h===!0)_=1;if(y===!0)_=2;if(g===!0)_=3;let x=o.attributes.position.count*_,v=1;if(x>t.maxTextureSize)v=Math.ceil(x/t.maxTextureSize),x=t.maxTextureSize;let E=new Float32Array(x*v*4*d),S=new ad(E,x,v,d);S.type=Fr,S.needsUpdate=!0;let T=_*4;for(let P=0;P<d;P++){let w=m[P],I=p[P],F=b[P],N=x*v*4*P;for(let U=0;U<w.count;U++){let D=U*T;if(h===!0)r.fromBufferAttribute(w,U),E[N+D+0]=r.x,E[N+D+1]=r.y,E[N+D+2]=r.z,E[N+D+3]=0;if(y===!0)r.fromBufferAttribute(I,U),E[N+D+4]=r.x,E[N+D+5]=r.y,E[N+D+6]=r.z,E[N+D+7]=0;if(g===!0)r.fromBufferAttribute(F,U),E[N+D+8]=r.x,E[N+D+9]=r.y,E[N+D+10]=r.z,E[N+D+11]=F.itemSize===4?r.w:1}}f={count:d,texture:S,size:new Ke(x,v)},i.set(o,f),o.addEventListener("dispose",A)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",a.morphTexture,n);else{let h=0;for(let g=0;g<l.length;g++)h+=l[g];let y=o.morphTargetsRelative?1:1-h;c.getUniforms().setValue(e,"morphTargetBaseInfluence",y),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",f.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",f.size)}return{update:s}}function Bk(e,t,n,i,r){let s=new WeakMap;function a(l){let u=r.render.frame,d=l.geometry,f=t.get(l,d);if(s.get(f)!==u)t.update(f),s.set(f,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let h=l.skeleton;if(s.get(h)!==u)h.update(),s.set(h,u)}return f}function o(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:a,dispose:o}}function Vk(e,t,n,i,r,s){let a=new ai(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),o=null,c=null,l=new On;l.setAttribute("position",new Gn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Gn([0,2,0,0,2,0],2));let u=new _m({uniforms:{tDiffuse:{value:null}},vertexShader:`+ `}function fD(e){let t=new WeakMap,n=new WeakMap,i=null;function r(f,h=!1){if(f===null||f===void 0)return null;if(h)return a(f);return s(f)}function s(f){if(f&&f.isTexture){let h=f.mapping;if(h===ud||h===dd)if(t.has(f)){let b=t.get(f).texture;return o(b,f.mapping)}else{let b=f.image;if(b&&b.height>0){let m=new ag(b.height);return m.fromEquirectangularTexture(e,f),t.set(f,m),f.addEventListener("dispose",l),o(m.texture,f.mapping)}else return null}}return f}function a(f){if(f&&f.isTexture){let h=f.mapping,b=h===ud||h===dd,m=h===So||h===ya;if(b||m){let g=n.get(f),p=g!==void 0?g.texture.pmremVersion:0;if(f.isRenderTargetTexture&&f.pmremVersion!==p){if(i===null)i=new bl(e);return g=b?i.fromEquirectangular(f,g):i.fromCubemap(f,g),g.texture.pmremVersion=f.pmremVersion,n.set(f,g),g.texture}else if(g!==void 0)return g.texture;else{let x=f.image;if(b&&x&&x.height>0||m&&x&&c(x)){if(i===null)i=new bl(e);return g=b?i.fromEquirectangular(f):i.fromCubemap(f),g.texture.pmremVersion=f.pmremVersion,n.set(f,g),f.addEventListener("dispose",u),g.texture}else return null}}}return f}function o(f,h){if(h===ud)f.mapping=So;else if(h===dd)f.mapping=ya;return f}function c(f){let h=0,b=6;for(let m=0;m<b;m++)if(f[m]!==void 0)h++;return h===b}function l(f){let h=f.target;h.removeEventListener("dispose",l);let b=t.get(h);if(b!==void 0)t.delete(h),b.dispose()}function u(f){let h=f.target;h.removeEventListener("dispose",u);let b=n.get(h);if(b!==void 0)n.delete(h),b.dispose()}function d(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:d}}function hD(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let r=e.getExtension(i);return t[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let r=n(i);if(r===null)ba("WebGLRenderer: "+i+" extension not supported.");return r}}}function pD(e,t,n,i){let r={},s=new WeakMap;function a(d){let f=d.target;if(f.index!==null)t.remove(f.index);for(let b in f.attributes)t.remove(f.attributes[b]);f.removeEventListener("dispose",a),delete r[f.id];let h=s.get(f);if(h)t.remove(h),s.delete(f);if(i.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0)delete f._maxInstanceCount;n.memory.geometries--}function o(d,f){if(r[f.id]===!0)return f;return f.addEventListener("dispose",a),r[f.id]=!0,n.memory.geometries++,f}function c(d){let f=d.attributes;for(let h in f)t.update(f[h],e.ARRAY_BUFFER)}function l(d){let f=[],h=d.index,b=d.attributes.position,m=0;if(b===void 0)return;if(h!==null){let x=h.array;m=h.version;for(let _=0,y=x.length;_<y;_+=3){let v=x[_+0],T=x[_+1],A=x[_+2];f.push(v,T,T,A,A,v)}}else{let x=b.array;m=b.version;for(let _=0,y=x.length/3-1;_<y;_+=3){let v=_+0,T=_+1,A=_+2;f.push(v,T,T,A,A,v)}}let g=new(b.count>=65535?Sd:wd)(f,1);g.version=m;let p=s.get(d);if(p)t.remove(p);s.set(d,g)}function u(d){let f=s.get(d);if(f){let h=d.index;if(h!==null){if(f.version<h.version)l(d)}}else l(d);return s.get(d)}return{get:o,update:c,getWireframeAttribute:u}}function mD(e,t,n){let i;function r(d){i=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function c(d,f){e.drawElements(i,f,s,d*a),n.update(f,i,1)}function l(d,f,h){if(h===0)return;e.drawElementsInstanced(i,f,s,d*a,h),n.update(f,i,h)}function u(d,f,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,f,0,s,d,0,h);let m=0;for(let g=0;g<h;g++)m+=f[g];n.update(m,i,1)}this.setMode=r,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function gD(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,a,o){switch(n.calls++,a){case e.TRIANGLES:n.triangles+=o*(s/3);break;case e.LINES:n.lines+=o*(s/2);break;case e.LINE_STRIP:n.lines+=o*(s-1);break;case e.LINE_LOOP:n.lines+=o*s;break;case e.POINTS:n.points+=o*s;break;default:Ze("WebGLInfo: Unknown draw mode:",a);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function bD(e,t,n){let i=new WeakMap,r=new Pt;function s(a,o,c){let l=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=u!==void 0?u.length:0,f=i.get(o);if(f===void 0||f.count!==d){let w=function(){A.dispose(),i.delete(o),o.removeEventListener("dispose",w)};if(f!==void 0)f.texture.dispose();let h=o.morphAttributes.position!==void 0,b=o.morphAttributes.normal!==void 0,m=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],x=o.morphAttributes.color||[],_=0;if(h===!0)_=1;if(b===!0)_=2;if(m===!0)_=3;let y=o.attributes.position.count*_,v=1;if(y>t.maxTextureSize)v=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize;let T=new Float32Array(y*v*4*d),A=new Td(T,y,v,d);A.type=Br,A.needsUpdate=!0;let E=_*4;for(let P=0;P<d;P++){let S=g[P],I=p[P],U=x[P],N=y*v*4*P;for(let F=0;F<S.count;F++){let D=F*E;if(h===!0)r.fromBufferAttribute(S,F),T[N+D+0]=r.x,T[N+D+1]=r.y,T[N+D+2]=r.z,T[N+D+3]=0;if(b===!0)r.fromBufferAttribute(I,F),T[N+D+4]=r.x,T[N+D+5]=r.y,T[N+D+6]=r.z,T[N+D+7]=0;if(m===!0)r.fromBufferAttribute(U,F),T[N+D+8]=r.x,T[N+D+9]=r.y,T[N+D+10]=r.z,T[N+D+11]=U.itemSize===4?r.w:1}}f={count:d,texture:A,size:new Ke(y,v)},i.set(o,f),o.addEventListener("dispose",w)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",a.morphTexture,n);else{let h=0;for(let m=0;m<l.length;m++)h+=l[m];let b=o.morphTargetsRelative?1:1-h;c.getUniforms().setValue(e,"morphTargetBaseInfluence",b),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",f.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",f.size)}return{update:s}}function xD(e,t,n,i,r){let s=new WeakMap;function a(l){let u=r.render.frame,d=l.geometry,f=t.get(l,d);if(s.get(f)!==u)t.update(f),s.set(f,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let h=l.skeleton;if(s.get(h)!==u)h.update(),s.set(h,u)}return f}function o(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:a,dispose:o}}function _D(e,t,n,i,r,s){let a=new ci(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),o=null,c=null,l=new Dn;l.setAttribute("position",new Wn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Wn([0,2,0,0,2,0],2));let u=new Dm({uniforms:{tDiffuse:{value:null}},vertexShader:`precision highp float;uniform mat4 modelViewMatrix;@@ -262,17 +266,17 @@ var _R=Object.create;var{getPrototypeOf:vR,defineProperty:gf,getOwnPropertyNames#ifdef SRGB_TRANSFERgl_FragColor = sRGBTransferOETF( gl_FragColor );#endif- }`,depthTest:!1,depthWrite:!1}),d=new jt(l,u),f=new Ta(-1,1,1,-1,0,1),h=null,y=null,g=!1,m,p=null,b=[],_=!1;this.setSize=function(x,v){if(a.setSize(x,v),o!==null)o.setSize(x,v);if(c!==null)c.setSize(x,v);for(let E=0;E<b.length;E++){let S=b[E];if(S.setSize)S.setSize(x,v)}},this.setEffects=function(x){b=x,_=b.length>0&&b[0].isRenderPass===!0;let{width:v,height:E}=a;if(b.length>0&&o===null)o=new ai(v,E,{type:dr,depthBuffer:!1,stencilBuffer:!1}),c=new ai(v,E,{type:dr,depthBuffer:!1,stencilBuffer:!1});for(let S=0;S<b.length;S++){let T=b[S];if(T.setSize)T.setSize(v,E)}},this.begin=function(x,v){if(g)return!1;if(x.toneMapping===Li&&b.length===0)return!1;if(p=v,v!==null){let{width:E,height:S}=v;if(a.width!==E||a.height!==S)this.setSize(E,S)}if(_===!1)x.setRenderTarget(a);return m=x.toneMapping,x.toneMapping=Li,!0},this.hasRenderPass=function(){return _},this.end=function(x,v){x.toneMapping=m,g=!0;let E=a,S=o;for(let T=0;T<b.length;T++){let A=b[T];if(A.enabled===!1)continue;if(A.render(x,S,E,v),A.needsSwap!==!1)E=S,S=S===o?c:o}if(h!==x.outputColorSpace||y!==x.toneMapping){if(h=x.outputColorSpace,y=x.toneMapping,u.defines={},ot.getTransfer(h)===Bt)u.defines.SRGB_TRANSFER="";let T=zk[y];if(T)u.defines[T]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=E.texture,x.setRenderTarget(p),x.render(d,f),p=null,g=!1},this.isCompositing=function(){return g},this.dispose=function(){if(a.dispose(),o!==null)o.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}function ko(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=BT[r];if(s===void 0)s=new Float32Array(r),BT[r]=s;if(t!==0){i.toArray(s,0);for(let a=1,o=0;a!==t;++a)o+=n,e[a].toArray(s,o)}return s}function pn(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function mn(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Md(e,t){let n=zT[t];if(n===void 0)n=new Int32Array(t),zT[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function jk(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function Hk(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(pn(n,t))return;e.uniform2fv(this.addr,t),mn(n,t)}}function Gk(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if(pn(n,t))return;e.uniform3fv(this.addr,t),mn(n,t)}}function $k(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(pn(n,t))return;e.uniform4fv(this.addr,t),mn(n,t)}}function Kk(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(pn(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),mn(n,t)}else{if(pn(n,i))return;HT.set(i),e.uniformMatrix2fv(this.addr,!1,HT),mn(n,i)}}function Wk(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(pn(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),mn(n,t)}else{if(pn(n,i))return;jT.set(i),e.uniformMatrix3fv(this.addr,!1,jT),mn(n,i)}}function Xk(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(pn(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),mn(n,t)}else{if(pn(n,i))return;VT.set(i),e.uniformMatrix4fv(this.addr,!1,VT),mn(n,i)}}function qk(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function Jk(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(pn(n,t))return;e.uniform2iv(this.addr,t),mn(n,t)}}function Zk(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(pn(n,t))return;e.uniform3iv(this.addr,t),mn(n,t)}}function Yk(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(pn(n,t))return;e.uniform4iv(this.addr,t),mn(n,t)}}function Qk(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function eD(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(pn(n,t))return;e.uniform2uiv(this.addr,t),mn(n,t)}}function tD(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(pn(n,t))return;e.uniform3uiv(this.addr,t),mn(n,t)}}function nD(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(pn(n,t))return;e.uniform4uiv(this.addr,t),mn(n,t)}}function iD(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;let s;if(this.type===e.SAMPLER_2D_SHADOW)Hm.compareFunction=n.isReversedDepthBuffer()?sd:rd,s=Hm;else s=rA;n.setTexture2D(t||s,r)}function rD(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture3D(t||aA,r)}function sD(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTextureCube(t||oA,r)}function aD(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture2DArray(t||sA,r)}function oD(e){switch(e){case 5126:return jk;case 35664:return Hk;case 35665:return Gk;case 35666:return $k;case 35674:return Kk;case 35675:return Wk;case 35676:return Xk;case 5124:case 35670:return qk;case 35667:case 35671:return Jk;case 35668:case 35672:return Zk;case 35669:case 35673:return Yk;case 5125:return Qk;case 36294:return eD;case 36295:return tD;case 36296:return nD;case 35678:case 36198:case 36298:case 36306:case 35682:return iD;case 35679:case 36299:case 36307:return rD;case 35680:case 36300:case 36308:case 36293:return sD;case 36289:case 36303:case 36311:case 36292:return aD}}function cD(e,t){e.uniform1fv(this.addr,t)}function lD(e,t){let n=ko(t,this.size,2);e.uniform2fv(this.addr,n)}function uD(e,t){let n=ko(t,this.size,3);e.uniform3fv(this.addr,n)}function dD(e,t){let n=ko(t,this.size,4);e.uniform4fv(this.addr,n)}function fD(e,t){let n=ko(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function hD(e,t){let n=ko(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function pD(e,t){let n=ko(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function mD(e,t){e.uniform1iv(this.addr,t)}function gD(e,t){e.uniform2iv(this.addr,t)}function bD(e,t){e.uniform3iv(this.addr,t)}function yD(e,t){e.uniform4iv(this.addr,t)}function xD(e,t){e.uniform1uiv(this.addr,t)}function _D(e,t){e.uniform2uiv(this.addr,t)}function vD(e,t){e.uniform3uiv(this.addr,t)}function ED(e,t){e.uniform4uiv(this.addr,t)}function TD(e,t,n){let i=this.cache,r=t.length,s=Md(n,r);if(!pn(i,s))e.uniform1iv(this.addr,s),mn(i,s);let a;if(this.type===e.SAMPLER_2D_SHADOW)a=Hm;else a=rA;for(let o=0;o!==r;++o)n.setTexture2D(t[o]||a,s[o])}function AD(e,t,n){let i=this.cache,r=t.length,s=Md(n,r);if(!pn(i,s))e.uniform1iv(this.addr,s),mn(i,s);for(let a=0;a!==r;++a)n.setTexture3D(t[a]||aA,s[a])}function SD(e,t,n){let i=this.cache,r=t.length,s=Md(n,r);if(!pn(i,s))e.uniform1iv(this.addr,s),mn(i,s);for(let a=0;a!==r;++a)n.setTextureCube(t[a]||oA,s[a])}function wD(e,t,n){let i=this.cache,r=t.length,s=Md(n,r);if(!pn(i,s))e.uniform1iv(this.addr,s),mn(i,s);for(let a=0;a!==r;++a)n.setTexture2DArray(t[a]||sA,s[a])}function MD(e){switch(e){case 5126:return cD;case 35664:return lD;case 35665:return uD;case 35666:return dD;case 35674:return fD;case 35675:return hD;case 35676:return pD;case 5124:case 35670:return mD;case 35667:case 35671:return gD;case 35668:case 35672:return bD;case 35669:case 35673:return yD;case 5125:return xD;case 36294:return _D;case 36295:return vD;case 36296:return ED;case 35678:case 36198:case 36298:case 36306:case 35682:return TD;case 35679:case 36299:case 36307:return AD;case 35680:case 36300:case 36308:case 36293:return SD;case 36289:case 36303:case 36311:case 36292:return wD}}class cA{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=oD(t.type)}}class lA{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=MD(t.type)}}class uA{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let a=i[r];a.setValue(e,t[a.id],n)}}}function GT(e,t){e.seq.push(t),e.map[t.id]=t}function RD(e,t,n){let i=e.name,r=i.length;Vm.lastIndex=0;while(!0){let s=Vm.exec(i),a=Vm.lastIndex,o=s[1],c=s[2]==="]",l=s[3];if(c)o=o|0;if(l===void 0||l==="["&&a+2===r){GT(n,l===void 0?new cA(o,e,t):new lA(o,e,t));break}else{let d=n.map[o];if(d===void 0)d=new uA(o),GT(n,d);n=d}}}class rl{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let a=e.getActiveUniform(t,s),o=e.getUniformLocation(t,a.name);RD(a,o,this)}let i=[],r=[];for(let s of this.seq)if(s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(s);else r.push(s);if(i.length>0)this.seq=i.concat(r)}setValue(e,t,n,i){let r=this.map[t];if(r!==void 0)r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){let a=t[r],o=n[a.id];if(o.needsUpdate!==!1)a.setValue(e,o.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let s=e[i];if(s.id in t)n.push(s)}return n}}function $T(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}function ND(e,t){let n=e.split(`+ }`,depthTest:!1,depthWrite:!1}),d=new jt(l,u),f=new Ra(-1,1,1,-1,0,1),h=null,b=null,m=!1,g,p=null,x=[],_=!1;this.setSize=function(y,v){if(a.setSize(y,v),o!==null)o.setSize(y,v);if(c!==null)c.setSize(y,v);for(let T=0;T<x.length;T++){let A=x[T];if(A.setSize)A.setSize(y,v)}},this.setEffects=function(y){x=y,_=x.length>0&&x[0].isRenderPass===!0;let{width:v,height:T}=a;if(x.length>0&&o===null)o=new ci(v,T,{type:hr,depthBuffer:!1,stencilBuffer:!1}),c=new ci(v,T,{type:hr,depthBuffer:!1,stencilBuffer:!1});for(let A=0;A<x.length;A++){let E=x[A];if(E.setSize)E.setSize(v,T)}},this.begin=function(y,v){if(m)return!1;if(y.toneMapping===Ui&&x.length===0)return!1;if(p=v,v!==null){let{width:T,height:A}=v;if(a.width!==T||a.height!==A)this.setSize(T,A)}if(_===!1)y.setRenderTarget(a);return g=y.toneMapping,y.toneMapping=Ui,!0},this.hasRenderPass=function(){return _},this.end=function(y,v){y.toneMapping=g,m=!0;let T=a,A=o;for(let E=0;E<x.length;E++){let w=x[E];if(w.enabled===!1)continue;if(w.render(y,A,T,v),w.needsSwap!==!1)T=A,A=A===o?c:o}if(h!==y.outputColorSpace||b!==y.toneMapping){if(h=y.outputColorSpace,b=y.toneMapping,u.defines={},ot.getTransfer(h)===Bt)u.defines.SRGB_TRANSFER="";let E=yD[b];if(E)u.defines[E]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=T.texture,y.setRenderTarget(p),y.render(d,f),p=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){if(a.dispose(),o!==null)o.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}function jo(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=rA[r];if(s===void 0)s=new Float32Array(r),rA[r]=s;if(t!==0){i.toArray(s,0);for(let a=1,o=0;a!==t;++a)o+=n,e[a].toArray(s,o)}return s}function pn(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function mn(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Gd(e,t){let n=sA[t];if(n===void 0)n=new Int32Array(t),sA[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function vD(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function ED(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(pn(n,t))return;e.uniform2fv(this.addr,t),mn(n,t)}}function TD(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if(pn(n,t))return;e.uniform3fv(this.addr,t),mn(n,t)}}function AD(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(pn(n,t))return;e.uniform4fv(this.addr,t),mn(n,t)}}function wD(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(pn(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),mn(n,t)}else{if(pn(n,i))return;cA.set(i),e.uniformMatrix2fv(this.addr,!1,cA),mn(n,i)}}function SD(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(pn(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),mn(n,t)}else{if(pn(n,i))return;oA.set(i),e.uniformMatrix3fv(this.addr,!1,oA),mn(n,i)}}function MD(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(pn(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),mn(n,t)}else{if(pn(n,i))return;aA.set(i),e.uniformMatrix4fv(this.addr,!1,aA),mn(n,i)}}function RD(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function ID(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(pn(n,t))return;e.uniform2iv(this.addr,t),mn(n,t)}}function CD(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(pn(n,t))return;e.uniform3iv(this.addr,t),mn(n,t)}}function ND(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(pn(n,t))return;e.uniform4iv(this.addr,t),mn(n,t)}}function PD(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function OD(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(pn(n,t))return;e.uniform2uiv(this.addr,t),mn(n,t)}}function kD(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(pn(n,t))return;e.uniform3uiv(this.addr,t),mn(n,t)}}function DD(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(pn(n,t))return;e.uniform4uiv(this.addr,t),mn(n,t)}}function LD(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;let s;if(this.type===e.SAMPLER_2D_SHADOW)rg.compareFunction=n.isReversedDepthBuffer()?Ed:vd,s=rg;else s=TA;n.setTexture2D(t||s,r)}function FD(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture3D(t||wA,r)}function UD(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTextureCube(t||SA,r)}function BD(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture2DArray(t||AA,r)}function zD(e){switch(e){case 5126:return vD;case 35664:return ED;case 35665:return TD;case 35666:return AD;case 35674:return wD;case 35675:return SD;case 35676:return MD;case 5124:case 35670:return RD;case 35667:case 35671:return ID;case 35668:case 35672:return CD;case 35669:case 35673:return ND;case 5125:return PD;case 36294:return OD;case 36295:return kD;case 36296:return DD;case 35678:case 36198:case 36298:case 36306:case 35682:return LD;case 35679:case 36299:case 36307:return FD;case 35680:case 36300:case 36308:case 36293:return UD;case 36289:case 36303:case 36311:case 36292:return BD}}function VD(e,t){e.uniform1fv(this.addr,t)}function jD(e,t){let n=jo(t,this.size,2);e.uniform2fv(this.addr,n)}function HD(e,t){let n=jo(t,this.size,3);e.uniform3fv(this.addr,n)}function GD(e,t){let n=jo(t,this.size,4);e.uniform4fv(this.addr,n)}function $D(e,t){let n=jo(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function KD(e,t){let n=jo(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function WD(e,t){let n=jo(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function XD(e,t){e.uniform1iv(this.addr,t)}function qD(e,t){e.uniform2iv(this.addr,t)}function JD(e,t){e.uniform3iv(this.addr,t)}function ZD(e,t){e.uniform4iv(this.addr,t)}function YD(e,t){e.uniform1uiv(this.addr,t)}function QD(e,t){e.uniform2uiv(this.addr,t)}function eL(e,t){e.uniform3uiv(this.addr,t)}function tL(e,t){e.uniform4uiv(this.addr,t)}function nL(e,t,n){let i=this.cache,r=t.length,s=Gd(n,r);if(!pn(i,s))e.uniform1iv(this.addr,s),mn(i,s);let a;if(this.type===e.SAMPLER_2D_SHADOW)a=rg;else a=TA;for(let o=0;o!==r;++o)n.setTexture2D(t[o]||a,s[o])}function iL(e,t,n){let i=this.cache,r=t.length,s=Gd(n,r);if(!pn(i,s))e.uniform1iv(this.addr,s),mn(i,s);for(let a=0;a!==r;++a)n.setTexture3D(t[a]||wA,s[a])}function rL(e,t,n){let i=this.cache,r=t.length,s=Gd(n,r);if(!pn(i,s))e.uniform1iv(this.addr,s),mn(i,s);for(let a=0;a!==r;++a)n.setTextureCube(t[a]||SA,s[a])}function sL(e,t,n){let i=this.cache,r=t.length,s=Gd(n,r);if(!pn(i,s))e.uniform1iv(this.addr,s),mn(i,s);for(let a=0;a!==r;++a)n.setTexture2DArray(t[a]||AA,s[a])}function aL(e){switch(e){case 5126:return VD;case 35664:return jD;case 35665:return HD;case 35666:return GD;case 35674:return $D;case 35675:return KD;case 35676:return WD;case 5124:case 35670:return XD;case 35667:case 35671:return qD;case 35668:case 35672:return JD;case 35669:case 35673:return ZD;case 5125:return YD;case 36294:return QD;case 36295:return eL;case 36296:return tL;case 35678:case 36198:case 36298:case 36306:case 35682:return nL;case 35679:case 36299:case 36307:return iL;case 35680:case 36300:case 36308:case 36293:return rL;case 36289:case 36303:case 36311:case 36292:return sL}}class MA{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=zD(t.type)}}class RA{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=aL(t.type)}}class IA{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let a=i[r];a.setValue(e,t[a.id],n)}}}function lA(e,t){e.seq.push(t),e.map[t.id]=t}function oL(e,t,n){let i=e.name,r=i.length;ng.lastIndex=0;while(!0){let s=ng.exec(i),a=ng.lastIndex,o=s[1],c=s[2]==="]",l=s[3];if(c)o=o|0;if(l===void 0||l==="["&&a+2===r){lA(n,l===void 0?new MA(o,e,t):new RA(o,e,t));break}else{let d=n.map[o];if(d===void 0)d=new IA(o),lA(n,d);n=d}}}class gl{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let a=e.getActiveUniform(t,s),o=e.getUniformLocation(t,a.name);oL(a,o,this)}let i=[],r=[];for(let s of this.seq)if(s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(s);else r.push(s);if(i.length>0)this.seq=i.concat(r)}setValue(e,t,n,i){let r=this.map[t];if(r!==void 0)r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){let a=t[r],o=n[a.id];if(o.needsUpdate!==!1)a.setValue(e,o.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let s=e[i];if(s.id in t)n.push(s)}return n}}function uA(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}function uL(e,t){let n=e.split(``),i=[],r=Math.max(t-6,0),s=Math.min(t+6,n.length);for(let a=r;a<s;a++){let o=a+1;i.push(`${o===t?">":" "} ${o}: ${n[a]}`)}return i.join(`-`)}function PD(e){ot._getMatrix(KT,ot.workingColorSpace,e);let t=`mat3( ${KT.elements.map((n)=>n.toFixed(4))} )`;switch(ot.getTransfer(e)){case dm:return[t,"LinearTransferOETF"];case Bt:return[t,"sRGBTransferOETF"];default:return je("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function WT(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let a=/ERROR: 0:(\d+)/.exec(s);if(a){let o=parseInt(a[1]);return n.toUpperCase()+`+`)}function dL(e){ot._getMatrix(dA,ot.workingColorSpace,e);let t=`mat3( ${dA.elements.map((n)=>n.toFixed(4))} )`;switch(ot.getTransfer(e)){case Sm:return[t,"LinearTransferOETF"];case Bt:return[t,"sRGBTransferOETF"];default:return je("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function fA(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let a=/ERROR: 0:(\d+)/.exec(s);if(a){let o=parseInt(a[1]);return n.toUpperCase()+``+s+`-`+ND(e.getShaderSource(t),o)}else return s}function OD(e,t){let n=PD(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`-`)}function DD(e,t){let n=kD[t];if(n===void 0)return je("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function LD(){ot.getLuminanceCoefficients(Sd);let e=Sd.x.toFixed(4),t=Sd.y.toFixed(4),n=Sd.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`-`)}function FD(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(il).join(`-`)}function UD(e){let t=[];for(let n in e){let i=e[n];if(i===!1)continue;t.push("#define "+n+" "+i)}return t.join(`-`)}function BD(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),a=s.name,o=1;if(s.type===e.FLOAT_MAT2)o=2;if(s.type===e.FLOAT_MAT3)o=3;if(s.type===e.FLOAT_MAT4)o=4;n[a]={type:s.type,location:e.getAttribLocation(t,a),locationSize:o}}return n}function il(e){return e!==""}function XT(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function qT(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}function Gm(e){return e.replace(zD,jD)}function jD(e,t){let n=st[t];if(n===void 0){let i=VD.get(t);if(i!==void 0)n=st[i],je('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Gm(n)}function JT(e){return e.replace(HD,GD)}function GD(e,t,n,i){let r="";for(let s=parseInt(t);s<parseInt(n);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function ZT(e){let t=`precision ${e.precision} float;+`+uL(e.getShaderSource(t),o)}else return s}function fL(e,t){let n=dL(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`+`)}function pL(e,t){let n=hL[t];if(n===void 0)return je("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function mL(){ot.getLuminanceCoefficients(jd);let e=jd.x.toFixed(4),t=jd.y.toFixed(4),n=jd.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`+`)}function gL(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ml).join(`+`)}function bL(e){let t=[];for(let n in e){let i=e[n];if(i===!1)continue;t.push("#define "+n+" "+i)}return t.join(`+`)}function xL(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),a=s.name,o=1;if(s.type===e.FLOAT_MAT2)o=2;if(s.type===e.FLOAT_MAT3)o=3;if(s.type===e.FLOAT_MAT4)o=4;n[a]={type:s.type,location:e.getAttribLocation(t,a),locationSize:o}}return n}function ml(e){return e!==""}function hA(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function pA(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}function sg(e){return e.replace(yL,vL)}function vL(e,t){let n=st[t];if(n===void 0){let i=_L.get(t);if(i!==void 0)n=st[i],je('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return sg(n)}function mA(e){return e.replace(EL,TL)}function TL(e,t,n,i){let r="";for(let s=parseInt(t);s<parseInt(n);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function gA(e){let t=`precision ${e.precision} float;precision ${e.precision} int;precision ${e.precision} sampler2D;precision ${e.precision} samplerCube;@@ -292,30 +296,30 @@ var _R=Object.create;var{getPrototypeOf:vR,defineProperty:gf,getOwnPropertyNames`;if(e.precision==="highp")t+=`#define HIGH_PRECISION`;else if(e.precision==="mediump")t+=`#define MEDIUM_PRECISION`;else if(e.precision==="lowp")t+=`-#define LOW_PRECISION`;return t}function KD(e){return $D[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}function XD(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return WD[e.envMapMode]||"ENVMAP_TYPE_CUBE"}function JD(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return qD[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}function YD(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return ZD[e.combine]||"ENVMAP_BLENDING_NONE"}function QD(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function eL(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:a,fragmentShader:o}=n,c=KD(n),l=XD(n),u=JD(n),d=YD(n),f=QD(n),h=FD(n),y=UD(s),g=r.createProgram(),m,p,b=n.glslVersion?"#version "+n.glslVersion+`-`:"";if(n.isRawShaderMaterial){if(m=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y].filter(il).join(`-`),m.length>0)m+=`-`;if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y].filter(il).join(`+#define LOW_PRECISION`;return t}function wL(e){return AL[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}function ML(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return SL[e.envMapMode]||"ENVMAP_TYPE_CUBE"}function IL(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return RL[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}function NL(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return CL[e.combine]||"ENVMAP_BLENDING_NONE"}function PL(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function OL(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:a,fragmentShader:o}=n,c=wL(n),l=ML(n),u=IL(n),d=NL(n),f=PL(n),h=gL(n),b=bL(s),m=r.createProgram(),g,p,x=n.glslVersion?"#version "+n.glslVersion+`+`:"";if(n.isRawShaderMaterial){if(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(ml).join(`+`),g.length>0)g+=`+`;if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(ml).join(``),p.length>0)p+=`-`}else m=[ZT(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&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 "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`-`].filter(il).join(`-`),p=[ZT(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",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?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Li?"#define TONE_MAPPING":"",n.toneMapping!==Li?st.tonemapping_pars_fragment:"",n.toneMapping!==Li?DD("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",st.colorspace_pars_fragment,OD("linearToOutputTexel",n.outputColorSpace),LD(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`-`].filter(il).join(`-`);if(a=Gm(a),a=XT(a,n),a=qT(a,n),o=Gm(o),o=XT(o,n),o=qT(o,n),a=JT(a),o=JT(o),n.isRawShaderMaterial!==!0)b=`#version 300 es-`,m=[h,"#define attribute in","#define varying out","#define texture2D texture"].join(`+`}else g=[gA(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 "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&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 "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`+`].filter(ml).join(`+`),p=[gA(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 "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",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?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Ui?"#define TONE_MAPPING":"",n.toneMapping!==Ui?st.tonemapping_pars_fragment:"",n.toneMapping!==Ui?pL("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",st.colorspace_pars_fragment,fL("linearToOutputTexel",n.outputColorSpace),mL(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`+`].filter(ml).join(`+`);if(a=sg(a),a=hA(a,n),a=pA(a,n),o=sg(o),o=hA(o,n),o=pA(o,n),a=mA(a),o=mA(o),n.isRawShaderMaterial!==!0)x=`#version 300 es+`,g=[h,"#define attribute in","#define varying out","#define texture2D texture"].join(``)+`-`+m,p=["#define varying in",n.glslVersion===fm?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===fm?"":"#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(`+`+g,p=["#define varying in",n.glslVersion===Mm?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Mm?"":"#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(``)+`-`+p;let _=b+m+a,x=b+p+o,v=$T(r,r.VERTEX_SHADER,_),E=$T(r,r.FRAGMENT_SHADER,x);if(r.attachShader(g,v),r.attachShader(g,E),n.index0AttributeName!==void 0)r.bindAttribLocation(g,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(g,0,"position");r.linkProgram(g);function S(w){if(e.debug.checkShaderErrors){let I=r.getProgramInfoLog(g)||"",F=r.getShaderInfoLog(v)||"",N=r.getShaderInfoLog(E)||"",U=I.trim(),D=F.trim(),O=N.trim(),K=!0,B=!0;if(r.getProgramParameter(g,r.LINK_STATUS)===!1)if(K=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,g,v,E);else{let X=WT(r,v,"vertex"),q=WT(r,E,"fragment");Ze("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(g,r.VALIDATE_STATUS)+`+`+p;let _=x+g+a,y=x+p+o,v=uA(r,r.VERTEX_SHADER,_),T=uA(r,r.FRAGMENT_SHADER,y);if(r.attachShader(m,v),r.attachShader(m,T),n.index0AttributeName!==void 0)r.bindAttribLocation(m,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(m,0,"position");r.linkProgram(m);function A(S){if(e.debug.checkShaderErrors){let I=r.getProgramInfoLog(m)||"",U=r.getShaderInfoLog(v)||"",N=r.getShaderInfoLog(T)||"",F=I.trim(),D=U.trim(),O=N.trim(),K=!0,B=!0;if(r.getProgramParameter(m,r.LINK_STATUS)===!1)if(K=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,m,v,T);else{let X=fA(r,v,"vertex"),q=fA(r,T,"fragment");Ze("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+`-Material Name: `+w.name+`-Material Type: `+w.type+`+Material Name: `+S.name+`+Material Type: `+S.type+`-Program Info Log: `+U+`+Program Info Log: `+F+``+X+`-`+q)}else if(U!=="")je("WebGLProgram: Program Info Log:",U);else if(D===""||O==="")B=!1;if(B)w.diagnostics={runnable:K,programLog:U,vertexShader:{log:D,prefix:m},fragmentShader:{log:O,prefix:p}}}r.deleteShader(v),r.deleteShader(E),T=new rl(r,g),A=BD(r,g)}let T;this.getUniforms=function(){if(T===void 0)S(this);return T};let A;this.getAttributes=function(){if(A===void 0)S(this);return A};let P=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(P===!1)P=r.getProgramParameter(g,ID);return P},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(g),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=CD++,this.cacheKey=t,this.usedTimes=1,this.program=g,this.vertexShader=v,this.fragmentShader=E,this}class dA{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new fA(e),t.set(e,n);return n}}class fA{constructor(e){this.id=tL++,this.code=e,this.usedTimes=0}}function nL(e){return e===ya||e===td||e===nd}function iL(e,t,n,i,r,s){let a=new od,o=new dA,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:d,precision:f}=i,h={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",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 y(T){if(c.add(T),T===0)return"uv";return`uv${T}`}function g(T,A,P,w,I,F){let N=w.fog,U=I.geometry,D=T.isMeshStandardMaterial||T.isMeshLambertMaterial||T.isMeshPhongMaterial?w.environment:null,O=T.isMeshStandardMaterial||T.isMeshLambertMaterial&&!T.envMap||T.isMeshPhongMaterial&&!T.envMap,K=t.get(T.envMap||D,O),B=!!K&&K.mapping===Fc?K.image.height:null,X=h[T.type];if(T.precision!==null){if(f=i.getMaxPrecision(T.precision),f!==T.precision)je("WebGLProgram.getParameters:",T.precision,"not supported, using",f,"instead.")}let q=U.morphAttributes.position||U.morphAttributes.normal||U.morphAttributes.color,le=q!==void 0?q.length:0,de=0;if(U.morphAttributes.position!==void 0)de=1;if(U.morphAttributes.normal!==void 0)de=2;if(U.morphAttributes.color!==void 0)de=3;let Me,pe,J,L;if(X){let zt=mr[X];Me=zt.vertexShader,pe=zt.fragmentShader}else{Me=T.vertexShader,pe=T.fragmentShader;let zt=o.getVertexShaderStage(T),wt=o.getFragmentShaderStage(T);o.update(T,zt,wt),J=zt.id,L=wt.id}let W=e.getRenderTarget(),te=e.state.buffers.depth.getReversed(),ie=I.isInstancedMesh===!0,ce=I.isBatchedMesh===!0,_e=!!T.map,Re=!!T.matcap,Oe=!!K,We=!!T.aoMap,Ye=!!T.lightMap,Kt=!!T.bumpMap&&T.wireframe===!1,lt=!!T.normalMap,Dt=!!T.displacementMap,Yt=!!T.emissiveMap,tn=!!T.metalnessMap,z=!!T.roughnessMap,xn=T.anisotropy>0,St=T.clearcoat>0,Wt=T.dispersion>0,C=T.retroreflectivity>0,M=T.iridescence>0,V=T.sheen>0,Q=T.transmission>0,he=xn&&!!T.anisotropyMap,ge=St&&!!T.clearcoatMap,ve=St&&!!T.clearcoatNormalMap,re=St&&!!T.clearcoatRoughnessMap,oe=M&&!!T.iridescenceMap,Ie=M&&!!T.iridescenceThicknessMap,Ve=V&&!!T.sheenColorMap,Ee=V&&!!T.sheenRoughnessMap,me=!!T.specularMap,Ge=!!T.specularColorMap,Xe=!!T.specularIntensityMap,_t=Q&&!!T.transmissionMap,G=Q&&!!T.thicknessMap,ye=!!T.gradientMap,ae=!!T.alphaMap,xe=T.alphaTest>0,Ce=!!T.alphaHash,fe=!!T.extensions,Ae=Li;if(T.toneMapped){if(W===null||W.isXRRenderTarget===!0)Ae=e.toneMapping}let it={shaderID:X,shaderType:T.type,shaderName:T.name,vertexShader:Me,fragmentShader:pe,defines:T.defines,customVertexShaderID:J,customFragmentShaderID:L,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:f,batching:ce,batchingColor:ce&&I._colorsTexture!==null,instancing:ie,instancingColor:ie&&I.instanceColor!==null,instancingMorph:ie&&I.morphTexture!==null,outputColorSpace:W===null?e.outputColorSpace:W.isXRRenderTarget===!0?W.texture.colorSpace:ot.workingColorSpace,alphaToCoverage:!!T.alphaToCoverage,map:_e,matcap:Re,envMap:Oe,envMapMode:Oe&&K.mapping,envMapCubeUVHeight:B,aoMap:We,lightMap:Ye,bumpMap:Kt,normalMap:lt,displacementMap:Dt,emissiveMap:Yt,normalMapObjectSpace:lt&&T.normalMapType===mT,normalMapTangentSpace:lt&&T.normalMapType===um,packedNormalMap:lt&&T.normalMapType===um&&nL(T.normalMap.format),metalnessMap:tn,roughnessMap:z,anisotropy:xn,anisotropyMap:he,clearcoat:St,clearcoatMap:ge,clearcoatNormalMap:ve,clearcoatRoughnessMap:re,dispersion:Wt,retroreflection:C,iridescence:M,iridescenceMap:oe,iridescenceThicknessMap:Ie,sheen:V,sheenColorMap:Ve,sheenRoughnessMap:Ee,specularMap:me,specularColorMap:Ge,specularIntensityMap:Xe,transmission:Q,transmissionMap:_t,thicknessMap:G,gradientMap:ye,opaque:T.transparent===!1&&T.blending===Dc&&T.alphaToCoverage===!1,alphaMap:ae,alphaTest:xe,alphaHash:Ce,combine:T.combine,mapUv:_e&&y(T.map.channel),aoMapUv:We&&y(T.aoMap.channel),lightMapUv:Ye&&y(T.lightMap.channel),bumpMapUv:Kt&&y(T.bumpMap.channel),normalMapUv:lt&&y(T.normalMap.channel),displacementMapUv:Dt&&y(T.displacementMap.channel),emissiveMapUv:Yt&&y(T.emissiveMap.channel),metalnessMapUv:tn&&y(T.metalnessMap.channel),roughnessMapUv:z&&y(T.roughnessMap.channel),anisotropyMapUv:he&&y(T.anisotropyMap.channel),clearcoatMapUv:ge&&y(T.clearcoatMap.channel),clearcoatNormalMapUv:ve&&y(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:re&&y(T.clearcoatRoughnessMap.channel),iridescenceMapUv:oe&&y(T.iridescenceMap.channel),iridescenceThicknessMapUv:Ie&&y(T.iridescenceThicknessMap.channel),sheenColorMapUv:Ve&&y(T.sheenColorMap.channel),sheenRoughnessMapUv:Ee&&y(T.sheenRoughnessMap.channel),specularMapUv:me&&y(T.specularMap.channel),specularColorMapUv:Ge&&y(T.specularColorMap.channel),specularIntensityMapUv:Xe&&y(T.specularIntensityMap.channel),transmissionMapUv:_t&&y(T.transmissionMap.channel),thicknessMapUv:G&&y(T.thicknessMap.channel),alphaMapUv:ae&&y(T.alphaMap.channel),vertexTangents:!!U.attributes.tangent&&(lt||xn),vertexNormals:!!U.attributes.normal,vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!U.attributes.color&&U.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!U.attributes.uv&&(_e||ae),fog:!!N,useFog:T.fog===!0,fogExp2:!!N&&N.isFogExp2,flatShading:T.wireframe===!1&&(T.flatShading===!0||U.attributes.normal===void 0&<===!1&&(T.isMeshLambertMaterial||T.isMeshPhongMaterial||T.isMeshStandardMaterial||T.isMeshPhysicalMaterial)),sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:te,skinning:I.isSkinnedMesh===!0,hasPositionAttribute:U.attributes.position!==void 0,morphTargets:U.morphAttributes.position!==void 0,morphNormals:U.morphAttributes.normal!==void 0,morphColors:U.morphAttributes.color!==void 0,morphTargetsCount:le,morphTextureStride:de,numSunLights:A.sun.length,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numSunLightShadows:A.sunShadowMap.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:F.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:T.dithering,shadowMapEnabled:e.shadowMap.enabled&&P.length>0,shadowMapType:e.shadowMap.type,toneMapping:Ae,decodeVideoTexture:_e&&T.map.isVideoTexture===!0&&ot.getTransfer(T.map.colorSpace)===Bt,decodeVideoTextureEmissive:Yt&&T.emissiveMap.isVideoTexture===!0&&ot.getTransfer(T.emissiveMap.colorSpace)===Bt,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===xi,flipSided:T.side===Pn,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionClipCullDistance:fe&&T.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(fe&&T.extensions.multiDraw===!0||ce)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:T.customProgramCacheKey()};return it.vertexUv1s=c.has(1),it.vertexUv2s=c.has(2),it.vertexUv3s=c.has(3),c.clear(),it}function m(T){let A=[];if(T.shaderID)A.push(T.shaderID);else A.push(T.customVertexShaderID),A.push(T.customFragmentShaderID);if(T.defines!==void 0)for(let P in T.defines)A.push(P),A.push(T.defines[P]);if(T.isRawShaderMaterial===!1)p(A,T),b(A,T),A.push(e.outputColorSpace);return A.push(T.customProgramCacheKey),A.join()}function p(T,A){T.push(A.precision),T.push(A.outputColorSpace),T.push(A.envMapMode),T.push(A.envMapCubeUVHeight),T.push(A.mapUv),T.push(A.alphaMapUv),T.push(A.lightMapUv),T.push(A.aoMapUv),T.push(A.bumpMapUv),T.push(A.normalMapUv),T.push(A.displacementMapUv),T.push(A.emissiveMapUv),T.push(A.metalnessMapUv),T.push(A.roughnessMapUv),T.push(A.anisotropyMapUv),T.push(A.clearcoatMapUv),T.push(A.clearcoatNormalMapUv),T.push(A.clearcoatRoughnessMapUv),T.push(A.iridescenceMapUv),T.push(A.iridescenceThicknessMapUv),T.push(A.sheenColorMapUv),T.push(A.sheenRoughnessMapUv),T.push(A.specularMapUv),T.push(A.specularColorMapUv),T.push(A.specularIntensityMapUv),T.push(A.transmissionMapUv),T.push(A.thicknessMapUv),T.push(A.combine),T.push(A.fogExp2),T.push(A.sizeAttenuation),T.push(A.morphTargetsCount),T.push(A.morphAttributeCount),T.push(A.numSunLights),T.push(A.numDirLights),T.push(A.numPointLights),T.push(A.numSpotLights),T.push(A.numSpotLightMaps),T.push(A.numHemiLights),T.push(A.numRectAreaLights),T.push(A.numSunLightShadows),T.push(A.numDirLightShadows),T.push(A.numPointLightShadows),T.push(A.numSpotLightShadows),T.push(A.numSpotLightShadowsWithMaps),T.push(A.numLightProbes),T.push(A.shadowMapType),T.push(A.toneMapping),T.push(A.numClippingPlanes),T.push(A.numClipIntersection),T.push(A.depthPacking)}function b(T,A){if(a.disableAll(),A.instancing)a.enable(0);if(A.instancingColor)a.enable(1);if(A.instancingMorph)a.enable(2);if(A.matcap)a.enable(3);if(A.envMap)a.enable(4);if(A.normalMapObjectSpace)a.enable(5);if(A.normalMapTangentSpace)a.enable(6);if(A.clearcoat)a.enable(7);if(A.iridescence)a.enable(8);if(A.alphaTest)a.enable(9);if(A.vertexColors)a.enable(10);if(A.vertexAlphas)a.enable(11);if(A.vertexUv1s)a.enable(12);if(A.vertexUv2s)a.enable(13);if(A.vertexUv3s)a.enable(14);if(A.vertexTangents)a.enable(15);if(A.anisotropy)a.enable(16);if(A.alphaHash)a.enable(17);if(A.batching)a.enable(18);if(A.dispersion)a.enable(19);if(A.retroreflection)a.enable(24);if(A.batchingColor)a.enable(20);if(A.gradientMap)a.enable(21);if(A.packedNormalMap)a.enable(22);if(A.vertexNormals)a.enable(23);if(T.push(a.mask),a.disableAll(),A.fog)a.enable(0);if(A.useFog)a.enable(1);if(A.flatShading)a.enable(2);if(A.logarithmicDepthBuffer)a.enable(3);if(A.reversedDepthBuffer)a.enable(4);if(A.skinning)a.enable(5);if(A.morphTargets)a.enable(6);if(A.morphNormals)a.enable(7);if(A.morphColors)a.enable(8);if(A.premultipliedAlpha)a.enable(9);if(A.shadowMapEnabled)a.enable(10);if(A.doubleSided)a.enable(11);if(A.flipSided)a.enable(12);if(A.useDepthPacking)a.enable(13);if(A.dithering)a.enable(14);if(A.transmission)a.enable(15);if(A.sheen)a.enable(16);if(A.opaque)a.enable(17);if(A.pointsUvs)a.enable(18);if(A.decodeVideoTexture)a.enable(19);if(A.decodeVideoTextureEmissive)a.enable(20);if(A.alphaToCoverage)a.enable(21);if(A.numLightProbeGrids>0)a.enable(22);if(A.hasPositionAttribute)a.enable(23);T.push(a.mask)}function _(T){let A=h[T.type],P;if(A){let w=mr[A];P=MT.clone(w.uniforms)}else P=T.uniforms;return P}function x(T,A){let P=u.get(A);if(P!==void 0)++P.usedTimes;else P=new eL(e,A,T,r),l.push(P),u.set(A,P);return P}function v(T){if(--T.usedTimes===0){let A=l.indexOf(T);l[A]=l[l.length-1],l.pop(),u.delete(T.cacheKey),T.destroy()}}function E(T){o.remove(T)}function S(){o.dispose()}return{getParameters:g,getProgramCacheKey:m,getUniforms:_,acquireProgram:x,releaseProgram:v,releaseShaderCache:E,programs:l,dispose:S}}function rL(){let e=new WeakMap;function t(a){return e.has(a)}function n(a){let o=e.get(a);if(o===void 0)o={},e.set(a,o);return o}function i(a){e.delete(a)}function r(a,o,c){e.get(a)[o]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function sL(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function YT(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function QT(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function a(f){let h=0;if(f.isInstancedMesh)h+=2;if(f.isSkinnedMesh)h+=1;return h}function o(f,h,y,g,m,p){let b=e[t];if(b===void 0)b={id:f.id,object:f,geometry:h,material:y,materialVariant:a(f),groupOrder:g,renderOrder:f.renderOrder,z:m,group:p},e[t]=b;else b.id=f.id,b.object=f,b.geometry=h,b.material=y,b.materialVariant=a(f),b.groupOrder=g,b.renderOrder=f.renderOrder,b.z=m,b.group=p;return t++,b}function c(f,h,y,g,m,p,b){if(b.reversedDepth===!0)m=-m;let _=o(f,h,y,g,m,p);if(y.transmission>0)i.push(_);else if(y.transparent===!0)r.push(_);else n.push(_)}function l(f,h,y,g,m,p){let b=o(f,h,y,g,m,p);if(y.transmission>0)i.unshift(b);else if(y.transparent===!0)r.unshift(b);else n.unshift(b)}function u(f,h){if(n.length>1)n.sort(f||sL);if(i.length>1)i.sort(h||YT);if(r.length>1)r.sort(h||YT)}function d(){for(let f=t,h=e.length;f<h;f++){let y=e[f];if(y.id===null)break;y.id=null,y.object=null,y.geometry=null,y.material=null,y.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:d,sort:u}}function aL(){let e=new WeakMap;function t(i,r){let s=e.get(i),a;if(s===void 0)a=new QT,e.set(i,[a]);else if(r>=s.length)a=new QT,s.push(a);else a=s[r];return a}function n(){e=new WeakMap}return{get:t,dispose:n}}function oL(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new j,color:new qe};break;case"SpotLight":n={position:new j,direction:new j,color:new qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new j,color:new qe,distance:0,decay:0};break;case"HemisphereLight":n={direction:new j,skyColor:new qe,groundColor:new qe};break;case"RectAreaLight":n={color:new qe,position:new j,halfWidth:new j,halfHeight:new j};break}return e[t.id]=n,n}}}function cL(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ke};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ke};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ke,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}function uL(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function dL(e){let t=new oL,n=cL(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],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 l=0;l<9;l++)i.probe.push(new j);let r=new j,s=new Qe,a=new Qe;function o(l){let u=0,d=0,f=0;for(let I=0;I<9;I++)i.probe[I].set(0,0,0);let h=0,y=0,g=0,m=0,p=0,b=0,_=0,x=0,v=0,E=0,S=0,T=0,A=0,P=0;l.sort(uL);for(let I=0,F=l.length;I<F;I++){let N=l[I],{color:U,intensity:D,distance:O}=N,K=null;if(N.shadow&&N.shadow.map)if(N.shadow.map.texture.format===ya)K=N.shadow.map.texture;else K=N.shadow.map.depthTexture||N.shadow.map.texture;if(N.isAmbientLight)u+=U.r*D,d+=U.g*D,f+=U.b*D;else if(N.isLightProbe){for(let B=0;B<9;B++)i.probe[B].addScaledVector(N.sh.coefficients[B],D);P++}else if(N.isSunLight){let B=t.get(N);if(B.color.copy(N.color).multiplyScalar(N.intensity),N.castShadow){let X=N.shadow,q=n.get(N);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize.copy(X.mapSize).multiply(X.getFrameExtents()),i.sunShadow[y]=q,i.sunShadowMap[y]=K;let le=X.getViewportCount();for(let de=0;de<le;de++)i.sunShadowMatrix[g+de]=X.getMatrix(de),i.sunShadowCascade[g+de]=X._cascadeData[de];g+=le,y++}i.sun[h]=B,h++}else if(N.isDirectionalLight){let B=t.get(N);if(B.color.copy(N.color).multiplyScalar(N.intensity),N.castShadow){let X=N.shadow,q=n.get(N);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize=X.mapSize,i.directionalShadow[m]=q,i.directionalShadowMap[m]=K,i.directionalShadowMatrix[m]=N.shadow.matrix,v++}i.directional[m]=B,m++}else if(N.isSpotLight){let B=t.get(N);B.position.setFromMatrixPosition(N.matrixWorld),B.color.copy(U).multiplyScalar(D),B.distance=O,B.coneCos=Math.cos(N.angle),B.penumbraCos=Math.cos(N.angle*(1-N.penumbra)),B.decay=N.decay,i.spot[b]=B;let X=N.shadow;if(N.map){if(i.spotLightMap[T]=N.map,T++,X.updateMatrices(N),N.castShadow)A++}if(i.spotLightMatrix[b]=X.matrix,N.castShadow){let q=n.get(N);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize=X.mapSize,i.spotShadow[b]=q,i.spotShadowMap[b]=K,S++}b++}else if(N.isRectAreaLight){let B=t.get(N);B.color.copy(U).multiplyScalar(D),B.halfWidth.set(N.width*0.5,0,0),B.halfHeight.set(0,N.height*0.5,0),i.rectArea[_]=B,_++}else if(N.isPointLight){let B=t.get(N);if(B.color.copy(N.color).multiplyScalar(N.intensity),B.distance=N.distance,B.decay=N.decay,N.castShadow){let X=N.shadow,q=n.get(N);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize=X.mapSize,q.shadowCameraNear=X.camera.near,q.shadowCameraFar=X.camera.far,i.pointShadow[p]=q,i.pointShadowMap[p]=K,i.pointShadowMatrix[p]=N.shadow.matrix,E++}i.point[p]=B,p++}else if(N.isHemisphereLight){let B=t.get(N);B.skyColor.copy(N.color).multiplyScalar(D),B.groundColor.copy(N.groundColor).multiplyScalar(D),i.hemi[x]=B,x++}}if(_>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=Te.LTC_FLOAT_1,i.rectAreaLTC2=Te.LTC_FLOAT_2;else i.rectAreaLTC1=Te.LTC_HALF_1,i.rectAreaLTC2=Te.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=f;let w=i.hash;if(w.sunLength!==h||w.directionalLength!==m||w.pointLength!==p||w.spotLength!==b||w.rectAreaLength!==_||w.hemiLength!==x||w.numSunShadows!==y||w.numDirectionalShadows!==v||w.numPointShadows!==E||w.numSpotShadows!==S||w.numSpotMaps!==T||w.numLightProbes!==P)i.sun.length=h,i.directional.length=m,i.spot.length=b,i.rectArea.length=_,i.point.length=p,i.hemi.length=x,i.sunShadow.length=y,i.sunShadowMap.length=y,i.sunShadowMatrix.length=g,i.sunShadowCascade.length=g,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.directionalShadowMatrix.length=v,i.pointShadow.length=E,i.pointShadowMap.length=E,i.pointShadowMatrix.length=E,i.spotShadow.length=S,i.spotShadowMap.length=S,i.spotLightMatrix.length=S+T-A,i.spotLightMap.length=T,i.numSpotLightShadowsWithMaps=A,i.numLightProbes=P,w.sunLength=h,w.directionalLength=m,w.pointLength=p,w.spotLength=b,w.rectAreaLength=_,w.hemiLength=x,w.numSunShadows=y,w.numDirectionalShadows=v,w.numPointShadows=E,w.numSpotShadows=S,w.numSpotMaps=T,w.numLightProbes=P,i.version=lL++}function c(l,u){let d=0,f=0,h=0,y=0,g=0,m=0,p=u.matrixWorldInverse;for(let b=0,_=l.length;b<_;b++){let x=l[b];if(x.isSunLight){let v=i.sun[d];v.direction.setFromMatrixPosition(x.matrixWorld),v.direction.transformDirection(p),d++}else if(x.isDirectionalLight){let v=i.directional[f];v.direction.setFromMatrixPosition(x.matrixWorld),r.setFromMatrixPosition(x.target.matrixWorld),v.direction.sub(r),v.direction.transformDirection(p),f++}else if(x.isSpotLight){let v=i.spot[y];v.position.setFromMatrixPosition(x.matrixWorld),v.position.applyMatrix4(p),v.direction.setFromMatrixPosition(x.matrixWorld),r.setFromMatrixPosition(x.target.matrixWorld),v.direction.sub(r),v.direction.transformDirection(p),y++}else if(x.isRectAreaLight){let v=i.rectArea[g];v.position.setFromMatrixPosition(x.matrixWorld),v.position.applyMatrix4(p),a.identity(),s.copy(x.matrixWorld),s.premultiply(p),a.extractRotation(s),v.halfWidth.set(x.width*0.5,0,0),v.halfHeight.set(0,x.height*0.5,0),v.halfWidth.applyMatrix4(a),v.halfHeight.applyMatrix4(a),g++}else if(x.isPointLight){let v=i.point[h];v.position.setFromMatrixPosition(x.matrixWorld),v.position.applyMatrix4(p),h++}else if(x.isHemisphereLight){let v=i.hemi[m];v.direction.setFromMatrixPosition(x.matrixWorld),v.direction.transformDirection(p),m++}}}return{setup:o,setupView:c,state:i}}function eA(e){let t=new dL(e),n=[],i=[],r=[];function s(f){d.camera=f,n.length=0,i.length=0,r.length=0}function a(f){n.push(f)}function o(f){i.push(f)}function c(f){r.push(f)}function l(){t.setup(n)}function u(f){t.setupView(n,f)}let d={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:d,setupLights:l,setupLightsView:u,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function fL(e){let t=new WeakMap;function n(r,s=0){let a=t.get(r),o;if(a===void 0)o=new eA(e),t.set(r,[o]);else if(s>=a.length)o=new eA(e),a.push(o);else o=a[s];return o}function i(){t=new WeakMap}return{get:n,dispose:i}}function bL(e,t,n){let i=new Wc,r=new Ke,s=new Ke,a=new Nt,o=new vm,c=new Em,l={},u=n.maxTextureSize,d={[us]:Pn,[Pn]:us,[xi]:xi},f=new _i({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ke},radius:{value:4}},vertexShader:hL,fragmentShader:pL}),h=f.clone();h.defines.HORIZONTAL_PASS=1;let y=new On;y.setAttribute("position",new vn(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let g=new jt(y,f),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=kc;let p=this.type;this.render=function(E,S,T){if(m.enabled===!1)return;if(m.autoUpdate===!1&&m.needsUpdate===!1)return;if(E.length===0)return;if(this.type===NE)je("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=kc;let A=e.getRenderTarget(),P=e.getActiveCubeFace(),w=e.getActiveMipmapLevel(),I=e.state;if(I.setBlending(lr),I.buffers.depth.getReversed()===!0)I.buffers.color.setClear(0,0,0,0);else I.buffers.color.setClear(1,1,1,1);I.buffers.depth.setTest(!0),I.setScissorTest(!1);let F=p!==this.type;if(F)S.traverse(function(N){if(N.material)if(Array.isArray(N.material))N.material.forEach((U)=>U.needsUpdate=!0);else N.material.needsUpdate=!0});for(let N=0,U=E.length;N<U;N++){let D=E[N],O=D.shadow;if(O===void 0){je("WebGLShadowMap:",D,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;r.copy(O.mapSize);let K=O.getFrameExtents();if(r.multiply(K),s.copy(O.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/K.x),r.x=s.x*K.x,O.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/K.y),r.y=s.y*K.y,O.mapSize.y=s.y}let B=e.state.buffers.depth.getReversed();if(O.camera._reversedDepth=B,O.map===null||F===!0){if(O.map!==null){if(O.map.depthTexture!==null)O.map.depthTexture.dispose(),O.map.depthTexture=null;O.map.dispose()}if(this.type===go){if(D.isPointLight){je("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}O.map=new ai(r.x,r.y,{format:ya,type:dr,minFilter:En,magFilter:En,generateMipmaps:!1}),O.map.texture.name=D.name+".shadowMap",O.map.depthTexture=new _a(r.x,r.y,Fr),O.map.depthTexture.name=D.name+".shadowMapDepth",O.map.depthTexture.format=ga,O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=Fi,O.map.depthTexture.magFilter=Fi}else{if(D.isPointLight)O.map=new $m(r.x),O.map.depthTexture=new ym(r.x,ds);else O.map=new ai(r.x,r.y),O.map.depthTexture=new _a(r.x,r.y,ds);if(O.map.depthTexture.name=D.name+".shadowMap",O.map.depthTexture.format=ga,this.type===kc)O.map.depthTexture.compareFunction=B?sd:rd,O.map.depthTexture.minFilter=En,O.map.depthTexture.magFilter=En;else O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=Fi,O.map.depthTexture.magFilter=Fi}O.camera.updateProjectionMatrix()}if(O.map.isWebGLCubeRenderTarget!==!0&&(O.map.width!==r.x||O.map.height!==r.y))O.map.setSize(r.x,r.y);let X=O.map.isWebGLCubeRenderTarget?6:O.getViewportCount();if(D.isPointLight!==!0)O.updateMatrices(D,T);for(let q=0;q<X;q++){let le=O.getCamera(q);if(D.isPointLight){let{camera:de,matrix:Me}=O,pe=D.distance||de.far;if(pe!==de.far)de.far=pe,de.updateProjectionMatrix();nl.setFromMatrixPosition(D.matrixWorld),de.position.copy(nl),jm.copy(de.position),jm.add(mL[q]),de.up.copy(gL[q]),de.lookAt(jm),de.updateMatrixWorld(),Me.makeTranslation(-nl.x,-nl.y,-nl.z),tA.multiplyMatrices(de.projectionMatrix,de.matrixWorldInverse),O._frustum.setFromProjectionMatrix(tA,de.coordinateSystem,de.reversedDepth)}if(O.map.isWebGLCubeRenderTarget)e.setRenderTarget(O.map,q),e.clear();else{if(q===0)e.setRenderTarget(O.map),e.clear();let de=O.getViewport(q);a.set(s.x*de.x,s.y*de.y,s.x*de.z,s.y*de.w),I.viewport(a)}i=O.getFrustum(q),x(S,T,le,D,this.type)}if(O.isPointLightShadow!==!0&&this.type===go)b(O,T);O.needsUpdate=!1}p=this.type,m.needsUpdate=!1,e.setRenderTarget(A,P,w)};function b(E,S){let T=t.update(g);if(f.defines.VSM_SAMPLES!==E.blurSamples)f.defines.VSM_SAMPLES=E.blurSamples,h.defines.VSM_SAMPLES=E.blurSamples,f.needsUpdate=!0,h.needsUpdate=!0;if(E.mapPass===null)E.mapPass=new ai(r.x,r.y,{format:ya,type:dr});else if(E.mapPass.width!==E.map.width||E.mapPass.height!==E.map.height)E.mapPass.setSize(E.map.width,E.map.height);f.uniforms.shadow_pass.value=E.map.depthTexture,f.uniforms.resolution.value.set(E.map.width,E.map.height),f.uniforms.radius.value=E.radius,e.setRenderTarget(E.mapPass),e.clear(),e.renderBufferDirect(S,null,T,f,g,null),h.uniforms.shadow_pass.value=E.mapPass.texture,h.uniforms.resolution.value.set(E.map.width,E.map.height),h.uniforms.radius.value=E.radius,e.setRenderTarget(E.map),e.clear(),e.renderBufferDirect(S,null,T,h,g,null)}function _(E,S,T,A){let P=null,w=T.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(w!==void 0)P=w;else if(P=T.isPointLight===!0?c:o,e.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0||S.map&&S.alphaTest>0||S.alphaToCoverage===!0){let I=P.uuid,F=S.uuid,N=l[I];if(N===void 0)N={},l[I]=N;let U=N[F];if(U===void 0)U=P.clone(),N[F]=U,S.addEventListener("dispose",v);P=U}if(P.visible=S.visible,P.wireframe=S.wireframe,A===go)P.side=S.shadowSide!==null?S.shadowSide:S.side;else P.side=S.shadowSide!==null?S.shadowSide:d[S.side];if(P.alphaMap=S.alphaMap,P.alphaTest=S.alphaToCoverage===!0?0.5:S.alphaTest,P.map=S.map,P.clipShadows=S.clipShadows,P.clippingPlanes=S.clippingPlanes,P.clipIntersection=S.clipIntersection,P.displacementMap=S.displacementMap,P.displacementScale=S.displacementScale,P.displacementBias=S.displacementBias,P.wireframeLinewidth=S.wireframeLinewidth,P.linewidth=S.linewidth,T.isPointLight===!0&&P.isMeshDistanceMaterial===!0){let I=e.properties.get(P);I.light=T}return P}function x(E,S,T,A,P){if(E.visible===!1)return;if(E.layers.test(S.layers)&&(E.isMesh||E.isLine||E.isPoints)){if((E.castShadow||E.receiveShadow&&P===go)&&(!E.frustumCulled||E.intersectsFrustum(i))){E.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,E.matrixWorld);let F=t.update(E),N=E.material;if(Array.isArray(N)){let U=F.groups;for(let D=0,O=U.length;D<O;D++){let K=U[D],B=N[K.materialIndex];if(B&&B.visible){let X=_(E,B,A,P);E.onBeforeShadow(e,E,S,T,F,X,K),e.renderBufferDirect(T,null,F,X,E,K),E.onAfterShadow(e,E,S,T,F,X,K)}}}else if(N.visible){let U=_(E,N,A,P);E.onBeforeShadow(e,E,S,T,F,U,null),e.renderBufferDirect(T,null,F,U,E,null),E.onAfterShadow(e,E,S,T,F,U,null)}}}let I=E.children;for(let F=0,N=I.length;F<N;F++)x(I[F],S,T,A,P)}function v(E){E.target.removeEventListener("dispose",v);for(let T in l){let A=l[T],P=E.target.uuid;if(P in A)A[P].dispose(),delete A[P]}}}function yL(e,t){function n(){let G=!1,ye=new Nt,ae=null,xe=new Nt(0,0,0,0);return{setMask:function(Ce){if(ae!==Ce&&!G)e.colorMask(Ce,Ce,Ce,Ce),ae=Ce},setLocked:function(Ce){G=Ce},setClear:function(Ce,fe,Ae,it,zt){if(zt===!0)Ce*=it,fe*=it,Ae*=it;if(ye.set(Ce,fe,Ae,it),xe.equals(ye)===!1)e.clearColor(Ce,fe,Ae,it),xe.copy(ye)},reset:function(){G=!1,ae=null,xe.set(-1,0,0,0)}}}function i(){let G=!1,ye=!1,ae=null,xe=null,Ce=null;return{setReversed:function(fe){if(ye!==fe){let Ae=t.get("EXT_clip_control");if(fe)Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.ZERO_TO_ONE_EXT);else Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.NEGATIVE_ONE_TO_ONE_EXT);ye=fe;let it=Ce;Ce=null,this.setClear(it)}},getReversed:function(){return ye},setTest:function(fe){if(fe)W(e.DEPTH_TEST);else te(e.DEPTH_TEST)},setMask:function(fe){if(ae!==fe&&!G)e.depthMask(fe),ae=fe},setFunc:function(fe){if(ye)fe=ST[fe];if(xe!==fe){switch(fe){case YE:e.depthFunc(e.NEVER);break;case QE:e.depthFunc(e.ALWAYS);break;case eT:e.depthFunc(e.LESS);break;case xp:e.depthFunc(e.LEQUAL);break;case tT:e.depthFunc(e.EQUAL);break;case nT:e.depthFunc(e.GEQUAL);break;case iT:e.depthFunc(e.GREATER);break;case rT:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}xe=fe}},setLocked:function(fe){G=fe},setClear:function(fe){if(Ce!==fe){if(Ce=fe,ye)fe=1-fe;e.clearDepth(fe)}},reset:function(){G=!1,ae=null,xe=null,Ce=null,ye=!1}}}function r(){let G=!1,ye=null,ae=null,xe=null,Ce=null,fe=null,Ae=null,it=null,zt=null;return{setTest:function(wt){if(!G)if(wt)W(e.STENCIL_TEST);else te(e.STENCIL_TEST)},setMask:function(wt){if(ye!==wt&&!G)e.stencilMask(wt),ye=wt},setFunc:function(wt,$i,Tr){if(ae!==wt||xe!==$i||Ce!==Tr)e.stencilFunc(wt,$i,Tr),ae=wt,xe=$i,Ce=Tr},setOp:function(wt,$i,Tr){if(fe!==wt||Ae!==$i||it!==Tr)e.stencilOp(wt,$i,Tr),fe=wt,Ae=$i,it=Tr},setLocked:function(wt){G=wt},setClear:function(wt){if(zt!==wt)e.clearStencil(wt),zt=wt},reset:function(){G=!1,ye=null,ae=null,xe=null,Ce=null,fe=null,Ae=null,it=null,zt=null}}}let s=new n,a=new i,o=new r,c=new WeakMap,l=new WeakMap,u={},d={},f={},h=new WeakMap,y=[],g=null,m=!1,p=null,b=null,_=null,x=null,v=null,E=null,S=null,T=new qe(0,0,0),A=0,P=!1,w=null,I=null,F=null,N=null,U=null,D=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),O=!1,K=0,B=e.getParameter(e.VERSION);if(B.indexOf("WebGL")!==-1)K=parseFloat(/^WebGL (\d)/.exec(B)[1]),O=K>=1;else if(B.indexOf("OpenGL ES")!==-1)K=parseFloat(/^OpenGL ES (\d)/.exec(B)[1]),O=K>=2;let X=null,q={},le=e.getParameter(e.SCISSOR_BOX),de=e.getParameter(e.VIEWPORT),Me=new Nt().fromArray(le),pe=new Nt().fromArray(de);function J(G,ye,ae,xe){let Ce=new Uint8Array(4),fe=e.createTexture();e.bindTexture(G,fe),e.texParameteri(G,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(G,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let Ae=0;Ae<ae;Ae++)if(G===e.TEXTURE_3D||G===e.TEXTURE_2D_ARRAY)e.texImage3D(ye,0,e.RGBA,1,1,xe,0,e.RGBA,e.UNSIGNED_BYTE,Ce);else e.texImage2D(ye+Ae,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,Ce);return fe}let L={};L[e.TEXTURE_2D]=J(e.TEXTURE_2D,e.TEXTURE_2D,1),L[e.TEXTURE_CUBE_MAP]=J(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),L[e.TEXTURE_2D_ARRAY]=J(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),L[e.TEXTURE_3D]=J(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),W(e.DEPTH_TEST),a.setFunc(xp),Kt(!1),lt(mp),W(e.CULL_FACE),We(lr);function W(G){if(u[G]!==!0)e.enable(G),u[G]=!0}function te(G){if(u[G]!==!1)e.disable(G),u[G]=!1}function ie(G,ye){if(f[G]!==ye){if(e.bindFramebuffer(G,ye),f[G]=ye,G===e.DRAW_FRAMEBUFFER)f[e.FRAMEBUFFER]=ye;if(G===e.FRAMEBUFFER)f[e.DRAW_FRAMEBUFFER]=ye;return!0}return!1}function ce(G,ye){let ae=y,xe=!1;if(G){if(ae=h.get(ye),ae===void 0)ae=[],h.set(ye,ae);let Ce=G.textures;if(ae.length!==Ce.length||ae[0]!==e.COLOR_ATTACHMENT0){for(let fe=0,Ae=Ce.length;fe<Ae;fe++)ae[fe]=e.COLOR_ATTACHMENT0+fe;ae.length=Ce.length,xe=!0}}else if(ae[0]!==e.BACK)ae[0]=e.BACK,xe=!0;if(xe)e.drawBuffers(ae)}function _e(G){if(g!==G)return e.useProgram(G),g=G,!0;return!1}let Re={[bo]:e.FUNC_ADD,[OE]:e.FUNC_SUBTRACT,[kE]:e.FUNC_REVERSE_SUBTRACT};Re[DE]=e.MIN,Re[LE]=e.MAX;let Oe={[FE]:e.ZERO,[UE]:e.ONE,[BE]:e.SRC_COLOR,[VE]:e.SRC_ALPHA,[WE]:e.SRC_ALPHA_SATURATE,[$E]:e.DST_COLOR,[HE]:e.DST_ALPHA,[zE]:e.ONE_MINUS_SRC_COLOR,[jE]:e.ONE_MINUS_SRC_ALPHA,[KE]:e.ONE_MINUS_DST_COLOR,[GE]:e.ONE_MINUS_DST_ALPHA,[XE]:e.CONSTANT_COLOR,[qE]:e.ONE_MINUS_CONSTANT_COLOR,[JE]:e.CONSTANT_ALPHA,[ZE]:e.ONE_MINUS_CONSTANT_ALPHA};function We(G,ye,ae,xe,Ce,fe,Ae,it,zt,wt){if(G===lr){if(m===!0)te(e.BLEND),m=!1;return}if(m===!1)W(e.BLEND),m=!0;if(G!==PE){if(G!==p||wt!==P){if(b!==bo||v!==bo)e.blendEquation(e.FUNC_ADD),b=bo,v=bo;if(wt)switch(G){case Dc:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case gp:e.blendFunc(e.ONE,e.ONE);break;case bp:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case yp:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ze("WebGLState: Invalid blending: ",G);break}else switch(G){case Dc:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case gp:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case bp:Ze("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case yp:Ze("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ze("WebGLState: Invalid blending: ",G);break}_=null,x=null,E=null,S=null,T.set(0,0,0),A=0,p=G,P=wt}return}if(Ce=Ce||ye,fe=fe||ae,Ae=Ae||xe,ye!==b||Ce!==v)e.blendEquationSeparate(Re[ye],Re[Ce]),b=ye,v=Ce;if(ae!==_||xe!==x||fe!==E||Ae!==S)e.blendFuncSeparate(Oe[ae],Oe[xe],Oe[fe],Oe[Ae]),_=ae,x=xe,E=fe,S=Ae;if(it.equals(T)===!1||zt!==A)e.blendColor(it.r,it.g,it.b,zt),T.copy(it),A=zt;p=G,P=!1}function Ye(G,ye){G.side===xi?te(e.CULL_FACE):W(e.CULL_FACE);let ae=G.side===Pn;if(ye)ae=!ae;Kt(ae),G.blending===Dc&&G.transparent===!1?We(lr):We(G.blending,G.blendEquation,G.blendSrc,G.blendDst,G.blendEquationAlpha,G.blendSrcAlpha,G.blendDstAlpha,G.blendColor,G.blendAlpha,G.premultipliedAlpha),a.setFunc(G.depthFunc),a.setTest(G.depthTest),a.setMask(G.depthWrite),s.setMask(G.colorWrite);let xe=G.stencilWrite;if(o.setTest(xe),xe)o.setMask(G.stencilWriteMask),o.setFunc(G.stencilFunc,G.stencilRef,G.stencilFuncMask),o.setOp(G.stencilFail,G.stencilZFail,G.stencilZPass);Yt(G.polygonOffset,G.polygonOffsetFactor,G.polygonOffsetUnits),G.alphaToCoverage===!0?W(e.SAMPLE_ALPHA_TO_COVERAGE):te(e.SAMPLE_ALPHA_TO_COVERAGE)}function Kt(G){if(w!==G){if(G)e.frontFace(e.CW);else e.frontFace(e.CCW);w=G}}function lt(G){if(G!==IE){if(W(e.CULL_FACE),G!==I)if(G===mp)e.cullFace(e.BACK);else if(G===CE)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else te(e.CULL_FACE);I=G}function Dt(G){if(G!==F){if(O)e.lineWidth(G);F=G}}function Yt(G,ye,ae){if(G){if(W(e.POLYGON_OFFSET_FILL),N!==ye||U!==ae){if(N=ye,U=ae,a.getReversed())ye=-ye;e.polygonOffset(ye,ae)}}else te(e.POLYGON_OFFSET_FILL)}function tn(G){if(G)W(e.SCISSOR_TEST);else te(e.SCISSOR_TEST)}function z(G){if(G===void 0)G=e.TEXTURE0+D-1;if(X!==G)e.activeTexture(G),X=G}function xn(G,ye,ae){if(ae===void 0)if(X===null)ae=e.TEXTURE0+D-1;else ae=X;let xe=q[ae];if(xe===void 0)xe={type:void 0,texture:void 0},q[ae]=xe;if(xe.type!==G||xe.texture!==ye){if(X!==ae)e.activeTexture(ae),X=ae;e.bindTexture(G,ye||L[G]),xe.type=G,xe.texture=ye}}function St(){let G=q[X];if(G!==void 0&&G.type!==void 0)e.bindTexture(G.type,null),G.type=void 0,G.texture=void 0}function Wt(){try{e.compressedTexImage2D(...arguments)}catch(G){Ze("WebGLState:",G)}}function C(){try{e.compressedTexImage3D(...arguments)}catch(G){Ze("WebGLState:",G)}}function M(){try{e.texSubImage2D(...arguments)}catch(G){Ze("WebGLState:",G)}}function V(){try{e.texSubImage3D(...arguments)}catch(G){Ze("WebGLState:",G)}}function Q(){try{e.compressedTexSubImage2D(...arguments)}catch(G){Ze("WebGLState:",G)}}function he(){try{e.compressedTexSubImage3D(...arguments)}catch(G){Ze("WebGLState:",G)}}function ge(){try{e.texStorage2D(...arguments)}catch(G){Ze("WebGLState:",G)}}function ve(){try{e.texStorage3D(...arguments)}catch(G){Ze("WebGLState:",G)}}function re(){try{e.texImage2D(...arguments)}catch(G){Ze("WebGLState:",G)}}function oe(){try{e.texImage3D(...arguments)}catch(G){Ze("WebGLState:",G)}}function Ie(G){if(d[G]!==void 0)return d[G];else return e.getParameter(G)}function Ve(G,ye){if(d[G]!==ye)e.pixelStorei(G,ye),d[G]=ye}function Ee(G){if(Me.equals(G)===!1)e.scissor(G.x,G.y,G.z,G.w),Me.copy(G)}function me(G){if(pe.equals(G)===!1)e.viewport(G.x,G.y,G.z,G.w),pe.copy(G)}function Ge(G,ye){let ae=l.get(ye);if(ae===void 0)ae=new WeakMap,l.set(ye,ae);let xe=ae.get(G);if(xe===void 0)xe=e.getUniformBlockIndex(ye,G.name),ae.set(G,xe)}function Xe(G,ye){let xe=l.get(ye).get(G);if(c.get(ye)!==xe)e.uniformBlockBinding(ye,xe,G.__bindingPointIndex),c.set(ye,xe)}function _t(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),a.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},d={},X=null,q={},f={},h=new WeakMap,y=[],g=null,m=!1,p=null,b=null,_=null,x=null,v=null,E=null,S=null,T=new qe(0,0,0),A=0,P=!1,w=null,I=null,F=null,N=null,U=null,Me.set(0,0,e.canvas.width,e.canvas.height),pe.set(0,0,e.canvas.width,e.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:W,disable:te,bindFramebuffer:ie,drawBuffers:ce,useProgram:_e,setBlending:We,setMaterial:Ye,setFlipSided:Kt,setCullFace:lt,setLineWidth:Dt,setPolygonOffset:Yt,setScissorTest:tn,activeTexture:z,bindTexture:xn,unbindTexture:St,compressedTexImage2D:Wt,compressedTexImage3D:C,texImage2D:re,texImage3D:oe,pixelStorei:Ve,getParameter:Ie,updateUBOMapping:Ge,uniformBlockBinding:Xe,texStorage2D:ge,texStorage3D:ve,texSubImage2D:M,texSubImage3D:V,compressedTexSubImage2D:Q,compressedTexSubImage3D:he,scissor:Ee,viewport:me,reset:_t}}function xL(e,t,n,i,r,s,a){let o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ke,u=new WeakMap,d=new Set,f,h=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(C){}function g(C,M){return y?new OffscreenCanvas(C,M):ho("canvas")}function m(C,M,V){let Q=1,he=Wt(C);if(he.width>V||he.height>V)Q=V/Math.max(he.width,he.height);if(Q<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){let ge=Math.floor(Q*he.width),ve=Math.floor(Q*he.height);if(f===void 0)f=g(ge,ve);let re=M?g(ge,ve):f;return re.width=ge,re.height=ve,re.getContext("2d").drawImage(C,0,0,ge,ve),je("WebGLRenderer: Texture has been resized from ("+he.width+"x"+he.height+") to ("+ge+"x"+ve+")."),re}else{if("data"in C)je("WebGLRenderer: Image in DataTexture is too big ("+he.width+"x"+he.height+").");return C}return C}function p(C){return C.generateMipmaps}function b(C){e.generateMipmap(C)}function _(C){if(C.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(C.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(C.isWebGLArrayRenderTarget||C.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function x(C,M,V,Q,he,ge=!1){if(C!==null){if(e[C]!==void 0)return e[C];je("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let ve;if(Q){if(ve=t.get("EXT_texture_norm16"),!ve)je("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let re=M;if(M===e.RED){if(V===e.FLOAT)re=e.R32F;if(V===e.HALF_FLOAT)re=e.R16F;if(V===e.UNSIGNED_BYTE)re=e.R8;if(V===e.UNSIGNED_SHORT&&ve)re=ve.R16_EXT;if(V===e.SHORT&&ve)re=ve.R16_SNORM_EXT}if(M===e.RED_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.R8UI;if(V===e.UNSIGNED_SHORT)re=e.R16UI;if(V===e.UNSIGNED_INT)re=e.R32UI;if(V===e.BYTE)re=e.R8I;if(V===e.SHORT)re=e.R16I;if(V===e.INT)re=e.R32I}if(M===e.RG){if(V===e.FLOAT)re=e.RG32F;if(V===e.HALF_FLOAT)re=e.RG16F;if(V===e.UNSIGNED_BYTE)re=e.RG8;if(V===e.UNSIGNED_SHORT&&ve)re=ve.RG16_EXT;if(V===e.SHORT&&ve)re=ve.RG16_SNORM_EXT}if(M===e.RG_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.RG8UI;if(V===e.UNSIGNED_SHORT)re=e.RG16UI;if(V===e.UNSIGNED_INT)re=e.RG32UI;if(V===e.BYTE)re=e.RG8I;if(V===e.SHORT)re=e.RG16I;if(V===e.INT)re=e.RG32I}if(M===e.RGB_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.RGB8UI;if(V===e.UNSIGNED_SHORT)re=e.RGB16UI;if(V===e.UNSIGNED_INT)re=e.RGB32UI;if(V===e.BYTE)re=e.RGB8I;if(V===e.SHORT)re=e.RGB16I;if(V===e.INT)re=e.RGB32I}if(M===e.RGBA_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.RGBA8UI;if(V===e.UNSIGNED_SHORT)re=e.RGBA16UI;if(V===e.UNSIGNED_INT)re=e.RGBA32UI;if(V===e.BYTE)re=e.RGBA8I;if(V===e.SHORT)re=e.RGBA16I;if(V===e.INT)re=e.RGBA32I}if(M===e.RGB){if(V===e.UNSIGNED_SHORT&&ve)re=ve.RGB16_EXT;if(V===e.SHORT&&ve)re=ve.RGB16_SNORM_EXT;if(V===e.UNSIGNED_INT_5_9_9_9_REV)re=e.RGB9_E5;if(V===e.UNSIGNED_INT_10F_11F_11F_REV)re=e.R11F_G11F_B10F}if(M===e.RGBA){let oe=ge?dm:ot.getTransfer(he);if(V===e.FLOAT)re=e.RGBA32F;if(V===e.HALF_FLOAT)re=e.RGBA16F;if(V===e.UNSIGNED_BYTE)re=oe===Bt?e.SRGB8_ALPHA8:e.RGBA8;if(V===e.UNSIGNED_SHORT&&ve)re=ve.RGBA16_EXT;if(V===e.SHORT&&ve)re=ve.RGBA16_SNORM_EXT;if(V===e.UNSIGNED_SHORT_4_4_4_4)re=e.RGBA4;if(V===e.UNSIGNED_SHORT_5_5_5_1)re=e.RGB5_A1}if(re===e.R16F||re===e.R32F||re===e.RG16F||re===e.RG32F||re===e.RGBA16F||re===e.RGBA32F)t.get("EXT_color_buffer_float");return re}function v(C,M){let V;if(C){if(M===null||M===ds||M===Eo)V=e.DEPTH24_STENCIL8;else if(M===Fr)V=e.DEPTH32F_STENCIL8;else if(M===Uc)V=e.DEPTH24_STENCIL8,je("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(M===null||M===ds||M===Eo)V=e.DEPTH_COMPONENT24;else if(M===Fr)V=e.DEPTH_COMPONENT32F;else if(M===Uc)V=e.DEPTH_COMPONENT16;return V}function E(C,M){if(p(C)===!0||C.isFramebufferTexture&&C.minFilter!==Fi&&C.minFilter!==En)return Math.log2(Math.max(M.width,M.height))+1;else if(C.mipmaps!==void 0&&C.mipmaps.length>0)return C.mipmaps.length;else if(C.isCompressedTexture&&Array.isArray(C.image))return M.mipmaps.length;else return 1}function S(C){let M=C.target;if(M.removeEventListener("dispose",S),A(M),M.isVideoTexture)u.delete(M);if(M.isHTMLTexture)d.delete(M)}function T(C){let M=C.target;M.removeEventListener("dispose",T),w(M)}function A(C){let M=i.get(C);if(M.__webglInit===void 0)return;let V=C.source,Q=h.get(V);if(Q){let he=Q[M.__cacheKey];if(he.usedTimes--,he.usedTimes===0)P(C);if(Object.keys(Q).length===0)h.delete(V)}i.remove(C)}function P(C){let M=i.get(C);e.deleteTexture(M.__webglTexture);let V=C.source,Q=h.get(V);delete Q[M.__cacheKey],a.memory.textures--}function w(C){let M=i.get(C);if(C.depthTexture)C.depthTexture.dispose(),i.remove(C.depthTexture);if(C.isWebGLCubeRenderTarget)for(let Q=0;Q<6;Q++){if(Array.isArray(M.__webglFramebuffer[Q]))for(let he=0;he<M.__webglFramebuffer[Q].length;he++)e.deleteFramebuffer(M.__webglFramebuffer[Q][he]);else e.deleteFramebuffer(M.__webglFramebuffer[Q]);if(M.__webglDepthbuffer)e.deleteRenderbuffer(M.__webglDepthbuffer[Q])}else{if(Array.isArray(M.__webglFramebuffer))for(let Q=0;Q<M.__webglFramebuffer.length;Q++)e.deleteFramebuffer(M.__webglFramebuffer[Q]);else e.deleteFramebuffer(M.__webglFramebuffer);if(M.__webglDepthbuffer)e.deleteRenderbuffer(M.__webglDepthbuffer);if(M.__webglMultisampledFramebuffer)e.deleteFramebuffer(M.__webglMultisampledFramebuffer);if(M.__webglColorRenderbuffer){for(let Q=0;Q<M.__webglColorRenderbuffer.length;Q++)if(M.__webglColorRenderbuffer[Q])e.deleteRenderbuffer(M.__webglColorRenderbuffer[Q])}if(M.__webglDepthRenderbuffer)e.deleteRenderbuffer(M.__webglDepthRenderbuffer)}let V=C.textures;for(let Q=0,he=V.length;Q<he;Q++){let ge=i.get(V[Q]);if(ge.__webglTexture)e.deleteTexture(ge.__webglTexture),a.memory.textures--;i.remove(V[Q])}i.remove(C)}let I=0;function F(){I=0}function N(){return I}function U(C){I=C}function D(){let C=I;if(C>=r.maxTextures)je("WebGLTextures: Trying to use "+(C+1)+" texture units while this GPU supports only "+r.maxTextures);return I+=1,C}function O(C){let M=[];return M.push(C.wrapS),M.push(C.wrapT),M.push(C.wrapR||0),M.push(C.magFilter),M.push(C.minFilter),M.push(C.anisotropy),M.push(C.internalFormat),M.push(C.format),M.push(C.type),M.push(C.generateMipmaps),M.push(C.premultiplyAlpha),M.push(C.flipY),M.push(C.unpackAlignment),M.push(C.colorSpace),M.join()}function K(C,M){let V=i.get(C);if(C.isVideoTexture)xn(C);if(C.isRenderTargetTexture===!1&&C.isExternalTexture!==!0&&C.version>0&&V.__version!==C.version){let Q=C.image;if(Q===null)je("WebGLRenderer: Texture marked for update but no image data found.");else if(Q.complete===!1)je("WebGLRenderer: Texture marked for update but image is incomplete");else{te(V,C,M);return}}else if(C.isExternalTexture)V.__webglTexture=C.sourceTexture?C.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,V.__webglTexture,e.TEXTURE0+M)}function B(C,M){let V=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&V.__version!==C.version){te(V,C,M);return}else if(C.isExternalTexture)V.__webglTexture=C.sourceTexture?C.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,V.__webglTexture,e.TEXTURE0+M)}function X(C,M){let V=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&V.__version!==C.version){te(V,C,M);return}n.bindTexture(e.TEXTURE_3D,V.__webglTexture,e.TEXTURE0+M)}function q(C,M){let V=i.get(C);if(C.isCubeDepthTexture!==!0&&C.version>0&&V.__version!==C.version){ie(V,C,M);return}n.bindTexture(e.TEXTURE_CUBE_MAP,V.__webglTexture,e.TEXTURE0+M)}let le={[xo]:e.REPEAT,[_o]:e.CLAMP_TO_EDGE,[qu]:e.MIRRORED_REPEAT},de={[Fi]:e.NEAREST,[Ju]:e.NEAREST_MIPMAP_NEAREST,[ma]:e.NEAREST_MIPMAP_LINEAR,[En]:e.LINEAR,[vo]:e.LINEAR_MIPMAP_NEAREST,[ur]:e.LINEAR_MIPMAP_LINEAR},Me={[gT]:e.NEVER,[vT]:e.ALWAYS,[bT]:e.LESS,[rd]:e.LEQUAL,[yT]:e.EQUAL,[sd]:e.GEQUAL,[xT]:e.GREATER,[_T]:e.NOTEQUAL};function pe(C,M){if(M.type===Fr&&t.has("OES_texture_float_linear")===!1&&(M.magFilter===En||M.magFilter===vo||M.magFilter===ma||M.magFilter===ur||M.minFilter===En||M.minFilter===vo||M.minFilter===ma||M.minFilter===ur))je("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(C,e.TEXTURE_WRAP_S,le[M.wrapS]),e.texParameteri(C,e.TEXTURE_WRAP_T,le[M.wrapT]),C===e.TEXTURE_3D||C===e.TEXTURE_2D_ARRAY)e.texParameteri(C,e.TEXTURE_WRAP_R,le[M.wrapR]);if(e.texParameteri(C,e.TEXTURE_MAG_FILTER,de[M.magFilter]),e.texParameteri(C,e.TEXTURE_MIN_FILTER,de[M.minFilter]),M.compareFunction)e.texParameteri(C,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(C,e.TEXTURE_COMPARE_FUNC,Me[M.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===Fi)return;if(M.minFilter!==ma&&M.minFilter!==ur)return;if(M.type===Fr&&t.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||i.get(M).__currentAnisotropy){let V=t.get("EXT_texture_filter_anisotropic");e.texParameterf(C,V.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,r.getMaxAnisotropy())),i.get(M).__currentAnisotropy=M.anisotropy}}}function J(C,M){let V=!1;if(C.__webglInit===void 0)C.__webglInit=!0,M.addEventListener("dispose",S);let Q=M.source,he=h.get(Q);if(he===void 0)he={},h.set(Q,he);let ge=O(M);if(ge!==C.__cacheKey){if(he[ge]===void 0)he[ge]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,V=!0;he[ge].usedTimes++;let ve=he[C.__cacheKey];if(ve!==void 0){if(he[C.__cacheKey].usedTimes--,ve.usedTimes===0)P(M)}C.__cacheKey=ge,C.__webglTexture=he[ge].texture}return V}function L(C,M,V){return Math.floor(Math.floor(C/V)/M)}function W(C,M,V,Q){let ge=C.updateRanges;if(ge.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,M.width,M.height,V,Q,M.data);else{ge.sort((Ve,Ee)=>Ve.start-Ee.start);let ve=0;for(let Ve=1;Ve<ge.length;Ve++){let Ee=ge[ve],me=ge[Ve],Ge=Ee.start+Ee.count,Xe=L(me.start,M.width,4),_t=L(Ee.start,M.width,4);if(me.start<=Ge+1&&Xe===_t&&L(me.start+me.count-1,M.width,4)===Xe)Ee.count=Math.max(Ee.count,me.start+me.count-Ee.start);else++ve,ge[ve]=me}ge.length=ve+1;let re=n.getParameter(e.UNPACK_ROW_LENGTH),oe=n.getParameter(e.UNPACK_SKIP_PIXELS),Ie=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,M.width);for(let Ve=0,Ee=ge.length;Ve<Ee;Ve++){let me=ge[Ve],Ge=Math.floor(me.start/4),Xe=Math.ceil(me.count/4),_t=Ge%M.width,G=Math.floor(Ge/M.width),ye=Xe,ae=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,_t),n.pixelStorei(e.UNPACK_SKIP_ROWS,G),n.texSubImage2D(e.TEXTURE_2D,0,_t,G,ye,1,V,Q,M.data)}C.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,re),n.pixelStorei(e.UNPACK_SKIP_PIXELS,oe),n.pixelStorei(e.UNPACK_SKIP_ROWS,Ie)}}function te(C,M,V){let Q=e.TEXTURE_2D;if(M.isDataArrayTexture||M.isCompressedArrayTexture)Q=e.TEXTURE_2D_ARRAY;if(M.isData3DTexture)Q=e.TEXTURE_3D;let he=J(C,M),ge=M.source;n.bindTexture(Q,C.__webglTexture,e.TEXTURE0+V);let ve=i.get(ge);if(ge.version!==ve.__version||he===!0){if(n.activeTexture(e.TEXTURE0+V),(typeof ImageBitmap<"u"&&M.image instanceof ImageBitmap)===!1){let ae=ot.getPrimaries(ot.workingColorSpace),xe=M.colorSpace===xa?null:ot.getPrimaries(M.colorSpace),Ce=M.colorSpace===xa||ae===xe?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,M.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ce)}n.pixelStorei(e.UNPACK_ALIGNMENT,M.unpackAlignment);let oe=m(M.image,!1,r.maxTextureSize);oe=St(M,oe);let Ie=s.convert(M.format,M.colorSpace),Ve=s.convert(M.type),Ee=x(M.internalFormat,Ie,Ve,M.normalized,M.colorSpace,M.isVideoTexture);pe(Q,M);let me,Ge=M.mipmaps,Xe=M.isVideoTexture!==!0,_t=ve.__version===void 0||he===!0,G=ge.dataReady,ye=E(M,oe);if(M.isDepthTexture){if(Ee=v(M.format===ba,M.type),_t)if(Xe)n.texStorage2D(e.TEXTURE_2D,1,Ee,oe.width,oe.height);else n.texImage2D(e.TEXTURE_2D,0,Ee,oe.width,oe.height,0,Ie,Ve,null)}else if(M.isDataTexture)if(Ge.length>0){if(Xe&&_t)n.texStorage2D(e.TEXTURE_2D,ye,Ee,Ge[0].width,Ge[0].height);for(let ae=0,xe=Ge.length;ae<xe;ae++)if(me=Ge[ae],Xe){if(G)n.texSubImage2D(e.TEXTURE_2D,ae,0,0,me.width,me.height,Ie,Ve,me.data)}else n.texImage2D(e.TEXTURE_2D,ae,Ee,me.width,me.height,0,Ie,Ve,me.data);M.generateMipmaps=!1}else if(Xe){if(_t)n.texStorage2D(e.TEXTURE_2D,ye,Ee,oe.width,oe.height);if(G)W(M,oe,Ie,Ve)}else n.texImage2D(e.TEXTURE_2D,0,Ee,oe.width,oe.height,0,Ie,Ve,oe.data);else if(M.isCompressedTexture)if(M.isCompressedArrayTexture){if(Xe&&_t)n.texStorage3D(e.TEXTURE_2D_ARRAY,ye,Ee,Ge[0].width,Ge[0].height,oe.depth);for(let ae=0,xe=Ge.length;ae<xe;ae++)if(me=Ge[ae],M.format!==fr)if(Ie!==null)if(Xe){if(G)if(M.layerUpdates.size>0){let Ce=Dm(me.width,me.height,M.format,M.type);for(let fe of M.layerUpdates){let Ae=me.data.subarray(fe*Ce/me.data.BYTES_PER_ELEMENT,(fe+1)*Ce/me.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ae,0,0,fe,me.width,me.height,1,Ie,Ae)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ae,0,0,0,me.width,me.height,oe.depth,Ie,me.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ae,Ee,me.width,me.height,oe.depth,0,me.data,0,0);else je("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Xe){if(G)n.texSubImage3D(e.TEXTURE_2D_ARRAY,ae,0,0,0,me.width,me.height,oe.depth,Ie,Ve,me.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,ae,Ee,me.width,me.height,oe.depth,0,Ie,Ve,me.data);if(M.layerUpdates.size>0)M.clearLayerUpdates()}else{if(Xe&&_t)n.texStorage2D(e.TEXTURE_2D,ye,Ee,Ge[0].width,Ge[0].height);for(let ae=0,xe=Ge.length;ae<xe;ae++)if(me=Ge[ae],M.format!==fr)if(Ie!==null)if(Xe){if(G)n.compressedTexSubImage2D(e.TEXTURE_2D,ae,0,0,me.width,me.height,Ie,me.data)}else n.compressedTexImage2D(e.TEXTURE_2D,ae,Ee,me.width,me.height,0,me.data);else je("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Xe){if(G)n.texSubImage2D(e.TEXTURE_2D,ae,0,0,me.width,me.height,Ie,Ve,me.data)}else n.texImage2D(e.TEXTURE_2D,ae,Ee,me.width,me.height,0,Ie,Ve,me.data)}else if(M.isDataArrayTexture)if(Xe){if(_t)n.texStorage3D(e.TEXTURE_2D_ARRAY,ye,Ee,oe.width,oe.height,oe.depth);if(G)if(M.layerUpdates.size>0){let ae=Dm(oe.width,oe.height,M.format,M.type);for(let xe of M.layerUpdates){let Ce=oe.data.subarray(xe*ae/oe.data.BYTES_PER_ELEMENT,(xe+1)*ae/oe.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,xe,oe.width,oe.height,1,Ie,Ve,Ce)}M.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,oe.width,oe.height,oe.depth,Ie,Ve,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,Ee,oe.width,oe.height,oe.depth,0,Ie,Ve,oe.data);else if(M.isData3DTexture)if(Xe){if(_t)n.texStorage3D(e.TEXTURE_3D,ye,Ee,oe.width,oe.height,oe.depth);if(G)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,oe.width,oe.height,oe.depth,Ie,Ve,oe.data)}else n.texImage3D(e.TEXTURE_3D,0,Ee,oe.width,oe.height,oe.depth,0,Ie,Ve,oe.data);else if(M.isFramebufferTexture){if(_t)if(Xe)n.texStorage2D(e.TEXTURE_2D,ye,Ee,oe.width,oe.height);else{let ae=oe.width,xe=oe.height;for(let Ce=0;Ce<ye;Ce++)n.texImage2D(e.TEXTURE_2D,Ce,Ee,ae,xe,0,Ie,Ve,null),ae>>=1,xe>>=1}}else if(M.isHTMLTexture){if("texElementImage2D"in e){let ae=e.canvas;if(!ae.hasAttribute("layoutsubtree"))ae.setAttribute("layoutsubtree","true");if(oe.parentNode!==ae){ae.appendChild(oe),d.add(M),ae.onpaint=(xe)=>{let Ce=xe.changedElements;for(let fe of d)if(Ce.includes(fe.image))fe.needsUpdate=!0},ae.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,oe);else{let{RGBA:Ce,RGBA:fe,UNSIGNED_BYTE:Ae}=e;e.texElementImage2D(e.TEXTURE_2D,0,Ce,fe,Ae,oe)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Ge.length>0){if(Xe&&_t){let ae=Wt(Ge[0]);n.texStorage2D(e.TEXTURE_2D,ye,Ee,ae.width,ae.height)}for(let ae=0,xe=Ge.length;ae<xe;ae++)if(me=Ge[ae],Xe){if(G)n.texSubImage2D(e.TEXTURE_2D,ae,0,0,Ie,Ve,me)}else n.texImage2D(e.TEXTURE_2D,ae,Ee,Ie,Ve,me);M.generateMipmaps=!1}else if(Xe){if(_t){let ae=Wt(oe);n.texStorage2D(e.TEXTURE_2D,ye,Ee,ae.width,ae.height)}if(G)n.texSubImage2D(e.TEXTURE_2D,0,0,0,Ie,Ve,oe)}else n.texImage2D(e.TEXTURE_2D,0,Ee,Ie,Ve,oe);if(p(M))b(Q);if(ve.__version=ge.version,M.onUpdate)M.onUpdate(M)}C.__version=M.version}function ie(C,M,V){if(M.image.length!==6)return;let Q=J(C,M),he=M.source;n.bindTexture(e.TEXTURE_CUBE_MAP,C.__webglTexture,e.TEXTURE0+V);let ge=i.get(he);if(he.version!==ge.__version||Q===!0){n.activeTexture(e.TEXTURE0+V);let ve=ot.getPrimaries(ot.workingColorSpace),re=M.colorSpace===xa?null:ot.getPrimaries(M.colorSpace),oe=M.colorSpace===xa||ve===re?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,M.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,M.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,oe);let Ie=M.isCompressedTexture||M.image[0].isCompressedTexture,Ve=M.image[0]&&M.image[0].isDataTexture,Ee=[];for(let fe=0;fe<6;fe++){if(!Ie&&!Ve)Ee[fe]=m(M.image[fe],!0,r.maxCubemapSize);else Ee[fe]=Ve?M.image[fe].image:M.image[fe];Ee[fe]=St(M,Ee[fe])}let me=Ee[0],Ge=s.convert(M.format,M.colorSpace),Xe=s.convert(M.type),_t=x(M.internalFormat,Ge,Xe,M.normalized,M.colorSpace),G=M.isVideoTexture!==!0,ye=ge.__version===void 0||Q===!0,ae=he.dataReady,xe=E(M,me);pe(e.TEXTURE_CUBE_MAP,M);let Ce;if(Ie){if(G&&ye)n.texStorage2D(e.TEXTURE_CUBE_MAP,xe,_t,me.width,me.height);for(let fe=0;fe<6;fe++){Ce=Ee[fe].mipmaps;for(let Ae=0;Ae<Ce.length;Ae++){let it=Ce[Ae];if(M.format!==fr)if(Ge!==null)if(G){if(ae)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,0,0,it.width,it.height,Ge,it.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,_t,it.width,it.height,0,it.data);else je("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,0,0,it.width,it.height,Ge,Xe,it.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,_t,it.width,it.height,0,Ge,Xe,it.data)}}}else{if(Ce=M.mipmaps,G&&ye){if(Ce.length>0)xe++;let fe=Wt(Ee[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,xe,_t,fe.width,fe.height)}for(let fe=0;fe<6;fe++)if(Ve){if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,0,0,Ee[fe].width,Ee[fe].height,Ge,Xe,Ee[fe].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,_t,Ee[fe].width,Ee[fe].height,0,Ge,Xe,Ee[fe].data);for(let Ae=0;Ae<Ce.length;Ae++){let zt=Ce[Ae].image[fe].image;if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,0,0,zt.width,zt.height,Ge,Xe,zt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,_t,zt.width,zt.height,0,Ge,Xe,zt.data)}}else{if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,0,0,Ge,Xe,Ee[fe])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,_t,Ge,Xe,Ee[fe]);for(let Ae=0;Ae<Ce.length;Ae++){let it=Ce[Ae];if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,0,0,Ge,Xe,it.image[fe])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,_t,Ge,Xe,it.image[fe])}}}if(p(M))b(e.TEXTURE_CUBE_MAP);if(ge.__version=he.version,M.onUpdate)M.onUpdate(M)}C.__version=M.version}function ce(C,M,V,Q,he,ge){let ve=s.convert(V.format,V.colorSpace),re=s.convert(V.type),oe=x(V.internalFormat,ve,re,V.normalized,V.colorSpace),Ie=i.get(M),Ve=i.get(V);if(Ve.__renderTarget=M,!Ie.__hasExternalTextures){let Ee=Math.max(1,M.width>>ge),me=Math.max(1,M.height>>ge);if(he===e.TEXTURE_3D||he===e.TEXTURE_2D_ARRAY)n.texImage3D(he,ge,oe,Ee,me,M.depth,0,ve,re,null);else n.texImage2D(he,ge,oe,Ee,me,0,ve,re,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,C),z(M))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,Q,he,Ve.__webglTexture,0,tn(M));else if(he===e.TEXTURE_2D||he>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&he<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,Q,he,Ve.__webglTexture,ge);n.bindFramebuffer(e.FRAMEBUFFER,null)}function _e(C,M,V){if(e.bindRenderbuffer(e.RENDERBUFFER,C),M.depthBuffer){let Q=M.depthTexture,he=Q&&Q.isDepthTexture?Q.type:null,ge=v(M.stencilBuffer,he),ve=M.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(z(M))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,tn(M),ge,M.width,M.height);else if(V)e.renderbufferStorageMultisample(e.RENDERBUFFER,tn(M),ge,M.width,M.height);else e.renderbufferStorage(e.RENDERBUFFER,ge,M.width,M.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,ve,e.RENDERBUFFER,C)}else{let Q=M.textures;for(let he=0;he<Q.length;he++){let ge=Q[he],ve=s.convert(ge.format,ge.colorSpace),re=s.convert(ge.type),oe=x(ge.internalFormat,ve,re,ge.normalized,ge.colorSpace);if(z(M))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,tn(M),oe,M.width,M.height);else if(V)e.renderbufferStorageMultisample(e.RENDERBUFFER,tn(M),oe,M.width,M.height);else e.renderbufferStorage(e.RENDERBUFFER,oe,M.width,M.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Re(C,M,V){let Q=M.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,C),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let he=i.get(M.depthTexture);if(he.__renderTarget=M,!he.__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0;if(Q){if(he.__webglInit===void 0)he.__webglInit=!0,M.depthTexture.addEventListener("dispose",S);if(he.__webglTexture===void 0){he.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,he.__webglTexture),pe(e.TEXTURE_CUBE_MAP,M.depthTexture);let Ie=s.convert(M.depthTexture.format),Ve=s.convert(M.depthTexture.type),Ee;if(M.depthTexture.format===ga)Ee=e.DEPTH_COMPONENT24;else if(M.depthTexture.format===ba)Ee=e.DEPTH24_STENCIL8;for(let me=0;me<6;me++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+me,0,Ee,M.width,M.height,0,Ie,Ve,null)}}else K(M.depthTexture,0);let ge=he.__webglTexture,ve=tn(M),re=Q?e.TEXTURE_CUBE_MAP_POSITIVE_X+V:e.TEXTURE_2D,oe=M.depthTexture.format===ba?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(M.depthTexture.format===ga)if(z(M))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,oe,re,ge,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,oe,re,ge,0);else if(M.depthTexture.format===ba)if(z(M))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,oe,re,ge,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,oe,re,ge,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Oe(C){let M=i.get(C),V=C.isWebGLCubeRenderTarget===!0;if(M.__boundDepthTexture!==C.depthTexture){let Q=C.depthTexture;if(M.__depthDisposeCallback)M.__depthDisposeCallback();if(Q){let he=()=>{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,Q.removeEventListener("dispose",he)};Q.addEventListener("dispose",he),M.__depthDisposeCallback=he}M.__boundDepthTexture=Q}if(C.depthTexture&&!M.__autoAllocateDepthBuffer)if(V)for(let Q=0;Q<6;Q++)Re(M.__webglFramebuffer[Q],C,Q);else{let Q=C.texture.mipmaps;if(Q&&Q.length>0)Re(M.__webglFramebuffer[0],C,0);else Re(M.__webglFramebuffer,C,0)}else if(V){M.__webglDepthbuffer=[];for(let Q=0;Q<6;Q++)if(n.bindFramebuffer(e.FRAMEBUFFER,M.__webglFramebuffer[Q]),M.__webglDepthbuffer[Q]===void 0)M.__webglDepthbuffer[Q]=e.createRenderbuffer(),_e(M.__webglDepthbuffer[Q],C,!1);else{let he=C.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ge=M.__webglDepthbuffer[Q];e.bindRenderbuffer(e.RENDERBUFFER,ge),e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,ge)}}else{let Q=C.texture.mipmaps;if(Q&&Q.length>0)n.bindFramebuffer(e.FRAMEBUFFER,M.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,M.__webglFramebuffer);if(M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=e.createRenderbuffer(),_e(M.__webglDepthbuffer,C,!1);else{let he=C.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ge=M.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ge),e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,ge)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function We(C,M,V){let Q=i.get(C);if(M!==void 0)ce(Q.__webglFramebuffer,C,C.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(V!==void 0)Oe(C)}function Ye(C){let M=C.texture,V=i.get(C),Q=i.get(M);C.addEventListener("dispose",T);let he=C.textures,ge=C.isWebGLCubeRenderTarget===!0,ve=he.length>1;if(!ve){if(Q.__webglTexture===void 0)Q.__webglTexture=e.createTexture();Q.__version=M.version,a.memory.textures++}if(ge){V.__webglFramebuffer=[];for(let re=0;re<6;re++)if(M.mipmaps&&M.mipmaps.length>0){V.__webglFramebuffer[re]=[];for(let oe=0;oe<M.mipmaps.length;oe++)V.__webglFramebuffer[re][oe]=e.createFramebuffer()}else V.__webglFramebuffer[re]=e.createFramebuffer()}else{if(M.mipmaps&&M.mipmaps.length>0){V.__webglFramebuffer=[];for(let re=0;re<M.mipmaps.length;re++)V.__webglFramebuffer[re]=e.createFramebuffer()}else V.__webglFramebuffer=e.createFramebuffer();if(ve)for(let re=0,oe=he.length;re<oe;re++){let Ie=i.get(he[re]);if(Ie.__webglTexture===void 0)Ie.__webglTexture=e.createTexture(),a.memory.textures++}if(C.samples>0&&z(C)===!1){V.__webglMultisampledFramebuffer=e.createFramebuffer(),V.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,V.__webglMultisampledFramebuffer);for(let re=0;re<he.length;re++){let oe=he[re];V.__webglColorRenderbuffer[re]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,V.__webglColorRenderbuffer[re]);let Ie=s.convert(oe.format,oe.colorSpace),Ve=s.convert(oe.type),Ee=x(oe.internalFormat,Ie,Ve,oe.normalized,oe.colorSpace,C.isXRRenderTarget===!0),me=tn(C);e.renderbufferStorageMultisample(e.RENDERBUFFER,me,Ee,C.width,C.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+re,e.RENDERBUFFER,V.__webglColorRenderbuffer[re])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),C.depthBuffer)V.__webglDepthRenderbuffer=e.createRenderbuffer(),_e(V.__webglDepthRenderbuffer,C,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ge){n.bindTexture(e.TEXTURE_CUBE_MAP,Q.__webglTexture),pe(e.TEXTURE_CUBE_MAP,M);for(let re=0;re<6;re++)if(M.mipmaps&&M.mipmaps.length>0)for(let oe=0;oe<M.mipmaps.length;oe++)ce(V.__webglFramebuffer[re][oe],C,M,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+re,oe);else ce(V.__webglFramebuffer[re],C,M,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+re,0);if(p(M))b(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(ve){for(let re=0,oe=he.length;re<oe;re++){let Ie=he[re],Ve=i.get(Ie),Ee=e.TEXTURE_2D;if(C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)Ee=C.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Ee,Ve.__webglTexture),pe(Ee,Ie),ce(V.__webglFramebuffer,C,Ie,e.COLOR_ATTACHMENT0+re,Ee,0),p(Ie))b(Ee)}n.unbindTexture()}else{let re=e.TEXTURE_2D;if(C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)re=C.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(re,Q.__webglTexture),pe(re,M),M.mipmaps&&M.mipmaps.length>0)for(let oe=0;oe<M.mipmaps.length;oe++)ce(V.__webglFramebuffer[oe],C,M,e.COLOR_ATTACHMENT0,re,oe);else ce(V.__webglFramebuffer,C,M,e.COLOR_ATTACHMENT0,re,0);if(p(M))b(re);n.unbindTexture()}if(C.depthBuffer)Oe(C)}function Kt(C){let M=C.textures;for(let V=0,Q=M.length;V<Q;V++){let he=M[V];if(p(he)){let ge=_(C),ve=i.get(he).__webglTexture;n.bindTexture(ge,ve),b(ge),n.unbindTexture()}}}let lt=[],Dt=[];function Yt(C){if(C.samples>0){if(z(C)===!1){let{textures:M,width:V,height:Q}=C,he=e.COLOR_BUFFER_BIT,ge=C.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ve=i.get(C),re=M.length>1;if(re)for(let Ie=0;Ie<M.length;Ie++)n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,ve.__webglMultisampledFramebuffer);let oe=C.texture.mipmaps;if(oe&&oe.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer);for(let Ie=0;Ie<M.length;Ie++){if(C.resolveDepthBuffer){if(C.depthBuffer)he|=e.DEPTH_BUFFER_BIT;if(C.stencilBuffer&&C.resolveStencilBuffer)he|=e.STENCIL_BUFFER_BIT}if(re){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ie]);let Ve=i.get(M[Ie]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ve,0)}if(e.blitFramebuffer(0,0,V,Q,0,0,V,Q,he,e.NEAREST),c===!0){if(lt.length=0,Dt.length=0,lt.push(e.COLOR_ATTACHMENT0+Ie),C.depthBuffer&&C.storeMultisampledDepthBuffer===!1)lt.push(ge),Dt.push(ge),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,Dt);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,lt)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),re)for(let Ie=0;Ie<M.length;Ie++){n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ie]);let Ve=i.get(M[Ie]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.TEXTURE_2D,Ve,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglMultisampledFramebuffer)}else if(C.depthBuffer&&C.storeMultisampledDepthBuffer===!1&&c){let M=C.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[M])}}}function tn(C){return Math.min(r.maxSamples,C.samples)}function z(C){let M=i.get(C);return C.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function xn(C){let M=a.render.frame;if(u.get(C)!==M)u.set(C,M),C.update()}function St(C,M){let{colorSpace:V,format:Q,type:he}=C;if(C.isCompressedTexture===!0||C.isVideoTexture===!0)return M;if(V!==si&&V!==xa)if(ot.getTransfer(V)===Bt){if(Q!==fr||he!==Ui)je("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ze("WebGLTextures: Unsupported texture color space:",V);return M}function Wt(C){if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement)l.width=C.naturalWidth||C.width,l.height=C.naturalHeight||C.height;else if(typeof VideoFrame<"u"&&C instanceof VideoFrame)l.width=C.displayWidth,l.height=C.displayHeight;else l.width=C.width,l.height=C.height;return l}this.allocateTextureUnit=D,this.resetTextureUnits=F,this.getTextureUnits=N,this.setTextureUnits=U,this.setTexture2D=K,this.setTexture2DArray=B,this.setTexture3D=X,this.setTextureCube=q,this.rebindTextures=We,this.setupRenderTarget=Ye,this.updateRenderTargetMipmap=Kt,this.updateMultisampleRenderTarget=Yt,this.setupDepthRenderbuffer=Oe,this.setupFrameBufferTexture=ce,this.useMultisampledRTT=z,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function _L(e,t){function n(i,r=xa){let s,a=ot.getTransfer(r);if(i===Ui)return e.UNSIGNED_BYTE;if(i===Mp)return e.UNSIGNED_SHORT_4_4_4_4;if(i===Rp)return e.UNSIGNED_SHORT_5_5_5_1;if(i===uT)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===dT)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===cT)return e.BYTE;if(i===lT)return e.SHORT;if(i===Uc)return e.UNSIGNED_SHORT;if(i===wp)return e.INT;if(i===ds)return e.UNSIGNED_INT;if(i===Fr)return e.FLOAT;if(i===dr)return e.HALF_FLOAT;if(i===fT)return e.ALPHA;if(i===hT)return e.RGB;if(i===fr)return e.RGBA;if(i===ga)return e.DEPTH_COMPONENT;if(i===ba)return e.DEPTH_STENCIL;if(i===pT)return e.RED;if(i===Ip)return e.RED_INTEGER;if(i===ya)return e.RG;if(i===Cp)return e.RG_INTEGER;if(i===Np)return e.RGBA_INTEGER;if(i===Zu||i===Yu||i===Qu||i===ed)if(a===Bt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Zu)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Yu)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Qu)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===ed)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Zu)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Yu)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Qu)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===ed)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Pp||i===Op||i===kp||i===Dp)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Pp)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Op)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===kp)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Dp)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Lp||i===Fp||i===Up||i===Bp||i===zp||i===td||i===Vp)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Lp||i===Fp)return a===Bt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Up)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Bp)return s.COMPRESSED_R11_EAC;if(i===zp)return s.COMPRESSED_SIGNED_R11_EAC;if(i===td)return s.COMPRESSED_RG11_EAC;if(i===Vp)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===jp||i===Hp||i===Gp||i===$p||i===Kp||i===Wp||i===Xp||i===qp||i===Jp||i===Zp||i===Yp||i===Qp||i===em||i===tm)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===jp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Hp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Gp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$p)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Kp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Wp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Xp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===qp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Jp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Zp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Yp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Qp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===em)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===tm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===nm||i===im||i===rm)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===nm)return a===Bt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===im)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===rm)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===sm||i===am||i===nd||i===om)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===sm)return s.COMPRESSED_RED_RGTC1_EXT;if(i===am)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===nd)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===om)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Eo)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}class hA{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new pd(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new _i({vertexShader:vL,fragmentShader:EL,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new jt(new Jc(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}function AL(e,t){function n(m,p){if(m.matrixAutoUpdate===!0)m.updateMatrix();p.value.copy(m.matrix)}function i(m,p){if(p.color.getRGB(m.fogColor.value,xm(e)),p.isFog)m.fogNear.value=p.near,m.fogFar.value=p.far;else if(p.isFogExp2)m.fogDensity.value=p.density}function r(m,p,b,_,x){if(p.isNodeMaterial)p.uniformsNeedUpdate=!1;else if(p.isMeshBasicMaterial)s(m,p);else if(p.isMeshLambertMaterial){if(s(m,p),p.envMap)m.envMapIntensity.value=p.envMapIntensity}else if(p.isMeshToonMaterial)s(m,p),d(m,p);else if(p.isMeshPhongMaterial){if(s(m,p),u(m,p),p.envMap)m.envMapIntensity.value=p.envMapIntensity}else if(p.isMeshStandardMaterial){if(s(m,p),f(m,p),p.isMeshPhysicalMaterial)h(m,p,x)}else if(p.isMeshMatcapMaterial)s(m,p),y(m,p);else if(p.isMeshDepthMaterial)s(m,p);else if(p.isMeshDistanceMaterial)s(m,p),g(m,p);else if(p.isMeshNormalMaterial)s(m,p);else if(p.isLineBasicMaterial){if(a(m,p),p.isLineDashedMaterial)o(m,p)}else if(p.isPointsMaterial)c(m,p,b,_);else if(p.isSpriteMaterial)l(m,p);else if(p.isShadowMaterial)m.color.value.copy(p.color),m.opacity.value=p.opacity;else if(p.isShaderMaterial)p.uniformsNeedUpdate=!1}function s(m,p){if(m.opacity.value=p.opacity,p.color)m.diffuse.value.copy(p.color);if(p.emissive)m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity);if(p.map)m.map.value=p.map,n(p.map,m.mapTransform);if(p.alphaMap)m.alphaMap.value=p.alphaMap,n(p.alphaMap,m.alphaMapTransform);if(p.bumpMap){if(m.bumpMap.value=p.bumpMap,n(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===Pn)m.bumpScale.value*=-1}if(p.normalMap){if(m.normalMap.value=p.normalMap,n(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===Pn)m.normalScale.value.negate()}if(p.displacementMap)m.displacementMap.value=p.displacementMap,n(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias;if(p.emissiveMap)m.emissiveMap.value=p.emissiveMap,n(p.emissiveMap,m.emissiveMapTransform);if(p.specularMap)m.specularMap.value=p.specularMap,n(p.specularMap,m.specularMapTransform);if(p.alphaTest>0)m.alphaTest.value=p.alphaTest;let b=t.get(p),{envMap:_,envMapRotation:x}=b;if(_){if(m.envMap.value=_,m.envMapRotation.value.setFromMatrix4(TL.makeRotationFromEuler(x)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1)m.envMapRotation.value.premultiply(mA);m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio}if(p.lightMap)m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,n(p.lightMap,m.lightMapTransform);if(p.aoMap)m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,n(p.aoMap,m.aoMapTransform)}function a(m,p){if(m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map)m.map.value=p.map,n(p.map,m.mapTransform)}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function c(m,p,b,_){if(m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*b,m.scale.value=_*0.5,p.map)m.map.value=p.map,n(p.map,m.uvTransform);if(p.alphaMap)m.alphaMap.value=p.alphaMap,n(p.alphaMap,m.alphaMapTransform);if(p.alphaTest>0)m.alphaTest.value=p.alphaTest}function l(m,p){if(m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map)m.map.value=p.map,n(p.map,m.mapTransform);if(p.alphaMap)m.alphaMap.value=p.alphaMap,n(p.alphaMap,m.alphaMapTransform);if(p.alphaTest>0)m.alphaTest.value=p.alphaTest}function u(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,0.0001)}function d(m,p){if(p.gradientMap)m.gradientMap.value=p.gradientMap}function f(m,p){if(m.metalness.value=p.metalness,p.metalnessMap)m.metalnessMap.value=p.metalnessMap,n(p.metalnessMap,m.metalnessMapTransform);if(m.roughness.value=p.roughness,p.roughnessMap)m.roughnessMap.value=p.roughnessMap,n(p.roughnessMap,m.roughnessMapTransform);if(p.envMap)m.envMapIntensity.value=p.envMapIntensity}function h(m,p,b){if(m.ior.value=p.ior,p.sheen>0){if(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap)m.sheenColorMap.value=p.sheenColorMap,n(p.sheenColorMap,m.sheenColorMapTransform);if(p.sheenRoughnessMap)m.sheenRoughnessMap.value=p.sheenRoughnessMap,n(p.sheenRoughnessMap,m.sheenRoughnessMapTransform)}if(p.clearcoat>0){if(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap)m.clearcoatMap.value=p.clearcoatMap,n(p.clearcoatMap,m.clearcoatMapTransform);if(p.clearcoatRoughnessMap)m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,n(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform);if(p.clearcoatNormalMap){if(m.clearcoatNormalMap.value=p.clearcoatNormalMap,n(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Pn)m.clearcoatNormalScale.value.negate()}}if(p.dispersion>0)m.dispersion.value=p.dispersion;if(p.retroreflectivity>0)m.retroreflectivity.value=p.retroreflectivity;if(p.iridescence>0){if(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap)m.iridescenceMap.value=p.iridescenceMap,n(p.iridescenceMap,m.iridescenceMapTransform);if(p.iridescenceThicknessMap)m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,n(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform)}if(p.transmission>0){if(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),p.transmissionMap)m.transmissionMap.value=p.transmissionMap,n(p.transmissionMap,m.transmissionMapTransform);if(m.thickness.value=p.thickness,p.thicknessMap)m.thicknessMap.value=p.thicknessMap,n(p.thicknessMap,m.thicknessMapTransform);m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)}if(p.anisotropy>0){if(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap)m.anisotropyMap.value=p.anisotropyMap,n(p.anisotropyMap,m.anisotropyMapTransform)}if(m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap)m.specularColorMap.value=p.specularColorMap,n(p.specularColorMap,m.specularColorMapTransform);if(p.specularIntensityMap)m.specularIntensityMap.value=p.specularIntensityMap,n(p.specularIntensityMap,m.specularIntensityMapTransform)}function y(m,p){if(p.matcap)m.matcap.value=p.matcap}function g(m,p){let b=t.get(p).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function SL(e,t,n,i){let r={},s={},a=[],o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(x,v){let E=v.program;i.uniformBlockBinding(x,E)}function l(x,v){let E=r[x.id];if(E===void 0)m(x),E=u(x),r[x.id]=E,x.addEventListener("dispose",b);let S=v.program;i.updateUBOMapping(x,S);let T=t.render.frame;if(s[x.id]!==T)f(x),s[x.id]=T}function u(x){let v=d();x.__bindingPointIndex=v;let E=e.createBuffer(),{__size:S,usage:T}=x;return e.bindBuffer(e.UNIFORM_BUFFER,E),e.bufferData(e.UNIFORM_BUFFER,S,T),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,v,E),E}function d(){for(let x=0;x<o;x++)if(a.indexOf(x)===-1)return a.push(x),x;return Ze("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(x){let v=r[x.id],{uniforms:E,__cache:S}=x;e.bindBuffer(e.UNIFORM_BUFFER,v);for(let T=0,A=E.length;T<A;T++){let P=E[T];if(Array.isArray(P))for(let w=0,I=P.length;w<I;w++)h(P[w],T,w,S);else h(P,T,0,S)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function h(x,v,E,S){if(g(x,v,E,S)===!0){let{__offset:T,value:A}=x;if(Array.isArray(A)){let P=0;for(let w=0;w<A.length;w++){let I=A[w],F=p(I);if(y(I,x.__data,P),typeof I!=="number"&&typeof I!=="boolean"&&!I.isMatrix3&&!ArrayBuffer.isView(I))P+=F.storage/Float32Array.BYTES_PER_ELEMENT}}else y(A,x.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,T,x.__data)}}function y(x,v,E){if(typeof x==="number"||typeof x==="boolean")v[0]=x;else if(x.isMatrix3)v[0]=x.elements[0],v[1]=x.elements[1],v[2]=x.elements[2],v[3]=0,v[4]=x.elements[3],v[5]=x.elements[4],v[6]=x.elements[5],v[7]=0,v[8]=x.elements[6],v[9]=x.elements[7],v[10]=x.elements[8],v[11]=0;else if(ArrayBuffer.isView(x))v.set(new x.constructor(x.buffer,x.byteOffset,v.length));else x.toArray(v,E)}function g(x,v,E,S){let T=x.value,A=v+"_"+E;if(S[A]===void 0){if(typeof T==="number"||typeof T==="boolean")S[A]=T;else if(ArrayBuffer.isView(T))S[A]=T.slice();else S[A]=T.clone();return!0}else{let P=S[A];if(typeof T==="number"||typeof T==="boolean"){if(P!==T)return S[A]=T,!0}else if(ArrayBuffer.isView(T))return!0;else if(P.equals(T)===!1)return P.copy(T),!0}return!1}function m(x){let v=x.uniforms,E=0,S=16;for(let A=0,P=v.length;A<P;A++){let w=Array.isArray(v[A])?v[A]:[v[A]];for(let I=0,F=w.length;I<F;I++){let N=w[I],U=Array.isArray(N.value)?N.value:[N.value];for(let D=0,O=U.length;D<O;D++){let K=U[D],B=p(K),X=E%S,q=X%B.boundary,le=X+q;if(E+=q,le!==0&&S-le<B.storage)E+=S-le;N.__data=new Float32Array(B.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=E,E+=B.storage}}}let T=E%S;if(T>0)E+=S-T;return x.__size=E,x.__cache={},this}function p(x){let v={boundary:0,storage:0};if(typeof x==="number"||typeof x==="boolean")v.boundary=4,v.storage=4;else if(x.isVector2)v.boundary=8,v.storage=8;else if(x.isVector3||x.isColor)v.boundary=16,v.storage=12;else if(x.isVector4)v.boundary=16,v.storage=16;else if(x.isMatrix3)v.boundary=48,v.storage=48;else if(x.isMatrix4)v.boundary=64,v.storage=64;else if(x.isTexture)je("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(x))v.boundary=16,v.storage=x.byteLength;else je("WebGLRenderer: Unsupported uniform value type.",x);return v}function b(x){let v=x.target;v.removeEventListener("dispose",b);let E=a.indexOf(v.__bindingPointIndex);a.splice(E,1),e.deleteBuffer(r[v.id]),delete r[v.id],delete s[v.id]}function _(){for(let x in r)e.deleteBuffer(r[x]);a=[],r={},s={}}return{bind:c,update:l,dispose:_}}function ML(){if(pr===null)pr=new $c(wL,16,16,ya,dr),pr.name="DFG_LUT",pr.minFilter=En,pr.magFilter=En,pr.wrapS=_o,pr.wrapT=_o,pr.generateMipmaps=!1,pr.needsUpdate=!0;return pr}class Km{constructor(e={}){let{canvas:t=ET(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=Ui}=e;this.isWebGLRenderer=!0;let h;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");h=n.getContextAttributes().alpha}else h=s;let y=f,g=new Set([Np,Cp,Ip]),m=new Set([Ui,ds,Uc,Eo,Mp,Rp]),p=new Uint32Array(4),b=new Int32Array(4),_=new j,x=null,v=null,E=[],S=[],T=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Li,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let A=this,P=!1,w=null,I=null,F=null,N=null;this._outputColorSpace=fs;let U=0,D=0,O=null,K=-1,B=null,X=new Nt,q=new Nt,le=null,de=new qe(0),Me=0,{width:pe,height:J}=t,L=1,W=null,te=null,ie=new Nt(0,0,pe,J),ce=new Nt(0,0,pe,J),_e=!1,Re=new Wc,Oe=!1,We=!1,Ye=new Qe,Kt=new j,lt=new Nt,Dt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Yt=!1;function tn(){return O===null?L:1}let z=n;function xn(R,H){return t.getContext(R,H)}let St,Wt,C,M,V,Q,he,ge,ve,re,oe,Ie,Ve,Ee,me,Ge,Xe,_t,G,ye,ae,xe,Ce;try{let R={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${RE}`);if(t.addEventListener("webglcontextlost",it,!1),t.addEventListener("webglcontextrestored",zt,!1),t.addEventListener("webglcontextcreationerror",wt,!1),z===null){if(z=xn("webgl2",R),z===null)if(xn("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}fe()}catch(R){throw t.removeEventListener("webglcontextlost",it,!1),t.removeEventListener("webglcontextrestored",zt,!1),t.removeEventListener("webglcontextcreationerror",wt,!1),Ze("WebGLRenderer: "+R.message),R}function fe(){if(St=new kk(z),St.init(),ae=new _L(z,St),Wt=new Ak(z,St,e,ae),C=new yL(z,St),Wt.reversedDepthBuffer&&d)C.buffers.depth.setReversed(!0);I=z.createFramebuffer(),F=z.createFramebuffer(),N=z.createFramebuffer(),M=new Fk(z),V=new rL,Q=new xL(z,St,C,V,Wt,ae,M),he=new Ok(A),ge=new BN(z),xe=new Ek(z,ge),ve=new Dk(z,ge,M,xe),re=new Bk(z,ve,ge,xe,M),_t=new Uk(z,Wt,Q),me=new Sk(V),oe=new iL(A,he,St,Wt,xe,me),Ie=new AL(A,V),Ve=new aL,Ee=new fL(St),Xe=new vk(A,he,C,re,h,o),Ge=new bL(A,re,Wt),Ce=new SL(z,M,Wt,C),G=new Tk(z,St,M),ye=new Lk(z,St,M),M.programs=oe.programs,A.capabilities=Wt,A.extensions=St,A.properties=V,A.renderLists=Ve,A.shadowMap=Ge,A.state=C,A.info=M}if(y!==Ui)T=new Vk(y,t.width,t.height,a,i,r);let Ae=new pA(A,z);this.xr=Ae,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let R=St.get("WEBGL_lose_context");if(R)R.loseContext()},this.forceContextRestore=function(){let R=St.get("WEBGL_lose_context");if(R)R.restoreContext()},this.getPixelRatio=function(){return L},this.setPixelRatio=function(R){if(R===void 0)return;L=R,this.setSize(pe,J,!1)},this.getSize=function(R){return R.set(pe,J)},this.setSize=function(R,H,ee=!0){if(Ae.isPresenting){je("WebGLRenderer: Can't change size while VR device is presenting.");return}if(pe=R,J=H,t.width=Math.floor(R*L),t.height=Math.floor(H*L),ee===!0)t.style.width=R+"px",t.style.height=H+"px";if(T!==null)T.setSize(t.width,t.height);this.setViewport(0,0,R,H)},this.getDrawingBufferSize=function(R){return R.set(pe*L,J*L).floor()},this.setDrawingBufferSize=function(R,H,ee){pe=R,J=H,L=ee,t.width=Math.floor(R*ee),t.height=Math.floor(H*ee),this.setViewport(0,0,R,H)},this.setEffects=function(R){if(y===Ui){Ze("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(R){for(let H=0;H<R.length;H++)if(R[H].isOutputPass===!0){je("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(R||[])},this.getCurrentViewport=function(R){return R.copy(X)},this.getViewport=function(R){return R.copy(ie)},this.setViewport=function(R,H,ee,Z){if(R.isVector4)ie.set(R.x,R.y,R.z,R.w);else ie.set(R,H,ee,Z);C.viewport(X.copy(ie).multiplyScalar(L).round())},this.getScissor=function(R){return R.copy(ce)},this.setScissor=function(R,H,ee,Z){if(R.isVector4)ce.set(R.x,R.y,R.z,R.w);else ce.set(R,H,ee,Z);C.scissor(q.copy(ce).multiplyScalar(L).round())},this.getScissorTest=function(){return _e},this.setScissorTest=function(R){C.setScissorTest(_e=R)},this.setOpaqueSort=function(R){W=R},this.setTransparentSort=function(R){te=R},this.getClearColor=function(R){return R.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor(...arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha(...arguments)},this.clear=function(R=!0,H=!0,ee=!0){let Z=0;if(R){let Y=!1;if(O!==null){let we=O.texture.format;Y=g.has(we)}if(Y){let we=O.texture.type,Pe=m.has(we),Se=Xe.getClearColor(),ke=Xe.getClearAlpha(),{r:ze,g:rt,b:ft}=Se;if(Pe)p[0]=ze,p[1]=rt,p[2]=ft,p[3]=ke,z.clearBufferuiv(z.COLOR,0,p);else b[0]=ze,b[1]=rt,b[2]=ft,b[3]=ke,z.clearBufferiv(z.COLOR,0,b)}else Z|=z.COLOR_BUFFER_BIT}if(H)Z|=z.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(ee)Z|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(Z!==0)z.clear(Z)},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.setNodesHandler=function(R){R.setRenderer(this),w=R},this.dispose=function(){t.removeEventListener("webglcontextlost",it,!1),t.removeEventListener("webglcontextrestored",zt,!1),t.removeEventListener("webglcontextcreationerror",wt,!1),Xe.dispose(),Ve.dispose(),Ee.dispose(),V.dispose(),he.dispose(),re.dispose(),xe.dispose(),Ce.dispose(),oe.dispose(),Ae.dispose(),Ae.removeEventListener("sessionstart",rb),Ae.removeEventListener("sessionend",sb),Ys.stop()};function it(R){R.preventDefault(),Oc("WebGLRenderer: Context Lost."),P=!0}function zt(){Oc("WebGLRenderer: Context Restored."),P=!1;let R=M.autoReset,H=Ge.enabled,ee=Ge.autoUpdate,Z=Ge.needsUpdate,Y=Ge.type;fe(),M.autoReset=R,Ge.enabled=H,Ge.autoUpdate=ee,Ge.needsUpdate=Z,Ge.type=Y}function wt(R){Ze("WebGLRenderer: A WebGL context could not be created. Reason: ",R.statusMessage)}function $i(R){let H=R.target;H.removeEventListener("dispose",$i),Tr(H)}function Tr(R){pR(R),V.remove(R)}function pR(R){let H=V.get(R).programs;if(H!==void 0){if(H.forEach(function(ee){oe.releaseProgram(ee)}),R.isShaderMaterial)oe.releaseShaderCache(R)}}this.renderBufferDirect=function(R,H,ee,Z,Y,we){if(H===null)H=Dt;let Pe=Y.isMesh&&Y.matrixWorld.determinantAffine()<0,Se=bR(R,H,ee,Z,Y);C.setMaterial(Z,Pe);let ke=ee.index,ze=1;if(Z.wireframe===!0){if(ke=ve.getWireframeAttribute(ee),ke===void 0)return;ze=2}let rt=ee.drawRange,ft=ee.attributes.position,De=rt.start*ze,Mt=(rt.start+rt.count)*ze;if(we!==null)De=Math.max(De,we.start*ze),Mt=Math.min(Mt,(we.start+we.count)*ze);if(ke!==null)De=Math.max(De,0),Mt=Math.min(Mt,ke.count);else if(ft!==void 0&&ft!==null)De=Math.max(De,0),Mt=Math.min(Mt,ft.count);let an=Mt-De;if(an<0||an===1/0)return;xe.setup(Y,Z,Se,ee,ke);let Ht,Lt=G;if(ke!==null)Ht=ge.get(ke),Lt=ye,Lt.setIndex(Ht);if(Y.isMesh)if(Z.wireframe===!0)C.setLineWidth(Z.wireframeLinewidth*tn()),Lt.setMode(z.LINES);else Lt.setMode(z.TRIANGLES);else if(Y.isLine){let Rn=Z.linewidth;if(Rn===void 0)Rn=1;if(C.setLineWidth(Rn*tn()),Y.isLineSegments)Lt.setMode(z.LINES);else if(Y.isLineLoop)Lt.setMode(z.LINE_LOOP);else Lt.setMode(z.LINE_STRIP)}else if(Y.isPoints)Lt.setMode(z.POINTS);else if(Y.isSprite)Lt.setMode(z.TRIANGLES);if(Y.isBatchedMesh)if(!St.get("WEBGL_multi_draw")){let{_multiDrawStarts:Rn,_multiDrawCounts:Ne,_multiDrawCount:Dn}=Y,bt=ke?ge.get(ke).bytesPerElement:1,fi=V.get(Z).currentProgram.getUniforms();for(let Ki=0;Ki<Dn;Ki++)fi.setValue(z,"_gl_DrawID",Ki),Lt.render(Rn[Ki]/bt,Ne[Ki])}else Lt.renderMultiDraw(Y._multiDrawStarts,Y._multiDrawCounts,Y._multiDrawCount);else if(Y.isInstancedMesh)Lt.renderInstances(De,an,Y.count);else if(ee.isInstancedBufferGeometry){let Rn=ee._maxInstanceCount!==void 0?ee._maxInstanceCount:1/0,Ne=Math.min(ee.instanceCount,Rn);Lt.renderInstances(De,an,Ne)}else Lt.render(De,an)};function ib(R,H,ee,Z){if(w!==null&&R.isNodeMaterial)w.setObject(Z,R);if(Oe===!0)me.setState(R,ee,!1);if(R.transparent===!0&&R.side===xi&&R.forceSinglePass===!1)R.side=Pn,R.needsUpdate=!0,Ml(R,H,Z),R.side=us,R.needsUpdate=!0,Ml(R,H,Z),R.side=xi;else Ml(R,H,Z)}this.compile=function(R,H,ee=null){if(ee===null)ee=R;if(w!==null)w.renderStart(R,H,ee);if(v=Ee.get(ee),v.init(H),S.push(v),ee.traverseVisible(function(Y){if(Y.isLight&&Y.layers.test(H.layers)){if(v.pushLight(Y),Y.castShadow)v.pushShadow(Y)}}),R!==ee)R.traverseVisible(function(Y){if(Y.isLight&&Y.layers.test(H.layers)){if(v.pushLight(Y),Y.castShadow)v.pushShadow(Y)}});if(v.setupLights(),w!==null)w.updateLights(v.state.lightsArray);if(We=this.localClippingEnabled,Oe=me.init(this.clippingPlanes,We),Oe===!0)me.setGlobalState(this.clippingPlanes,H);if(w!==null)Ge.render(v.state.shadowsArray,ee,H);let Z=new Set;if(R.traverse(function(Y){if(!(Y.isMesh||Y.isPoints||Y.isLine||Y.isSprite))return;let we=Y.material;if(we)if(Array.isArray(we))for(let Pe=0;Pe<we.length;Pe++){let Se=we[Pe];ib(Se,ee,H,Y),Z.add(Se)}else ib(we,ee,H,Y),Z.add(we)}),v=S.pop(),w!==null)w.renderEnd();return Z},this.compileAsync=function(R,H,ee=null){let Z=this.compile(R,H,ee);return new Promise((Y)=>{function we(){if(Z.forEach(function(Pe){let ke=V.get(Pe).currentProgram;if(ke===void 0||ke.isReady())Z.delete(Pe)}),Z.size===0){Y(R);return}setTimeout(we,10)}if(St.get("KHR_parallel_shader_compile")!==null)we();else setTimeout(we,10)})};let pf=null;function mR(R){if(pf)pf(R)}function rb(){Ys.stop()}function sb(){Ys.start()}let Ys=new nA;if(Ys.setAnimationLoop(mR),typeof self<"u")Ys.setContext(self);this.setAnimationLoop=function(R){pf=R,Ae.setAnimationLoop(R),R===null?Ys.stop():Ys.start()},Ae.addEventListener("sessionstart",rb),Ae.addEventListener("sessionend",sb),this.render=function(R,H){if(H!==void 0&&H.isCamera!==!0){Ze("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;if(w!==null)w.renderStart(R,H);let ee=Ae.enabled===!0&&Ae.isPresenting===!0,Z=T!==null&&(O===null||ee)&&T.begin(A,O);if(R.matrixWorldAutoUpdate===!0)R.updateMatrixWorld();if(H.parent===null&&H.matrixWorldAutoUpdate===!0)H.updateMatrixWorld();if(Ae.enabled===!0&&Ae.isPresenting===!0&&(T===null||T.isCompositing()===!1)){if(Ae.cameraAutoUpdate===!0)Ae.updateCamera(H);H=Ae.getCamera()}if(R.isScene===!0)R.onBeforeRender(A,R,H,O);if(v=Ee.get(R,S.length),v.init(H),v.state.textureUnits=Q.getTextureUnits(),S.push(v),Ye.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse),Re.setFromProjectionMatrix(Ye,hm,H.reversedDepth),We=this.localClippingEnabled,Oe=me.init(this.clippingPlanes,We),x=Ve.get(R,E.length),x.init(),E.push(x),Ae.enabled===!0&&Ae.isPresenting===!0){let Pe=A.xr.getDepthSensingMesh();if(Pe!==null)mf(Pe,H,-1/0,A.sortObjects)}if(mf(R,H,0,A.sortObjects),x.finish(),w!==null)w.updateLights(v.state.lightsArray);if(A.sortObjects===!0)x.sort(W,te);if(Yt=Ae.enabled===!1||Ae.isPresenting===!1||Ae.hasDepthSensing()===!1,Yt)Xe.addToRenderList(x,R);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Oe===!0)me.beginShadows();let Y=v.state.shadowsArray;if(Ge.render(Y,R,H),Oe===!0)me.endShadows();if((Z&&T.hasRenderPass())===!1){let Pe=x.opaque,Se=x.transmissive;if(v.setupLights(),H.isArrayCamera){let ke=H.cameras;if(Se.length>0)for(let ze=0,rt=ke.length;ze<rt;ze++){let ft=ke[ze];ob(Pe,Se,R,ft)}if(Yt)Xe.render(R);for(let ze=0,rt=ke.length;ze<rt;ze++){let ft=ke[ze];ab(x,R,ft,ft.viewport)}}else{if(Se.length>0)ob(Pe,Se,R,H);if(Yt)Xe.render(R);ab(x,R,H)}}if(O!==null&&D===0)Q.updateMultisampleRenderTarget(O),Q.updateRenderTargetMipmap(O);if(Z)T.end(A);if(R.isScene===!0)R.onAfterRender(A,R,H);if(xe.resetDefaultState(),K=-1,B=null,S.pop(),S.length>0){if(v=S[S.length-1],Q.setTextureUnits(v.state.textureUnits),Oe===!0)me.setGlobalState(A.clippingPlanes,v.state.camera)}else v=null;if(E.pop(),E.length>0)x=E[E.length-1];else x=null;if(w!==null)w.renderEnd()};function mf(R,H,ee,Z){if(R.visible===!1)return;if(R.layers.test(H.layers)){if(R.isGroup)ee=R.renderOrder;else if(R.isLOD){if(R.autoUpdate===!0)R.update(H)}else if(R.isLightProbeGrid)v.pushLightProbeGrid(R);else if(R.isLight){if(v.pushLight(R),R.castShadow)v.pushShadow(R)}else if(R.isSprite){if(!R.frustumCulled||R.intersectsFrustum(Re)){if(Z)lt.setFromMatrixPosition(R.matrixWorld).applyMatrix4(Ye);let Pe=re.update(R),Se=R.material;if(Se.visible)x.push(R,Pe,Se,ee,lt.z,null,H)}}else if(R.isMesh||R.isLine||R.isPoints){if(!R.frustumCulled||R.intersectsFrustum(Re)){let Pe=re.update(R),Se=R.material;if(Z){if(R.boundingSphere!==void 0){if(R.boundingSphere===null)R.computeBoundingSphere();lt.copy(R.boundingSphere.center)}else{if(Pe.boundingSphere===null)Pe.computeBoundingSphere();lt.copy(Pe.boundingSphere.center)}lt.applyMatrix4(R.matrixWorld).applyMatrix4(Ye)}if(Array.isArray(Se)){let ke=Pe.groups;for(let ze=0,rt=ke.length;ze<rt;ze++){let ft=ke[ze],De=Se[ft.materialIndex];if(De&&De.visible)x.push(R,Pe,De,ee,lt.z,ft,H)}}else if(Se.visible)x.push(R,Pe,Se,ee,lt.z,null,H)}}}let we=R.children;for(let Pe=0,Se=we.length;Pe<Se;Pe++)mf(we[Pe],H,ee,Z)}function ab(R,H,ee,Z){let{opaque:Y,transmissive:we,transparent:Pe}=R;if(v.setupLightsView(ee),Oe===!0)me.setGlobalState(A.clippingPlanes,ee);if(Z)C.viewport(X.copy(Z));if(Y.length>0)wl(Y,H,ee);if(we.length>0)wl(we,H,ee);if(Pe.length>0)wl(Pe,H,ee);C.buffers.depth.setTest(!0),C.buffers.depth.setMask(!0),C.buffers.color.setMask(!0),C.setPolygonOffset(!1)}function ob(R,H,ee,Z){if((ee.isScene===!0?ee.overrideMaterial:null)!==null)return;if(v.state.transmissionRenderTarget[Z.id]===void 0){let De=St.has("EXT_color_buffer_half_float")||St.has("EXT_color_buffer_float");v.state.transmissionRenderTarget[Z.id]=new ai(1,1,{generateMipmaps:!0,type:De?dr:Ui,minFilter:ur,samples:Math.max(4,Wt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:ot.workingColorSpace})}let we=v.state.transmissionRenderTarget[Z.id],Pe=Z.viewport||X;we.setSize(Pe.z*A.transmissionResolutionScale,Pe.w*A.transmissionResolutionScale);let Se=A.getRenderTarget(),ke=A.getActiveCubeFace(),ze=A.getActiveMipmapLevel();if(A.setRenderTarget(we),A.getClearColor(de),Me=A.getClearAlpha(),Me<1)A.setClearColor(16777215,0.5);if(A.clear(),Yt)Xe.render(ee);let rt=A.toneMapping;A.toneMapping=Li;let ft=Z.viewport;if(Z.viewport!==void 0)Z.viewport=void 0;if(v.setupLightsView(Z),Oe===!0)me.setGlobalState(A.clippingPlanes,Z);if(wl(R,ee,Z),Q.updateMultisampleRenderTarget(we),Q.updateRenderTargetMipmap(we),St.has("WEBGL_multisampled_render_to_texture")===!1){let De=!1;for(let Mt=0,an=H.length;Mt<an;Mt++){let Ht=H[Mt],{object:Lt,geometry:Rn,material:Ne,group:Dn}=Ht;if(Ne.side===xi&&Lt.layers.test(Z.layers)){let bt=Ne.side;Ne.side=Pn,Ne.needsUpdate=!0,cb(Lt,ee,Z,Rn,Ne,Dn),Ne.side=bt,Ne.needsUpdate=!0,De=!0}}if(De===!0)Q.updateMultisampleRenderTarget(we),Q.updateRenderTargetMipmap(we)}if(A.setRenderTarget(Se,ke,ze),A.setClearColor(de,Me),ft!==void 0)Z.viewport=ft;A.toneMapping=rt}function wl(R,H,ee){let Z=H.isScene===!0?H.overrideMaterial:null;for(let Y=0,we=R.length;Y<we;Y++){let Pe=R[Y],{object:Se,geometry:ke,group:ze}=Pe,rt=Pe.material;if(rt.allowOverride===!0&&Z!==null)rt=Z;if(Se.layers.test(ee.layers))cb(Se,H,ee,ke,rt,ze)}}function cb(R,H,ee,Z,Y,we){if(w!==null&&Y.isNodeMaterial)w.setObject(R,Y);if(R.onBeforeRender(A,H,ee,Z,Y,we),R.modelViewMatrix.multiplyMatrices(ee.matrixWorldInverse,R.matrixWorld),R.normalMatrix.getNormalMatrix(R.modelViewMatrix),Y.onBeforeRender(A,H,ee,Z,R,we),Y.transparent===!0&&Y.side===xi&&Y.forceSinglePass===!1)Y.side=Pn,Y.needsUpdate=!0,A.renderBufferDirect(ee,H,Z,Y,R,we),Y.side=us,Y.needsUpdate=!0,A.renderBufferDirect(ee,H,Z,Y,R,we),Y.side=xi;else A.renderBufferDirect(ee,H,Z,Y,R,we);R.onAfterRender(A,H,ee,Z,Y,we)}function Ml(R,H,ee){if(H.isScene!==!0)H=Dt;let Z=V.get(R),Y=v.state.lights,we=v.state.shadowsArray,Pe=Y.state.version,Se=oe.getParameters(R,Y.state,we,H,ee,v.state.lightProbeGridArray),ke=oe.getProgramCacheKey(Se),ze=Z.programs;Z.environment=R.isMeshStandardMaterial||R.isMeshLambertMaterial||R.isMeshPhongMaterial?H.environment:null,Z.fog=H.fog;let rt=R.isMeshStandardMaterial||R.isMeshLambertMaterial&&!R.envMap||R.isMeshPhongMaterial&&!R.envMap;if(Z.envMap=he.get(R.envMap||Z.environment,rt),Z.envMapRotation=Z.environment!==null&&R.envMap===null?H.environmentRotation:R.envMapRotation,ze===void 0)R.addEventListener("dispose",$i),ze=new Map,Z.programs=ze;let ft=ze.get(ke);if(ft!==void 0){if(Z.currentProgram===ft&&Z.lightsStateVersion===Pe)return ub(R,Se),ft}else{if(Se.uniforms=oe.getUniforms(R),w!==null&&R.isNodeMaterial)w.build(R,ee,Se);R.onBeforeCompile(Se,A),ft=oe.acquireProgram(Se,ke),ze.set(ke,ft),Z.uniforms=Se.uniforms}let De=Z.uniforms;if(!R.isShaderMaterial&&!R.isRawShaderMaterial||R.clipping===!0)De.clippingPlanes=me.uniform;if(ub(R,Se),Z.needsLights=xR(R),Z.lightsStateVersion=Pe,Z.needsLights)De.ambientLightColor.value=Y.state.ambient,De.lightProbe.value=Y.state.probe,De.sunLights.value=Y.state.sun,De.sunLightShadows.value=Y.state.sunShadow,De.directionalLights.value=Y.state.directional,De.directionalLightShadows.value=Y.state.directionalShadow,De.spotLights.value=Y.state.spot,De.spotLightShadows.value=Y.state.spotShadow,De.rectAreaLights.value=Y.state.rectArea,De.ltc_1.value=Y.state.rectAreaLTC1,De.ltc_2.value=Y.state.rectAreaLTC2,De.pointLights.value=Y.state.point,De.pointLightShadows.value=Y.state.pointShadow,De.hemisphereLights.value=Y.state.hemi,De.sunShadowMatrix.value=Y.state.sunShadowMatrix,De.sunShadowCascade.value=Y.state.sunShadowCascade,De.directionalShadowMatrix.value=Y.state.directionalShadowMatrix,De.spotLightMatrix.value=Y.state.spotLightMatrix,De.spotLightMap.value=Y.state.spotLightMap,De.pointShadowMatrix.value=Y.state.pointShadowMatrix;return Z.lightProbeGrid=v.state.lightProbeGridArray.length>0,Z.currentProgram=ft,Z.uniformsList=null,ft}function lb(R){if(R.uniformsList===null){let H=R.currentProgram.getUniforms();R.uniformsList=rl.seqWithValue(H.seq,R.uniforms)}return R.uniformsList}function ub(R,H){let ee=V.get(R);ee.outputColorSpace=H.outputColorSpace,ee.batching=H.batching,ee.batchingColor=H.batchingColor,ee.instancing=H.instancing,ee.instancingColor=H.instancingColor,ee.instancingMorph=H.instancingMorph,ee.skinning=H.skinning,ee.morphTargets=H.morphTargets,ee.morphNormals=H.morphNormals,ee.morphColors=H.morphColors,ee.morphTargetsCount=H.morphTargetsCount,ee.numClippingPlanes=H.numClippingPlanes,ee.numIntersection=H.numClipIntersection,ee.vertexAlphas=H.vertexAlphas,ee.vertexTangents=H.vertexTangents,ee.toneMapping=H.toneMapping}function gR(R,H){if(R.length===0)return null;if(R.length===1)return R[0].texture!==null?R[0]:null;_.setFromMatrixPosition(H.matrixWorld);for(let ee=0,Z=R.length;ee<Z;ee++){let Y=R[ee];if(Y.texture!==null&&Y.boundingBox.containsPoint(_))return Y}return null}function bR(R,H,ee,Z,Y){if(H.isScene!==!0)H=Dt;Q.resetTextureUnits();let we=H.fog,Pe=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial?H.environment:null,Se=O===null?A.outputColorSpace:O.isXRRenderTarget===!0?O.texture.colorSpace:ot.workingColorSpace,ke=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial&&!Z.envMap||Z.isMeshPhongMaterial&&!Z.envMap,ze=he.get(Z.envMap||Pe,ke),rt=Z.vertexColors===!0&&!!ee.attributes.color&&ee.attributes.color.itemSize===4,ft=!!ee.attributes.tangent&&(!!Z.normalMap||Z.anisotropy>0),De=!!ee.morphAttributes.position,Mt=!!ee.morphAttributes.normal,an=!!ee.morphAttributes.color,Ht=Li;if(Z.toneMapped){if(O===null||O.isXRRenderTarget===!0)Ht=A.toneMapping}let Lt=ee.morphAttributes.position||ee.morphAttributes.normal||ee.morphAttributes.color,Rn=Lt!==void 0?Lt.length:0,Ne=V.get(Z),Dn=v.state.lights;if(Oe===!0){if(We===!0||R!==B){let Vt=R===B&&Z.id===K;me.setState(Z,R,Vt)}}let bt=!1;if(Z.version===Ne.__version){if(Ne.needsLights&&Ne.lightsStateVersion!==Dn.state.version)bt=!0;else if(Ne.outputColorSpace!==Se)bt=!0;else if(Y.isBatchedMesh&&Ne.batching===!1)bt=!0;else if(!Y.isBatchedMesh&&Ne.batching===!0)bt=!0;else if(Y.isBatchedMesh&&Ne.batchingColor===!0&&Y._colorsTexture===null)bt=!0;else if(Y.isBatchedMesh&&Ne.batchingColor===!1&&Y._colorsTexture!==null)bt=!0;else if(Y.isInstancedMesh&&Ne.instancing===!1)bt=!0;else if(!Y.isInstancedMesh&&Ne.instancing===!0)bt=!0;else if(Y.isSkinnedMesh&&Ne.skinning===!1)bt=!0;else if(!Y.isSkinnedMesh&&Ne.skinning===!0)bt=!0;else if(Y.isInstancedMesh&&Ne.instancingColor===!0&&Y.instanceColor===null)bt=!0;else if(Y.isInstancedMesh&&Ne.instancingColor===!1&&Y.instanceColor!==null)bt=!0;else if(Y.isInstancedMesh&&Ne.instancingMorph===!0&&Y.morphTexture===null)bt=!0;else if(Y.isInstancedMesh&&Ne.instancingMorph===!1&&Y.morphTexture!==null)bt=!0;else if(Ne.envMap!==ze)bt=!0;else if(Z.fog===!0&&Ne.fog!==we)bt=!0;else if(Ne.numClippingPlanes!==void 0&&(Ne.numClippingPlanes!==me.numPlanes||Ne.numIntersection!==me.numIntersection))bt=!0;else if(Ne.vertexAlphas!==rt)bt=!0;else if(Ne.vertexTangents!==ft)bt=!0;else if(Ne.morphTargets!==De)bt=!0;else if(Ne.morphNormals!==Mt)bt=!0;else if(Ne.morphColors!==an)bt=!0;else if(Ne.toneMapping!==Ht)bt=!0;else if(Ne.morphTargetsCount!==Rn)bt=!0;else if(!!Ne.lightProbeGrid!==v.state.lightProbeGridArray.length>0)bt=!0}else bt=!0,Ne.__version=Z.version;let fi=Ne.currentProgram;if(bt===!0){if(fi=Ml(Z,H,Y),w&&Z.isNodeMaterial)w.onUpdateProgram(Z,fi,Ne)}let Ki=!1,$r=!1,ka=!1,Ot=fi.getUniforms(),nn=Ne.uniforms;if(C.useProgram(fi.program))Ki=!0,$r=!0,ka=!0;if(Z.id!==K)K=Z.id,$r=!0;if(Ne.needsLights){let Vt=gR(v.state.lightProbeGridArray,Y);if(Ne.lightProbeGrid!==Vt)Ne.lightProbeGrid=Vt,$r=!0}if(Ki||B!==R){if(C.buffers.depth.getReversed()&&R.reversedDepth!==!0)R._reversedDepth=!0,R.updateProjectionMatrix();Ot.setValue(z,"projectionMatrix",R.projectionMatrix),Ot.setValue(z,"viewMatrix",R.matrixWorldInverse);let Wr=Ot.map.cameraPosition;if(Wr!==void 0)Wr.setValue(z,Kt.setFromMatrixPosition(R.matrixWorld));if(Wt.logarithmicDepthBuffer)Ot.setValue(z,"logDepthBufFC",2/(Math.log(R.far+1)/Math.LN2));if(Z.isMeshPhongMaterial||Z.isMeshToonMaterial||Z.isMeshLambertMaterial||Z.isMeshBasicMaterial||Z.isMeshStandardMaterial||Z.isShaderMaterial)Ot.setValue(z,"isOrthographic",R.isOrthographicCamera===!0);if(B!==R)B=R,$r=!0,ka=!0}if(Ne.needsLights){if(Dn.state.sunShadowMap.length>0)Ot.setValue(z,"sunShadowMap",Dn.state.sunShadowMap,Q);if(Dn.state.directionalShadowMap.length>0)Ot.setValue(z,"directionalShadowMap",Dn.state.directionalShadowMap,Q);if(Dn.state.spotShadowMap.length>0)Ot.setValue(z,"spotShadowMap",Dn.state.spotShadowMap,Q);if(Dn.state.pointShadowMap.length>0)Ot.setValue(z,"pointShadowMap",Dn.state.pointShadowMap,Q)}if(Y.isSkinnedMesh){Ot.setOptional(z,Y,"bindMatrix"),Ot.setOptional(z,Y,"bindMatrixInverse");let Vt=Y.skeleton;if(Vt){if(Vt.boneTexture===null)Vt.computeBoneTexture();Ot.setValue(z,"boneTexture",Vt.boneTexture,Q)}}if(Y.isBatchedMesh){if(Ot.setOptional(z,Y,"batchingTexture"),Ot.setValue(z,"batchingTexture",Y._matricesTexture,Q),Ot.setOptional(z,Y,"batchingIdTexture"),Ot.setValue(z,"batchingIdTexture",Y._indirectTexture,Q),Ot.setOptional(z,Y,"batchingColorTexture"),Y._colorsTexture!==null)Ot.setValue(z,"batchingColorTexture",Y._colorsTexture,Q)}let Kr=ee.morphAttributes;if(Kr.position!==void 0||Kr.normal!==void 0||Kr.color!==void 0)_t.update(Y,ee,fi);if($r||Ne.receiveShadow!==Y.receiveShadow)Ne.receiveShadow=Y.receiveShadow,Ot.setValue(z,"receiveShadow",Y.receiveShadow);if((Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial)&&Z.envMap===null&&H.environment!==null)nn.envMapIntensity.value=H.environmentIntensity;if(nn.dfgLUT!==void 0)nn.dfgLUT.value=ML();if($r){if(Ot.setValue(z,"toneMappingExposure",A.toneMappingExposure),Ne.needsLights)yR(nn,ka);if(we&&Z.fog===!0)Ie.refreshFogUniforms(nn,we);if(Ie.refreshMaterialUniforms(nn,Z,L,J,v.state.transmissionRenderTarget[R.id]),Ne.needsLights&&Ne.lightProbeGrid){let Vt=Ne.lightProbeGrid;nn.probesSH.value=Vt.texture,nn.probesMin.value.copy(Vt.boundingBox.min),nn.probesMax.value.copy(Vt.boundingBox.max),nn.probesResolution.value.copy(Vt.resolution)}rl.upload(z,lb(Ne),nn,Q)}if(Z.isShaderMaterial&&Z.uniformsNeedUpdate===!0)rl.upload(z,lb(Ne),nn,Q),Z.uniformsNeedUpdate=!1;if(Z.isSpriteMaterial)Ot.setValue(z,"center",Y.center);if(Ot.setValue(z,"modelViewMatrix",Y.modelViewMatrix),Ot.setValue(z,"normalMatrix",Y.normalMatrix),Ot.setValue(z,"modelMatrix",Y.matrixWorld),Z.uniformsGroups!==void 0){let Vt=Z.uniformsGroups;for(let Wr=0,Da=Vt.length;Wr<Da;Wr++){let fb=Vt[Wr];Ce.update(fb,fi),Ce.bind(fb,fi)}}return fi}function yR(R,H){R.ambientLightColor.needsUpdate=H,R.lightProbe.needsUpdate=H,R.sunLights.needsUpdate=H,R.sunLightShadows.needsUpdate=H,R.directionalLights.needsUpdate=H,R.directionalLightShadows.needsUpdate=H,R.pointLights.needsUpdate=H,R.pointLightShadows.needsUpdate=H,R.spotLights.needsUpdate=H,R.spotLightShadows.needsUpdate=H,R.rectAreaLights.needsUpdate=H,R.hemisphereLights.needsUpdate=H}function xR(R){return R.isMeshLambertMaterial||R.isMeshToonMaterial||R.isMeshPhongMaterial||R.isMeshStandardMaterial||R.isShadowMaterial||R.isShaderMaterial&&R.lights===!0}this.getActiveCubeFace=function(){return U},this.getActiveMipmapLevel=function(){return D},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(R,H,ee){let Z=V.get(R);if(Z.__autoAllocateDepthBuffer=R.resolveDepthBuffer===!1,Z.__autoAllocateDepthBuffer===!1)Z.__useRenderToTexture=!1;V.get(R.texture).__webglTexture=H,V.get(R.depthTexture).__webglTexture=Z.__autoAllocateDepthBuffer?void 0:ee,Z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(R,H){let ee=V.get(R);ee.__webglFramebuffer=H,ee.__useDefaultFramebuffer=H===void 0},this.setRenderTarget=function(R,H=0,ee=0){O=R,U=H,D=ee;let Z=null,Y=!1,we=!1;if(R){let Se=V.get(R);if(Se.__useDefaultFramebuffer!==void 0){C.bindFramebuffer(z.FRAMEBUFFER,Se.__webglFramebuffer),X.copy(R.viewport),q.copy(R.scissor),le=R.scissorTest,C.viewport(X),C.scissor(q),C.setScissorTest(le),K=-1;return}else if(Se.__webglFramebuffer===void 0)Q.setupRenderTarget(R);else if(Se.__hasExternalTextures)Q.rebindTextures(R,V.get(R.texture).__webglTexture,V.get(R.depthTexture).__webglTexture);else if(R.depthBuffer){let rt=R.depthTexture;if(Se.__boundDepthTexture!==rt){if(rt!==null&&V.has(rt)&&(R.width!==rt.image.width||R.height!==rt.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Q.setupDepthRenderbuffer(R)}}let ke=R.texture;if(ke.isData3DTexture||ke.isDataArrayTexture||ke.isCompressedArrayTexture)we=!0;let ze=V.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget){if(Array.isArray(ze[H]))Z=ze[H][ee];else Z=ze[H];Y=!0}else if(R.samples>0&&Q.useMultisampledRTT(R)===!1)Z=V.get(R).__webglMultisampledFramebuffer;else if(Array.isArray(ze))Z=ze[ee];else Z=ze;X.copy(R.viewport),q.copy(R.scissor),le=R.scissorTest}else X.copy(ie).multiplyScalar(L).floor(),q.copy(ce).multiplyScalar(L).floor(),le=_e;if(ee!==0)Z=I;if(C.bindFramebuffer(z.FRAMEBUFFER,Z))C.drawBuffers(R,Z);if(C.viewport(X),C.scissor(q),C.setScissorTest(le),Y){let Se=V.get(R.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+H,Se.__webglTexture,ee)}else if(we){let Se=H;for(let ke=0;ke<R.textures.length;ke++){let ze=V.get(R.textures[ke]);z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0+ke,ze.__webglTexture,ee,Se)}}else if(R!==null&&ee!==0){let Se=V.get(R.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Se.__webglTexture,ee)}K=-1};function db(R){let H=V.get(R);if(H.__readFormat!==R.format||H.__readType!==R.type)H.__readFormat=R.format,H.__readType=R.type,H.__formatReadable=Wt.textureFormatReadable(R.format),H.__typeReadable=Wt.textureTypeReadable(R.type);return H}if(this.readRenderTargetPixels=function(R,H,ee,Z,Y,we,Pe,Se=0){if(!(R&&R.isWebGLRenderTarget)){Ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ke=V.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&Pe!==void 0)ke=ke[Pe];if(ke){C.bindFramebuffer(z.FRAMEBUFFER,ke);try{let ze=R.textures[Se],{format:rt,type:ft}=ze;if(R.textures.length>1)z.readBuffer(z.COLOR_ATTACHMENT0+Se);let De=db(ze);if(De.__formatReadable===!1){Ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(De.__typeReadable===!1){Ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(H>=0&&H<=R.width-Z&&(ee>=0&&ee<=R.height-Y))z.readPixels(H,ee,Z,Y,ae.convert(rt),ae.convert(ft),we)}finally{let ze=O!==null?V.get(O).__webglFramebuffer:null;C.bindFramebuffer(z.FRAMEBUFFER,ze)}}},this.readRenderTargetPixelsAsync=async function(R,H,ee,Z,Y,we,Pe,Se=0){if(!(R&&R.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ke=V.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&Pe!==void 0)ke=ke[Pe];if(ke)if(H>=0&&H<=R.width-Z&&(ee>=0&&ee<=R.height-Y)){C.bindFramebuffer(z.FRAMEBUFFER,ke);let ze=R.textures[Se],{format:rt,type:ft}=ze;if(R.textures.length>1)z.readBuffer(z.COLOR_ATTACHMENT0+Se);let De=db(ze);if(De.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(De.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Mt=z.createBuffer();z.bindBuffer(z.PIXEL_PACK_BUFFER,Mt),z.bufferData(z.PIXEL_PACK_BUFFER,we.byteLength,z.STREAM_READ),z.readPixels(H,ee,Z,Y,ae.convert(rt),ae.convert(ft),0),z.bindBuffer(z.PIXEL_PACK_BUFFER,null);let an=O!==null?V.get(O).__webglFramebuffer:null;C.bindFramebuffer(z.FRAMEBUFFER,an);let Ht=z.fenceSync(z.SYNC_GPU_COMMANDS_COMPLETE,0);return z.flush(),await AT(z,Ht,4),z.bindBuffer(z.PIXEL_PACK_BUFFER,Mt),z.getBufferSubData(z.PIXEL_PACK_BUFFER,0,we),z.bindBuffer(z.PIXEL_PACK_BUFFER,null),z.deleteBuffer(Mt),z.deleteSync(Ht),we}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(R,H=null,ee=0){let Z=Math.pow(2,-ee),Y=Math.floor(R.image.width*Z),we=Math.floor(R.image.height*Z),Pe=H!==null?H.x:0,Se=H!==null?H.y:0;Q.setTexture2D(R,0),z.copyTexSubImage2D(z.TEXTURE_2D,ee,0,0,Pe,Se,Y,we),C.unbindTexture()},this.copyTextureToTexture=function(R,H,ee=null,Z=null,Y=0,we=0){let Pe,Se,ke,ze,rt,ft,De,Mt,an,Ht=R.isCompressedTexture?R.mipmaps[we]:R.image;if(ee!==null)Pe=ee.max.x-ee.min.x,Se=ee.max.y-ee.min.y,ke=ee.isBox3?ee.max.z-ee.min.z:1,ze=ee.min.x,rt=ee.min.y,ft=ee.isBox3?ee.min.z:0;else{let nn=Math.pow(2,-Y);if(Pe=Math.floor(Ht.width*nn),Se=Math.floor(Ht.height*nn),R.isDataArrayTexture)ke=Ht.depth;else if(R.isData3DTexture)ke=Math.floor(Ht.depth*nn);else ke=1;ze=0,rt=0,ft=0}if(Z!==null)De=Z.x,Mt=Z.y,an=Z.z;else De=0,Mt=0,an=0;let Lt=ae.convert(H.format),Rn=ae.convert(H.type),Ne;if(H.isData3DTexture)Q.setTexture3D(H,0),Ne=z.TEXTURE_3D;else if(H.isDataArrayTexture||H.isCompressedArrayTexture)Q.setTexture2DArray(H,0),Ne=z.TEXTURE_2D_ARRAY;else Q.setTexture2D(H,0),Ne=z.TEXTURE_2D;C.activeTexture(z.TEXTURE0),C.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,H.flipY),C.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),C.pixelStorei(z.UNPACK_ALIGNMENT,H.unpackAlignment);let Dn=C.getParameter(z.UNPACK_ROW_LENGTH),bt=C.getParameter(z.UNPACK_IMAGE_HEIGHT),fi=C.getParameter(z.UNPACK_SKIP_PIXELS),Ki=C.getParameter(z.UNPACK_SKIP_ROWS),$r=C.getParameter(z.UNPACK_SKIP_IMAGES);C.pixelStorei(z.UNPACK_ROW_LENGTH,Ht.width),C.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Ht.height),C.pixelStorei(z.UNPACK_SKIP_PIXELS,ze),C.pixelStorei(z.UNPACK_SKIP_ROWS,rt),C.pixelStorei(z.UNPACK_SKIP_IMAGES,ft);let ka=R.isDataArrayTexture||R.isData3DTexture,Ot=H.isDataArrayTexture||H.isData3DTexture;if(R.isDepthTexture){let nn=V.get(R),Kr=V.get(H),Vt=V.get(nn.__renderTarget),Wr=V.get(Kr.__renderTarget);C.bindFramebuffer(z.READ_FRAMEBUFFER,Vt.__webglFramebuffer),C.bindFramebuffer(z.DRAW_FRAMEBUFFER,Wr.__webglFramebuffer);for(let Da=0;Da<ke;Da++){if(ka)z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,V.get(R).__webglTexture,Y,ft+Da),z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,V.get(H).__webglTexture,we,an+Da);z.blitFramebuffer(ze,rt,Pe,Se,De,Mt,Pe,Se,z.DEPTH_BUFFER_BIT,z.NEAREST)}C.bindFramebuffer(z.READ_FRAMEBUFFER,null),C.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(Y!==0||R.isRenderTargetTexture||V.has(R)){let nn=V.get(R),Kr=V.get(H);C.bindFramebuffer(z.READ_FRAMEBUFFER,F),C.bindFramebuffer(z.DRAW_FRAMEBUFFER,N);for(let Vt=0;Vt<ke;Vt++){if(ka)z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,nn.__webglTexture,Y,ft+Vt);else z.framebufferTexture2D(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,nn.__webglTexture,Y);if(Ot)z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Kr.__webglTexture,we,an+Vt);else z.framebufferTexture2D(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Kr.__webglTexture,we);if(Y!==0)z.blitFramebuffer(ze,rt,Pe,Se,De,Mt,Pe,Se,z.COLOR_BUFFER_BIT,z.NEAREST);else if(Ot)z.copyTexSubImage3D(Ne,we,De,Mt,an+Vt,ze,rt,Pe,Se);else z.copyTexSubImage2D(Ne,we,De,Mt,ze,rt,Pe,Se)}C.bindFramebuffer(z.READ_FRAMEBUFFER,null),C.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(Ot)if(R.isDataTexture||R.isData3DTexture)z.texSubImage3D(Ne,we,De,Mt,an,Pe,Se,ke,Lt,Rn,Ht.data);else if(H.isCompressedArrayTexture)z.compressedTexSubImage3D(Ne,we,De,Mt,an,Pe,Se,ke,Lt,Ht.data);else z.texSubImage3D(Ne,we,De,Mt,an,Pe,Se,ke,Lt,Rn,Ht);else if(R.isDataTexture)z.texSubImage2D(z.TEXTURE_2D,we,De,Mt,Pe,Se,Lt,Rn,Ht.data);else if(R.isCompressedTexture)z.compressedTexSubImage2D(z.TEXTURE_2D,we,De,Mt,Ht.width,Ht.height,Lt,Ht.data);else z.texSubImage2D(z.TEXTURE_2D,we,De,Mt,Pe,Se,Lt,Rn,Ht);if(C.pixelStorei(z.UNPACK_ROW_LENGTH,Dn),C.pixelStorei(z.UNPACK_IMAGE_HEIGHT,bt),C.pixelStorei(z.UNPACK_SKIP_PIXELS,fi),C.pixelStorei(z.UNPACK_SKIP_ROWS,Ki),C.pixelStorei(z.UNPACK_SKIP_IMAGES,$r),we===0&&H.generateMipmaps)z.generateMipmap(Ne);C.unbindTexture()},this.initRenderTarget=function(R){if(V.get(R).__webglFramebuffer===void 0)Q.setupRenderTarget(R)},this.initTexture=function(R){if(R.isCubeTexture)Q.setTextureCube(R,0);else if(R.isData3DTexture)Q.setTexture3D(R,0);else if(R.isDataArrayTexture||R.isCompressedArrayTexture)Q.setTexture2DArray(R,0);else Q.setTexture2D(R,0);C.unbindTexture()},this.resetState=function(){U=0,D=0,O=null,C.reset(),xe.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return hm}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=ot._getDrawingBufferColorSpace(e),t.unpackColorSpace=ot._getUnpackColorSpace()}}var zN=`#ifdef USE_ALPHAHASH+`+q)}else if(F!=="")je("WebGLProgram: Program Info Log:",F);else if(D===""||O==="")B=!1;if(B)S.diagnostics={runnable:K,programLog:F,vertexShader:{log:D,prefix:g},fragmentShader:{log:O,prefix:p}}}r.deleteShader(v),r.deleteShader(T),E=new gl(r,m),w=xL(r,m)}let E;this.getUniforms=function(){if(E===void 0)A(this);return E};let w;this.getAttributes=function(){if(w===void 0)A(this);return w};let P=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(P===!1)P=r.getProgramParameter(m,cL);return P},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=lL++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=v,this.fragmentShader=T,this}class CA{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new NA(e),t.set(e,n);return n}}class NA{constructor(e){this.id=kL++,this.code=e,this.usedTimes=0}}function DL(e){return e===Ta||e===xd||e===yd}function LL(e,t,n,i,r,s){let a=new Ad,o=new CA,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:d,precision:f}=i,h={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",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 b(E){if(c.add(E),E===0)return"uv";return`uv${E}`}function m(E,w,P,S,I,U){let N=S.fog,F=I.geometry,D=E.isMeshStandardMaterial||E.isMeshLambertMaterial||E.isMeshPhongMaterial?S.environment:null,O=E.isMeshStandardMaterial||E.isMeshLambertMaterial&&!E.envMap||E.isMeshPhongMaterial&&!E.envMap,K=t.get(E.envMap||D,O),B=!!K&&K.mapping===qc?K.image.height:null,X=h[E.type];if(E.precision!==null){if(f=i.getMaxPrecision(E.precision),f!==E.precision)je("WebGLProgram.getParameters:",E.precision,"not supported, using",f,"instead.")}let q=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,le=q!==void 0?q.length:0,de=0;if(F.morphAttributes.position!==void 0)de=1;if(F.morphAttributes.normal!==void 0)de=2;if(F.morphAttributes.color!==void 0)de=3;let Me,pe,J,L;if(X){let zt=br[X];Me=zt.vertexShader,pe=zt.fragmentShader}else{Me=E.vertexShader,pe=E.fragmentShader;let zt=o.getVertexShaderStage(E),Mt=o.getFragmentShaderStage(E);o.update(E,zt,Mt),J=zt.id,L=Mt.id}let W=e.getRenderTarget(),ne=e.state.buffers.depth.getReversed(),ie=I.isInstancedMesh===!0,ce=I.isBatchedMesh===!0,_e=!!E.map,Re=!!E.matcap,Oe=!!K,We=!!E.aoMap,Ye=!!E.lightMap,Wt=!!E.bumpMap&&E.wireframe===!1,lt=!!E.normalMap,Lt=!!E.displacementMap,Qt=!!E.emissiveMap,nn=!!E.metalnessMap,z=!!E.roughnessMap,yn=E.anisotropy>0,St=E.clearcoat>0,Xt=E.dispersion>0,C=E.retroreflectivity>0,M=E.iridescence>0,V=E.sheen>0,Q=E.transmission>0,he=yn&&!!E.anisotropyMap,ge=St&&!!E.clearcoatMap,ve=St&&!!E.clearcoatNormalMap,re=St&&!!E.clearcoatRoughnessMap,oe=M&&!!E.iridescenceMap,Ie=M&&!!E.iridescenceThicknessMap,Ve=V&&!!E.sheenColorMap,Ee=V&&!!E.sheenRoughnessMap,me=!!E.specularMap,Ge=!!E.specularColorMap,Xe=!!E.specularIntensityMap,vt=Q&&!!E.transmissionMap,G=Q&&!!E.thicknessMap,xe=!!E.gradientMap,ae=!!E.alphaMap,ye=E.alphaTest>0,Ce=!!E.alphaHash,fe=!!E.extensions,Ae=Ui;if(E.toneMapped){if(W===null||W.isXRRenderTarget===!0)Ae=e.toneMapping}let it={shaderID:X,shaderType:E.type,shaderName:E.name,vertexShader:Me,fragmentShader:pe,defines:E.defines,customVertexShaderID:J,customFragmentShaderID:L,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:f,batching:ce,batchingColor:ce&&I._colorsTexture!==null,instancing:ie,instancingColor:ie&&I.instanceColor!==null,instancingMorph:ie&&I.morphTexture!==null,outputColorSpace:W===null?e.outputColorSpace:W.isXRRenderTarget===!0?W.texture.colorSpace:ot.workingColorSpace,alphaToCoverage:!!E.alphaToCoverage,map:_e,matcap:Re,envMap:Oe,envMapMode:Oe&&K.mapping,envMapCubeUVHeight:B,aoMap:We,lightMap:Ye,bumpMap:Wt,normalMap:lt,displacementMap:Lt,emissiveMap:Qt,normalMapObjectSpace:lt&&E.normalMapType===kT,normalMapTangentSpace:lt&&E.normalMapType===wm,packedNormalMap:lt&&E.normalMapType===wm&&DL(E.normalMap.format),metalnessMap:nn,roughnessMap:z,anisotropy:yn,anisotropyMap:he,clearcoat:St,clearcoatMap:ge,clearcoatNormalMap:ve,clearcoatRoughnessMap:re,dispersion:Xt,retroreflection:C,iridescence:M,iridescenceMap:oe,iridescenceThicknessMap:Ie,sheen:V,sheenColorMap:Ve,sheenRoughnessMap:Ee,specularMap:me,specularColorMap:Ge,specularIntensityMap:Xe,transmission:Q,transmissionMap:vt,thicknessMap:G,gradientMap:xe,opaque:E.transparent===!1&&E.blending===Wc&&E.alphaToCoverage===!1,alphaMap:ae,alphaTest:ye,alphaHash:Ce,combine:E.combine,mapUv:_e&&b(E.map.channel),aoMapUv:We&&b(E.aoMap.channel),lightMapUv:Ye&&b(E.lightMap.channel),bumpMapUv:Wt&&b(E.bumpMap.channel),normalMapUv:lt&&b(E.normalMap.channel),displacementMapUv:Lt&&b(E.displacementMap.channel),emissiveMapUv:Qt&&b(E.emissiveMap.channel),metalnessMapUv:nn&&b(E.metalnessMap.channel),roughnessMapUv:z&&b(E.roughnessMap.channel),anisotropyMapUv:he&&b(E.anisotropyMap.channel),clearcoatMapUv:ge&&b(E.clearcoatMap.channel),clearcoatNormalMapUv:ve&&b(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:re&&b(E.clearcoatRoughnessMap.channel),iridescenceMapUv:oe&&b(E.iridescenceMap.channel),iridescenceThicknessMapUv:Ie&&b(E.iridescenceThicknessMap.channel),sheenColorMapUv:Ve&&b(E.sheenColorMap.channel),sheenRoughnessMapUv:Ee&&b(E.sheenRoughnessMap.channel),specularMapUv:me&&b(E.specularMap.channel),specularColorMapUv:Ge&&b(E.specularColorMap.channel),specularIntensityMapUv:Xe&&b(E.specularIntensityMap.channel),transmissionMapUv:vt&&b(E.transmissionMap.channel),thicknessMapUv:G&&b(E.thicknessMap.channel),alphaMapUv:ae&&b(E.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&(lt||yn),vertexNormals:!!F.attributes.normal,vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!F.attributes.uv&&(_e||ae),fog:!!N,useFog:E.fog===!0,fogExp2:!!N&&N.isFogExp2,flatShading:E.wireframe===!1&&(E.flatShading===!0||F.attributes.normal===void 0&<===!1&&(E.isMeshLambertMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isMeshPhysicalMaterial)),sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:ne,skinning:I.isSkinnedMesh===!0,hasPositionAttribute:F.attributes.position!==void 0,morphTargets:F.morphAttributes.position!==void 0,morphNormals:F.morphAttributes.normal!==void 0,morphColors:F.morphAttributes.color!==void 0,morphTargetsCount:le,morphTextureStride:de,numSunLights:w.sun.length,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numSunLightShadows:w.sunShadowMap.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numLightProbeGrids:U.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:E.dithering,shadowMapEnabled:e.shadowMap.enabled&&P.length>0,shadowMapType:e.shadowMap.type,toneMapping:Ae,decodeVideoTexture:_e&&E.map.isVideoTexture===!0&&ot.getTransfer(E.map.colorSpace)===Bt,decodeVideoTextureEmissive:Qt&&E.emissiveMap.isVideoTexture===!0&&ot.getTransfer(E.emissiveMap.colorSpace)===Bt,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===vi,flipSided:E.side===kn,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:fe&&E.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(fe&&E.extensions.multiDraw===!0||ce)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return it.vertexUv1s=c.has(1),it.vertexUv2s=c.has(2),it.vertexUv3s=c.has(3),c.clear(),it}function g(E){let w=[];if(E.shaderID)w.push(E.shaderID);else w.push(E.customVertexShaderID),w.push(E.customFragmentShaderID);if(E.defines!==void 0)for(let P in E.defines)w.push(P),w.push(E.defines[P]);if(E.isRawShaderMaterial===!1)p(w,E),x(w,E),w.push(e.outputColorSpace);return w.push(E.customProgramCacheKey),w.join()}function p(E,w){E.push(w.precision),E.push(w.outputColorSpace),E.push(w.envMapMode),E.push(w.envMapCubeUVHeight),E.push(w.mapUv),E.push(w.alphaMapUv),E.push(w.lightMapUv),E.push(w.aoMapUv),E.push(w.bumpMapUv),E.push(w.normalMapUv),E.push(w.displacementMapUv),E.push(w.emissiveMapUv),E.push(w.metalnessMapUv),E.push(w.roughnessMapUv),E.push(w.anisotropyMapUv),E.push(w.clearcoatMapUv),E.push(w.clearcoatNormalMapUv),E.push(w.clearcoatRoughnessMapUv),E.push(w.iridescenceMapUv),E.push(w.iridescenceThicknessMapUv),E.push(w.sheenColorMapUv),E.push(w.sheenRoughnessMapUv),E.push(w.specularMapUv),E.push(w.specularColorMapUv),E.push(w.specularIntensityMapUv),E.push(w.transmissionMapUv),E.push(w.thicknessMapUv),E.push(w.combine),E.push(w.fogExp2),E.push(w.sizeAttenuation),E.push(w.morphTargetsCount),E.push(w.morphAttributeCount),E.push(w.numSunLights),E.push(w.numDirLights),E.push(w.numPointLights),E.push(w.numSpotLights),E.push(w.numSpotLightMaps),E.push(w.numHemiLights),E.push(w.numRectAreaLights),E.push(w.numSunLightShadows),E.push(w.numDirLightShadows),E.push(w.numPointLightShadows),E.push(w.numSpotLightShadows),E.push(w.numSpotLightShadowsWithMaps),E.push(w.numLightProbes),E.push(w.shadowMapType),E.push(w.toneMapping),E.push(w.numClippingPlanes),E.push(w.numClipIntersection),E.push(w.depthPacking)}function x(E,w){if(a.disableAll(),w.instancing)a.enable(0);if(w.instancingColor)a.enable(1);if(w.instancingMorph)a.enable(2);if(w.matcap)a.enable(3);if(w.envMap)a.enable(4);if(w.normalMapObjectSpace)a.enable(5);if(w.normalMapTangentSpace)a.enable(6);if(w.clearcoat)a.enable(7);if(w.iridescence)a.enable(8);if(w.alphaTest)a.enable(9);if(w.vertexColors)a.enable(10);if(w.vertexAlphas)a.enable(11);if(w.vertexUv1s)a.enable(12);if(w.vertexUv2s)a.enable(13);if(w.vertexUv3s)a.enable(14);if(w.vertexTangents)a.enable(15);if(w.anisotropy)a.enable(16);if(w.alphaHash)a.enable(17);if(w.batching)a.enable(18);if(w.dispersion)a.enable(19);if(w.retroreflection)a.enable(24);if(w.batchingColor)a.enable(20);if(w.gradientMap)a.enable(21);if(w.packedNormalMap)a.enable(22);if(w.vertexNormals)a.enable(23);if(E.push(a.mask),a.disableAll(),w.fog)a.enable(0);if(w.useFog)a.enable(1);if(w.flatShading)a.enable(2);if(w.logarithmicDepthBuffer)a.enable(3);if(w.reversedDepthBuffer)a.enable(4);if(w.skinning)a.enable(5);if(w.morphTargets)a.enable(6);if(w.morphNormals)a.enable(7);if(w.morphColors)a.enable(8);if(w.premultipliedAlpha)a.enable(9);if(w.shadowMapEnabled)a.enable(10);if(w.doubleSided)a.enable(11);if(w.flipSided)a.enable(12);if(w.useDepthPacking)a.enable(13);if(w.dithering)a.enable(14);if(w.transmission)a.enable(15);if(w.sheen)a.enable(16);if(w.opaque)a.enable(17);if(w.pointsUvs)a.enable(18);if(w.decodeVideoTexture)a.enable(19);if(w.decodeVideoTextureEmissive)a.enable(20);if(w.alphaToCoverage)a.enable(21);if(w.numLightProbeGrids>0)a.enable(22);if(w.hasPositionAttribute)a.enable(23);E.push(a.mask)}function _(E){let w=h[E.type],P;if(w){let S=br[w];P=KT.clone(S.uniforms)}else P=E.uniforms;return P}function y(E,w){let P=u.get(w);if(P!==void 0)++P.usedTimes;else P=new OL(e,w,E,r),l.push(P),u.set(w,P);return P}function v(E){if(--E.usedTimes===0){let w=l.indexOf(E);l[w]=l[l.length-1],l.pop(),u.delete(E.cacheKey),E.destroy()}}function T(E){o.remove(E)}function A(){o.dispose()}return{getParameters:m,getProgramCacheKey:g,getUniforms:_,acquireProgram:y,releaseProgram:v,releaseShaderCache:T,programs:l,dispose:A}}function FL(){let e=new WeakMap;function t(a){return e.has(a)}function n(a){let o=e.get(a);if(o===void 0)o={},e.set(a,o);return o}function i(a){e.delete(a)}function r(a,o,c){e.get(a)[o]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function UL(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function bA(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function xA(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function a(f){let h=0;if(f.isInstancedMesh)h+=2;if(f.isSkinnedMesh)h+=1;return h}function o(f,h,b,m,g,p){let x=e[t];if(x===void 0)x={id:f.id,object:f,geometry:h,material:b,materialVariant:a(f),groupOrder:m,renderOrder:f.renderOrder,z:g,group:p},e[t]=x;else x.id=f.id,x.object=f,x.geometry=h,x.material=b,x.materialVariant=a(f),x.groupOrder=m,x.renderOrder=f.renderOrder,x.z=g,x.group=p;return t++,x}function c(f,h,b,m,g,p,x){if(x.reversedDepth===!0)g=-g;let _=o(f,h,b,m,g,p);if(b.transmission>0)i.push(_);else if(b.transparent===!0)r.push(_);else n.push(_)}function l(f,h,b,m,g,p){let x=o(f,h,b,m,g,p);if(b.transmission>0)i.unshift(x);else if(b.transparent===!0)r.unshift(x);else n.unshift(x)}function u(f,h){if(n.length>1)n.sort(f||UL);if(i.length>1)i.sort(h||bA);if(r.length>1)r.sort(h||bA)}function d(){for(let f=t,h=e.length;f<h;f++){let b=e[f];if(b.id===null)break;b.id=null,b.object=null,b.geometry=null,b.material=null,b.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:d,sort:u}}function BL(){let e=new WeakMap;function t(i,r){let s=e.get(i),a;if(s===void 0)a=new xA,e.set(i,[a]);else if(r>=s.length)a=new xA,s.push(a);else a=s[r];return a}function n(){e=new WeakMap}return{get:t,dispose:n}}function zL(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new j,color:new qe};break;case"SpotLight":n={position:new j,direction:new j,color:new qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new j,color:new qe,distance:0,decay:0};break;case"HemisphereLight":n={direction:new j,skyColor:new qe,groundColor:new qe};break;case"RectAreaLight":n={color:new qe,position:new j,halfWidth:new j,halfHeight:new j};break}return e[t.id]=n,n}}}function VL(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ke};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ke};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ke,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}function HL(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function GL(e){let t=new zL,n=VL(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],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 l=0;l<9;l++)i.probe.push(new j);let r=new j,s=new Qe,a=new Qe;function o(l){let u=0,d=0,f=0;for(let I=0;I<9;I++)i.probe[I].set(0,0,0);let h=0,b=0,m=0,g=0,p=0,x=0,_=0,y=0,v=0,T=0,A=0,E=0,w=0,P=0;l.sort(HL);for(let I=0,U=l.length;I<U;I++){let N=l[I],{color:F,intensity:D,distance:O}=N,K=null;if(N.shadow&&N.shadow.map)if(N.shadow.map.texture.format===Ta)K=N.shadow.map.texture;else K=N.shadow.map.depthTexture||N.shadow.map.texture;if(N.isAmbientLight)u+=F.r*D,d+=F.g*D,f+=F.b*D;else if(N.isLightProbe){for(let B=0;B<9;B++)i.probe[B].addScaledVector(N.sh.coefficients[B],D);P++}else if(N.isSunLight){let B=t.get(N);if(B.color.copy(N.color).multiplyScalar(N.intensity),N.castShadow){let X=N.shadow,q=n.get(N);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize.copy(X.mapSize).multiply(X.getFrameExtents()),i.sunShadow[b]=q,i.sunShadowMap[b]=K;let le=X.getViewportCount();for(let de=0;de<le;de++)i.sunShadowMatrix[m+de]=X.getMatrix(de),i.sunShadowCascade[m+de]=X._cascadeData[de];m+=le,b++}i.sun[h]=B,h++}else if(N.isDirectionalLight){let B=t.get(N);if(B.color.copy(N.color).multiplyScalar(N.intensity),N.castShadow){let X=N.shadow,q=n.get(N);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize=X.mapSize,i.directionalShadow[g]=q,i.directionalShadowMap[g]=K,i.directionalShadowMatrix[g]=N.shadow.matrix,v++}i.directional[g]=B,g++}else if(N.isSpotLight){let B=t.get(N);B.position.setFromMatrixPosition(N.matrixWorld),B.color.copy(F).multiplyScalar(D),B.distance=O,B.coneCos=Math.cos(N.angle),B.penumbraCos=Math.cos(N.angle*(1-N.penumbra)),B.decay=N.decay,i.spot[x]=B;let X=N.shadow;if(N.map){if(i.spotLightMap[E]=N.map,E++,X.updateMatrices(N),N.castShadow)w++}if(i.spotLightMatrix[x]=X.matrix,N.castShadow){let q=n.get(N);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize=X.mapSize,i.spotShadow[x]=q,i.spotShadowMap[x]=K,A++}x++}else if(N.isRectAreaLight){let B=t.get(N);B.color.copy(F).multiplyScalar(D),B.halfWidth.set(N.width*0.5,0,0),B.halfHeight.set(0,N.height*0.5,0),i.rectArea[_]=B,_++}else if(N.isPointLight){let B=t.get(N);if(B.color.copy(N.color).multiplyScalar(N.intensity),B.distance=N.distance,B.decay=N.decay,N.castShadow){let X=N.shadow,q=n.get(N);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize=X.mapSize,q.shadowCameraNear=X.camera.near,q.shadowCameraFar=X.camera.far,i.pointShadow[p]=q,i.pointShadowMap[p]=K,i.pointShadowMatrix[p]=N.shadow.matrix,T++}i.point[p]=B,p++}else if(N.isHemisphereLight){let B=t.get(N);B.skyColor.copy(N.color).multiplyScalar(D),B.groundColor.copy(N.groundColor).multiplyScalar(D),i.hemi[y]=B,y++}}if(_>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=Te.LTC_FLOAT_1,i.rectAreaLTC2=Te.LTC_FLOAT_2;else i.rectAreaLTC1=Te.LTC_HALF_1,i.rectAreaLTC2=Te.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=f;let S=i.hash;if(S.sunLength!==h||S.directionalLength!==g||S.pointLength!==p||S.spotLength!==x||S.rectAreaLength!==_||S.hemiLength!==y||S.numSunShadows!==b||S.numDirectionalShadows!==v||S.numPointShadows!==T||S.numSpotShadows!==A||S.numSpotMaps!==E||S.numLightProbes!==P)i.sun.length=h,i.directional.length=g,i.spot.length=x,i.rectArea.length=_,i.point.length=p,i.hemi.length=y,i.sunShadow.length=b,i.sunShadowMap.length=b,i.sunShadowMatrix.length=m,i.sunShadowCascade.length=m,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.directionalShadowMatrix.length=v,i.pointShadow.length=T,i.pointShadowMap.length=T,i.pointShadowMatrix.length=T,i.spotShadow.length=A,i.spotShadowMap.length=A,i.spotLightMatrix.length=A+E-w,i.spotLightMap.length=E,i.numSpotLightShadowsWithMaps=w,i.numLightProbes=P,S.sunLength=h,S.directionalLength=g,S.pointLength=p,S.spotLength=x,S.rectAreaLength=_,S.hemiLength=y,S.numSunShadows=b,S.numDirectionalShadows=v,S.numPointShadows=T,S.numSpotShadows=A,S.numSpotMaps=E,S.numLightProbes=P,i.version=jL++}function c(l,u){let d=0,f=0,h=0,b=0,m=0,g=0,p=u.matrixWorldInverse;for(let x=0,_=l.length;x<_;x++){let y=l[x];if(y.isSunLight){let v=i.sun[d];v.direction.setFromMatrixPosition(y.matrixWorld),v.direction.transformDirection(p),d++}else if(y.isDirectionalLight){let v=i.directional[f];v.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),v.direction.sub(r),v.direction.transformDirection(p),f++}else if(y.isSpotLight){let v=i.spot[b];v.position.setFromMatrixPosition(y.matrixWorld),v.position.applyMatrix4(p),v.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),v.direction.sub(r),v.direction.transformDirection(p),b++}else if(y.isRectAreaLight){let v=i.rectArea[m];v.position.setFromMatrixPosition(y.matrixWorld),v.position.applyMatrix4(p),a.identity(),s.copy(y.matrixWorld),s.premultiply(p),a.extractRotation(s),v.halfWidth.set(y.width*0.5,0,0),v.halfHeight.set(0,y.height*0.5,0),v.halfWidth.applyMatrix4(a),v.halfHeight.applyMatrix4(a),m++}else if(y.isPointLight){let v=i.point[h];v.position.setFromMatrixPosition(y.matrixWorld),v.position.applyMatrix4(p),h++}else if(y.isHemisphereLight){let v=i.hemi[g];v.direction.setFromMatrixPosition(y.matrixWorld),v.direction.transformDirection(p),g++}}}return{setup:o,setupView:c,state:i}}function yA(e){let t=new GL(e),n=[],i=[],r=[];function s(f){d.camera=f,n.length=0,i.length=0,r.length=0}function a(f){n.push(f)}function o(f){i.push(f)}function c(f){r.push(f)}function l(){t.setup(n)}function u(f){t.setupView(n,f)}let d={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:d,setupLights:l,setupLightsView:u,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function $L(e){let t=new WeakMap;function n(r,s=0){let a=t.get(r),o;if(a===void 0)o=new yA(e),t.set(r,[o]);else if(s>=a.length)o=new yA(e),a.push(o);else o=a[s];return o}function i(){t=new WeakMap}return{get:n,dispose:i}}function JL(e,t,n){let i=new sl,r=new Ke,s=new Ke,a=new Pt,o=new Lm,c=new Fm,l={},u=n.maxTextureSize,d={[fs]:kn,[kn]:fs,[vi]:vi},f=new Ei({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ke},radius:{value:4}},vertexShader:KL,fragmentShader:WL}),h=f.clone();h.defines.HORIZONTAL_PASS=1;let b=new Dn;b.setAttribute("position",new vn(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let m=new jt(b,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Kc;let p=this.type;this.render=function(T,A,E){if(g.enabled===!1)return;if(g.autoUpdate===!1&&g.needsUpdate===!1)return;if(T.length===0)return;if(this.type===JE)je("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Kc;let w=e.getRenderTarget(),P=e.getActiveCubeFace(),S=e.getActiveMipmapLevel(),I=e.state;if(I.setBlending(dr),I.buffers.depth.getReversed()===!0)I.buffers.color.setClear(0,0,0,0);else I.buffers.color.setClear(1,1,1,1);I.buffers.depth.setTest(!0),I.setScissorTest(!1);let U=p!==this.type;if(U)A.traverse(function(N){if(N.material)if(Array.isArray(N.material))N.material.forEach((F)=>F.needsUpdate=!0);else N.material.needsUpdate=!0});for(let N=0,F=T.length;N<F;N++){let D=T[N],O=D.shadow;if(O===void 0){je("WebGLShadowMap:",D,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;r.copy(O.mapSize);let K=O.getFrameExtents();if(r.multiply(K),s.copy(O.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/K.x),r.x=s.x*K.x,O.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/K.y),r.y=s.y*K.y,O.mapSize.y=s.y}let B=e.state.buffers.depth.getReversed();if(O.camera._reversedDepth=B,O.map===null||U===!0){if(O.map!==null){if(O.map.depthTexture!==null)O.map.depthTexture.dispose(),O.map.depthTexture=null;O.map.dispose()}if(this.type===Ao){if(D.isPointLight){je("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}O.map=new ci(r.x,r.y,{format:Ta,type:hr,minFilter:En,magFilter:En,generateMipmaps:!1}),O.map.texture.name=D.name+".shadowMap",O.map.depthTexture=new wa(r.x,r.y,Br),O.map.depthTexture.name=D.name+".shadowMapDepth",O.map.depthTexture.format=va,O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=Bi,O.map.depthTexture.magFilter=Bi}else{if(D.isPointLight)O.map=new ag(r.x),O.map.depthTexture=new Om(r.x,hs);else O.map=new ci(r.x,r.y),O.map.depthTexture=new wa(r.x,r.y,hs);if(O.map.depthTexture.name=D.name+".shadowMap",O.map.depthTexture.format=va,this.type===Kc)O.map.depthTexture.compareFunction=B?Ed:vd,O.map.depthTexture.minFilter=En,O.map.depthTexture.magFilter=En;else O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=Bi,O.map.depthTexture.magFilter=Bi}O.camera.updateProjectionMatrix()}if(O.map.isWebGLCubeRenderTarget!==!0&&(O.map.width!==r.x||O.map.height!==r.y))O.map.setSize(r.x,r.y);let X=O.map.isWebGLCubeRenderTarget?6:O.getViewportCount();if(D.isPointLight!==!0)O.updateMatrices(D,E);for(let q=0;q<X;q++){let le=O.getCamera(q);if(D.isPointLight){let{camera:de,matrix:Me}=O,pe=D.distance||de.far;if(pe!==de.far)de.far=pe,de.updateProjectionMatrix();pl.setFromMatrixPosition(D.matrixWorld),de.position.copy(pl),ig.copy(de.position),ig.add(XL[q]),de.up.copy(qL[q]),de.lookAt(ig),de.updateMatrixWorld(),Me.makeTranslation(-pl.x,-pl.y,-pl.z),_A.multiplyMatrices(de.projectionMatrix,de.matrixWorldInverse),O._frustum.setFromProjectionMatrix(_A,de.coordinateSystem,de.reversedDepth)}if(O.map.isWebGLCubeRenderTarget)e.setRenderTarget(O.map,q),e.clear();else{if(q===0)e.setRenderTarget(O.map),e.clear();let de=O.getViewport(q);a.set(s.x*de.x,s.y*de.y,s.x*de.z,s.y*de.w),I.viewport(a)}i=O.getFrustum(q),y(A,E,le,D,this.type)}if(O.isPointLightShadow!==!0&&this.type===Ao)x(O,E);O.needsUpdate=!1}p=this.type,g.needsUpdate=!1,e.setRenderTarget(w,P,S)};function x(T,A){let E=t.update(m);if(f.defines.VSM_SAMPLES!==T.blurSamples)f.defines.VSM_SAMPLES=T.blurSamples,h.defines.VSM_SAMPLES=T.blurSamples,f.needsUpdate=!0,h.needsUpdate=!0;if(T.mapPass===null)T.mapPass=new ci(r.x,r.y,{format:Ta,type:hr});else if(T.mapPass.width!==T.map.width||T.mapPass.height!==T.map.height)T.mapPass.setSize(T.map.width,T.map.height);f.uniforms.shadow_pass.value=T.map.depthTexture,f.uniforms.resolution.value.set(T.map.width,T.map.height),f.uniforms.radius.value=T.radius,e.setRenderTarget(T.mapPass),e.clear(),e.renderBufferDirect(A,null,E,f,m,null),h.uniforms.shadow_pass.value=T.mapPass.texture,h.uniforms.resolution.value.set(T.map.width,T.map.height),h.uniforms.radius.value=T.radius,e.setRenderTarget(T.map),e.clear(),e.renderBufferDirect(A,null,E,h,m,null)}function _(T,A,E,w){let P=null,S=E.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(S!==void 0)P=S;else if(P=E.isPointLight===!0?c:o,e.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let I=P.uuid,U=A.uuid,N=l[I];if(N===void 0)N={},l[I]=N;let F=N[U];if(F===void 0)F=P.clone(),N[U]=F,A.addEventListener("dispose",v);P=F}if(P.visible=A.visible,P.wireframe=A.wireframe,w===Ao)P.side=A.shadowSide!==null?A.shadowSide:A.side;else P.side=A.shadowSide!==null?A.shadowSide:d[A.side];if(P.alphaMap=A.alphaMap,P.alphaTest=A.alphaToCoverage===!0?0.5:A.alphaTest,P.map=A.map,P.clipShadows=A.clipShadows,P.clippingPlanes=A.clippingPlanes,P.clipIntersection=A.clipIntersection,P.displacementMap=A.displacementMap,P.displacementScale=A.displacementScale,P.displacementBias=A.displacementBias,P.wireframeLinewidth=A.wireframeLinewidth,P.linewidth=A.linewidth,E.isPointLight===!0&&P.isMeshDistanceMaterial===!0){let I=e.properties.get(P);I.light=E}return P}function y(T,A,E,w,P){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)){if((T.castShadow||T.receiveShadow&&P===Ao)&&(!T.frustumCulled||T.intersectsFrustum(i))){T.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,T.matrixWorld);let U=t.update(T),N=T.material;if(Array.isArray(N)){let F=U.groups;for(let D=0,O=F.length;D<O;D++){let K=F[D],B=N[K.materialIndex];if(B&&B.visible){let X=_(T,B,w,P);T.onBeforeShadow(e,T,A,E,U,X,K),e.renderBufferDirect(E,null,U,X,T,K),T.onAfterShadow(e,T,A,E,U,X,K)}}}else if(N.visible){let F=_(T,N,w,P);T.onBeforeShadow(e,T,A,E,U,F,null),e.renderBufferDirect(E,null,U,F,T,null),T.onAfterShadow(e,T,A,E,U,F,null)}}}let I=T.children;for(let U=0,N=I.length;U<N;U++)y(I[U],A,E,w,P)}function v(T){T.target.removeEventListener("dispose",v);for(let E in l){let w=l[E],P=T.target.uuid;if(P in w)w[P].dispose(),delete w[P]}}}function ZL(e,t){function n(){let G=!1,xe=new Pt,ae=null,ye=new Pt(0,0,0,0);return{setMask:function(Ce){if(ae!==Ce&&!G)e.colorMask(Ce,Ce,Ce,Ce),ae=Ce},setLocked:function(Ce){G=Ce},setClear:function(Ce,fe,Ae,it,zt){if(zt===!0)Ce*=it,fe*=it,Ae*=it;if(xe.set(Ce,fe,Ae,it),ye.equals(xe)===!1)e.clearColor(Ce,fe,Ae,it),ye.copy(xe)},reset:function(){G=!1,ae=null,ye.set(-1,0,0,0)}}}function i(){let G=!1,xe=!1,ae=null,ye=null,Ce=null;return{setReversed:function(fe){if(xe!==fe){let Ae=t.get("EXT_clip_control");if(fe)Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.ZERO_TO_ONE_EXT);else Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.NEGATIVE_ONE_TO_ONE_EXT);xe=fe;let it=Ce;Ce=null,this.setClear(it)}},getReversed:function(){return xe},setTest:function(fe){if(fe)W(e.DEPTH_TEST);else ne(e.DEPTH_TEST)},setMask:function(fe){if(ae!==fe&&!G)e.depthMask(fe),ae=fe},setFunc:function(fe){if(xe)fe=GT[fe];if(ye!==fe){switch(fe){case bT:e.depthFunc(e.NEVER);break;case xT:e.depthFunc(e.ALWAYS);break;case yT:e.depthFunc(e.LESS);break;case kp:e.depthFunc(e.LEQUAL);break;case _T:e.depthFunc(e.EQUAL);break;case vT:e.depthFunc(e.GEQUAL);break;case ET:e.depthFunc(e.GREATER);break;case TT:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}ye=fe}},setLocked:function(fe){G=fe},setClear:function(fe){if(Ce!==fe){if(Ce=fe,xe)fe=1-fe;e.clearDepth(fe)}},reset:function(){G=!1,ae=null,ye=null,Ce=null,xe=!1}}}function r(){let G=!1,xe=null,ae=null,ye=null,Ce=null,fe=null,Ae=null,it=null,zt=null;return{setTest:function(Mt){if(!G)if(Mt)W(e.STENCIL_TEST);else ne(e.STENCIL_TEST)},setMask:function(Mt){if(xe!==Mt&&!G)e.stencilMask(Mt),xe=Mt},setFunc:function(Mt,Xi,wr){if(ae!==Mt||ye!==Xi||Ce!==wr)e.stencilFunc(Mt,Xi,wr),ae=Mt,ye=Xi,Ce=wr},setOp:function(Mt,Xi,wr){if(fe!==Mt||Ae!==Xi||it!==wr)e.stencilOp(Mt,Xi,wr),fe=Mt,Ae=Xi,it=wr},setLocked:function(Mt){G=Mt},setClear:function(Mt){if(zt!==Mt)e.clearStencil(Mt),zt=Mt},reset:function(){G=!1,xe=null,ae=null,ye=null,Ce=null,fe=null,Ae=null,it=null,zt=null}}}let s=new n,a=new i,o=new r,c=new WeakMap,l=new WeakMap,u={},d={},f={},h=new WeakMap,b=[],m=null,g=!1,p=null,x=null,_=null,y=null,v=null,T=null,A=null,E=new qe(0,0,0),w=0,P=!1,S=null,I=null,U=null,N=null,F=null,D=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),O=!1,K=0,B=e.getParameter(e.VERSION);if(B.indexOf("WebGL")!==-1)K=parseFloat(/^WebGL (\d)/.exec(B)[1]),O=K>=1;else if(B.indexOf("OpenGL ES")!==-1)K=parseFloat(/^OpenGL ES (\d)/.exec(B)[1]),O=K>=2;let X=null,q={},le=e.getParameter(e.SCISSOR_BOX),de=e.getParameter(e.VIEWPORT),Me=new Pt().fromArray(le),pe=new Pt().fromArray(de);function J(G,xe,ae,ye){let Ce=new Uint8Array(4),fe=e.createTexture();e.bindTexture(G,fe),e.texParameteri(G,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(G,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let Ae=0;Ae<ae;Ae++)if(G===e.TEXTURE_3D||G===e.TEXTURE_2D_ARRAY)e.texImage3D(xe,0,e.RGBA,1,1,ye,0,e.RGBA,e.UNSIGNED_BYTE,Ce);else e.texImage2D(xe+Ae,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,Ce);return fe}let L={};L[e.TEXTURE_2D]=J(e.TEXTURE_2D,e.TEXTURE_2D,1),L[e.TEXTURE_CUBE_MAP]=J(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),L[e.TEXTURE_2D_ARRAY]=J(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),L[e.TEXTURE_3D]=J(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),W(e.DEPTH_TEST),a.setFunc(kp),Wt(!1),lt(Cp),W(e.CULL_FACE),We(dr);function W(G){if(u[G]!==!0)e.enable(G),u[G]=!0}function ne(G){if(u[G]!==!1)e.disable(G),u[G]=!1}function ie(G,xe){if(f[G]!==xe){if(e.bindFramebuffer(G,xe),f[G]=xe,G===e.DRAW_FRAMEBUFFER)f[e.FRAMEBUFFER]=xe;if(G===e.FRAMEBUFFER)f[e.DRAW_FRAMEBUFFER]=xe;return!0}return!1}function ce(G,xe){let ae=b,ye=!1;if(G){if(ae=h.get(xe),ae===void 0)ae=[],h.set(xe,ae);let Ce=G.textures;if(ae.length!==Ce.length||ae[0]!==e.COLOR_ATTACHMENT0){for(let fe=0,Ae=Ce.length;fe<Ae;fe++)ae[fe]=e.COLOR_ATTACHMENT0+fe;ae.length=Ce.length,ye=!0}}else if(ae[0]!==e.BACK)ae[0]=e.BACK,ye=!0;if(ye)e.drawBuffers(ae)}function _e(G){if(m!==G)return e.useProgram(G),m=G,!0;return!1}let Re={[wo]:e.FUNC_ADD,[YE]:e.FUNC_SUBTRACT,[QE]:e.FUNC_REVERSE_SUBTRACT};Re[eT]=e.MIN,Re[tT]=e.MAX;let Oe={[nT]:e.ZERO,[iT]:e.ONE,[rT]:e.SRC_COLOR,[aT]:e.SRC_ALPHA,[fT]:e.SRC_ALPHA_SATURATE,[uT]:e.DST_COLOR,[cT]:e.DST_ALPHA,[sT]:e.ONE_MINUS_SRC_COLOR,[oT]:e.ONE_MINUS_SRC_ALPHA,[dT]:e.ONE_MINUS_DST_COLOR,[lT]:e.ONE_MINUS_DST_ALPHA,[hT]:e.CONSTANT_COLOR,[pT]:e.ONE_MINUS_CONSTANT_COLOR,[mT]:e.CONSTANT_ALPHA,[gT]:e.ONE_MINUS_CONSTANT_ALPHA};function We(G,xe,ae,ye,Ce,fe,Ae,it,zt,Mt){if(G===dr){if(g===!0)ne(e.BLEND),g=!1;return}if(g===!1)W(e.BLEND),g=!0;if(G!==ZE){if(G!==p||Mt!==P){if(x!==wo||v!==wo)e.blendEquation(e.FUNC_ADD),x=wo,v=wo;if(Mt)switch(G){case Wc:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Np:e.blendFunc(e.ONE,e.ONE);break;case Pp:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case Op:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ze("WebGLState: Invalid blending: ",G);break}else switch(G){case Wc:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Np:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case Pp:Ze("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Op:Ze("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ze("WebGLState: Invalid blending: ",G);break}_=null,y=null,T=null,A=null,E.set(0,0,0),w=0,p=G,P=Mt}return}if(Ce=Ce||xe,fe=fe||ae,Ae=Ae||ye,xe!==x||Ce!==v)e.blendEquationSeparate(Re[xe],Re[Ce]),x=xe,v=Ce;if(ae!==_||ye!==y||fe!==T||Ae!==A)e.blendFuncSeparate(Oe[ae],Oe[ye],Oe[fe],Oe[Ae]),_=ae,y=ye,T=fe,A=Ae;if(it.equals(E)===!1||zt!==w)e.blendColor(it.r,it.g,it.b,zt),E.copy(it),w=zt;p=G,P=!1}function Ye(G,xe){G.side===vi?ne(e.CULL_FACE):W(e.CULL_FACE);let ae=G.side===kn;if(xe)ae=!ae;Wt(ae),G.blending===Wc&&G.transparent===!1?We(dr):We(G.blending,G.blendEquation,G.blendSrc,G.blendDst,G.blendEquationAlpha,G.blendSrcAlpha,G.blendDstAlpha,G.blendColor,G.blendAlpha,G.premultipliedAlpha),a.setFunc(G.depthFunc),a.setTest(G.depthTest),a.setMask(G.depthWrite),s.setMask(G.colorWrite);let ye=G.stencilWrite;if(o.setTest(ye),ye)o.setMask(G.stencilWriteMask),o.setFunc(G.stencilFunc,G.stencilRef,G.stencilFuncMask),o.setOp(G.stencilFail,G.stencilZFail,G.stencilZPass);Qt(G.polygonOffset,G.polygonOffsetFactor,G.polygonOffsetUnits),G.alphaToCoverage===!0?W(e.SAMPLE_ALPHA_TO_COVERAGE):ne(e.SAMPLE_ALPHA_TO_COVERAGE)}function Wt(G){if(S!==G){if(G)e.frontFace(e.CW);else e.frontFace(e.CCW);S=G}}function lt(G){if(G!==XE){if(W(e.CULL_FACE),G!==I)if(G===Cp)e.cullFace(e.BACK);else if(G===qE)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else ne(e.CULL_FACE);I=G}function Lt(G){if(G!==U){if(O)e.lineWidth(G);U=G}}function Qt(G,xe,ae){if(G){if(W(e.POLYGON_OFFSET_FILL),N!==xe||F!==ae){if(N=xe,F=ae,a.getReversed())xe=-xe;e.polygonOffset(xe,ae)}}else ne(e.POLYGON_OFFSET_FILL)}function nn(G){if(G)W(e.SCISSOR_TEST);else ne(e.SCISSOR_TEST)}function z(G){if(G===void 0)G=e.TEXTURE0+D-1;if(X!==G)e.activeTexture(G),X=G}function yn(G,xe,ae){if(ae===void 0)if(X===null)ae=e.TEXTURE0+D-1;else ae=X;let ye=q[ae];if(ye===void 0)ye={type:void 0,texture:void 0},q[ae]=ye;if(ye.type!==G||ye.texture!==xe){if(X!==ae)e.activeTexture(ae),X=ae;e.bindTexture(G,xe||L[G]),ye.type=G,ye.texture=xe}}function St(){let G=q[X];if(G!==void 0&&G.type!==void 0)e.bindTexture(G.type,null),G.type=void 0,G.texture=void 0}function Xt(){try{e.compressedTexImage2D(...arguments)}catch(G){Ze("WebGLState:",G)}}function C(){try{e.compressedTexImage3D(...arguments)}catch(G){Ze("WebGLState:",G)}}function M(){try{e.texSubImage2D(...arguments)}catch(G){Ze("WebGLState:",G)}}function V(){try{e.texSubImage3D(...arguments)}catch(G){Ze("WebGLState:",G)}}function Q(){try{e.compressedTexSubImage2D(...arguments)}catch(G){Ze("WebGLState:",G)}}function he(){try{e.compressedTexSubImage3D(...arguments)}catch(G){Ze("WebGLState:",G)}}function ge(){try{e.texStorage2D(...arguments)}catch(G){Ze("WebGLState:",G)}}function ve(){try{e.texStorage3D(...arguments)}catch(G){Ze("WebGLState:",G)}}function re(){try{e.texImage2D(...arguments)}catch(G){Ze("WebGLState:",G)}}function oe(){try{e.texImage3D(...arguments)}catch(G){Ze("WebGLState:",G)}}function Ie(G){if(d[G]!==void 0)return d[G];else return e.getParameter(G)}function Ve(G,xe){if(d[G]!==xe)e.pixelStorei(G,xe),d[G]=xe}function Ee(G){if(Me.equals(G)===!1)e.scissor(G.x,G.y,G.z,G.w),Me.copy(G)}function me(G){if(pe.equals(G)===!1)e.viewport(G.x,G.y,G.z,G.w),pe.copy(G)}function Ge(G,xe){let ae=l.get(xe);if(ae===void 0)ae=new WeakMap,l.set(xe,ae);let ye=ae.get(G);if(ye===void 0)ye=e.getUniformBlockIndex(xe,G.name),ae.set(G,ye)}function Xe(G,xe){let ye=l.get(xe).get(G);if(c.get(xe)!==ye)e.uniformBlockBinding(xe,ye,G.__bindingPointIndex),c.set(xe,ye)}function vt(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),a.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},d={},X=null,q={},f={},h=new WeakMap,b=[],m=null,g=!1,p=null,x=null,_=null,y=null,v=null,T=null,A=null,E=new qe(0,0,0),w=0,P=!1,S=null,I=null,U=null,N=null,F=null,Me.set(0,0,e.canvas.width,e.canvas.height),pe.set(0,0,e.canvas.width,e.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:W,disable:ne,bindFramebuffer:ie,drawBuffers:ce,useProgram:_e,setBlending:We,setMaterial:Ye,setFlipSided:Wt,setCullFace:lt,setLineWidth:Lt,setPolygonOffset:Qt,setScissorTest:nn,activeTexture:z,bindTexture:yn,unbindTexture:St,compressedTexImage2D:Xt,compressedTexImage3D:C,texImage2D:re,texImage3D:oe,pixelStorei:Ve,getParameter:Ie,updateUBOMapping:Ge,uniformBlockBinding:Xe,texStorage2D:ge,texStorage3D:ve,texSubImage2D:M,texSubImage3D:V,compressedTexSubImage2D:Q,compressedTexSubImage3D:he,scissor:Ee,viewport:me,reset:vt}}function YL(e,t,n,i,r,s,a){let o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ke,u=new WeakMap,d=new Set,f,h=new WeakMap,b=!1;try{b=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(C){}function m(C,M){return b?new OffscreenCanvas(C,M):vo("canvas")}function g(C,M,V){let Q=1,he=Xt(C);if(he.width>V||he.height>V)Q=V/Math.max(he.width,he.height);if(Q<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){let ge=Math.floor(Q*he.width),ve=Math.floor(Q*he.height);if(f===void 0)f=m(ge,ve);let re=M?m(ge,ve):f;return re.width=ge,re.height=ve,re.getContext("2d").drawImage(C,0,0,ge,ve),je("WebGLRenderer: Texture has been resized from ("+he.width+"x"+he.height+") to ("+ge+"x"+ve+")."),re}else{if("data"in C)je("WebGLRenderer: Image in DataTexture is too big ("+he.width+"x"+he.height+").");return C}return C}function p(C){return C.generateMipmaps}function x(C){e.generateMipmap(C)}function _(C){if(C.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(C.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(C.isWebGLArrayRenderTarget||C.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function y(C,M,V,Q,he,ge=!1){if(C!==null){if(e[C]!==void 0)return e[C];je("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let ve;if(Q){if(ve=t.get("EXT_texture_norm16"),!ve)je("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let re=M;if(M===e.RED){if(V===e.FLOAT)re=e.R32F;if(V===e.HALF_FLOAT)re=e.R16F;if(V===e.UNSIGNED_BYTE)re=e.R8;if(V===e.UNSIGNED_SHORT&&ve)re=ve.R16_EXT;if(V===e.SHORT&&ve)re=ve.R16_SNORM_EXT}if(M===e.RED_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.R8UI;if(V===e.UNSIGNED_SHORT)re=e.R16UI;if(V===e.UNSIGNED_INT)re=e.R32UI;if(V===e.BYTE)re=e.R8I;if(V===e.SHORT)re=e.R16I;if(V===e.INT)re=e.R32I}if(M===e.RG){if(V===e.FLOAT)re=e.RG32F;if(V===e.HALF_FLOAT)re=e.RG16F;if(V===e.UNSIGNED_BYTE)re=e.RG8;if(V===e.UNSIGNED_SHORT&&ve)re=ve.RG16_EXT;if(V===e.SHORT&&ve)re=ve.RG16_SNORM_EXT}if(M===e.RG_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.RG8UI;if(V===e.UNSIGNED_SHORT)re=e.RG16UI;if(V===e.UNSIGNED_INT)re=e.RG32UI;if(V===e.BYTE)re=e.RG8I;if(V===e.SHORT)re=e.RG16I;if(V===e.INT)re=e.RG32I}if(M===e.RGB_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.RGB8UI;if(V===e.UNSIGNED_SHORT)re=e.RGB16UI;if(V===e.UNSIGNED_INT)re=e.RGB32UI;if(V===e.BYTE)re=e.RGB8I;if(V===e.SHORT)re=e.RGB16I;if(V===e.INT)re=e.RGB32I}if(M===e.RGBA_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.RGBA8UI;if(V===e.UNSIGNED_SHORT)re=e.RGBA16UI;if(V===e.UNSIGNED_INT)re=e.RGBA32UI;if(V===e.BYTE)re=e.RGBA8I;if(V===e.SHORT)re=e.RGBA16I;if(V===e.INT)re=e.RGBA32I}if(M===e.RGB){if(V===e.UNSIGNED_SHORT&&ve)re=ve.RGB16_EXT;if(V===e.SHORT&&ve)re=ve.RGB16_SNORM_EXT;if(V===e.UNSIGNED_INT_5_9_9_9_REV)re=e.RGB9_E5;if(V===e.UNSIGNED_INT_10F_11F_11F_REV)re=e.R11F_G11F_B10F}if(M===e.RGBA){let oe=ge?Sm:ot.getTransfer(he);if(V===e.FLOAT)re=e.RGBA32F;if(V===e.HALF_FLOAT)re=e.RGBA16F;if(V===e.UNSIGNED_BYTE)re=oe===Bt?e.SRGB8_ALPHA8:e.RGBA8;if(V===e.UNSIGNED_SHORT&&ve)re=ve.RGBA16_EXT;if(V===e.SHORT&&ve)re=ve.RGBA16_SNORM_EXT;if(V===e.UNSIGNED_SHORT_4_4_4_4)re=e.RGBA4;if(V===e.UNSIGNED_SHORT_5_5_5_1)re=e.RGB5_A1}if(re===e.R16F||re===e.R32F||re===e.RG16F||re===e.RG32F||re===e.RGBA16F||re===e.RGBA32F)t.get("EXT_color_buffer_float");return re}function v(C,M){let V;if(C){if(M===null||M===hs||M===Co)V=e.DEPTH24_STENCIL8;else if(M===Br)V=e.DEPTH32F_STENCIL8;else if(M===Jc)V=e.DEPTH24_STENCIL8,je("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(M===null||M===hs||M===Co)V=e.DEPTH_COMPONENT24;else if(M===Br)V=e.DEPTH_COMPONENT32F;else if(M===Jc)V=e.DEPTH_COMPONENT16;return V}function T(C,M){if(p(C)===!0||C.isFramebufferTexture&&C.minFilter!==Bi&&C.minFilter!==En)return Math.log2(Math.max(M.width,M.height))+1;else if(C.mipmaps!==void 0&&C.mipmaps.length>0)return C.mipmaps.length;else if(C.isCompressedTexture&&Array.isArray(C.image))return M.mipmaps.length;else return 1}function A(C){let M=C.target;if(M.removeEventListener("dispose",A),w(M),M.isVideoTexture)u.delete(M);if(M.isHTMLTexture)d.delete(M)}function E(C){let M=C.target;M.removeEventListener("dispose",E),S(M)}function w(C){let M=i.get(C);if(M.__webglInit===void 0)return;let V=C.source,Q=h.get(V);if(Q){let he=Q[M.__cacheKey];if(he.usedTimes--,he.usedTimes===0)P(C);if(Object.keys(Q).length===0)h.delete(V)}i.remove(C)}function P(C){let M=i.get(C);e.deleteTexture(M.__webglTexture);let V=C.source,Q=h.get(V);delete Q[M.__cacheKey],a.memory.textures--}function S(C){let M=i.get(C);if(C.depthTexture)C.depthTexture.dispose(),i.remove(C.depthTexture);if(C.isWebGLCubeRenderTarget)for(let Q=0;Q<6;Q++){if(Array.isArray(M.__webglFramebuffer[Q]))for(let he=0;he<M.__webglFramebuffer[Q].length;he++)e.deleteFramebuffer(M.__webglFramebuffer[Q][he]);else e.deleteFramebuffer(M.__webglFramebuffer[Q]);if(M.__webglDepthbuffer)e.deleteRenderbuffer(M.__webglDepthbuffer[Q])}else{if(Array.isArray(M.__webglFramebuffer))for(let Q=0;Q<M.__webglFramebuffer.length;Q++)e.deleteFramebuffer(M.__webglFramebuffer[Q]);else e.deleteFramebuffer(M.__webglFramebuffer);if(M.__webglDepthbuffer)e.deleteRenderbuffer(M.__webglDepthbuffer);if(M.__webglMultisampledFramebuffer)e.deleteFramebuffer(M.__webglMultisampledFramebuffer);if(M.__webglColorRenderbuffer){for(let Q=0;Q<M.__webglColorRenderbuffer.length;Q++)if(M.__webglColorRenderbuffer[Q])e.deleteRenderbuffer(M.__webglColorRenderbuffer[Q])}if(M.__webglDepthRenderbuffer)e.deleteRenderbuffer(M.__webglDepthRenderbuffer)}let V=C.textures;for(let Q=0,he=V.length;Q<he;Q++){let ge=i.get(V[Q]);if(ge.__webglTexture)e.deleteTexture(ge.__webglTexture),a.memory.textures--;i.remove(V[Q])}i.remove(C)}let I=0;function U(){I=0}function N(){return I}function F(C){I=C}function D(){let C=I;if(C>=r.maxTextures)je("WebGLTextures: Trying to use "+(C+1)+" texture units while this GPU supports only "+r.maxTextures);return I+=1,C}function O(C){let M=[];return M.push(C.wrapS),M.push(C.wrapT),M.push(C.wrapR||0),M.push(C.magFilter),M.push(C.minFilter),M.push(C.anisotropy),M.push(C.internalFormat),M.push(C.format),M.push(C.type),M.push(C.generateMipmaps),M.push(C.premultiplyAlpha),M.push(C.flipY),M.push(C.unpackAlignment),M.push(C.colorSpace),M.join()}function K(C,M){let V=i.get(C);if(C.isVideoTexture)yn(C);if(C.isRenderTargetTexture===!1&&C.isExternalTexture!==!0&&C.version>0&&V.__version!==C.version){let Q=C.image;if(Q===null)je("WebGLRenderer: Texture marked for update but no image data found.");else if(Q.complete===!1)je("WebGLRenderer: Texture marked for update but image is incomplete");else{ne(V,C,M);return}}else if(C.isExternalTexture)V.__webglTexture=C.sourceTexture?C.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,V.__webglTexture,e.TEXTURE0+M)}function B(C,M){let V=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&V.__version!==C.version){ne(V,C,M);return}else if(C.isExternalTexture)V.__webglTexture=C.sourceTexture?C.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,V.__webglTexture,e.TEXTURE0+M)}function X(C,M){let V=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&V.__version!==C.version){ne(V,C,M);return}n.bindTexture(e.TEXTURE_3D,V.__webglTexture,e.TEXTURE0+M)}function q(C,M){let V=i.get(C);if(C.isCubeDepthTexture!==!0&&C.version>0&&V.__version!==C.version){ie(V,C,M);return}n.bindTexture(e.TEXTURE_CUBE_MAP,V.__webglTexture,e.TEXTURE0+M)}let le={[Mo]:e.REPEAT,[Ro]:e.CLAMP_TO_EDGE,[fd]:e.MIRRORED_REPEAT},de={[Bi]:e.NEAREST,[hd]:e.NEAREST_MIPMAP_NEAREST,[_a]:e.NEAREST_MIPMAP_LINEAR,[En]:e.LINEAR,[Io]:e.LINEAR_MIPMAP_NEAREST,[fr]:e.LINEAR_MIPMAP_LINEAR},Me={[DT]:e.NEVER,[zT]:e.ALWAYS,[LT]:e.LESS,[vd]:e.LEQUAL,[FT]:e.EQUAL,[Ed]:e.GEQUAL,[UT]:e.GREATER,[BT]:e.NOTEQUAL};function pe(C,M){if(M.type===Br&&t.has("OES_texture_float_linear")===!1&&(M.magFilter===En||M.magFilter===Io||M.magFilter===_a||M.magFilter===fr||M.minFilter===En||M.minFilter===Io||M.minFilter===_a||M.minFilter===fr))je("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(C,e.TEXTURE_WRAP_S,le[M.wrapS]),e.texParameteri(C,e.TEXTURE_WRAP_T,le[M.wrapT]),C===e.TEXTURE_3D||C===e.TEXTURE_2D_ARRAY)e.texParameteri(C,e.TEXTURE_WRAP_R,le[M.wrapR]);if(e.texParameteri(C,e.TEXTURE_MAG_FILTER,de[M.magFilter]),e.texParameteri(C,e.TEXTURE_MIN_FILTER,de[M.minFilter]),M.compareFunction)e.texParameteri(C,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(C,e.TEXTURE_COMPARE_FUNC,Me[M.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===Bi)return;if(M.minFilter!==_a&&M.minFilter!==fr)return;if(M.type===Br&&t.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||i.get(M).__currentAnisotropy){let V=t.get("EXT_texture_filter_anisotropic");e.texParameterf(C,V.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,r.getMaxAnisotropy())),i.get(M).__currentAnisotropy=M.anisotropy}}}function J(C,M){let V=!1;if(C.__webglInit===void 0)C.__webglInit=!0,M.addEventListener("dispose",A);let Q=M.source,he=h.get(Q);if(he===void 0)he={},h.set(Q,he);let ge=O(M);if(ge!==C.__cacheKey){if(he[ge]===void 0)he[ge]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,V=!0;he[ge].usedTimes++;let ve=he[C.__cacheKey];if(ve!==void 0){if(he[C.__cacheKey].usedTimes--,ve.usedTimes===0)P(M)}C.__cacheKey=ge,C.__webglTexture=he[ge].texture}return V}function L(C,M,V){return Math.floor(Math.floor(C/V)/M)}function W(C,M,V,Q){let ge=C.updateRanges;if(ge.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,M.width,M.height,V,Q,M.data);else{ge.sort((Ve,Ee)=>Ve.start-Ee.start);let ve=0;for(let Ve=1;Ve<ge.length;Ve++){let Ee=ge[ve],me=ge[Ve],Ge=Ee.start+Ee.count,Xe=L(me.start,M.width,4),vt=L(Ee.start,M.width,4);if(me.start<=Ge+1&&Xe===vt&&L(me.start+me.count-1,M.width,4)===Xe)Ee.count=Math.max(Ee.count,me.start+me.count-Ee.start);else++ve,ge[ve]=me}ge.length=ve+1;let re=n.getParameter(e.UNPACK_ROW_LENGTH),oe=n.getParameter(e.UNPACK_SKIP_PIXELS),Ie=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,M.width);for(let Ve=0,Ee=ge.length;Ve<Ee;Ve++){let me=ge[Ve],Ge=Math.floor(me.start/4),Xe=Math.ceil(me.count/4),vt=Ge%M.width,G=Math.floor(Ge/M.width),xe=Xe,ae=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,vt),n.pixelStorei(e.UNPACK_SKIP_ROWS,G),n.texSubImage2D(e.TEXTURE_2D,0,vt,G,xe,1,V,Q,M.data)}C.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,re),n.pixelStorei(e.UNPACK_SKIP_PIXELS,oe),n.pixelStorei(e.UNPACK_SKIP_ROWS,Ie)}}function ne(C,M,V){let Q=e.TEXTURE_2D;if(M.isDataArrayTexture||M.isCompressedArrayTexture)Q=e.TEXTURE_2D_ARRAY;if(M.isData3DTexture)Q=e.TEXTURE_3D;let he=J(C,M),ge=M.source;n.bindTexture(Q,C.__webglTexture,e.TEXTURE0+V);let ve=i.get(ge);if(ge.version!==ve.__version||he===!0){if(n.activeTexture(e.TEXTURE0+V),(typeof ImageBitmap<"u"&&M.image instanceof ImageBitmap)===!1){let ae=ot.getPrimaries(ot.workingColorSpace),ye=M.colorSpace===Aa?null:ot.getPrimaries(M.colorSpace),Ce=M.colorSpace===Aa||ae===ye?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,M.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ce)}n.pixelStorei(e.UNPACK_ALIGNMENT,M.unpackAlignment);let oe=g(M.image,!1,r.maxTextureSize);oe=St(M,oe);let Ie=s.convert(M.format,M.colorSpace),Ve=s.convert(M.type),Ee=y(M.internalFormat,Ie,Ve,M.normalized,M.colorSpace,M.isVideoTexture);pe(Q,M);let me,Ge=M.mipmaps,Xe=M.isVideoTexture!==!0,vt=ve.__version===void 0||he===!0,G=ge.dataReady,xe=T(M,oe);if(M.isDepthTexture){if(Ee=v(M.format===Ea,M.type),vt)if(Xe)n.texStorage2D(e.TEXTURE_2D,1,Ee,oe.width,oe.height);else n.texImage2D(e.TEXTURE_2D,0,Ee,oe.width,oe.height,0,Ie,Ve,null)}else if(M.isDataTexture)if(Ge.length>0){if(Xe&&vt)n.texStorage2D(e.TEXTURE_2D,xe,Ee,Ge[0].width,Ge[0].height);for(let ae=0,ye=Ge.length;ae<ye;ae++)if(me=Ge[ae],Xe){if(G)n.texSubImage2D(e.TEXTURE_2D,ae,0,0,me.width,me.height,Ie,Ve,me.data)}else n.texImage2D(e.TEXTURE_2D,ae,Ee,me.width,me.height,0,Ie,Ve,me.data);M.generateMipmaps=!1}else if(Xe){if(vt)n.texStorage2D(e.TEXTURE_2D,xe,Ee,oe.width,oe.height);if(G)W(M,oe,Ie,Ve)}else n.texImage2D(e.TEXTURE_2D,0,Ee,oe.width,oe.height,0,Ie,Ve,oe.data);else if(M.isCompressedTexture)if(M.isCompressedArrayTexture){if(Xe&&vt)n.texStorage3D(e.TEXTURE_2D_ARRAY,xe,Ee,Ge[0].width,Ge[0].height,oe.depth);for(let ae=0,ye=Ge.length;ae<ye;ae++)if(me=Ge[ae],M.format!==pr)if(Ie!==null)if(Xe){if(G)if(M.layerUpdates.size>0){let Ce=Jm(me.width,me.height,M.format,M.type);for(let fe of M.layerUpdates){let Ae=me.data.subarray(fe*Ce/me.data.BYTES_PER_ELEMENT,(fe+1)*Ce/me.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ae,0,0,fe,me.width,me.height,1,Ie,Ae)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ae,0,0,0,me.width,me.height,oe.depth,Ie,me.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ae,Ee,me.width,me.height,oe.depth,0,me.data,0,0);else je("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Xe){if(G)n.texSubImage3D(e.TEXTURE_2D_ARRAY,ae,0,0,0,me.width,me.height,oe.depth,Ie,Ve,me.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,ae,Ee,me.width,me.height,oe.depth,0,Ie,Ve,me.data);if(M.layerUpdates.size>0)M.clearLayerUpdates()}else{if(Xe&&vt)n.texStorage2D(e.TEXTURE_2D,xe,Ee,Ge[0].width,Ge[0].height);for(let ae=0,ye=Ge.length;ae<ye;ae++)if(me=Ge[ae],M.format!==pr)if(Ie!==null)if(Xe){if(G)n.compressedTexSubImage2D(e.TEXTURE_2D,ae,0,0,me.width,me.height,Ie,me.data)}else n.compressedTexImage2D(e.TEXTURE_2D,ae,Ee,me.width,me.height,0,me.data);else je("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Xe){if(G)n.texSubImage2D(e.TEXTURE_2D,ae,0,0,me.width,me.height,Ie,Ve,me.data)}else n.texImage2D(e.TEXTURE_2D,ae,Ee,me.width,me.height,0,Ie,Ve,me.data)}else if(M.isDataArrayTexture)if(Xe){if(vt)n.texStorage3D(e.TEXTURE_2D_ARRAY,xe,Ee,oe.width,oe.height,oe.depth);if(G)if(M.layerUpdates.size>0){let ae=Jm(oe.width,oe.height,M.format,M.type);for(let ye of M.layerUpdates){let Ce=oe.data.subarray(ye*ae/oe.data.BYTES_PER_ELEMENT,(ye+1)*ae/oe.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,ye,oe.width,oe.height,1,Ie,Ve,Ce)}M.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,oe.width,oe.height,oe.depth,Ie,Ve,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,Ee,oe.width,oe.height,oe.depth,0,Ie,Ve,oe.data);else if(M.isData3DTexture)if(Xe){if(vt)n.texStorage3D(e.TEXTURE_3D,xe,Ee,oe.width,oe.height,oe.depth);if(G)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,oe.width,oe.height,oe.depth,Ie,Ve,oe.data)}else n.texImage3D(e.TEXTURE_3D,0,Ee,oe.width,oe.height,oe.depth,0,Ie,Ve,oe.data);else if(M.isFramebufferTexture){if(vt)if(Xe)n.texStorage2D(e.TEXTURE_2D,xe,Ee,oe.width,oe.height);else{let ae=oe.width,ye=oe.height;for(let Ce=0;Ce<xe;Ce++)n.texImage2D(e.TEXTURE_2D,Ce,Ee,ae,ye,0,Ie,Ve,null),ae>>=1,ye>>=1}}else if(M.isHTMLTexture){if("texElementImage2D"in e){let ae=e.canvas;if(!ae.hasAttribute("layoutsubtree"))ae.setAttribute("layoutsubtree","true");if(oe.parentNode!==ae){ae.appendChild(oe),d.add(M),ae.onpaint=(ye)=>{let Ce=ye.changedElements;for(let fe of d)if(Ce.includes(fe.image))fe.needsUpdate=!0},ae.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,oe);else{let{RGBA:Ce,RGBA:fe,UNSIGNED_BYTE:Ae}=e;e.texElementImage2D(e.TEXTURE_2D,0,Ce,fe,Ae,oe)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Ge.length>0){if(Xe&&vt){let ae=Xt(Ge[0]);n.texStorage2D(e.TEXTURE_2D,xe,Ee,ae.width,ae.height)}for(let ae=0,ye=Ge.length;ae<ye;ae++)if(me=Ge[ae],Xe){if(G)n.texSubImage2D(e.TEXTURE_2D,ae,0,0,Ie,Ve,me)}else n.texImage2D(e.TEXTURE_2D,ae,Ee,Ie,Ve,me);M.generateMipmaps=!1}else if(Xe){if(vt){let ae=Xt(oe);n.texStorage2D(e.TEXTURE_2D,xe,Ee,ae.width,ae.height)}if(G)n.texSubImage2D(e.TEXTURE_2D,0,0,0,Ie,Ve,oe)}else n.texImage2D(e.TEXTURE_2D,0,Ee,Ie,Ve,oe);if(p(M))x(Q);if(ve.__version=ge.version,M.onUpdate)M.onUpdate(M)}C.__version=M.version}function ie(C,M,V){if(M.image.length!==6)return;let Q=J(C,M),he=M.source;n.bindTexture(e.TEXTURE_CUBE_MAP,C.__webglTexture,e.TEXTURE0+V);let ge=i.get(he);if(he.version!==ge.__version||Q===!0){n.activeTexture(e.TEXTURE0+V);let ve=ot.getPrimaries(ot.workingColorSpace),re=M.colorSpace===Aa?null:ot.getPrimaries(M.colorSpace),oe=M.colorSpace===Aa||ve===re?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,M.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,M.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,oe);let Ie=M.isCompressedTexture||M.image[0].isCompressedTexture,Ve=M.image[0]&&M.image[0].isDataTexture,Ee=[];for(let fe=0;fe<6;fe++){if(!Ie&&!Ve)Ee[fe]=g(M.image[fe],!0,r.maxCubemapSize);else Ee[fe]=Ve?M.image[fe].image:M.image[fe];Ee[fe]=St(M,Ee[fe])}let me=Ee[0],Ge=s.convert(M.format,M.colorSpace),Xe=s.convert(M.type),vt=y(M.internalFormat,Ge,Xe,M.normalized,M.colorSpace),G=M.isVideoTexture!==!0,xe=ge.__version===void 0||Q===!0,ae=he.dataReady,ye=T(M,me);pe(e.TEXTURE_CUBE_MAP,M);let Ce;if(Ie){if(G&&xe)n.texStorage2D(e.TEXTURE_CUBE_MAP,ye,vt,me.width,me.height);for(let fe=0;fe<6;fe++){Ce=Ee[fe].mipmaps;for(let Ae=0;Ae<Ce.length;Ae++){let it=Ce[Ae];if(M.format!==pr)if(Ge!==null)if(G){if(ae)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,0,0,it.width,it.height,Ge,it.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,vt,it.width,it.height,0,it.data);else je("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,0,0,it.width,it.height,Ge,Xe,it.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,vt,it.width,it.height,0,Ge,Xe,it.data)}}}else{if(Ce=M.mipmaps,G&&xe){if(Ce.length>0)ye++;let fe=Xt(Ee[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,ye,vt,fe.width,fe.height)}for(let fe=0;fe<6;fe++)if(Ve){if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,0,0,Ee[fe].width,Ee[fe].height,Ge,Xe,Ee[fe].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,vt,Ee[fe].width,Ee[fe].height,0,Ge,Xe,Ee[fe].data);for(let Ae=0;Ae<Ce.length;Ae++){let zt=Ce[Ae].image[fe].image;if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,0,0,zt.width,zt.height,Ge,Xe,zt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,vt,zt.width,zt.height,0,Ge,Xe,zt.data)}}else{if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,0,0,Ge,Xe,Ee[fe])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,vt,Ge,Xe,Ee[fe]);for(let Ae=0;Ae<Ce.length;Ae++){let it=Ce[Ae];if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,0,0,Ge,Xe,it.image[fe])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,vt,Ge,Xe,it.image[fe])}}}if(p(M))x(e.TEXTURE_CUBE_MAP);if(ge.__version=he.version,M.onUpdate)M.onUpdate(M)}C.__version=M.version}function ce(C,M,V,Q,he,ge){let ve=s.convert(V.format,V.colorSpace),re=s.convert(V.type),oe=y(V.internalFormat,ve,re,V.normalized,V.colorSpace),Ie=i.get(M),Ve=i.get(V);if(Ve.__renderTarget=M,!Ie.__hasExternalTextures){let Ee=Math.max(1,M.width>>ge),me=Math.max(1,M.height>>ge);if(he===e.TEXTURE_3D||he===e.TEXTURE_2D_ARRAY)n.texImage3D(he,ge,oe,Ee,me,M.depth,0,ve,re,null);else n.texImage2D(he,ge,oe,Ee,me,0,ve,re,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,C),z(M))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,Q,he,Ve.__webglTexture,0,nn(M));else if(he===e.TEXTURE_2D||he>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&he<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,Q,he,Ve.__webglTexture,ge);n.bindFramebuffer(e.FRAMEBUFFER,null)}function _e(C,M,V){if(e.bindRenderbuffer(e.RENDERBUFFER,C),M.depthBuffer){let Q=M.depthTexture,he=Q&&Q.isDepthTexture?Q.type:null,ge=v(M.stencilBuffer,he),ve=M.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(z(M))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,nn(M),ge,M.width,M.height);else if(V)e.renderbufferStorageMultisample(e.RENDERBUFFER,nn(M),ge,M.width,M.height);else e.renderbufferStorage(e.RENDERBUFFER,ge,M.width,M.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,ve,e.RENDERBUFFER,C)}else{let Q=M.textures;for(let he=0;he<Q.length;he++){let ge=Q[he],ve=s.convert(ge.format,ge.colorSpace),re=s.convert(ge.type),oe=y(ge.internalFormat,ve,re,ge.normalized,ge.colorSpace);if(z(M))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,nn(M),oe,M.width,M.height);else if(V)e.renderbufferStorageMultisample(e.RENDERBUFFER,nn(M),oe,M.width,M.height);else e.renderbufferStorage(e.RENDERBUFFER,oe,M.width,M.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Re(C,M,V){let Q=M.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,C),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let he=i.get(M.depthTexture);if(he.__renderTarget=M,!he.__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0;if(Q){if(he.__webglInit===void 0)he.__webglInit=!0,M.depthTexture.addEventListener("dispose",A);if(he.__webglTexture===void 0){he.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,he.__webglTexture),pe(e.TEXTURE_CUBE_MAP,M.depthTexture);let Ie=s.convert(M.depthTexture.format),Ve=s.convert(M.depthTexture.type),Ee;if(M.depthTexture.format===va)Ee=e.DEPTH_COMPONENT24;else if(M.depthTexture.format===Ea)Ee=e.DEPTH24_STENCIL8;for(let me=0;me<6;me++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+me,0,Ee,M.width,M.height,0,Ie,Ve,null)}}else K(M.depthTexture,0);let ge=he.__webglTexture,ve=nn(M),re=Q?e.TEXTURE_CUBE_MAP_POSITIVE_X+V:e.TEXTURE_2D,oe=M.depthTexture.format===Ea?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(M.depthTexture.format===va)if(z(M))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,oe,re,ge,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,oe,re,ge,0);else if(M.depthTexture.format===Ea)if(z(M))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,oe,re,ge,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,oe,re,ge,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Oe(C){let M=i.get(C),V=C.isWebGLCubeRenderTarget===!0;if(M.__boundDepthTexture!==C.depthTexture){let Q=C.depthTexture;if(M.__depthDisposeCallback)M.__depthDisposeCallback();if(Q){let he=()=>{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,Q.removeEventListener("dispose",he)};Q.addEventListener("dispose",he),M.__depthDisposeCallback=he}M.__boundDepthTexture=Q}if(C.depthTexture&&!M.__autoAllocateDepthBuffer)if(V)for(let Q=0;Q<6;Q++)Re(M.__webglFramebuffer[Q],C,Q);else{let Q=C.texture.mipmaps;if(Q&&Q.length>0)Re(M.__webglFramebuffer[0],C,0);else Re(M.__webglFramebuffer,C,0)}else if(V){M.__webglDepthbuffer=[];for(let Q=0;Q<6;Q++)if(n.bindFramebuffer(e.FRAMEBUFFER,M.__webglFramebuffer[Q]),M.__webglDepthbuffer[Q]===void 0)M.__webglDepthbuffer[Q]=e.createRenderbuffer(),_e(M.__webglDepthbuffer[Q],C,!1);else{let he=C.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ge=M.__webglDepthbuffer[Q];e.bindRenderbuffer(e.RENDERBUFFER,ge),e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,ge)}}else{let Q=C.texture.mipmaps;if(Q&&Q.length>0)n.bindFramebuffer(e.FRAMEBUFFER,M.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,M.__webglFramebuffer);if(M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=e.createRenderbuffer(),_e(M.__webglDepthbuffer,C,!1);else{let he=C.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ge=M.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ge),e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,ge)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function We(C,M,V){let Q=i.get(C);if(M!==void 0)ce(Q.__webglFramebuffer,C,C.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(V!==void 0)Oe(C)}function Ye(C){let M=C.texture,V=i.get(C),Q=i.get(M);C.addEventListener("dispose",E);let he=C.textures,ge=C.isWebGLCubeRenderTarget===!0,ve=he.length>1;if(!ve){if(Q.__webglTexture===void 0)Q.__webglTexture=e.createTexture();Q.__version=M.version,a.memory.textures++}if(ge){V.__webglFramebuffer=[];for(let re=0;re<6;re++)if(M.mipmaps&&M.mipmaps.length>0){V.__webglFramebuffer[re]=[];for(let oe=0;oe<M.mipmaps.length;oe++)V.__webglFramebuffer[re][oe]=e.createFramebuffer()}else V.__webglFramebuffer[re]=e.createFramebuffer()}else{if(M.mipmaps&&M.mipmaps.length>0){V.__webglFramebuffer=[];for(let re=0;re<M.mipmaps.length;re++)V.__webglFramebuffer[re]=e.createFramebuffer()}else V.__webglFramebuffer=e.createFramebuffer();if(ve)for(let re=0,oe=he.length;re<oe;re++){let Ie=i.get(he[re]);if(Ie.__webglTexture===void 0)Ie.__webglTexture=e.createTexture(),a.memory.textures++}if(C.samples>0&&z(C)===!1){V.__webglMultisampledFramebuffer=e.createFramebuffer(),V.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,V.__webglMultisampledFramebuffer);for(let re=0;re<he.length;re++){let oe=he[re];V.__webglColorRenderbuffer[re]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,V.__webglColorRenderbuffer[re]);let Ie=s.convert(oe.format,oe.colorSpace),Ve=s.convert(oe.type),Ee=y(oe.internalFormat,Ie,Ve,oe.normalized,oe.colorSpace,C.isXRRenderTarget===!0),me=nn(C);e.renderbufferStorageMultisample(e.RENDERBUFFER,me,Ee,C.width,C.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+re,e.RENDERBUFFER,V.__webglColorRenderbuffer[re])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),C.depthBuffer)V.__webglDepthRenderbuffer=e.createRenderbuffer(),_e(V.__webglDepthRenderbuffer,C,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ge){n.bindTexture(e.TEXTURE_CUBE_MAP,Q.__webglTexture),pe(e.TEXTURE_CUBE_MAP,M);for(let re=0;re<6;re++)if(M.mipmaps&&M.mipmaps.length>0)for(let oe=0;oe<M.mipmaps.length;oe++)ce(V.__webglFramebuffer[re][oe],C,M,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+re,oe);else ce(V.__webglFramebuffer[re],C,M,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+re,0);if(p(M))x(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(ve){for(let re=0,oe=he.length;re<oe;re++){let Ie=he[re],Ve=i.get(Ie),Ee=e.TEXTURE_2D;if(C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)Ee=C.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Ee,Ve.__webglTexture),pe(Ee,Ie),ce(V.__webglFramebuffer,C,Ie,e.COLOR_ATTACHMENT0+re,Ee,0),p(Ie))x(Ee)}n.unbindTexture()}else{let re=e.TEXTURE_2D;if(C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)re=C.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(re,Q.__webglTexture),pe(re,M),M.mipmaps&&M.mipmaps.length>0)for(let oe=0;oe<M.mipmaps.length;oe++)ce(V.__webglFramebuffer[oe],C,M,e.COLOR_ATTACHMENT0,re,oe);else ce(V.__webglFramebuffer,C,M,e.COLOR_ATTACHMENT0,re,0);if(p(M))x(re);n.unbindTexture()}if(C.depthBuffer)Oe(C)}function Wt(C){let M=C.textures;for(let V=0,Q=M.length;V<Q;V++){let he=M[V];if(p(he)){let ge=_(C),ve=i.get(he).__webglTexture;n.bindTexture(ge,ve),x(ge),n.unbindTexture()}}}let lt=[],Lt=[];function Qt(C){if(C.samples>0){if(z(C)===!1){let{textures:M,width:V,height:Q}=C,he=e.COLOR_BUFFER_BIT,ge=C.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ve=i.get(C),re=M.length>1;if(re)for(let Ie=0;Ie<M.length;Ie++)n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,ve.__webglMultisampledFramebuffer);let oe=C.texture.mipmaps;if(oe&&oe.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer);for(let Ie=0;Ie<M.length;Ie++){if(C.resolveDepthBuffer){if(C.depthBuffer)he|=e.DEPTH_BUFFER_BIT;if(C.stencilBuffer&&C.resolveStencilBuffer)he|=e.STENCIL_BUFFER_BIT}if(re){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ie]);let Ve=i.get(M[Ie]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ve,0)}if(e.blitFramebuffer(0,0,V,Q,0,0,V,Q,he,e.NEAREST),c===!0){if(lt.length=0,Lt.length=0,lt.push(e.COLOR_ATTACHMENT0+Ie),C.depthBuffer&&C.storeMultisampledDepthBuffer===!1)lt.push(ge),Lt.push(ge),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,Lt);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,lt)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),re)for(let Ie=0;Ie<M.length;Ie++){n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ie]);let Ve=i.get(M[Ie]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.TEXTURE_2D,Ve,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglMultisampledFramebuffer)}else if(C.depthBuffer&&C.storeMultisampledDepthBuffer===!1&&c){let M=C.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[M])}}}function nn(C){return Math.min(r.maxSamples,C.samples)}function z(C){let M=i.get(C);return C.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function yn(C){let M=a.render.frame;if(u.get(C)!==M)u.set(C,M),C.update()}function St(C,M){let{colorSpace:V,format:Q,type:he}=C;if(C.isCompressedTexture===!0||C.isVideoTexture===!0)return M;if(V!==oi&&V!==Aa)if(ot.getTransfer(V)===Bt){if(Q!==pr||he!==zi)je("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ze("WebGLTextures: Unsupported texture color space:",V);return M}function Xt(C){if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement)l.width=C.naturalWidth||C.width,l.height=C.naturalHeight||C.height;else if(typeof VideoFrame<"u"&&C instanceof VideoFrame)l.width=C.displayWidth,l.height=C.displayHeight;else l.width=C.width,l.height=C.height;return l}this.allocateTextureUnit=D,this.resetTextureUnits=U,this.getTextureUnits=N,this.setTextureUnits=F,this.setTexture2D=K,this.setTexture2DArray=B,this.setTexture3D=X,this.setTextureCube=q,this.rebindTextures=We,this.setupRenderTarget=Ye,this.updateRenderTargetMipmap=Wt,this.updateMultisampleRenderTarget=Qt,this.setupDepthRenderbuffer=Oe,this.setupFrameBufferTexture=ce,this.useMultisampledRTT=z,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function QL(e,t){function n(i,r=Aa){let s,a=ot.getTransfer(r);if(i===zi)return e.UNSIGNED_BYTE;if(i===jp)return e.UNSIGNED_SHORT_4_4_4_4;if(i===Hp)return e.UNSIGNED_SHORT_5_5_5_1;if(i===IT)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===CT)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===MT)return e.BYTE;if(i===RT)return e.SHORT;if(i===Jc)return e.UNSIGNED_SHORT;if(i===Vp)return e.INT;if(i===hs)return e.UNSIGNED_INT;if(i===Br)return e.FLOAT;if(i===hr)return e.HALF_FLOAT;if(i===NT)return e.ALPHA;if(i===PT)return e.RGB;if(i===pr)return e.RGBA;if(i===va)return e.DEPTH_COMPONENT;if(i===Ea)return e.DEPTH_STENCIL;if(i===OT)return e.RED;if(i===Gp)return e.RED_INTEGER;if(i===Ta)return e.RG;if(i===$p)return e.RG_INTEGER;if(i===Kp)return e.RGBA_INTEGER;if(i===pd||i===md||i===gd||i===bd)if(a===Bt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===pd)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===md)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===gd)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===bd)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===pd)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===md)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===gd)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===bd)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Wp||i===Xp||i===qp||i===Jp)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Wp)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Xp)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===qp)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Jp)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Zp||i===Yp||i===Qp||i===em||i===tm||i===xd||i===nm)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Zp||i===Yp)return a===Bt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Qp)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===em)return s.COMPRESSED_R11_EAC;if(i===tm)return s.COMPRESSED_SIGNED_R11_EAC;if(i===xd)return s.COMPRESSED_RG11_EAC;if(i===nm)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===im||i===rm||i===sm||i===am||i===om||i===cm||i===lm||i===um||i===dm||i===fm||i===hm||i===pm||i===mm||i===gm)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===im)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===rm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===sm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===am)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===om)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===cm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===lm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===um)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===dm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===fm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===hm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===pm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===mm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===gm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===bm||i===xm||i===ym)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===bm)return a===Bt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===xm)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ym)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===_m||i===vm||i===yd||i===Em)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===_m)return s.COMPRESSED_RED_RGTC1_EXT;if(i===vm)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===yd)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Em)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Co)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}class PA{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Nd(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new Ei({vertexShader:e8,fragmentShader:t8,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new jt(new cl(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}function i8(e,t){function n(g,p){if(g.matrixAutoUpdate===!0)g.updateMatrix();p.value.copy(g.matrix)}function i(g,p){if(p.color.getRGB(g.fogColor.value,km(e)),p.isFog)g.fogNear.value=p.near,g.fogFar.value=p.far;else if(p.isFogExp2)g.fogDensity.value=p.density}function r(g,p,x,_,y){if(p.isNodeMaterial)p.uniformsNeedUpdate=!1;else if(p.isMeshBasicMaterial)s(g,p);else if(p.isMeshLambertMaterial){if(s(g,p),p.envMap)g.envMapIntensity.value=p.envMapIntensity}else if(p.isMeshToonMaterial)s(g,p),d(g,p);else if(p.isMeshPhongMaterial){if(s(g,p),u(g,p),p.envMap)g.envMapIntensity.value=p.envMapIntensity}else if(p.isMeshStandardMaterial){if(s(g,p),f(g,p),p.isMeshPhysicalMaterial)h(g,p,y)}else if(p.isMeshMatcapMaterial)s(g,p),b(g,p);else if(p.isMeshDepthMaterial)s(g,p);else if(p.isMeshDistanceMaterial)s(g,p),m(g,p);else if(p.isMeshNormalMaterial)s(g,p);else if(p.isLineBasicMaterial){if(a(g,p),p.isLineDashedMaterial)o(g,p)}else if(p.isPointsMaterial)c(g,p,x,_);else if(p.isSpriteMaterial)l(g,p);else if(p.isShadowMaterial)g.color.value.copy(p.color),g.opacity.value=p.opacity;else if(p.isShaderMaterial)p.uniformsNeedUpdate=!1}function s(g,p){if(g.opacity.value=p.opacity,p.color)g.diffuse.value.copy(p.color);if(p.emissive)g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity);if(p.map)g.map.value=p.map,n(p.map,g.mapTransform);if(p.alphaMap)g.alphaMap.value=p.alphaMap,n(p.alphaMap,g.alphaMapTransform);if(p.bumpMap){if(g.bumpMap.value=p.bumpMap,n(p.bumpMap,g.bumpMapTransform),g.bumpScale.value=p.bumpScale,p.side===kn)g.bumpScale.value*=-1}if(p.normalMap){if(g.normalMap.value=p.normalMap,n(p.normalMap,g.normalMapTransform),g.normalScale.value.copy(p.normalScale),p.side===kn)g.normalScale.value.negate()}if(p.displacementMap)g.displacementMap.value=p.displacementMap,n(p.displacementMap,g.displacementMapTransform),g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias;if(p.emissiveMap)g.emissiveMap.value=p.emissiveMap,n(p.emissiveMap,g.emissiveMapTransform);if(p.specularMap)g.specularMap.value=p.specularMap,n(p.specularMap,g.specularMapTransform);if(p.alphaTest>0)g.alphaTest.value=p.alphaTest;let x=t.get(p),{envMap:_,envMapRotation:y}=x;if(_){if(g.envMap.value=_,g.envMapRotation.value.setFromMatrix4(n8.makeRotationFromEuler(y)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1)g.envMapRotation.value.premultiply(kA);g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio}if(p.lightMap)g.lightMap.value=p.lightMap,g.lightMapIntensity.value=p.lightMapIntensity,n(p.lightMap,g.lightMapTransform);if(p.aoMap)g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,n(p.aoMap,g.aoMapTransform)}function a(g,p){if(g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map)g.map.value=p.map,n(p.map,g.mapTransform)}function o(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function c(g,p,x,_){if(g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*x,g.scale.value=_*0.5,p.map)g.map.value=p.map,n(p.map,g.uvTransform);if(p.alphaMap)g.alphaMap.value=p.alphaMap,n(p.alphaMap,g.alphaMapTransform);if(p.alphaTest>0)g.alphaTest.value=p.alphaTest}function l(g,p){if(g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map)g.map.value=p.map,n(p.map,g.mapTransform);if(p.alphaMap)g.alphaMap.value=p.alphaMap,n(p.alphaMap,g.alphaMapTransform);if(p.alphaTest>0)g.alphaTest.value=p.alphaTest}function u(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,0.0001)}function d(g,p){if(p.gradientMap)g.gradientMap.value=p.gradientMap}function f(g,p){if(g.metalness.value=p.metalness,p.metalnessMap)g.metalnessMap.value=p.metalnessMap,n(p.metalnessMap,g.metalnessMapTransform);if(g.roughness.value=p.roughness,p.roughnessMap)g.roughnessMap.value=p.roughnessMap,n(p.roughnessMap,g.roughnessMapTransform);if(p.envMap)g.envMapIntensity.value=p.envMapIntensity}function h(g,p,x){if(g.ior.value=p.ior,p.sheen>0){if(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap)g.sheenColorMap.value=p.sheenColorMap,n(p.sheenColorMap,g.sheenColorMapTransform);if(p.sheenRoughnessMap)g.sheenRoughnessMap.value=p.sheenRoughnessMap,n(p.sheenRoughnessMap,g.sheenRoughnessMapTransform)}if(p.clearcoat>0){if(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap)g.clearcoatMap.value=p.clearcoatMap,n(p.clearcoatMap,g.clearcoatMapTransform);if(p.clearcoatRoughnessMap)g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,n(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform);if(p.clearcoatNormalMap){if(g.clearcoatNormalMap.value=p.clearcoatNormalMap,n(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===kn)g.clearcoatNormalScale.value.negate()}}if(p.dispersion>0)g.dispersion.value=p.dispersion;if(p.retroreflectivity>0)g.retroreflectivity.value=p.retroreflectivity;if(p.iridescence>0){if(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap)g.iridescenceMap.value=p.iridescenceMap,n(p.iridescenceMap,g.iridescenceMapTransform);if(p.iridescenceThicknessMap)g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,n(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform)}if(p.transmission>0){if(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=x.texture,g.transmissionSamplerSize.value.set(x.width,x.height),p.transmissionMap)g.transmissionMap.value=p.transmissionMap,n(p.transmissionMap,g.transmissionMapTransform);if(g.thickness.value=p.thickness,p.thicknessMap)g.thicknessMap.value=p.thicknessMap,n(p.thicknessMap,g.thicknessMapTransform);g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)}if(p.anisotropy>0){if(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap)g.anisotropyMap.value=p.anisotropyMap,n(p.anisotropyMap,g.anisotropyMapTransform)}if(g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap)g.specularColorMap.value=p.specularColorMap,n(p.specularColorMap,g.specularColorMapTransform);if(p.specularIntensityMap)g.specularIntensityMap.value=p.specularIntensityMap,n(p.specularIntensityMap,g.specularIntensityMapTransform)}function b(g,p){if(p.matcap)g.matcap.value=p.matcap}function m(g,p){let x=t.get(p).light;g.referencePosition.value.setFromMatrixPosition(x.matrixWorld),g.nearDistance.value=x.shadow.camera.near,g.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function r8(e,t,n,i){let r={},s={},a=[],o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,v){let T=v.program;i.uniformBlockBinding(y,T)}function l(y,v){let T=r[y.id];if(T===void 0)g(y),T=u(y),r[y.id]=T,y.addEventListener("dispose",x);let A=v.program;i.updateUBOMapping(y,A);let E=t.render.frame;if(s[y.id]!==E)f(y),s[y.id]=E}function u(y){let v=d();y.__bindingPointIndex=v;let T=e.createBuffer(),{__size:A,usage:E}=y;return e.bindBuffer(e.UNIFORM_BUFFER,T),e.bufferData(e.UNIFORM_BUFFER,A,E),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,v,T),T}function d(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return Ze("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(y){let v=r[y.id],{uniforms:T,__cache:A}=y;e.bindBuffer(e.UNIFORM_BUFFER,v);for(let E=0,w=T.length;E<w;E++){let P=T[E];if(Array.isArray(P))for(let S=0,I=P.length;S<I;S++)h(P[S],E,S,A);else h(P,E,0,A)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function h(y,v,T,A){if(m(y,v,T,A)===!0){let{__offset:E,value:w}=y;if(Array.isArray(w)){let P=0;for(let S=0;S<w.length;S++){let I=w[S],U=p(I);if(b(I,y.__data,P),typeof I!=="number"&&typeof I!=="boolean"&&!I.isMatrix3&&!ArrayBuffer.isView(I))P+=U.storage/Float32Array.BYTES_PER_ELEMENT}}else b(w,y.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,E,y.__data)}}function b(y,v,T){if(typeof y==="number"||typeof y==="boolean")v[0]=y;else if(y.isMatrix3)v[0]=y.elements[0],v[1]=y.elements[1],v[2]=y.elements[2],v[3]=0,v[4]=y.elements[3],v[5]=y.elements[4],v[6]=y.elements[5],v[7]=0,v[8]=y.elements[6],v[9]=y.elements[7],v[10]=y.elements[8],v[11]=0;else if(ArrayBuffer.isView(y))v.set(new y.constructor(y.buffer,y.byteOffset,v.length));else y.toArray(v,T)}function m(y,v,T,A){let E=y.value,w=v+"_"+T;if(A[w]===void 0){if(typeof E==="number"||typeof E==="boolean")A[w]=E;else if(ArrayBuffer.isView(E))A[w]=E.slice();else A[w]=E.clone();return!0}else{let P=A[w];if(typeof E==="number"||typeof E==="boolean"){if(P!==E)return A[w]=E,!0}else if(ArrayBuffer.isView(E))return!0;else if(P.equals(E)===!1)return P.copy(E),!0}return!1}function g(y){let v=y.uniforms,T=0,A=16;for(let w=0,P=v.length;w<P;w++){let S=Array.isArray(v[w])?v[w]:[v[w]];for(let I=0,U=S.length;I<U;I++){let N=S[I],F=Array.isArray(N.value)?N.value:[N.value];for(let D=0,O=F.length;D<O;D++){let K=F[D],B=p(K),X=T%A,q=X%B.boundary,le=X+q;if(T+=q,le!==0&&A-le<B.storage)T+=A-le;N.__data=new Float32Array(B.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=T,T+=B.storage}}}let E=T%A;if(E>0)T+=A-E;return y.__size=T,y.__cache={},this}function p(y){let v={boundary:0,storage:0};if(typeof y==="number"||typeof y==="boolean")v.boundary=4,v.storage=4;else if(y.isVector2)v.boundary=8,v.storage=8;else if(y.isVector3||y.isColor)v.boundary=16,v.storage=12;else if(y.isVector4)v.boundary=16,v.storage=16;else if(y.isMatrix3)v.boundary=48,v.storage=48;else if(y.isMatrix4)v.boundary=64,v.storage=64;else if(y.isTexture)je("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(y))v.boundary=16,v.storage=y.byteLength;else je("WebGLRenderer: Unsupported uniform value type.",y);return v}function x(y){let v=y.target;v.removeEventListener("dispose",x);let T=a.indexOf(v.__bindingPointIndex);a.splice(T,1),e.deleteBuffer(r[v.id]),delete r[v.id],delete s[v.id]}function _(){for(let y in r)e.deleteBuffer(r[y]);a=[],r={},s={}}return{bind:c,update:l,dispose:_}}function a8(){if(gr===null)gr=new il(s8,16,16,Ta,hr),gr.name="DFG_LUT",gr.minFilter=En,gr.magFilter=En,gr.wrapS=Ro,gr.wrapT=Ro,gr.generateMipmaps=!1,gr.needsUpdate=!0;return gr}class og{constructor(e={}){let{canvas:t=VT(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=zi}=e;this.isWebGLRenderer=!0;let h;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");h=n.getContextAttributes().alpha}else h=s;let b=f,m=new Set([Kp,$p,Gp]),g=new Set([zi,hs,Jc,Co,jp,Hp]),p=new Uint32Array(4),x=new Int32Array(4),_=new j,y=null,v=null,T=[],A=[],E=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Ui,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let w=this,P=!1,S=null,I=null,U=null,N=null;this._outputColorSpace=ps;let F=0,D=0,O=null,K=-1,B=null,X=new Pt,q=new Pt,le=null,de=new qe(0),Me=0,{width:pe,height:J}=t,L=1,W=null,ne=null,ie=new Pt(0,0,pe,J),ce=new Pt(0,0,pe,J),_e=!1,Re=new sl,Oe=!1,We=!1,Ye=new Qe,Wt=new j,lt=new Pt,Lt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Qt=!1;function nn(){return O===null?L:1}let z=n;function yn(R,H){return t.getContext(R,H)}let St,Xt,C,M,V,Q,he,ge,ve,re,oe,Ie,Ve,Ee,me,Ge,Xe,vt,G,xe,ae,ye,Ce;try{let R={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${WE}`);if(t.addEventListener("webglcontextlost",it,!1),t.addEventListener("webglcontextrestored",zt,!1),t.addEventListener("webglcontextcreationerror",Mt,!1),z===null){if(z=yn("webgl2",R),z===null)if(yn("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}fe()}catch(R){throw t.removeEventListener("webglcontextlost",it,!1),t.removeEventListener("webglcontextrestored",zt,!1),t.removeEventListener("webglcontextcreationerror",Mt,!1),Ze("WebGLRenderer: "+R.message),R}function fe(){if(St=new hD(z),St.init(),ae=new QL(z,St),Xt=new iD(z,St,e,ae),C=new ZL(z,St),Xt.reversedDepthBuffer&&d)C.buffers.depth.setReversed(!0);I=z.createFramebuffer(),U=z.createFramebuffer(),N=z.createFramebuffer(),M=new gD(z),V=new FL,Q=new YL(z,St,C,V,Xt,ae,M),he=new fD(w),ge=new xP(z),ye=new tD(z,ge),ve=new pD(z,ge,M,ye),re=new xD(z,ve,ge,ye,M),vt=new bD(z,Xt,Q),me=new rD(V),oe=new LL(w,he,St,Xt,ye,me),Ie=new i8(w,V),Ve=new BL,Ee=new $L(St),Xe=new eD(w,he,C,re,h,o),Ge=new JL(w,re,Xt),Ce=new r8(z,M,Xt,C),G=new nD(z,St,M),xe=new mD(z,St,M),M.programs=oe.programs,w.capabilities=Xt,w.extensions=St,w.properties=V,w.renderLists=Ve,w.shadowMap=Ge,w.state=C,w.info=M}if(b!==zi)E=new _D(b,t.width,t.height,a,i,r);let Ae=new OA(w,z);this.xr=Ae,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let R=St.get("WEBGL_lose_context");if(R)R.loseContext()},this.forceContextRestore=function(){let R=St.get("WEBGL_lose_context");if(R)R.restoreContext()},this.getPixelRatio=function(){return L},this.setPixelRatio=function(R){if(R===void 0)return;L=R,this.setSize(pe,J,!1)},this.getSize=function(R){return R.set(pe,J)},this.setSize=function(R,H,ee=!0){if(Ae.isPresenting){je("WebGLRenderer: Can't change size while VR device is presenting.");return}if(pe=R,J=H,t.width=Math.floor(R*L),t.height=Math.floor(H*L),ee===!0)t.style.width=R+"px",t.style.height=H+"px";if(E!==null)E.setSize(t.width,t.height);this.setViewport(0,0,R,H)},this.getDrawingBufferSize=function(R){return R.set(pe*L,J*L).floor()},this.setDrawingBufferSize=function(R,H,ee){pe=R,J=H,L=ee,t.width=Math.floor(R*ee),t.height=Math.floor(H*ee),this.setViewport(0,0,R,H)},this.setEffects=function(R){if(b===zi){Ze("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(R){for(let H=0;H<R.length;H++)if(R[H].isOutputPass===!0){je("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}E.setEffects(R||[])},this.getCurrentViewport=function(R){return R.copy(X)},this.getViewport=function(R){return R.copy(ie)},this.setViewport=function(R,H,ee,Z){if(R.isVector4)ie.set(R.x,R.y,R.z,R.w);else ie.set(R,H,ee,Z);C.viewport(X.copy(ie).multiplyScalar(L).round())},this.getScissor=function(R){return R.copy(ce)},this.setScissor=function(R,H,ee,Z){if(R.isVector4)ce.set(R.x,R.y,R.z,R.w);else ce.set(R,H,ee,Z);C.scissor(q.copy(ce).multiplyScalar(L).round())},this.getScissorTest=function(){return _e},this.setScissorTest=function(R){C.setScissorTest(_e=R)},this.setOpaqueSort=function(R){W=R},this.setTransparentSort=function(R){ne=R},this.getClearColor=function(R){return R.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor(...arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha(...arguments)},this.clear=function(R=!0,H=!0,ee=!0){let Z=0;if(R){let Y=!1;if(O!==null){let Se=O.texture.format;Y=m.has(Se)}if(Y){let Se=O.texture.type,Pe=g.has(Se),we=Xe.getClearColor(),ke=Xe.getClearAlpha(),{r:ze,g:rt,b:ft}=we;if(Pe)p[0]=ze,p[1]=rt,p[2]=ft,p[3]=ke,z.clearBufferuiv(z.COLOR,0,p);else x[0]=ze,x[1]=rt,x[2]=ft,x[3]=ke,z.clearBufferiv(z.COLOR,0,x)}else Z|=z.COLOR_BUFFER_BIT}if(H)Z|=z.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(ee)Z|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(Z!==0)z.clear(Z)},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.setNodesHandler=function(R){R.setRenderer(this),S=R},this.dispose=function(){t.removeEventListener("webglcontextlost",it,!1),t.removeEventListener("webglcontextrestored",zt,!1),t.removeEventListener("webglcontextcreationerror",Mt,!1),Xe.dispose(),Ve.dispose(),Ee.dispose(),V.dispose(),he.dispose(),re.dispose(),ye.dispose(),Ce.dispose(),oe.dispose(),Ae.dispose(),Ae.removeEventListener("sessionstart",Eb),Ae.removeEventListener("sessionend",Tb),na.stop()};function it(R){R.preventDefault(),$c("WebGLRenderer: Context Lost."),P=!0}function zt(){$c("WebGLRenderer: Context Restored."),P=!1;let R=M.autoReset,H=Ge.enabled,ee=Ge.autoUpdate,Z=Ge.needsUpdate,Y=Ge.type;fe(),M.autoReset=R,Ge.enabled=H,Ge.autoUpdate=ee,Ge.needsUpdate=Z,Ge.type=Y}function Mt(R){Ze("WebGLRenderer: A WebGL context could not be created. Reason: ",R.statusMessage)}function Xi(R){let H=R.target;H.removeEventListener("dispose",Xi),wr(H)}function wr(R){WR(R),V.remove(R)}function WR(R){let H=V.get(R).programs;if(H!==void 0){if(H.forEach(function(ee){oe.releaseProgram(ee)}),R.isShaderMaterial)oe.releaseShaderCache(R)}}this.renderBufferDirect=function(R,H,ee,Z,Y,Se){if(H===null)H=Lt;let Pe=Y.isMesh&&Y.matrixWorld.determinantAffine()<0,we=JR(R,H,ee,Z,Y);C.setMaterial(Z,Pe);let ke=ee.index,ze=1;if(Z.wireframe===!0){if(ke=ve.getWireframeAttribute(ee),ke===void 0)return;ze=2}let rt=ee.drawRange,ft=ee.attributes.position,De=rt.start*ze,Rt=(rt.start+rt.count)*ze;if(Se!==null)De=Math.max(De,Se.start*ze),Rt=Math.min(Rt,(Se.start+Se.count)*ze);if(ke!==null)De=Math.max(De,0),Rt=Math.min(Rt,ke.count);else if(ft!==void 0&&ft!==null)De=Math.max(De,0),Rt=Math.min(Rt,ft.count);let on=Rt-De;if(on<0||on===1/0)return;ye.setup(Y,Z,we,ee,ke);let Gt,Ft=G;if(ke!==null)Gt=ge.get(ke),Ft=xe,Ft.setIndex(Gt);if(Y.isMesh)if(Z.wireframe===!0)C.setLineWidth(Z.wireframeLinewidth*nn()),Ft.setMode(z.LINES);else Ft.setMode(z.TRIANGLES);else if(Y.isLine){let In=Z.linewidth;if(In===void 0)In=1;if(C.setLineWidth(In*nn()),Y.isLineSegments)Ft.setMode(z.LINES);else if(Y.isLineLoop)Ft.setMode(z.LINE_LOOP);else Ft.setMode(z.LINE_STRIP)}else if(Y.isPoints)Ft.setMode(z.POINTS);else if(Y.isSprite)Ft.setMode(z.TRIANGLES);if(Y.isBatchedMesh)if(!St.get("WEBGL_multi_draw")){let{_multiDrawStarts:In,_multiDrawCounts:Ne,_multiDrawCount:Fn}=Y,xt=ke?ge.get(ke).bytesPerElement:1,pi=V.get(Z).currentProgram.getUniforms();for(let qi=0;qi<Fn;qi++)pi.setValue(z,"_gl_DrawID",qi),Ft.render(In[qi]/xt,Ne[qi])}else Ft.renderMultiDraw(Y._multiDrawStarts,Y._multiDrawCounts,Y._multiDrawCount);else if(Y.isInstancedMesh)Ft.renderInstances(De,on,Y.count);else if(ee.isInstancedBufferGeometry){let In=ee._maxInstanceCount!==void 0?ee._maxInstanceCount:1/0,Ne=Math.min(ee.instanceCount,In);Ft.renderInstances(De,on,Ne)}else Ft.render(De,on)};function vb(R,H,ee,Z){if(S!==null&&R.isNodeMaterial)S.setObject(Z,R);if(Oe===!0)me.setState(R,ee,!1);if(R.transparent===!0&&R.side===vi&&R.forceSinglePass===!1)R.side=kn,R.needsUpdate=!0,Vl(R,H,Z),R.side=fs,R.needsUpdate=!0,Vl(R,H,Z),R.side=vi;else Vl(R,H,Z)}this.compile=function(R,H,ee=null){if(ee===null)ee=R;if(S!==null)S.renderStart(R,H,ee);if(v=Ee.get(ee),v.init(H),A.push(v),ee.traverseVisible(function(Y){if(Y.isLight&&Y.layers.test(H.layers)){if(v.pushLight(Y),Y.castShadow)v.pushShadow(Y)}}),R!==ee)R.traverseVisible(function(Y){if(Y.isLight&&Y.layers.test(H.layers)){if(v.pushLight(Y),Y.castShadow)v.pushShadow(Y)}});if(v.setupLights(),S!==null)S.updateLights(v.state.lightsArray);if(We=this.localClippingEnabled,Oe=me.init(this.clippingPlanes,We),Oe===!0)me.setGlobalState(this.clippingPlanes,H);if(S!==null)Ge.render(v.state.shadowsArray,ee,H);let Z=new Set;if(R.traverse(function(Y){if(!(Y.isMesh||Y.isPoints||Y.isLine||Y.isSprite))return;let Se=Y.material;if(Se)if(Array.isArray(Se))for(let Pe=0;Pe<Se.length;Pe++){let we=Se[Pe];vb(we,ee,H,Y),Z.add(we)}else vb(Se,ee,H,Y),Z.add(Se)}),v=A.pop(),S!==null)S.renderEnd();return Z},this.compileAsync=function(R,H,ee=null){let Z=this.compile(R,H,ee);return new Promise((Y)=>{function Se(){if(Z.forEach(function(Pe){let ke=V.get(Pe).currentProgram;if(ke===void 0||ke.isReady())Z.delete(Pe)}),Z.size===0){Y(R);return}setTimeout(Se,10)}if(St.get("KHR_parallel_shader_compile")!==null)Se();else setTimeout(Se,10)})};let Nf=null;function XR(R){if(Nf)Nf(R)}function Eb(){na.stop()}function Tb(){na.start()}let na=new vA;if(na.setAnimationLoop(XR),typeof self<"u")na.setContext(self);this.setAnimationLoop=function(R){Nf=R,Ae.setAnimationLoop(R),R===null?na.stop():na.start()},Ae.addEventListener("sessionstart",Eb),Ae.addEventListener("sessionend",Tb),this.render=function(R,H){if(H!==void 0&&H.isCamera!==!0){Ze("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;if(S!==null)S.renderStart(R,H);let ee=Ae.enabled===!0&&Ae.isPresenting===!0,Z=E!==null&&(O===null||ee)&&E.begin(w,O);if(R.matrixWorldAutoUpdate===!0)R.updateMatrixWorld();if(H.parent===null&&H.matrixWorldAutoUpdate===!0)H.updateMatrixWorld();if(Ae.enabled===!0&&Ae.isPresenting===!0&&(E===null||E.isCompositing()===!1)){if(Ae.cameraAutoUpdate===!0)Ae.updateCamera(H);H=Ae.getCamera()}if(R.isScene===!0)R.onBeforeRender(w,R,H,O);if(v=Ee.get(R,A.length),v.init(H),v.state.textureUnits=Q.getTextureUnits(),A.push(v),Ye.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse),Re.setFromProjectionMatrix(Ye,Rm,H.reversedDepth),We=this.localClippingEnabled,Oe=me.init(this.clippingPlanes,We),y=Ve.get(R,T.length),y.init(),T.push(y),Ae.enabled===!0&&Ae.isPresenting===!0){let Pe=w.xr.getDepthSensingMesh();if(Pe!==null)Pf(Pe,H,-1/0,w.sortObjects)}if(Pf(R,H,0,w.sortObjects),y.finish(),S!==null)S.updateLights(v.state.lightsArray);if(w.sortObjects===!0)y.sort(W,ne);if(Qt=Ae.enabled===!1||Ae.isPresenting===!1||Ae.hasDepthSensing()===!1,Qt)Xe.addToRenderList(y,R);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Oe===!0)me.beginShadows();let Y=v.state.shadowsArray;if(Ge.render(Y,R,H),Oe===!0)me.endShadows();if((Z&&E.hasRenderPass())===!1){let Pe=y.opaque,we=y.transmissive;if(v.setupLights(),H.isArrayCamera){let ke=H.cameras;if(we.length>0)for(let ze=0,rt=ke.length;ze<rt;ze++){let ft=ke[ze];wb(Pe,we,R,ft)}if(Qt)Xe.render(R);for(let ze=0,rt=ke.length;ze<rt;ze++){let ft=ke[ze];Ab(y,R,ft,ft.viewport)}}else{if(we.length>0)wb(Pe,we,R,H);if(Qt)Xe.render(R);Ab(y,R,H)}}if(O!==null&&D===0)Q.updateMultisampleRenderTarget(O),Q.updateRenderTargetMipmap(O);if(Z)E.end(w);if(R.isScene===!0)R.onAfterRender(w,R,H);if(ye.resetDefaultState(),K=-1,B=null,A.pop(),A.length>0){if(v=A[A.length-1],Q.setTextureUnits(v.state.textureUnits),Oe===!0)me.setGlobalState(w.clippingPlanes,v.state.camera)}else v=null;if(T.pop(),T.length>0)y=T[T.length-1];else y=null;if(S!==null)S.renderEnd()};function Pf(R,H,ee,Z){if(R.visible===!1)return;if(R.layers.test(H.layers)){if(R.isGroup)ee=R.renderOrder;else if(R.isLOD){if(R.autoUpdate===!0)R.update(H)}else if(R.isLightProbeGrid)v.pushLightProbeGrid(R);else if(R.isLight){if(v.pushLight(R),R.castShadow)v.pushShadow(R)}else if(R.isSprite){if(!R.frustumCulled||R.intersectsFrustum(Re)){if(Z)lt.setFromMatrixPosition(R.matrixWorld).applyMatrix4(Ye);let Pe=re.update(R),we=R.material;if(we.visible)y.push(R,Pe,we,ee,lt.z,null,H)}}else if(R.isMesh||R.isLine||R.isPoints){if(!R.frustumCulled||R.intersectsFrustum(Re)){let Pe=re.update(R),we=R.material;if(Z){if(R.boundingSphere!==void 0){if(R.boundingSphere===null)R.computeBoundingSphere();lt.copy(R.boundingSphere.center)}else{if(Pe.boundingSphere===null)Pe.computeBoundingSphere();lt.copy(Pe.boundingSphere.center)}lt.applyMatrix4(R.matrixWorld).applyMatrix4(Ye)}if(Array.isArray(we)){let ke=Pe.groups;for(let ze=0,rt=ke.length;ze<rt;ze++){let ft=ke[ze],De=we[ft.materialIndex];if(De&&De.visible)y.push(R,Pe,De,ee,lt.z,ft,H)}}else if(we.visible)y.push(R,Pe,we,ee,lt.z,null,H)}}}let Se=R.children;for(let Pe=0,we=Se.length;Pe<we;Pe++)Pf(Se[Pe],H,ee,Z)}function Ab(R,H,ee,Z){let{opaque:Y,transmissive:Se,transparent:Pe}=R;if(v.setupLightsView(ee),Oe===!0)me.setGlobalState(w.clippingPlanes,ee);if(Z)C.viewport(X.copy(Z));if(Y.length>0)zl(Y,H,ee);if(Se.length>0)zl(Se,H,ee);if(Pe.length>0)zl(Pe,H,ee);C.buffers.depth.setTest(!0),C.buffers.depth.setMask(!0),C.buffers.color.setMask(!0),C.setPolygonOffset(!1)}function wb(R,H,ee,Z){if((ee.isScene===!0?ee.overrideMaterial:null)!==null)return;if(v.state.transmissionRenderTarget[Z.id]===void 0){let De=St.has("EXT_color_buffer_half_float")||St.has("EXT_color_buffer_float");v.state.transmissionRenderTarget[Z.id]=new ci(1,1,{generateMipmaps:!0,type:De?hr:zi,minFilter:fr,samples:Math.max(4,Xt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:ot.workingColorSpace})}let Se=v.state.transmissionRenderTarget[Z.id],Pe=Z.viewport||X;Se.setSize(Pe.z*w.transmissionResolutionScale,Pe.w*w.transmissionResolutionScale);let we=w.getRenderTarget(),ke=w.getActiveCubeFace(),ze=w.getActiveMipmapLevel();if(w.setRenderTarget(Se),w.getClearColor(de),Me=w.getClearAlpha(),Me<1)w.setClearColor(16777215,0.5);if(w.clear(),Qt)Xe.render(ee);let rt=w.toneMapping;w.toneMapping=Ui;let ft=Z.viewport;if(Z.viewport!==void 0)Z.viewport=void 0;if(v.setupLightsView(Z),Oe===!0)me.setGlobalState(w.clippingPlanes,Z);if(zl(R,ee,Z),Q.updateMultisampleRenderTarget(Se),Q.updateRenderTargetMipmap(Se),St.has("WEBGL_multisampled_render_to_texture")===!1){let De=!1;for(let Rt=0,on=H.length;Rt<on;Rt++){let Gt=H[Rt],{object:Ft,geometry:In,material:Ne,group:Fn}=Gt;if(Ne.side===vi&&Ft.layers.test(Z.layers)){let xt=Ne.side;Ne.side=kn,Ne.needsUpdate=!0,Sb(Ft,ee,Z,In,Ne,Fn),Ne.side=xt,Ne.needsUpdate=!0,De=!0}}if(De===!0)Q.updateMultisampleRenderTarget(Se),Q.updateRenderTargetMipmap(Se)}if(w.setRenderTarget(we,ke,ze),w.setClearColor(de,Me),ft!==void 0)Z.viewport=ft;w.toneMapping=rt}function zl(R,H,ee){let Z=H.isScene===!0?H.overrideMaterial:null;for(let Y=0,Se=R.length;Y<Se;Y++){let Pe=R[Y],{object:we,geometry:ke,group:ze}=Pe,rt=Pe.material;if(rt.allowOverride===!0&&Z!==null)rt=Z;if(we.layers.test(ee.layers))Sb(we,H,ee,ke,rt,ze)}}function Sb(R,H,ee,Z,Y,Se){if(S!==null&&Y.isNodeMaterial)S.setObject(R,Y);if(R.onBeforeRender(w,H,ee,Z,Y,Se),R.modelViewMatrix.multiplyMatrices(ee.matrixWorldInverse,R.matrixWorld),R.normalMatrix.getNormalMatrix(R.modelViewMatrix),Y.onBeforeRender(w,H,ee,Z,R,Se),Y.transparent===!0&&Y.side===vi&&Y.forceSinglePass===!1)Y.side=kn,Y.needsUpdate=!0,w.renderBufferDirect(ee,H,Z,Y,R,Se),Y.side=fs,Y.needsUpdate=!0,w.renderBufferDirect(ee,H,Z,Y,R,Se),Y.side=vi;else w.renderBufferDirect(ee,H,Z,Y,R,Se);R.onAfterRender(w,H,ee,Z,Y,Se)}function Vl(R,H,ee){if(H.isScene!==!0)H=Lt;let Z=V.get(R),Y=v.state.lights,Se=v.state.shadowsArray,Pe=Y.state.version,we=oe.getParameters(R,Y.state,Se,H,ee,v.state.lightProbeGridArray),ke=oe.getProgramCacheKey(we),ze=Z.programs;Z.environment=R.isMeshStandardMaterial||R.isMeshLambertMaterial||R.isMeshPhongMaterial?H.environment:null,Z.fog=H.fog;let rt=R.isMeshStandardMaterial||R.isMeshLambertMaterial&&!R.envMap||R.isMeshPhongMaterial&&!R.envMap;if(Z.envMap=he.get(R.envMap||Z.environment,rt),Z.envMapRotation=Z.environment!==null&&R.envMap===null?H.environmentRotation:R.envMapRotation,ze===void 0)R.addEventListener("dispose",Xi),ze=new Map,Z.programs=ze;let ft=ze.get(ke);if(ft!==void 0){if(Z.currentProgram===ft&&Z.lightsStateVersion===Pe)return Rb(R,we),ft}else{if(we.uniforms=oe.getUniforms(R),S!==null&&R.isNodeMaterial)S.build(R,ee,we);R.onBeforeCompile(we,w),ft=oe.acquireProgram(we,ke),ze.set(ke,ft),Z.uniforms=we.uniforms}let De=Z.uniforms;if(!R.isShaderMaterial&&!R.isRawShaderMaterial||R.clipping===!0)De.clippingPlanes=me.uniform;if(Rb(R,we),Z.needsLights=YR(R),Z.lightsStateVersion=Pe,Z.needsLights)De.ambientLightColor.value=Y.state.ambient,De.lightProbe.value=Y.state.probe,De.sunLights.value=Y.state.sun,De.sunLightShadows.value=Y.state.sunShadow,De.directionalLights.value=Y.state.directional,De.directionalLightShadows.value=Y.state.directionalShadow,De.spotLights.value=Y.state.spot,De.spotLightShadows.value=Y.state.spotShadow,De.rectAreaLights.value=Y.state.rectArea,De.ltc_1.value=Y.state.rectAreaLTC1,De.ltc_2.value=Y.state.rectAreaLTC2,De.pointLights.value=Y.state.point,De.pointLightShadows.value=Y.state.pointShadow,De.hemisphereLights.value=Y.state.hemi,De.sunShadowMatrix.value=Y.state.sunShadowMatrix,De.sunShadowCascade.value=Y.state.sunShadowCascade,De.directionalShadowMatrix.value=Y.state.directionalShadowMatrix,De.spotLightMatrix.value=Y.state.spotLightMatrix,De.spotLightMap.value=Y.state.spotLightMap,De.pointShadowMatrix.value=Y.state.pointShadowMatrix;return Z.lightProbeGrid=v.state.lightProbeGridArray.length>0,Z.currentProgram=ft,Z.uniformsList=null,ft}function Mb(R){if(R.uniformsList===null){let H=R.currentProgram.getUniforms();R.uniformsList=gl.seqWithValue(H.seq,R.uniforms)}return R.uniformsList}function Rb(R,H){let ee=V.get(R);ee.outputColorSpace=H.outputColorSpace,ee.batching=H.batching,ee.batchingColor=H.batchingColor,ee.instancing=H.instancing,ee.instancingColor=H.instancingColor,ee.instancingMorph=H.instancingMorph,ee.skinning=H.skinning,ee.morphTargets=H.morphTargets,ee.morphNormals=H.morphNormals,ee.morphColors=H.morphColors,ee.morphTargetsCount=H.morphTargetsCount,ee.numClippingPlanes=H.numClippingPlanes,ee.numIntersection=H.numClipIntersection,ee.vertexAlphas=H.vertexAlphas,ee.vertexTangents=H.vertexTangents,ee.toneMapping=H.toneMapping}function qR(R,H){if(R.length===0)return null;if(R.length===1)return R[0].texture!==null?R[0]:null;_.setFromMatrixPosition(H.matrixWorld);for(let ee=0,Z=R.length;ee<Z;ee++){let Y=R[ee];if(Y.texture!==null&&Y.boundingBox.containsPoint(_))return Y}return null}function JR(R,H,ee,Z,Y){if(H.isScene!==!0)H=Lt;Q.resetTextureUnits();let Se=H.fog,Pe=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial?H.environment:null,we=O===null?w.outputColorSpace:O.isXRRenderTarget===!0?O.texture.colorSpace:ot.workingColorSpace,ke=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial&&!Z.envMap||Z.isMeshPhongMaterial&&!Z.envMap,ze=he.get(Z.envMap||Pe,ke),rt=Z.vertexColors===!0&&!!ee.attributes.color&&ee.attributes.color.itemSize===4,ft=!!ee.attributes.tangent&&(!!Z.normalMap||Z.anisotropy>0),De=!!ee.morphAttributes.position,Rt=!!ee.morphAttributes.normal,on=!!ee.morphAttributes.color,Gt=Ui;if(Z.toneMapped){if(O===null||O.isXRRenderTarget===!0)Gt=w.toneMapping}let Ft=ee.morphAttributes.position||ee.morphAttributes.normal||ee.morphAttributes.color,In=Ft!==void 0?Ft.length:0,Ne=V.get(Z),Fn=v.state.lights;if(Oe===!0){if(We===!0||R!==B){let Vt=R===B&&Z.id===K;me.setState(Z,R,Vt)}}let xt=!1;if(Z.version===Ne.__version){if(Ne.needsLights&&Ne.lightsStateVersion!==Fn.state.version)xt=!0;else if(Ne.outputColorSpace!==we)xt=!0;else if(Y.isBatchedMesh&&Ne.batching===!1)xt=!0;else if(!Y.isBatchedMesh&&Ne.batching===!0)xt=!0;else if(Y.isBatchedMesh&&Ne.batchingColor===!0&&Y._colorsTexture===null)xt=!0;else if(Y.isBatchedMesh&&Ne.batchingColor===!1&&Y._colorsTexture!==null)xt=!0;else if(Y.isInstancedMesh&&Ne.instancing===!1)xt=!0;else if(!Y.isInstancedMesh&&Ne.instancing===!0)xt=!0;else if(Y.isSkinnedMesh&&Ne.skinning===!1)xt=!0;else if(!Y.isSkinnedMesh&&Ne.skinning===!0)xt=!0;else if(Y.isInstancedMesh&&Ne.instancingColor===!0&&Y.instanceColor===null)xt=!0;else if(Y.isInstancedMesh&&Ne.instancingColor===!1&&Y.instanceColor!==null)xt=!0;else if(Y.isInstancedMesh&&Ne.instancingMorph===!0&&Y.morphTexture===null)xt=!0;else if(Y.isInstancedMesh&&Ne.instancingMorph===!1&&Y.morphTexture!==null)xt=!0;else if(Ne.envMap!==ze)xt=!0;else if(Z.fog===!0&&Ne.fog!==Se)xt=!0;else if(Ne.numClippingPlanes!==void 0&&(Ne.numClippingPlanes!==me.numPlanes||Ne.numIntersection!==me.numIntersection))xt=!0;else if(Ne.vertexAlphas!==rt)xt=!0;else if(Ne.vertexTangents!==ft)xt=!0;else if(Ne.morphTargets!==De)xt=!0;else if(Ne.morphNormals!==Rt)xt=!0;else if(Ne.morphColors!==on)xt=!0;else if(Ne.toneMapping!==Gt)xt=!0;else if(Ne.morphTargetsCount!==In)xt=!0;else if(!!Ne.lightProbeGrid!==v.state.lightProbeGridArray.length>0)xt=!0}else xt=!0,Ne.__version=Z.version;let pi=Ne.currentProgram;if(xt===!0){if(pi=Vl(Z,H,Y),S&&Z.isNodeMaterial)S.onUpdateProgram(Z,pi,Ne)}let qi=!1,Wr=!1,za=!1,kt=pi.getUniforms(),rn=Ne.uniforms;if(C.useProgram(pi.program))qi=!0,Wr=!0,za=!0;if(Z.id!==K)K=Z.id,Wr=!0;if(Ne.needsLights){let Vt=qR(v.state.lightProbeGridArray,Y);if(Ne.lightProbeGrid!==Vt)Ne.lightProbeGrid=Vt,Wr=!0}if(qi||B!==R){if(C.buffers.depth.getReversed()&&R.reversedDepth!==!0)R._reversedDepth=!0,R.updateProjectionMatrix();kt.setValue(z,"projectionMatrix",R.projectionMatrix),kt.setValue(z,"viewMatrix",R.matrixWorldInverse);let qr=kt.map.cameraPosition;if(qr!==void 0)qr.setValue(z,Wt.setFromMatrixPosition(R.matrixWorld));if(Xt.logarithmicDepthBuffer)kt.setValue(z,"logDepthBufFC",2/(Math.log(R.far+1)/Math.LN2));if(Z.isMeshPhongMaterial||Z.isMeshToonMaterial||Z.isMeshLambertMaterial||Z.isMeshBasicMaterial||Z.isMeshStandardMaterial||Z.isShaderMaterial)kt.setValue(z,"isOrthographic",R.isOrthographicCamera===!0);if(B!==R)B=R,Wr=!0,za=!0}if(Ne.needsLights){if(Fn.state.sunShadowMap.length>0)kt.setValue(z,"sunShadowMap",Fn.state.sunShadowMap,Q);if(Fn.state.directionalShadowMap.length>0)kt.setValue(z,"directionalShadowMap",Fn.state.directionalShadowMap,Q);if(Fn.state.spotShadowMap.length>0)kt.setValue(z,"spotShadowMap",Fn.state.spotShadowMap,Q);if(Fn.state.pointShadowMap.length>0)kt.setValue(z,"pointShadowMap",Fn.state.pointShadowMap,Q)}if(Y.isSkinnedMesh){kt.setOptional(z,Y,"bindMatrix"),kt.setOptional(z,Y,"bindMatrixInverse");let Vt=Y.skeleton;if(Vt){if(Vt.boneTexture===null)Vt.computeBoneTexture();kt.setValue(z,"boneTexture",Vt.boneTexture,Q)}}if(Y.isBatchedMesh){if(kt.setOptional(z,Y,"batchingTexture"),kt.setValue(z,"batchingTexture",Y._matricesTexture,Q),kt.setOptional(z,Y,"batchingIdTexture"),kt.setValue(z,"batchingIdTexture",Y._indirectTexture,Q),kt.setOptional(z,Y,"batchingColorTexture"),Y._colorsTexture!==null)kt.setValue(z,"batchingColorTexture",Y._colorsTexture,Q)}let Xr=ee.morphAttributes;if(Xr.position!==void 0||Xr.normal!==void 0||Xr.color!==void 0)vt.update(Y,ee,pi);if(Wr||Ne.receiveShadow!==Y.receiveShadow)Ne.receiveShadow=Y.receiveShadow,kt.setValue(z,"receiveShadow",Y.receiveShadow);if((Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial)&&Z.envMap===null&&H.environment!==null)rn.envMapIntensity.value=H.environmentIntensity;if(rn.dfgLUT!==void 0)rn.dfgLUT.value=a8();if(Wr){if(kt.setValue(z,"toneMappingExposure",w.toneMappingExposure),Ne.needsLights)ZR(rn,za);if(Se&&Z.fog===!0)Ie.refreshFogUniforms(rn,Se);if(Ie.refreshMaterialUniforms(rn,Z,L,J,v.state.transmissionRenderTarget[R.id]),Ne.needsLights&&Ne.lightProbeGrid){let Vt=Ne.lightProbeGrid;rn.probesSH.value=Vt.texture,rn.probesMin.value.copy(Vt.boundingBox.min),rn.probesMax.value.copy(Vt.boundingBox.max),rn.probesResolution.value.copy(Vt.resolution)}gl.upload(z,Mb(Ne),rn,Q)}if(Z.isShaderMaterial&&Z.uniformsNeedUpdate===!0)gl.upload(z,Mb(Ne),rn,Q),Z.uniformsNeedUpdate=!1;if(Z.isSpriteMaterial)kt.setValue(z,"center",Y.center);if(kt.setValue(z,"modelViewMatrix",Y.modelViewMatrix),kt.setValue(z,"normalMatrix",Y.normalMatrix),kt.setValue(z,"modelMatrix",Y.matrixWorld),Z.uniformsGroups!==void 0){let Vt=Z.uniformsGroups;for(let qr=0,Va=Vt.length;qr<Va;qr++){let Cb=Vt[qr];Ce.update(Cb,pi),Ce.bind(Cb,pi)}}return pi}function ZR(R,H){R.ambientLightColor.needsUpdate=H,R.lightProbe.needsUpdate=H,R.sunLights.needsUpdate=H,R.sunLightShadows.needsUpdate=H,R.directionalLights.needsUpdate=H,R.directionalLightShadows.needsUpdate=H,R.pointLights.needsUpdate=H,R.pointLightShadows.needsUpdate=H,R.spotLights.needsUpdate=H,R.spotLightShadows.needsUpdate=H,R.rectAreaLights.needsUpdate=H,R.hemisphereLights.needsUpdate=H}function YR(R){return R.isMeshLambertMaterial||R.isMeshToonMaterial||R.isMeshPhongMaterial||R.isMeshStandardMaterial||R.isShadowMaterial||R.isShaderMaterial&&R.lights===!0}this.getActiveCubeFace=function(){return F},this.getActiveMipmapLevel=function(){return D},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(R,H,ee){let Z=V.get(R);if(Z.__autoAllocateDepthBuffer=R.resolveDepthBuffer===!1,Z.__autoAllocateDepthBuffer===!1)Z.__useRenderToTexture=!1;V.get(R.texture).__webglTexture=H,V.get(R.depthTexture).__webglTexture=Z.__autoAllocateDepthBuffer?void 0:ee,Z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(R,H){let ee=V.get(R);ee.__webglFramebuffer=H,ee.__useDefaultFramebuffer=H===void 0},this.setRenderTarget=function(R,H=0,ee=0){O=R,F=H,D=ee;let Z=null,Y=!1,Se=!1;if(R){let we=V.get(R);if(we.__useDefaultFramebuffer!==void 0){C.bindFramebuffer(z.FRAMEBUFFER,we.__webglFramebuffer),X.copy(R.viewport),q.copy(R.scissor),le=R.scissorTest,C.viewport(X),C.scissor(q),C.setScissorTest(le),K=-1;return}else if(we.__webglFramebuffer===void 0)Q.setupRenderTarget(R);else if(we.__hasExternalTextures)Q.rebindTextures(R,V.get(R.texture).__webglTexture,V.get(R.depthTexture).__webglTexture);else if(R.depthBuffer){let rt=R.depthTexture;if(we.__boundDepthTexture!==rt){if(rt!==null&&V.has(rt)&&(R.width!==rt.image.width||R.height!==rt.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Q.setupDepthRenderbuffer(R)}}let ke=R.texture;if(ke.isData3DTexture||ke.isDataArrayTexture||ke.isCompressedArrayTexture)Se=!0;let ze=V.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget){if(Array.isArray(ze[H]))Z=ze[H][ee];else Z=ze[H];Y=!0}else if(R.samples>0&&Q.useMultisampledRTT(R)===!1)Z=V.get(R).__webglMultisampledFramebuffer;else if(Array.isArray(ze))Z=ze[ee];else Z=ze;X.copy(R.viewport),q.copy(R.scissor),le=R.scissorTest}else X.copy(ie).multiplyScalar(L).floor(),q.copy(ce).multiplyScalar(L).floor(),le=_e;if(ee!==0)Z=I;if(C.bindFramebuffer(z.FRAMEBUFFER,Z))C.drawBuffers(R,Z);if(C.viewport(X),C.scissor(q),C.setScissorTest(le),Y){let we=V.get(R.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+H,we.__webglTexture,ee)}else if(Se){let we=H;for(let ke=0;ke<R.textures.length;ke++){let ze=V.get(R.textures[ke]);z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0+ke,ze.__webglTexture,ee,we)}}else if(R!==null&&ee!==0){let we=V.get(R.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,we.__webglTexture,ee)}K=-1};function Ib(R){let H=V.get(R);if(H.__readFormat!==R.format||H.__readType!==R.type)H.__readFormat=R.format,H.__readType=R.type,H.__formatReadable=Xt.textureFormatReadable(R.format),H.__typeReadable=Xt.textureTypeReadable(R.type);return H}if(this.readRenderTargetPixels=function(R,H,ee,Z,Y,Se,Pe,we=0){if(!(R&&R.isWebGLRenderTarget)){Ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ke=V.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&Pe!==void 0)ke=ke[Pe];if(ke){C.bindFramebuffer(z.FRAMEBUFFER,ke);try{let ze=R.textures[we],{format:rt,type:ft}=ze;if(R.textures.length>1)z.readBuffer(z.COLOR_ATTACHMENT0+we);let De=Ib(ze);if(De.__formatReadable===!1){Ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(De.__typeReadable===!1){Ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(H>=0&&H<=R.width-Z&&(ee>=0&&ee<=R.height-Y))z.readPixels(H,ee,Z,Y,ae.convert(rt),ae.convert(ft),Se)}finally{let ze=O!==null?V.get(O).__webglFramebuffer:null;C.bindFramebuffer(z.FRAMEBUFFER,ze)}}},this.readRenderTargetPixelsAsync=async function(R,H,ee,Z,Y,Se,Pe,we=0){if(!(R&&R.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ke=V.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&Pe!==void 0)ke=ke[Pe];if(ke)if(H>=0&&H<=R.width-Z&&(ee>=0&&ee<=R.height-Y)){C.bindFramebuffer(z.FRAMEBUFFER,ke);let ze=R.textures[we],{format:rt,type:ft}=ze;if(R.textures.length>1)z.readBuffer(z.COLOR_ATTACHMENT0+we);let De=Ib(ze);if(De.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(De.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Rt=z.createBuffer();z.bindBuffer(z.PIXEL_PACK_BUFFER,Rt),z.bufferData(z.PIXEL_PACK_BUFFER,Se.byteLength,z.STREAM_READ),z.readPixels(H,ee,Z,Y,ae.convert(rt),ae.convert(ft),0),z.bindBuffer(z.PIXEL_PACK_BUFFER,null);let on=O!==null?V.get(O).__webglFramebuffer:null;C.bindFramebuffer(z.FRAMEBUFFER,on);let Gt=z.fenceSync(z.SYNC_GPU_COMMANDS_COMPLETE,0);return z.flush(),await HT(z,Gt,4),z.bindBuffer(z.PIXEL_PACK_BUFFER,Rt),z.getBufferSubData(z.PIXEL_PACK_BUFFER,0,Se),z.bindBuffer(z.PIXEL_PACK_BUFFER,null),z.deleteBuffer(Rt),z.deleteSync(Gt),Se}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(R,H=null,ee=0){let Z=Math.pow(2,-ee),Y=Math.floor(R.image.width*Z),Se=Math.floor(R.image.height*Z),Pe=H!==null?H.x:0,we=H!==null?H.y:0;Q.setTexture2D(R,0),z.copyTexSubImage2D(z.TEXTURE_2D,ee,0,0,Pe,we,Y,Se),C.unbindTexture()},this.copyTextureToTexture=function(R,H,ee=null,Z=null,Y=0,Se=0){let Pe,we,ke,ze,rt,ft,De,Rt,on,Gt=R.isCompressedTexture?R.mipmaps[Se]:R.image;if(ee!==null)Pe=ee.max.x-ee.min.x,we=ee.max.y-ee.min.y,ke=ee.isBox3?ee.max.z-ee.min.z:1,ze=ee.min.x,rt=ee.min.y,ft=ee.isBox3?ee.min.z:0;else{let rn=Math.pow(2,-Y);if(Pe=Math.floor(Gt.width*rn),we=Math.floor(Gt.height*rn),R.isDataArrayTexture)ke=Gt.depth;else if(R.isData3DTexture)ke=Math.floor(Gt.depth*rn);else ke=1;ze=0,rt=0,ft=0}if(Z!==null)De=Z.x,Rt=Z.y,on=Z.z;else De=0,Rt=0,on=0;let Ft=ae.convert(H.format),In=ae.convert(H.type),Ne;if(H.isData3DTexture)Q.setTexture3D(H,0),Ne=z.TEXTURE_3D;else if(H.isDataArrayTexture||H.isCompressedArrayTexture)Q.setTexture2DArray(H,0),Ne=z.TEXTURE_2D_ARRAY;else Q.setTexture2D(H,0),Ne=z.TEXTURE_2D;C.activeTexture(z.TEXTURE0),C.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,H.flipY),C.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),C.pixelStorei(z.UNPACK_ALIGNMENT,H.unpackAlignment);let Fn=C.getParameter(z.UNPACK_ROW_LENGTH),xt=C.getParameter(z.UNPACK_IMAGE_HEIGHT),pi=C.getParameter(z.UNPACK_SKIP_PIXELS),qi=C.getParameter(z.UNPACK_SKIP_ROWS),Wr=C.getParameter(z.UNPACK_SKIP_IMAGES);C.pixelStorei(z.UNPACK_ROW_LENGTH,Gt.width),C.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Gt.height),C.pixelStorei(z.UNPACK_SKIP_PIXELS,ze),C.pixelStorei(z.UNPACK_SKIP_ROWS,rt),C.pixelStorei(z.UNPACK_SKIP_IMAGES,ft);let za=R.isDataArrayTexture||R.isData3DTexture,kt=H.isDataArrayTexture||H.isData3DTexture;if(R.isDepthTexture){let rn=V.get(R),Xr=V.get(H),Vt=V.get(rn.__renderTarget),qr=V.get(Xr.__renderTarget);C.bindFramebuffer(z.READ_FRAMEBUFFER,Vt.__webglFramebuffer),C.bindFramebuffer(z.DRAW_FRAMEBUFFER,qr.__webglFramebuffer);for(let Va=0;Va<ke;Va++){if(za)z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,V.get(R).__webglTexture,Y,ft+Va),z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,V.get(H).__webglTexture,Se,on+Va);z.blitFramebuffer(ze,rt,Pe,we,De,Rt,Pe,we,z.DEPTH_BUFFER_BIT,z.NEAREST)}C.bindFramebuffer(z.READ_FRAMEBUFFER,null),C.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(Y!==0||R.isRenderTargetTexture||V.has(R)){let rn=V.get(R),Xr=V.get(H);C.bindFramebuffer(z.READ_FRAMEBUFFER,U),C.bindFramebuffer(z.DRAW_FRAMEBUFFER,N);for(let Vt=0;Vt<ke;Vt++){if(za)z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,rn.__webglTexture,Y,ft+Vt);else z.framebufferTexture2D(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,rn.__webglTexture,Y);if(kt)z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Xr.__webglTexture,Se,on+Vt);else z.framebufferTexture2D(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Xr.__webglTexture,Se);if(Y!==0)z.blitFramebuffer(ze,rt,Pe,we,De,Rt,Pe,we,z.COLOR_BUFFER_BIT,z.NEAREST);else if(kt)z.copyTexSubImage3D(Ne,Se,De,Rt,on+Vt,ze,rt,Pe,we);else z.copyTexSubImage2D(Ne,Se,De,Rt,ze,rt,Pe,we)}C.bindFramebuffer(z.READ_FRAMEBUFFER,null),C.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(kt)if(R.isDataTexture||R.isData3DTexture)z.texSubImage3D(Ne,Se,De,Rt,on,Pe,we,ke,Ft,In,Gt.data);else if(H.isCompressedArrayTexture)z.compressedTexSubImage3D(Ne,Se,De,Rt,on,Pe,we,ke,Ft,Gt.data);else z.texSubImage3D(Ne,Se,De,Rt,on,Pe,we,ke,Ft,In,Gt);else if(R.isDataTexture)z.texSubImage2D(z.TEXTURE_2D,Se,De,Rt,Pe,we,Ft,In,Gt.data);else if(R.isCompressedTexture)z.compressedTexSubImage2D(z.TEXTURE_2D,Se,De,Rt,Gt.width,Gt.height,Ft,Gt.data);else z.texSubImage2D(z.TEXTURE_2D,Se,De,Rt,Pe,we,Ft,In,Gt);if(C.pixelStorei(z.UNPACK_ROW_LENGTH,Fn),C.pixelStorei(z.UNPACK_IMAGE_HEIGHT,xt),C.pixelStorei(z.UNPACK_SKIP_PIXELS,pi),C.pixelStorei(z.UNPACK_SKIP_ROWS,qi),C.pixelStorei(z.UNPACK_SKIP_IMAGES,Wr),Se===0&&H.generateMipmaps)z.generateMipmap(Ne);C.unbindTexture()},this.initRenderTarget=function(R){if(V.get(R).__webglFramebuffer===void 0)Q.setupRenderTarget(R)},this.initTexture=function(R){if(R.isCubeTexture)Q.setTextureCube(R,0);else if(R.isData3DTexture)Q.setTexture3D(R,0);else if(R.isDataArrayTexture||R.isCompressedArrayTexture)Q.setTexture2DArray(R,0);else Q.setTexture2D(R,0);C.unbindTexture()},this.resetState=function(){F=0,D=0,O=null,C.reset(),ye.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Rm}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=ot._getDrawingBufferColorSpace(e),t.unpackColorSpace=ot._getUnpackColorSpace()}}var yP=`#ifdef USE_ALPHAHASHif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;-#endif`,VN=`#ifdef USE_ALPHAHASH+#endif`,_P=`#ifdef USE_ALPHAHASHconst float ALPHA_HASH_SCALE = 0.05;float hash2D( vec2 value ) {return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );@@ -350,20 +354,20 @@ Program Info Log: `+U+`: cases.z;return clamp( threshold , 1.0e-6, 1.0 );}-#endif`,jN=`#ifdef USE_ALPHAMAP+#endif`,vP=`#ifdef USE_ALPHAMAPdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;-#endif`,HN=`#ifdef USE_ALPHAMAP+#endif`,EP=`#ifdef USE_ALPHAMAPuniform sampler2D alphaMap;-#endif`,GN=`#ifdef USE_ALPHATEST+#endif`,TP=`#ifdef USE_ALPHATEST#ifdef ALPHA_TO_COVERAGEdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );if ( diffuseColor.a == 0.0 ) discard;#elseif ( diffuseColor.a < alphaTest ) discard;#endif-#endif`,$N=`#ifdef USE_ALPHATEST+#endif`,AP=`#ifdef USE_ALPHATESTuniform float alphaTest;-#endif`,KN=`#ifdef USE_AOMAP+#endif`,wP=`#ifdef USE_AOMAPfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;reflectedLight.indirectDiffuse *= ambientOcclusion;#if defined( USE_CLEARCOAT )@@ -376,10 +380,10 @@ Program Info Log: `+U+`float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );#endif-#endif`,WN=`#ifdef USE_AOMAP+#endif`,SP=`#ifdef USE_AOMAPuniform sampler2D aoMap;uniform float aoMapIntensity;-#endif`,XN=`#ifdef USE_BATCHING+#endif`,MP=`#ifdef USE_BATCHING#if ! defined( GL_ANGLE_multi_draw )#define gl_DrawID _gl_DrawIDuniform int _gl_DrawID;@@ -413,15 +417,15 @@ Program Info Log: `+U+`int y = j / size;return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );}-#endif`,qN=`#ifdef USE_BATCHING+#endif`,RP=`#ifdef USE_BATCHINGmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );-#endif`,JN=`vec3 transformed = vec3( position );+#endif`,IP=`vec3 transformed = vec3( position );#ifdef USE_ALPHAHASHvPosition = vec3( position );-#endif`,ZN=`vec3 objectNormal = vec3( normal );+#endif`,CP=`vec3 objectNormal = vec3( normal );#ifdef USE_TANGENTvec3 objectTangent = vec3( tangent.xyz );-#endif`,YN=`float G_BlinnPhong_Implicit( ) {+#endif`,NP=`float G_BlinnPhong_Implicit( ) {return 0.25;}float D_BlinnPhong( const in float shininess, const in float dotNH ) {@@ -435,7 +439,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vefloat G = G_BlinnPhong_Implicit( );float D = D_BlinnPhong( shininess, dotNH );return F * ( G * D );-} // validated`,QN=`#ifdef USE_IRIDESCENCE+} // validated`,PP=`#ifdef USE_IRIDESCENCEconst mat3 XYZ_TO_REC709 = mat3(3.2404542, -0.9692660, 0.0556434,-1.5371385, 1.8760108, -0.2040259,@@ -498,7 +502,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve}return max( I, vec3( 0.0 ) );}-#endif`,eP=`#ifdef USE_BUMPMAP+#endif`,OP=`#ifdef USE_BUMPMAPuniform sampler2D bumpMap;uniform float bumpScale;vec2 dHdxy_fwd() {@@ -519,7 +523,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vevec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );return normalize( abs( fDet ) * surf_norm - vGrad );}-#endif`,tP=`#if NUM_CLIPPING_PLANES > 0+#endif`,kP=`#if NUM_CLIPPING_PLANES > 0vec4 plane;#ifdef ALPHA_TO_COVERAGEfloat distanceToPlane, distanceGradient;@@ -565,20 +569,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in veif ( clipped ) discard;#endif#endif-#endif`,nP=`#if NUM_CLIPPING_PLANES > 0+#endif`,DP=`#if NUM_CLIPPING_PLANES > 0varying vec3 vClipPosition;uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];-#endif`,iP=`#if NUM_CLIPPING_PLANES > 0+#endif`,LP=`#if NUM_CLIPPING_PLANES > 0varying vec3 vClipPosition;-#endif`,rP=`#if NUM_CLIPPING_PLANES > 0+#endif`,FP=`#if NUM_CLIPPING_PLANES > 0vClipPosition = - mvPosition.xyz;-#endif`,sP=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )+#endif`,UP=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )diffuseColor *= vColor;-#endif`,aP=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )+#endif`,BP=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )varying vec4 vColor;-#endif`,oP=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )+#endif`,zP=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )varying vec4 vColor;-#endif`,cP=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )+#endif`,VP=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )vColor = vec4( 1.0 );#endif#ifdef USE_COLOR_ALPHA@@ -591,7 +595,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve#endif#ifdef USE_BATCHING_COLORvColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );-#endif`,lP=`#define PI 3.141592653589793+#endif`,jP=`#define PI 3.141592653589793#define PI2 6.283185307179586#define PI_HALF 1.5707963267948966#define RECIPROCAL_PI 0.3183098861837907@@ -662,7 +666,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {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`,uP=`#ifdef ENVMAP_TYPE_CUBE_UV+} // validated`,HP=`#ifdef ENVMAP_TYPE_CUBE_UV#define cubeUV_minMipLevel 4.0#define cubeUV_minTileSize 16.0float getFace( vec3 direction ) {@@ -755,7 +759,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {return vec4( mix( color0, color1, mipF ), 1.0 );}}-#endif`,dP=`vec3 transformedNormal = objectNormal;+#endif`,GP=`vec3 transformedNormal = objectNormal;#ifdef USE_TANGENTvec3 transformedTangent = objectTangent;#endif@@ -781,21 +785,21 @@ transformedNormal = normalMatrix * transformedNormal;#endif#ifdef USE_TANGENTtransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;-#endif`,fP=`#ifdef USE_DISPLACEMENTMAP+#endif`,$P=`#ifdef USE_DISPLACEMENTMAPuniform sampler2D displacementMap;uniform float displacementScale;uniform float displacementBias;-#endif`,hP=`#ifdef USE_DISPLACEMENTMAP+#endif`,KP=`#ifdef USE_DISPLACEMENTMAPtransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );-#endif`,pP=`#ifdef USE_EMISSIVEMAP+#endif`,WP=`#ifdef USE_EMISSIVEMAPvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );#ifdef DECODE_VIDEO_TEXTURE_EMISSIVEemissiveColor = sRGBTransferEOTF( emissiveColor );#endiftotalEmissiveRadiance *= emissiveColor.rgb;-#endif`,mP=`#ifdef USE_EMISSIVEMAP+#endif`,XP=`#ifdef USE_EMISSIVEMAPuniform sampler2D emissiveMap;-#endif`,gP="gl_FragColor = linearToOutputTexel( gl_FragColor );",bP=`vec4 LinearTransferOETF( in vec4 value ) {+#endif`,qP="gl_FragColor = linearToOutputTexel( gl_FragColor );",JP=`vec4 LinearTransferOETF( in vec4 value ) {return value;}vec4 sRGBTransferEOTF( in vec4 value ) {@@ -803,7 +807,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {}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 );-}`,yP=`#ifdef USE_ENVMAP+}`,ZP=`#ifdef USE_ENVMAP#ifdef ENV_WORLDPOSvec3 cameraToFrag;if ( isOrthographic ) {@@ -830,7 +834,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {outgoingLight += envColor.xyz * specularStrength * reflectivity;#endif#endif-#endif`,xP=`#ifdef USE_ENVMAP+#endif`,YP=`#ifdef USE_ENVMAPuniform float envMapIntensity;uniform mat3 envMapRotation;#ifdef ENVMAP_TYPE_CUBE@@ -838,7 +842,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {#elseuniform sampler2D envMap;#endif-#endif`,_P=`#ifdef USE_ENVMAP+#endif`,QP=`#ifdef USE_ENVMAPuniform float reflectivity;#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )#define ENV_WORLDPOS@@ -849,7 +853,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {#elsevarying vec3 vReflect;#endif-#endif`,vP=`#ifdef USE_ENVMAP+#endif`,eO=`#ifdef USE_ENVMAP#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )#define ENV_WORLDPOS#endif@@ -860,7 +864,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {varying vec3 vReflect;uniform float refractionRatio;#endif-#endif`,EP=`#ifdef USE_ENVMAP+#endif`,tO=`#ifdef USE_ENVMAP#ifdef ENV_WORLDPOSvWorldPosition = worldPosition.xyz;#else@@ -877,18 +881,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {vReflect = refract( cameraToVertex, worldNormal, refractionRatio );#endif#endif-#endif`,TP=`#ifdef USE_FOG+#endif`,nO=`#ifdef USE_FOGvFogDepth = - mvPosition.z;-#endif`,AP=`#ifdef USE_FOG+#endif`,iO=`#ifdef USE_FOGvarying float vFogDepth;-#endif`,SP=`#ifdef USE_FOG+#endif`,rO=`#ifdef USE_FOG#ifdef FOG_EXP2float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );#elsefloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );#endifgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );-#endif`,wP=`#ifdef USE_FOG+#endif`,sO=`#ifdef USE_FOGuniform vec3 fogColor;varying float vFogDepth;#ifdef FOG_EXP2@@ -897,7 +901,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {uniform float fogNear;uniform float fogFar;#endif-#endif`,MP=`#ifdef USE_GRADIENTMAP+#endif`,aO=`#ifdef USE_GRADIENTMAPuniform sampler2D gradientMap;#endifvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {@@ -909,12 +913,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {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-}`,RP=`#ifdef USE_LIGHTMAP+}`,oO=`#ifdef USE_LIGHTMAPuniform sampler2D lightMap;uniform float lightMapIntensity;-#endif`,IP=`LambertMaterial material;+#endif`,cO=`LambertMaterial material;material.diffuseColor = diffuseColor.rgb;-material.specularStrength = specularStrength;`,CP=`varying vec3 vViewPosition;+material.specularStrength = specularStrength;`,lO=`varying vec3 vViewPosition;struct LambertMaterial {vec3 diffuseColor;float specularStrength;@@ -928,7 +932,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometrreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );}#define RE_Direct RE_Direct_Lambert-#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,NP=`uniform bool receiveShadow;+#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,uO=`uniform bool receiveShadow;uniform vec3 ambientLightColor;#if defined( USE_LIGHT_PROBES )uniform vec3 lightProbe[ 9 ];@@ -1057,7 +1061,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosireturn irradiance;}#endif-#include <lightprobes_pars_fragment>`,PP=`#ifdef USE_ENVMAP+#include <lightprobes_pars_fragment>`,dO=`#ifdef USE_ENVMAPvec3 getIBLIrradiance( const in vec3 normal ) {#ifdef ENVMAP_TYPE_CUBE_UVvec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );@@ -1114,8 +1118,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi}#endif#endif-#endif`,OP=`ToonMaterial material;-material.diffuseColor = diffuseColor.rgb;`,kP=`varying vec3 vViewPosition;+#endif`,fO=`ToonMaterial material;+material.diffuseColor = diffuseColor.rgb;`,hO=`varying vec3 vViewPosition;struct ToonMaterial {vec3 diffuseColor;};@@ -1127,11 +1131,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPoreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );}#define RE_Direct RE_Direct_Toon-#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,DP=`BlinnPhongMaterial material;+#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,pO=`BlinnPhongMaterial material;material.diffuseColor = diffuseColor.rgb;material.specularColor = specular;material.specularShininess = shininess;-material.specularStrength = specularStrength;`,LP=`varying vec3 vViewPosition;+material.specularStrength = specularStrength;`,mO=`varying vec3 vViewPosition;struct BlinnPhongMaterial {vec3 diffuseColor;vec3 specularColor;@@ -1148,7 +1152,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geomreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );}#define RE_Direct RE_Direct_BlinnPhong-#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,FP=`PhysicalMaterial material;+#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,gO=`PhysicalMaterial material;material.diffuseColor = diffuseColor.rgb;material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );material.metalness = metalnessFactor;@@ -1241,7 +1245,7 @@ material.roughness = min( material.roughness, 1.0 );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`,UP=`uniform sampler2D dfgLUT;+#endif`,bO=`uniform sampler2D dfgLUT;struct PhysicalMaterial {vec3 diffuseColor;vec3 diffuseContribution;@@ -1608,7 +1612,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia#define RE_IndirectSpecular RE_IndirectSpecular_Physicalfloat 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 );-}`,BP=`+}`,xO=`vec3 geometryPosition = - vViewPosition;vec3 geometryNormal = normal;vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );@@ -1756,7 +1760,7 @@ IncidentLight directLight;#if defined( RE_IndirectSpecular )vec3 radiance = vec3( 0.0 );vec3 clearcoatRadiance = vec3( 0.0 );-#endif`,zP=`#if defined( RE_IndirectDiffuse )+#endif`,yO=`#if defined( RE_IndirectDiffuse )#ifdef USE_LIGHTMAPvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;@@ -1786,7 +1790,7 @@ IncidentLight directLight;#ifdef USE_CLEARCOATclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );#endif-#endif`,VP=`#if defined( RE_IndirectDiffuse )+#endif`,_O=`#if defined( RE_IndirectDiffuse )#if defined( LAMBERT ) || defined( PHONG )irradiance += iblIrradiance;#endif@@ -1794,7 +1798,7 @@ IncidentLight directLight;#endif#if defined( RE_IndirectSpecular )RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );-#endif`,jP=`#ifdef USE_LIGHT_PROBES_GRID+#endif`,vO=`#ifdef USE_LIGHT_PROBES_GRIDuniform highp sampler3D probesSH;uniform vec3 probesMin;uniform vec3 probesMax;@@ -1839,27 +1843,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {result += c8 * 0.429043 * ( x * x - y * y );return max( result, vec3( 0.0 ) );}-#endif`,HP=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )+#endif`,EO=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;-#endif`,GP=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )+#endif`,TO=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )uniform float logDepthBufFC;varying float vFragDepth;varying float vIsPerspective;-#endif`,$P=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER+#endif`,AO=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFERvarying float vFragDepth;varying float vIsPerspective;-#endif`,KP=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER+#endif`,wO=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFERvFragDepth = 1.0 + gl_Position.w;vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );-#endif`,WP=`#ifdef USE_MAP+#endif`,SO=`#ifdef USE_MAPvec4 sampledDiffuseColor = texture2D( map, vMapUv );#ifdef DECODE_VIDEO_TEXTUREsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );#endifdiffuseColor *= sampledDiffuseColor;-#endif`,XP=`#ifdef USE_MAP+#endif`,MO=`#ifdef USE_MAPuniform sampler2D map;-#endif`,qP=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )+#endif`,RO=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )#if defined( USE_POINTS_UV )vec2 uv = vUv;#else@@ -1871,7 +1875,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {#endif#ifdef USE_ALPHAMAPdiffuseColor.a *= texture2D( alphaMap, uv ).g;-#endif`,JP=`#if defined( USE_POINTS_UV )+#endif`,IO=`#if defined( USE_POINTS_UV )varying vec2 vUv;#else#if defined( USE_MAP ) || defined( USE_ALPHAMAP )@@ -1883,19 +1887,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {#endif#ifdef USE_ALPHAMAPuniform sampler2D alphaMap;-#endif`,ZP=`float metalnessFactor = metalness;+#endif`,CO=`float metalnessFactor = metalness;#ifdef USE_METALNESSMAPvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );metalnessFactor *= texelMetalness.b;-#endif`,YP=`#ifdef USE_METALNESSMAP+#endif`,NO=`#ifdef USE_METALNESSMAPuniform sampler2D metalnessMap;-#endif`,QP=`#ifdef USE_INSTANCING_MORPH+#endif`,PO=`#ifdef USE_INSTANCING_MORPHfloat 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`,eO=`#if defined( USE_MORPHCOLORS )+#endif`,OO=`#if defined( USE_MORPHCOLORS )vColor *= morphTargetBaseInfluence;for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {#if defined( USE_COLOR_ALPHA )@@ -1904,12 +1908,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];#endif}-#endif`,tO=`#ifdef USE_MORPHNORMALS+#endif`,kO=`#ifdef USE_MORPHNORMALSobjectNormal *= morphTargetBaseInfluence;for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];}-#endif`,nO=`#ifdef USE_MORPHTARGETS+#endif`,DO=`#ifdef USE_MORPHTARGETS#ifndef USE_INSTANCING_MORPHuniform float morphTargetBaseInfluence;uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];@@ -1923,12 +1927,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {ivec3 morphUV = ivec3( x, y, morphTargetIndex );return texelFetch( morphTargetsTexture, morphUV, 0 );}-#endif`,iO=`#ifdef USE_MORPHTARGETS+#endif`,LO=`#ifdef USE_MORPHTARGETStransformed *= morphTargetBaseInfluence;for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];}-#endif`,rO=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;+#endif`,FO=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;#ifdef FLAT_SHADEDvec3 fdx = dFdx( vViewPosition );vec3 fdy = dFdy( vViewPosition );@@ -1969,7 +1973,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {tbn2[1] *= faceDirection;#endif#endif-vec3 nonPerturbedNormal = normal;`,sO=`#ifdef USE_NORMALMAP_OBJECTSPACE+vec3 nonPerturbedNormal = normal;`,UO=`#ifdef USE_NORMALMAP_OBJECTSPACEnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;#ifdef FLIP_SIDEDnormal = - normal;@@ -1987,19 +1991,19 @@ vec3 nonPerturbedNormal = normal;`,sO=`#ifdef USE_NORMALMAP_OBJECTSPACEnormal = normalize( tbn * mapN );#elif defined( USE_BUMPMAP )normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );-#endif`,aO=`#ifndef FLAT_SHADED+#endif`,BO=`#ifndef FLAT_SHADEDvarying vec3 vNormal;#ifdef USE_TANGENTvarying vec3 vTangent;varying vec3 vBitangent;#endif-#endif`,oO=`#ifndef FLAT_SHADED+#endif`,zO=`#ifndef FLAT_SHADEDvarying vec3 vNormal;#ifdef USE_TANGENTvarying vec3 vTangent;varying vec3 vBitangent;#endif-#endif`,cO=`#ifndef FLAT_SHADED+#endif`,VO=`#ifndef FLAT_SHADEDvNormal = normalize( transformedNormal );#ifdef USE_TANGENTvTangent = normalize( transformedTangent );@@ -2008,7 +2012,7 @@ vec3 nonPerturbedNormal = normal;`,sO=`#ifdef USE_NORMALMAP_OBJECTSPACEvBitangent = - vBitangent;#endif#endif-#endif`,lO=`#ifdef USE_NORMALMAP+#endif`,jO=`#ifdef USE_NORMALMAPuniform sampler2D normalMap;uniform vec2 normalScale;#endif@@ -2030,13 +2034,13 @@ vec3 nonPerturbedNormal = normal;`,sO=`#ifdef USE_NORMALMAP_OBJECTSPACEfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );return mat3( T * scale, B * scale, N );}-#endif`,uO=`#ifdef USE_CLEARCOAT+#endif`,HO=`#ifdef USE_CLEARCOATvec3 clearcoatNormal = nonPerturbedNormal;-#endif`,dO=`#ifdef USE_CLEARCOAT_NORMALMAP+#endif`,GO=`#ifdef USE_CLEARCOAT_NORMALMAPvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;clearcoatMapN.xy *= clearcoatNormalScale;clearcoatNormal = normalize( tbn2 * clearcoatMapN );-#endif`,fO=`#ifdef USE_CLEARCOATMAP+#endif`,$O=`#ifdef USE_CLEARCOATMAPuniform sampler2D clearcoatMap;#endif#ifdef USE_CLEARCOAT_NORMALMAP@@ -2045,18 +2049,18 @@ vec3 nonPerturbedNormal = normal;`,sO=`#ifdef USE_NORMALMAP_OBJECTSPACE#endif#ifdef USE_CLEARCOAT_ROUGHNESSMAPuniform sampler2D clearcoatRoughnessMap;-#endif`,hO=`#ifdef USE_IRIDESCENCEMAP+#endif`,KO=`#ifdef USE_IRIDESCENCEMAPuniform sampler2D iridescenceMap;#endif#ifdef USE_IRIDESCENCE_THICKNESSMAPuniform sampler2D iridescenceThicknessMap;-#endif`,pO=`#ifdef OPAQUE+#endif`,WO=`#ifdef OPAQUEdiffuseColor.a = 1.0;#endif#ifdef USE_TRANSMISSIONdiffuseColor.a *= material.transmissionAlpha;#endif-gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,mO=`vec3 packNormalToRGB( const in vec3 normal ) {+gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,XO=`vec3 packNormalToRGB( const in vec3 normal ) {return normalize( normal ) * 0.5 + 0.5;}vec3 unpackRGBToNormal( const in vec3 rgb ) {@@ -2135,9 +2139,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const#elsereturn ( near * far ) / ( ( far - near ) * depth - far );#endif-}`,gO=`#ifdef PREMULTIPLIED_ALPHA+}`,qO=`#ifdef PREMULTIPLIED_ALPHAgl_FragColor.rgb *= gl_FragColor.a;-#endif`,bO=`vec4 mvPosition = vec4( transformed, 1.0 );+#endif`,JO=`vec4 mvPosition = vec4( transformed, 1.0 );#ifdef USE_BATCHINGmvPosition = batchingMatrix * mvPosition;#endif@@ -2145,22 +2149,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, constmvPosition = instanceMatrix * mvPosition;#endifmvPosition = modelViewMatrix * mvPosition;-gl_Position = projectionMatrix * mvPosition;`,yO=`#ifdef DITHERING+gl_Position = projectionMatrix * mvPosition;`,ZO=`#ifdef DITHERINGgl_FragColor.rgb = dithering( gl_FragColor.rgb );-#endif`,xO=`#ifdef DITHERING+#endif`,YO=`#ifdef DITHERINGvec3 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`,_O=`float roughnessFactor = roughness;+#endif`,QO=`float roughnessFactor = roughness;#ifdef USE_ROUGHNESSMAPvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );roughnessFactor *= texelRoughness.g;-#endif`,vO=`#ifdef USE_ROUGHNESSMAP+#endif`,ek=`#ifdef USE_ROUGHNESSMAPuniform sampler2D roughnessMap;-#endif`,EO=`#if NUM_SPOT_LIGHT_COORDS > 0+#endif`,tk=`#if NUM_SPOT_LIGHT_COORDS > 0varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];#endif#if NUM_SPOT_LIGHT_MAPS > 0@@ -2411,7 +2415,7 @@ gl_Position = projectionMatrix * mvPosition;`,yO=`#ifdef DITHERING}#endif#endif-#endif`,TO=`#if NUM_SPOT_LIGHT_COORDS > 0+#endif`,nk=`#if NUM_SPOT_LIGHT_COORDS > 0uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];#endif@@ -2456,7 +2460,7 @@ gl_Position = projectionMatrix * mvPosition;`,yO=`#ifdef DITHERING};uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];#endif-#endif`,AO=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )+#endif`,ik=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )#ifdef HAS_NORMALvec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );#else@@ -2496,7 +2500,7 @@ gl_Position = projectionMatrix * mvPosition;`,yO=`#ifdef DITHERINGvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;}#pragma unroll_loop_end-#endif`,SO=`float getShadowMask() {+#endif`,rk=`float getShadowMask() {float shadow = 1.0;#ifdef USE_SHADOWMAP#if NUM_SUN_LIGHT_SHADOWS > 0@@ -2537,12 +2541,12 @@ gl_Position = projectionMatrix * mvPosition;`,yO=`#ifdef DITHERING#endif#endifreturn shadow;-}`,wO=`#ifdef USE_SKINNING+}`,sk=`#ifdef USE_SKINNINGmat4 boneMatX = getBoneMatrix( skinIndex.x );mat4 boneMatY = getBoneMatrix( skinIndex.y );mat4 boneMatZ = getBoneMatrix( skinIndex.z );mat4 boneMatW = getBoneMatrix( skinIndex.w );-#endif`,MO=`#ifdef USE_SKINNING+#endif`,ak=`#ifdef USE_SKINNINGuniform mat4 bindMatrix;uniform mat4 bindMatrixInverse;uniform highp sampler2D boneTexture;@@ -2557,7 +2561,7 @@ gl_Position = projectionMatrix * mvPosition;`,yO=`#ifdef DITHERINGvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );return mat4( v1, v2, v3, v4 );}-#endif`,RO=`#ifdef USE_SKINNING+#endif`,ok=`#ifdef USE_SKINNINGvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );vec4 skinned = vec4( 0.0 );skinned += boneMatX * skinVertex * skinWeight.x;@@ -2565,7 +2569,7 @@ gl_Position = projectionMatrix * mvPosition;`,yO=`#ifdef DITHERINGskinned += boneMatZ * skinVertex * skinWeight.z;skinned += boneMatW * skinVertex * skinWeight.w;transformed = ( bindMatrixInverse * skinned ).xyz;-#endif`,IO=`#ifdef USE_SKINNING+#endif`,ck=`#ifdef USE_SKINNINGmat4 skinMatrix = mat4( 0.0 );skinMatrix += skinWeight.x * boneMatX;skinMatrix += skinWeight.y * boneMatY;@@ -2576,17 +2580,17 @@ gl_Position = projectionMatrix * mvPosition;`,yO=`#ifdef DITHERING#ifdef USE_TANGENTobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;#endif-#endif`,CO=`float specularStrength;+#endif`,lk=`float specularStrength;#ifdef USE_SPECULARMAPvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );specularStrength = texelSpecular.r;#elsespecularStrength = 1.0;-#endif`,NO=`#ifdef USE_SPECULARMAP+#endif`,uk=`#ifdef USE_SPECULARMAPuniform sampler2D specularMap;-#endif`,PO=`#if defined( TONE_MAPPING )+#endif`,dk=`#if defined( TONE_MAPPING )gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );-#endif`,OO=`#ifndef saturate+#endif`,fk=`#ifndef saturate#define saturate( a ) clamp( a, 0.0, 1.0 )#endifuniform float toneMappingExposure;@@ -2683,7 +2687,7 @@ vec3 NeutralToneMapping( vec3 color ) {float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );return mix( color, vec3( newPeak ), g );}-vec3 CustomToneMapping( vec3 color ) { return color; }`,kO=`#ifdef USE_TRANSMISSION+vec3 CustomToneMapping( vec3 color ) { return color; }`,hk=`#ifdef USE_TRANSMISSIONmaterial.transmission = transmission;material.transmissionAlpha = 1.0;material.thickness = thickness;@@ -2704,7 +2708,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,kO=`#ifdef USE_TRANSMISSmaterial.attenuationColor, material.attenuationDistance );material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );-#endif`,DO=`#ifdef USE_TRANSMISSION+#endif`,pk=`#ifdef USE_TRANSMISSIONuniform float transmission;uniform float thickness;uniform float attenuationDistance;@@ -2830,7 +2834,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,kO=`#ifdef USE_TRANSMISSfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );}-#endif`,LO=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )+#endif`,mk=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )varying vec2 vUv;#endif#ifdef USE_MAP@@ -2900,7 +2904,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,kO=`#ifdef USE_TRANSMISS#ifdef USE_THICKNESSMAPuniform mat3 thicknessMapTransform;varying vec2 vThicknessMapUv;-#endif`,FO=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )+#endif`,gk=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )varying vec2 vUv;#endif#ifdef USE_MAP@@ -2994,7 +2998,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,kO=`#ifdef USE_TRANSMISS#ifdef USE_THICKNESSMAPuniform mat3 thicknessMapTransform;varying vec2 vThicknessMapUv;-#endif`,UO=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )+#endif`,bk=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )vUv = vec3( uv, 1 ).xy;#endif#ifdef USE_MAP@@ -3065,7 +3069,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,kO=`#ifdef USE_TRANSMISS#endif#ifdef USE_THICKNESSMAPvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;-#endif`,BO=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0+#endif`,xk=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0vec4 worldPosition = vec4( transformed, 1.0 );#ifdef USE_BATCHINGworldPosition = batchingMatrix * worldPosition;@@ -3074,12 +3078,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,kO=`#ifdef USE_TRANSMISSworldPosition = instanceMatrix * worldPosition;#endifworldPosition = modelMatrix * worldPosition;-#endif`,zO=`varying vec2 vUv;+#endif`,yk=`varying vec2 vUv;uniform mat3 uvTransform;void main() {vUv = ( uvTransform * vec3( uv, 1 ) ).xy;gl_Position = vec4( position.xy, 1.0, 1.0 );-}`,VO=`uniform sampler2D t2D;+}`,_k=`uniform sampler2D t2D;uniform float backgroundIntensity;varying vec2 vUv;void main() {@@ -3091,14 +3095,14 @@ void main() {gl_FragColor = texColor;#include <tonemapping_fragment>#include <colorspace_fragment>-}`,jO=`varying vec3 vWorldDirection;+}`,vk=`varying vec3 vWorldDirection;#include <common>void main() {vWorldDirection = transformDirection( position, modelMatrix );#include <begin_vertex>#include <project_vertex>gl_Position.z = gl_Position.w;-}`,HO=`#ifdef ENVMAP_TYPE_CUBE+}`,Ek=`#ifdef ENVMAP_TYPE_CUBEuniform samplerCube envMap;#elif defined( ENVMAP_TYPE_CUBE_UV )uniform sampler2D envMap;@@ -3120,14 +3124,14 @@ void main() {gl_FragColor = texColor;#include <tonemapping_fragment>#include <colorspace_fragment>-}`,GO=`varying vec3 vWorldDirection;+}`,Tk=`varying vec3 vWorldDirection;#include <common>void main() {vWorldDirection = transformDirection( position, modelMatrix );#include <begin_vertex>#include <project_vertex>gl_Position.z = gl_Position.w;-}`,$O=`uniform samplerCube tCube;+}`,Ak=`uniform samplerCube tCube;uniform float tFlip;uniform float opacity;varying vec3 vWorldDirection;@@ -3137,7 +3141,7 @@ void main() {gl_FragColor.a *= opacity;#include <tonemapping_fragment>#include <colorspace_fragment>-}`,KO=`#include <common>+}`,wk=`#include <common>#include <batching_pars_vertex>#include <uv_pars_vertex>#include <displacementmap_pars_vertex>@@ -3164,7 +3168,7 @@ void main() {#include <logdepthbuf_vertex>#include <clipping_planes_vertex>vHighPrecisionZW = gl_Position.zw;-}`,WO=`#if DEPTH_PACKING == 3200+}`,Sk=`#if DEPTH_PACKING == 3200uniform float opacity;#endif#include <common>@@ -3202,7 +3206,7 @@ void main() {#elif DEPTH_PACKING == 3203gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );#endif-}`,XO=`#define DISTANCE+}`,Mk=`#define DISTANCEvarying vec3 vWorldPosition;#include <common>#include <batching_pars_vertex>@@ -3229,7 +3233,7 @@ void main() {#include <worldpos_vertex>#include <clipping_planes_vertex>vWorldPosition = worldPosition.xyz;-}`,qO=`#define DISTANCE+}`,Rk=`#define DISTANCEuniform vec3 referencePosition;uniform float nearDistance;uniform float farDistance;@@ -3252,13 +3256,13 @@ void main() {dist = ( dist - nearDistance ) / ( farDistance - nearDistance );dist = saturate( dist );gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );-}`,JO=`varying vec3 vWorldDirection;+}`,Ik=`varying vec3 vWorldDirection;#include <common>void main() {vWorldDirection = transformDirection( position, modelMatrix );#include <begin_vertex>#include <project_vertex>-}`,ZO=`uniform sampler2D tEquirect;+}`,Ck=`uniform sampler2D tEquirect;varying vec3 vWorldDirection;#include <common>void main() {@@ -3267,7 +3271,7 @@ void main() {gl_FragColor = texture2D( tEquirect, sampleUV );#include <tonemapping_fragment>#include <colorspace_fragment>-}`,YO=`uniform float scale;+}`,Nk=`uniform float scale;attribute float lineDistance;varying float vLineDistance;#include <common>@@ -3289,7 +3293,7 @@ void main() {#include <logdepthbuf_vertex>#include <clipping_planes_vertex>#include <fog_vertex>-}`,QO=`uniform vec3 diffuse;+}`,Pk=`uniform vec3 diffuse;uniform float opacity;uniform float dashSize;uniform float totalSize;@@ -3317,7 +3321,7 @@ void main() {#include <colorspace_fragment>#include <fog_fragment>#include <premultiplied_alpha_fragment>-}`,ek=`#include <common>+}`,Ok=`#include <common>#include <batching_pars_vertex>#include <uv_pars_vertex>#include <envmap_pars_vertex>@@ -3349,7 +3353,7 @@ void main() {#include <worldpos_vertex>#include <envmap_vertex>#include <fog_vertex>-}`,tk=`uniform vec3 diffuse;+}`,kk=`uniform vec3 diffuse;uniform float opacity;#ifndef FLAT_SHADEDvarying vec3 vNormal;@@ -3397,7 +3401,7 @@ void main() {#include <fog_fragment>#include <premultiplied_alpha_fragment>#include <dithering_fragment>-}`,nk=`#define LAMBERT+}`,Dk=`#define LAMBERTvarying vec3 vViewPosition;#include <common>#include <batching_pars_vertex>@@ -3436,7 +3440,7 @@ void main() {#include <envmap_vertex>#include <shadowmap_vertex>#include <fog_vertex>-}`,ik=`#define LAMBERT+}`,Lk=`#define LAMBERTuniform vec3 diffuse;uniform vec3 emissive;uniform float opacity;@@ -3494,7 +3498,7 @@ void main() {#include <fog_fragment>#include <premultiplied_alpha_fragment>#include <dithering_fragment>-}`,rk=`#define MATCAP+}`,Fk=`#define MATCAPvarying vec3 vViewPosition;#include <common>#include <batching_pars_vertex>@@ -3528,7 +3532,7 @@ void main() {#include <clipping_planes_vertex>#include <fog_vertex>vViewPosition = - mvPosition.xyz;-}`,sk=`#define MATCAP+}`,Uk=`#define MATCAPuniform vec3 diffuse;uniform float opacity;uniform sampler2D matcap;@@ -3574,7 +3578,7 @@ void main() {#include <fog_fragment>#include <premultiplied_alpha_fragment>#include <dithering_fragment>-}`,ak=`#define NORMAL+}`,Bk=`#define NORMAL#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )varying vec3 vViewPosition;#endif@@ -3607,7 +3611,7 @@ void main() {#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )vViewPosition = - mvPosition.xyz;#endif-}`,ok=`#define NORMAL+}`,zk=`#define NORMALuniform float opacity;#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )varying vec3 vViewPosition;@@ -3628,7 +3632,7 @@ void main() {#ifdef OPAQUEgl_FragColor.a = 1.0;#endif-}`,ck=`#define PHONG+}`,Vk=`#define PHONGvarying vec3 vViewPosition;#include <common>#include <batching_pars_vertex>@@ -3667,7 +3671,7 @@ void main() {#include <envmap_vertex>#include <shadowmap_vertex>#include <fog_vertex>-}`,lk=`#define PHONG+}`,jk=`#define PHONGuniform vec3 diffuse;uniform vec3 emissive;uniform vec3 specular;@@ -3727,7 +3731,7 @@ void main() {#include <fog_fragment>#include <premultiplied_alpha_fragment>#include <dithering_fragment>-}`,uk=`#define STANDARD+}`,Hk=`#define STANDARDvarying vec3 vViewPosition;#ifdef USE_TRANSMISSIONvarying vec3 vWorldPosition;@@ -3770,7 +3774,7 @@ void main() {#ifdef USE_TRANSMISSIONvWorldPosition = worldPosition.xyz;#endif-}`,dk=`#define STANDARD+}`,Gk=`#define STANDARD#ifdef PHYSICAL#define IOR#define USE_SPECULAR@@ -3898,7 +3902,7 @@ void main() {#include <fog_fragment>#include <premultiplied_alpha_fragment>#include <dithering_fragment>-}`,fk=`#define TOON+}`,$k=`#define TOONvarying vec3 vViewPosition;#include <common>#include <batching_pars_vertex>@@ -3935,7 +3939,7 @@ void main() {#include <worldpos_vertex>#include <shadowmap_vertex>#include <fog_vertex>-}`,hk=`#define TOON+}`,Kk=`#define TOONuniform vec3 diffuse;uniform vec3 emissive;uniform float opacity;@@ -3987,7 +3991,7 @@ void main() {#include <fog_fragment>#include <premultiplied_alpha_fragment>#include <dithering_fragment>-}`,pk=`uniform float size;+}`,Wk=`uniform float size;uniform float scale;#include <common>#include <color_pars_vertex>@@ -4018,7 +4022,7 @@ void main() {#include <clipping_planes_vertex>#include <worldpos_vertex>#include <fog_vertex>-}`,mk=`uniform vec3 diffuse;+}`,Xk=`uniform vec3 diffuse;uniform float opacity;#include <common>#include <color_pars_fragment>@@ -4043,7 +4047,7 @@ void main() {#include <colorspace_fragment>#include <fog_fragment>#include <premultiplied_alpha_fragment>-}`,gk=`#include <common>+}`,qk=`#include <common>#include <batching_pars_vertex>#include <fog_pars_vertex>#include <morphtarget_pars_vertex>@@ -4066,7 +4070,7 @@ void main() {#include <worldpos_vertex>#include <shadowmap_vertex>#include <fog_vertex>-}`,bk=`uniform vec3 color;+}`,Jk=`uniform vec3 color;uniform float opacity;#include <common>#include <fog_pars_fragment>@@ -4082,7 +4086,7 @@ void main() {#include <colorspace_fragment>#include <fog_fragment>#include <premultiplied_alpha_fragment>-}`,yk=`uniform float rotation;+}`,Zk=`uniform float rotation;uniform vec2 center;#include <common>#include <uv_pars_vertex>@@ -4106,7 +4110,7 @@ void main() {#include <logdepthbuf_vertex>#include <clipping_planes_vertex>#include <fog_vertex>-}`,xk=`uniform vec3 diffuse;+}`,Yk=`uniform vec3 diffuse;uniform float opacity;#include <common>#include <uv_pars_fragment>@@ -4131,9 +4135,9 @@ void main() {#include <tonemapping_fragment>#include <colorspace_fragment>#include <fog_fragment>-}`,st,Te,mr,Ad,_k,iA,Oo=4,wk=6,Mk=20,Rk=256,tl,DT,Fm=null,Um=0,Bm=0,zm=!1,Ik,Aa,$m,zk,rA,Hm,sA,aA,oA,BT,zT,VT,jT,HT,Vm,ID=37297,CD=0,KT,kD,Sd,zD,VD,HD,$D,WD,qD,ZD,tL=0,lL=0,hL=`void main() {+}`,st,Te,br,Vd,Qk,EA,Vo=4,sD=6,aD=20,oD=256,hl,eA,Ym=null,Qm=0,eg=0,tg=!1,cD,Ia,ag,yD,TA,rg,AA,wA,SA,rA,sA,aA,oA,cA,ng,cL=37297,lL=0,dA,hL,jd,yL,_L,EL,AL,SL,RL,CL,kL=0,jL=0,KL=`void main() {gl_Position = vec4( position, 1.0 );-}`,pL=`uniform sampler2D shadow_pass;+}`,WL=`uniform sampler2D shadow_pass;uniform vec2 resolution;uniform float radius;void main() {@@ -4158,12 +4162,12 @@ void main() {squared_mean = squared_mean / samples;float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );-}`,mL,gL,tA,nl,jm,vL=`+}`,XL,qL,_A,pl,ig,e8=`void main() {gl_Position = vec4( position, 1.0 );-}`,EL=`+}`,t8=`uniform sampler2DArray depthColor;uniform float depthWidth;uniform float depthHeight;@@ -4182,7 +4186,7 @@ void main() {}-}`,pA,TL,mA,wL,pr=null;var zi=Ft(()=>{Lm();Lm();st={alphahash_fragment:zN,alphahash_pars_fragment:VN,alphamap_fragment:jN,alphamap_pars_fragment:HN,alphatest_fragment:GN,alphatest_pars_fragment:$N,aomap_fragment:KN,aomap_pars_fragment:WN,batching_pars_vertex:XN,batching_vertex:qN,begin_vertex:JN,beginnormal_vertex:ZN,bsdfs:YN,iridescence_fragment:QN,bumpmap_pars_fragment:eP,clipping_planes_fragment:tP,clipping_planes_pars_fragment:nP,clipping_planes_pars_vertex:iP,clipping_planes_vertex:rP,color_fragment:sP,color_pars_fragment:aP,color_pars_vertex:oP,color_vertex:cP,common:lP,cube_uv_reflection_fragment:uP,defaultnormal_vertex:dP,displacementmap_pars_vertex:fP,displacementmap_vertex:hP,emissivemap_fragment:pP,emissivemap_pars_fragment:mP,colorspace_fragment:gP,colorspace_pars_fragment:bP,envmap_fragment:yP,envmap_common_pars_fragment:xP,envmap_pars_fragment:_P,envmap_pars_vertex:vP,envmap_physical_pars_fragment:PP,envmap_vertex:EP,fog_vertex:TP,fog_pars_vertex:AP,fog_fragment:SP,fog_pars_fragment:wP,gradientmap_pars_fragment:MP,lightmap_pars_fragment:RP,lights_lambert_fragment:IP,lights_lambert_pars_fragment:CP,lights_pars_begin:NP,lights_toon_fragment:OP,lights_toon_pars_fragment:kP,lights_phong_fragment:DP,lights_phong_pars_fragment:LP,lights_physical_fragment:FP,lights_physical_pars_fragment:UP,lights_fragment_begin:BP,lights_fragment_maps:zP,lights_fragment_end:VP,lightprobes_pars_fragment:jP,logdepthbuf_fragment:HP,logdepthbuf_pars_fragment:GP,logdepthbuf_pars_vertex:$P,logdepthbuf_vertex:KP,map_fragment:WP,map_pars_fragment:XP,map_particle_fragment:qP,map_particle_pars_fragment:JP,metalnessmap_fragment:ZP,metalnessmap_pars_fragment:YP,morphinstance_vertex:QP,morphcolor_vertex:eO,morphnormal_vertex:tO,morphtarget_pars_vertex:nO,morphtarget_vertex:iO,normal_fragment_begin:rO,normal_fragment_maps:sO,normal_pars_fragment:aO,normal_pars_vertex:oO,normal_vertex:cO,normalmap_pars_fragment:lO,clearcoat_normal_fragment_begin:uO,clearcoat_normal_fragment_maps:dO,clearcoat_pars_fragment:fO,iridescence_pars_fragment:hO,opaque_fragment:pO,packing:mO,premultiplied_alpha_fragment:gO,project_vertex:bO,dithering_fragment:yO,dithering_pars_fragment:xO,roughnessmap_fragment:_O,roughnessmap_pars_fragment:vO,shadowmap_pars_fragment:EO,shadowmap_pars_vertex:TO,shadowmap_vertex:AO,shadowmask_pars_fragment:SO,skinbase_vertex:wO,skinning_pars_vertex:MO,skinning_vertex:RO,skinnormal_vertex:IO,specularmap_fragment:CO,specularmap_pars_fragment:NO,tonemapping_fragment:PO,tonemapping_pars_fragment:OO,transmission_fragment:kO,transmission_pars_fragment:DO,uv_pars_fragment:LO,uv_pars_vertex:FO,uv_vertex:UO,worldpos_vertex:BO,background_vert:zO,background_frag:VO,backgroundCube_vert:jO,backgroundCube_frag:HO,cube_vert:GO,cube_frag:$O,depth_vert:KO,depth_frag:WO,distance_vert:XO,distance_frag:qO,equirect_vert:JO,equirect_frag:ZO,linedashed_vert:YO,linedashed_frag:QO,meshbasic_vert:ek,meshbasic_frag:tk,meshlambert_vert:nk,meshlambert_frag:ik,meshmatcap_vert:rk,meshmatcap_frag:sk,meshnormal_vert:ak,meshnormal_frag:ok,meshphong_vert:ck,meshphong_frag:lk,meshphysical_vert:uk,meshphysical_frag:dk,meshtoon_vert:fk,meshtoon_frag:hk,points_vert:pk,points_frag:mk,shadow_vert:gk,shadow_frag:bk,sprite_vert:yk,sprite_frag:xk},Te={common:{diffuse:{value:new qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new tt},alphaMap:{value:null},alphaMapTransform:{value:new tt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new tt}},envmap:{envMap:{value:null},envMapRotation:{value:new tt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new tt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new tt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new tt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new tt},normalScale:{value:new Ke(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new tt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new tt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new tt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new tt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new j},probesMax:{value:new j},probesResolution:{value:new j}},points:{diffuse:{value:new qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new tt},alphaTest:{value:0},uvTransform:{value:new tt}},sprite:{diffuse:{value:new qe(16777215)},opacity:{value:1},center:{value:new Ke(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new tt},alphaMap:{value:null},alphaMapTransform:{value:new tt},alphaTest:{value:0}}},mr={basic:{uniforms:kn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.fog]),vertexShader:st.meshbasic_vert,fragmentShader:st.meshbasic_frag},lambert:{uniforms:kn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,Te.lights,{emissive:{value:new qe(0)},envMapIntensity:{value:1}}]),vertexShader:st.meshlambert_vert,fragmentShader:st.meshlambert_frag},phong:{uniforms:kn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,Te.lights,{emissive:{value:new qe(0)},specular:{value:new qe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:st.meshphong_vert,fragmentShader:st.meshphong_frag},standard:{uniforms:kn([Te.common,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.roughnessmap,Te.metalnessmap,Te.fog,Te.lights,{emissive:{value:new qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:st.meshphysical_vert,fragmentShader:st.meshphysical_frag},toon:{uniforms:kn([Te.common,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.gradientmap,Te.fog,Te.lights,{emissive:{value:new qe(0)}}]),vertexShader:st.meshtoon_vert,fragmentShader:st.meshtoon_frag},matcap:{uniforms:kn([Te.common,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,{matcap:{value:null}}]),vertexShader:st.meshmatcap_vert,fragmentShader:st.meshmatcap_frag},points:{uniforms:kn([Te.points,Te.fog]),vertexShader:st.points_vert,fragmentShader:st.points_frag},dashed:{uniforms:kn([Te.common,Te.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:st.linedashed_vert,fragmentShader:st.linedashed_frag},depth:{uniforms:kn([Te.common,Te.displacementmap]),vertexShader:st.depth_vert,fragmentShader:st.depth_frag},normal:{uniforms:kn([Te.common,Te.bumpmap,Te.normalmap,Te.displacementmap,{opacity:{value:1}}]),vertexShader:st.meshnormal_vert,fragmentShader:st.meshnormal_frag},sprite:{uniforms:kn([Te.sprite,Te.fog]),vertexShader:st.sprite_vert,fragmentShader:st.sprite_frag},background:{uniforms:{uvTransform:{value:new tt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:st.background_vert,fragmentShader:st.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new tt}},vertexShader:st.backgroundCube_vert,fragmentShader:st.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:st.cube_vert,fragmentShader:st.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:st.equirect_vert,fragmentShader:st.equirect_frag},distance:{uniforms:kn([Te.common,Te.displacementmap,{referencePosition:{value:new j},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:st.distance_vert,fragmentShader:st.distance_frag},shadow:{uniforms:kn([Te.lights,Te.fog,{color:{value:new qe(0)},opacity:{value:1}}]),vertexShader:st.shadow_vert,fragmentShader:st.shadow_frag}};mr.physical={uniforms:kn([mr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new tt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new tt},clearcoatNormalScale:{value:new Ke(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new tt},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new tt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new tt},sheen:{value:0},sheenColor:{value:new qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new tt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new tt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new tt},transmissionSamplerSize:{value:new Ke},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new tt},attenuationDistance:{value:0},attenuationColor:{value:new qe(0)},specularColor:{value:new qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new tt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new tt},anisotropyVector:{value:new Ke},anisotropyMap:{value:null},anisotropyMapTransform:{value:new tt}}]),vertexShader:st.meshphysical_vert,fragmentShader:st.meshphysical_frag};Ad={r:0,b:0,g:0},_k=new Qe,iA=new tt;iA.set(-1,0,0,0,1,0,0,0,1);tl=new Ta,DT=new qe,Ik=new j,Aa=new j;$m=class $m extends ai{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new hd(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`+}`,OA,n8,kA,s8,gr=null;var ji=mt(()=>{Zm();Zm();st={alphahash_fragment:yP,alphahash_pars_fragment:_P,alphamap_fragment:vP,alphamap_pars_fragment:EP,alphatest_fragment:TP,alphatest_pars_fragment:AP,aomap_fragment:wP,aomap_pars_fragment:SP,batching_pars_vertex:MP,batching_vertex:RP,begin_vertex:IP,beginnormal_vertex:CP,bsdfs:NP,iridescence_fragment:PP,bumpmap_pars_fragment:OP,clipping_planes_fragment:kP,clipping_planes_pars_fragment:DP,clipping_planes_pars_vertex:LP,clipping_planes_vertex:FP,color_fragment:UP,color_pars_fragment:BP,color_pars_vertex:zP,color_vertex:VP,common:jP,cube_uv_reflection_fragment:HP,defaultnormal_vertex:GP,displacementmap_pars_vertex:$P,displacementmap_vertex:KP,emissivemap_fragment:WP,emissivemap_pars_fragment:XP,colorspace_fragment:qP,colorspace_pars_fragment:JP,envmap_fragment:ZP,envmap_common_pars_fragment:YP,envmap_pars_fragment:QP,envmap_pars_vertex:eO,envmap_physical_pars_fragment:dO,envmap_vertex:tO,fog_vertex:nO,fog_pars_vertex:iO,fog_fragment:rO,fog_pars_fragment:sO,gradientmap_pars_fragment:aO,lightmap_pars_fragment:oO,lights_lambert_fragment:cO,lights_lambert_pars_fragment:lO,lights_pars_begin:uO,lights_toon_fragment:fO,lights_toon_pars_fragment:hO,lights_phong_fragment:pO,lights_phong_pars_fragment:mO,lights_physical_fragment:gO,lights_physical_pars_fragment:bO,lights_fragment_begin:xO,lights_fragment_maps:yO,lights_fragment_end:_O,lightprobes_pars_fragment:vO,logdepthbuf_fragment:EO,logdepthbuf_pars_fragment:TO,logdepthbuf_pars_vertex:AO,logdepthbuf_vertex:wO,map_fragment:SO,map_pars_fragment:MO,map_particle_fragment:RO,map_particle_pars_fragment:IO,metalnessmap_fragment:CO,metalnessmap_pars_fragment:NO,morphinstance_vertex:PO,morphcolor_vertex:OO,morphnormal_vertex:kO,morphtarget_pars_vertex:DO,morphtarget_vertex:LO,normal_fragment_begin:FO,normal_fragment_maps:UO,normal_pars_fragment:BO,normal_pars_vertex:zO,normal_vertex:VO,normalmap_pars_fragment:jO,clearcoat_normal_fragment_begin:HO,clearcoat_normal_fragment_maps:GO,clearcoat_pars_fragment:$O,iridescence_pars_fragment:KO,opaque_fragment:WO,packing:XO,premultiplied_alpha_fragment:qO,project_vertex:JO,dithering_fragment:ZO,dithering_pars_fragment:YO,roughnessmap_fragment:QO,roughnessmap_pars_fragment:ek,shadowmap_pars_fragment:tk,shadowmap_pars_vertex:nk,shadowmap_vertex:ik,shadowmask_pars_fragment:rk,skinbase_vertex:sk,skinning_pars_vertex:ak,skinning_vertex:ok,skinnormal_vertex:ck,specularmap_fragment:lk,specularmap_pars_fragment:uk,tonemapping_fragment:dk,tonemapping_pars_fragment:fk,transmission_fragment:hk,transmission_pars_fragment:pk,uv_pars_fragment:mk,uv_pars_vertex:gk,uv_vertex:bk,worldpos_vertex:xk,background_vert:yk,background_frag:_k,backgroundCube_vert:vk,backgroundCube_frag:Ek,cube_vert:Tk,cube_frag:Ak,depth_vert:wk,depth_frag:Sk,distance_vert:Mk,distance_frag:Rk,equirect_vert:Ik,equirect_frag:Ck,linedashed_vert:Nk,linedashed_frag:Pk,meshbasic_vert:Ok,meshbasic_frag:kk,meshlambert_vert:Dk,meshlambert_frag:Lk,meshmatcap_vert:Fk,meshmatcap_frag:Uk,meshnormal_vert:Bk,meshnormal_frag:zk,meshphong_vert:Vk,meshphong_frag:jk,meshphysical_vert:Hk,meshphysical_frag:Gk,meshtoon_vert:$k,meshtoon_frag:Kk,points_vert:Wk,points_frag:Xk,shadow_vert:qk,shadow_frag:Jk,sprite_vert:Zk,sprite_frag:Yk},Te={common:{diffuse:{value:new qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new tt},alphaMap:{value:null},alphaMapTransform:{value:new tt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new tt}},envmap:{envMap:{value:null},envMapRotation:{value:new tt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new tt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new tt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new tt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new tt},normalScale:{value:new Ke(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new tt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new tt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new tt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new tt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new j},probesMax:{value:new j},probesResolution:{value:new j}},points:{diffuse:{value:new qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new tt},alphaTest:{value:0},uvTransform:{value:new tt}},sprite:{diffuse:{value:new qe(16777215)},opacity:{value:1},center:{value:new Ke(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new tt},alphaMap:{value:null},alphaMapTransform:{value:new tt},alphaTest:{value:0}}},br={basic:{uniforms:Ln([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.fog]),vertexShader:st.meshbasic_vert,fragmentShader:st.meshbasic_frag},lambert:{uniforms:Ln([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,Te.lights,{emissive:{value:new qe(0)},envMapIntensity:{value:1}}]),vertexShader:st.meshlambert_vert,fragmentShader:st.meshlambert_frag},phong:{uniforms:Ln([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,Te.lights,{emissive:{value:new qe(0)},specular:{value:new qe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:st.meshphong_vert,fragmentShader:st.meshphong_frag},standard:{uniforms:Ln([Te.common,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.roughnessmap,Te.metalnessmap,Te.fog,Te.lights,{emissive:{value:new qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:st.meshphysical_vert,fragmentShader:st.meshphysical_frag},toon:{uniforms:Ln([Te.common,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.gradientmap,Te.fog,Te.lights,{emissive:{value:new qe(0)}}]),vertexShader:st.meshtoon_vert,fragmentShader:st.meshtoon_frag},matcap:{uniforms:Ln([Te.common,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,{matcap:{value:null}}]),vertexShader:st.meshmatcap_vert,fragmentShader:st.meshmatcap_frag},points:{uniforms:Ln([Te.points,Te.fog]),vertexShader:st.points_vert,fragmentShader:st.points_frag},dashed:{uniforms:Ln([Te.common,Te.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:st.linedashed_vert,fragmentShader:st.linedashed_frag},depth:{uniforms:Ln([Te.common,Te.displacementmap]),vertexShader:st.depth_vert,fragmentShader:st.depth_frag},normal:{uniforms:Ln([Te.common,Te.bumpmap,Te.normalmap,Te.displacementmap,{opacity:{value:1}}]),vertexShader:st.meshnormal_vert,fragmentShader:st.meshnormal_frag},sprite:{uniforms:Ln([Te.sprite,Te.fog]),vertexShader:st.sprite_vert,fragmentShader:st.sprite_frag},background:{uniforms:{uvTransform:{value:new tt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:st.background_vert,fragmentShader:st.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new tt}},vertexShader:st.backgroundCube_vert,fragmentShader:st.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:st.cube_vert,fragmentShader:st.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:st.equirect_vert,fragmentShader:st.equirect_frag},distance:{uniforms:Ln([Te.common,Te.displacementmap,{referencePosition:{value:new j},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:st.distance_vert,fragmentShader:st.distance_frag},shadow:{uniforms:Ln([Te.lights,Te.fog,{color:{value:new qe(0)},opacity:{value:1}}]),vertexShader:st.shadow_vert,fragmentShader:st.shadow_frag}};br.physical={uniforms:Ln([br.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new tt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new tt},clearcoatNormalScale:{value:new Ke(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new tt},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new tt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new tt},sheen:{value:0},sheenColor:{value:new qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new tt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new tt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new tt},transmissionSamplerSize:{value:new Ke},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new tt},attenuationDistance:{value:0},attenuationColor:{value:new qe(0)},specularColor:{value:new qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new tt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new tt},anisotropyVector:{value:new Ke},anisotropyMap:{value:null},anisotropyMapTransform:{value:new tt}}]),vertexShader:st.meshphysical_vert,fragmentShader:st.meshphysical_frag};Vd={r:0,b:0,g:0},Qk=new Qe,EA=new tt;EA.set(-1,0,0,0,1,0,0,0,1);hl=new Ra,eA=new qe,cD=new j,Ia=new j;ag=class ag extends ci{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Cd(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`varying vec3 vWorldDirection;@@ -4217,61 +4221,61 @@ void main() {gl_FragColor = texture2D( tEquirect, sampleUV );}- `},i=new ms(5,5,5),r=new _i({name:"CubemapFromEquirect",uniforms:va(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Pn,blending:lr});r.uniforms.tEquirect.value=t;let s=new jt(i,r),a=t.minFilter;if(t.minFilter===ur)t.minFilter=En;return new Rm(1,10,this).update(e,s),t.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}};zk={[_p]:"LINEAR_TONE_MAPPING",[vp]:"REINHARD_TONE_MAPPING",[Ep]:"CINEON_TONE_MAPPING",[Lc]:"ACES_FILMIC_TONE_MAPPING",[Ap]:"AGX_TONE_MAPPING",[Sp]:"NEUTRAL_TONE_MAPPING",[Tp]:"CUSTOM_TONE_MAPPING"};rA=new Qt,Hm=new _a(1,1),sA=new ad,aA=new bm,oA=new hd,BT=[],zT=[],VT=new Float32Array(16),jT=new Float32Array(9),HT=new Float32Array(4);Vm=/(\w+)(\])?(\[|\.)?/g;KT=new tt;kD={[_p]:"Linear",[vp]:"Reinhard",[Ep]:"Cineon",[Lc]:"ACESFilmic",[Ap]:"AgX",[Sp]:"Neutral",[Tp]:"Custom"};Sd=new j;zD=/^[ \t]*#include +<([\w\d./]+)>/gm;VD=new Map;HD=/#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;$D={[kc]:"SHADOWMAP_TYPE_PCF",[go]:"SHADOWMAP_TYPE_VSM"};WD={[yo]:"ENVMAP_TYPE_CUBE",[pa]:"ENVMAP_TYPE_CUBE",[Fc]:"ENVMAP_TYPE_CUBE_UV"};qD={[pa]:"ENVMAP_MODE_REFRACTION"};ZD={[sT]:"ENVMAP_BLENDING_MULTIPLY",[aT]:"ENVMAP_BLENDING_MIX",[oT]:"ENVMAP_BLENDING_ADD"};mL=[new j(1,0,0),new j(-1,0,0),new j(0,1,0),new j(0,-1,0),new j(0,0,1),new j(0,0,-1)],gL=[new j(0,-1,0),new j(0,-1,0),new j(0,0,1),new j(0,0,-1),new j(0,-1,0),new j(0,-1,0)],tA=new Qe,nl=new j,jm=new j;pA=class pA extends Bi{constructor(e,t){super();let n=this,i=null,r=1,s=null,a="local-floor",o=1,c=null,l=null,u=null,d=null,f=null,h=null,y=typeof XRWebGLBinding<"u",g=new hA,m={},p=t.getContextAttributes(),b=null,_=null,x=[],v=[],E=new Ke,S=null,T=null,A=new fn;A.viewport=new Nt;let P=new fn;P.viewport=new Nt;let w=[A,P],I=new Im,F=null,N=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let L=x[J];if(L===void 0)L=new jc,x[J]=L;return L.getTargetRaySpace()},this.getControllerGrip=function(J){let L=x[J];if(L===void 0)L=new jc,x[J]=L;return L.getGripSpace()},this.getHand=function(J){let L=x[J];if(L===void 0)L=new jc,x[J]=L;return L.getHandSpace()};function U(J){let L=v.indexOf(J.inputSource);if(L===-1)return;let W=x[L];if(W!==void 0)W.update(J.inputSource,J.frame,c||s),W.dispatchEvent({type:J.type,data:J.inputSource})}function D(){i.removeEventListener("select",U),i.removeEventListener("selectstart",U),i.removeEventListener("selectend",U),i.removeEventListener("squeeze",U),i.removeEventListener("squeezestart",U),i.removeEventListener("squeezeend",U),i.removeEventListener("end",D),i.removeEventListener("inputsourceschange",O);for(let J=0;J<x.length;J++){let L=v[J];if(L===null)continue;v[J]=null,x[J].disconnect(L)}F=null,N=null,g.reset();for(let J in m)delete m[J];if(e.setRenderTarget(b),f=null,d=null,u=null,i=null,_=null,pe.stop(),n.isPresenting=!1,e.setPixelRatio(S),e.setSize(E.width,E.height,!1),T!==null){let J=T.camera;J.fov=T.fov,J.zoom=T.zoom,J.updateProjectionMatrix(),T=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){if(r=J,n.isPresenting===!0)je("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){if(a=J,n.isPresenting===!0)je("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(J){c=J},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){if(u===null&&y)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return h},this.getSession=function(){return i},this.setSession=async function(J){if(i=J,i!==null){if(b=e.getRenderTarget(),i.addEventListener("select",U),i.addEventListener("selectstart",U),i.addEventListener("selectend",U),i.addEventListener("squeeze",U),i.addEventListener("squeezestart",U),i.addEventListener("squeezeend",U),i.addEventListener("end",D),i.addEventListener("inputsourceschange",O),p.xrCompatible!==!0)await t.makeXRCompatible();if(S=e.getPixelRatio(),e.getSize(E),!(y&&("createProjectionLayer"in XRWebGLBinding.prototype))){let W={antialias:p.antialias,alpha:!0,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,t,W),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),_=new ai(f.framebufferWidth,f.framebufferHeight,{format:fr,type:Ui,colorSpace:e.outputColorSpace,stencilBuffer:p.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}else{let W=null,te=null,ie=null;if(p.depth)ie=p.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,W=p.stencil?ba:ga,te=p.stencil?Eo:ds;let ce={colorFormat:t.RGBA8,depthFormat:ie,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(ce),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),_=new ai(d.textureWidth,d.textureHeight,{format:fr,type:Ui,depthTexture:new _a(d.textureWidth,d.textureHeight,te,void 0,void 0,void 0,void 0,void 0,void 0,W),stencilBuffer:p.stencil,colorSpace:e.outputColorSpace,samples:p.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(o),c=null,s=await i.requestReferenceSpace(a),pe.setContext(i),pe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function O(J){for(let L=0;L<J.removed.length;L++){let W=J.removed[L],te=v.indexOf(W);if(te>=0)v[te]=null,x[te].disconnect(W)}for(let L=0;L<J.added.length;L++){let W=J.added[L],te=v.indexOf(W);if(te===-1){for(let ce=0;ce<x.length;ce++)if(ce>=v.length){v.push(W),te=ce;break}else if(v[ce]===null){v[ce]=W,te=ce;break}if(te===-1)break}let ie=x[te];if(ie)ie.connect(W)}}let K=new j,B=new j;function X(J,L,W){K.setFromMatrixPosition(L.matrixWorld),B.setFromMatrixPosition(W.matrixWorld);let te=K.distanceTo(B),ie=L.projectionMatrix.elements,ce=W.projectionMatrix.elements,_e=ie[14]/(ie[10]-1),Re=ie[14]/(ie[10]+1),Oe=(ie[9]+1)/ie[5],We=(ie[9]-1)/ie[5],Ye=(ie[8]-1)/ie[0],Kt=(ce[8]+1)/ce[0],lt=_e*Ye,Dt=_e*Kt,Yt=te/(-Ye+Kt),tn=Yt*-Ye;if(L.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(tn),J.translateZ(Yt),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert(),ie[10]===-1)J.projectionMatrix.copy(L.projectionMatrix),J.projectionMatrixInverse.copy(L.projectionMatrixInverse);else{let z=_e+Yt,xn=Re+Yt,St=lt-tn,Wt=Dt+(te-tn),C=Oe*Re/xn*z,M=We*Re/xn*z;J.projectionMatrix.makePerspective(St,Wt,C,M,z,xn),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}}function q(J,L){if(L===null)J.matrixWorld.copy(J.matrix);else J.matrixWorld.multiplyMatrices(L.matrixWorld,J.matrix);J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(i===null)return;let{near:L,far:W}=J;if(g.texture!==null){if(g.depthNear>0)L=g.depthNear;if(g.depthFar>0)W=g.depthFar}if(I.near=P.near=A.near=L,I.far=P.far=A.far=W,F!==I.near||N!==I.far)i.updateRenderState({depthNear:I.near,depthFar:I.far}),F=I.near,N=I.far;I.layers.mask=J.layers.mask|6,A.layers.mask=I.layers.mask&-5,P.layers.mask=I.layers.mask&-3;let te=J.parent,ie=I.cameras;q(I,te);for(let ce=0;ce<ie.length;ce++)q(ie[ce],te);if(ie.length===2)X(I,A,P);else I.projectionMatrix.copy(A.projectionMatrix);if(T===null&&J.isPerspectiveCamera)T={camera:J,fov:J.fov,zoom:J.zoom};le(J,I,te)};function le(J,L,W){if(W===null)J.matrix.copy(L.matrixWorld);else J.matrix.copy(W.matrixWorld),J.matrix.invert(),J.matrix.multiply(L.matrixWorld);if(J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(L.projectionMatrix),J.projectionMatrixInverse.copy(L.projectionMatrixInverse),J.isPerspectiveCamera)J.fov=ha*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1}this.getCamera=function(){return I},this.getFoveation=function(){if(d===null&&f===null)return;return o},this.setFoveation=function(J){if(o=J,d!==null)d.fixedFoveation=J;if(f!==null&&f.fixedFoveation!==void 0)f.fixedFoveation=J},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(I)},this.getCameraTexture=function(J){return m[J]};let de=null;function Me(J,L){if(l=L.getViewerPose(c||s),h=L,l!==null){let W=l.views;if(f!==null)e.setRenderTargetFramebuffer(_,f.framebuffer),e.setRenderTarget(_);let te=!1;if(W.length!==I.cameras.length)I.cameras.length=0,te=!0;for(let Re=0;Re<W.length;Re++){let Oe=W[Re],We=null;if(f!==null)We=f.getViewport(Oe);else{let Kt=u.getViewSubImage(d,Oe);if(We=Kt.viewport,Re===0)e.setRenderTargetTextures(_,Kt.colorTexture,Kt.depthStencilTexture),e.setRenderTarget(_)}let Ye=w[Re];if(Ye===void 0)Ye=new fn,Ye.layers.enable(Re),Ye.viewport=new Nt,w[Re]=Ye;if(Ye.matrix.fromArray(Oe.transform.matrix),Ye.matrix.decompose(Ye.position,Ye.quaternion,Ye.scale),Ye.projectionMatrix.fromArray(Oe.projectionMatrix),Ye.projectionMatrixInverse.copy(Ye.projectionMatrix).invert(),Ye.viewport.set(We.x,We.y,We.width,We.height),Re===0)I.matrix.copy(Ye.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale);if(te===!0)I.cameras.push(Ye)}let ie=i.enabledFeatures;if(ie&&ie.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){u=n.getBinding();let Re=u.getDepthInformation(W[0]);if(Re&&Re.isValid&&Re.texture)g.init(Re,i.renderState)}if(ie&&ie.includes("camera-access")&&y){e.state.unbindTexture(),u=n.getBinding();for(let Re=0;Re<W.length;Re++){let Oe=W[Re].camera;if(Oe){let We=m[Oe];if(!We)We=new pd,m[Oe]=We;let Ye=u.getCameraImage(Oe);We.sourceTexture=Ye}}}}for(let W=0;W<x.length;W++){let te=v[W],ie=x[W];if(te!==null&&ie!==void 0)ie.update(te,L,c||s)}if(de)de(J,L);if(L.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:L});h=null}let pe=new nA;pe.setAnimationLoop(Me),this.setAnimationLoop=function(J){de=J},this.dispose=function(){}}};TL=new Qe,mA=new tt;mA.set(-1,0,0,0,1,0,0,0,1);wL=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183])});var lS=class{_listeners={};addEventListener(e,t){let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t);return this}removeEventListener(e,t){let n=this._listeners[e];if(n!==void 0){let i=n.indexOf(t);if(i!==-1)n.splice(i,1)}return this}dispatchEvent(e){let t=this._listeners[e.type];if(t!==void 0){let n=t.slice(0);for(let i=0,r=n.length;i<r;i++)n[i].call(this,e)}return this}dispose(){for(let e in this._listeners)delete this._listeners[e]}},As=class{_disposed=!1;_name;_parent;_child;_attributes;constructor(e,t,n,i={}){if(this._name=e,this._parent=t,this._child=n,this._attributes=i,!t.isOnGraph(n))throw Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(e){return this._child=e,this}getAttributes(){return this._attributes}dispose(){if(this._disposed)return;this._parent._destroyRef(this),this._disposed=!0}isDisposed(){return this._disposed}},dg,bn=class{list=[];constructor(e){if(e)for(let t of e)this.list.push(t)}add(e){this.list.push(e)}remove(e){let t=this.list.indexOf(e);if(t>=0)this.list.splice(t,1)}removeChild(e){let t=[];for(let n of this.list)if(n.getChild()===e)t.push(n);for(let n of t)this.remove(n);return t}listRefsByChild(e){let t=[];for(let n of this.list)if(n.getChild()===e)t.push(n);return t}values(){return this.list}},Rt=class{set=new Set;map=new Map;constructor(e){if(e)for(let t of e)this.add(t)}add(e){let t=e.getChild();this.removeChild(t),this.set.add(e),this.map.set(t,e)}remove(e){this.set.delete(e),this.map.delete(e.getChild())}removeChild(e){let t=this.map.get(e)||null;if(t)this.remove(t);return t}getRefByChild(e){return this.map.get(e)||null}values(){return Array.from(this.set)}},dn=class{map={};constructor(e){if(e)Object.assign(this.map,e)}set(e,t){this.map[e]=t}delete(e){delete this.map[e]}get(e){return this.map[e]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}},Tt,Ts,uS;var dS=Ft(()=>{dg=class extends lS{_emptySet=new Set;_edges=new Set;_parentEdges=new Map;_childEdges=new Map;listEdges(){return Array.from(this._edges)}listParentEdges(e){return Array.from(this._childEdges.get(e)||this._emptySet)}listParents(e){let t=new Set;for(let n of this.listParentEdges(e))t.add(n.getParent());return Array.from(t)}listChildEdges(e){return Array.from(this._parentEdges.get(e)||this._emptySet)}listChildren(e){let t=new Set;for(let n of this.listChildEdges(e))t.add(n.getChild());return Array.from(t)}disconnectParents(e,t){for(let n of this.listParentEdges(e))if(!t||t(n.getParent()))n.dispose();return this}_createEdge(e,t,n,i){let r=new As(e,t,n,i);this._edges.add(r);let s=r.getParent();if(!this._parentEdges.has(s))this._parentEdges.set(s,new Set);this._parentEdges.get(s).add(r);let a=r.getChild();if(!this._childEdges.has(a))this._childEdges.set(a,new Set);return this._childEdges.get(a).add(r),r}_destroyEdge(e){return this._edges.delete(e),this._parentEdges.get(e.getParent()).delete(e),this._childEdges.get(e.getChild()).delete(e),this}},Tt=Symbol("attributes"),Ts=Symbol("immutableKeys"),uS=class e extends lS{_disposed=!1;graph;[Tt];[Ts];constructor(t){super();this.graph=t,this[Ts]=new Set,this[Tt]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let t=this.getDefaults(),n={};for(let i in t){let r=t[i];if(r instanceof e){let s=this.graph._createEdge(i,this,r);this[Ts].add(i),n[i]=s}else n[i]=r}return n}isOnGraph(t){return this.graph===t.graph}isDisposed(){return this._disposed}dispose(){if(this._disposed)return;this.graph.listChildEdges(this).forEach((t)=>t.dispose()),this.graph.disconnectParents(this),this._disposed=!0,this.dispatchEvent({type:"dispose"})}detach(){return this.graph.disconnectParents(this),this}swap(t,n){for(let i in this[Tt]){let r=this[Tt][i];if(r instanceof As){let s=r;if(s.getChild()===t)this.setRef(i,n,s.getAttributes())}else if(r instanceof bn)for(let s of r.listRefsByChild(t)){let a=s.getAttributes();this.removeRef(i,t),this.addRef(i,n,a)}else if(r instanceof Rt){let s=r.getRefByChild(t);if(s){let a=s.getAttributes();this.removeRef(i,t),this.addRef(i,n,a)}}else if(r instanceof dn)for(let s of r.keys()){let a=r.get(s);if(a.getChild()===t)this.setRefMap(i,s,n,a.getAttributes())}}return this}get(t){return this[Tt][t]}set(t,n){return this[Tt][t]=n,this.dispatchEvent({type:"change",attribute:t})}getRef(t){let n=this[Tt][t];return n?n.getChild():null}setRef(t,n,i){if(this[Ts].has(t))throw Error(`Cannot overwrite immutable attribute, "${t}".`);let r=this[Tt][t];if(r)r.dispose();if(!n)return this;let s=this.graph._createEdge(t,this,n,i);return this[Tt][t]=s,this.dispatchEvent({type:"change",attribute:t})}listRefs(t){return this.assertRefList(t).values().map((n)=>n.getChild())}addRef(t,n,i){let r=this.graph._createEdge(t,this,n,i);return this.assertRefList(t).add(r),this.dispatchEvent({type:"change",attribute:t})}removeRef(t,n){let i=this.assertRefList(t);if(i instanceof bn)for(let r of i.listRefsByChild(n))r.dispose();else{let r=i.getRefByChild(n);if(r)r.dispose()}return this}assertRefList(t){let n=this[Tt][t];if(n instanceof bn||n instanceof Rt)return n;throw Error(`Expected RefList or RefSet for attribute "${t}"`)}listRefMapKeys(t){return this.assertRefMap(t).keys()}listRefMapValues(t){return this.assertRefMap(t).values().map((n)=>n.getChild())}getRefMap(t,n){let i=this.assertRefMap(t).get(n);return i?i.getChild():null}setRefMap(t,n,i,r){let s=this.assertRefMap(t),a=s.get(n);if(a)a.dispose();if(!i)return this;r=Object.assign(r||{},{key:n});let o=this.graph._createEdge(t,this,i,{...r,key:n});return s.set(n,o),this.dispatchEvent({type:"change",attribute:t,key:n})}assertRefMap(t){let n=this[Tt][t];if(n instanceof dn)return n;throw Error(`Expected RefMap for attribute "${t}"`)}dispatchEvent(t){return super.dispatchEvent({...t,target:this}),this.graph.dispatchEvent({...t,target:this,type:`node:${t.type}`}),this}_destroyRef(t){let n=t.getName();if(this[Tt][n]===t){if(this[Tt][n]=null,this[Ts].has(n))t.getChild().dispose()}else if(this[Tt][n]instanceof bn)this[Tt][n].remove(t);else if(this[Tt][n]instanceof Rt)this[Tt][n].remove(t);else if(this[Tt][n]instanceof dn){let i=this[Tt][n];for(let r of i.keys())if(i.get(r)===t)i.delete(r)}else return;this.graph._destroyEdge(t),this.dispatchEvent({type:"change",attribute:n})}}});function n8(e,t){if(t>e.byteLength)throw TypeError("Corrupt JPG, exceeded buffer limits");if(e.getUint8(t)!==255)throw TypeError("Invalid JPG, marker table corrupted");return e}function i8(){var e=new pg(3);if(pg!=Float32Array)e[0]=0,e[1]=0,e[2]=0;return e}function fg(e){var t=e[0],n=e[1],i=e[2];return Math.sqrt(t*t+n*n+i*i)}function r8(e,t,n){var i=t[0],r=t[1],s=t[2],a=n[3]*i+n[7]*r+n[11]*s+n[15];return a=a||1,e[0]=(n[0]*i+n[4]*r+n[8]*s+n[12])/a,e[1]=(n[1]*i+n[5]*r+n[9]*s+n[13])/a,e[2]=(n[2]*i+n[6]*r+n[10]*s+n[14])/a,e}function gg(e){let t=_S(),n=e.propertyType==="Node"?[e]:e.listChildren();for(let i of n)i.traverse((r)=>{let s=r.getMesh();if(!s)return;let a=s8(s,r.getWorldMatrix());if(a.min.every(isFinite)&&a.max.every(isFinite))mg(a.min,t),mg(a.max,t)});return t}function s8(e,t){let n=_S();for(let i of e.listPrimitives()){let r=i.getAttribute("POSITION"),s=i.getIndices();if(!r)continue;let a=[0,0,0],o=[0,0,0];for(let c=0,l=s?s.getCount():r.getCount();c<l;c++){let u=s?s.getScalar(c):c;a=r.getElement(u,a),o=r8(o,a,t),mg(o,n)}}return n}function mg(e,t){for(let n=0;n<3;n++)t.min[n]=Math.min(e[n],t.min[n]),t.max[n]=Math.max(e[n],t.max[n])}function _S(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}function hS(e){return Object.prototype.toString.call(e)==="[object Object]"}function wa(e){if(hS(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;if(hS(n)===!1)return!1;if(Object.hasOwn(n,"isPrototypeOf")===!1)return!1;return!0}function o8(e){var t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],h=e[12],y=e[13],g=e[14],m=e[15],p=t*a-n*s,b=t*o-i*s,_=n*o-i*a,x=l*y-u*h,v=l*g-d*h,E=u*g-d*y,S=t*E-n*v+i*x,T=s*E-a*v+o*x,A=l*_-u*b+d*p,P=h*_-y*b+g*p;return c*S-r*T+m*A-f*P}function c8(e,t,n){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],h=t[10],y=t[11],g=t[12],m=t[13],p=t[14],b=t[15],_=n[0],x=n[1],v=n[2],E=n[3];return e[0]=_*i+x*o+v*d+E*g,e[1]=_*r+x*c+v*f+E*m,e[2]=_*s+x*l+v*h+E*p,e[3]=_*a+x*u+v*y+E*b,_=n[4],x=n[5],v=n[6],E=n[7],e[4]=_*i+x*o+v*d+E*g,e[5]=_*r+x*c+v*f+E*m,e[6]=_*s+x*l+v*h+E*p,e[7]=_*a+x*u+v*y+E*b,_=n[8],x=n[9],v=n[10],E=n[11],e[8]=_*i+x*o+v*d+E*g,e[9]=_*r+x*c+v*f+E*m,e[10]=_*s+x*l+v*h+E*p,e[11]=_*a+x*u+v*y+E*b,_=n[12],x=n[13],v=n[14],E=n[15],e[12]=_*i+x*o+v*d+E*g,e[13]=_*r+x*c+v*f+E*m,e[14]=_*s+x*l+v*h+E*p,e[15]=_*a+x*u+v*y+E*b,e}function l8(e,t){var n=t[0],i=t[1],r=t[2],s=t[4],a=t[5],o=t[6],c=t[8],l=t[9],u=t[10];return e[0]=Math.sqrt(n*n+i*i+r*r),e[1]=Math.sqrt(s*s+a*a+o*o),e[2]=Math.sqrt(c*c+l*l+u*u),e}function u8(e,t){var n=new pg(3);l8(n,t);var i=1/n[0],r=1/n[1],s=1/n[2],a=t[0]*i,o=t[1]*r,c=t[2]*s,l=t[4]*i,u=t[5]*r,d=t[6]*s,f=t[8]*i,h=t[9]*r,y=t[10]*s,g=a+u+y,m=0;if(g>0)m=Math.sqrt(g+1)*2,e[3]=0.25*m,e[0]=(d-h)/m,e[1]=(f-c)/m,e[2]=(o-l)/m;else if(a>u&&a>y)m=Math.sqrt(1+a-u-y)*2,e[3]=(d-h)/m,e[0]=0.25*m,e[1]=(o+l)/m,e[2]=(f+c)/m;else if(u>y)m=Math.sqrt(1+u-a-y)*2,e[3]=(f-c)/m,e[0]=(o+l)/m,e[1]=0.25*m,e[2]=(d+h)/m;else m=Math.sqrt(1+y-a-u)*2,e[3]=(o-l)/m,e[0]=(f+c)/m,e[1]=(d+h)/m,e[2]=0.25*m;return e}function d8(e,t){if(!!e!==!!t)return!1;let n=e.getChild(),i=t.getChild();return n===i||n.equals(i)}function f8(e,t){if(!!e!==!!t)return!1;let n=e.values(),i=t.values();if(n.length!==i.length)return!1;for(let r=0;r<n.length;r++){let s=n[r],a=i[r];if(s.getChild()===a.getChild())continue;if(!s.getChild().equals(a.getChild()))return!1}return!0}function h8(e,t){if(!!e!==!!t)return!1;let n=e.keys(),i=t.keys();if(n.length!==i.length)return!1;for(let r of n){let s=e.get(r),a=t.get(r);if(!!s!==!!a)return!1;let o=s.getChild(),c=a.getChild();if(o===c)continue;if(!o.equals(c))return!1}return!0}function vS(e,t){if(e===t)return!0;if(!!e!==!!t||!e||!t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ES(e,t){if(e===t)return!0;if(!!e!==!!t)return!1;if(!wa(e)||!wa(t))return e===t;let n=e,i=t,r=0,s=0,a;for(a in n)r++;for(a in i)s++;if(r!==s)return!1;for(a in n){let o=n[a],c=i[a];if(Ld(o)&&Ld(c)){if(!vS(o,c))return!1}else if(wa(o)&&wa(c)){if(!ES(o,c))return!1}else if(o!==c)return!1}return!0}function Ld(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function x8(e){switch(e.constructor){case Float32Array:return Be.ComponentType.FLOAT;case Uint32Array:return Be.ComponentType.UNSIGNED_INT;case Uint16Array:return Be.ComponentType.UNSIGNED_SHORT;case Uint8Array:return Be.ComponentType.UNSIGNED_BYTE;case Int16Array:return Be.ComponentType.SHORT;case Int8Array:return Be.ComponentType.BYTE;case Float64Array:return Be.ComponentType.FLOAT64}if(typeof Float16Array<"u"&&e.constructor===Float16Array)return Be.ComponentType.FLOAT16;throw Error("Unknown accessor componentType.")}function A8(e,t){let n=t.jsonDoc,i=t.bufferViews[e.bufferView],r=n.json.bufferViews[e.bufferView],s=ul[e.componentType],a=Be.getElementSize(e.type),o=s.BYTES_PER_ELEMENT,c=e.byteOffset||0,l=new s(e.count*a),u=new DataView(i.buffer,i.byteOffset,i.byteLength),d=r.byteStride;for(let f=0;f<e.count;f++)for(let h=0;h<a;h++){let y=c+f*d+h*o,g;switch(e.componentType){case Be.ComponentType.FLOAT:g=u.getFloat32(y,!0);break;case Be.ComponentType.UNSIGNED_INT:g=u.getUint32(y,!0);break;case Be.ComponentType.UNSIGNED_SHORT:g=u.getUint16(y,!0);break;case Be.ComponentType.UNSIGNED_BYTE:g=u.getUint8(y);break;case Be.ComponentType.SHORT:g=u.getInt16(y,!0);break;case Be.ComponentType.BYTE:g=u.getInt8(y);break;case Be.ComponentType.FLOAT16:g=u.getFloat16(y,!0);break;case Be.ComponentType.FLOAT64:g=u.getFloat64(y,!0);break;default:throw Error(`Unexpected componentType "${e.componentType}".`)}l[f*a+h]=g}return l}function Dd(e,t){let n=t.jsonDoc,i=t.bufferViews[e.bufferView],r=n.json.bufferViews[e.bufferView],s=ul[e.componentType],a=Be.getElementSize(e.type),o=s.BYTES_PER_ELEMENT,c=a*o;if(r.byteStride!==void 0&&r.byteStride!==c)return A8(e,t);let l=i.byteOffset+(e.byteOffset||0),u=e.count*a*o;return new s(i.buffer.slice(l,l+u))}function S8(e,t){let n=ul[e.componentType],i=Be.getElementSize(e.type),r;if(e.bufferView!==void 0)r=Dd(e,t);else r=new n(e.count*i);let s=e.sparse;if(!s)return r;let a=s.count,o={...e,...s.indices,count:a,type:"SCALAR"},c={...e,...s.values,count:a},l=Dd(o,t),u=Dd(c,t);for(let d=0;d<o.count;d++)for(let f=0;f<i;f++)r[l[d]*i+f]=u[d*i+f];return r}function w8(e,t){let n=e.getGraph().listParentEdges(t).find((i)=>i.getParent()!==e.getRoot());return n?n.getName().replace(/texture$/i,""):""}function P8(e){let t=[];for(let n in e){let i=e[n];if(Array.isArray(i)&&i.length===0)t.push(n);else if(i===null||i==="")t.push(n);else if(i&&typeof i==="object"&&Object.keys(i).length===0)t.push(n)}for(let n of t)delete e[n]}function k8(e,t){return t.uri!==void 0&&!(t.uri in e.resources)}function D8(e,t){return t.uri!==void 0&&!(t.uri in e.resources)&&t.bufferView===void 0}function bS(e){if(e.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;let t=new Uint32Array(e.buffer,e.byteOffset,3);return t[0]===1179937895&&t[1]===2}var yS="v4.5.1",ws="@glb.bin",ne,YL,Ei,QL,ul,Je=class{static createBufferFromDataURI(e){if(typeof Buffer>"u"){let t=atob(e.split(",")[1]),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}else{let t=e.split(",")[1],n=e.indexOf("base64")>=0;return Buffer.from(t,n?"base64":"utf8")}}static encodeText(e){return new TextEncoder().encode(e)}static decodeText(e){return new TextDecoder().decode(e)}static concat(e){let t=0;for(let r of e)t+=r.byteLength;let n=new Uint8Array(t),i=0;for(let r of e)n.set(r,i),i+=r.byteLength;return n}static pad(e,t=0){let n=this.padNumber(e.byteLength);if(n===e.byteLength)return e;let i=new Uint8Array(n);if(i.set(e),t!==0)for(let r=e.byteLength;r<n;r++)i[r]=t;return i}static padNumber(e){return Math.ceil(e/4)*4}static equals(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;let n=e.byteLength;while(n--)if(e[n]!==t[n])return!1;return!0}static toView(e,t=0,n=1/0){return new Uint8Array(e.buffer,e.byteOffset+t,Math.min(e.byteLength,n))}static assertView(e){if(e&&!ArrayBuffer.isView(e))throw Error(`Method requires Uint8Array parameter; received "${typeof e}".`);return e}},xS=class{static hexToFactor(e,t){e=Math.floor(e);let n=t;return n[0]=(e>>16&255)/255,n[1]=(e>>8&255)/255,n[2]=(e&255)/255,this.convertSRGBToLinear(t,t)}static factorToHex(e){let t=[...e],[n,i,r]=this.convertLinearToSRGB(e,t);return n*255<<16^i*255<<8^r*255<<0}static convertSRGBToLinear(e,t){let n=e,i=t;for(let r=0;r<3;r++)i[r]=n[r]<0.04045?n[r]*0.0773993808:Math.pow(n[r]*0.9478672986+0.0521327014,2.4);return t}static convertLinearToSRGB(e,t){let n=e,i=t;for(let r=0;r<3;r++)i[r]=n[r]<0.0031308?n[r]*12.92:1.055*Math.pow(n[r],0.41666)-0.055;return t}},e8=class{match(e){return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255}getSize(e){let t=new DataView(e.buffer,e.byteOffset+4),n,i;while(t.byteLength){if(n=t.getUint16(0,!1),n8(t,n),i=t.getUint8(n+1),i===192||i===193||i===194)return[t.getUint16(n+7,!1),t.getUint16(n+5,!1)];t=new DataView(e.buffer,t.byteOffset+n+2)}throw TypeError("Invalid JPG, no size found")}getChannels(e){return 3}},t8=class e{static PNG_FRIED_CHUNK_NAME="CgBI";match(t){return t.length>=8&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71&&t[4]===13&&t[5]===10&&t[6]===26&&t[7]===10}getSize(t){let n=new DataView(t.buffer,t.byteOffset);if(Je.decodeText(t.slice(12,16))===e.PNG_FRIED_CHUNK_NAME)return[n.getUint32(32,!1),n.getUint32(36,!1)];return[n.getUint32(16,!1),n.getUint32(20,!1)]}getChannels(t){return 4}},ji,Ma=class{static basename(e){let t=e.split(/[\\/]/).pop();return t.substring(0,t.lastIndexOf("."))}static extension(e){if(e.startsWith("data:image/")){let t=e.match(/data:(image\/\w+)/)[1];return ji.mimeTypeToExtension(t)}else if(e.startsWith("data:model/gltf+json"))return"gltf";else if(e.startsWith("data:model/gltf-binary"))return"glb";else if(e.startsWith("data:application/"))return"bin";return e.split(/[\\/]/).pop().split(/[.]/).pop()}},pg,fS="https://null.example",hg,a8,Ia,pt=class e{static identity(t){return t}static eq(t,n,i=0.00001){if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(Math.abs(t[r]-n[r])>i)return!1;return!0}static clamp(t,n,i){if(t<n)return n;if(t>i)return i;return t}static decodeNormalizedInt(t,n){switch(n){case 5126:return t;case 5123:return t/65535;case 5121:return t/255;case 5122:return Math.max(t/32767,-1);case 5120:return Math.max(t/127,-1);default:throw Error("Invalid component type.")}}static encodeNormalizedInt(t,n){switch(n){case 5126:return t;case 5123:return Math.round(e.clamp(t,0,1)*65535);case 5121:return Math.round(e.clamp(t,0,1)*255);case 5122:return Math.round(e.clamp(t,-1,1)*32767);case 5120:return Math.round(e.clamp(t,-1,1)*127);default:throw Error("Invalid component type.")}}static decompose(t,n,i,r){let s=fg([t[0],t[1],t[2]]),a=fg([t[4],t[5],t[6]]),o=fg([t[8],t[9],t[10]]);if(o8(t)<0)s=-s;n[0]=t[12],n[1]=t[13],n[2]=t[14];let c=t.slice(),l=1/s,u=1/a,d=1/o;c[0]*=l,c[1]*=l,c[2]*=l,c[4]*=u,c[5]*=u,c[6]*=u,c[8]*=d,c[9]*=d,c[10]*=d,u8(i,c),r[0]=s,r[1]=a,r[2]=o}static compose(t,n,i,r){let s=r,a=n[0],o=n[1],c=n[2],l=n[3],u=a+a,d=o+o,f=c+c,h=a*u,y=a*d,g=a*f,m=o*d,p=o*f,b=c*f,_=l*u,x=l*d,v=l*f,E=i[0],S=i[1],T=i[2];return s[0]=(1-(m+b))*E,s[1]=(y+v)*E,s[2]=(g-x)*E,s[3]=0,s[4]=(y-v)*S,s[5]=(1-(h+b))*S,s[6]=(p+_)*S,s[7]=0,s[8]=(g+x)*T,s[9]=(p-_)*T,s[10]=(1-(h+m))*T,s[11]=0,s[12]=t[0],s[13]=t[1],s[14]=t[2],s[15]=1,s}},p8="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",m8=999,g8=6,pS,b8=function(){let e="";for(let t=0;t<g8;t++)e+=p8.charAt(Math.floor(Math.random()*42));return e},TS=function(){for(let e=0;e<m8;e++){let t=b8();if(!pS.has(t))return pS.add(t),t}return""},Ms=(e)=>e,y8,bg,jn,Be,AS,Ca,dl,SS,Fd,nt,At,Nd,Pd,Od,_8,Ra,yg,Ud,Wn,xg,Bd,wS,zo,Rs,zd,xt=class{static EXTENSION_NAME;extensionName="";prereadTypes=[];prewriteTypes=[];readDependencies=[];writeDependencies=[];document;required=!1;properties=new Set;_listener;constructor(e){this.document=e,e.getRoot()._enableExtension(this),this._listener=(n)=>{let i=n,r=i.target;if(r instanceof nt&&r.extensionName===this.extensionName){if(i.type==="node:create")this._addExtensionProperty(r);if(i.type==="node:dispose")this._removeExtensionProperty(r)}};let t=e.getGraph();t.addEventListener("node:create",this._listener),t.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);let e=this.document.getGraph();e.removeEventListener("node:create",this._listener),e.removeEventListener("node:dispose",this._listener);for(let t of this.properties)t.dispose()}static register(){}isRequired(){return this.required}setRequired(e){return this.required=e,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(e){return this.properties.add(e),this}_removeExtensionProperty(e){return this.properties.delete(e),this}install(e,t){return this}preread(e,t){return this}prewrite(e,t){return this}},v8=class{jsonDoc;buffers=[];bufferViews=[];bufferViewBuffers=[];accessors=[];textures=[];textureInfos=new Map;materials=[];meshes=[];cameras=[];nodes=[];skins=[];animations=[];scenes=[];constructor(e){this.jsonDoc=e}setTextureInfo(e,t){if(this.textureInfos.set(e,t),t.texCoord!==void 0)e.setTexCoord(t.texCoord);if(t.extras!==void 0)e.setExtras(t.extras);let n=this.jsonDoc.json.textures[t.index];if(n.sampler===void 0)return;let i=this.jsonDoc.json.samplers[n.sampler];if(i.magFilter!==void 0)e.setMagFilter(i.magFilter);if(i.minFilter!==void 0)e.setMinFilter(i.minFilter);if(i.wrapS!==void 0)e.setWrapS(i.wrapS);if(i.wrapT!==void 0)e.setWrapT(i.wrapT)}},mS,E8,T8=class{static read(e,t=mS){let n={...mS,...t},{json:i}=e,r=new zd().setLogger(n.logger);this.validate(e,n);let s=new v8(e),a=i.asset,o=r.getRoot().getAsset();if(a.copyright)o.copyright=a.copyright;if(a.extras)o.extras=a.extras;if(i.extras!==void 0)r.getRoot().setExtras({...i.extras});let c=i.extensionsUsed||[],l=i.extensionsRequired||[];n.extensions.sort((p,b)=>p.EXTENSION_NAME>b.EXTENSION_NAME?1:-1);for(let p of n.extensions)if(c.includes(p.EXTENSION_NAME)){let b=r.createExtension(p).setRequired(l.includes(p.EXTENSION_NAME)),_=b.prereadTypes.filter((x)=>!E8.has(x));if(_.length)n.logger.warn(`Preread hooks for some types (${_.join()}), requested by extension ${b.extensionName}, are unsupported. Please file an issue or a PR.`);for(let x of b.readDependencies)b.install(x,n.dependencies[x])}let u=i.buffers||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Buffer")).forEach((p)=>p.preread(s,"Buffer")),s.buffers=u.map((p)=>{let b=r.createBuffer(p.name);if(p.extras)b.setExtras(p.extras);if(p.uri&&p.uri.indexOf("__")!==0)b.setURI(p.uri);return b}),s.bufferViewBuffers=(i.bufferViews||[]).map((p,b)=>{if(!s.bufferViews[b]){let _=e.json.buffers[p.buffer],x=_.uri?e.resources[_.uri]:e.resources[ws],v=p.byteOffset||0;s.bufferViews[b]=Je.toView(x,v,p.byteLength)}return s.buffers[p.buffer]});let d=i.accessors||[];s.accessors=d.map((p)=>{let b=s.bufferViewBuffers[p.bufferView],_=r.createAccessor(p.name,b).setType(p.type);if(p.extras)_.setExtras(p.extras);if(p.normalized!==void 0)_.setNormalized(p.normalized);if(p.bufferView===void 0)return _;return _.setArray(Dd(p,s)),_});let f=i.images||[],h=i.textures||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Texture")).forEach((p)=>p.preread(s,"Texture")),s.textures=f.map((p)=>{let b=r.createTexture(p.name);if(p.extras)b.setExtras(p.extras);if(p.bufferView!==void 0){let _=i.bufferViews[p.bufferView],x=e.json.buffers[_.buffer],v=x.uri?e.resources[x.uri]:e.resources[ws],E=_.byteOffset||0,S=_.byteLength,T=v.slice(E,E+S);b.setImage(T)}else if(p.uri!==void 0){if(b.setImage(e.resources[p.uri]),p.uri.indexOf("__")!==0)b.setURI(p.uri)}if(p.mimeType!==void 0)b.setMimeType(p.mimeType);else if(p.uri){let _=Ma.extension(p.uri);b.setMimeType(ji.extensionToMimeType(_))}return b}),r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Material")).forEach((p)=>p.preread(s,"Material")),s.materials=(i.materials||[]).map((p)=>{let b=r.createMaterial(p.name);if(p.extras)b.setExtras(p.extras);if(p.alphaMode!==void 0)b.setAlphaMode(p.alphaMode);if(p.alphaCutoff!==void 0)b.setAlphaCutoff(p.alphaCutoff);if(p.doubleSided!==void 0)b.setDoubleSided(p.doubleSided);let _=p.pbrMetallicRoughness||{};if(_.baseColorFactor!==void 0)b.setBaseColorFactor(_.baseColorFactor);if(p.emissiveFactor!==void 0)b.setEmissiveFactor(p.emissiveFactor);if(_.metallicFactor!==void 0)b.setMetallicFactor(_.metallicFactor);if(_.roughnessFactor!==void 0)b.setRoughnessFactor(_.roughnessFactor);if(_.baseColorTexture!==void 0){let x=_.baseColorTexture,v=s.textures[h[x.index].source];b.setBaseColorTexture(v),s.setTextureInfo(b.getBaseColorTextureInfo(),x)}if(p.emissiveTexture!==void 0){let x=p.emissiveTexture,v=s.textures[h[x.index].source];b.setEmissiveTexture(v),s.setTextureInfo(b.getEmissiveTextureInfo(),x)}if(p.normalTexture!==void 0){let x=p.normalTexture,v=s.textures[h[x.index].source];if(b.setNormalTexture(v),s.setTextureInfo(b.getNormalTextureInfo(),x),p.normalTexture.scale!==void 0)b.setNormalScale(p.normalTexture.scale)}if(p.occlusionTexture!==void 0){let x=p.occlusionTexture,v=s.textures[h[x.index].source];if(b.setOcclusionTexture(v),s.setTextureInfo(b.getOcclusionTextureInfo(),x),p.occlusionTexture.strength!==void 0)b.setOcclusionStrength(p.occlusionTexture.strength)}if(_.metallicRoughnessTexture!==void 0){let x=_.metallicRoughnessTexture,v=s.textures[h[x.index].source];b.setMetallicRoughnessTexture(v),s.setTextureInfo(b.getMetallicRoughnessTextureInfo(),x)}return b}),r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Mesh")).forEach((p)=>p.preread(s,"Mesh"));let y=i.meshes||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Primitive")).forEach((p)=>p.preread(s,"Primitive")),s.meshes=y.map((p)=>{let b=r.createMesh(p.name);if(p.extras)b.setExtras(p.extras);if(p.weights!==void 0)b.setWeights(p.weights);return(p.primitives||[]).forEach((_)=>{let x=r.createPrimitive();if(_.extras)x.setExtras(_.extras);if(_.material!==void 0)x.setMaterial(s.materials[_.material]);if(_.mode!==void 0)x.setMode(_.mode);for(let[E,S]of Object.entries(_.attributes||{}))x.setAttribute(E,s.accessors[S]);if(_.indices!==void 0)x.setIndices(s.accessors[_.indices]);let v=p.extras&&p.extras.targetNames||[];(_.targets||[]).forEach((E,S)=>{let T=v[S]||S.toString(),A=r.createPrimitiveTarget(T);for(let[P,w]of Object.entries(E))A.setAttribute(P,s.accessors[w]);x.addTarget(A)}),b.addPrimitive(x)}),b}),s.cameras=(i.cameras||[]).map((p)=>{let b=r.createCamera(p.name).setType(p.type);if(p.extras)b.setExtras(p.extras);if(p.type===Fd.Type.PERSPECTIVE){let _=p.perspective;if(b.setYFov(_.yfov),b.setZNear(_.znear),_.zfar!==void 0)b.setZFar(_.zfar);if(_.aspectRatio!==void 0)b.setAspectRatio(_.aspectRatio)}else{let _=p.orthographic;b.setZNear(_.znear).setZFar(_.zfar).setXMag(_.xmag).setYMag(_.ymag)}return b});let g=i.nodes||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Node")).forEach((p)=>p.preread(s,"Node")),s.nodes=g.map((p)=>{let b=r.createNode(p.name);if(p.extras)b.setExtras(p.extras);if(p.translation!==void 0)b.setTranslation(p.translation);if(p.rotation!==void 0)b.setRotation(p.rotation);if(p.scale!==void 0)b.setScale(p.scale);if(p.matrix!==void 0){let _=[0,0,0],x=[0,0,0,1],v=[1,1,1];pt.decompose(p.matrix,_,x,v),b.setTranslation(_),b.setRotation(x),b.setScale(v)}if(p.weights!==void 0)b.setWeights(p.weights);return b}),s.skins=(i.skins||[]).map((p)=>{let b=r.createSkin(p.name);if(p.extras)b.setExtras(p.extras);if(p.inverseBindMatrices!==void 0)b.setInverseBindMatrices(s.accessors[p.inverseBindMatrices]);if(p.skeleton!==void 0)b.setSkeleton(s.nodes[p.skeleton]);for(let _ of p.joints)b.addJoint(s.nodes[_]);return b}),g.map((p,b)=>{let _=s.nodes[b];if((p.children||[]).forEach((x)=>_.addChild(s.nodes[x])),p.mesh!==void 0)_.setMesh(s.meshes[p.mesh]);if(p.camera!==void 0)_.setCamera(s.cameras[p.camera]);if(p.skin!==void 0)_.setSkin(s.skins[p.skin])}),s.animations=(i.animations||[]).map((p)=>{let b=r.createAnimation(p.name);if(p.extras)b.setExtras(p.extras);let _=(p.samplers||[]).map((x)=>{let v=r.createAnimationSampler().setInput(s.accessors[x.input]).setOutput(s.accessors[x.output]).setInterpolation(x.interpolation||dl.Interpolation.LINEAR);if(x.extras)v.setExtras(x.extras);return b.addSampler(v),v});return(p.channels||[]).forEach((x)=>{let v=r.createAnimationChannel().setSampler(_[x.sampler]).setTargetPath(x.target.path);if(x.target.node!==void 0)v.setTargetNode(s.nodes[x.target.node]);if(x.extras)v.setExtras(x.extras);b.addChannel(v)}),b});let m=i.scenes||[];if(r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Scene")).forEach((p)=>p.preread(s,"Scene")),s.scenes=m.map((p)=>{let b=r.createScene(p.name);if(p.extras)b.setExtras(p.extras);return(p.nodes||[]).map((_)=>s.nodes[_]).forEach((_)=>b.addChild(_)),b}),i.scene!==void 0)r.getRoot().setDefaultScene(s.scenes[i.scene]);return r.getRoot().listExtensionsUsed().forEach((p)=>p.read(s)),d.forEach((p,b)=>{let _=s.accessors[b],x=!!p.sparse,v=!p.bufferView&&!_.getArray();if(x||v)_.setSparse(!0).setArray(S8(p,s))}),r}static validate(e,t){let n=e.json;if(n.asset.version!=="2.0")throw Error(`Unsupported glTF version, "${n.asset.version}".`);if(n.extensionsRequired){for(let i of n.extensionsRequired)if(!t.extensions.find((r)=>r.EXTENSION_NAME===i))throw Error(`Missing required extension, "${i}".`)}if(n.extensionsUsed){for(let i of n.extensionsUsed)if(!t.extensions.find((r)=>r.EXTENSION_NAME===i))t.logger.warn(`Missing optional extension, "${i}".`)}}},MS,Ss,gS=class{multiple;basename;counter={};constructor(e,t){this.multiple=e,this.basename=t}createURI(e,t){if(e.getURI())return e.getURI();else if(!this.multiple)return`${this.basename(e)}.${t}`;else{let n=this.basename(e);return this.counter[n]=this.counter[n]||1,`${n}_${this.counter[n]++}.${t}`}}},kd,M8,R8,I8,C8,N8=class{static write(e,t){let n=e.getGraph(),i=e.getRoot(),r={asset:{generator:`glTF-Transform ${yS}`,...i.getAsset()},extras:{...i.getExtras()}},s={json:r,resources:{}},a=new Ss(e,s,t),o=t.logger||Ia.DEFAULT_INSTANCE,c=new Set(t.extensions.map((g)=>g.EXTENSION_NAME)),l=e.getRoot().listExtensionsUsed().filter((g)=>c.has(g.extensionName)).sort((g,m)=>g.extensionName>m.extensionName?1:-1),u=e.getRoot().listExtensionsRequired().filter((g)=>c.has(g.extensionName)).sort((g,m)=>g.extensionName>m.extensionName?1:-1);if(l.length<e.getRoot().listExtensionsUsed().length)o.warn("Some extensions were not registered for I/O, and will not be written.");for(let g of l){let m=g.prewriteTypes.filter((p)=>!C8.has(p));if(m.length)o.warn(`Prewrite hooks for some types (${m.join()}), requested by extension ${g.extensionName}, are unsupported. Please file an issue or a PR.`);for(let p of g.writeDependencies)g.install(p,t.dependencies[p])}function d(g,m,p,b){let _=[],x=0;for(let E of g){let S=a.createAccessorDef(E);S.bufferView=r.bufferViews.length;let T=E.getArray(),A=Je.pad(Je.toView(T));S.byteOffset=x,x+=A.byteLength,_.push(A),a.accessorIndexMap.set(E,r.accessors.length),r.accessors.push(S)}let v={buffer:m,byteOffset:p,byteLength:Je.concat(_).byteLength};if(b)v.target=b;return r.bufferViews.push(v),{buffers:_,byteLength:x}}function f(g,m,p){let b=g[0].getCount(),_=0;for(let T of g){let A=a.createAccessorDef(T);A.bufferView=r.bufferViews.length,A.byteOffset=_;let P=T.getElementSize(),w=T.getComponentSize();_+=Je.padNumber(P*w),a.accessorIndexMap.set(T,r.accessors.length),r.accessors.push(A)}let x=b*_,v=new ArrayBuffer(x),E=new DataView(v);for(let T=0;T<b;T++){let A=0;for(let P of g){let w=P.getElementSize(),I=P.getComponentSize(),F=P.getComponentType(),N=P.getArray();for(let U=0;U<w;U++){let D=T*_+A+U*I,O=N[T*w+U];switch(F){case Be.ComponentType.FLOAT:E.setFloat32(D,O,!0);break;case Be.ComponentType.BYTE:E.setInt8(D,O);break;case Be.ComponentType.SHORT:E.setInt16(D,O,!0);break;case Be.ComponentType.UNSIGNED_BYTE:E.setUint8(D,O);break;case Be.ComponentType.UNSIGNED_SHORT:E.setUint16(D,O,!0);break;case Be.ComponentType.UNSIGNED_INT:E.setUint32(D,O,!0);break;case Be.ComponentType.FLOAT16:E.setFloat16(D,O,!0);break;case Be.ComponentType.FLOAT64:E.setFloat64(D,O,!0);break;default:throw Error("Unexpected component type: "+F)}}A+=Je.padNumber(w*I)}}let S={buffer:m,byteOffset:p,byteLength:x,byteStride:_,target:Ss.BufferViewTarget.ARRAY_BUFFER};return r.bufferViews.push(S),{byteLength:x,buffers:[new Uint8Array(v)]}}function h(g,m,p){let b=[],_=0,x=new Map,v=-1/0,E=!1;for(let F of g){let N=a.createAccessorDef(F);r.accessors.push(N),a.accessorIndexMap.set(F,r.accessors.length-1);let U=[],D=[],O=[],K=Array(F.getElementSize()).fill(0);for(let le=0,de=F.getCount();le<de;le++){if(F.getElement(le,O),pt.eq(O,K,0))continue;v=Math.max(le,v),U.push(le);for(let Me=0;Me<O.length;Me++)D.push(O[Me])}let B=U.length,X={accessorDef:N,count:B};if(x.set(F,X),B===0)continue;if(B>F.getCount()/2)E=!0;let q=ul[F.getComponentType()];X.indices=U,X.values=new q(D)}if(!Number.isFinite(v))return{buffers:b,byteLength:_};if(E)o.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let S=v<255?Uint8Array:v<65535?Uint16Array:Uint32Array,T=v<255?I8:v<65535?R8:M8,A={buffer:m,byteOffset:p+_,byteLength:0};for(let F of g){let N=x.get(F);if(N.count===0)continue;N.indicesByteOffset=A.byteLength;let U=Je.pad(Je.toView(new S(N.indices)));b.push(U),_+=U.byteLength,A.byteLength+=U.byteLength}r.bufferViews.push(A);let P=r.bufferViews.length-1,w={buffer:m,byteOffset:p+_,byteLength:0};for(let F of g){let N=x.get(F);if(N.count===0)continue;N.valuesByteOffset=w.byteLength;let U=Je.pad(Je.toView(N.values));b.push(U),_+=U.byteLength,w.byteLength+=U.byteLength}r.bufferViews.push(w);let I=r.bufferViews.length-1;for(let F of g){let N=x.get(F);if(N.count===0)continue;N.accessorDef.sparse={count:N.count,indices:{bufferView:P,byteOffset:N.indicesByteOffset,componentType:T},values:{bufferView:I,byteOffset:N.valuesByteOffset}}}return{buffers:b,byteLength:_}}if(r.accessors=[],r.bufferViews=[],r.samplers=[],r.textures=[],r.images=i.listTextures().map((g,m)=>{let p=a.createPropertyDef(g);if(g.getMimeType())p.mimeType=g.getMimeType();let b=g.getImage();if(b)a.createImageData(p,b,g);return a.imageIndexMap.set(g,m),p}),l.filter((g)=>g.prewriteTypes.includes("Accessor")).forEach((g)=>g.prewrite(a,"Accessor")),i.listAccessors().forEach((g)=>{let{accessorUsageGroupedByParent:m,accessorParents:p}=a;if(a.accessorIndexMap.has(g))return;let b=a.getAccessorUsage(g);if(a.addAccessorToUsageGroup(g,b),m.has(b)){let _=n.listParents(g).find((x)=>x.propertyType!=="Root");p.set(g,_)}}),l.filter((g)=>g.prewriteTypes.includes("Buffer")).forEach((g)=>g.prewrite(a,"Buffer")),(i.listAccessors().length>0||a.otherBufferViews.size>0||i.listTextures().length>0&&t.format==="GLB")&&i.listBuffers().length===0)throw Error("Buffer required for Document resources, but none was found.");if(r.buffers=[],i.listBuffers().forEach((g,m)=>{let p=a.createPropertyDef(g),b=a.accessorUsageGroupedByParent,_=g.listParents().filter((P)=>P instanceof Be),x=new Set(_.map((P)=>a.accessorParents.get(P))),v=new Map(Array.from(x).map((P,w)=>[P,w])),E={};for(let P of _){if(a.accessorIndexMap.has(P))continue;let w=a.getAccessorUsage(P),I=w;if(b.has(w)){let F=a.accessorParents.get(P);I+=`:${v.get(F)}`}E[I]||={usage:w,accessors:[]},E[I].accessors.push(P)}let S=[],T=r.buffers.length,A=0;for(let{usage:P,accessors:w}of Object.values(E))if(P===kd.ARRAY_BUFFER&&t.vertexLayout==="interleaved"){let I=f(w,T,A);A+=I.byteLength;for(let F of I.buffers)S.push(F)}else if(P===kd.ARRAY_BUFFER)for(let I of w){let F=f([I],T,A);A+=F.byteLength;for(let N of F.buffers)S.push(N)}else if(P===kd.SPARSE){let I=h(w,T,A);A+=I.byteLength;for(let F of I.buffers)S.push(F)}else if(P===kd.ELEMENT_ARRAY_BUFFER){let I=Ss.BufferViewTarget.ELEMENT_ARRAY_BUFFER,F=d(w,T,A,I);A+=F.byteLength;for(let N of F.buffers)S.push(N)}else{let I=d(w,T,A);A+=I.byteLength;for(let F of I.buffers)S.push(F)}if(a.imageBufferViews.length&&m===0){for(let P=0;P<a.imageBufferViews.length;P++)if(r.bufferViews[r.images[P].bufferView].byteOffset=A,A+=a.imageBufferViews[P].byteLength,S.push(a.imageBufferViews[P]),A%8){let w=8-A%8;A+=w,S.push(new Uint8Array(w))}}if(a.otherBufferViews.has(g))for(let P of a.otherBufferViews.get(g))r.bufferViews.push({buffer:T,byteOffset:A,byteLength:P.byteLength}),a.otherBufferViewsIndexMap.set(P,r.bufferViews.length-1),A+=P.byteLength,S.push(P);if(A){let P;if(t.format==="GLB")P=ws;else P=a.bufferURIGenerator.createURI(g,"bin"),p.uri=P;p.byteLength=A,a.assignResourceURI(P,Je.concat(S),!0)}r.buffers.push(p),a.bufferIndexMap.set(g,m)}),i.listAccessors().find((g)=>!g.getBuffer()))o.warn("Skipped writing one or more Accessors: no Buffer assigned.");l.filter((g)=>g.prewriteTypes.includes("Material")).forEach((g)=>g.prewrite(a,"Material")),r.materials=i.listMaterials().map((g,m)=>{let p=a.createPropertyDef(g);if(g.getAlphaMode()!==Ra.AlphaMode.OPAQUE)p.alphaMode=g.getAlphaMode();if(g.getAlphaMode()===Ra.AlphaMode.MASK)p.alphaCutoff=g.getAlphaCutoff();if(g.getDoubleSided())p.doubleSided=!0;if(p.pbrMetallicRoughness={},!pt.eq(g.getBaseColorFactor(),[1,1,1,1]))p.pbrMetallicRoughness.baseColorFactor=g.getBaseColorFactor();if(!pt.eq(g.getEmissiveFactor(),[0,0,0]))p.emissiveFactor=g.getEmissiveFactor();if(g.getRoughnessFactor()!==1)p.pbrMetallicRoughness.roughnessFactor=g.getRoughnessFactor();if(g.getMetallicFactor()!==1)p.pbrMetallicRoughness.metallicFactor=g.getMetallicFactor();if(g.getBaseColorTexture()){let b=g.getBaseColorTexture(),_=g.getBaseColorTextureInfo();p.pbrMetallicRoughness.baseColorTexture=a.createTextureInfoDef(b,_)}if(g.getEmissiveTexture()){let b=g.getEmissiveTexture(),_=g.getEmissiveTextureInfo();p.emissiveTexture=a.createTextureInfoDef(b,_)}if(g.getNormalTexture()){let b=g.getNormalTexture(),_=g.getNormalTextureInfo(),x=a.createTextureInfoDef(b,_);if(g.getNormalScale()!==1)x.scale=g.getNormalScale();p.normalTexture=x}if(g.getOcclusionTexture()){let b=g.getOcclusionTexture(),_=g.getOcclusionTextureInfo(),x=a.createTextureInfoDef(b,_);if(g.getOcclusionStrength()!==1)x.strength=g.getOcclusionStrength();p.occlusionTexture=x}if(g.getMetallicRoughnessTexture()){let b=g.getMetallicRoughnessTexture(),_=g.getMetallicRoughnessTextureInfo();p.pbrMetallicRoughness.metallicRoughnessTexture=a.createTextureInfoDef(b,_)}return a.materialIndexMap.set(g,m),p}),l.filter((g)=>g.prewriteTypes.includes("Mesh")).forEach((g)=>g.prewrite(a,"Mesh")),r.meshes=i.listMeshes().map((g,m)=>{let p=a.createPropertyDef(g),b=null;if(p.primitives=g.listPrimitives().map((_)=>{let x={attributes:{}};x.mode=_.getMode();let v=_.getMaterial();if(v)x.material=a.materialIndexMap.get(v);if(Object.keys(_.getExtras()).length)x.extras=_.getExtras();let E=_.getIndices();if(E)x.indices=a.accessorIndexMap.get(E);for(let S of _.listSemantics())x.attributes[S]=a.accessorIndexMap.get(_.getAttribute(S));for(let S of _.listTargets()){let T={};for(let A of S.listSemantics())T[A]=a.accessorIndexMap.get(S.getAttribute(A));x.targets=x.targets||[],x.targets.push(T)}if(_.listTargets().length&&!b)b=_.listTargets().map((S)=>S.getName());return x}),g.getWeights().length)p.weights=g.getWeights();if(b)p.extras=p.extras||{},p.extras.targetNames=b;return a.meshIndexMap.set(g,m),p}),r.cameras=i.listCameras().map((g,m)=>{let p=a.createPropertyDef(g);if(p.type=g.getType(),p.type===Fd.Type.PERSPECTIVE){p.perspective={znear:g.getZNear(),zfar:g.getZFar(),yfov:g.getYFov()};let b=g.getAspectRatio();if(b!==null)p.perspective.aspectRatio=b}else p.orthographic={znear:g.getZNear(),zfar:g.getZFar(),xmag:g.getXMag(),ymag:g.getYMag()};return a.cameraIndexMap.set(g,m),p}),r.nodes=i.listNodes().map((g,m)=>{let p=a.createPropertyDef(g);if(!pt.eq(g.getTranslation(),[0,0,0]))p.translation=g.getTranslation();if(!pt.eq(g.getRotation(),[0,0,0,1]))p.rotation=g.getRotation();if(!pt.eq(g.getScale(),[1,1,1]))p.scale=g.getScale();if(g.getWeights().length)p.weights=g.getWeights();return a.nodeIndexMap.set(g,m),p}),r.skins=i.listSkins().map((g,m)=>{let p=a.createPropertyDef(g),b=g.getInverseBindMatrices();if(b)p.inverseBindMatrices=a.accessorIndexMap.get(b);let _=g.getSkeleton();if(_)p.skeleton=a.nodeIndexMap.get(_);return p.joints=g.listJoints().map((x)=>a.nodeIndexMap.get(x)),a.skinIndexMap.set(g,m),p}),i.listNodes().forEach((g,m)=>{let p=r.nodes[m],b=g.getMesh();if(b)p.mesh=a.meshIndexMap.get(b);let _=g.getCamera();if(_)p.camera=a.cameraIndexMap.get(_);let x=g.getSkin();if(x)p.skin=a.skinIndexMap.get(x);if(g.listChildren().length>0)p.children=g.listChildren().map((v)=>a.nodeIndexMap.get(v))}),r.animations=i.listAnimations().map((g,m)=>{let p=a.createPropertyDef(g),b=new Map;return p.samplers=g.listSamplers().map((_,x)=>{let v=a.createPropertyDef(_);return v.input=a.accessorIndexMap.get(_.getInput()),v.output=a.accessorIndexMap.get(_.getOutput()),v.interpolation=_.getInterpolation(),b.set(_,x),v}),p.channels=g.listChannels().map((_)=>{let x=a.createPropertyDef(_);return x.sampler=b.get(_.getSampler()),x.target={node:a.nodeIndexMap.get(_.getTargetNode()),path:_.getTargetPath()},x}),a.animationIndexMap.set(g,m),p}),r.scenes=i.listScenes().map((g,m)=>{let p=a.createPropertyDef(g);return p.nodes=g.listChildren().map((b)=>a.nodeIndexMap.get(b)),a.sceneIndexMap.set(g,m),p});let y=i.getDefaultScene();if(y)r.scene=i.listScenes().indexOf(y);return r.extensionsUsed=l.map((g)=>g.extensionName),r.extensionsRequired=u.map((g)=>g.extensionName),l.forEach((g)=>g.write(a)),P8(r),s}},O8=class{_logger=Ia.DEFAULT_INSTANCE;_extensions=new Set;_dependencies={};_vertexLayout="interleaved";_strictResources=!0;lastReadBytes=0;lastWriteBytes=0;setLogger(e){return this._logger=e,this}registerExtensions(e){for(let t of e)this._extensions.add(t),t.register();return this}registerDependencies(e){return Object.assign(this._dependencies,e),this}setVertexLayout(e){return this._vertexLayout=e,this}setStrictResources(e){return this._strictResources=e,this}async read(e){return await this.readJSON(await this.readAsJSON(e))}async readAsJSON(e){let t=await this.readURI(e,"view");this.lastReadBytes=t.byteLength;let n=bS(t)?this._binaryToJSON(t):{json:JSON.parse(Je.decodeText(t)),resources:{}};return await this._readResourcesExternal(n,this.dirname(e)),this._readResourcesInternal(n),n}async readJSON(e){return e=this._copyJSON(e),this._readResourcesInternal(e),T8.read(e,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(e){let t=this._binaryToJSON(Je.assertView(e));this._readResourcesInternal(t);let n=t.json;if(n.buffers&&n.buffers.some((i)=>k8(t,i)))throw Error("Cannot resolve external buffers with binaryToJSON().");else if(n.images&&n.images.some((i)=>D8(t,i)))throw Error("Cannot resolve external images with binaryToJSON().");return t}async readBinary(e){return this.readJSON(await this.binaryToJSON(Je.assertView(e)))}async writeJSON(e,t={}){if(t.format==="GLB"&&e.getRoot().listBuffers().length>1)throw Error("GLB must have 0–1 buffers.");return N8.write(e,{format:t.format||"GLTF",basename:t.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:{...this._dependencies},extensions:Array.from(this._extensions)})}async writeBinary(e){let{json:t,resources:n}=await this.writeJSON(e,{format:"GLB"}),i=new Uint32Array([1179937895,2,12]),r=JSON.stringify(t),s=Je.pad(Je.encodeText(r),32),a=Je.toView(new Uint32Array([s.byteLength,1313821514])),o=Je.concat([a,s]);i[i.length-1]+=o.byteLength;let c=Object.values(n)[0];if(!c||!c.byteLength)return Je.concat([Je.toView(i),o]);let l=Je.pad(c,0),u=Je.toView(new Uint32Array([l.byteLength,5130562])),d=Je.concat([u,l]);return i[i.length-1]+=d.byteLength,Je.concat([Je.toView(i),o,d])}async _readResourcesExternal(e,t){let n=e.json.images||[],i=e.json.buffers||[],r=[...n,...i].map(async(s)=>{let a=s.uri;if(!a||a.match(/data:/))return Promise.resolve();try{e.resources[a]=await this.readURI(this.resolve(t,a),"view"),this.lastReadBytes+=e.resources[a].byteLength}catch(o){if(!this._strictResources&&n.includes(s))this._logger.warn(`Failed to load image URI, "${a}". ${o}`),e.resources[a]=null;else throw o}});await Promise.all(r)}_readResourcesInternal(e){function t(n){if(!n.uri)return;if(n.uri in e.resources){Je.assertView(e.resources[n.uri]);return}if(n.uri.match(/data:/)){let i=`__${TS()}.${Ma.extension(n.uri)}`;e.resources[i]=Je.createBufferFromDataURI(n.uri),n.uri=i}}(e.json.images||[]).forEach((n)=>{if(n.bufferView===void 0&&n.uri===void 0)throw Error("Missing resource URI or buffer view.");t(n)}),(e.json.buffers||[]).forEach(t)}_copyJSON(e){let{images:t,buffers:n}=e.json;if(e={json:{...e.json},resources:{...e.resources}},t)e.json.images=t.map((i)=>({...i}));if(n)e.json.buffers=n.map((i)=>({...i}));return e}_binaryToJSON(e){if(!bS(e))throw Error("Invalid glTF 2.0 binary.");let t=new Uint32Array(e.buffer,e.byteOffset+12,2);if(t[1]!==1313821514)throw Error("Missing required GLB JSON chunk.");let n=20,i=t[0],r=Je.decodeText(Je.toView(e,n,i)),s=JSON.parse(r),a=n+i;if(e.byteLength<=a)return{json:s,resources:{}};let o=new Uint32Array(e.buffer,e.byteOffset+a,2);if(o[1]!==5130562)return{json:s,resources:{}};let c=o[0],l=Je.toView(e,a+8,c);return{json:s,resources:{[ws]:l}}}},RS;var fl=Ft(()=>{dS();ne=function(e){return e.ACCESSOR="Accessor",e.ANIMATION="Animation",e.ANIMATION_CHANNEL="AnimationChannel",e.ANIMATION_SAMPLER="AnimationSampler",e.BUFFER="Buffer",e.CAMERA="Camera",e.MATERIAL="Material",e.MESH="Mesh",e.PRIMITIVE="Primitive",e.PRIMITIVE_TARGET="PrimitiveTarget",e.NODE="Node",e.ROOT="Root",e.SCENE="Scene",e.SKIN="Skin",e.TEXTURE="Texture",e.TEXTURE_INFO="TextureInfo",e}({}),YL=function(e){return e.ARRAY_BUFFER="ARRAY_BUFFER",e.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",e.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",e.OTHER="OTHER",e.SPARSE="SPARSE",e}({}),Ei=function(e){return e[e.R=4096]="R",e[e.G=256]="G",e[e.B=16]="B",e[e.A=1]="A",e}({}),QL=class extends Float32Array{constructor(){super();throw Error("Unsupported typed array instantiation.")}},ul={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5131":typeof Float16Array<"u"?Float16Array:QL,"5126":Float32Array,"5130":Float64Array},ji=class{static impls={"image/jpeg":new e8,"image/png":new t8};static registerFormat(e,t){this.impls[e]=t}static getMimeType(e){for(let t in this.impls)if(this.impls[t].match(e))return t;return null}static getSize(e,t){if(!this.impls[t])return null;return this.impls[t].getSize(e)}static getChannels(e,t){if(!this.impls[t])return null;return this.impls[t].getChannels(e)}static getVRAMByteLength(e,t){if(!this.impls[t])return null;if(this.impls[t].getVRAMByteLength)return this.impls[t].getVRAMByteLength(e);let n=0,i=4,r=this.getSize(e,t);if(!r)return null;while(r[0]>1||r[1]>1)n+=r[0]*r[1]*i,r[0]=Math.max(Math.floor(r[0]/2),1),r[1]=Math.max(Math.floor(r[1]/2),1);return n+=4,n}static mimeTypeToExtension(e){if(e==="image/jpeg")return"jpg";return e.split("/").pop()}static extensionToMimeType(e){if(e==="jpg")return"image/jpeg";if(!e)return"";return`image/${e}`}};pg=typeof Float32Array<"u"?Float32Array:Array;Math.PI/180;180/Math.PI;(function(){var e=i8();return function(t,n,i,r,s,a){var o,c;if(!n)n=3;if(!i)i=0;if(r)c=Math.min(r*n+i,t.length);else c=t.length;for(o=i;o<c;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],s(e,e,a),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2];return t}})();hg=class{static DEFAULT_INIT={};static PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;static dirname(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.substring(0,t+1)}static basename(e){return Ma.basename(new URL(e,fS).pathname)}static extension(e){return Ma.extension(new URL(e,fS).pathname)}static resolve(e,t){if(!this.isRelativePath(t))return t;let n=e.split("/"),i=t.split("/");n.pop();for(let r=0;r<i.length;r++){if(i[r]===".")continue;if(i[r]==="..")n.pop();else n.push(i[r])}return n.join("/")}static isAbsoluteURL(e){return this.PROTOCOL_REGEXP.test(e)}static isRelativePath(e){return!/^(?:[a-zA-Z]+:)?\//.test(e)}};a8=function(e){return e[e.SILENT=4]="SILENT",e[e.ERROR=3]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=1]="INFO",e[e.DEBUG=0]="DEBUG",e}({}),Ia=class e{verbosity;static Verbosity=a8;static DEFAULT_INSTANCE=new e(1);constructor(t){this.verbosity=t}debug(t){if(this.verbosity<=0)console.debug(t)}info(t){if(this.verbosity<=1)console.info(t)}warn(t){if(this.verbosity<=2)console.warn(t)}error(t){if(this.verbosity<=3)console.error(t)}};pS=new Set,y8=new Set,bg=class extends uS{constructor(e,t=""){super(e);this[Tt].name=t,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(e,t){if(Array.isArray(t))t=t.slice();return super.set(e,t)}getName(){return this.get("name")}setName(e){return this.set("name",e)}getExtras(){return this.get("extras")}setExtras(e){return this.set("extras",e)}clone(){return new this.constructor(this.graph).copy(this,Ms)}copy(e,t=Ms){for(let n in this[Tt]){let i=this[Tt][n];if(i instanceof As){if(!this[Ts].has(n))i.dispose()}else if(i instanceof bn||i instanceof Rt)for(let r of i.values())r.dispose();else if(i instanceof dn)for(let r of i.values())r.dispose()}for(let n in e[Tt]){let i=this[Tt][n],r=e[Tt][n];if(r instanceof As)if(this[Ts].has(n))i.getChild().copy(t(r.getChild()),t);else this.setRef(n,t(r.getChild()),r.getAttributes());else if(r instanceof Rt||r instanceof bn)for(let s of r.values())this.addRef(n,t(s.getChild()),s.getAttributes());else if(r instanceof dn)for(let s of r.keys()){let a=r.get(s);this.setRefMap(n,s,t(a.getChild()),a.getAttributes())}else if(wa(r))this[Tt][n]=JSON.parse(JSON.stringify(r));else if(Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r))this[Tt][n]=r.slice();else this[Tt][n]=r}return this}equals(e,t=y8){if(this===e)return!0;if(this.propertyType!==e.propertyType)return!1;for(let n in this[Tt]){if(t.has(n))continue;let i=this[Tt][n],r=e[Tt][n];if(i instanceof As||r instanceof As){if(!d8(i,r))return!1}else if(i instanceof Rt||r instanceof Rt||i instanceof bn||r instanceof bn){if(!f8(i,r))return!1}else if(i instanceof dn||r instanceof dn){if(!h8(i,r))return!1}else if(wa(i)||wa(r)){if(!ES(i,r))return!1}else if(Ld(i)||Ld(r)){if(!vS(i,r))return!1}else if(i!==r)return!1}return!0}detach(){return this.graph.disconnectParents(this,(e)=>e.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}},jn=class extends bg{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new dn})}getExtension(e){return this.getRefMap("extensions",e)}setExtension(e,t){if(t)t._validateParent(this);return this.setRefMap("extensions",e,t)}listExtensions(){return this.listRefMapValues("extensions")}},Be=class e extends jn{static Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};static ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126,FLOAT16:5131,FLOAT64:5130};init(){this.propertyType="Accessor"}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:e.Type.SCALAR,componentType:e.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(t){switch(t){case e.Type.SCALAR:return 1;case e.Type.VEC2:return 2;case e.Type.VEC3:return 3;case e.Type.VEC4:return 4;case e.Type.MAT2:return 4;case e.Type.MAT3:return 9;case e.Type.MAT4:return 16;default:throw Error("Unexpected type: "+t)}}static getComponentSize(t){switch(t){case e.ComponentType.BYTE:case e.ComponentType.UNSIGNED_BYTE:return 1;case e.ComponentType.SHORT:case e.ComponentType.UNSIGNED_SHORT:return 2;case e.ComponentType.UNSIGNED_INT:case e.ComponentType.FLOAT:return 4;case e.ComponentType.FLOAT16:return 2;case e.ComponentType.FLOAT64:return 8;default:throw Error("Unexpected component type: "+t)}}getMinNormalized(t){let n=this.getNormalized(),i=this.getElementSize(),r=this.getComponentType();if(this.getMin(t),n)for(let s=0;s<i;s++)t[s]=pt.decodeNormalizedInt(t[s],r);return t}getMin(t){let n=this.getArray(),i=this.getCount(),r=this.getElementSize();for(let s=0;s<r;s++)t[s]=1/0;for(let s=0;s<i*r;s+=r)for(let a=0;a<r;a++){let o=n[s+a];if(Number.isFinite(o))t[a]=Math.min(t[a],o)}return t}getMaxNormalized(t){let n=this.getNormalized(),i=this.getElementSize(),r=this.getComponentType();if(this.getMax(t),n)for(let s=0;s<i;s++)t[s]=pt.decodeNormalizedInt(t[s],r);return t}getMax(t){let n=this.get("array"),i=this.getCount(),r=this.getElementSize();for(let s=0;s<r;s++)t[s]=-1/0;for(let s=0;s<i*r;s+=r)for(let a=0;a<r;a++){let o=n[s+a];if(Number.isFinite(o))t[a]=Math.max(t[a],o)}return t}getCount(){let t=this.get("array");return t?t.length/this.getElementSize():0}getType(){return this.get("type")}setType(t){return this.set("type",t)}getElementSize(){return e.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(t){return this.set("normalized",t)}getScalar(t){let n=this.getElementSize(),i=this.getComponentType(),r=this.getArray();if(this.getNormalized())return pt.decodeNormalizedInt(r[t*n],i);return r[t*n]}setScalar(t,n){let i=this.getElementSize(),r=this.getComponentType(),s=this.getArray();if(this.getNormalized())s[t*i]=pt.encodeNormalizedInt(n,r);else s[t*i]=n;return this}getElement(t,n){let i=this.getNormalized(),r=this.getElementSize(),s=this.getComponentType(),a=this.getArray();for(let o=0;o<r;o++)if(i)n[o]=pt.decodeNormalizedInt(a[t*r+o],s);else n[o]=a[t*r+o];return n}setElement(t,n){let i=this.getNormalized(),r=this.getElementSize(),s=this.getComponentType(),a=this.getArray();for(let o=0;o<r;o++)if(i)a[t*r+o]=pt.encodeNormalizedInt(n[o],s);else a[t*r+o]=n[o];return this}getSparse(){return this.get("sparse")}setSparse(t){return this.set("sparse",t)}getBuffer(){return this.getRef("buffer")}setBuffer(t){return this.setRef("buffer",t)}getArray(){return this.get("array")}setArray(t){return this.set("componentType",t?x8(t):e.ComponentType.FLOAT),this.set("array",t),this}getByteLength(){let t=this.get("array");return t?t.byteLength:0}};AS=class extends jn{init(){this.propertyType="Animation"}getDefaults(){return Object.assign(super.getDefaults(),{channels:new Rt,samplers:new Rt})}addChannel(e){return this.addRef("channels",e)}removeChannel(e){return this.removeRef("channels",e)}listChannels(){return this.listRefs("channels")}addSampler(e){return this.addRef("samplers",e)}removeSampler(e){return this.removeRef("samplers",e)}listSamplers(){return this.listRefs("samplers")}},Ca=class extends jn{static TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};init(){this.propertyType="AnimationChannel"}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(e){return this.set("targetPath",e)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(e){return this.setRef("targetNode",e)}getSampler(){return this.getRef("sampler")}setSampler(e){return this.setRef("sampler",e)}},dl=class e extends jn{static Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};init(){this.propertyType="AnimationSampler"}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:e.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(t){return this.set("interpolation",t)}getInput(){return this.getRef("input")}setInput(t){return this.setRef("input",t,{usage:"OTHER"})}getOutput(){return this.getRef("output")}setOutput(t){return this.setRef("output",t,{usage:"OTHER"})}},SS=class extends jn{init(){this.propertyType="Buffer"}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(e){return this.set("uri",e)}},Fd=class e extends jn{static Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};init(){this.propertyType="Camera"}getDefaults(){return Object.assign(super.getDefaults(),{type:e.Type.PERSPECTIVE,znear:0.1,zfar:100,aspectRatio:null,yfov:Math.PI*2*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(t){return this.set("type",t)}getZNear(){return this.get("znear")}setZNear(t){return this.set("znear",t)}getZFar(){return this.get("zfar")}setZFar(t){return this.set("zfar",t)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(t){return this.set("aspectRatio",t)}getYFov(){return this.get("yfov")}setYFov(t){return this.set("yfov",t)}getXMag(){return this.get("xmag")}setXMag(t){return this.set("xmag",t)}getYMag(){return this.get("ymag")}setYMag(t){return this.set("ymag",t)}},nt=class extends bg{static EXTENSION_NAME;_validateParent(e){if(!this.parentTypes.includes(e.propertyType))throw Error(`Parent "${e.propertyType}" invalid for child "${this.propertyType}".`)}},At=class e extends jn{static WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};static MagFilter={NEAREST:9728,LINEAR:9729};static MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};init(){this.propertyType="TextureInfo"}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:e.WrapMode.REPEAT,wrapT:e.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(t){return this.set("texCoord",t)}getMagFilter(){return this.get("magFilter")}setMagFilter(t){return this.set("magFilter",t)}getMinFilter(){return this.get("minFilter")}setMinFilter(t){return this.set("minFilter",t)}getWrapS(){return this.get("wrapS")}setWrapS(t){return this.set("wrapS",t)}getWrapT(){return this.get("wrapT")}setWrapT(t){return this.set("wrapT",t)}},{R:Nd,G:Pd,B:Od,A:_8}=Ei,Ra=class e extends jn{static AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};init(){this.propertyType="Material"}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:e.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new At(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new At(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new At(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new At(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new At(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(t){return this.set("doubleSided",t)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(t){let n=this.get("baseColorFactor").slice();return n[3]=t,this.set("baseColorFactor",n)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(t){return this.set("alphaMode",t)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(t){return this.set("alphaCutoff",t)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(t){return this.set("baseColorFactor",t)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(t){return this.setRef("baseColorTexture",t,{channels:Nd|Pd|Od|_8,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(t){return this.set("emissiveFactor",t)}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(t){return this.setRef("emissiveTexture",t,{channels:Nd|Pd|Od,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(t){return this.set("normalScale",t)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(t){return this.setRef("normalTexture",t,{channels:Nd|Pd|Od})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(t){return this.set("occlusionStrength",t)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(t){return this.setRef("occlusionTexture",t,{channels:Nd})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(t){return this.set("roughnessFactor",t)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(t){return this.set("metallicFactor",t)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(t){return this.setRef("metallicRoughnessTexture",t,{channels:Pd|Od})}},yg=class extends jn{init(){this.propertyType="Mesh"}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new Rt})}addPrimitive(e){return this.addRef("primitives",e)}removePrimitive(e){return this.removeRef("primitives",e)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}},Ud=class extends jn{init(){this.propertyType="Node"}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new Rt})}copy(e,t=Ms){if(t===Ms)throw Error("Node cannot be copied.");return super.copy(e,t)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(e){return this.set("translation",e)}setRotation(e){return this.set("rotation",e)}setScale(e){return this.set("scale",e)}getMatrix(){return pt.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(e){let t=this.get("translation").slice(),n=this.get("rotation").slice(),i=this.get("scale").slice();return pt.decompose(e,t,n,i),this.set("translation",t).set("rotation",n).set("scale",i)}getWorldTranslation(){let e=[0,0,0];return pt.decompose(this.getWorldMatrix(),e,[0,0,0,1],[1,1,1]),e}getWorldRotation(){let e=[0,0,0,1];return pt.decompose(this.getWorldMatrix(),[0,0,0],e,[1,1,1]),e}getWorldScale(){let e=[1,1,1];return pt.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],e),e}getWorldMatrix(){let e=[];for(let i=this;i!=null;i=i.getParentNode())e.push(i);let t,n=e.pop().getMatrix();while(t=e.pop())c8(n,n,t.getMatrix());return n}addChild(e){let t=e.getParentNode();if(t)t.removeChild(e);for(let n of e.listParents())if(n.propertyType==="Scene")n.removeChild(e);return this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}getParentNode(){for(let e of this.listParents())if(e.propertyType==="Node")return e;return null}getMesh(){return this.getRef("mesh")}setMesh(e){return this.setRef("mesh",e)}getCamera(){return this.getRef("camera")}setCamera(e){return this.setRef("camera",e)}getSkin(){return this.getRef("skin")}setSkin(e){return this.setRef("skin",e)}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}traverse(e){e(this);for(let t of this.listChildren())t.traverse(e);return this}},Wn=class e extends jn{static Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};init(){this.propertyType="Primitive"}getDefaults(){return Object.assign(super.getDefaults(),{mode:e.Mode.TRIANGLES,material:null,indices:null,attributes:new dn,targets:new Rt})}getIndices(){return this.getRef("indices")}setIndices(t){return this.setRef("indices",t,{usage:"ELEMENT_ARRAY_BUFFER"})}getAttribute(t){return this.getRefMap("attributes",t)}setAttribute(t,n){return this.setRefMap("attributes",t,n,{usage:"ARRAY_BUFFER"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(t){return this.setRef("material",t)}getMode(){return this.get("mode")}setMode(t){return this.set("mode",t)}listTargets(){return this.listRefs("targets")}addTarget(t){return this.addRef("targets",t)}removeTarget(t){return this.removeRef("targets",t)}},xg=class extends bg{init(){this.propertyType="PrimitiveTarget"}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new dn})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:"ARRAY_BUFFER"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}},Bd=class extends jn{init(){this.propertyType="Scene"}getDefaults(){return Object.assign(super.getDefaults(),{children:new Rt})}copy(e,t=Ms){if(t===Ms)throw Error("Scene cannot be copied.");return super.copy(e,t)}addChild(e){let t=e.getParentNode();if(t)t.removeChild(e);return this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}traverse(e){for(let t of this.listChildren())t.traverse(e);return this}},wS=class extends jn{init(){this.propertyType="Skin"}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new Rt})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(e){return this.setRef("skeleton",e)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(e){return this.setRef("inverseBindMatrices",e,{usage:"INVERSE_BIND_MATRICES"})}addJoint(e){return this.addRef("joints",e)}removeJoint(e){return this.removeRef("joints",e)}listJoints(){return this.listRefs("joints")}},zo=class extends jn{init(){this.propertyType="Texture"}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||ji.extensionToMimeType(Ma.extension(this.get("uri")))}setMimeType(e){return this.set("mimeType",e)}getURI(){return this.get("uri")}setURI(e){this.set("uri",e);let t=ji.extensionToMimeType(Ma.extension(e));if(t)this.set("mimeType",t);return this}getImage(){return this.get("image")}setImage(e){return this.set("image",Je.assertView(e))}getSize(){let e=this.get("image");if(!e)return null;return ji.getSize(e,this.getMimeType())}},Rs=class extends jn{_extensions=new Set;init(){this.propertyType="Root"}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${yS}`,version:"2.0"},defaultScene:null,accessors:new Rt,animations:new Rt,buffers:new Rt,cameras:new Rt,materials:new Rt,meshes:new Rt,nodes:new Rt,scenes:new Rt,skins:new Rt,textures:new Rt})}constructor(e){super(e);e.addEventListener("node:create",(t)=>{this._addChildOfRoot(t.target)})}clone(){throw Error("Root cannot be cloned.")}copy(e,t=Ms){if(t===Ms)throw Error("Root cannot be copied.");this.set("asset",{...e.get("asset")}),this.setName(e.getName()),this.setExtras({...e.getExtras()}),this.setDefaultScene(e.getDefaultScene()?t(e.getDefaultScene()):null);for(let n of e.listRefMapKeys("extensions")){let i=e.getExtension(n);this.setExtension(n,t(i))}return this}_addChildOfRoot(e){if(e instanceof Bd)this.addRef("scenes",e);else if(e instanceof Ud)this.addRef("nodes",e);else if(e instanceof Fd)this.addRef("cameras",e);else if(e instanceof wS)this.addRef("skins",e);else if(e instanceof yg)this.addRef("meshes",e);else if(e instanceof Ra)this.addRef("materials",e);else if(e instanceof zo)this.addRef("textures",e);else if(e instanceof AS)this.addRef("animations",e);else if(e instanceof Be)this.addRef("accessors",e);else if(e instanceof SS)this.addRef("buffers",e);return this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter((e)=>e.isRequired())}_enableExtension(e){return this._extensions.add(e),this}_disableExtension(e){return this._extensions.delete(e),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(e){return this.setRef("defaultScene",e)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}},zd=class e{_graph=new dg;_root=new Rs(this._graph);_logger=Ia.DEFAULT_INSTANCE;static _GRAPH_DOCUMENTS=new WeakMap;static fromGraph(t){return e._GRAPH_DOCUMENTS.get(t)||null}constructor(){e._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(t){return this._logger=t,this}clone(){throw Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(t){throw Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...t){let n=t.map((i)=>i.name);for(let i of t)await i(this,{stack:n});return this}hasExtension(t){return this.getRoot().listExtensionsUsed().some((n)=>n.extensionName===t)}createExtension(t){let n=t.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find((i)=>i.extensionName===n)||new t(this)}disposeExtension(t){let n=this.getRoot().listExtensionsUsed().find((i)=>i.extensionName===t);if(n)n.dispose()}createScene(t=""){return new Bd(this._graph,t)}createNode(t=""){return new Ud(this._graph,t)}createCamera(t=""){return new Fd(this._graph,t)}createSkin(t=""){return new wS(this._graph,t)}createMesh(t=""){return new yg(this._graph,t)}createPrimitive(){return new Wn(this._graph)}createPrimitiveTarget(t=""){return new xg(this._graph,t)}createMaterial(t=""){return new Ra(this._graph,t)}createTexture(t=""){return new zo(this._graph,t)}createAnimation(t=""){return new AS(this._graph,t)}createAnimationChannel(t=""){return new Ca(this._graph,t)}createAnimationSampler(t=""){return new dl(this._graph,t)}createAccessor(t="",n=null){if(!n)n=this.getRoot().listBuffers()[0];return new Be(this._graph,t).setBuffer(n)}createBuffer(t=""){return new SS(this._graph,t)}},mS={logger:Ia.DEFAULT_INSTANCE,extensions:[],dependencies:{}},E8=new Set(["Buffer","Texture","Material","Mesh","Primitive","Node","Scene"]);MS=function(e){return e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e}(MS||{}),Ss=class{_doc;jsonDoc;options;static BufferViewTarget=MS;static BufferViewUsage=YL;static USAGE_TO_TARGET={["ARRAY_BUFFER"]:34962,["ELEMENT_ARRAY_BUFFER"]:34963};accessorIndexMap=new Map;animationIndexMap=new Map;bufferIndexMap=new Map;cameraIndexMap=new Map;skinIndexMap=new Map;materialIndexMap=new Map;meshIndexMap=new Map;nodeIndexMap=new Map;imageIndexMap=new Map;textureDefIndexMap=new Map;textureInfoDefMap=new Map;samplerDefIndexMap=new Map;sceneIndexMap=new Map;imageBufferViews=[];otherBufferViews=new Map;otherBufferViewsIndexMap=new Map;extensionData={};bufferURIGenerator;imageURIGenerator;logger;_accessorUsageMap=new Map;accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]);accessorParents=new Map;constructor(e,t,n){this._doc=e,this.jsonDoc=t,this.options=n;let i=e.getRoot(),r=i.listBuffers().length,s=i.listTextures().length;this.bufferURIGenerator=new gS(r>1,()=>n.basename||"buffer"),this.imageURIGenerator=new gS(s>1,(a)=>w8(e,a)||n.basename||"texture"),this.logger=e.getLogger()}createTextureInfoDef(e,t){let n={magFilter:t.getMagFilter()||void 0,minFilter:t.getMinFilter()||void 0,wrapS:t.getWrapS(),wrapT:t.getWrapT()},i=JSON.stringify(n);if(!this.samplerDefIndexMap.has(i))this.samplerDefIndexMap.set(i,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(n);let r={source:this.imageIndexMap.get(e),sampler:this.samplerDefIndexMap.get(i)},s=JSON.stringify(r);if(!this.textureDefIndexMap.has(s))this.textureDefIndexMap.set(s,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(r);let a={index:this.textureDefIndexMap.get(s)};if(t.getTexCoord()!==0)a.texCoord=t.getTexCoord();if(Object.keys(t.getExtras()).length>0)a.extras=t.getExtras();return this.textureInfoDefMap.set(t,a),a}createPropertyDef(e){let t={};if(e.getName())t.name=e.getName();if(Object.keys(e.getExtras()).length>0)t.extras=e.getExtras();return t}createAccessorDef(e){let t=this.createPropertyDef(e);if(t.type=e.getType(),t.componentType=e.getComponentType(),t.count=e.getCount(),this._doc.getGraph().listParentEdges(e).some((n)=>n.getName()==="attributes"&&n.getAttributes().key==="POSITION"||n.getName()==="input"))t.max=e.getMax([]).map(Math.fround),t.min=e.getMin([]).map(Math.fround);if(e.getNormalized())t.normalized=e.getNormalized();return t}createImageData(e,t,n){if(this.options.format==="GLB")this.imageBufferViews.push(t),e.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:t.byteLength});else{let i=ji.mimeTypeToExtension(n.getMimeType());e.uri=this.imageURIGenerator.createURI(n,i),this.assignResourceURI(e.uri,t,!1)}}assignResourceURI(e,t,n){let i=this.jsonDoc.resources;if(!(e in i)){i[e]=t;return}if(t===i[e]){this.logger.warn(`Duplicate resource URI, "${e}".`);return}let r=`Resource URI "${e}" already assigned to different data.`;if(!n){this.logger.warn(r);return}throw Error(r)}getAccessorUsage(e){let t=this._accessorUsageMap.get(e);if(t)return t;if(e.getSparse())return"SPARSE";for(let n of this._doc.getGraph().listParentEdges(e)){let{usage:i}=n.getAttributes();if(i)return i;if(n.getParent().propertyType!=="Root")this.logger.warn(`Missing attribute ".usage" on edge, "${n.getName()}".`)}return"OTHER"}addAccessorToUsageGroup(e,t){let n=this._accessorUsageMap.get(e);if(n&&n!==t)throw Error(`Accessor with usage "${n}" cannot be reused as "${t}".`);return this._accessorUsageMap.set(e,t),this}};({BufferViewUsage:kd}=Ss),{UNSIGNED_INT:M8,UNSIGNED_SHORT:R8,UNSIGNED_BYTE:I8}=Be.ComponentType,C8=new Set(["Accessor","Buffer","Material","Mesh"]);RS=class extends O8{_fetchConfig;constructor(e=hg.DEFAULT_INIT){super();this._fetchConfig=e}async readURI(e,t){let n=await fetch(e,this._fetchConfig);switch(t){case"view":return new Uint8Array(await n.arrayBuffer());case"text":return n.text()}}resolve(e,t){return hg.resolve(e,t)}dirname(e){return hg.dirname(e)}}});function L8(){return{vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null}}class Vo{constructor(e,t,n,i){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,n),this._littleEndian=i,this._offset=0}_nextUint8(){let e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){let e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){let e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){let e=this._dataView.getUint32(this._offset,this._littleEndian),t=this._dataView.getUint32(this._offset+4,this._littleEndian),n=e+4294967296*t;return this._offset+=8,n}_nextInt32(){let e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){let t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t=0){let n=this._offset,i=0;while(this._dataView.getUint8(this._offset)!==t&&i<e)i++,this._offset++;if(i<e)this._offset++;return new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,i)}}function IS(e){return new TextDecoder().decode(e)}function Vd(e){let t=new Uint8Array(e.buffer,e.byteOffset,Hn.length);if(t[0]!==Hn[0]||t[1]!==Hn[1]||t[2]!==Hn[2]||t[3]!==Hn[3]||t[4]!==Hn[4]||t[5]!==Hn[5]||t[6]!==Hn[6]||t[7]!==Hn[7]||t[8]!==Hn[8]||t[9]!==Hn[9]||t[10]!==Hn[10]||t[11]!==Hn[11])throw Error("Missing KTX 2.0 identifier.");let n=L8(),i=17*Uint32Array.BYTES_PER_ELEMENT,r=new Vo(e,Hn.length,i,!0);n.vkFormat=r._nextUint32(),n.typeSize=r._nextUint32(),n.pixelWidth=r._nextUint32(),n.pixelHeight=r._nextUint32(),n.pixelDepth=r._nextUint32(),n.layerCount=r._nextUint32(),n.faceCount=r._nextUint32(),n.levelCount=r._nextUint32(),n.supercompressionScheme=r._nextUint32();let s=r._nextUint32(),a=r._nextUint32(),o=r._nextUint32(),c=r._nextUint32(),l=r._nextUint64(),u=r._nextUint64(),d=Math.max(n.levelCount,1)*3*8,f=new Vo(e,Hn.length+i,d,!0);for(let ie=0,ce=Math.max(n.levelCount,1);ie<ce;ie++)n.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+f._nextUint64(),f._nextUint64()),uncompressedByteLength:f._nextUint64()});let h=new Vo(e,s,a,!0);h._skip(4);let y=h._nextUint16(),g=h._nextUint16(),m=h._nextUint16(),p=h._nextUint16(),b=h._nextUint8(),_=h._nextUint8(),x=h._nextUint8(),v=h._nextUint8(),E=[h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8()],S=[h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8()],A={vendorId:y,descriptorType:g,versionNumber:m,colorModel:b,colorPrimaries:_,transferFunction:x,flags:v,texelBlockDimension:E,bytesPlane:S,samples:[]},P=6,w=4,I=(p/4-P)/w;for(let ie=0;ie<I;ie++){let ce={bitOffset:h._nextUint16(),bitLength:h._nextUint8(),channelType:h._nextUint8(),samplePosition:[h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(ce.channelType&64)ce.sampleLower=h._nextInt32(),ce.sampleUpper=h._nextInt32();else ce.sampleLower=h._nextUint32(),ce.sampleUpper=h._nextUint32();A.samples[ie]=ce}n.dataFormatDescriptor.length=0,n.dataFormatDescriptor.push(A);let F=new Vo(e,o,c,!0);while(F._offset<c){let ie=F._nextUint32(),ce=F._scan(ie),_e=IS(ce);if(n.keyValue[_e]=F._nextUint8Array(ie-ce.byteLength-1),_e.match(/^ktx/i)){let Oe=IS(n.keyValue[_e]);n.keyValue[_e]=Oe.substring(0,Oe.lastIndexOf("\x00"))}let Re=ie%4?4-ie%4:0;F._skip(Re)}if(u<=0)return n;let N=new Vo(e,l,u,!0),U=N._nextUint16(),D=N._nextUint16(),O=N._nextUint32(),K=N._nextUint32(),B=N._nextUint32(),X=N._nextUint32(),q=[];for(let ie=0,ce=Math.max(n.levelCount,1);ie<ce;ie++)q.push({imageFlags:N._nextUint32(),rgbSliceByteOffset:N._nextUint32(),rgbSliceByteLength:N._nextUint32(),alphaSliceByteOffset:N._nextUint32(),alphaSliceByteLength:N._nextUint32()});let le=l+N._offset,de=le+O,Me=de+K,pe=Me+B,J=new Uint8Array(e.buffer,e.byteOffset+le,O),L=new Uint8Array(e.buffer,e.byteOffset+de,K),W=new Uint8Array(e.buffer,e.byteOffset+Me,B),te=new Uint8Array(e.buffer,e.byteOffset+pe,X);return n.globalData={endpointCount:U,selectorCount:D,imageDescs:q,endpointsData:J,selectorsData:L,tablesData:W,extendedData:te},n}var CS=0,NS=163,PS=166,_g=0,OS=123,kS=1000066000,_6,Hn;var DS=Ft(()=>{_6=new Uint8Array([0]),Hn=[171,75,84,88,32,50,48,187,13,10,26,10]});function H8(e,t,n,i){let r=t.createFeatureID().setFeatureCount(i.featureCount);if(i.nullFeatureId!==void 0)r.setNullFeatureID(i.nullFeatureId);if(i.label!==void 0)r.setLabel(i.label);if(i.attribute!==void 0)r.setAttribute(i.attribute);let s=i.texture;if(s!==void 0){let a=G8(t,n,s);r.setTexture(a)}if(i.propertyTable!==void 0){let a=e.getRoot().getExtension(et).listPropertyTables();r.setPropertyTable(a[i.propertyTable])}return r}function G8(e,t,n){let i=e.createFeatureIDTexture(),{json:r}=t.jsonDoc;if(n.channels)i.setChannels(n.channels);if(n.index!==void 0){let s=r.textures[n.index].source;i.setTexture(t.textures[s]),t.setTextureInfo(i.getTextureInfo(),n)}return i}function $8(e,t,n){let i=e.getRoot(),r={featureCount:n.getFeatureCount()};if(n.getNullFeatureID()!=null)r.nullFeatureId=n.getNullFeatureID();if(n.getLabel())r.label=n.getLabel();if(n.getAttribute()!=null)r.attribute=n.getAttribute();if(n.getTexture()){let s=n.getTexture(),a=s.getTexture(),o=s.getTextureInfo();r.texture=t.createTextureInfoDef(a,o);let c=s.getChannels();if(!pt.eq(c,[0]))r.texture.channels=c}if(n.getPropertyTable()){let s=i.getExtension(et),a=n.getPropertyTable();r.propertyTable=s.listPropertyTables().indexOf(a)}return r}function X8(e){if(!e.extensions||!e.extensions.EXT_meshopt_compression)return!1;return!!e.extensions[Xn].fallback}function Z8(e,t,n,i){let{filter:r,bits:s}=i,a={array:e.getArray(),byteStride:e.getElementSize()*e.getComponentSize(),componentType:e.getComponentType(),normalized:e.getNormalized()};if(n!=="ATTRIBUTES")return a;if(r!=="NONE"){let o=e.getNormalized()?Y8(e):new Float32Array(a.array);switch(r){case"EXPONENTIAL":a.byteStride=e.getElementSize()*4,a.componentType=J8,a.normalized=!1,a.array=t.encodeFilterExp(o,e.getCount(),a.byteStride,s);break;case"OCTAHEDRAL":a.byteStride=s>8?8:4,a.componentType=s>8?US:q8,a.normalized=!0,o=e.getElementSize()===3?eF(o):o,a.array=t.encodeFilterOct(o,e.getCount(),a.byteStride,s);break;case"QUATERNION":a.byteStride=8,a.componentType=US,a.normalized=!0,a.array=t.encodeFilterQuat(o,e.getCount(),a.byteStride,s);break;default:throw Error("Invalid filter.")}if(a.min=e.getMin([]),a.max=e.getMax([]),e.getNormalized())a.min=a.min.map((c)=>Ag(c,e.getComponentType())),a.max=a.max.map((c)=>Ag(c,e.getComponentType()));if(a.normalized)a.min=a.min.map((c)=>BS(c,a.componentType)),a.max=a.max.map((c)=>BS(c,a.componentType))}else if(a.byteStride%4)a.array=Q8(a.array,e.getElementSize()),a.byteStride=a.array.byteLength/e.getCount();return a}function Y8(e){let t=e.getComponentType(),n=e.getArray(),i=new Float32Array(n.length);for(let r=0;r<n.length;r++)i[r]=Ag(n[r],t);return i}function Q8(e,t){let n=Je.padNumber(e.BYTES_PER_ELEMENT*t)/e.BYTES_PER_ELEMENT,i=e.length/t,r=new e.constructor(i*n);for(let s=0;s*t<e.length;s++)for(let a=0;a<t;a++)r[s*n+a]=e[s*t+a];return r}function eF(e){let t=new Float32Array(e.length*4/3);for(let n=0,i=e.length/3;n<i;n++)t[n*4]=e[n*3],t[n*4+1]=e[n*3+1],t[n*4+2]=e[n*3+2];return t}function tF(e,t){if(t===Ss.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return e.listParents().some((n)=>n instanceof Wn&&n.getMode()===Wn.Mode.TRIANGLES)?"TRIANGLES":"INDICES";return"ATTRIBUTES"}function nF(e,t){let n=t.getGraph().listParentEdges(e).filter((i)=>!(i.getParent()instanceof Rs));for(let i of n){let r=i.getName(),s=i.getAttributes().key||"",a=i.getParent().propertyType===ne.PRIMITIVE_TARGET;if(r==="indices")return{filter:"NONE"};if(r==="attributes"){if(s==="POSITION")return{filter:"NONE"};if(s==="TEXCOORD_0")return{filter:"NONE"};if(s.startsWith("JOINTS_"))return{filter:"NONE"};if(s.startsWith("WEIGHTS_"))return{filter:"NONE"};if(s==="NORMAL"||s==="TANGENT")return a?{filter:"NONE"}:{filter:"OCTAHEDRAL",bits:8}}if(r==="output"){let o=tw(e);if(o==="rotation")return{filter:"QUATERNION",bits:16};if(o==="translation")return{filter:"EXPONENTIAL",bits:12};if(o==="scale")return{filter:"EXPONENTIAL",bits:12};return{filter:"NONE"}}if(r==="input")return{filter:"NONE"};if(r==="inverseBindMatrices")return{filter:"NONE"}}return{filter:"NONE"}}function tw(e){for(let t of e.listParents()){if(!(t instanceof dl))continue;for(let n of t.listParents()){if(!(n instanceof Ca))continue;return n.getTargetPath()}}return null}function yF(e,t,n){let i=e.createStructuralMetadata();if(n.schema!==void 0){let o=xF(e,n.schema);i.setSchema(o)}else if(n.schemaUri){let o=n.schemaUri;i.setSchemaUri(o)}let r=n.propertyTextures||[];for(let o of r){let c=AF(e,t,o);i.addPropertyTexture(c)}let s=n.propertyTables||[];for(let o of s){let c=wF(e,t,o);i.addPropertyTable(c)}let a=n.propertyAttributes||[];for(let o of a){let c=RF(e,o);i.addPropertyAttribute(c)}return i}function xF(e,t){let n=e.createSchema().setId(t.id);if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.version!==void 0)n.setVersion(t.version);let i=t.classes||{};for(let s of Object.keys(i)){let a=i[s];n.setClass(s,_F(e,a))}let r=t.enums||{};for(let s of Object.keys(r))n.setEnum(s,EF(e,r[s]));return n}function _F(e,t){let n=e.createClass();if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);let i=t.properties||{};for(let r of Object.keys(i)){let s=vF(e,i[r]);n.setProperty(r,s)}return n}function vF(e,t){let n=e.createClassProperty().setType(t.type);if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.componentType!==void 0)n.setComponentType(t.componentType);if(t.enumType!==void 0)n.setEnumType(t.enumType);if(t.array!==void 0)n.setArray(t.array);if(t.count!==void 0)n.setCount(t.count);if(t.normalized!==void 0)n.setNormalized(t.normalized);if(t.offset!==void 0)n.setOffset(t.offset);if(t.scale!==void 0)n.setScale(t.scale);if(t.max!==void 0)n.setMax(t.max);if(t.min!==void 0)n.setMin(t.min);if(t.required!==void 0)n.setRequired(t.required);if(t.noData!==void 0)n.setNoData(t.noData);if(t.default!==void 0)n.setDefault(t.default);return n}function EF(e,t){let n=e.createEnum();if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.valueType!==void 0)n.setValueType(t.valueType);let i=t.values||{};for(let r of i)n.addEnumValue(TF(e,r));return n}function TF(e,t){let n=e.createEnumValue();if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.value!==void 0)n.setValue(t.value);return n}function AF(e,t,n){let i=e.createPropertyTexture();if(i.setClass(n.class),n.name!==void 0)i.setName(n.name);let r=n.properties||{};for(let s of Object.keys(r)){let a=SF(e,t,r[s]);i.setProperty(s,a)}return i}function SF(e,t,n){let i=e.createPropertyTextureProperty(),r=t.jsonDoc.json.textures||[];if(n.channels)i.setChannels(n.channels);let s=r[n.index].source;if(s!==void 0){let a=t.textures[s];i.setTexture(a);let o=i.getTextureInfo();if(o)t.setTextureInfo(o,n)}if(n.offset!==void 0)i.setOffset(n.offset);if(n.scale!==void 0)i.setScale(n.scale);if(n.max!==void 0)i.setMax(n.max);if(n.min!==void 0)i.setMin(n.min);return i}function wF(e,t,n){let i=e.createPropertyTable().setClass(n.class).setCount(n.count);if(n.name!==void 0)i.setName(n.name);let r=n.properties||{};for(let s of Object.keys(r)){let a=MF(e,t,r[s]);i.setProperty(s,a)}return i}function MF(e,t,n){let i=e.createPropertyTableProperty(),r=vg(t,n.values);if(i.setValues(r),n.arrayOffsets!==void 0){let s=vg(t,n.arrayOffsets);i.setArrayOffsets(s)}if(n.stringOffsets!==void 0){let s=vg(t,n.stringOffsets);i.setStringOffsets(s)}if(n.arrayOffsetType!==void 0)i.setArrayOffsetType(n.arrayOffsetType);if(n.stringOffsetType!==void 0)i.setStringOffsetType(n.stringOffsetType);if(n.offset!==void 0)i.setOffset(n.offset);if(n.scale!==void 0)i.setScale(n.scale);if(n.max!==void 0)i.setMax(n.max);if(n.min!==void 0)i.setMin(n.min);return i}function RF(e,t){let n=e.createPropertyAttribute();if(n.setClass(t.class),t.name!==void 0)n.setName(t.name);let i=t.properties||{};for(let r of Object.keys(i)){let s=IF(e,i[r]);n.setProperty(r,s)}return n}function IF(e,t){let n=e.createPropertyAttributeProperty();if(n.setAttribute(t.attribute),t.offset!==void 0)n.setOffset(t.offset);if(t.scale!==void 0)n.setScale(t.scale);if(t.max!==void 0)n.setMax(t.max);if(t.min!==void 0)n.setMin(t.min);return n}function CF(e,t){let n={},i=t.getSchema();if(i)n.schema=NF(i);let r=t.getSchemaUri();if(r)n.schemaUri=r;let s=t.listPropertyTables();if(s.length>0){let c=[];for(let l of s){let u=LF(e,l);c.push(u)}n.propertyTables=c}let a=t.listPropertyTextures();if(a.length>0){let c=[];for(let l of a){let u=zF(e,l);c.push(u)}n.propertyTextures=c}let o=t.listPropertyAttributes();if(o.length>0){let c=[];for(let l of o){let u=UF(l);c.push(u)}n.propertyAttributes=c}return n}function NF(e){let t={id:e.getId()},n=e.listClassKeys();if(n.length>0){t.classes={};for(let r of n){let s=PF(e.getClass(r));t.classes[r]=s}}let i=e.listEnumKeys();if(i.length>0){t.enums={};for(let r of i){let s=kF(e.getEnum(r));t.enums[r]=s}}if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();if(e.getVersion())t.version=e.getVersion();return t}function PF(e){let t={},n=e.listPropertyKeys();if(n.length>0){t.properties={};for(let i of n){let r=e.getProperty(i);t.properties[i]=OF(r)}}if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();return t}function OF(e){let t={type:e.getType()};if(e.getArray())t.array=e.getArray();if(e.getNormalized())t.normalized=e.getNormalized();if(e.getRequired())t.required=e.getRequired();if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();if(e.getComponentType()!=null)t.componentType=e.getComponentType();if(e.getEnumType()!=null)t.enumType=e.getEnumType();if(e.getCount()!=null)t.count=e.getCount();if(e.getOffset()!=null)t.offset=e.getOffset();if(e.getScale()!=null)t.scale=e.getScale();if(e.getMax()!=null)t.max=e.getMax();if(e.getMin()!=null)t.min=e.getMin();if(e.getNoData()!=null)t.noData=e.getNoData();if(e.getDefault()!=null)t.default=e.getDefault();return t}function kF(e){let t={values:e.listValues().map(DF)};if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();if(e.getValueType()!=="UINT16")t.valueType=e.getValueType();return t}function DF(e){let t={name:e.getName(),value:e.getValue()};if(e.getDescription())t.description=e.getDescription();return t}function LF(e,t){let n={class:t.getClass(),count:t.getCount()};if(t.getName())n.name=t.getName();let i=t.listPropertyKeys();if(i.length>0){n.properties={};for(let r of i){let s=FF(e,t.getProperty(r));n.properties[r]=s}}return n}function FF(e,t){let n=t.getValues(),i={values:e.otherBufferViewsIndexMap.get(n)};if(t.getArrayOffsets()){let r=t.getArrayOffsets();i.arrayOffsets=e.otherBufferViewsIndexMap.get(r)}if(t.getStringOffsets()){let r=t.getStringOffsets();i.stringOffsets=e.otherBufferViewsIndexMap.get(r)}if(t.getArrayOffsetType()!=null)i.arrayOffsetType=t.getArrayOffsetType();if(t.getStringOffsetType()!=null)i.stringOffsetType=t.getStringOffsetType();if(t.getOffset()!=null)i.offset=t.getOffset();if(t.getScale()!=null)i.scale=t.getScale();if(t.getMax()!=null)i.max=t.getMax();if(t.getMin()!=null)i.min=t.getMin();return i}function UF(e){let t={class:e.getClass()};if(e.getName())t.name=e.getName();let n=e.listPropertyKeys();if(n.length>0){t.properties={};for(let i of n){let r=BF(e.getProperty(i));t.properties[i]=r}}return t}function BF(e){let t={attribute:e.getAttribute()};if(e.getOffset()!=null)t.offset=e.getOffset();if(e.getScale()!=null)t.scale=e.getScale();if(e.getMax()!=null)t.max=e.getMax();if(e.getMin()!=null)t.min=e.getMin();return t}function zF(e,t){let n={class:t.getClass()};if(t.getName())n.name=t.getName();let i=t.listPropertyKeys();if(i.length>0){n.properties={};for(let r of i){let s=VF(e,t.getProperty(r));n.properties[r]=s}}return n}function VF(e,t){let n=t.getTexture(),i=t.getTextureInfo(),r=t.getChannels(),s=e.createTextureInfoDef(n,i);if(!pt.eq(r,[0]))s.channels=r;if(t.getOffset()!=null)s.offset=t.getOffset();if(t.getScale()!=null)s.scale=t.getScale();if(t.getMax()!=null)s.max=t.getMax();if(t.getMin()!=null)s.min=t.getMin();return s}function vg(e,t){let n=e.jsonDoc,i=n.json.buffers||[],r=(n.json.bufferViews||[])[t],s=i[r.buffer],a=s.uri?n.resources[s.uri]:n.resources[ws],o=r.byteOffset||0,c=r.byteLength;return a.slice(o,o+c)}function jF(e,t){let n=e.getRoot().listBuffers()[0],i=t.otherBufferViews.get(n);if(!i)i=[],t.otherBufferViews.set(n,i);return i}function VS(e,t){if(e.byteLength<4+t)return null;let n=e.getUint32(t);if(e.byteLength<n+t||n<8)return null;return{type:Je.decodeText(new Uint8Array(e.buffer,e.byteOffset+t+4,4)),start:t+8,end:t+n}}function WF(e,t){let n=new yn.DecoderBuffer;try{if(n.Init(t,t.length),e.GetEncodedGeometryType(n)!==yn.TRIANGULAR_MESH)throw Error(`[${en}] Unknown geometry type.`);let i=new yn.Mesh;if(!e.DecodeBufferToMesh(n,i).ok()||i.ptr===0)throw Error(`[${en}] Decoding failure.`);return i}finally{yn.destroy(n)}}function XF(e,t){let n=t.num_faces()*3,i,r;if(t.num_points()<=65534){let s=n*Uint16Array.BYTES_PER_ELEMENT;i=yn._malloc(s),e.GetTrianglesUInt16Array(t,s,i),r=new Uint16Array(yn.HEAPU16.buffer,i,n).slice()}else{let s=n*Uint32Array.BYTES_PER_ELEMENT;i=yn._malloc(s),e.GetTrianglesUInt32Array(t,s,i),r=new Uint32Array(yn.HEAPU32.buffer,i,n).slice()}return yn._free(i),r}function qF(e,t,n,i){let r=sw[i.componentType],s=rw[i.componentType],a=n.num_components(),o=t.num_points()*a,c=o*s.BYTES_PER_ELEMENT,l=yn._malloc(c);e.GetAttributeDataArrayForAllPoints(t,n,r,c,l);let u=new s(yn.HEAPF32.buffer,l,o).slice();return yn._free(l),u}function JF(e){yn=e,rw={[Be.ComponentType.FLOAT]:Float32Array,[Be.ComponentType.UNSIGNED_INT]:Uint32Array,[Be.ComponentType.UNSIGNED_SHORT]:Uint16Array,[Be.ComponentType.UNSIGNED_BYTE]:Uint8Array,[Be.ComponentType.SHORT]:Int16Array,[Be.ComponentType.BYTE]:Int8Array},sw={[Be.ComponentType.FLOAT]:yn.DT_FLOAT32,[Be.ComponentType.UNSIGNED_INT]:yn.DT_UINT32,[Be.ComponentType.UNSIGNED_SHORT]:yn.DT_UINT16,[Be.ComponentType.UNSIGNED_BYTE]:yn.DT_UINT8,[Be.ComponentType.SHORT]:yn.DT_INT16,[Be.ComponentType.BYTE]:yn.DT_INT8}}function YF(e){Ti=e}function QF(e,t=GS){let n={...GS,...t};n.quantizationBits={...aw,...t.quantizationBits};let i=new Ti.MeshBuilder,r=new Ti.Mesh,s=new Ti.ExpertEncoder(r),a={},o=new Ti.DracoInt8Array,c=e.listTargets().length>0,l=!1;for(let g of e.listSemantics()){let m=e.getAttribute(g);if(m.getSparse()){l=!0;continue}let p=e2(g),b=t2(i,m.getComponentType(),r,Ti[p],m.getCount(),m.getElementSize(),m.getArray());if(b===-1)throw Error(`Error compressing "${g}" attribute.`);if(a[g]=b,n.quantizationVolume==="mesh"||g!=="POSITION")s.SetAttributeQuantization(b,n.quantizationBits[p]);else if(typeof n.quantizationVolume==="object"){let{quantizationVolume:_}=n,x=Math.max(_.max[0]-_.min[0],_.max[1]-_.min[1],_.max[2]-_.min[2]);s.SetAttributeExplicitQuantization(b,n.quantizationBits[p],m.getElementSize(),_.min,x)}else throw Error("Invalid quantization volume state.")}let u=e.getIndices();if(!u)throw new Sg("Primitive must have indices.");if(i.AddFacesToMesh(r,u.getCount()/3,u.getArray()),s.SetSpeedOptions(n.encodeSpeed,n.decodeSpeed),s.SetTrackEncodedProperties(!0),n.method===0||c||l)s.SetEncodingMethod(Ti.MESH_SEQUENTIAL_ENCODING);else s.SetEncodingMethod(Ti.MESH_EDGEBREAKER_ENCODING);let d=s.EncodeToDracoBuffer(!(c||l),o);if(d<=0)throw new Sg("Error applying Draco compression.");let f=new Uint8Array(d);for(let g=0;g<d;++g)f[g]=o.GetValue(g);let h=s.GetNumberOfEncodedPoints(),y=s.GetNumberOfEncodedFaces()*3;return Ti.destroy(o),Ti.destroy(r),Ti.destroy(i),Ti.destroy(s),{numVertices:h,numIndices:y,data:f,attributeIDs:a}}function e2(e){if(e==="POSITION")return"POSITION";else if(e==="NORMAL")return"NORMAL";else if(e.startsWith("COLOR_"))return"COLOR";else if(e.startsWith("TEXCOORD_"))return"TEX_COORD";return"GENERIC"}function t2(e,t,n,i,r,s,a){switch(t){case Be.ComponentType.UNSIGNED_BYTE:return e.AddUInt8Attribute(n,i,r,s,a);case Be.ComponentType.BYTE:return e.AddInt8Attribute(n,i,r,s,a);case Be.ComponentType.UNSIGNED_SHORT:return e.AddUInt16Attribute(n,i,r,s,a);case Be.ComponentType.SHORT:return e.AddInt16Attribute(n,i,r,s,a);case Be.ComponentType.UNSIGNED_INT:return e.AddUInt32Attribute(n,i,r,s,a);case Be.ComponentType.FLOAT:return e.AddFloatAttribute(n,i,r,s,a);default:throw Error(`Unexpected component type, "${t}".`)}}function n2(e){let t=e.getLogger(),n=new Set,i=new Set,r=0,s=0;for(let d of e.getRoot().listMeshes())for(let f of d.listPrimitives())if(!f.getIndices())i.add(f),r++;else if(f.getMode()!==Wn.Mode.TRIANGLES)i.add(f),s++;else n.add(f);if(r>0)t.warn(`[${en}] Skipping Draco compression of ${r} non-indexed primitives.`);if(s>0)t.warn(`[${en}] Skipping Draco compression of ${s} non-TRIANGLES primitives.`);let a=e.getRoot().listAccessors(),o=new Map;for(let d=0;d<a.length;d++)o.set(a[d],d);let c=new Map,l=new Set,u=new Map;for(let d of Array.from(n)){let f=$S(d,o);if(l.has(f)){u.set(d,f);continue}if(c.has(d.getIndices())){let h=d.getIndices(),y=h.clone();o.set(y,e.getRoot().listAccessors().length-1),d.swap(h,y)}for(let h of d.listAttributes())if(c.has(h)){let y=h.clone();o.set(y,e.getRoot().listAccessors().length-1),d.swap(h,y)}f=$S(d,o),l.add(f),u.set(d,f),c.set(d.getIndices(),f);for(let h of d.listAttributes())c.set(h,f)}for(let d of Array.from(c.keys())){let f=new Set(d.listParents().map((h)=>h.propertyType));if(f.size!==2||!f.has(ne.PRIMITIVE)||!f.has(ne.ROOT))throw Error(`[${en}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let d of Array.from(n)){let f=u.get(d),h=d.getIndices();if(c.get(h)!==f||d.listAttributes().some((y)=>c.get(y)!==f))throw Error(`[${en}] Draco primitives must share all, or no, accessors.`)}for(let d of Array.from(i)){let f=d.getIndices();if(c.has(f)||d.listAttributes().some((h)=>c.has(h)))throw Error(`[${en}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return u}function $S(e,t){let n=[],i=e.getIndices();n.push(t.get(i));for(let r of e.listAttributes())n.push(t.get(r));return n.sort().join("|")}function Z2(e){return e.vkFormat>_g&&e.vkFormat<=OS}function ew(e){let t=e.vkFormat===kS&&e.dataFormatDescriptor[0].colorModel===167;return e.vkFormat===_g||t}function Eg(e){return JSON.parse(JSON.stringify(e))}var Is="EXT_mesh_gpu_instancing",jr="EXT_mesh_features",Xn="EXT_meshopt_compression",et="EXT_structural_metadata",jd="EXT_texture_webp",Hd="EXT_texture_avif",F8="KHR_accessor_float16",U8="KHR_accessor_float64",en="KHR_draco_mesh_compression",Vr="KHR_lights_punctual",Cs="KHR_materials_anisotropy",Ns="KHR_materials_clearcoat",Ps="KHR_materials_diffuse_transmission",Os="KHR_materials_dispersion",ks="KHR_materials_emissive_strength",Ds="KHR_materials_ior",Ls="KHR_materials_iridescence",Fs="KHR_materials_pbrSpecularGlossiness",Us="KHR_materials_sheen",Bs="KHR_materials_specular",zs="KHR_materials_transmission",jo="KHR_materials_unlit",Vs="KHR_materials_volume",ui="KHR_materials_variants",LS="KHR_mesh_primitive_restart",FS="KHR_mesh_quantization",js="KHR_node_visibility",Gd="KHR_texture_basisu",Hs="KHR_texture_transform",Hi="KHR_xmp_json_ld",B8,z8,V8,hl,j8,Tg="INSTANCE_ATTRIBUTE",K8,$d,W8,q8,US,J8,BS,Ag,zS,pl,iF,rF,sF,aF,oF,cF,lF,uF,dF,fF,hF,pF,mF,gF,bF,HF=class{match(e){return e.length>=12&&Je.decodeText(e.slice(4,12))==="ftypavif"}getSize(e){if(!this.match(e))return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=VS(t,0);if(!n)return null;let i=n.end;while(n=VS(t,i))if(n.type==="meta")i=n.start+4;else if(n.type==="iprp"||n.type==="ipco")i=n.start;else if(n.type==="ispe")return[t.getUint32(n.start+4),t.getUint32(n.start+8)];else if(n.type==="mdat")break;else i=n.end;return null}getChannels(e){return 4}},nw,GF=class{match(e){return e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80}getSize(e){let t=Je.decodeText(e.slice(0,4)),n=Je.decodeText(e.slice(8,12));if(t!=="RIFF"||n!=="WEBP")return null;let i=new DataView(e.buffer,e.byteOffset),r=12;while(r<i.byteLength){let s=Je.decodeText(new Uint8Array([i.getUint8(r),i.getUint8(r+1),i.getUint8(r+2),i.getUint8(r+3)])),a=i.getUint32(r+4,!0);if(s==="VP8 ")return[i.getInt16(r+14,!0)&16383,i.getInt16(r+16,!0)&16383];else if(s==="VP8L"){let o=i.getUint8(r+9),c=i.getUint8(r+10),l=i.getUint8(r+11),u=i.getUint8(r+12);return[1+((c&63)<<8|o),1+((u&15)<<10|l<<2|(c&192)>>6)]}r+=8+a+a%2}return null}getChannels(e){return 4}},iw,jS,$F,HS,KF,yn,rw,sw,Ti,ZF,aw,GS,Sg,ow,KS,i2,r2,s2,a2,o2,c2,WS,XS,l2,u2,d2,f2,h2,p2,m2,g2,b2,y2,x2,_2,v2,E2,cw,T2,A2,S2,w2,qS,JS,ZS,YS,M2,lw,R2,I2,C2,N2,P2,O2,k2,D2,L2,F2,U2,uw,B2,z2,V2,j2,dw,H2,G2,QS,$2,K2,W2,X2,fw,wg,q2,J2,Y2=class{match(e){return e[0]===171&&e[1]===75&&e[2]===84&&e[3]===88&&e[4]===32&&e[5]===50&&e[6]===48&&e[7]===187&&e[8]===13&&e[9]===10&&e[10]===26&&e[11]===10}getSize(e){let t=Vd(e);return[t.pixelWidth,t.pixelHeight]}getChannels(e){let t=Vd(e),n=t.dataFormatDescriptor[0];if(Z2(t))return n.samples.length;if(ew(t))switch(n.colorModel){case NS:return n.samples.length===2&&(n.samples[1].channelType&15)===15?4:3;case PS:return(n.samples[0].channelType&15)===3?4:3;default:throw Error(`Unexpected KTX2 colorModel, "${n.colorModel}".`)}throw Error(`Unexpected KTX2 vkFormat, "${t.vkFormat}".`)}getVRAMByteLength(e){let t=Vd(e),n=0;if(ew(t)){let i=this.getChannels(e)>3;for(let r=0;r<t.levels.length;r++){let s=t.levels[r];if(s.uncompressedByteLength)n+=s.uncompressedByteLength;else{let a=Math.max(1,Math.floor(t.pixelWidth/Math.pow(2,r))),o=Math.max(1,Math.floor(t.pixelHeight/Math.pow(2,r))),c=i?16:8;n+=a/4*(o/4)*c}}}else for(let i of t.levels)if(t.supercompressionScheme===CS)n+=i.levelData.byteLength;else n+=i.uncompressedByteLength;return n}},Mg,Q2,eU,tU,nU,iU,rU,hw;var Kd=Ft(()=>{fl();DS();B8=class extends nt{static EXTENSION_NAME=jr;init(){this.extensionName=jr,this.propertyType="FeatureID",this.parentTypes=["Features"]}getDefaults(){return Object.assign(super.getDefaults(),{nullFeatureId:null,label:"",attribute:null,texture:null,propertyTable:null})}getFeatureCount(){return this.get("featureCount")}setFeatureCount(e){return this.set("featureCount",e)}getNullFeatureID(){return this.get("nullFeatureId")}setNullFeatureID(e){return this.set("nullFeatureId",e)}getLabel(){return this.get("label")}setLabel(e){return this.set("label",e)}getAttribute(){return this.get("attribute")}setAttribute(e){return this.set("attribute",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getPropertyTable(){return this.getRef("propertyTable")}setPropertyTable(e){return this.setRef("propertyTable",e)}},z8=class extends nt{static EXTENSION_NAME=jr;init(){this.extensionName=jr,this.propertyType="FeatureIDTexture",this.parentTypes=["FeatureID"]}getDefaults(){let e=new At(this.graph,"textureInfo");return e.setMinFilter(At.MagFilter.NEAREST),e.setMagFilter(At.MagFilter.NEAREST),Object.assign(super.getDefaults(),{channels:[0],texture:null,textureInfo:e})}getChannels(){return this.get("channels")}setChannels(e){return this.set("channels",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getTextureInfo(){return this.getRef("texture")?this.getRef("textureInfo"):null}},V8=class extends nt{static EXTENSION_NAME=jr;init(){this.extensionName=jr,this.propertyType="Features",this.parentTypes=[ne.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{featureIds:new Rt([])})}listFeatureIDs(){return this.listRefs("featureIds")}addFeatureID(e){return this.addRef("featureIds",e)}removeFeatureID(e){return this.removeRef("featureIds",e)}},hl=jr,j8=class extends xt{extensionName=jr;static EXTENSION_NAME=jr;createFeatures(){return new V8(this.document.getGraph())}createFeatureID(){return new B8(this.document.getGraph())}createFeatureIDTexture(){return new z8(this.document.getGraph())}read(e){return(e.jsonDoc.json.meshes||[]).forEach((t,n)=>{(t.primitives||[]).forEach((i,r)=>{this._readPrimitive(e,n,i,r)})}),this}_readPrimitive(e,t,n,i){if(!n.extensions||!n.extensions[hl])return;let r=this.createFeatures(),s=n.extensions[hl];for(let a of s.featureIds){let o=H8(this.document,this,e,a);r.addFeatureID(o)}e.meshes[t].listPrimitives()[i].setExtension(hl,r)}write(e){let t=e.jsonDoc.json.meshes;if(!t)return this;for(let n of this.document.getRoot().listMeshes()){let i=t[e.meshIndexMap.get(n)];n.listPrimitives().forEach((r,s)=>{let a=i.primitives[s];this._writePrimitive(e,r,a)})}return this}_writePrimitive(e,t,n){let i=t.getExtension(hl);if(!i)return;let r={featureIds:[]};i.listFeatureIDs().forEach((s)=>{r.featureIds.push($8(this.document,e,s))}),n.extensions=n.extensions||{},n.extensions[hl]=r}};K8=class extends nt{static EXTENSION_NAME=Is;init(){this.extensionName=Is,this.propertyType="InstancedMesh",this.parentTypes=[ne.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new dn})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:Tg})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}},$d=class extends xt{static EXTENSION_NAME=Is;extensionName=Is;prewriteTypes=[ne.ACCESSOR];createInstancedMesh(){return new K8(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,n)=>{if(!t.extensions||!t.extensions.EXT_mesh_gpu_instancing)return;let i=t.extensions[Is],r=this.createInstancedMesh();for(let s in i.attributes)r.setAttribute(s,e.accessors[i.attributes[s]]);e.nodes[n].setExtension(Is,r)}),this}prewrite(e){e.accessorUsageGroupedByParent.add(Tg);for(let t of this.properties)for(let n of t.listAttributes())e.addAccessorToUsageGroup(n,Tg);return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listNodes().forEach((n)=>{let i=n.getExtension(Is);if(i){let r=e.nodeIndexMap.get(n),s=t.json.nodes[r],a={attributes:{}};i.listSemantics().forEach((o)=>{let c=i.getAttribute(o);a.attributes[o]=e.accessorIndexMap.get(c)}),s.extensions=s.extensions||{},s.extensions[Is]=a}}),this}},W8=function(e){return e.QUANTIZE="quantize",e.FILTER="filter",e}({});({BYTE:q8,SHORT:US,FLOAT:J8}=Be.ComponentType),{encodeNormalizedInt:BS,decodeNormalizedInt:Ag}=pt;zS={method:"quantize"},pl=class extends xt{extensionName=Xn;prereadTypes=[ne.BUFFER,ne.PRIMITIVE];prewriteTypes=[ne.BUFFER,ne.ACCESSOR];readDependencies=["meshopt.decoder"];writeDependencies=["meshopt.encoder"];static EXTENSION_NAME=Xn;static EncoderMethod=W8;_decoder=null;_decoderFallbackBufferMap=new Map;_encoder=null;_encoderOptions=zS;_encoderFallbackBuffer=null;_encoderBufferViews={};_encoderBufferViewData={};_encoderBufferViewAccessors={};install(e,t){if(e==="meshopt.decoder")this._decoder=t;if(e==="meshopt.encoder")this._encoder=t;return this}setEncoderOptions(e){return this._encoderOptions={...zS,...e},this}preread(e,t){if(!this._decoder){if(!this.isRequired())return this;throw Error(`[${Xn}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw Error(`[${Xn}]: Missing WASM support.`)}if(t===ne.BUFFER)this._prereadBuffers(e);else if(t===ne.PRIMITIVE)this._prereadPrimitives(e);return this}_prereadBuffers(e){let t=e.jsonDoc;(t.json.bufferViews||[]).forEach((n,i)=>{if(!n.extensions||!n.extensions.EXT_meshopt_compression)return;let r=n.extensions[Xn],s=r.byteOffset||0,a=r.byteLength||0,{count:o,byteStride:c}=r,l=new Uint8Array(o*c),u=t.json.buffers[r.buffer],d=u.uri?t.resources[u.uri]:t.resources[ws],f=Je.toView(d,s,a);this._decoder.decodeGltfBuffer(l,o,c,f,r.mode,r.filter),e.bufferViews[i]=l})}_prereadPrimitives(e){let t=e.jsonDoc;(t.json.bufferViews||[]).forEach((n)=>{if(!n.extensions||!n.extensions.EXT_meshopt_compression)return;let i=n.extensions[Xn],r=e.buffers[i.buffer],s=e.buffers[n.buffer],a=t.json.buffers[n.buffer];if(X8(a))this._decoderFallbackBufferMap.set(s,r)})}read(e){if(!this.isRequired())return this;for(let[t,n]of this._decoderFallbackBufferMap){for(let i of t.listParents())if(i instanceof Be)i.swap(t,n);t.dispose()}return this}prewrite(e,t){if(t===ne.ACCESSOR)this._prewriteAccessors(e);else if(t===ne.BUFFER)this._prewriteBuffers(e);return this}_prewriteAccessors(e){let t=e.jsonDoc.json,n=this._encoder,i=this._encoderOptions,r=this.document.getGraph(),s=this.document.createBuffer(),a=this.document.getRoot().listBuffers().indexOf(s),o=1,c=new Map,l=(u)=>{for(let d of r.listParents(u)){if(d.propertyType===ne.ROOT)continue;let f=c.get(u);if(f===void 0)c.set(u,f=o++);return f}return-1};this._encoderFallbackBuffer=s,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let u of this.document.getRoot().listAccessors()){if(tw(u)==="weights")continue;if(u.getSparse())continue;let d=e.getAccessorUsage(u),f=e.accessorUsageGroupedByParent.has(d)?l(u):null,h=tF(u,d),y=i.method==="filter"?nF(u,this.document):{filter:"NONE"},g=Z8(u,n,h,y),{array:m,byteStride:p}=g,b=u.getBuffer();if(!b)throw Error(`${Xn}: Missing buffer for accessor.`);let _=this.document.getRoot().listBuffers().indexOf(b),x=[d,f,h,y.filter,p,_].join(":"),v=this._encoderBufferViews[x],E=this._encoderBufferViewData[x],S=this._encoderBufferViewAccessors[x];if(!v||!E)S=this._encoderBufferViewAccessors[x]=[],E=this._encoderBufferViewData[x]=[],v=this._encoderBufferViews[x]={buffer:a,target:Ss.USAGE_TO_TARGET[d],byteOffset:0,byteLength:0,byteStride:d===Ss.BufferViewUsage.ARRAY_BUFFER?p:void 0,extensions:{[Xn]:{buffer:_,byteOffset:0,byteLength:0,mode:h,filter:y.filter!=="NONE"?y.filter:void 0,byteStride:p,count:0}}};let T=e.createAccessorDef(u);if(T.componentType=g.componentType,T.normalized=g.normalized,T.byteOffset=v.byteLength,T.min&&g.min)T.min=g.min;if(T.max&&g.max)T.max=g.max;e.accessorIndexMap.set(u,t.accessors.length),t.accessors.push(T),S.push(T),E.push(new Uint8Array(m.buffer,m.byteOffset,m.byteLength)),v.byteLength+=m.byteLength,v.extensions.EXT_meshopt_compression.count+=u.getCount()}}_prewriteBuffers(e){let t=this._encoder;for(let n in this._encoderBufferViews){let i=this._encoderBufferViews[n],r=this._encoderBufferViewData[n],s=this.document.getRoot().listBuffers()[i.extensions[Xn].buffer],a=e.otherBufferViews.get(s)||[],{count:o,byteStride:c,mode:l}=i.extensions[Xn],u=Je.concat(r),d=t.encodeGltfBuffer(u,o,c,l),f=Je.pad(d);i.extensions[Xn].byteLength=d.byteLength,r.length=0,r.push(f),a.push(f),e.otherBufferViews.set(s,a)}}write(e){let t=0;for(let s in this._encoderBufferViews){let a=this._encoderBufferViews[s],o=this._encoderBufferViewData[s][0],c=e.otherBufferViewsIndexMap.get(o),l=this._encoderBufferViewAccessors[s];for(let h of l)h.bufferView=c;let u=e.jsonDoc.json.bufferViews[c],d=u.byteOffset||0;Object.assign(u,a),u.byteOffset=t;let f=u.extensions[Xn];f.byteOffset=d,t+=Je.padNumber(a.byteLength)}let n=this._encoderFallbackBuffer,i=e.bufferIndexMap.get(n),r=e.jsonDoc.json.buffers[i];return r.byteLength=t,r.extensions={[Xn]:{fallback:!0}},n.dispose(),this}},iF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="StructuralMetadata",this.parentTypes=[ne.ROOT]}getDefaults(){return Object.assign(super.getDefaults(),{schema:null,schemaUri:"",propertyTables:new bn,propertyTextures:new bn,propertyAttributes:new bn})}getSchema(){return this.getRef("schema")}setSchema(e){return this.setRef("schema",e)}getSchemaUri(){return this.get("schemaUri")}setSchemaUri(e){return this.set("schemaUri",e)}listPropertyTables(){return this.listRefs("propertyTables")}addPropertyTable(e){return this.addRef("propertyTables",e)}removePropertyTable(e){return this.removeRef("propertyTables",e)}listPropertyTextures(){return this.listRefs("propertyTextures")}addPropertyTexture(e){return this.addRef("propertyTextures",e)}removePropertyTexture(e){return this.removeRef("propertyTextures",e)}listPropertyAttributes(){return this.listRefs("propertyAttributes")}addPropertyAttribute(e){return this.addRef("propertyAttributes",e)}removePropertyAttribute(e){return this.removeRef("propertyAttributes",e)}},rF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="Schema",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",version:"",classes:new dn,enums:new dn})}getId(){return this.get("id")}setId(e){return this.set("id",e)}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getVersion(){return this.get("version")}setVersion(e){return this.set("version",e)}setClass(e,t){return this.setRefMap("classes",e,t)}getClass(e){return this.getRefMap("classes",e)}listClassKeys(){return this.listRefMapKeys("classes")}listClassValues(){return this.listRefMapValues("classes")}setEnum(e,t){return this.setRefMap("enums",e,t)}getEnum(e){return this.getRefMap("enums",e)}listEnumKeys(){return this.listRefMapKeys("enums")}listEnumValues(){return this.listRefMapValues("enums")}},sF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="Class",this.parentTypes=["Schema"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",properties:new dn})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},aF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="ClassProperty",this.parentTypes=["Class"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",componentType:null,enumType:null,array:null,count:null,normalized:null,offset:null,scale:null,max:null,min:null,required:null,noData:null,default:null})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getType(){return this.get("type")}setType(e){return this.set("type",e)}getComponentType(){return this.get("componentType")}setComponentType(e){return this.set("componentType",e)}getEnumType(){return this.get("enumType")}setEnumType(e){return this.set("enumType",e)}getArray(){return this.get("array")}setArray(e){return this.set("array",e)}getCount(){return this.get("count")}setCount(e){return this.set("count",e)}getNormalized(){return this.get("normalized")}setNormalized(e){return this.set("normalized",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}getRequired(){return this.get("required")}setRequired(e){return this.set("required",e)}getNoData(){return this.get("noData")}setNoData(e){return this.set("noData",e)}getDefault(){return this.get("default")}setDefault(e){return this.set("default",e)}},oF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="Enum",this.parentTypes=["Schema"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",valueType:"UINT16",values:new bn})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getValueType(){return this.get("valueType")}setValueType(e){return this.set("valueType",e)}listValues(){return this.listRefs("values")}addEnumValue(e){return this.addRef("values",e)}removeEnumValue(e){return this.removeRef("values",e)}},cF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="EnumValue",this.parentTypes=["Enum"]}getDefaults(){return Object.assign(super.getDefaults(),{description:null})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getValue(){return this.get("value")}setValue(e){return this.set("value",e)}},lF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTable",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new dn})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}getCount(){return this.get("count")}setCount(e){return this.set("count",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},uF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTableProperty",this.parentTypes=["PropertyTable"]}getDefaults(){return Object.assign(super.getDefaults(),{arrayOffsets:null,stringOffsets:null,arrayOffsetType:null,stringOffsetType:null,offset:null,scale:null,max:null,min:null})}getValues(){return this.get("values")}setValues(e){return this.set("values",e)}getArrayOffsets(){return this.get("arrayOffsets")}setArrayOffsets(e){return this.set("arrayOffsets",e)}getStringOffsets(){return this.get("stringOffsets")}setStringOffsets(e){return this.set("stringOffsets",e)}getArrayOffsetType(){return this.get("arrayOffsetType")}setArrayOffsetType(e){return this.set("arrayOffsetType",e)}getStringOffsetType(){return this.get("stringOffsetType")}setStringOffsetType(e){return this.set("stringOffsetType",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},dF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTexture",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new dn})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},fF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTextureProperty",this.parentTypes=["PropertyTexture"]}getDefaults(){let e=new At(this.graph,"textureInfo");return e.setMinFilter(At.MagFilter.NEAREST),e.setMagFilter(At.MagFilter.NEAREST),Object.assign(super.getDefaults(),{channels:[0],texture:null,textureInfo:e,offset:null,scale:null,max:null,min:null})}getChannels(){return this.get("channels")}setChannels(e){return this.set("channels",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getTextureInfo(){return this.getRef("texture")?this.getRef("textureInfo"):null}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},hF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyAttribute",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new dn})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},pF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyAttributeProperty",this.parentTypes=["PropertyAttribute"]}getDefaults(){return Object.assign(super.getDefaults(),{offset:null,scale:null,max:null,min:null})}getAttribute(){return this.get("attribute")}setAttribute(e){return this.set("attribute",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},mF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="NodeStructuralMetadata",this.parentTypes=[ne.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{class:"",properties:{}})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}getProperties(){return this.get("properties")}setProperties(e){return this.set("properties",e)}},gF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="MeshPrimitiveStructuralMetadata",this.parentTypes=[ne.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{propertyTextures:new bn,propertyAttributes:new bn})}listPropertyTextures(){return this.listRefs("propertyTextures")}addPropertyTexture(e){return this.addRef("propertyTextures",e)}removePropertyTexture(e){return this.removeRef("propertyTextures",e)}listPropertyAttributes(){return this.listRefs("propertyAttributes")}addPropertyAttribute(e){return this.addRef("propertyAttributes",e)}removePropertyAttribute(e){return this.removeRef("propertyAttributes",e)}},bF=class extends xt{extensionName=et;static EXTENSION_NAME=et;prewriteTypes=[ne.BUFFER];prereadTypes=[ne.SCENE];createStructuralMetadata(){return new iF(this.document.getGraph())}createSchema(){return new rF(this.document.getGraph())}createClass(){return new sF(this.document.getGraph())}createClassProperty(){return new aF(this.document.getGraph())}createEnum(){return new oF(this.document.getGraph())}createEnumValue(){return new cF(this.document.getGraph())}createPropertyTable(){return new lF(this.document.getGraph())}createPropertyTableProperty(){return new uF(this.document.getGraph())}createPropertyTexture(){return new dF(this.document.getGraph())}createPropertyTextureProperty(){return new fF(this.document.getGraph())}createPropertyAttribute(){return new hF(this.document.getGraph())}createPropertyAttributeProperty(){return new pF(this.document.getGraph())}createNodeStructuralMetadata(){return new mF(this.document.getGraph())}createMeshPrimitiveStructuralMetadata(){return new gF(this.document.getGraph())}read(e){return this}preread(e){let t=this.document.getRoot(),{json:n}=e.jsonDoc,i=n.extensions[et],r=yF(this,e,i);return t.setExtension(et,r),(n.meshes||[]).forEach((s,a)=>{let o=e.meshes[a].listPrimitives();(s.primitives||[]).forEach((c,l)=>{let u=o[l];this._readPrimitive(r,u,c)})}),(n.nodes||[]).forEach((s,a)=>{this._readNode(e.nodes[a],s)}),this}_readPrimitive(e,t,n){if(!n.extensions||!n.extensions.EXT_structural_metadata)return;let i=this.createMeshPrimitiveStructuralMetadata(),r=n.extensions[et],s=e.listPropertyTextures(),a=r.propertyTextures||[];for(let l of a){let u=s[l];i.addPropertyTexture(u)}let o=e.listPropertyAttributes(),c=r.propertyAttributes||[];for(let l of c){let u=o[l];i.addPropertyAttribute(u)}t.setExtension(et,i)}_readNode(e,t){if(!t.extensions||!t.extensions.EXT_structural_metadata)return;let n=t.extensions[et],i=this.createNodeStructuralMetadata().setClass(n.class).setProperties(n.properties);e.setExtension(et,i)}write(e){let t=this.document.getRoot(),n=t.getExtension(et);if(!n)return this;let i=e.jsonDoc.json,r=CF(e,n);i.extensions=i.extensions||{},i.extensions[et]=r;let s=t.listMeshes(),a=i.meshes;if(a)for(let l of s){let u=a[e.meshIndexMap.get(l)];l.listPrimitives().forEach((d,f)=>{let h=u.primitives[f];this._writePrimitive(n,d,h)})}let o=t.listNodes(),c=i.nodes;if(c)for(let l of o){let u=e.nodeIndexMap.get(l);this._writeNode(l,c[u])}return this}_writePrimitive(e,t,n){let i=t.getExtension(et);if(!i)return;let r=e.listPropertyTextures(),s=e.listPropertyAttributes(),a,o,c=i.listPropertyTextures();if(c.length>0){a=[];for(let d of c){let f=r.indexOf(d);if(f>=0)a.push(f);else throw Error(`${et}: Invalid property texture in mesh primitive`)}}let l=i.listPropertyAttributes();if(l.length>0){o=[];for(let d of l){let f=s.indexOf(d);if(f>=0)o.push(f);else throw Error(`${et}: Invalid property attribute in mesh primitive`)}}let u={propertyTextures:a,propertyAttributes:o};n.extensions=n.extensions||{},n.extensions[et]=u}_writeNode(e,t){let n=e.getExtension("EXT_structural_metadata");if(!n)return;t.extensions=t.extensions||{},t.extensions[et]={class:n.getClass(),properties:n.getProperties()}}prewrite(e,t){if(t===ne.BUFFER)this._prewriteBuffers(e);return this}_prewriteBuffers(e){let t=this.document,n=t.getRoot().getExtension(et);e.jsonDoc.json.bufferViews||=[];for(let i of n.listPropertyTables())for(let r of i.listPropertyValues()){let s=jF(t,e);s.push(r.getValues());let a=r.getArrayOffsets();if(a)s.push(a);let o=r.getStringOffsets();if(o)s.push(o)}}};nw=class extends xt{extensionName=Hd;prereadTypes=[ne.TEXTURE];static EXTENSION_NAME=Hd;static register(){ji.registerFormat("image/avif",new HF)}preread(e){return(e.jsonDoc.json.textures||[]).forEach((t)=>{if(t.extensions&&t.extensions.EXT_texture_avif)t.source=t.extensions[Hd].source}),this}read(e){return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listTextures().forEach((n)=>{if(n.getMimeType()==="image/avif"){let i=e.imageIndexMap.get(n);(t.json.textures||[]).forEach((r)=>{if(r.source===i)r.extensions=r.extensions||{},r.extensions[Hd]={source:r.source},delete r.source})}}),this}};iw=class extends xt{extensionName=jd;prereadTypes=[ne.TEXTURE];static EXTENSION_NAME=jd;static register(){ji.registerFormat("image/webp",new GF)}preread(e){return(e.jsonDoc.json.textures||[]).forEach((t)=>{if(t.extensions&&t.extensions.EXT_texture_webp)t.source=t.extensions[jd].source}),this}read(e){return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listTextures().forEach((n)=>{if(n.getMimeType()==="image/webp"){let i=e.imageIndexMap.get(n);(t.json.textures||[]).forEach((r)=>{if(r.source===i)r.extensions=r.extensions||{},r.extensions[jd]={source:r.source},delete r.source})}}),this}},jS=F8,$F=class extends xt{extensionName=jS;static EXTENSION_NAME=jS;read(e){return this}write(e){return this}},HS=U8,KF=class extends xt{extensionName=HS;static EXTENSION_NAME=HS;read(e){return this}write(e){return this}};ZF=function(e){return e[e.EDGEBREAKER=1]="EDGEBREAKER",e[e.SEQUENTIAL=0]="SEQUENTIAL",e}({}),aw={["POSITION"]:14,["NORMAL"]:10,["COLOR"]:8,["TEX_COORD"]:12,["GENERIC"]:12},GS={decodeSpeed:5,encodeSpeed:5,method:1,quantizationBits:aw,quantizationVolume:"mesh"};Sg=class extends Error{},ow=class extends xt{extensionName=en;prereadTypes=[ne.PRIMITIVE];prewriteTypes=[ne.ACCESSOR];readDependencies=["draco3d.decoder"];writeDependencies=["draco3d.encoder"];static EXTENSION_NAME=en;static EncoderMethod=ZF;_decoderModule=null;_encoderModule=null;_encoderOptions={};install(e,t){if(e==="draco3d.decoder")this._decoderModule=t,JF(this._decoderModule);if(e==="draco3d.encoder")this._encoderModule=t,YF(this._encoderModule);return this}setEncoderOptions(e){return this._encoderOptions=e,this}preread(e){if(!this._decoderModule)throw Error(`[${en}] Please install extension dependency, "draco3d.decoder".`);let t=this.document.getLogger(),n=e.jsonDoc,i=new Map;try{let r=n.json.meshes||[];for(let s of r)for(let a of s.primitives){if(!a.extensions||!a.extensions.KHR_draco_mesh_compression)continue;let o=a.extensions[en],[c,l]=i.get(o.bufferView)||[];if(!l||!c){let u=n.json.bufferViews[o.bufferView],d=n.json.buffers[u.buffer],f=d.uri?n.resources[d.uri]:n.resources[ws],h=u.byteOffset||0,y=u.byteLength,g=Je.toView(f,h,y);c=new this._decoderModule.Decoder,l=WF(c,g),i.set(o.bufferView,[c,l]),t.debug(`[${en}] Decompressed ${g.byteLength} bytes.`)}for(let u in o.attributes){let d=e.jsonDoc.json.accessors[a.attributes[u]],f=c.GetAttributeByUniqueId(l,o.attributes[u]),h=qF(c,l,f,d);e.accessors[a.attributes[u]].setArray(h)}if(a.indices!==void 0)e.accessors[a.indices].setArray(XF(c,l))}}finally{for(let[r,s]of Array.from(i.values()))this._decoderModule.destroy(r),this._decoderModule.destroy(s)}return this}read(e){return this}prewrite(e,t){if(!this._encoderModule)throw Error(`[${en}] Please install extension dependency, "draco3d.encoder".`);let n=this.document.getLogger();n.debug(`[${en}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let i=n2(this.document),r=new Map,s="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)n.warn(`[${en}]: quantizationVolume=scene requires exactly 1 scene.`);else s=gg(this.document.getRoot().listScenes().pop());for(let a of Array.from(i.keys())){let o=i.get(a);if(!o)throw Error("Unexpected primitive.");if(r.has(o)){r.set(o,r.get(o));continue}let c=a.getIndices(),l=e.jsonDoc.json.accessors,u;try{u=QF(a,{...this._encoderOptions,quantizationVolume:s})}catch(h){if(h instanceof Sg){n.warn(`[${en}]: ${h.message} Skipping primitive compression.`);continue}throw h}r.set(o,u);let d=e.createAccessorDef(c);if(d.count=u.numIndices,e.accessorIndexMap.set(c,l.length),l.push(d),u.numVertices>65534&&Be.getComponentSize(d.componentType)<=2)d.componentType=Be.ComponentType.UNSIGNED_INT;else if(u.numVertices>254&&Be.getComponentSize(d.componentType)<=1)d.componentType=Be.ComponentType.UNSIGNED_SHORT;for(let h of a.listSemantics()){let y=a.getAttribute(h);if(u.attributeIDs[h]===void 0)continue;let g=e.createAccessorDef(y);g.count=u.numVertices,e.accessorIndexMap.set(y,l.length),l.push(g)}let f=a.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!e.otherBufferViews.has(f))e.otherBufferViews.set(f,[]);e.otherBufferViews.get(f).push(u.data)}return n.debug(`[${en}] Compressed ${i.size} primitives.`),e.extensionData[en]={primitiveHashMap:i,primitiveEncodingMap:r},this}write(e){let t=e.extensionData[en];for(let n of this.document.getRoot().listMeshes()){let i=e.jsonDoc.json.meshes[e.meshIndexMap.get(n)];for(let r=0;r<n.listPrimitives().length;r++){let s=n.listPrimitives()[r],a=i.primitives[r],o=t.primitiveHashMap.get(s);if(!o)continue;let c=t.primitiveEncodingMap.get(o);if(!c)continue;a.extensions=a.extensions||{},a.extensions[en]={bufferView:e.otherBufferViewsIndexMap.get(c.data),attributes:c.attributeIDs}}}if(!t.primitiveHashMap.size){let n=e.jsonDoc.json;n.extensionsUsed=(n.extensionsUsed||[]).filter((i)=>i!==en),n.extensionsRequired=(n.extensionsRequired||[]).filter((i)=>i!==en)}return this}};KS=class e extends nt{static EXTENSION_NAME=Vr;static Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};init(){this.extensionName=Vr,this.propertyType="Light",this.parentTypes=[ne.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:e.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(t){return this.set("color",t)}getIntensity(){return this.get("intensity")}setIntensity(t){return this.set("intensity",t)}getType(){return this.get("type")}setType(t){return this.set("type",t)}getRange(){return this.get("range")}setRange(t){return this.set("range",t)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(t){return this.set("innerConeAngle",t)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(t){return this.set("outerConeAngle",t)}},i2=class extends xt{extensionName=Vr;static EXTENSION_NAME=Vr;createLight(e=""){return new KS(this.document.getGraph(),e)}read(e){let t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions.KHR_lights_punctual)return this;let n=(t.json.extensions.KHR_lights_punctual.lights||[]).map((i)=>{let r=this.createLight().setName(i.name||"").setType(i.type);if(i.extras)r.setExtras(i.extras);if(i.color!==void 0)r.setColor(i.color);if(i.intensity!==void 0)r.setIntensity(i.intensity);if(i.range!==void 0)r.setRange(i.range);if(i.spot?.innerConeAngle!==void 0)r.setInnerConeAngle(i.spot.innerConeAngle);if(i.spot?.outerConeAngle!==void 0)r.setOuterConeAngle(i.spot.outerConeAngle);return r});return t.json.nodes.forEach((i,r)=>{if(!i.extensions||!i.extensions.KHR_lights_punctual)return;let s=i.extensions[Vr];e.nodes[r].setExtension(Vr,n[s.light])}),this}write(e){let t=e.jsonDoc;if(this.properties.size===0)return this;let n=[],i=new Map;for(let r of this.properties){let s=r,a=e.createPropertyDef(r);if(a.type=s.getType(),!pt.eq(s.getColor(),[1,1,1]))a.color=s.getColor();if(s.getIntensity()!==1)a.intensity=s.getIntensity();if(s.getRange()!=null)a.range=s.getRange();if(s.getName())a.name=s.getName();if(s.getType()===KS.Type.SPOT)a.spot={innerConeAngle:s.getInnerConeAngle(),outerConeAngle:s.getOuterConeAngle()};n.push(a),i.set(s,n.length-1)}return this.document.getRoot().listNodes().forEach((r)=>{let s=r.getExtension(Vr);if(s){let a=e.nodeIndexMap.get(r),o=t.json.nodes[a];o.extensions=o.extensions||{},o.extensions[Vr]={light:i.get(s)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[Vr]={lights:n},this}},{R:r2,G:s2,B:a2}=Ei,o2=class extends nt{static EXTENSION_NAME=Cs;init(){this.extensionName=Cs,this.propertyType="Anisotropy",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new At(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(e){return this.set("anisotropyStrength",e)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(e){return this.set("anisotropyRotation",e)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(e){return this.setRef("anisotropyTexture",e,{channels:r2|s2|a2})}},c2=class extends xt{static EXTENSION_NAME=Cs;extensionName=Cs;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createAnisotropy(){return new o2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_anisotropy){let a=this.createAnisotropy();e.materials[s].setExtension(Cs,a);let o=r.extensions[Cs];if(o.extras)a.setExtras(o.extras);if(o.anisotropyStrength!==void 0)a.setAnisotropyStrength(o.anisotropyStrength);if(o.anisotropyRotation!==void 0)a.setAnisotropyRotation(o.anisotropyRotation);if(o.anisotropyTexture!==void 0){let c=o.anisotropyTexture,l=e.textures[i[c.index].source];a.setAnisotropyTexture(l),e.setTextureInfo(a.getAnisotropyTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Cs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Cs]=a,i.getAnisotropyStrength()>0)a.anisotropyStrength=i.getAnisotropyStrength();if(i.getAnisotropyRotation()!==0)a.anisotropyRotation=i.getAnisotropyRotation();if(i.getAnisotropyTexture()){let o=i.getAnisotropyTexture(),c=i.getAnisotropyTextureInfo();a.anisotropyTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:WS,G:XS,B:l2}=Ei,u2=class extends nt{static EXTENSION_NAME=Ns;init(){this.extensionName=Ns,this.propertyType="Clearcoat",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new At(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new At(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new At(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(e){return this.set("clearcoatFactor",e)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(e){return this.setRef("clearcoatTexture",e,{channels:WS})}getClearcoatRoughnessFactor(){return this.get("clearcoatRoughnessFactor")}setClearcoatRoughnessFactor(e){return this.set("clearcoatRoughnessFactor",e)}getClearcoatRoughnessTexture(){return this.getRef("clearcoatRoughnessTexture")}getClearcoatRoughnessTextureInfo(){return this.getRef("clearcoatRoughnessTexture")?this.getRef("clearcoatRoughnessTextureInfo"):null}setClearcoatRoughnessTexture(e){return this.setRef("clearcoatRoughnessTexture",e,{channels:XS})}getClearcoatNormalScale(){return this.get("clearcoatNormalScale")}setClearcoatNormalScale(e){return this.set("clearcoatNormalScale",e)}getClearcoatNormalTexture(){return this.getRef("clearcoatNormalTexture")}getClearcoatNormalTextureInfo(){return this.getRef("clearcoatNormalTexture")?this.getRef("clearcoatNormalTextureInfo"):null}setClearcoatNormalTexture(e){return this.setRef("clearcoatNormalTexture",e,{channels:WS|XS|l2})}},d2=class extends xt{static EXTENSION_NAME=Ns;extensionName=Ns;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createClearcoat(){return new u2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_clearcoat){let a=this.createClearcoat();e.materials[s].setExtension(Ns,a);let o=r.extensions[Ns];if(o.extras)a.setExtras(o.extras);if(o.clearcoatFactor!==void 0)a.setClearcoatFactor(o.clearcoatFactor);if(o.clearcoatRoughnessFactor!==void 0)a.setClearcoatRoughnessFactor(o.clearcoatRoughnessFactor);if(o.clearcoatTexture!==void 0){let c=o.clearcoatTexture,l=e.textures[i[c.index].source];a.setClearcoatTexture(l),e.setTextureInfo(a.getClearcoatTextureInfo(),c)}if(o.clearcoatRoughnessTexture!==void 0){let c=o.clearcoatRoughnessTexture,l=e.textures[i[c.index].source];a.setClearcoatRoughnessTexture(l),e.setTextureInfo(a.getClearcoatRoughnessTextureInfo(),c)}if(o.clearcoatNormalTexture!==void 0){let c=o.clearcoatNormalTexture,l=e.textures[i[c.index].source];if(a.setClearcoatNormalTexture(l),e.setTextureInfo(a.getClearcoatNormalTextureInfo(),c),c.scale!==void 0)a.setClearcoatNormalScale(c.scale)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Ns);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Ns]=a,a.clearcoatFactor=i.getClearcoatFactor(),a.clearcoatRoughnessFactor=i.getClearcoatRoughnessFactor(),i.getClearcoatTexture()){let o=i.getClearcoatTexture(),c=i.getClearcoatTextureInfo();a.clearcoatTexture=e.createTextureInfoDef(o,c)}if(i.getClearcoatRoughnessTexture()){let o=i.getClearcoatRoughnessTexture(),c=i.getClearcoatRoughnessTextureInfo();a.clearcoatRoughnessTexture=e.createTextureInfoDef(o,c)}if(i.getClearcoatNormalTexture()){let o=i.getClearcoatNormalTexture(),c=i.getClearcoatNormalTextureInfo();if(a.clearcoatNormalTexture=e.createTextureInfoDef(o,c),i.getClearcoatNormalScale()!==1)a.clearcoatNormalTexture.scale=i.getClearcoatNormalScale()}}}),this}},{R:f2,G:h2,B:p2,A:m2}=Ei,g2=class extends nt{static EXTENSION_NAME=Ps;init(){this.extensionName=Ps,this.propertyType="DiffuseTransmission",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new At(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new At(this.graph,"diffuseTransmissionColorTextureInfo")})}getDiffuseTransmissionFactor(){return this.get("diffuseTransmissionFactor")}setDiffuseTransmissionFactor(e){return this.set("diffuseTransmissionFactor",e)}getDiffuseTransmissionTexture(){return this.getRef("diffuseTransmissionTexture")}getDiffuseTransmissionTextureInfo(){return this.getRef("diffuseTransmissionTexture")?this.getRef("diffuseTransmissionTextureInfo"):null}setDiffuseTransmissionTexture(e){return this.setRef("diffuseTransmissionTexture",e,{channels:m2})}getDiffuseTransmissionColorFactor(){return this.get("diffuseTransmissionColorFactor")}setDiffuseTransmissionColorFactor(e){return this.set("diffuseTransmissionColorFactor",e)}getDiffuseTransmissionColorTexture(){return this.getRef("diffuseTransmissionColorTexture")}getDiffuseTransmissionColorTextureInfo(){return this.getRef("diffuseTransmissionColorTexture")?this.getRef("diffuseTransmissionColorTextureInfo"):null}setDiffuseTransmissionColorTexture(e){return this.setRef("diffuseTransmissionColorTexture",e,{channels:f2|h2|p2})}},b2=class extends xt{extensionName=Ps;static EXTENSION_NAME=Ps;createDiffuseTransmission(){return new g2(this.document.getGraph())}read(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_diffuse_transmission){let a=this.createDiffuseTransmission();e.materials[s].setExtension(Ps,a);let o=r.extensions[Ps];if(o.extras)a.setExtras(o.extras);if(o.diffuseTransmissionFactor!==void 0)a.setDiffuseTransmissionFactor(o.diffuseTransmissionFactor);if(o.diffuseTransmissionColorFactor!==void 0)a.setDiffuseTransmissionColorFactor(o.diffuseTransmissionColorFactor);if(o.diffuseTransmissionTexture!==void 0){let c=o.diffuseTransmissionTexture,l=e.textures[i[c.index].source];a.setDiffuseTransmissionTexture(l),e.setTextureInfo(a.getDiffuseTransmissionTextureInfo(),c)}if(o.diffuseTransmissionColorTexture!==void 0){let c=o.diffuseTransmissionColorTexture,l=e.textures[i[c.index].source];a.setDiffuseTransmissionColorTexture(l),e.setTextureInfo(a.getDiffuseTransmissionColorTextureInfo(),c)}}}),this}write(e){let t=e.jsonDoc;for(let n of this.document.getRoot().listMaterials()){let i=n.getExtension(Ps);if(!i)continue;let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Ps]=a,a.diffuseTransmissionFactor=i.getDiffuseTransmissionFactor(),a.diffuseTransmissionColorFactor=i.getDiffuseTransmissionColorFactor(),i.getDiffuseTransmissionTexture()){let o=i.getDiffuseTransmissionTexture(),c=i.getDiffuseTransmissionTextureInfo();a.diffuseTransmissionTexture=e.createTextureInfoDef(o,c)}if(i.getDiffuseTransmissionColorTexture()){let o=i.getDiffuseTransmissionColorTexture(),c=i.getDiffuseTransmissionColorTextureInfo();a.diffuseTransmissionColorTexture=e.createTextureInfoDef(o,c)}}return this}},y2=class extends nt{static EXTENSION_NAME=Os;init(){this.extensionName=Os,this.propertyType="Dispersion",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(e){return this.set("dispersion",e)}},x2=class extends xt{static EXTENSION_NAME=Os;extensionName=Os;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createDispersion(){return new y2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_dispersion){let i=this.createDispersion();e.materials[n].setExtension(Os,i);let r=t.extensions[Os];if(r.extras)i.setExtras(r.extras);if(r.dispersion!==void 0)i.setDispersion(r.dispersion)}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Os);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);s.extensions=s.extensions||{},s.extensions[Os]=a,a.dispersion=i.getDispersion()}}),this}},_2=class extends nt{static EXTENSION_NAME=ks;init(){this.extensionName=ks,this.propertyType="EmissiveStrength",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(e){return this.set("emissiveStrength",e)}},v2=class extends xt{static EXTENSION_NAME=ks;extensionName=ks;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createEmissiveStrength(){return new _2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_emissive_strength){let i=this.createEmissiveStrength();e.materials[n].setExtension(ks,i);let r=t.extensions[ks];if(r.extras)i.setExtras(r.extras);if(r.emissiveStrength!==void 0)i.setEmissiveStrength(r.emissiveStrength)}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(ks);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);s.extensions=s.extensions||{},s.extensions[ks]=a,a.emissiveStrength=i.getEmissiveStrength()}}),this}},E2=class extends nt{static EXTENSION_NAME=Ds;init(){this.extensionName=Ds,this.propertyType="IOR",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(e){return this.set("ior",e)}},cw=class extends xt{static EXTENSION_NAME=Ds;extensionName=Ds;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createIOR(){return new E2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_ior){let i=this.createIOR();e.materials[n].setExtension(Ds,i);let r=t.extensions[Ds];if(r.extras)i.setExtras(r.extras);if(r.ior!==void 0)i.setIOR(r.ior)}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Ds);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);s.extensions=s.extensions||{},s.extensions[Ds]=a,a.ior=i.getIOR()}}),this}},{R:T2,G:A2}=Ei,S2=class extends nt{static EXTENSION_NAME=Ls;init(){this.extensionName=Ls,this.propertyType="Iridescence",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new At(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new At(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(e){return this.set("iridescenceFactor",e)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(e){return this.setRef("iridescenceTexture",e,{channels:T2})}getIridescenceIOR(){return this.get("iridescenceIOR")}setIridescenceIOR(e){return this.set("iridescenceIOR",e)}getIridescenceThicknessMinimum(){return this.get("iridescenceThicknessMinimum")}setIridescenceThicknessMinimum(e){return this.set("iridescenceThicknessMinimum",e)}getIridescenceThicknessMaximum(){return this.get("iridescenceThicknessMaximum")}setIridescenceThicknessMaximum(e){return this.set("iridescenceThicknessMaximum",e)}getIridescenceThicknessTexture(){return this.getRef("iridescenceThicknessTexture")}getIridescenceThicknessTextureInfo(){return this.getRef("iridescenceThicknessTexture")?this.getRef("iridescenceThicknessTextureInfo"):null}setIridescenceThicknessTexture(e){return this.setRef("iridescenceThicknessTexture",e,{channels:A2})}},w2=class extends xt{static EXTENSION_NAME=Ls;extensionName=Ls;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createIridescence(){return new S2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_iridescence){let a=this.createIridescence();e.materials[s].setExtension(Ls,a);let o=r.extensions[Ls];if(o.extras)a.setExtras(o.extras);if(o.iridescenceFactor!==void 0)a.setIridescenceFactor(o.iridescenceFactor);if(o.iridescenceIor!==void 0)a.setIridescenceIOR(o.iridescenceIor);if(o.iridescenceThicknessMinimum!==void 0)a.setIridescenceThicknessMinimum(o.iridescenceThicknessMinimum);if(o.iridescenceThicknessMaximum!==void 0)a.setIridescenceThicknessMaximum(o.iridescenceThicknessMaximum);if(o.iridescenceTexture!==void 0){let c=o.iridescenceTexture,l=e.textures[i[c.index].source];a.setIridescenceTexture(l),e.setTextureInfo(a.getIridescenceTextureInfo(),c)}if(o.iridescenceThicknessTexture!==void 0){let c=o.iridescenceThicknessTexture,l=e.textures[i[c.index].source];a.setIridescenceThicknessTexture(l),e.setTextureInfo(a.getIridescenceThicknessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Ls);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Ls]=a,i.getIridescenceFactor()>0)a.iridescenceFactor=i.getIridescenceFactor();if(i.getIridescenceIOR()!==1.3)a.iridescenceIor=i.getIridescenceIOR();if(i.getIridescenceThicknessMinimum()!==100)a.iridescenceThicknessMinimum=i.getIridescenceThicknessMinimum();if(i.getIridescenceThicknessMaximum()!==400)a.iridescenceThicknessMaximum=i.getIridescenceThicknessMaximum();if(i.getIridescenceTexture()){let o=i.getIridescenceTexture(),c=i.getIridescenceTextureInfo();a.iridescenceTexture=e.createTextureInfoDef(o,c)}if(i.getIridescenceThicknessTexture()){let o=i.getIridescenceThicknessTexture(),c=i.getIridescenceThicknessTextureInfo();a.iridescenceThicknessTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:qS,G:JS,B:ZS,A:YS}=Ei,M2=class extends nt{static EXTENSION_NAME=Fs;init(){this.extensionName=Fs,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new At(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new At(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(e){return this.set("diffuseFactor",e)}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(e){return this.setRef("diffuseTexture",e,{channels:qS|JS|ZS|YS,isColor:!0})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getGlossinessFactor(){return this.get("glossinessFactor")}setGlossinessFactor(e){return this.set("glossinessFactor",e)}getSpecularGlossinessTexture(){return this.getRef("specularGlossinessTexture")}getSpecularGlossinessTextureInfo(){return this.getRef("specularGlossinessTexture")?this.getRef("specularGlossinessTextureInfo"):null}setSpecularGlossinessTexture(e){return this.setRef("specularGlossinessTexture",e,{channels:qS|JS|ZS|YS})}},lw=class extends xt{static EXTENSION_NAME=Fs;extensionName=Fs;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createPBRSpecularGlossiness(){return new M2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_pbrSpecularGlossiness){let a=this.createPBRSpecularGlossiness();e.materials[s].setExtension(Fs,a);let o=r.extensions[Fs];if(o.extras)a.setExtras(o.extras);if(o.diffuseFactor!==void 0)a.setDiffuseFactor(o.diffuseFactor);if(o.specularFactor!==void 0)a.setSpecularFactor(o.specularFactor);if(o.glossinessFactor!==void 0)a.setGlossinessFactor(o.glossinessFactor);if(o.diffuseTexture!==void 0){let c=o.diffuseTexture,l=e.textures[i[c.index].source];a.setDiffuseTexture(l),e.setTextureInfo(a.getDiffuseTextureInfo(),c)}if(o.specularGlossinessTexture!==void 0){let c=o.specularGlossinessTexture,l=e.textures[i[c.index].source];a.setSpecularGlossinessTexture(l),e.setTextureInfo(a.getSpecularGlossinessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Fs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Fs]=a,a.diffuseFactor=i.getDiffuseFactor(),a.specularFactor=i.getSpecularFactor(),a.glossinessFactor=i.getGlossinessFactor(),i.getDiffuseTexture()){let o=i.getDiffuseTexture(),c=i.getDiffuseTextureInfo();a.diffuseTexture=e.createTextureInfoDef(o,c)}if(i.getSpecularGlossinessTexture()){let o=i.getSpecularGlossinessTexture(),c=i.getSpecularGlossinessTextureInfo();a.specularGlossinessTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:R2,G:I2,B:C2,A:N2}=Ei,P2=class extends nt{static EXTENSION_NAME=Us;init(){this.extensionName=Us,this.propertyType="Sheen",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new At(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new At(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}setSheenColorFactor(e){return this.set("sheenColorFactor",e)}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(e){return this.setRef("sheenColorTexture",e,{channels:R2|I2|C2,isColor:!0})}getSheenRoughnessFactor(){return this.get("sheenRoughnessFactor")}setSheenRoughnessFactor(e){return this.set("sheenRoughnessFactor",e)}getSheenRoughnessTexture(){return this.getRef("sheenRoughnessTexture")}getSheenRoughnessTextureInfo(){return this.getRef("sheenRoughnessTexture")?this.getRef("sheenRoughnessTextureInfo"):null}setSheenRoughnessTexture(e){return this.setRef("sheenRoughnessTexture",e,{channels:N2})}},O2=class extends xt{static EXTENSION_NAME=Us;extensionName=Us;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createSheen(){return new P2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_sheen){let a=this.createSheen();e.materials[s].setExtension(Us,a);let o=r.extensions[Us];if(o.extras)a.setExtras(o.extras);if(o.sheenColorFactor!==void 0)a.setSheenColorFactor(o.sheenColorFactor);if(o.sheenRoughnessFactor!==void 0)a.setSheenRoughnessFactor(o.sheenRoughnessFactor);if(o.sheenColorTexture!==void 0){let c=o.sheenColorTexture,l=e.textures[i[c.index].source];a.setSheenColorTexture(l),e.setTextureInfo(a.getSheenColorTextureInfo(),c)}if(o.sheenRoughnessTexture!==void 0){let c=o.sheenRoughnessTexture,l=e.textures[i[c.index].source];a.setSheenRoughnessTexture(l),e.setTextureInfo(a.getSheenRoughnessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Us);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Us]=a,a.sheenColorFactor=i.getSheenColorFactor(),a.sheenRoughnessFactor=i.getSheenRoughnessFactor(),i.getSheenColorTexture()){let o=i.getSheenColorTexture(),c=i.getSheenColorTextureInfo();a.sheenColorTexture=e.createTextureInfoDef(o,c)}if(i.getSheenRoughnessTexture()){let o=i.getSheenRoughnessTexture(),c=i.getSheenRoughnessTextureInfo();a.sheenRoughnessTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:k2,G:D2,B:L2,A:F2}=Ei,U2=class extends nt{static EXTENSION_NAME=Bs;init(){this.extensionName=Bs,this.propertyType="Specular",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new At(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new At(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(e){return this.set("specularColorFactor",e)}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(e){return this.setRef("specularTexture",e,{channels:F2})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(e){return this.setRef("specularColorTexture",e,{channels:k2|D2|L2,isColor:!0})}},uw=class extends xt{static EXTENSION_NAME=Bs;extensionName=Bs;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createSpecular(){return new U2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_specular){let a=this.createSpecular();e.materials[s].setExtension(Bs,a);let o=r.extensions[Bs];if(o.extras)a.setExtras(o.extras);if(o.specularFactor!==void 0)a.setSpecularFactor(o.specularFactor);if(o.specularColorFactor!==void 0)a.setSpecularColorFactor(o.specularColorFactor);if(o.specularTexture!==void 0){let c=o.specularTexture,l=e.textures[i[c.index].source];a.setSpecularTexture(l),e.setTextureInfo(a.getSpecularTextureInfo(),c)}if(o.specularColorTexture!==void 0){let c=o.specularColorTexture,l=e.textures[i[c.index].source];a.setSpecularColorTexture(l),e.setTextureInfo(a.getSpecularColorTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Bs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Bs]=a,i.getSpecularFactor()!==1)a.specularFactor=i.getSpecularFactor();if(!pt.eq(i.getSpecularColorFactor(),[1,1,1]))a.specularColorFactor=i.getSpecularColorFactor();if(i.getSpecularTexture()){let o=i.getSpecularTexture(),c=i.getSpecularTextureInfo();a.specularTexture=e.createTextureInfoDef(o,c)}if(i.getSpecularColorTexture()){let o=i.getSpecularColorTexture(),c=i.getSpecularColorTextureInfo();a.specularColorTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:B2}=Ei,z2=class extends nt{static EXTENSION_NAME=zs;init(){this.extensionName=zs,this.propertyType="Transmission",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new At(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(e){return this.set("transmissionFactor",e)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(e){return this.setRef("transmissionTexture",e,{channels:B2})}},V2=class extends xt{static EXTENSION_NAME=zs;extensionName=zs;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createTransmission(){return new z2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_transmission){let a=this.createTransmission();e.materials[s].setExtension(zs,a);let o=r.extensions[zs];if(o.extras)a.setExtras(o.extras);if(o.transmissionFactor!==void 0)a.setTransmissionFactor(o.transmissionFactor);if(o.transmissionTexture!==void 0){let c=o.transmissionTexture,l=e.textures[i[c.index].source];a.setTransmissionTexture(l),e.setTextureInfo(a.getTransmissionTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(zs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[zs]=a,a.transmissionFactor=i.getTransmissionFactor(),i.getTransmissionTexture()){let o=i.getTransmissionTexture(),c=i.getTransmissionTextureInfo();a.transmissionTexture=e.createTextureInfoDef(o,c)}}}),this}},j2=class extends nt{static EXTENSION_NAME=jo;init(){this.extensionName=jo,this.propertyType="Unlit",this.parentTypes=[ne.MATERIAL]}},dw=class extends xt{static EXTENSION_NAME=jo;extensionName=jo;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createUnlit(){return new j2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_unlit)e.materials[n].setExtension(jo,this.createUnlit())}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{if(n.getExtension("KHR_materials_unlit")){let i=e.materialIndexMap.get(n),r=t.json.materials[i];r.extensions=r.extensions||{},r.extensions[jo]={}}}),this}},H2=class extends nt{static EXTENSION_NAME=ui;init(){this.extensionName=ui,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new Rt})}getMaterial(){return this.getRef("material")}setMaterial(e){return this.setRef("material",e)}addVariant(e){return this.addRef("variants",e)}removeVariant(e){return this.removeRef("variants",e)}listVariants(){return this.listRefs("variants")}},G2=class extends nt{static EXTENSION_NAME=ui;init(){this.extensionName=ui,this.propertyType="MappingList",this.parentTypes=[ne.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new Rt})}addMapping(e){return this.addRef("mappings",e)}removeMapping(e){return this.removeRef("mappings",e)}listMappings(){return this.listRefs("mappings")}},QS=class extends nt{static EXTENSION_NAME=ui;init(){this.extensionName=ui,this.propertyType="Variant",this.parentTypes=["MappingList"]}},$2=class extends xt{extensionName=ui;static EXTENSION_NAME=ui;createMappingList(){return new G2(this.document.getGraph())}createVariant(e=""){return new QS(this.document.getGraph(),e)}createMapping(){return new H2(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((e)=>e instanceof QS)}read(e){let t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions.KHR_materials_variants)return this;let n=(t.json.extensions.KHR_materials_variants.variants||[]).map((i)=>this.createVariant().setName(i.name||""));return(t.json.meshes||[]).forEach((i,r)=>{let s=e.meshes[r];(i.primitives||[]).forEach((a,o)=>{if(!a.extensions||!a.extensions.KHR_materials_variants)return;let c=this.createMappingList(),l=a.extensions[ui];for(let u of l.mappings){let d=this.createMapping();if(u.material!==void 0)d.setMaterial(e.materials[u.material]);for(let f of u.variants||[])d.addVariant(n[f]);c.addMapping(d)}s.listPrimitives()[o].setExtension(ui,c)})}),this}write(e){let t=e.jsonDoc,n=this.listVariants();if(!n.length)return this;let i=[],r=new Map;for(let s of n)r.set(s,i.length),i.push(e.createPropertyDef(s));for(let s of this.document.getRoot().listMeshes()){let a=e.meshIndexMap.get(s);s.listPrimitives().forEach((o,c)=>{let l=o.getExtension(ui);if(!l)return;let u=e.jsonDoc.json.meshes[a].primitives[c],d=l.listMappings().map((f)=>{let h=e.createPropertyDef(f),y=f.getMaterial();if(y)h.material=e.materialIndexMap.get(y);return h.variants=f.listVariants().map((g)=>r.get(g)),h});u.extensions=u.extensions||{},u.extensions[ui]={mappings:d}})}return t.json.extensions=t.json.extensions||{},t.json.extensions[ui]={variants:i},this}},{G:K2}=Ei,W2=class extends nt{static EXTENSION_NAME=Vs;init(){this.extensionName=Vs,this.propertyType="Volume",this.parentTypes=[ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new At(this.graph,"thicknessTexture"),attenuationDistance:1/0,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(e){return this.set("thicknessFactor",e)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(e){return this.setRef("thicknessTexture",e,{channels:K2})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(e){return this.set("attenuationDistance",e)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(e){return this.set("attenuationColor",e)}},X2=class extends xt{static EXTENSION_NAME=Vs;extensionName=Vs;prereadTypes=[ne.MESH];prewriteTypes=[ne.MESH];createVolume(){return new W2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_volume){let a=this.createVolume();e.materials[s].setExtension(Vs,a);let o=r.extensions[Vs];if(o.extras)a.setExtras(o.extras);if(o.thicknessFactor!==void 0)a.setThicknessFactor(o.thicknessFactor);if(o.attenuationDistance!==void 0)a.setAttenuationDistance(o.attenuationDistance);if(o.attenuationColor!==void 0)a.setAttenuationColor(o.attenuationColor);if(o.thicknessTexture!==void 0){let c=o.thicknessTexture,l=e.textures[i[c.index].source];a.setThicknessTexture(l),e.setTextureInfo(a.getThicknessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Vs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Vs]=a,i.getThicknessFactor()>0)a.thicknessFactor=i.getThicknessFactor();if(Number.isFinite(i.getAttenuationDistance()))a.attenuationDistance=i.getAttenuationDistance();if(!pt.eq(i.getAttenuationColor(),[1,1,1]))a.attenuationColor=i.getAttenuationColor();if(i.getThicknessTexture()){let o=i.getThicknessTexture(),c=i.getThicknessTextureInfo();a.thicknessTexture=e.createTextureInfoDef(o,c)}}}),this}},fw=class extends xt{extensionName=LS;static EXTENSION_NAME=LS;read(e){return this}write(e){return this}},wg=class extends xt{extensionName=FS;static EXTENSION_NAME=FS;read(e){return this}write(e){return this}},q2=class extends nt{static EXTENSION_NAME=js;init(){this.extensionName=js,this.propertyType="Visibility",this.parentTypes=[ne.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{visible:!0})}getVisible(){return this.get("visible")}setVisible(e){return this.set("visible",e)}},J2=class extends xt{static EXTENSION_NAME=js;extensionName=js;createVisibility(){return new q2(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_node_visibility){let i=this.createVisibility();e.nodes[n].setExtension(js,i);let r=t.extensions[js];if(r.visible!==void 0)i.setVisible(r.visible)}}),this}write(e){let t=e.jsonDoc;for(let n of this.document.getRoot().listNodes()){let i=n.getExtension(js);if(!i)continue;let r=e.nodeIndexMap.get(n),s=t.json.nodes[r];s.extensions=s.extensions||{},s.extensions[js]={visible:i.getVisible()}}return this}};Mg=class extends xt{static EXTENSION_NAME=Gd;extensionName=Gd;prereadTypes=[ne.TEXTURE];static register(){ji.registerFormat("image/ktx2",new Y2)}preread(e){if(e.jsonDoc.json.textures)e.jsonDoc.json.textures.forEach((t)=>{if(t.extensions&&t.extensions.KHR_texture_basisu)t.source=t.extensions[Gd].source});return this}read(e){return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listTextures().forEach((n)=>{if(n.getMimeType()==="image/ktx2"){let i=e.imageIndexMap.get(n);t.json.textures.forEach((r)=>{if(r.source===i)r.extensions=r.extensions||{},r.extensions[Gd]={source:r.source},delete r.source})}}),this}},Q2=class extends nt{static EXTENSION_NAME=Hs;init(){this.extensionName=Hs,this.propertyType="Transform",this.parentTypes=[ne.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getRotation(){return this.get("rotation")}setRotation(e){return this.set("rotation",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getTexCoord(){return this.get("texCoord")}setTexCoord(e){return this.set("texCoord",e)}},eU=class extends xt{extensionName=Hs;static EXTENSION_NAME=Hs;createTransform(){return new Q2(this.document.getGraph())}read(e){for(let[t,n]of Array.from(e.textureInfos.entries())){if(!n.extensions||!n.extensions.KHR_texture_transform)continue;let i=this.createTransform(),r=n.extensions[Hs];if(r.offset!==void 0)i.setOffset(r.offset);if(r.rotation!==void 0)i.setRotation(r.rotation);if(r.scale!==void 0)i.setScale(r.scale);if(r.texCoord!==void 0)i.setTexCoord(r.texCoord);t.setExtension(Hs,i)}return this}write(e){let t=Array.from(e.textureInfoDefMap.entries());for(let[n,i]of t){let r=n.getExtension(Hs);if(!r)continue;i.extensions=i.extensions||{};let s={},a=pt.eq;if(!a(r.getOffset(),[0,0]))s.offset=r.getOffset();if(r.getRotation()!==0)s.rotation=r.getRotation();if(!a(r.getScale(),[1,1]))s.scale=r.getScale();if(r.getTexCoord()!=null)s.texCoord=r.getTexCoord();i.extensions[Hs]=s}return this}},tU=[ne.ROOT,ne.SCENE,ne.NODE,ne.MESH,ne.MATERIAL,ne.TEXTURE,ne.ANIMATION],nU=class extends nt{static EXTENSION_NAME=Hi;init(){this.extensionName=Hi,this.propertyType="Packet",this.parentTypes=tU}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(e){return this.set("context",{...e})}listProperties(){return Object.keys(this.get("properties"))}getProperty(e){let t=this.get("properties");return e in t?t[e]:null}setProperty(e,t){this._assertContext(e);let n={...this.get("properties")};if(t)n[e]=t;else delete n[e];return this.set("properties",n)}toJSONLD(){return{"@context":Eg(this.get("context")),...Eg(this.get("properties"))}}fromJSONLD(e){e=Eg(e);let t=e["@context"];if(t)this.set("context",t);return delete e["@context"],this.set("properties",e)}_assertContext(e){if(!(e.split(":")[0]in this.get("context")))throw Error(`${Hi}: Missing context for term, "${e}".`)}};iU=class extends xt{extensionName=Hi;static EXTENSION_NAME=Hi;createPacket(){return new nU(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(e){let t=e.jsonDoc.json.extensions?.[Hi];if(!t||!t.packets)return this;let n=e.jsonDoc.json,i=this.document.getRoot(),r=t.packets.map((o)=>this.createPacket().fromJSONLD(o)),s=[[n.asset],n.scenes,n.nodes,n.meshes,n.materials,n.images,n.animations],a=[[i],i.listScenes(),i.listNodes(),i.listMeshes(),i.listMaterials(),i.listTextures(),i.listAnimations()];for(let o=0;o<s.length;o++){let c=s[o]||[];for(let l=0;l<c.length;l++){let u=c[l];if(u.extensions&&u.extensions.KHR_xmp_json_ld){let d=u.extensions[Hi];a[o][l].setExtension(Hi,r[d.packet])}}}return this}write(e){let{json:t}=e.jsonDoc,n=[];for(let i of this.properties){n.push(i.toJSONLD());for(let r of i.listParents()){let s;switch(r.propertyType){case ne.ROOT:s=t.asset;break;case ne.SCENE:s=t.scenes[e.sceneIndexMap.get(r)];break;case ne.NODE:s=t.nodes[e.nodeIndexMap.get(r)];break;case ne.MESH:s=t.meshes[e.meshIndexMap.get(r)];break;case ne.MATERIAL:s=t.materials[e.materialIndexMap.get(r)];break;case ne.TEXTURE:s=t.images[e.imageIndexMap.get(r)];break;case ne.ANIMATION:s=t.animations[e.animationIndexMap.get(r)];break;default:s=null,this.document.getLogger().warn(`[${Hi}]: Unsupported parent property, "${r.propertyType}"`)}if(!s)continue;s.extensions=s.extensions||{},s.extensions[Hi]={packet:n.length-1}}}if(n.length>0)t.extensions=t.extensions||{},t.extensions[Hi]={packets:n};return this}},rU=[$F,KF,ow,i2,c2,d2,b2,x2,v2,cw,w2,lw,uw,O2,V2,dw,$2,X2,fw,wg,J2,Mg,eU,iU],hw=[$d,j8,pl,bF,nw,iw,...rU]});var mw=Xr(function(j$,pw){function sU(e){var t=Array(e);for(var n=0;n<e;++n)t[n]=n;return t}pw.exports=sU});var yw=Xr(function(H$,bw){/*!+ `},i=new bs(5,5,5),r=new Ei({name:"CubemapFromEquirect",uniforms:Sa(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:kn,blending:dr});r.uniforms.tEquirect.value=t;let s=new jt(i,r),a=t.minFilter;if(t.minFilter===fr)t.minFilter=En;return new Hm(1,10,this).update(e,s),t.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}};yD={[Dp]:"LINEAR_TONE_MAPPING",[Lp]:"REINHARD_TONE_MAPPING",[Fp]:"CINEON_TONE_MAPPING",[Xc]:"ACES_FILMIC_TONE_MAPPING",[Bp]:"AGX_TONE_MAPPING",[zp]:"NEUTRAL_TONE_MAPPING",[Up]:"CUSTOM_TONE_MAPPING"};TA=new en,rg=new wa(1,1),AA=new Td,wA=new Pm,SA=new Cd,rA=[],sA=[],aA=new Float32Array(16),oA=new Float32Array(9),cA=new Float32Array(4);ng=/(\w+)(\])?(\[|\.)?/g;dA=new tt;hL={[Dp]:"Linear",[Lp]:"Reinhard",[Fp]:"Cineon",[Xc]:"ACESFilmic",[Bp]:"AgX",[zp]:"Neutral",[Up]:"Custom"};jd=new j;yL=/^[ \t]*#include +<([\w\d./]+)>/gm;_L=new Map;EL=/#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;AL={[Kc]:"SHADOWMAP_TYPE_PCF",[Ao]:"SHADOWMAP_TYPE_VSM"};SL={[So]:"ENVMAP_TYPE_CUBE",[ya]:"ENVMAP_TYPE_CUBE",[qc]:"ENVMAP_TYPE_CUBE_UV"};RL={[ya]:"ENVMAP_MODE_REFRACTION"};CL={[AT]:"ENVMAP_BLENDING_MULTIPLY",[wT]:"ENVMAP_BLENDING_MIX",[ST]:"ENVMAP_BLENDING_ADD"};XL=[new j(1,0,0),new j(-1,0,0),new j(0,1,0),new j(0,-1,0),new j(0,0,1),new j(0,0,-1)],qL=[new j(0,-1,0),new j(0,-1,0),new j(0,0,1),new j(0,0,-1),new j(0,-1,0),new j(0,-1,0)],_A=new Qe,pl=new j,ig=new j;OA=class OA extends Vi{constructor(e,t){super();let n=this,i=null,r=1,s=null,a="local-floor",o=1,c=null,l=null,u=null,d=null,f=null,h=null,b=typeof XRWebGLBinding<"u",m=new PA,g={},p=t.getContextAttributes(),x=null,_=null,y=[],v=[],T=new Ke,A=null,E=null,w=new fn;w.viewport=new Pt;let P=new fn;P.viewport=new Pt;let S=[w,P],I=new Gm,U=null,N=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let L=y[J];if(L===void 0)L=new el,y[J]=L;return L.getTargetRaySpace()},this.getControllerGrip=function(J){let L=y[J];if(L===void 0)L=new el,y[J]=L;return L.getGripSpace()},this.getHand=function(J){let L=y[J];if(L===void 0)L=new el,y[J]=L;return L.getHandSpace()};function F(J){let L=v.indexOf(J.inputSource);if(L===-1)return;let W=y[L];if(W!==void 0)W.update(J.inputSource,J.frame,c||s),W.dispatchEvent({type:J.type,data:J.inputSource})}function D(){i.removeEventListener("select",F),i.removeEventListener("selectstart",F),i.removeEventListener("selectend",F),i.removeEventListener("squeeze",F),i.removeEventListener("squeezestart",F),i.removeEventListener("squeezeend",F),i.removeEventListener("end",D),i.removeEventListener("inputsourceschange",O);for(let J=0;J<y.length;J++){let L=v[J];if(L===null)continue;v[J]=null,y[J].disconnect(L)}U=null,N=null,m.reset();for(let J in g)delete g[J];if(e.setRenderTarget(x),f=null,d=null,u=null,i=null,_=null,pe.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(T.width,T.height,!1),E!==null){let J=E.camera;J.fov=E.fov,J.zoom=E.zoom,J.updateProjectionMatrix(),E=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){if(r=J,n.isPresenting===!0)je("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){if(a=J,n.isPresenting===!0)je("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(J){c=J},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){if(u===null&&b)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return h},this.getSession=function(){return i},this.setSession=async function(J){if(i=J,i!==null){if(x=e.getRenderTarget(),i.addEventListener("select",F),i.addEventListener("selectstart",F),i.addEventListener("selectend",F),i.addEventListener("squeeze",F),i.addEventListener("squeezestart",F),i.addEventListener("squeezeend",F),i.addEventListener("end",D),i.addEventListener("inputsourceschange",O),p.xrCompatible!==!0)await t.makeXRCompatible();if(A=e.getPixelRatio(),e.getSize(T),!(b&&("createProjectionLayer"in XRWebGLBinding.prototype))){let W={antialias:p.antialias,alpha:!0,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,t,W),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),_=new ci(f.framebufferWidth,f.framebufferHeight,{format:pr,type:zi,colorSpace:e.outputColorSpace,stencilBuffer:p.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}else{let W=null,ne=null,ie=null;if(p.depth)ie=p.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,W=p.stencil?Ea:va,ne=p.stencil?Co:hs;let ce={colorFormat:t.RGBA8,depthFormat:ie,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(ce),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),_=new ci(d.textureWidth,d.textureHeight,{format:pr,type:zi,depthTexture:new wa(d.textureWidth,d.textureHeight,ne,void 0,void 0,void 0,void 0,void 0,void 0,W),stencilBuffer:p.stencil,colorSpace:e.outputColorSpace,samples:p.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(o),c=null,s=await i.requestReferenceSpace(a),pe.setContext(i),pe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function O(J){for(let L=0;L<J.removed.length;L++){let W=J.removed[L],ne=v.indexOf(W);if(ne>=0)v[ne]=null,y[ne].disconnect(W)}for(let L=0;L<J.added.length;L++){let W=J.added[L],ne=v.indexOf(W);if(ne===-1){for(let ce=0;ce<y.length;ce++)if(ce>=v.length){v.push(W),ne=ce;break}else if(v[ce]===null){v[ce]=W,ne=ce;break}if(ne===-1)break}let ie=y[ne];if(ie)ie.connect(W)}}let K=new j,B=new j;function X(J,L,W){K.setFromMatrixPosition(L.matrixWorld),B.setFromMatrixPosition(W.matrixWorld);let ne=K.distanceTo(B),ie=L.projectionMatrix.elements,ce=W.projectionMatrix.elements,_e=ie[14]/(ie[10]-1),Re=ie[14]/(ie[10]+1),Oe=(ie[9]+1)/ie[5],We=(ie[9]-1)/ie[5],Ye=(ie[8]-1)/ie[0],Wt=(ce[8]+1)/ce[0],lt=_e*Ye,Lt=_e*Wt,Qt=ne/(-Ye+Wt),nn=Qt*-Ye;if(L.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(nn),J.translateZ(Qt),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert(),ie[10]===-1)J.projectionMatrix.copy(L.projectionMatrix),J.projectionMatrixInverse.copy(L.projectionMatrixInverse);else{let z=_e+Qt,yn=Re+Qt,St=lt-nn,Xt=Lt+(ne-nn),C=Oe*Re/yn*z,M=We*Re/yn*z;J.projectionMatrix.makePerspective(St,Xt,C,M,z,yn),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}}function q(J,L){if(L===null)J.matrixWorld.copy(J.matrix);else J.matrixWorld.multiplyMatrices(L.matrixWorld,J.matrix);J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(i===null)return;let{near:L,far:W}=J;if(m.texture!==null){if(m.depthNear>0)L=m.depthNear;if(m.depthFar>0)W=m.depthFar}if(I.near=P.near=w.near=L,I.far=P.far=w.far=W,U!==I.near||N!==I.far)i.updateRenderState({depthNear:I.near,depthFar:I.far}),U=I.near,N=I.far;I.layers.mask=J.layers.mask|6,w.layers.mask=I.layers.mask&-5,P.layers.mask=I.layers.mask&-3;let ne=J.parent,ie=I.cameras;q(I,ne);for(let ce=0;ce<ie.length;ce++)q(ie[ce],ne);if(ie.length===2)X(I,w,P);else I.projectionMatrix.copy(w.projectionMatrix);if(E===null&&J.isPerspectiveCamera)E={camera:J,fov:J.fov,zoom:J.zoom};le(J,I,ne)};function le(J,L,W){if(W===null)J.matrix.copy(L.matrixWorld);else J.matrix.copy(W.matrixWorld),J.matrix.invert(),J.matrix.multiply(L.matrixWorld);if(J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(L.projectionMatrix),J.projectionMatrixInverse.copy(L.projectionMatrixInverse),J.isPerspectiveCamera)J.fov=xa*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1}this.getCamera=function(){return I},this.getFoveation=function(){if(d===null&&f===null)return;return o},this.setFoveation=function(J){if(o=J,d!==null)d.fixedFoveation=J;if(f!==null&&f.fixedFoveation!==void 0)f.fixedFoveation=J},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(I)},this.getCameraTexture=function(J){return g[J]};let de=null;function Me(J,L){if(l=L.getViewerPose(c||s),h=L,l!==null){let W=l.views;if(f!==null)e.setRenderTargetFramebuffer(_,f.framebuffer),e.setRenderTarget(_);let ne=!1;if(W.length!==I.cameras.length)I.cameras.length=0,ne=!0;for(let Re=0;Re<W.length;Re++){let Oe=W[Re],We=null;if(f!==null)We=f.getViewport(Oe);else{let Wt=u.getViewSubImage(d,Oe);if(We=Wt.viewport,Re===0)e.setRenderTargetTextures(_,Wt.colorTexture,Wt.depthStencilTexture),e.setRenderTarget(_)}let Ye=S[Re];if(Ye===void 0)Ye=new fn,Ye.layers.enable(Re),Ye.viewport=new Pt,S[Re]=Ye;if(Ye.matrix.fromArray(Oe.transform.matrix),Ye.matrix.decompose(Ye.position,Ye.quaternion,Ye.scale),Ye.projectionMatrix.fromArray(Oe.projectionMatrix),Ye.projectionMatrixInverse.copy(Ye.projectionMatrix).invert(),Ye.viewport.set(We.x,We.y,We.width,We.height),Re===0)I.matrix.copy(Ye.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale);if(ne===!0)I.cameras.push(Ye)}let ie=i.enabledFeatures;if(ie&&ie.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&b){u=n.getBinding();let Re=u.getDepthInformation(W[0]);if(Re&&Re.isValid&&Re.texture)m.init(Re,i.renderState)}if(ie&&ie.includes("camera-access")&&b){e.state.unbindTexture(),u=n.getBinding();for(let Re=0;Re<W.length;Re++){let Oe=W[Re].camera;if(Oe){let We=g[Oe];if(!We)We=new Nd,g[Oe]=We;let Ye=u.getCameraImage(Oe);We.sourceTexture=Ye}}}}for(let W=0;W<y.length;W++){let ne=v[W],ie=y[W];if(ne!==null&&ie!==void 0)ie.update(ne,L,c||s)}if(de)de(J,L);if(L.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:L});h=null}let pe=new vA;pe.setAnimationLoop(Me),this.setAnimationLoop=function(J){de=J},this.dispose=function(){}}};n8=new Qe,kA=new tt;kA.set(-1,0,0,0,1,0,0,0,1);s8=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183])});async function El(e){let t=await crypto.subtle.digest("SHA-256",Uint8Array.from(e));return Array.from(new Uint8Array(t),(n)=>n.toString(16).padStart(2,"0")).join("")}function P8(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=()=>{throw Error("Texture manifest cannot read image dimensions")},i=(s,a)=>{if(s+a>e.byteLength)n()};if(e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71)return i(16,8),{width:t.getUint32(16),height:t.getUint32(20)};if(Sg(e))return i(20,8),{width:t.getUint32(20,!0),height:t.getUint32(24,!0)};if(e[0]===255&&e[1]===216){let s=2;while(s+4<=e.byteLength){if(e[s]!==255)n();let a=e[s+1];if(a===255){s++;continue}if(a===216||a===1||a>=208&&a<=215){s+=2;continue}let o=t.getUint16(s+2);if(a>=192&&a<=207&&![196,200,204].includes(a))return i(s+5,4),{width:t.getUint16(s+7),height:t.getUint16(s+5)};s+=2+o}n()}let r=(s)=>String.fromCharCode(...e.subarray(s,Math.min(s+4,e.byteLength)));if(r(0)==="RIFF"&&r(8)==="WEBP"){i(12,19);let s=r(12);if(s==="VP8X")return{width:1+(t.getUint32(24,!0)&16777215),height:1+(t.getUint32(27,!0)&16777215)};if(s==="VP8L"){let a=t.getUint32(21,!0);return{width:1+(a&16383),height:1+(a>>14&16383)}}if(s==="VP8 ")return i(26,4),{width:t.getUint16(26,!0)&16383,height:t.getUint16(28,!0)&16383}}return n()}function O8(e){if(!Ss(e))return;let t=Ss(e.extensions)?e.extensions:{};for(let n of["KHR_texture_basisu","EXT_texture_webp","EXT_texture_avif"]){let i=t[n];if(Ss(i)&&ws(i.source)!==void 0)return ws(i.source)}return ws(e.source)}function k8(e){let t=Array.isArray(e.textures)?e.textures:[],n=new Set;for(let i of Array.isArray(e.materials)?e.materials:[]){if(!Ss(i))continue;let r=Ss(i.pbrMetallicRoughness)?i.pbrMetallicRoughness:{};for(let s of[r.baseColorTexture,i.emissiveTexture]){let a=Ss(s)?ws(s.index):void 0,o=a===void 0?void 0:O8(t[a]);if(o!==void 0)n.add(o)}}return n}function D8(e){let t=atob(e);return Uint8Array.from(t,(n)=>n.charCodeAt(0))}function L8(e,t){let n=Array.isArray(e.bufferViews)?e.bufferViews:[];return(Array.isArray(e.images)?e.images:[]).map((i)=>{if(!Ss(i))throw Error("Invalid glTF image");let r=ws(i.bufferView);if(r!==void 0){let a=n[r];if(!Ss(a)||ws(a.buffer)!==0||!t)throw Error("Texture manifest requires images embedded in the GLB binary chunk");let o=ws(a.byteOffset)??0,c=ws(a.byteLength);if(c===void 0||o+c>t.byteLength)throw Error("Invalid glTF image buffer view");if(typeof i.mimeType!=="string")throw Error("Embedded image needs a mimeType");return{bytes:t.subarray(o,o+c),mimeType:i.mimeType}}let s=typeof i.uri==="string"?/^data:([^;,]+);base64,(.*)$/s.exec(i.uri):null;if(!s)throw Error("Texture manifest requires embedded image bytes");return{bytes:D8(s[2]),mimeType:s[1]}})}async function Rw(e,t,n={}){let i=k8(e),r=[];for(let[s,{bytes:a,mimeType:o}]of L8(e,t).entries()){let c=`sha256:${await El(a)}`,l=n.sources?.get(s),u=l??c,d=n.maps?.find((f)=>f.sha256===u);r.push({image:s,sha256:c,bytes:a.byteLength,mimeType:o,...P8(a),colorSpace:i.has(s)?"srgb":"linear",...l&&l!==c?{sourceSha256:l}:{},...d?{material:{pin:{...d.pin},slot:d.slot}}:{}})}return r}function Iw(e){let t={"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/ktx2":"ktx2"}[e];if(!t)throw Error(`External textures do not support ${e}`);return t}var Ss=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),ws=(e)=>Number.isInteger(e)&&e>=0?e:void 0,N8,Sg=(e)=>e.byteLength>=12&&N8.every((t,n)=>e[n]===t);var Mg=mt(()=>{N8=Object.freeze([171,75,84,88,32,50,48,187,13,10,26,10])});var Cw=class{_listeners={};addEventListener(e,t){let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t);return this}removeEventListener(e,t){let n=this._listeners[e];if(n!==void 0){let i=n.indexOf(t);if(i!==-1)n.splice(i,1)}return this}dispatchEvent(e){let t=this._listeners[e.type];if(t!==void 0){let n=t.slice(0);for(let i=0,r=n.length;i<r;i++)n[i].call(this,e)}return this}dispose(){for(let e in this._listeners)delete this._listeners[e]}},Rs=class{_disposed=!1;_name;_parent;_child;_attributes;constructor(e,t,n,i={}){if(this._name=e,this._parent=t,this._child=n,this._attributes=i,!t.isOnGraph(n))throw Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(e){return this._child=e,this}getAttributes(){return this._attributes}dispose(){if(this._disposed)return;this._parent._destroyRef(this),this._disposed=!0}isDisposed(){return this._disposed}},Rg,bn=class{list=[];constructor(e){if(e)for(let t of e)this.list.push(t)}add(e){this.list.push(e)}remove(e){let t=this.list.indexOf(e);if(t>=0)this.list.splice(t,1)}removeChild(e){let t=[];for(let n of this.list)if(n.getChild()===e)t.push(n);for(let n of t)this.remove(n);return t}listRefsByChild(e){let t=[];for(let n of this.list)if(n.getChild()===e)t.push(n);return t}values(){return this.list}},It=class{set=new Set;map=new Map;constructor(e){if(e)for(let t of e)this.add(t)}add(e){let t=e.getChild();this.removeChild(t),this.set.add(e),this.map.set(t,e)}remove(e){this.set.delete(e),this.map.delete(e.getChild())}removeChild(e){let t=this.map.get(e)||null;if(t)this.remove(t);return t}getRefByChild(e){return this.map.get(e)||null}values(){return Array.from(this.set)}},dn=class{map={};constructor(e){if(e)Object.assign(this.map,e)}set(e,t){this.map[e]=t}delete(e){delete this.map[e]}get(e){return this.map[e]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}},At,Ms,Nw;var Pw=mt(()=>{Rg=class extends Cw{_emptySet=new Set;_edges=new Set;_parentEdges=new Map;_childEdges=new Map;listEdges(){return Array.from(this._edges)}listParentEdges(e){return Array.from(this._childEdges.get(e)||this._emptySet)}listParents(e){let t=new Set;for(let n of this.listParentEdges(e))t.add(n.getParent());return Array.from(t)}listChildEdges(e){return Array.from(this._parentEdges.get(e)||this._emptySet)}listChildren(e){let t=new Set;for(let n of this.listChildEdges(e))t.add(n.getChild());return Array.from(t)}disconnectParents(e,t){for(let n of this.listParentEdges(e))if(!t||t(n.getParent()))n.dispose();return this}_createEdge(e,t,n,i){let r=new Rs(e,t,n,i);this._edges.add(r);let s=r.getParent();if(!this._parentEdges.has(s))this._parentEdges.set(s,new Set);this._parentEdges.get(s).add(r);let a=r.getChild();if(!this._childEdges.has(a))this._childEdges.set(a,new Set);return this._childEdges.get(a).add(r),r}_destroyEdge(e){return this._edges.delete(e),this._parentEdges.get(e.getParent()).delete(e),this._childEdges.get(e.getChild()).delete(e),this}},At=Symbol("attributes"),Ms=Symbol("immutableKeys"),Nw=class e extends Cw{_disposed=!1;graph;[At];[Ms];constructor(t){super();this.graph=t,this[Ms]=new Set,this[At]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let t=this.getDefaults(),n={};for(let i in t){let r=t[i];if(r instanceof e){let s=this.graph._createEdge(i,this,r);this[Ms].add(i),n[i]=s}else n[i]=r}return n}isOnGraph(t){return this.graph===t.graph}isDisposed(){return this._disposed}dispose(){if(this._disposed)return;this.graph.listChildEdges(this).forEach((t)=>t.dispose()),this.graph.disconnectParents(this),this._disposed=!0,this.dispatchEvent({type:"dispose"})}detach(){return this.graph.disconnectParents(this),this}swap(t,n){for(let i in this[At]){let r=this[At][i];if(r instanceof Rs){let s=r;if(s.getChild()===t)this.setRef(i,n,s.getAttributes())}else if(r instanceof bn)for(let s of r.listRefsByChild(t)){let a=s.getAttributes();this.removeRef(i,t),this.addRef(i,n,a)}else if(r instanceof It){let s=r.getRefByChild(t);if(s){let a=s.getAttributes();this.removeRef(i,t),this.addRef(i,n,a)}}else if(r instanceof dn)for(let s of r.keys()){let a=r.get(s);if(a.getChild()===t)this.setRefMap(i,s,n,a.getAttributes())}}return this}get(t){return this[At][t]}set(t,n){return this[At][t]=n,this.dispatchEvent({type:"change",attribute:t})}getRef(t){let n=this[At][t];return n?n.getChild():null}setRef(t,n,i){if(this[Ms].has(t))throw Error(`Cannot overwrite immutable attribute, "${t}".`);let r=this[At][t];if(r)r.dispose();if(!n)return this;let s=this.graph._createEdge(t,this,n,i);return this[At][t]=s,this.dispatchEvent({type:"change",attribute:t})}listRefs(t){return this.assertRefList(t).values().map((n)=>n.getChild())}addRef(t,n,i){let r=this.graph._createEdge(t,this,n,i);return this.assertRefList(t).add(r),this.dispatchEvent({type:"change",attribute:t})}removeRef(t,n){let i=this.assertRefList(t);if(i instanceof bn)for(let r of i.listRefsByChild(n))r.dispose();else{let r=i.getRefByChild(n);if(r)r.dispose()}return this}assertRefList(t){let n=this[At][t];if(n instanceof bn||n instanceof It)return n;throw Error(`Expected RefList or RefSet for attribute "${t}"`)}listRefMapKeys(t){return this.assertRefMap(t).keys()}listRefMapValues(t){return this.assertRefMap(t).values().map((n)=>n.getChild())}getRefMap(t,n){let i=this.assertRefMap(t).get(n);return i?i.getChild():null}setRefMap(t,n,i,r){let s=this.assertRefMap(t),a=s.get(n);if(a)a.dispose();if(!i)return this;r=Object.assign(r||{},{key:n});let o=this.graph._createEdge(t,this,i,{...r,key:n});return s.set(n,o),this.dispatchEvent({type:"change",attribute:t,key:n})}assertRefMap(t){let n=this[At][t];if(n instanceof dn)return n;throw Error(`Expected RefMap for attribute "${t}"`)}dispatchEvent(t){return super.dispatchEvent({...t,target:this}),this.graph.dispatchEvent({...t,target:this,type:`node:${t.type}`}),this}_destroyRef(t){let n=t.getName();if(this[At][n]===t){if(this[At][n]=null,this[Ms].has(n))t.getChild().dispose()}else if(this[At][n]instanceof bn)this[At][n].remove(t);else if(this[At][n]instanceof It)this[At][n].remove(t);else if(this[At][n]instanceof dn){let i=this[At][n];for(let r of i.keys())if(i.get(r)===t)i.delete(r)}else return;this.graph._destroyEdge(t),this.dispatchEvent({type:"change",attribute:n})}}});function V8(e,t){if(t>e.byteLength)throw TypeError("Corrupt JPG, exceeded buffer limits");if(e.getUint8(t)!==255)throw TypeError("Invalid JPG, marker table corrupted");return e}function j8(){var e=new Ng(3);if(Ng!=Float32Array)e[0]=0,e[1]=0,e[2]=0;return e}function Ig(e){var t=e[0],n=e[1],i=e[2];return Math.sqrt(t*t+n*n+i*i)}function H8(e,t,n){var i=t[0],r=t[1],s=t[2],a=n[3]*i+n[7]*r+n[11]*s+n[15];return a=a||1,e[0]=(n[0]*i+n[4]*r+n[8]*s+n[12])/a,e[1]=(n[1]*i+n[5]*r+n[9]*s+n[13])/a,e[2]=(n[2]*i+n[6]*r+n[10]*s+n[14])/a,e}function Og(e){let t=jw(),n=e.propertyType==="Node"?[e]:e.listChildren();for(let i of n)i.traverse((r)=>{let s=r.getMesh();if(!s)return;let a=G8(s,r.getWorldMatrix());if(a.min.every(isFinite)&&a.max.every(isFinite))Pg(a.min,t),Pg(a.max,t)});return t}function G8(e,t){let n=jw();for(let i of e.listPrimitives()){let r=i.getAttribute("POSITION"),s=i.getIndices();if(!r)continue;let a=[0,0,0],o=[0,0,0];for(let c=0,l=s?s.getCount():r.getCount();c<l;c++){let u=s?s.getScalar(c):c;a=r.getElement(u,a),o=H8(o,a,t),Pg(o,n)}}return n}function Pg(e,t){for(let n=0;n<3;n++)t.min[n]=Math.min(e[n],t.min[n]),t.max[n]=Math.max(e[n],t.max[n])}function jw(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}function kw(e){return Object.prototype.toString.call(e)==="[object Object]"}function Na(e){if(kw(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;if(kw(n)===!1)return!1;if(Object.hasOwn(n,"isPrototypeOf")===!1)return!1;return!0}function K8(e){var t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],h=e[12],b=e[13],m=e[14],g=e[15],p=t*a-n*s,x=t*o-i*s,_=n*o-i*a,y=l*b-u*h,v=l*m-d*h,T=u*m-d*b,A=t*T-n*v+i*y,E=s*T-a*v+o*y,w=l*_-u*x+d*p,P=h*_-b*x+m*p;return c*A-r*E+g*w-f*P}function W8(e,t,n){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],h=t[10],b=t[11],m=t[12],g=t[13],p=t[14],x=t[15],_=n[0],y=n[1],v=n[2],T=n[3];return e[0]=_*i+y*o+v*d+T*m,e[1]=_*r+y*c+v*f+T*g,e[2]=_*s+y*l+v*h+T*p,e[3]=_*a+y*u+v*b+T*x,_=n[4],y=n[5],v=n[6],T=n[7],e[4]=_*i+y*o+v*d+T*m,e[5]=_*r+y*c+v*f+T*g,e[6]=_*s+y*l+v*h+T*p,e[7]=_*a+y*u+v*b+T*x,_=n[8],y=n[9],v=n[10],T=n[11],e[8]=_*i+y*o+v*d+T*m,e[9]=_*r+y*c+v*f+T*g,e[10]=_*s+y*l+v*h+T*p,e[11]=_*a+y*u+v*b+T*x,_=n[12],y=n[13],v=n[14],T=n[15],e[12]=_*i+y*o+v*d+T*m,e[13]=_*r+y*c+v*f+T*g,e[14]=_*s+y*l+v*h+T*p,e[15]=_*a+y*u+v*b+T*x,e}function X8(e,t){var n=t[0],i=t[1],r=t[2],s=t[4],a=t[5],o=t[6],c=t[8],l=t[9],u=t[10];return e[0]=Math.sqrt(n*n+i*i+r*r),e[1]=Math.sqrt(s*s+a*a+o*o),e[2]=Math.sqrt(c*c+l*l+u*u),e}function q8(e,t){var n=new Ng(3);X8(n,t);var i=1/n[0],r=1/n[1],s=1/n[2],a=t[0]*i,o=t[1]*r,c=t[2]*s,l=t[4]*i,u=t[5]*r,d=t[6]*s,f=t[8]*i,h=t[9]*r,b=t[10]*s,m=a+u+b,g=0;if(m>0)g=Math.sqrt(m+1)*2,e[3]=0.25*g,e[0]=(d-h)/g,e[1]=(f-c)/g,e[2]=(o-l)/g;else if(a>u&&a>b)g=Math.sqrt(1+a-u-b)*2,e[3]=(d-h)/g,e[0]=0.25*g,e[1]=(o+l)/g,e[2]=(f+c)/g;else if(u>b)g=Math.sqrt(1+u-a-b)*2,e[3]=(f-c)/g,e[0]=(o+l)/g,e[1]=0.25*g,e[2]=(d+h)/g;else g=Math.sqrt(1+b-a-u)*2,e[3]=(o-l)/g,e[0]=(f+c)/g,e[1]=(d+h)/g,e[2]=0.25*g;return e}function J8(e,t){if(!!e!==!!t)return!1;let n=e.getChild(),i=t.getChild();return n===i||n.equals(i)}function Z8(e,t){if(!!e!==!!t)return!1;let n=e.values(),i=t.values();if(n.length!==i.length)return!1;for(let r=0;r<n.length;r++){let s=n[r],a=i[r];if(s.getChild()===a.getChild())continue;if(!s.getChild().equals(a.getChild()))return!1}return!0}function Y8(e,t){if(!!e!==!!t)return!1;let n=e.keys(),i=t.keys();if(n.length!==i.length)return!1;for(let r of n){let s=e.get(r),a=t.get(r);if(!!s!==!!a)return!1;let o=s.getChild(),c=a.getChild();if(o===c)continue;if(!o.equals(c))return!1}return!0}function Hw(e,t){if(e===t)return!0;if(!!e!==!!t||!e||!t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Gw(e,t){if(e===t)return!0;if(!!e!==!!t)return!1;if(!Na(e)||!Na(t))return e===t;let n=e,i=t,r=0,s=0,a;for(a in n)r++;for(a in i)s++;if(r!==s)return!1;for(a in n){let o=n[a],c=i[a];if(Qd(o)&&Qd(c)){if(!Hw(o,c))return!1}else if(Na(o)&&Na(c)){if(!Gw(o,c))return!1}else if(o!==c)return!1}return!0}function Qd(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function rF(e){switch(e.constructor){case Float32Array:return Be.ComponentType.FLOAT;case Uint32Array:return Be.ComponentType.UNSIGNED_INT;case Uint16Array:return Be.ComponentType.UNSIGNED_SHORT;case Uint8Array:return Be.ComponentType.UNSIGNED_BYTE;case Int16Array:return Be.ComponentType.SHORT;case Int8Array:return Be.ComponentType.BYTE;case Float64Array:return Be.ComponentType.FLOAT64}if(typeof Float16Array<"u"&&e.constructor===Float16Array)return Be.ComponentType.FLOAT16;throw Error("Unknown accessor componentType.")}function lF(e,t){let n=t.jsonDoc,i=t.bufferViews[e.bufferView],r=n.json.bufferViews[e.bufferView],s=Tl[e.componentType],a=Be.getElementSize(e.type),o=s.BYTES_PER_ELEMENT,c=e.byteOffset||0,l=new s(e.count*a),u=new DataView(i.buffer,i.byteOffset,i.byteLength),d=r.byteStride;for(let f=0;f<e.count;f++)for(let h=0;h<a;h++){let b=c+f*d+h*o,m;switch(e.componentType){case Be.ComponentType.FLOAT:m=u.getFloat32(b,!0);break;case Be.ComponentType.UNSIGNED_INT:m=u.getUint32(b,!0);break;case Be.ComponentType.UNSIGNED_SHORT:m=u.getUint16(b,!0);break;case Be.ComponentType.UNSIGNED_BYTE:m=u.getUint8(b);break;case Be.ComponentType.SHORT:m=u.getInt16(b,!0);break;case Be.ComponentType.BYTE:m=u.getInt8(b);break;case Be.ComponentType.FLOAT16:m=u.getFloat16(b,!0);break;case Be.ComponentType.FLOAT64:m=u.getFloat64(b,!0);break;default:throw Error(`Unexpected componentType "${e.componentType}".`)}l[f*a+h]=m}return l}function Yd(e,t){let n=t.jsonDoc,i=t.bufferViews[e.bufferView],r=n.json.bufferViews[e.bufferView],s=Tl[e.componentType],a=Be.getElementSize(e.type),o=s.BYTES_PER_ELEMENT,c=a*o;if(r.byteStride!==void 0&&r.byteStride!==c)return lF(e,t);let l=i.byteOffset+(e.byteOffset||0),u=e.count*a*o;return new s(i.buffer.slice(l,l+u))}function uF(e,t){let n=Tl[e.componentType],i=Be.getElementSize(e.type),r;if(e.bufferView!==void 0)r=Yd(e,t);else r=new n(e.count*i);let s=e.sparse;if(!s)return r;let a=s.count,o={...e,...s.indices,count:a,type:"SCALAR"},c={...e,...s.values,count:a},l=Yd(o,t),u=Yd(c,t);for(let d=0;d<o.count;d++)for(let f=0;f<i;f++)r[l[d]*i+f]=u[d*i+f];return r}function dF(e,t){let n=e.getGraph().listParentEdges(t).find((i)=>i.getParent()!==e.getRoot());return n?n.getName().replace(/texture$/i,""):""}function bF(e){let t=[];for(let n in e){let i=e[n];if(Array.isArray(i)&&i.length===0)t.push(n);else if(i===null||i==="")t.push(n);else if(i&&typeof i==="object"&&Object.keys(i).length===0)t.push(n)}for(let n of t)delete e[n]}function yF(e,t){return t.uri!==void 0&&!(t.uri in e.resources)}function _F(e,t){return t.uri!==void 0&&!(t.uri in e.resources)&&t.bufferView===void 0}function Uw(e){if(e.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;let t=new Uint32Array(e.buffer,e.byteOffset,3);return t[0]===1179937895&&t[1]===2}var Bw="v4.5.1",Cs="@glb.bin",te,F8,Ai,zw,U8,Tl,Je=class{static createBufferFromDataURI(e){if(typeof Buffer>"u"){let t=atob(e.split(",")[1]),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}else{let t=e.split(",")[1],n=e.indexOf("base64")>=0;return Buffer.from(t,n?"base64":"utf8")}}static encodeText(e){return new TextEncoder().encode(e)}static decodeText(e){return new TextDecoder().decode(e)}static concat(e){let t=0;for(let r of e)t+=r.byteLength;let n=new Uint8Array(t),i=0;for(let r of e)n.set(r,i),i+=r.byteLength;return n}static pad(e,t=0){let n=this.padNumber(e.byteLength);if(n===e.byteLength)return e;let i=new Uint8Array(n);if(i.set(e),t!==0)for(let r=e.byteLength;r<n;r++)i[r]=t;return i}static padNumber(e){return Math.ceil(e/4)*4}static equals(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;let n=e.byteLength;while(n--)if(e[n]!==t[n])return!1;return!0}static toView(e,t=0,n=1/0){return new Uint8Array(e.buffer,e.byteOffset+t,Math.min(e.byteLength,n))}static assertView(e){if(e&&!ArrayBuffer.isView(e))throw Error(`Method requires Uint8Array parameter; received "${typeof e}".`);return e}},Vw=class{static hexToFactor(e,t){e=Math.floor(e);let n=t;return n[0]=(e>>16&255)/255,n[1]=(e>>8&255)/255,n[2]=(e&255)/255,this.convertSRGBToLinear(t,t)}static factorToHex(e){let t=[...e],[n,i,r]=this.convertLinearToSRGB(e,t);return n*255<<16^i*255<<8^r*255<<0}static convertSRGBToLinear(e,t){let n=e,i=t;for(let r=0;r<3;r++)i[r]=n[r]<0.04045?n[r]*0.0773993808:Math.pow(n[r]*0.9478672986+0.0521327014,2.4);return t}static convertLinearToSRGB(e,t){let n=e,i=t;for(let r=0;r<3;r++)i[r]=n[r]<0.0031308?n[r]*12.92:1.055*Math.pow(n[r],0.41666)-0.055;return t}},B8=class{match(e){return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255}getSize(e){let t=new DataView(e.buffer,e.byteOffset+4),n,i;while(t.byteLength){if(n=t.getUint16(0,!1),V8(t,n),i=t.getUint8(n+1),i===192||i===193||i===194)return[t.getUint16(n+7,!1),t.getUint16(n+5,!1)];t=new DataView(e.buffer,t.byteOffset+n+2)}throw TypeError("Invalid JPG, no size found")}getChannels(e){return 3}},z8=class e{static PNG_FRIED_CHUNK_NAME="CgBI";match(t){return t.length>=8&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71&&t[4]===13&&t[5]===10&&t[6]===26&&t[7]===10}getSize(t){let n=new DataView(t.buffer,t.byteOffset);if(Je.decodeText(t.slice(12,16))===e.PNG_FRIED_CHUNK_NAME)return[n.getUint32(32,!1),n.getUint32(36,!1)];return[n.getUint32(16,!1),n.getUint32(20,!1)]}getChannels(t){return 4}},Gi,Pa=class{static basename(e){let t=e.split(/[\\/]/).pop();return t.substring(0,t.lastIndexOf("."))}static extension(e){if(e.startsWith("data:image/")){let t=e.match(/data:(image\/\w+)/)[1];return Gi.mimeTypeToExtension(t)}else if(e.startsWith("data:model/gltf+json"))return"gltf";else if(e.startsWith("data:model/gltf-binary"))return"glb";else if(e.startsWith("data:application/"))return"bin";return e.split(/[\\/]/).pop().split(/[.]/).pop()}},Ng,Ow="https://null.example",Cg,$8,ka,pt=class e{static identity(t){return t}static eq(t,n,i=0.00001){if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(Math.abs(t[r]-n[r])>i)return!1;return!0}static clamp(t,n,i){if(t<n)return n;if(t>i)return i;return t}static decodeNormalizedInt(t,n){switch(n){case 5126:return t;case 5123:return t/65535;case 5121:return t/255;case 5122:return Math.max(t/32767,-1);case 5120:return Math.max(t/127,-1);default:throw Error("Invalid component type.")}}static encodeNormalizedInt(t,n){switch(n){case 5126:return t;case 5123:return Math.round(e.clamp(t,0,1)*65535);case 5121:return Math.round(e.clamp(t,0,1)*255);case 5122:return Math.round(e.clamp(t,-1,1)*32767);case 5120:return Math.round(e.clamp(t,-1,1)*127);default:throw Error("Invalid component type.")}}static decompose(t,n,i,r){let s=Ig([t[0],t[1],t[2]]),a=Ig([t[4],t[5],t[6]]),o=Ig([t[8],t[9],t[10]]);if(K8(t)<0)s=-s;n[0]=t[12],n[1]=t[13],n[2]=t[14];let c=t.slice(),l=1/s,u=1/a,d=1/o;c[0]*=l,c[1]*=l,c[2]*=l,c[4]*=u,c[5]*=u,c[6]*=u,c[8]*=d,c[9]*=d,c[10]*=d,q8(i,c),r[0]=s,r[1]=a,r[2]=o}static compose(t,n,i,r){let s=r,a=n[0],o=n[1],c=n[2],l=n[3],u=a+a,d=o+o,f=c+c,h=a*u,b=a*d,m=a*f,g=o*d,p=o*f,x=c*f,_=l*u,y=l*d,v=l*f,T=i[0],A=i[1],E=i[2];return s[0]=(1-(g+x))*T,s[1]=(b+v)*T,s[2]=(m-y)*T,s[3]=0,s[4]=(b-v)*A,s[5]=(1-(h+x))*A,s[6]=(p+_)*A,s[7]=0,s[8]=(m+y)*E,s[9]=(p-_)*E,s[10]=(1-(h+g))*E,s[11]=0,s[12]=t[0],s[13]=t[1],s[14]=t[2],s[15]=1,s}},Q8="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",eF=999,tF=6,Dw,nF=function(){let e="";for(let t=0;t<tF;t++)e+=Q8.charAt(Math.floor(Math.random()*42));return e},$w=function(){for(let e=0;e<eF;e++){let t=nF();if(!Dw.has(t))return Dw.add(t),t}return""},Ns=(e)=>e,iF,kg,Gn,Be,Kw,Da,Al,Ww,ef,nt,wt,Xd,qd,Jd,sF,Oa,Dg,tf,Jn,Lg,nf,Xw,Xo,Ps,rf,_t=class{static EXTENSION_NAME;extensionName="";prereadTypes=[];prewriteTypes=[];readDependencies=[];writeDependencies=[];document;required=!1;properties=new Set;_listener;constructor(e){this.document=e,e.getRoot()._enableExtension(this),this._listener=(n)=>{let i=n,r=i.target;if(r instanceof nt&&r.extensionName===this.extensionName){if(i.type==="node:create")this._addExtensionProperty(r);if(i.type==="node:dispose")this._removeExtensionProperty(r)}};let t=e.getGraph();t.addEventListener("node:create",this._listener),t.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);let e=this.document.getGraph();e.removeEventListener("node:create",this._listener),e.removeEventListener("node:dispose",this._listener);for(let t of this.properties)t.dispose()}static register(){}isRequired(){return this.required}setRequired(e){return this.required=e,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(e){return this.properties.add(e),this}_removeExtensionProperty(e){return this.properties.delete(e),this}install(e,t){return this}preread(e,t){return this}prewrite(e,t){return this}},aF=class{jsonDoc;buffers=[];bufferViews=[];bufferViewBuffers=[];accessors=[];textures=[];textureInfos=new Map;materials=[];meshes=[];cameras=[];nodes=[];skins=[];animations=[];scenes=[];constructor(e){this.jsonDoc=e}setTextureInfo(e,t){if(this.textureInfos.set(e,t),t.texCoord!==void 0)e.setTexCoord(t.texCoord);if(t.extras!==void 0)e.setExtras(t.extras);let n=this.jsonDoc.json.textures[t.index];if(n.sampler===void 0)return;let i=this.jsonDoc.json.samplers[n.sampler];if(i.magFilter!==void 0)e.setMagFilter(i.magFilter);if(i.minFilter!==void 0)e.setMinFilter(i.minFilter);if(i.wrapS!==void 0)e.setWrapS(i.wrapS);if(i.wrapT!==void 0)e.setWrapT(i.wrapT)}},Lw,oF,cF=class{static read(e,t=Lw){let n={...Lw,...t},{json:i}=e,r=new rf().setLogger(n.logger);this.validate(e,n);let s=new aF(e),a=i.asset,o=r.getRoot().getAsset();if(a.copyright)o.copyright=a.copyright;if(a.extras)o.extras=a.extras;if(i.extras!==void 0)r.getRoot().setExtras({...i.extras});let c=i.extensionsUsed||[],l=i.extensionsRequired||[];n.extensions.sort((p,x)=>p.EXTENSION_NAME>x.EXTENSION_NAME?1:-1);for(let p of n.extensions)if(c.includes(p.EXTENSION_NAME)){let x=r.createExtension(p).setRequired(l.includes(p.EXTENSION_NAME)),_=x.prereadTypes.filter((y)=>!oF.has(y));if(_.length)n.logger.warn(`Preread hooks for some types (${_.join()}), requested by extension ${x.extensionName}, are unsupported. Please file an issue or a PR.`);for(let y of x.readDependencies)x.install(y,n.dependencies[y])}let u=i.buffers||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Buffer")).forEach((p)=>p.preread(s,"Buffer")),s.buffers=u.map((p)=>{let x=r.createBuffer(p.name);if(p.extras)x.setExtras(p.extras);if(p.uri&&p.uri.indexOf("__")!==0)x.setURI(p.uri);return x}),s.bufferViewBuffers=(i.bufferViews||[]).map((p,x)=>{if(!s.bufferViews[x]){let _=e.json.buffers[p.buffer],y=_.uri?e.resources[_.uri]:e.resources[Cs],v=p.byteOffset||0;s.bufferViews[x]=Je.toView(y,v,p.byteLength)}return s.buffers[p.buffer]});let d=i.accessors||[];s.accessors=d.map((p)=>{let x=s.bufferViewBuffers[p.bufferView],_=r.createAccessor(p.name,x).setType(p.type);if(p.extras)_.setExtras(p.extras);if(p.normalized!==void 0)_.setNormalized(p.normalized);if(p.bufferView===void 0)return _;return _.setArray(Yd(p,s)),_});let f=i.images||[],h=i.textures||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Texture")).forEach((p)=>p.preread(s,"Texture")),s.textures=f.map((p)=>{let x=r.createTexture(p.name);if(p.extras)x.setExtras(p.extras);if(p.bufferView!==void 0){let _=i.bufferViews[p.bufferView],y=e.json.buffers[_.buffer],v=y.uri?e.resources[y.uri]:e.resources[Cs],T=_.byteOffset||0,A=_.byteLength,E=v.slice(T,T+A);x.setImage(E)}else if(p.uri!==void 0){if(x.setImage(e.resources[p.uri]),p.uri.indexOf("__")!==0)x.setURI(p.uri)}if(p.mimeType!==void 0)x.setMimeType(p.mimeType);else if(p.uri){let _=Pa.extension(p.uri);x.setMimeType(Gi.extensionToMimeType(_))}return x}),r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Material")).forEach((p)=>p.preread(s,"Material")),s.materials=(i.materials||[]).map((p)=>{let x=r.createMaterial(p.name);if(p.extras)x.setExtras(p.extras);if(p.alphaMode!==void 0)x.setAlphaMode(p.alphaMode);if(p.alphaCutoff!==void 0)x.setAlphaCutoff(p.alphaCutoff);if(p.doubleSided!==void 0)x.setDoubleSided(p.doubleSided);let _=p.pbrMetallicRoughness||{};if(_.baseColorFactor!==void 0)x.setBaseColorFactor(_.baseColorFactor);if(p.emissiveFactor!==void 0)x.setEmissiveFactor(p.emissiveFactor);if(_.metallicFactor!==void 0)x.setMetallicFactor(_.metallicFactor);if(_.roughnessFactor!==void 0)x.setRoughnessFactor(_.roughnessFactor);if(_.baseColorTexture!==void 0){let y=_.baseColorTexture,v=s.textures[h[y.index].source];x.setBaseColorTexture(v),s.setTextureInfo(x.getBaseColorTextureInfo(),y)}if(p.emissiveTexture!==void 0){let y=p.emissiveTexture,v=s.textures[h[y.index].source];x.setEmissiveTexture(v),s.setTextureInfo(x.getEmissiveTextureInfo(),y)}if(p.normalTexture!==void 0){let y=p.normalTexture,v=s.textures[h[y.index].source];if(x.setNormalTexture(v),s.setTextureInfo(x.getNormalTextureInfo(),y),p.normalTexture.scale!==void 0)x.setNormalScale(p.normalTexture.scale)}if(p.occlusionTexture!==void 0){let y=p.occlusionTexture,v=s.textures[h[y.index].source];if(x.setOcclusionTexture(v),s.setTextureInfo(x.getOcclusionTextureInfo(),y),p.occlusionTexture.strength!==void 0)x.setOcclusionStrength(p.occlusionTexture.strength)}if(_.metallicRoughnessTexture!==void 0){let y=_.metallicRoughnessTexture,v=s.textures[h[y.index].source];x.setMetallicRoughnessTexture(v),s.setTextureInfo(x.getMetallicRoughnessTextureInfo(),y)}return x}),r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Mesh")).forEach((p)=>p.preread(s,"Mesh"));let b=i.meshes||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Primitive")).forEach((p)=>p.preread(s,"Primitive")),s.meshes=b.map((p)=>{let x=r.createMesh(p.name);if(p.extras)x.setExtras(p.extras);if(p.weights!==void 0)x.setWeights(p.weights);return(p.primitives||[]).forEach((_)=>{let y=r.createPrimitive();if(_.extras)y.setExtras(_.extras);if(_.material!==void 0)y.setMaterial(s.materials[_.material]);if(_.mode!==void 0)y.setMode(_.mode);for(let[T,A]of Object.entries(_.attributes||{}))y.setAttribute(T,s.accessors[A]);if(_.indices!==void 0)y.setIndices(s.accessors[_.indices]);let v=p.extras&&p.extras.targetNames||[];(_.targets||[]).forEach((T,A)=>{let E=v[A]||A.toString(),w=r.createPrimitiveTarget(E);for(let[P,S]of Object.entries(T))w.setAttribute(P,s.accessors[S]);y.addTarget(w)}),x.addPrimitive(y)}),x}),s.cameras=(i.cameras||[]).map((p)=>{let x=r.createCamera(p.name).setType(p.type);if(p.extras)x.setExtras(p.extras);if(p.type===ef.Type.PERSPECTIVE){let _=p.perspective;if(x.setYFov(_.yfov),x.setZNear(_.znear),_.zfar!==void 0)x.setZFar(_.zfar);if(_.aspectRatio!==void 0)x.setAspectRatio(_.aspectRatio)}else{let _=p.orthographic;x.setZNear(_.znear).setZFar(_.zfar).setXMag(_.xmag).setYMag(_.ymag)}return x});let m=i.nodes||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Node")).forEach((p)=>p.preread(s,"Node")),s.nodes=m.map((p)=>{let x=r.createNode(p.name);if(p.extras)x.setExtras(p.extras);if(p.translation!==void 0)x.setTranslation(p.translation);if(p.rotation!==void 0)x.setRotation(p.rotation);if(p.scale!==void 0)x.setScale(p.scale);if(p.matrix!==void 0){let _=[0,0,0],y=[0,0,0,1],v=[1,1,1];pt.decompose(p.matrix,_,y,v),x.setTranslation(_),x.setRotation(y),x.setScale(v)}if(p.weights!==void 0)x.setWeights(p.weights);return x}),s.skins=(i.skins||[]).map((p)=>{let x=r.createSkin(p.name);if(p.extras)x.setExtras(p.extras);if(p.inverseBindMatrices!==void 0)x.setInverseBindMatrices(s.accessors[p.inverseBindMatrices]);if(p.skeleton!==void 0)x.setSkeleton(s.nodes[p.skeleton]);for(let _ of p.joints)x.addJoint(s.nodes[_]);return x}),m.map((p,x)=>{let _=s.nodes[x];if((p.children||[]).forEach((y)=>_.addChild(s.nodes[y])),p.mesh!==void 0)_.setMesh(s.meshes[p.mesh]);if(p.camera!==void 0)_.setCamera(s.cameras[p.camera]);if(p.skin!==void 0)_.setSkin(s.skins[p.skin])}),s.animations=(i.animations||[]).map((p)=>{let x=r.createAnimation(p.name);if(p.extras)x.setExtras(p.extras);let _=(p.samplers||[]).map((y)=>{let v=r.createAnimationSampler().setInput(s.accessors[y.input]).setOutput(s.accessors[y.output]).setInterpolation(y.interpolation||Al.Interpolation.LINEAR);if(y.extras)v.setExtras(y.extras);return x.addSampler(v),v});return(p.channels||[]).forEach((y)=>{let v=r.createAnimationChannel().setSampler(_[y.sampler]).setTargetPath(y.target.path);if(y.target.node!==void 0)v.setTargetNode(s.nodes[y.target.node]);if(y.extras)v.setExtras(y.extras);x.addChannel(v)}),x});let g=i.scenes||[];if(r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Scene")).forEach((p)=>p.preread(s,"Scene")),s.scenes=g.map((p)=>{let x=r.createScene(p.name);if(p.extras)x.setExtras(p.extras);return(p.nodes||[]).map((_)=>s.nodes[_]).forEach((_)=>x.addChild(_)),x}),i.scene!==void 0)r.getRoot().setDefaultScene(s.scenes[i.scene]);return r.getRoot().listExtensionsUsed().forEach((p)=>p.read(s)),d.forEach((p,x)=>{let _=s.accessors[x],y=!!p.sparse,v=!p.bufferView&&!_.getArray();if(y||v)_.setSparse(!0).setArray(uF(p,s))}),r}static validate(e,t){let n=e.json;if(n.asset.version!=="2.0")throw Error(`Unsupported glTF version, "${n.asset.version}".`);if(n.extensionsRequired){for(let i of n.extensionsRequired)if(!t.extensions.find((r)=>r.EXTENSION_NAME===i))throw Error(`Missing required extension, "${i}".`)}if(n.extensionsUsed){for(let i of n.extensionsUsed)if(!t.extensions.find((r)=>r.EXTENSION_NAME===i))t.logger.warn(`Missing optional extension, "${i}".`)}}},qw,Is,Fw=class{multiple;basename;counter={};constructor(e,t){this.multiple=e,this.basename=t}createURI(e,t){if(e.getURI())return e.getURI();else if(!this.multiple)return`${this.basename(e)}.${t}`;else{let n=this.basename(e);return this.counter[n]=this.counter[n]||1,`${n}_${this.counter[n]++}.${t}`}}},Zd,fF,hF,pF,mF,gF=class{static write(e,t){let n=e.getGraph(),i=e.getRoot(),r={asset:{generator:`glTF-Transform ${Bw}`,...i.getAsset()},extras:{...i.getExtras()}},s={json:r,resources:{}},a=new Is(e,s,t),o=t.logger||ka.DEFAULT_INSTANCE,c=new Set(t.extensions.map((m)=>m.EXTENSION_NAME)),l=e.getRoot().listExtensionsUsed().filter((m)=>c.has(m.extensionName)).sort((m,g)=>m.extensionName>g.extensionName?1:-1),u=e.getRoot().listExtensionsRequired().filter((m)=>c.has(m.extensionName)).sort((m,g)=>m.extensionName>g.extensionName?1:-1);if(l.length<e.getRoot().listExtensionsUsed().length)o.warn("Some extensions were not registered for I/O, and will not be written.");for(let m of l){let g=m.prewriteTypes.filter((p)=>!mF.has(p));if(g.length)o.warn(`Prewrite hooks for some types (${g.join()}), requested by extension ${m.extensionName}, are unsupported. Please file an issue or a PR.`);for(let p of m.writeDependencies)m.install(p,t.dependencies[p])}function d(m,g,p,x){let _=[],y=0;for(let T of m){let A=a.createAccessorDef(T);A.bufferView=r.bufferViews.length;let E=T.getArray(),w=Je.pad(Je.toView(E));A.byteOffset=y,y+=w.byteLength,_.push(w),a.accessorIndexMap.set(T,r.accessors.length),r.accessors.push(A)}let v={buffer:g,byteOffset:p,byteLength:Je.concat(_).byteLength};if(x)v.target=x;return r.bufferViews.push(v),{buffers:_,byteLength:y}}function f(m,g,p){let x=m[0].getCount(),_=0;for(let E of m){let w=a.createAccessorDef(E);w.bufferView=r.bufferViews.length,w.byteOffset=_;let P=E.getElementSize(),S=E.getComponentSize();_+=Je.padNumber(P*S),a.accessorIndexMap.set(E,r.accessors.length),r.accessors.push(w)}let y=x*_,v=new ArrayBuffer(y),T=new DataView(v);for(let E=0;E<x;E++){let w=0;for(let P of m){let S=P.getElementSize(),I=P.getComponentSize(),U=P.getComponentType(),N=P.getArray();for(let F=0;F<S;F++){let D=E*_+w+F*I,O=N[E*S+F];switch(U){case Be.ComponentType.FLOAT:T.setFloat32(D,O,!0);break;case Be.ComponentType.BYTE:T.setInt8(D,O);break;case Be.ComponentType.SHORT:T.setInt16(D,O,!0);break;case Be.ComponentType.UNSIGNED_BYTE:T.setUint8(D,O);break;case Be.ComponentType.UNSIGNED_SHORT:T.setUint16(D,O,!0);break;case Be.ComponentType.UNSIGNED_INT:T.setUint32(D,O,!0);break;case Be.ComponentType.FLOAT16:T.setFloat16(D,O,!0);break;case Be.ComponentType.FLOAT64:T.setFloat64(D,O,!0);break;default:throw Error("Unexpected component type: "+U)}}w+=Je.padNumber(S*I)}}let A={buffer:g,byteOffset:p,byteLength:y,byteStride:_,target:Is.BufferViewTarget.ARRAY_BUFFER};return r.bufferViews.push(A),{byteLength:y,buffers:[new Uint8Array(v)]}}function h(m,g,p){let x=[],_=0,y=new Map,v=-1/0,T=!1;for(let U of m){let N=a.createAccessorDef(U);r.accessors.push(N),a.accessorIndexMap.set(U,r.accessors.length-1);let F=[],D=[],O=[],K=Array(U.getElementSize()).fill(0);for(let le=0,de=U.getCount();le<de;le++){if(U.getElement(le,O),pt.eq(O,K,0))continue;v=Math.max(le,v),F.push(le);for(let Me=0;Me<O.length;Me++)D.push(O[Me])}let B=F.length,X={accessorDef:N,count:B};if(y.set(U,X),B===0)continue;if(B>U.getCount()/2)T=!0;let q=Tl[U.getComponentType()];X.indices=F,X.values=new q(D)}if(!Number.isFinite(v))return{buffers:x,byteLength:_};if(T)o.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let A=v<255?Uint8Array:v<65535?Uint16Array:Uint32Array,E=v<255?pF:v<65535?hF:fF,w={buffer:g,byteOffset:p+_,byteLength:0};for(let U of m){let N=y.get(U);if(N.count===0)continue;N.indicesByteOffset=w.byteLength;let F=Je.pad(Je.toView(new A(N.indices)));x.push(F),_+=F.byteLength,w.byteLength+=F.byteLength}r.bufferViews.push(w);let P=r.bufferViews.length-1,S={buffer:g,byteOffset:p+_,byteLength:0};for(let U of m){let N=y.get(U);if(N.count===0)continue;N.valuesByteOffset=S.byteLength;let F=Je.pad(Je.toView(N.values));x.push(F),_+=F.byteLength,S.byteLength+=F.byteLength}r.bufferViews.push(S);let I=r.bufferViews.length-1;for(let U of m){let N=y.get(U);if(N.count===0)continue;N.accessorDef.sparse={count:N.count,indices:{bufferView:P,byteOffset:N.indicesByteOffset,componentType:E},values:{bufferView:I,byteOffset:N.valuesByteOffset}}}return{buffers:x,byteLength:_}}if(r.accessors=[],r.bufferViews=[],r.samplers=[],r.textures=[],r.images=i.listTextures().map((m,g)=>{let p=a.createPropertyDef(m);if(m.getMimeType())p.mimeType=m.getMimeType();let x=m.getImage();if(x)a.createImageData(p,x,m);return a.imageIndexMap.set(m,g),p}),l.filter((m)=>m.prewriteTypes.includes("Accessor")).forEach((m)=>m.prewrite(a,"Accessor")),i.listAccessors().forEach((m)=>{let{accessorUsageGroupedByParent:g,accessorParents:p}=a;if(a.accessorIndexMap.has(m))return;let x=a.getAccessorUsage(m);if(a.addAccessorToUsageGroup(m,x),g.has(x)){let _=n.listParents(m).find((y)=>y.propertyType!=="Root");p.set(m,_)}}),l.filter((m)=>m.prewriteTypes.includes("Buffer")).forEach((m)=>m.prewrite(a,"Buffer")),(i.listAccessors().length>0||a.otherBufferViews.size>0||i.listTextures().length>0&&t.format==="GLB")&&i.listBuffers().length===0)throw Error("Buffer required for Document resources, but none was found.");if(r.buffers=[],i.listBuffers().forEach((m,g)=>{let p=a.createPropertyDef(m),x=a.accessorUsageGroupedByParent,_=m.listParents().filter((P)=>P instanceof Be),y=new Set(_.map((P)=>a.accessorParents.get(P))),v=new Map(Array.from(y).map((P,S)=>[P,S])),T={};for(let P of _){if(a.accessorIndexMap.has(P))continue;let S=a.getAccessorUsage(P),I=S;if(x.has(S)){let U=a.accessorParents.get(P);I+=`:${v.get(U)}`}T[I]||={usage:S,accessors:[]},T[I].accessors.push(P)}let A=[],E=r.buffers.length,w=0;for(let{usage:P,accessors:S}of Object.values(T))if(P===Zd.ARRAY_BUFFER&&t.vertexLayout==="interleaved"){let I=f(S,E,w);w+=I.byteLength;for(let U of I.buffers)A.push(U)}else if(P===Zd.ARRAY_BUFFER)for(let I of S){let U=f([I],E,w);w+=U.byteLength;for(let N of U.buffers)A.push(N)}else if(P===Zd.SPARSE){let I=h(S,E,w);w+=I.byteLength;for(let U of I.buffers)A.push(U)}else if(P===Zd.ELEMENT_ARRAY_BUFFER){let I=Is.BufferViewTarget.ELEMENT_ARRAY_BUFFER,U=d(S,E,w,I);w+=U.byteLength;for(let N of U.buffers)A.push(N)}else{let I=d(S,E,w);w+=I.byteLength;for(let U of I.buffers)A.push(U)}if(a.imageBufferViews.length&&g===0){for(let P=0;P<a.imageBufferViews.length;P++)if(r.bufferViews[r.images[P].bufferView].byteOffset=w,w+=a.imageBufferViews[P].byteLength,A.push(a.imageBufferViews[P]),w%8){let S=8-w%8;w+=S,A.push(new Uint8Array(S))}}if(a.otherBufferViews.has(m))for(let P of a.otherBufferViews.get(m))r.bufferViews.push({buffer:E,byteOffset:w,byteLength:P.byteLength}),a.otherBufferViewsIndexMap.set(P,r.bufferViews.length-1),w+=P.byteLength,A.push(P);if(w){let P;if(t.format==="GLB")P=Cs;else P=a.bufferURIGenerator.createURI(m,"bin"),p.uri=P;p.byteLength=w,a.assignResourceURI(P,Je.concat(A),!0)}r.buffers.push(p),a.bufferIndexMap.set(m,g)}),i.listAccessors().find((m)=>!m.getBuffer()))o.warn("Skipped writing one or more Accessors: no Buffer assigned.");l.filter((m)=>m.prewriteTypes.includes("Material")).forEach((m)=>m.prewrite(a,"Material")),r.materials=i.listMaterials().map((m,g)=>{let p=a.createPropertyDef(m);if(m.getAlphaMode()!==Oa.AlphaMode.OPAQUE)p.alphaMode=m.getAlphaMode();if(m.getAlphaMode()===Oa.AlphaMode.MASK)p.alphaCutoff=m.getAlphaCutoff();if(m.getDoubleSided())p.doubleSided=!0;if(p.pbrMetallicRoughness={},!pt.eq(m.getBaseColorFactor(),[1,1,1,1]))p.pbrMetallicRoughness.baseColorFactor=m.getBaseColorFactor();if(!pt.eq(m.getEmissiveFactor(),[0,0,0]))p.emissiveFactor=m.getEmissiveFactor();if(m.getRoughnessFactor()!==1)p.pbrMetallicRoughness.roughnessFactor=m.getRoughnessFactor();if(m.getMetallicFactor()!==1)p.pbrMetallicRoughness.metallicFactor=m.getMetallicFactor();if(m.getBaseColorTexture()){let x=m.getBaseColorTexture(),_=m.getBaseColorTextureInfo();p.pbrMetallicRoughness.baseColorTexture=a.createTextureInfoDef(x,_)}if(m.getEmissiveTexture()){let x=m.getEmissiveTexture(),_=m.getEmissiveTextureInfo();p.emissiveTexture=a.createTextureInfoDef(x,_)}if(m.getNormalTexture()){let x=m.getNormalTexture(),_=m.getNormalTextureInfo(),y=a.createTextureInfoDef(x,_);if(m.getNormalScale()!==1)y.scale=m.getNormalScale();p.normalTexture=y}if(m.getOcclusionTexture()){let x=m.getOcclusionTexture(),_=m.getOcclusionTextureInfo(),y=a.createTextureInfoDef(x,_);if(m.getOcclusionStrength()!==1)y.strength=m.getOcclusionStrength();p.occlusionTexture=y}if(m.getMetallicRoughnessTexture()){let x=m.getMetallicRoughnessTexture(),_=m.getMetallicRoughnessTextureInfo();p.pbrMetallicRoughness.metallicRoughnessTexture=a.createTextureInfoDef(x,_)}return a.materialIndexMap.set(m,g),p}),l.filter((m)=>m.prewriteTypes.includes("Mesh")).forEach((m)=>m.prewrite(a,"Mesh")),r.meshes=i.listMeshes().map((m,g)=>{let p=a.createPropertyDef(m),x=null;if(p.primitives=m.listPrimitives().map((_)=>{let y={attributes:{}};y.mode=_.getMode();let v=_.getMaterial();if(v)y.material=a.materialIndexMap.get(v);if(Object.keys(_.getExtras()).length)y.extras=_.getExtras();let T=_.getIndices();if(T)y.indices=a.accessorIndexMap.get(T);for(let A of _.listSemantics())y.attributes[A]=a.accessorIndexMap.get(_.getAttribute(A));for(let A of _.listTargets()){let E={};for(let w of A.listSemantics())E[w]=a.accessorIndexMap.get(A.getAttribute(w));y.targets=y.targets||[],y.targets.push(E)}if(_.listTargets().length&&!x)x=_.listTargets().map((A)=>A.getName());return y}),m.getWeights().length)p.weights=m.getWeights();if(x)p.extras=p.extras||{},p.extras.targetNames=x;return a.meshIndexMap.set(m,g),p}),r.cameras=i.listCameras().map((m,g)=>{let p=a.createPropertyDef(m);if(p.type=m.getType(),p.type===ef.Type.PERSPECTIVE){p.perspective={znear:m.getZNear(),zfar:m.getZFar(),yfov:m.getYFov()};let x=m.getAspectRatio();if(x!==null)p.perspective.aspectRatio=x}else p.orthographic={znear:m.getZNear(),zfar:m.getZFar(),xmag:m.getXMag(),ymag:m.getYMag()};return a.cameraIndexMap.set(m,g),p}),r.nodes=i.listNodes().map((m,g)=>{let p=a.createPropertyDef(m);if(!pt.eq(m.getTranslation(),[0,0,0]))p.translation=m.getTranslation();if(!pt.eq(m.getRotation(),[0,0,0,1]))p.rotation=m.getRotation();if(!pt.eq(m.getScale(),[1,1,1]))p.scale=m.getScale();if(m.getWeights().length)p.weights=m.getWeights();return a.nodeIndexMap.set(m,g),p}),r.skins=i.listSkins().map((m,g)=>{let p=a.createPropertyDef(m),x=m.getInverseBindMatrices();if(x)p.inverseBindMatrices=a.accessorIndexMap.get(x);let _=m.getSkeleton();if(_)p.skeleton=a.nodeIndexMap.get(_);return p.joints=m.listJoints().map((y)=>a.nodeIndexMap.get(y)),a.skinIndexMap.set(m,g),p}),i.listNodes().forEach((m,g)=>{let p=r.nodes[g],x=m.getMesh();if(x)p.mesh=a.meshIndexMap.get(x);let _=m.getCamera();if(_)p.camera=a.cameraIndexMap.get(_);let y=m.getSkin();if(y)p.skin=a.skinIndexMap.get(y);if(m.listChildren().length>0)p.children=m.listChildren().map((v)=>a.nodeIndexMap.get(v))}),r.animations=i.listAnimations().map((m,g)=>{let p=a.createPropertyDef(m),x=new Map;return p.samplers=m.listSamplers().map((_,y)=>{let v=a.createPropertyDef(_);return v.input=a.accessorIndexMap.get(_.getInput()),v.output=a.accessorIndexMap.get(_.getOutput()),v.interpolation=_.getInterpolation(),x.set(_,y),v}),p.channels=m.listChannels().map((_)=>{let y=a.createPropertyDef(_);return y.sampler=x.get(_.getSampler()),y.target={node:a.nodeIndexMap.get(_.getTargetNode()),path:_.getTargetPath()},y}),a.animationIndexMap.set(m,g),p}),r.scenes=i.listScenes().map((m,g)=>{let p=a.createPropertyDef(m);return p.nodes=m.listChildren().map((x)=>a.nodeIndexMap.get(x)),a.sceneIndexMap.set(m,g),p});let b=i.getDefaultScene();if(b)r.scene=i.listScenes().indexOf(b);return r.extensionsUsed=l.map((m)=>m.extensionName),r.extensionsRequired=u.map((m)=>m.extensionName),l.forEach((m)=>m.write(a)),bF(r),s}},xF=class{_logger=ka.DEFAULT_INSTANCE;_extensions=new Set;_dependencies={};_vertexLayout="interleaved";_strictResources=!0;lastReadBytes=0;lastWriteBytes=0;setLogger(e){return this._logger=e,this}registerExtensions(e){for(let t of e)this._extensions.add(t),t.register();return this}registerDependencies(e){return Object.assign(this._dependencies,e),this}setVertexLayout(e){return this._vertexLayout=e,this}setStrictResources(e){return this._strictResources=e,this}async read(e){return await this.readJSON(await this.readAsJSON(e))}async readAsJSON(e){let t=await this.readURI(e,"view");this.lastReadBytes=t.byteLength;let n=Uw(t)?this._binaryToJSON(t):{json:JSON.parse(Je.decodeText(t)),resources:{}};return await this._readResourcesExternal(n,this.dirname(e)),this._readResourcesInternal(n),n}async readJSON(e){return e=this._copyJSON(e),this._readResourcesInternal(e),cF.read(e,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(e){let t=this._binaryToJSON(Je.assertView(e));this._readResourcesInternal(t);let n=t.json;if(n.buffers&&n.buffers.some((i)=>yF(t,i)))throw Error("Cannot resolve external buffers with binaryToJSON().");else if(n.images&&n.images.some((i)=>_F(t,i)))throw Error("Cannot resolve external images with binaryToJSON().");return t}async readBinary(e){return this.readJSON(await this.binaryToJSON(Je.assertView(e)))}async writeJSON(e,t={}){if(t.format==="GLB"&&e.getRoot().listBuffers().length>1)throw Error("GLB must have 0–1 buffers.");return gF.write(e,{format:t.format||"GLTF",basename:t.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:{...this._dependencies},extensions:Array.from(this._extensions)})}async writeBinary(e){let{json:t,resources:n}=await this.writeJSON(e,{format:"GLB"}),i=new Uint32Array([1179937895,2,12]),r=JSON.stringify(t),s=Je.pad(Je.encodeText(r),32),a=Je.toView(new Uint32Array([s.byteLength,1313821514])),o=Je.concat([a,s]);i[i.length-1]+=o.byteLength;let c=Object.values(n)[0];if(!c||!c.byteLength)return Je.concat([Je.toView(i),o]);let l=Je.pad(c,0),u=Je.toView(new Uint32Array([l.byteLength,5130562])),d=Je.concat([u,l]);return i[i.length-1]+=d.byteLength,Je.concat([Je.toView(i),o,d])}async _readResourcesExternal(e,t){let n=e.json.images||[],i=e.json.buffers||[],r=[...n,...i].map(async(s)=>{let a=s.uri;if(!a||a.match(/data:/))return Promise.resolve();try{e.resources[a]=await this.readURI(this.resolve(t,a),"view"),this.lastReadBytes+=e.resources[a].byteLength}catch(o){if(!this._strictResources&&n.includes(s))this._logger.warn(`Failed to load image URI, "${a}". ${o}`),e.resources[a]=null;else throw o}});await Promise.all(r)}_readResourcesInternal(e){function t(n){if(!n.uri)return;if(n.uri in e.resources){Je.assertView(e.resources[n.uri]);return}if(n.uri.match(/data:/)){let i=`__${$w()}.${Pa.extension(n.uri)}`;e.resources[i]=Je.createBufferFromDataURI(n.uri),n.uri=i}}(e.json.images||[]).forEach((n)=>{if(n.bufferView===void 0&&n.uri===void 0)throw Error("Missing resource URI or buffer view.");t(n)}),(e.json.buffers||[]).forEach(t)}_copyJSON(e){let{images:t,buffers:n}=e.json;if(e={json:{...e.json},resources:{...e.resources}},t)e.json.images=t.map((i)=>({...i}));if(n)e.json.buffers=n.map((i)=>({...i}));return e}_binaryToJSON(e){if(!Uw(e))throw Error("Invalid glTF 2.0 binary.");let t=new Uint32Array(e.buffer,e.byteOffset+12,2);if(t[1]!==1313821514)throw Error("Missing required GLB JSON chunk.");let n=20,i=t[0],r=Je.decodeText(Je.toView(e,n,i)),s=JSON.parse(r),a=n+i;if(e.byteLength<=a)return{json:s,resources:{}};let o=new Uint32Array(e.buffer,e.byteOffset+a,2);if(o[1]!==5130562)return{json:s,resources:{}};let c=o[0],l=Je.toView(e,a+8,c);return{json:s,resources:{[Cs]:l}}}},Jw;var wl=mt(()=>{Pw();te=function(e){return e.ACCESSOR="Accessor",e.ANIMATION="Animation",e.ANIMATION_CHANNEL="AnimationChannel",e.ANIMATION_SAMPLER="AnimationSampler",e.BUFFER="Buffer",e.CAMERA="Camera",e.MATERIAL="Material",e.MESH="Mesh",e.PRIMITIVE="Primitive",e.PRIMITIVE_TARGET="PrimitiveTarget",e.NODE="Node",e.ROOT="Root",e.SCENE="Scene",e.SKIN="Skin",e.TEXTURE="Texture",e.TEXTURE_INFO="TextureInfo",e}({}),F8=function(e){return e.ARRAY_BUFFER="ARRAY_BUFFER",e.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",e.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",e.OTHER="OTHER",e.SPARSE="SPARSE",e}({}),Ai=function(e){return e[e.R=4096]="R",e[e.G=256]="G",e[e.B=16]="B",e[e.A=1]="A",e}({}),zw=function(e){return e.GLTF="GLTF",e.GLB="GLB",e}({}),U8=class extends Float32Array{constructor(){super();throw Error("Unsupported typed array instantiation.")}},Tl={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5131":typeof Float16Array<"u"?Float16Array:U8,"5126":Float32Array,"5130":Float64Array},Gi=class{static impls={"image/jpeg":new B8,"image/png":new z8};static registerFormat(e,t){this.impls[e]=t}static getMimeType(e){for(let t in this.impls)if(this.impls[t].match(e))return t;return null}static getSize(e,t){if(!this.impls[t])return null;return this.impls[t].getSize(e)}static getChannels(e,t){if(!this.impls[t])return null;return this.impls[t].getChannels(e)}static getVRAMByteLength(e,t){if(!this.impls[t])return null;if(this.impls[t].getVRAMByteLength)return this.impls[t].getVRAMByteLength(e);let n=0,i=4,r=this.getSize(e,t);if(!r)return null;while(r[0]>1||r[1]>1)n+=r[0]*r[1]*i,r[0]=Math.max(Math.floor(r[0]/2),1),r[1]=Math.max(Math.floor(r[1]/2),1);return n+=4,n}static mimeTypeToExtension(e){if(e==="image/jpeg")return"jpg";return e.split("/").pop()}static extensionToMimeType(e){if(e==="jpg")return"image/jpeg";if(!e)return"";return`image/${e}`}};Ng=typeof Float32Array<"u"?Float32Array:Array;Math.PI/180;180/Math.PI;(function(){var e=j8();return function(t,n,i,r,s,a){var o,c;if(!n)n=3;if(!i)i=0;if(r)c=Math.min(r*n+i,t.length);else c=t.length;for(o=i;o<c;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],s(e,e,a),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2];return t}})();Cg=class{static DEFAULT_INIT={};static PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;static dirname(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.substring(0,t+1)}static basename(e){return Pa.basename(new URL(e,Ow).pathname)}static extension(e){return Pa.extension(new URL(e,Ow).pathname)}static resolve(e,t){if(!this.isRelativePath(t))return t;let n=e.split("/"),i=t.split("/");n.pop();for(let r=0;r<i.length;r++){if(i[r]===".")continue;if(i[r]==="..")n.pop();else n.push(i[r])}return n.join("/")}static isAbsoluteURL(e){return this.PROTOCOL_REGEXP.test(e)}static isRelativePath(e){return!/^(?:[a-zA-Z]+:)?\//.test(e)}};$8=function(e){return e[e.SILENT=4]="SILENT",e[e.ERROR=3]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=1]="INFO",e[e.DEBUG=0]="DEBUG",e}({}),ka=class e{verbosity;static Verbosity=$8;static DEFAULT_INSTANCE=new e(1);constructor(t){this.verbosity=t}debug(t){if(this.verbosity<=0)console.debug(t)}info(t){if(this.verbosity<=1)console.info(t)}warn(t){if(this.verbosity<=2)console.warn(t)}error(t){if(this.verbosity<=3)console.error(t)}};Dw=new Set,iF=new Set,kg=class extends Nw{constructor(e,t=""){super(e);this[At].name=t,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(e,t){if(Array.isArray(t))t=t.slice();return super.set(e,t)}getName(){return this.get("name")}setName(e){return this.set("name",e)}getExtras(){return this.get("extras")}setExtras(e){return this.set("extras",e)}clone(){return new this.constructor(this.graph).copy(this,Ns)}copy(e,t=Ns){for(let n in this[At]){let i=this[At][n];if(i instanceof Rs){if(!this[Ms].has(n))i.dispose()}else if(i instanceof bn||i instanceof It)for(let r of i.values())r.dispose();else if(i instanceof dn)for(let r of i.values())r.dispose()}for(let n in e[At]){let i=this[At][n],r=e[At][n];if(r instanceof Rs)if(this[Ms].has(n))i.getChild().copy(t(r.getChild()),t);else this.setRef(n,t(r.getChild()),r.getAttributes());else if(r instanceof It||r instanceof bn)for(let s of r.values())this.addRef(n,t(s.getChild()),s.getAttributes());else if(r instanceof dn)for(let s of r.keys()){let a=r.get(s);this.setRefMap(n,s,t(a.getChild()),a.getAttributes())}else if(Na(r))this[At][n]=JSON.parse(JSON.stringify(r));else if(Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r))this[At][n]=r.slice();else this[At][n]=r}return this}equals(e,t=iF){if(this===e)return!0;if(this.propertyType!==e.propertyType)return!1;for(let n in this[At]){if(t.has(n))continue;let i=this[At][n],r=e[At][n];if(i instanceof Rs||r instanceof Rs){if(!J8(i,r))return!1}else if(i instanceof It||r instanceof It||i instanceof bn||r instanceof bn){if(!Z8(i,r))return!1}else if(i instanceof dn||r instanceof dn){if(!Y8(i,r))return!1}else if(Na(i)||Na(r)){if(!Gw(i,r))return!1}else if(Qd(i)||Qd(r)){if(!Hw(i,r))return!1}else if(i!==r)return!1}return!0}detach(){return this.graph.disconnectParents(this,(e)=>e.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}},Gn=class extends kg{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new dn})}getExtension(e){return this.getRefMap("extensions",e)}setExtension(e,t){if(t)t._validateParent(this);return this.setRefMap("extensions",e,t)}listExtensions(){return this.listRefMapValues("extensions")}},Be=class e extends Gn{static Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};static ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126,FLOAT16:5131,FLOAT64:5130};init(){this.propertyType="Accessor"}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:e.Type.SCALAR,componentType:e.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(t){switch(t){case e.Type.SCALAR:return 1;case e.Type.VEC2:return 2;case e.Type.VEC3:return 3;case e.Type.VEC4:return 4;case e.Type.MAT2:return 4;case e.Type.MAT3:return 9;case e.Type.MAT4:return 16;default:throw Error("Unexpected type: "+t)}}static getComponentSize(t){switch(t){case e.ComponentType.BYTE:case e.ComponentType.UNSIGNED_BYTE:return 1;case e.ComponentType.SHORT:case e.ComponentType.UNSIGNED_SHORT:return 2;case e.ComponentType.UNSIGNED_INT:case e.ComponentType.FLOAT:return 4;case e.ComponentType.FLOAT16:return 2;case e.ComponentType.FLOAT64:return 8;default:throw Error("Unexpected component type: "+t)}}getMinNormalized(t){let n=this.getNormalized(),i=this.getElementSize(),r=this.getComponentType();if(this.getMin(t),n)for(let s=0;s<i;s++)t[s]=pt.decodeNormalizedInt(t[s],r);return t}getMin(t){let n=this.getArray(),i=this.getCount(),r=this.getElementSize();for(let s=0;s<r;s++)t[s]=1/0;for(let s=0;s<i*r;s+=r)for(let a=0;a<r;a++){let o=n[s+a];if(Number.isFinite(o))t[a]=Math.min(t[a],o)}return t}getMaxNormalized(t){let n=this.getNormalized(),i=this.getElementSize(),r=this.getComponentType();if(this.getMax(t),n)for(let s=0;s<i;s++)t[s]=pt.decodeNormalizedInt(t[s],r);return t}getMax(t){let n=this.get("array"),i=this.getCount(),r=this.getElementSize();for(let s=0;s<r;s++)t[s]=-1/0;for(let s=0;s<i*r;s+=r)for(let a=0;a<r;a++){let o=n[s+a];if(Number.isFinite(o))t[a]=Math.max(t[a],o)}return t}getCount(){let t=this.get("array");return t?t.length/this.getElementSize():0}getType(){return this.get("type")}setType(t){return this.set("type",t)}getElementSize(){return e.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(t){return this.set("normalized",t)}getScalar(t){let n=this.getElementSize(),i=this.getComponentType(),r=this.getArray();if(this.getNormalized())return pt.decodeNormalizedInt(r[t*n],i);return r[t*n]}setScalar(t,n){let i=this.getElementSize(),r=this.getComponentType(),s=this.getArray();if(this.getNormalized())s[t*i]=pt.encodeNormalizedInt(n,r);else s[t*i]=n;return this}getElement(t,n){let i=this.getNormalized(),r=this.getElementSize(),s=this.getComponentType(),a=this.getArray();for(let o=0;o<r;o++)if(i)n[o]=pt.decodeNormalizedInt(a[t*r+o],s);else n[o]=a[t*r+o];return n}setElement(t,n){let i=this.getNormalized(),r=this.getElementSize(),s=this.getComponentType(),a=this.getArray();for(let o=0;o<r;o++)if(i)a[t*r+o]=pt.encodeNormalizedInt(n[o],s);else a[t*r+o]=n[o];return this}getSparse(){return this.get("sparse")}setSparse(t){return this.set("sparse",t)}getBuffer(){return this.getRef("buffer")}setBuffer(t){return this.setRef("buffer",t)}getArray(){return this.get("array")}setArray(t){return this.set("componentType",t?rF(t):e.ComponentType.FLOAT),this.set("array",t),this}getByteLength(){let t=this.get("array");return t?t.byteLength:0}};Kw=class extends Gn{init(){this.propertyType="Animation"}getDefaults(){return Object.assign(super.getDefaults(),{channels:new It,samplers:new It})}addChannel(e){return this.addRef("channels",e)}removeChannel(e){return this.removeRef("channels",e)}listChannels(){return this.listRefs("channels")}addSampler(e){return this.addRef("samplers",e)}removeSampler(e){return this.removeRef("samplers",e)}listSamplers(){return this.listRefs("samplers")}},Da=class extends Gn{static TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};init(){this.propertyType="AnimationChannel"}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(e){return this.set("targetPath",e)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(e){return this.setRef("targetNode",e)}getSampler(){return this.getRef("sampler")}setSampler(e){return this.setRef("sampler",e)}},Al=class e extends Gn{static Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};init(){this.propertyType="AnimationSampler"}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:e.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(t){return this.set("interpolation",t)}getInput(){return this.getRef("input")}setInput(t){return this.setRef("input",t,{usage:"OTHER"})}getOutput(){return this.getRef("output")}setOutput(t){return this.setRef("output",t,{usage:"OTHER"})}},Ww=class extends Gn{init(){this.propertyType="Buffer"}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(e){return this.set("uri",e)}},ef=class e extends Gn{static Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};init(){this.propertyType="Camera"}getDefaults(){return Object.assign(super.getDefaults(),{type:e.Type.PERSPECTIVE,znear:0.1,zfar:100,aspectRatio:null,yfov:Math.PI*2*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(t){return this.set("type",t)}getZNear(){return this.get("znear")}setZNear(t){return this.set("znear",t)}getZFar(){return this.get("zfar")}setZFar(t){return this.set("zfar",t)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(t){return this.set("aspectRatio",t)}getYFov(){return this.get("yfov")}setYFov(t){return this.set("yfov",t)}getXMag(){return this.get("xmag")}setXMag(t){return this.set("xmag",t)}getYMag(){return this.get("ymag")}setYMag(t){return this.set("ymag",t)}},nt=class extends kg{static EXTENSION_NAME;_validateParent(e){if(!this.parentTypes.includes(e.propertyType))throw Error(`Parent "${e.propertyType}" invalid for child "${this.propertyType}".`)}},wt=class e extends Gn{static WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};static MagFilter={NEAREST:9728,LINEAR:9729};static MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};init(){this.propertyType="TextureInfo"}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:e.WrapMode.REPEAT,wrapT:e.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(t){return this.set("texCoord",t)}getMagFilter(){return this.get("magFilter")}setMagFilter(t){return this.set("magFilter",t)}getMinFilter(){return this.get("minFilter")}setMinFilter(t){return this.set("minFilter",t)}getWrapS(){return this.get("wrapS")}setWrapS(t){return this.set("wrapS",t)}getWrapT(){return this.get("wrapT")}setWrapT(t){return this.set("wrapT",t)}},{R:Xd,G:qd,B:Jd,A:sF}=Ai,Oa=class e extends Gn{static AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};init(){this.propertyType="Material"}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:e.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new wt(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new wt(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new wt(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new wt(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new wt(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(t){return this.set("doubleSided",t)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(t){let n=this.get("baseColorFactor").slice();return n[3]=t,this.set("baseColorFactor",n)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(t){return this.set("alphaMode",t)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(t){return this.set("alphaCutoff",t)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(t){return this.set("baseColorFactor",t)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(t){return this.setRef("baseColorTexture",t,{channels:Xd|qd|Jd|sF,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(t){return this.set("emissiveFactor",t)}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(t){return this.setRef("emissiveTexture",t,{channels:Xd|qd|Jd,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(t){return this.set("normalScale",t)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(t){return this.setRef("normalTexture",t,{channels:Xd|qd|Jd})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(t){return this.set("occlusionStrength",t)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(t){return this.setRef("occlusionTexture",t,{channels:Xd})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(t){return this.set("roughnessFactor",t)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(t){return this.set("metallicFactor",t)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(t){return this.setRef("metallicRoughnessTexture",t,{channels:qd|Jd})}},Dg=class extends Gn{init(){this.propertyType="Mesh"}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new It})}addPrimitive(e){return this.addRef("primitives",e)}removePrimitive(e){return this.removeRef("primitives",e)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}},tf=class extends Gn{init(){this.propertyType="Node"}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new It})}copy(e,t=Ns){if(t===Ns)throw Error("Node cannot be copied.");return super.copy(e,t)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(e){return this.set("translation",e)}setRotation(e){return this.set("rotation",e)}setScale(e){return this.set("scale",e)}getMatrix(){return pt.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(e){let t=this.get("translation").slice(),n=this.get("rotation").slice(),i=this.get("scale").slice();return pt.decompose(e,t,n,i),this.set("translation",t).set("rotation",n).set("scale",i)}getWorldTranslation(){let e=[0,0,0];return pt.decompose(this.getWorldMatrix(),e,[0,0,0,1],[1,1,1]),e}getWorldRotation(){let e=[0,0,0,1];return pt.decompose(this.getWorldMatrix(),[0,0,0],e,[1,1,1]),e}getWorldScale(){let e=[1,1,1];return pt.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],e),e}getWorldMatrix(){let e=[];for(let i=this;i!=null;i=i.getParentNode())e.push(i);let t,n=e.pop().getMatrix();while(t=e.pop())W8(n,n,t.getMatrix());return n}addChild(e){let t=e.getParentNode();if(t)t.removeChild(e);for(let n of e.listParents())if(n.propertyType==="Scene")n.removeChild(e);return this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}getParentNode(){for(let e of this.listParents())if(e.propertyType==="Node")return e;return null}getMesh(){return this.getRef("mesh")}setMesh(e){return this.setRef("mesh",e)}getCamera(){return this.getRef("camera")}setCamera(e){return this.setRef("camera",e)}getSkin(){return this.getRef("skin")}setSkin(e){return this.setRef("skin",e)}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}traverse(e){e(this);for(let t of this.listChildren())t.traverse(e);return this}},Jn=class e extends Gn{static Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};init(){this.propertyType="Primitive"}getDefaults(){return Object.assign(super.getDefaults(),{mode:e.Mode.TRIANGLES,material:null,indices:null,attributes:new dn,targets:new It})}getIndices(){return this.getRef("indices")}setIndices(t){return this.setRef("indices",t,{usage:"ELEMENT_ARRAY_BUFFER"})}getAttribute(t){return this.getRefMap("attributes",t)}setAttribute(t,n){return this.setRefMap("attributes",t,n,{usage:"ARRAY_BUFFER"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(t){return this.setRef("material",t)}getMode(){return this.get("mode")}setMode(t){return this.set("mode",t)}listTargets(){return this.listRefs("targets")}addTarget(t){return this.addRef("targets",t)}removeTarget(t){return this.removeRef("targets",t)}},Lg=class extends kg{init(){this.propertyType="PrimitiveTarget"}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new dn})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:"ARRAY_BUFFER"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}},nf=class extends Gn{init(){this.propertyType="Scene"}getDefaults(){return Object.assign(super.getDefaults(),{children:new It})}copy(e,t=Ns){if(t===Ns)throw Error("Scene cannot be copied.");return super.copy(e,t)}addChild(e){let t=e.getParentNode();if(t)t.removeChild(e);return this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}traverse(e){for(let t of this.listChildren())t.traverse(e);return this}},Xw=class extends Gn{init(){this.propertyType="Skin"}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new It})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(e){return this.setRef("skeleton",e)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(e){return this.setRef("inverseBindMatrices",e,{usage:"INVERSE_BIND_MATRICES"})}addJoint(e){return this.addRef("joints",e)}removeJoint(e){return this.removeRef("joints",e)}listJoints(){return this.listRefs("joints")}},Xo=class extends Gn{init(){this.propertyType="Texture"}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||Gi.extensionToMimeType(Pa.extension(this.get("uri")))}setMimeType(e){return this.set("mimeType",e)}getURI(){return this.get("uri")}setURI(e){this.set("uri",e);let t=Gi.extensionToMimeType(Pa.extension(e));if(t)this.set("mimeType",t);return this}getImage(){return this.get("image")}setImage(e){return this.set("image",Je.assertView(e))}getSize(){let e=this.get("image");if(!e)return null;return Gi.getSize(e,this.getMimeType())}},Ps=class extends Gn{_extensions=new Set;init(){this.propertyType="Root"}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Bw}`,version:"2.0"},defaultScene:null,accessors:new It,animations:new It,buffers:new It,cameras:new It,materials:new It,meshes:new It,nodes:new It,scenes:new It,skins:new It,textures:new It})}constructor(e){super(e);e.addEventListener("node:create",(t)=>{this._addChildOfRoot(t.target)})}clone(){throw Error("Root cannot be cloned.")}copy(e,t=Ns){if(t===Ns)throw Error("Root cannot be copied.");this.set("asset",{...e.get("asset")}),this.setName(e.getName()),this.setExtras({...e.getExtras()}),this.setDefaultScene(e.getDefaultScene()?t(e.getDefaultScene()):null);for(let n of e.listRefMapKeys("extensions")){let i=e.getExtension(n);this.setExtension(n,t(i))}return this}_addChildOfRoot(e){if(e instanceof nf)this.addRef("scenes",e);else if(e instanceof tf)this.addRef("nodes",e);else if(e instanceof ef)this.addRef("cameras",e);else if(e instanceof Xw)this.addRef("skins",e);else if(e instanceof Dg)this.addRef("meshes",e);else if(e instanceof Oa)this.addRef("materials",e);else if(e instanceof Xo)this.addRef("textures",e);else if(e instanceof Kw)this.addRef("animations",e);else if(e instanceof Be)this.addRef("accessors",e);else if(e instanceof Ww)this.addRef("buffers",e);return this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter((e)=>e.isRequired())}_enableExtension(e){return this._extensions.add(e),this}_disableExtension(e){return this._extensions.delete(e),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(e){return this.setRef("defaultScene",e)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}},rf=class e{_graph=new Rg;_root=new Ps(this._graph);_logger=ka.DEFAULT_INSTANCE;static _GRAPH_DOCUMENTS=new WeakMap;static fromGraph(t){return e._GRAPH_DOCUMENTS.get(t)||null}constructor(){e._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(t){return this._logger=t,this}clone(){throw Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(t){throw Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...t){let n=t.map((i)=>i.name);for(let i of t)await i(this,{stack:n});return this}hasExtension(t){return this.getRoot().listExtensionsUsed().some((n)=>n.extensionName===t)}createExtension(t){let n=t.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find((i)=>i.extensionName===n)||new t(this)}disposeExtension(t){let n=this.getRoot().listExtensionsUsed().find((i)=>i.extensionName===t);if(n)n.dispose()}createScene(t=""){return new nf(this._graph,t)}createNode(t=""){return new tf(this._graph,t)}createCamera(t=""){return new ef(this._graph,t)}createSkin(t=""){return new Xw(this._graph,t)}createMesh(t=""){return new Dg(this._graph,t)}createPrimitive(){return new Jn(this._graph)}createPrimitiveTarget(t=""){return new Lg(this._graph,t)}createMaterial(t=""){return new Oa(this._graph,t)}createTexture(t=""){return new Xo(this._graph,t)}createAnimation(t=""){return new Kw(this._graph,t)}createAnimationChannel(t=""){return new Da(this._graph,t)}createAnimationSampler(t=""){return new Al(this._graph,t)}createAccessor(t="",n=null){if(!n)n=this.getRoot().listBuffers()[0];return new Be(this._graph,t).setBuffer(n)}createBuffer(t=""){return new Ww(this._graph,t)}},Lw={logger:ka.DEFAULT_INSTANCE,extensions:[],dependencies:{}},oF=new Set(["Buffer","Texture","Material","Mesh","Primitive","Node","Scene"]);qw=function(e){return e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e}(qw||{}),Is=class{_doc;jsonDoc;options;static BufferViewTarget=qw;static BufferViewUsage=F8;static USAGE_TO_TARGET={["ARRAY_BUFFER"]:34962,["ELEMENT_ARRAY_BUFFER"]:34963};accessorIndexMap=new Map;animationIndexMap=new Map;bufferIndexMap=new Map;cameraIndexMap=new Map;skinIndexMap=new Map;materialIndexMap=new Map;meshIndexMap=new Map;nodeIndexMap=new Map;imageIndexMap=new Map;textureDefIndexMap=new Map;textureInfoDefMap=new Map;samplerDefIndexMap=new Map;sceneIndexMap=new Map;imageBufferViews=[];otherBufferViews=new Map;otherBufferViewsIndexMap=new Map;extensionData={};bufferURIGenerator;imageURIGenerator;logger;_accessorUsageMap=new Map;accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]);accessorParents=new Map;constructor(e,t,n){this._doc=e,this.jsonDoc=t,this.options=n;let i=e.getRoot(),r=i.listBuffers().length,s=i.listTextures().length;this.bufferURIGenerator=new Fw(r>1,()=>n.basename||"buffer"),this.imageURIGenerator=new Fw(s>1,(a)=>dF(e,a)||n.basename||"texture"),this.logger=e.getLogger()}createTextureInfoDef(e,t){let n={magFilter:t.getMagFilter()||void 0,minFilter:t.getMinFilter()||void 0,wrapS:t.getWrapS(),wrapT:t.getWrapT()},i=JSON.stringify(n);if(!this.samplerDefIndexMap.has(i))this.samplerDefIndexMap.set(i,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(n);let r={source:this.imageIndexMap.get(e),sampler:this.samplerDefIndexMap.get(i)},s=JSON.stringify(r);if(!this.textureDefIndexMap.has(s))this.textureDefIndexMap.set(s,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(r);let a={index:this.textureDefIndexMap.get(s)};if(t.getTexCoord()!==0)a.texCoord=t.getTexCoord();if(Object.keys(t.getExtras()).length>0)a.extras=t.getExtras();return this.textureInfoDefMap.set(t,a),a}createPropertyDef(e){let t={};if(e.getName())t.name=e.getName();if(Object.keys(e.getExtras()).length>0)t.extras=e.getExtras();return t}createAccessorDef(e){let t=this.createPropertyDef(e);if(t.type=e.getType(),t.componentType=e.getComponentType(),t.count=e.getCount(),this._doc.getGraph().listParentEdges(e).some((n)=>n.getName()==="attributes"&&n.getAttributes().key==="POSITION"||n.getName()==="input"))t.max=e.getMax([]).map(Math.fround),t.min=e.getMin([]).map(Math.fround);if(e.getNormalized())t.normalized=e.getNormalized();return t}createImageData(e,t,n){if(this.options.format==="GLB")this.imageBufferViews.push(t),e.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:t.byteLength});else{let i=Gi.mimeTypeToExtension(n.getMimeType());e.uri=this.imageURIGenerator.createURI(n,i),this.assignResourceURI(e.uri,t,!1)}}assignResourceURI(e,t,n){let i=this.jsonDoc.resources;if(!(e in i)){i[e]=t;return}if(t===i[e]){this.logger.warn(`Duplicate resource URI, "${e}".`);return}let r=`Resource URI "${e}" already assigned to different data.`;if(!n){this.logger.warn(r);return}throw Error(r)}getAccessorUsage(e){let t=this._accessorUsageMap.get(e);if(t)return t;if(e.getSparse())return"SPARSE";for(let n of this._doc.getGraph().listParentEdges(e)){let{usage:i}=n.getAttributes();if(i)return i;if(n.getParent().propertyType!=="Root")this.logger.warn(`Missing attribute ".usage" on edge, "${n.getName()}".`)}return"OTHER"}addAccessorToUsageGroup(e,t){let n=this._accessorUsageMap.get(e);if(n&&n!==t)throw Error(`Accessor with usage "${n}" cannot be reused as "${t}".`);return this._accessorUsageMap.set(e,t),this}};({BufferViewUsage:Zd}=Is),{UNSIGNED_INT:fF,UNSIGNED_SHORT:hF,UNSIGNED_BYTE:pF}=Be.ComponentType,mF=new Set(["Accessor","Buffer","Material","Mesh"]);Jw=class extends xF{_fetchConfig;constructor(e=Cg.DEFAULT_INIT){super();this._fetchConfig=e}async readURI(e,t){let n=await fetch(e,this._fetchConfig);switch(t){case"view":return new Uint8Array(await n.arrayBuffer());case"text":return n.text()}}resolve(e,t){return Cg.resolve(e,t)}dirname(e){return Cg.dirname(e)}}});function vF(){return{vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null}}class qo{constructor(e,t,n,i){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,n),this._littleEndian=i,this._offset=0}_nextUint8(){let e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){let e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){let e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){let e=this._dataView.getUint32(this._offset,this._littleEndian),t=this._dataView.getUint32(this._offset+4,this._littleEndian),n=e+4294967296*t;return this._offset+=8,n}_nextInt32(){let e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){let t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t=0){let n=this._offset,i=0;while(this._dataView.getUint8(this._offset)!==t&&i<e)i++,this._offset++;if(i<e)this._offset++;return new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,i)}}function Zw(e){return new TextDecoder().decode(e)}function sf(e){let t=new Uint8Array(e.buffer,e.byteOffset,$n.length);if(t[0]!==$n[0]||t[1]!==$n[1]||t[2]!==$n[2]||t[3]!==$n[3]||t[4]!==$n[4]||t[5]!==$n[5]||t[6]!==$n[6]||t[7]!==$n[7]||t[8]!==$n[8]||t[9]!==$n[9]||t[10]!==$n[10]||t[11]!==$n[11])throw Error("Missing KTX 2.0 identifier.");let n=vF(),i=17*Uint32Array.BYTES_PER_ELEMENT,r=new qo(e,$n.length,i,!0);n.vkFormat=r._nextUint32(),n.typeSize=r._nextUint32(),n.pixelWidth=r._nextUint32(),n.pixelHeight=r._nextUint32(),n.pixelDepth=r._nextUint32(),n.layerCount=r._nextUint32(),n.faceCount=r._nextUint32(),n.levelCount=r._nextUint32(),n.supercompressionScheme=r._nextUint32();let s=r._nextUint32(),a=r._nextUint32(),o=r._nextUint32(),c=r._nextUint32(),l=r._nextUint64(),u=r._nextUint64(),d=Math.max(n.levelCount,1)*3*8,f=new qo(e,$n.length+i,d,!0);for(let ie=0,ce=Math.max(n.levelCount,1);ie<ce;ie++)n.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+f._nextUint64(),f._nextUint64()),uncompressedByteLength:f._nextUint64()});let h=new qo(e,s,a,!0);h._skip(4);let b=h._nextUint16(),m=h._nextUint16(),g=h._nextUint16(),p=h._nextUint16(),x=h._nextUint8(),_=h._nextUint8(),y=h._nextUint8(),v=h._nextUint8(),T=[h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8()],A=[h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8()],w={vendorId:b,descriptorType:m,versionNumber:g,colorModel:x,colorPrimaries:_,transferFunction:y,flags:v,texelBlockDimension:T,bytesPlane:A,samples:[]},P=6,S=4,I=(p/4-P)/S;for(let ie=0;ie<I;ie++){let ce={bitOffset:h._nextUint16(),bitLength:h._nextUint8(),channelType:h._nextUint8(),samplePosition:[h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(ce.channelType&64)ce.sampleLower=h._nextInt32(),ce.sampleUpper=h._nextInt32();else ce.sampleLower=h._nextUint32(),ce.sampleUpper=h._nextUint32();w.samples[ie]=ce}n.dataFormatDescriptor.length=0,n.dataFormatDescriptor.push(w);let U=new qo(e,o,c,!0);while(U._offset<c){let ie=U._nextUint32(),ce=U._scan(ie),_e=Zw(ce);if(n.keyValue[_e]=U._nextUint8Array(ie-ce.byteLength-1),_e.match(/^ktx/i)){let Oe=Zw(n.keyValue[_e]);n.keyValue[_e]=Oe.substring(0,Oe.lastIndexOf("\x00"))}let Re=ie%4?4-ie%4:0;U._skip(Re)}if(u<=0)return n;let N=new qo(e,l,u,!0),F=N._nextUint16(),D=N._nextUint16(),O=N._nextUint32(),K=N._nextUint32(),B=N._nextUint32(),X=N._nextUint32(),q=[];for(let ie=0,ce=Math.max(n.levelCount,1);ie<ce;ie++)q.push({imageFlags:N._nextUint32(),rgbSliceByteOffset:N._nextUint32(),rgbSliceByteLength:N._nextUint32(),alphaSliceByteOffset:N._nextUint32(),alphaSliceByteLength:N._nextUint32()});let le=l+N._offset,de=le+O,Me=de+K,pe=Me+B,J=new Uint8Array(e.buffer,e.byteOffset+le,O),L=new Uint8Array(e.buffer,e.byteOffset+de,K),W=new Uint8Array(e.buffer,e.byteOffset+Me,B),ne=new Uint8Array(e.buffer,e.byteOffset+pe,X);return n.globalData={endpointCount:F,selectorCount:D,imageDescs:q,endpointsData:J,selectorsData:L,tablesData:W,extendedData:ne},n}var Yw=0,Qw=163,eS=166,Fg=0,tS=123,nS=1000066000,x$,$n;var iS=mt(()=>{x$=new Uint8Array([0]),$n=[171,75,84,88,32,50,48,187,13,10,26,10]});function RF(e,t,n,i){let r=t.createFeatureID().setFeatureCount(i.featureCount);if(i.nullFeatureId!==void 0)r.setNullFeatureID(i.nullFeatureId);if(i.label!==void 0)r.setLabel(i.label);if(i.attribute!==void 0)r.setAttribute(i.attribute);let s=i.texture;if(s!==void 0){let a=IF(t,n,s);r.setTexture(a)}if(i.propertyTable!==void 0){let a=e.getRoot().getExtension(et).listPropertyTables();r.setPropertyTable(a[i.propertyTable])}return r}function IF(e,t,n){let i=e.createFeatureIDTexture(),{json:r}=t.jsonDoc;if(n.channels)i.setChannels(n.channels);if(n.index!==void 0){let s=r.textures[n.index].source;i.setTexture(t.textures[s]),t.setTextureInfo(i.getTextureInfo(),n)}return i}function CF(e,t,n){let i=e.getRoot(),r={featureCount:n.getFeatureCount()};if(n.getNullFeatureID()!=null)r.nullFeatureId=n.getNullFeatureID();if(n.getLabel())r.label=n.getLabel();if(n.getAttribute()!=null)r.attribute=n.getAttribute();if(n.getTexture()){let s=n.getTexture(),a=s.getTexture(),o=s.getTextureInfo();r.texture=t.createTextureInfoDef(a,o);let c=s.getChannels();if(!pt.eq(c,[0]))r.texture.channels=c}if(n.getPropertyTable()){let s=i.getExtension(et),a=n.getPropertyTable();r.propertyTable=s.listPropertyTables().indexOf(a)}return r}function OF(e){if(!e.extensions||!e.extensions.EXT_meshopt_compression)return!1;return!!e.extensions[Zn].fallback}function LF(e,t,n,i){let{filter:r,bits:s}=i,a={array:e.getArray(),byteStride:e.getElementSize()*e.getComponentSize(),componentType:e.getComponentType(),normalized:e.getNormalized()};if(n!=="ATTRIBUTES")return a;if(r!=="NONE"){let o=e.getNormalized()?FF(e):new Float32Array(a.array);switch(r){case"EXPONENTIAL":a.byteStride=e.getElementSize()*4,a.componentType=DF,a.normalized=!1,a.array=t.encodeFilterExp(o,e.getCount(),a.byteStride,s);break;case"OCTAHEDRAL":a.byteStride=s>8?8:4,a.componentType=s>8?aS:kF,a.normalized=!0,o=e.getElementSize()===3?BF(o):o,a.array=t.encodeFilterOct(o,e.getCount(),a.byteStride,s);break;case"QUATERNION":a.byteStride=8,a.componentType=aS,a.normalized=!0,a.array=t.encodeFilterQuat(o,e.getCount(),a.byteStride,s);break;default:throw Error("Invalid filter.")}if(a.min=e.getMin([]),a.max=e.getMax([]),e.getNormalized())a.min=a.min.map((c)=>Vg(c,e.getComponentType())),a.max=a.max.map((c)=>Vg(c,e.getComponentType()));if(a.normalized)a.min=a.min.map((c)=>oS(c,a.componentType)),a.max=a.max.map((c)=>oS(c,a.componentType))}else if(a.byteStride%4)a.array=UF(a.array,e.getElementSize()),a.byteStride=a.array.byteLength/e.getCount();return a}function FF(e){let t=e.getComponentType(),n=e.getArray(),i=new Float32Array(n.length);for(let r=0;r<n.length;r++)i[r]=Vg(n[r],t);return i}function UF(e,t){let n=Je.padNumber(e.BYTES_PER_ELEMENT*t)/e.BYTES_PER_ELEMENT,i=e.length/t,r=new e.constructor(i*n);for(let s=0;s*t<e.length;s++)for(let a=0;a<t;a++)r[s*n+a]=e[s*t+a];return r}function BF(e){let t=new Float32Array(e.length*4/3);for(let n=0,i=e.length/3;n<i;n++)t[n*4]=e[n*3],t[n*4+1]=e[n*3+1],t[n*4+2]=e[n*3+2];return t}function zF(e,t){if(t===Is.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return e.listParents().some((n)=>n instanceof Jn&&n.getMode()===Jn.Mode.TRIANGLES)?"TRIANGLES":"INDICES";return"ATTRIBUTES"}function VF(e,t){let n=t.getGraph().listParentEdges(e).filter((i)=>!(i.getParent()instanceof Ps));for(let i of n){let r=i.getName(),s=i.getAttributes().key||"",a=i.getParent().propertyType===te.PRIMITIVE_TARGET;if(r==="indices")return{filter:"NONE"};if(r==="attributes"){if(s==="POSITION")return{filter:"NONE"};if(s==="TEXCOORD_0")return{filter:"NONE"};if(s.startsWith("JOINTS_"))return{filter:"NONE"};if(s.startsWith("WEIGHTS_"))return{filter:"NONE"};if(s==="NORMAL"||s==="TANGENT")return a?{filter:"NONE"}:{filter:"OCTAHEDRAL",bits:8}}if(r==="output"){let o=TS(e);if(o==="rotation")return{filter:"QUATERNION",bits:16};if(o==="translation")return{filter:"EXPONENTIAL",bits:12};if(o==="scale")return{filter:"EXPONENTIAL",bits:12};return{filter:"NONE"}}if(r==="input")return{filter:"NONE"};if(r==="inverseBindMatrices")return{filter:"NONE"}}return{filter:"NONE"}}function TS(e){for(let t of e.listParents()){if(!(t instanceof Al))continue;for(let n of t.listParents()){if(!(n instanceof Da))continue;return n.getTargetPath()}}return null}function i2(e,t,n){let i=e.createStructuralMetadata();if(n.schema!==void 0){let o=r2(e,n.schema);i.setSchema(o)}else if(n.schemaUri){let o=n.schemaUri;i.setSchemaUri(o)}let r=n.propertyTextures||[];for(let o of r){let c=l2(e,t,o);i.addPropertyTexture(c)}let s=n.propertyTables||[];for(let o of s){let c=d2(e,t,o);i.addPropertyTable(c)}let a=n.propertyAttributes||[];for(let o of a){let c=h2(e,o);i.addPropertyAttribute(c)}return i}function r2(e,t){let n=e.createSchema().setId(t.id);if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.version!==void 0)n.setVersion(t.version);let i=t.classes||{};for(let s of Object.keys(i)){let a=i[s];n.setClass(s,s2(e,a))}let r=t.enums||{};for(let s of Object.keys(r))n.setEnum(s,o2(e,r[s]));return n}function s2(e,t){let n=e.createClass();if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);let i=t.properties||{};for(let r of Object.keys(i)){let s=a2(e,i[r]);n.setProperty(r,s)}return n}function a2(e,t){let n=e.createClassProperty().setType(t.type);if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.componentType!==void 0)n.setComponentType(t.componentType);if(t.enumType!==void 0)n.setEnumType(t.enumType);if(t.array!==void 0)n.setArray(t.array);if(t.count!==void 0)n.setCount(t.count);if(t.normalized!==void 0)n.setNormalized(t.normalized);if(t.offset!==void 0)n.setOffset(t.offset);if(t.scale!==void 0)n.setScale(t.scale);if(t.max!==void 0)n.setMax(t.max);if(t.min!==void 0)n.setMin(t.min);if(t.required!==void 0)n.setRequired(t.required);if(t.noData!==void 0)n.setNoData(t.noData);if(t.default!==void 0)n.setDefault(t.default);return n}function o2(e,t){let n=e.createEnum();if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.valueType!==void 0)n.setValueType(t.valueType);let i=t.values||{};for(let r of i)n.addEnumValue(c2(e,r));return n}function c2(e,t){let n=e.createEnumValue();if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.value!==void 0)n.setValue(t.value);return n}function l2(e,t,n){let i=e.createPropertyTexture();if(i.setClass(n.class),n.name!==void 0)i.setName(n.name);let r=n.properties||{};for(let s of Object.keys(r)){let a=u2(e,t,r[s]);i.setProperty(s,a)}return i}function u2(e,t,n){let i=e.createPropertyTextureProperty(),r=t.jsonDoc.json.textures||[];if(n.channels)i.setChannels(n.channels);let s=r[n.index].source;if(s!==void 0){let a=t.textures[s];i.setTexture(a);let o=i.getTextureInfo();if(o)t.setTextureInfo(o,n)}if(n.offset!==void 0)i.setOffset(n.offset);if(n.scale!==void 0)i.setScale(n.scale);if(n.max!==void 0)i.setMax(n.max);if(n.min!==void 0)i.setMin(n.min);return i}function d2(e,t,n){let i=e.createPropertyTable().setClass(n.class).setCount(n.count);if(n.name!==void 0)i.setName(n.name);let r=n.properties||{};for(let s of Object.keys(r)){let a=f2(e,t,r[s]);i.setProperty(s,a)}return i}function f2(e,t,n){let i=e.createPropertyTableProperty(),r=Ug(t,n.values);if(i.setValues(r),n.arrayOffsets!==void 0){let s=Ug(t,n.arrayOffsets);i.setArrayOffsets(s)}if(n.stringOffsets!==void 0){let s=Ug(t,n.stringOffsets);i.setStringOffsets(s)}if(n.arrayOffsetType!==void 0)i.setArrayOffsetType(n.arrayOffsetType);if(n.stringOffsetType!==void 0)i.setStringOffsetType(n.stringOffsetType);if(n.offset!==void 0)i.setOffset(n.offset);if(n.scale!==void 0)i.setScale(n.scale);if(n.max!==void 0)i.setMax(n.max);if(n.min!==void 0)i.setMin(n.min);return i}function h2(e,t){let n=e.createPropertyAttribute();if(n.setClass(t.class),t.name!==void 0)n.setName(t.name);let i=t.properties||{};for(let r of Object.keys(i)){let s=p2(e,i[r]);n.setProperty(r,s)}return n}function p2(e,t){let n=e.createPropertyAttributeProperty();if(n.setAttribute(t.attribute),t.offset!==void 0)n.setOffset(t.offset);if(t.scale!==void 0)n.setScale(t.scale);if(t.max!==void 0)n.setMax(t.max);if(t.min!==void 0)n.setMin(t.min);return n}function m2(e,t){let n={},i=t.getSchema();if(i)n.schema=g2(i);let r=t.getSchemaUri();if(r)n.schemaUri=r;let s=t.listPropertyTables();if(s.length>0){let c=[];for(let l of s){let u=v2(e,l);c.push(u)}n.propertyTables=c}let a=t.listPropertyTextures();if(a.length>0){let c=[];for(let l of a){let u=w2(e,l);c.push(u)}n.propertyTextures=c}let o=t.listPropertyAttributes();if(o.length>0){let c=[];for(let l of o){let u=T2(l);c.push(u)}n.propertyAttributes=c}return n}function g2(e){let t={id:e.getId()},n=e.listClassKeys();if(n.length>0){t.classes={};for(let r of n){let s=b2(e.getClass(r));t.classes[r]=s}}let i=e.listEnumKeys();if(i.length>0){t.enums={};for(let r of i){let s=y2(e.getEnum(r));t.enums[r]=s}}if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();if(e.getVersion())t.version=e.getVersion();return t}function b2(e){let t={},n=e.listPropertyKeys();if(n.length>0){t.properties={};for(let i of n){let r=e.getProperty(i);t.properties[i]=x2(r)}}if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();return t}function x2(e){let t={type:e.getType()};if(e.getArray())t.array=e.getArray();if(e.getNormalized())t.normalized=e.getNormalized();if(e.getRequired())t.required=e.getRequired();if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();if(e.getComponentType()!=null)t.componentType=e.getComponentType();if(e.getEnumType()!=null)t.enumType=e.getEnumType();if(e.getCount()!=null)t.count=e.getCount();if(e.getOffset()!=null)t.offset=e.getOffset();if(e.getScale()!=null)t.scale=e.getScale();if(e.getMax()!=null)t.max=e.getMax();if(e.getMin()!=null)t.min=e.getMin();if(e.getNoData()!=null)t.noData=e.getNoData();if(e.getDefault()!=null)t.default=e.getDefault();return t}function y2(e){let t={values:e.listValues().map(_2)};if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();if(e.getValueType()!=="UINT16")t.valueType=e.getValueType();return t}function _2(e){let t={name:e.getName(),value:e.getValue()};if(e.getDescription())t.description=e.getDescription();return t}function v2(e,t){let n={class:t.getClass(),count:t.getCount()};if(t.getName())n.name=t.getName();let i=t.listPropertyKeys();if(i.length>0){n.properties={};for(let r of i){let s=E2(e,t.getProperty(r));n.properties[r]=s}}return n}function E2(e,t){let n=t.getValues(),i={values:e.otherBufferViewsIndexMap.get(n)};if(t.getArrayOffsets()){let r=t.getArrayOffsets();i.arrayOffsets=e.otherBufferViewsIndexMap.get(r)}if(t.getStringOffsets()){let r=t.getStringOffsets();i.stringOffsets=e.otherBufferViewsIndexMap.get(r)}if(t.getArrayOffsetType()!=null)i.arrayOffsetType=t.getArrayOffsetType();if(t.getStringOffsetType()!=null)i.stringOffsetType=t.getStringOffsetType();if(t.getOffset()!=null)i.offset=t.getOffset();if(t.getScale()!=null)i.scale=t.getScale();if(t.getMax()!=null)i.max=t.getMax();if(t.getMin()!=null)i.min=t.getMin();return i}function T2(e){let t={class:e.getClass()};if(e.getName())t.name=e.getName();let n=e.listPropertyKeys();if(n.length>0){t.properties={};for(let i of n){let r=A2(e.getProperty(i));t.properties[i]=r}}return t}function A2(e){let t={attribute:e.getAttribute()};if(e.getOffset()!=null)t.offset=e.getOffset();if(e.getScale()!=null)t.scale=e.getScale();if(e.getMax()!=null)t.max=e.getMax();if(e.getMin()!=null)t.min=e.getMin();return t}function w2(e,t){let n={class:t.getClass()};if(t.getName())n.name=t.getName();let i=t.listPropertyKeys();if(i.length>0){n.properties={};for(let r of i){let s=S2(e,t.getProperty(r));n.properties[r]=s}}return n}function S2(e,t){let n=t.getTexture(),i=t.getTextureInfo(),r=t.getChannels(),s=e.createTextureInfoDef(n,i);if(!pt.eq(r,[0]))s.channels=r;if(t.getOffset()!=null)s.offset=t.getOffset();if(t.getScale()!=null)s.scale=t.getScale();if(t.getMax()!=null)s.max=t.getMax();if(t.getMin()!=null)s.min=t.getMin();return s}function Ug(e,t){let n=e.jsonDoc,i=n.json.buffers||[],r=(n.json.bufferViews||[])[t],s=i[r.buffer],a=s.uri?n.resources[s.uri]:n.resources[Cs],o=r.byteOffset||0,c=r.byteLength;return a.slice(o,o+c)}function M2(e,t){let n=e.getRoot().listBuffers()[0],i=t.otherBufferViews.get(n);if(!i)i=[],t.otherBufferViews.set(n,i);return i}function lS(e,t){if(e.byteLength<4+t)return null;let n=e.getUint32(t);if(e.byteLength<n+t||n<8)return null;return{type:Je.decodeText(new Uint8Array(e.buffer,e.byteOffset+t+4,4)),start:t+8,end:t+n}}function P2(e,t){let n=new xn.DecoderBuffer;try{if(n.Init(t,t.length),e.GetEncodedGeometryType(n)!==xn.TRIANGULAR_MESH)throw Error(`[${tn}] Unknown geometry type.`);let i=new xn.Mesh;if(!e.DecodeBufferToMesh(n,i).ok()||i.ptr===0)throw Error(`[${tn}] Decoding failure.`);return i}finally{xn.destroy(n)}}function O2(e,t){let n=t.num_faces()*3,i,r;if(t.num_points()<=65534){let s=n*Uint16Array.BYTES_PER_ELEMENT;i=xn._malloc(s),e.GetTrianglesUInt16Array(t,s,i),r=new Uint16Array(xn.HEAPU16.buffer,i,n).slice()}else{let s=n*Uint32Array.BYTES_PER_ELEMENT;i=xn._malloc(s),e.GetTrianglesUInt32Array(t,s,i),r=new Uint32Array(xn.HEAPU32.buffer,i,n).slice()}return xn._free(i),r}function k2(e,t,n,i){let r=MS[i.componentType],s=SS[i.componentType],a=n.num_components(),o=t.num_points()*a,c=o*s.BYTES_PER_ELEMENT,l=xn._malloc(c);e.GetAttributeDataArrayForAllPoints(t,n,r,c,l);let u=new s(xn.HEAPF32.buffer,l,o).slice();return xn._free(l),u}function D2(e){xn=e,SS={[Be.ComponentType.FLOAT]:Float32Array,[Be.ComponentType.UNSIGNED_INT]:Uint32Array,[Be.ComponentType.UNSIGNED_SHORT]:Uint16Array,[Be.ComponentType.UNSIGNED_BYTE]:Uint8Array,[Be.ComponentType.SHORT]:Int16Array,[Be.ComponentType.BYTE]:Int8Array},MS={[Be.ComponentType.FLOAT]:xn.DT_FLOAT32,[Be.ComponentType.UNSIGNED_INT]:xn.DT_UINT32,[Be.ComponentType.UNSIGNED_SHORT]:xn.DT_UINT16,[Be.ComponentType.UNSIGNED_BYTE]:xn.DT_UINT8,[Be.ComponentType.SHORT]:xn.DT_INT16,[Be.ComponentType.BYTE]:xn.DT_INT8}}function F2(e){wi=e}function U2(e,t=fS){let n={...fS,...t};n.quantizationBits={...RS,...t.quantizationBits};let i=new wi.MeshBuilder,r=new wi.Mesh,s=new wi.ExpertEncoder(r),a={},o=new wi.DracoInt8Array,c=e.listTargets().length>0,l=!1;for(let m of e.listSemantics()){let g=e.getAttribute(m);if(g.getSparse()){l=!0;continue}let p=B2(m),x=z2(i,g.getComponentType(),r,wi[p],g.getCount(),g.getElementSize(),g.getArray());if(x===-1)throw Error(`Error compressing "${m}" attribute.`);if(a[m]=x,n.quantizationVolume==="mesh"||m!=="POSITION")s.SetAttributeQuantization(x,n.quantizationBits[p]);else if(typeof n.quantizationVolume==="object"){let{quantizationVolume:_}=n,y=Math.max(_.max[0]-_.min[0],_.max[1]-_.min[1],_.max[2]-_.min[2]);s.SetAttributeExplicitQuantization(x,n.quantizationBits[p],g.getElementSize(),_.min,y)}else throw Error("Invalid quantization volume state.")}let u=e.getIndices();if(!u)throw new jg("Primitive must have indices.");if(i.AddFacesToMesh(r,u.getCount()/3,u.getArray()),s.SetSpeedOptions(n.encodeSpeed,n.decodeSpeed),s.SetTrackEncodedProperties(!0),n.method===0||c||l)s.SetEncodingMethod(wi.MESH_SEQUENTIAL_ENCODING);else s.SetEncodingMethod(wi.MESH_EDGEBREAKER_ENCODING);let d=s.EncodeToDracoBuffer(!(c||l),o);if(d<=0)throw new jg("Error applying Draco compression.");let f=new Uint8Array(d);for(let m=0;m<d;++m)f[m]=o.GetValue(m);let h=s.GetNumberOfEncodedPoints(),b=s.GetNumberOfEncodedFaces()*3;return wi.destroy(o),wi.destroy(r),wi.destroy(i),wi.destroy(s),{numVertices:h,numIndices:b,data:f,attributeIDs:a}}function B2(e){if(e==="POSITION")return"POSITION";else if(e==="NORMAL")return"NORMAL";else if(e.startsWith("COLOR_"))return"COLOR";else if(e.startsWith("TEXCOORD_"))return"TEX_COORD";return"GENERIC"}function z2(e,t,n,i,r,s,a){switch(t){case Be.ComponentType.UNSIGNED_BYTE:return e.AddUInt8Attribute(n,i,r,s,a);case Be.ComponentType.BYTE:return e.AddInt8Attribute(n,i,r,s,a);case Be.ComponentType.UNSIGNED_SHORT:return e.AddUInt16Attribute(n,i,r,s,a);case Be.ComponentType.SHORT:return e.AddInt16Attribute(n,i,r,s,a);case Be.ComponentType.UNSIGNED_INT:return e.AddUInt32Attribute(n,i,r,s,a);case Be.ComponentType.FLOAT:return e.AddFloatAttribute(n,i,r,s,a);default:throw Error(`Unexpected component type, "${t}".`)}}function V2(e){let t=e.getLogger(),n=new Set,i=new Set,r=0,s=0;for(let d of e.getRoot().listMeshes())for(let f of d.listPrimitives())if(!f.getIndices())i.add(f),r++;else if(f.getMode()!==Jn.Mode.TRIANGLES)i.add(f),s++;else n.add(f);if(r>0)t.warn(`[${tn}] Skipping Draco compression of ${r} non-indexed primitives.`);if(s>0)t.warn(`[${tn}] Skipping Draco compression of ${s} non-TRIANGLES primitives.`);let a=e.getRoot().listAccessors(),o=new Map;for(let d=0;d<a.length;d++)o.set(a[d],d);let c=new Map,l=new Set,u=new Map;for(let d of Array.from(n)){let f=hS(d,o);if(l.has(f)){u.set(d,f);continue}if(c.has(d.getIndices())){let h=d.getIndices(),b=h.clone();o.set(b,e.getRoot().listAccessors().length-1),d.swap(h,b)}for(let h of d.listAttributes())if(c.has(h)){let b=h.clone();o.set(b,e.getRoot().listAccessors().length-1),d.swap(h,b)}f=hS(d,o),l.add(f),u.set(d,f),c.set(d.getIndices(),f);for(let h of d.listAttributes())c.set(h,f)}for(let d of Array.from(c.keys())){let f=new Set(d.listParents().map((h)=>h.propertyType));if(f.size!==2||!f.has(te.PRIMITIVE)||!f.has(te.ROOT))throw Error(`[${tn}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let d of Array.from(n)){let f=u.get(d),h=d.getIndices();if(c.get(h)!==f||d.listAttributes().some((b)=>c.get(b)!==f))throw Error(`[${tn}] Draco primitives must share all, or no, accessors.`)}for(let d of Array.from(i)){let f=d.getIndices();if(c.has(f)||d.listAttributes().some((h)=>c.has(h)))throw Error(`[${tn}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return u}function hS(e,t){let n=[],i=e.getIndices();n.push(t.get(i));for(let r of e.listAttributes())n.push(t.get(r));return n.sort().join("|")}function LU(e){return e.vkFormat>Fg&&e.vkFormat<=tS}function ES(e){let t=e.vkFormat===nS&&e.dataFormatDescriptor[0].colorModel===167;return e.vkFormat===Fg||t}function Bg(e){return JSON.parse(JSON.stringify(e))}var Os="EXT_mesh_gpu_instancing",Gr="EXT_mesh_features",Zn="EXT_meshopt_compression",et="EXT_structural_metadata",af="EXT_texture_webp",of="EXT_texture_avif",EF="KHR_accessor_float16",TF="KHR_accessor_float64",tn="KHR_draco_mesh_compression",Hr="KHR_lights_punctual",ks="KHR_materials_anisotropy",Ds="KHR_materials_clearcoat",Ls="KHR_materials_diffuse_transmission",Fs="KHR_materials_dispersion",Us="KHR_materials_emissive_strength",Bs="KHR_materials_ior",zs="KHR_materials_iridescence",Vs="KHR_materials_pbrSpecularGlossiness",js="KHR_materials_sheen",Hs="KHR_materials_specular",Gs="KHR_materials_transmission",Jo="KHR_materials_unlit",$s="KHR_materials_volume",fi="KHR_materials_variants",rS="KHR_mesh_primitive_restart",sS="KHR_mesh_quantization",Ks="KHR_node_visibility",cf="KHR_texture_basisu",Ws="KHR_texture_transform",$i="KHR_xmp_json_ld",AF,wF,SF,Sl,MF,zg="INSTANCE_ATTRIBUTE",NF,lf,PF,kF,aS,DF,oS,Vg,cS,Ml,jF,HF,GF,$F,KF,WF,XF,qF,JF,ZF,YF,QF,e2,t2,n2,R2=class{match(e){return e.length>=12&&Je.decodeText(e.slice(4,12))==="ftypavif"}getSize(e){if(!this.match(e))return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=lS(t,0);if(!n)return null;let i=n.end;while(n=lS(t,i))if(n.type==="meta")i=n.start+4;else if(n.type==="iprp"||n.type==="ipco")i=n.start;else if(n.type==="ispe")return[t.getUint32(n.start+4),t.getUint32(n.start+8)];else if(n.type==="mdat")break;else i=n.end;return null}getChannels(e){return 4}},AS,I2=class{match(e){return e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80}getSize(e){let t=Je.decodeText(e.slice(0,4)),n=Je.decodeText(e.slice(8,12));if(t!=="RIFF"||n!=="WEBP")return null;let i=new DataView(e.buffer,e.byteOffset),r=12;while(r<i.byteLength){let s=Je.decodeText(new Uint8Array([i.getUint8(r),i.getUint8(r+1),i.getUint8(r+2),i.getUint8(r+3)])),a=i.getUint32(r+4,!0);if(s==="VP8 ")return[i.getInt16(r+14,!0)&16383,i.getInt16(r+16,!0)&16383];else if(s==="VP8L"){let o=i.getUint8(r+9),c=i.getUint8(r+10),l=i.getUint8(r+11),u=i.getUint8(r+12);return[1+((c&63)<<8|o),1+((u&15)<<10|l<<2|(c&192)>>6)]}r+=8+a+a%2}return null}getChannels(e){return 4}},wS,uS,C2,dS,N2,xn,SS,MS,wi,L2,RS,fS,jg,IS,pS,j2,H2,G2,$2,K2,W2,mS,gS,X2,q2,J2,Z2,Y2,Q2,eU,tU,nU,iU,rU,sU,aU,oU,CS,cU,lU,uU,dU,bS,xS,yS,_S,fU,NS,hU,pU,mU,gU,bU,xU,yU,_U,vU,EU,TU,PS,AU,wU,SU,MU,OS,RU,IU,vS,CU,NU,PU,OU,kS,Hg,kU,DU,FU=class{match(e){return e[0]===171&&e[1]===75&&e[2]===84&&e[3]===88&&e[4]===32&&e[5]===50&&e[6]===48&&e[7]===187&&e[8]===13&&e[9]===10&&e[10]===26&&e[11]===10}getSize(e){let t=sf(e);return[t.pixelWidth,t.pixelHeight]}getChannels(e){let t=sf(e),n=t.dataFormatDescriptor[0];if(LU(t))return n.samples.length;if(ES(t))switch(n.colorModel){case Qw:return n.samples.length===2&&(n.samples[1].channelType&15)===15?4:3;case eS:return(n.samples[0].channelType&15)===3?4:3;default:throw Error(`Unexpected KTX2 colorModel, "${n.colorModel}".`)}throw Error(`Unexpected KTX2 vkFormat, "${t.vkFormat}".`)}getVRAMByteLength(e){let t=sf(e),n=0;if(ES(t)){let i=this.getChannels(e)>3;for(let r=0;r<t.levels.length;r++){let s=t.levels[r];if(s.uncompressedByteLength)n+=s.uncompressedByteLength;else{let a=Math.max(1,Math.floor(t.pixelWidth/Math.pow(2,r))),o=Math.max(1,Math.floor(t.pixelHeight/Math.pow(2,r))),c=i?16:8;n+=a/4*(o/4)*c}}}else for(let i of t.levels)if(t.supercompressionScheme===Yw)n+=i.levelData.byteLength;else n+=i.uncompressedByteLength;return n}},Gg,UU,BU,zU,VU,jU,HU,DS;var uf=mt(()=>{wl();iS();AF=class extends nt{static EXTENSION_NAME=Gr;init(){this.extensionName=Gr,this.propertyType="FeatureID",this.parentTypes=["Features"]}getDefaults(){return Object.assign(super.getDefaults(),{nullFeatureId:null,label:"",attribute:null,texture:null,propertyTable:null})}getFeatureCount(){return this.get("featureCount")}setFeatureCount(e){return this.set("featureCount",e)}getNullFeatureID(){return this.get("nullFeatureId")}setNullFeatureID(e){return this.set("nullFeatureId",e)}getLabel(){return this.get("label")}setLabel(e){return this.set("label",e)}getAttribute(){return this.get("attribute")}setAttribute(e){return this.set("attribute",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getPropertyTable(){return this.getRef("propertyTable")}setPropertyTable(e){return this.setRef("propertyTable",e)}},wF=class extends nt{static EXTENSION_NAME=Gr;init(){this.extensionName=Gr,this.propertyType="FeatureIDTexture",this.parentTypes=["FeatureID"]}getDefaults(){let e=new wt(this.graph,"textureInfo");return e.setMinFilter(wt.MagFilter.NEAREST),e.setMagFilter(wt.MagFilter.NEAREST),Object.assign(super.getDefaults(),{channels:[0],texture:null,textureInfo:e})}getChannels(){return this.get("channels")}setChannels(e){return this.set("channels",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getTextureInfo(){return this.getRef("texture")?this.getRef("textureInfo"):null}},SF=class extends nt{static EXTENSION_NAME=Gr;init(){this.extensionName=Gr,this.propertyType="Features",this.parentTypes=[te.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{featureIds:new It([])})}listFeatureIDs(){return this.listRefs("featureIds")}addFeatureID(e){return this.addRef("featureIds",e)}removeFeatureID(e){return this.removeRef("featureIds",e)}},Sl=Gr,MF=class extends _t{extensionName=Gr;static EXTENSION_NAME=Gr;createFeatures(){return new SF(this.document.getGraph())}createFeatureID(){return new AF(this.document.getGraph())}createFeatureIDTexture(){return new wF(this.document.getGraph())}read(e){return(e.jsonDoc.json.meshes||[]).forEach((t,n)=>{(t.primitives||[]).forEach((i,r)=>{this._readPrimitive(e,n,i,r)})}),this}_readPrimitive(e,t,n,i){if(!n.extensions||!n.extensions[Sl])return;let r=this.createFeatures(),s=n.extensions[Sl];for(let a of s.featureIds){let o=RF(this.document,this,e,a);r.addFeatureID(o)}e.meshes[t].listPrimitives()[i].setExtension(Sl,r)}write(e){let t=e.jsonDoc.json.meshes;if(!t)return this;for(let n of this.document.getRoot().listMeshes()){let i=t[e.meshIndexMap.get(n)];n.listPrimitives().forEach((r,s)=>{let a=i.primitives[s];this._writePrimitive(e,r,a)})}return this}_writePrimitive(e,t,n){let i=t.getExtension(Sl);if(!i)return;let r={featureIds:[]};i.listFeatureIDs().forEach((s)=>{r.featureIds.push(CF(this.document,e,s))}),n.extensions=n.extensions||{},n.extensions[Sl]=r}};NF=class extends nt{static EXTENSION_NAME=Os;init(){this.extensionName=Os,this.propertyType="InstancedMesh",this.parentTypes=[te.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new dn})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:zg})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}},lf=class extends _t{static EXTENSION_NAME=Os;extensionName=Os;prewriteTypes=[te.ACCESSOR];createInstancedMesh(){return new NF(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,n)=>{if(!t.extensions||!t.extensions.EXT_mesh_gpu_instancing)return;let i=t.extensions[Os],r=this.createInstancedMesh();for(let s in i.attributes)r.setAttribute(s,e.accessors[i.attributes[s]]);e.nodes[n].setExtension(Os,r)}),this}prewrite(e){e.accessorUsageGroupedByParent.add(zg);for(let t of this.properties)for(let n of t.listAttributes())e.addAccessorToUsageGroup(n,zg);return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listNodes().forEach((n)=>{let i=n.getExtension(Os);if(i){let r=e.nodeIndexMap.get(n),s=t.json.nodes[r],a={attributes:{}};i.listSemantics().forEach((o)=>{let c=i.getAttribute(o);a.attributes[o]=e.accessorIndexMap.get(c)}),s.extensions=s.extensions||{},s.extensions[Os]=a}}),this}},PF=function(e){return e.QUANTIZE="quantize",e.FILTER="filter",e}({});({BYTE:kF,SHORT:aS,FLOAT:DF}=Be.ComponentType),{encodeNormalizedInt:oS,decodeNormalizedInt:Vg}=pt;cS={method:"quantize"},Ml=class extends _t{extensionName=Zn;prereadTypes=[te.BUFFER,te.PRIMITIVE];prewriteTypes=[te.BUFFER,te.ACCESSOR];readDependencies=["meshopt.decoder"];writeDependencies=["meshopt.encoder"];static EXTENSION_NAME=Zn;static EncoderMethod=PF;_decoder=null;_decoderFallbackBufferMap=new Map;_encoder=null;_encoderOptions=cS;_encoderFallbackBuffer=null;_encoderBufferViews={};_encoderBufferViewData={};_encoderBufferViewAccessors={};install(e,t){if(e==="meshopt.decoder")this._decoder=t;if(e==="meshopt.encoder")this._encoder=t;return this}setEncoderOptions(e){return this._encoderOptions={...cS,...e},this}preread(e,t){if(!this._decoder){if(!this.isRequired())return this;throw Error(`[${Zn}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw Error(`[${Zn}]: Missing WASM support.`)}if(t===te.BUFFER)this._prereadBuffers(e);else if(t===te.PRIMITIVE)this._prereadPrimitives(e);return this}_prereadBuffers(e){let t=e.jsonDoc;(t.json.bufferViews||[]).forEach((n,i)=>{if(!n.extensions||!n.extensions.EXT_meshopt_compression)return;let r=n.extensions[Zn],s=r.byteOffset||0,a=r.byteLength||0,{count:o,byteStride:c}=r,l=new Uint8Array(o*c),u=t.json.buffers[r.buffer],d=u.uri?t.resources[u.uri]:t.resources[Cs],f=Je.toView(d,s,a);this._decoder.decodeGltfBuffer(l,o,c,f,r.mode,r.filter),e.bufferViews[i]=l})}_prereadPrimitives(e){let t=e.jsonDoc;(t.json.bufferViews||[]).forEach((n)=>{if(!n.extensions||!n.extensions.EXT_meshopt_compression)return;let i=n.extensions[Zn],r=e.buffers[i.buffer],s=e.buffers[n.buffer],a=t.json.buffers[n.buffer];if(OF(a))this._decoderFallbackBufferMap.set(s,r)})}read(e){if(!this.isRequired())return this;for(let[t,n]of this._decoderFallbackBufferMap){for(let i of t.listParents())if(i instanceof Be)i.swap(t,n);t.dispose()}return this}prewrite(e,t){if(t===te.ACCESSOR)this._prewriteAccessors(e);else if(t===te.BUFFER)this._prewriteBuffers(e);return this}_prewriteAccessors(e){let t=e.jsonDoc.json,n=this._encoder,i=this._encoderOptions,r=this.document.getGraph(),s=this.document.createBuffer(),a=this.document.getRoot().listBuffers().indexOf(s),o=1,c=new Map,l=(u)=>{for(let d of r.listParents(u)){if(d.propertyType===te.ROOT)continue;let f=c.get(u);if(f===void 0)c.set(u,f=o++);return f}return-1};this._encoderFallbackBuffer=s,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let u of this.document.getRoot().listAccessors()){if(TS(u)==="weights")continue;if(u.getSparse())continue;let d=e.getAccessorUsage(u),f=e.accessorUsageGroupedByParent.has(d)?l(u):null,h=zF(u,d),b=i.method==="filter"?VF(u,this.document):{filter:"NONE"},m=LF(u,n,h,b),{array:g,byteStride:p}=m,x=u.getBuffer();if(!x)throw Error(`${Zn}: Missing buffer for accessor.`);let _=this.document.getRoot().listBuffers().indexOf(x),y=[d,f,h,b.filter,p,_].join(":"),v=this._encoderBufferViews[y],T=this._encoderBufferViewData[y],A=this._encoderBufferViewAccessors[y];if(!v||!T)A=this._encoderBufferViewAccessors[y]=[],T=this._encoderBufferViewData[y]=[],v=this._encoderBufferViews[y]={buffer:a,target:Is.USAGE_TO_TARGET[d],byteOffset:0,byteLength:0,byteStride:d===Is.BufferViewUsage.ARRAY_BUFFER?p:void 0,extensions:{[Zn]:{buffer:_,byteOffset:0,byteLength:0,mode:h,filter:b.filter!=="NONE"?b.filter:void 0,byteStride:p,count:0}}};let E=e.createAccessorDef(u);if(E.componentType=m.componentType,E.normalized=m.normalized,E.byteOffset=v.byteLength,E.min&&m.min)E.min=m.min;if(E.max&&m.max)E.max=m.max;e.accessorIndexMap.set(u,t.accessors.length),t.accessors.push(E),A.push(E),T.push(new Uint8Array(g.buffer,g.byteOffset,g.byteLength)),v.byteLength+=g.byteLength,v.extensions.EXT_meshopt_compression.count+=u.getCount()}}_prewriteBuffers(e){let t=this._encoder;for(let n in this._encoderBufferViews){let i=this._encoderBufferViews[n],r=this._encoderBufferViewData[n],s=this.document.getRoot().listBuffers()[i.extensions[Zn].buffer],a=e.otherBufferViews.get(s)||[],{count:o,byteStride:c,mode:l}=i.extensions[Zn],u=Je.concat(r),d=t.encodeGltfBuffer(u,o,c,l),f=Je.pad(d);i.extensions[Zn].byteLength=d.byteLength,r.length=0,r.push(f),a.push(f),e.otherBufferViews.set(s,a)}}write(e){let t=0;for(let s in this._encoderBufferViews){let a=this._encoderBufferViews[s],o=this._encoderBufferViewData[s][0],c=e.otherBufferViewsIndexMap.get(o),l=this._encoderBufferViewAccessors[s];for(let h of l)h.bufferView=c;let u=e.jsonDoc.json.bufferViews[c],d=u.byteOffset||0;Object.assign(u,a),u.byteOffset=t;let f=u.extensions[Zn];f.byteOffset=d,t+=Je.padNumber(a.byteLength)}let n=this._encoderFallbackBuffer,i=e.bufferIndexMap.get(n),r=e.jsonDoc.json.buffers[i];return r.byteLength=t,r.extensions={[Zn]:{fallback:!0}},n.dispose(),this}},jF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="StructuralMetadata",this.parentTypes=[te.ROOT]}getDefaults(){return Object.assign(super.getDefaults(),{schema:null,schemaUri:"",propertyTables:new bn,propertyTextures:new bn,propertyAttributes:new bn})}getSchema(){return this.getRef("schema")}setSchema(e){return this.setRef("schema",e)}getSchemaUri(){return this.get("schemaUri")}setSchemaUri(e){return this.set("schemaUri",e)}listPropertyTables(){return this.listRefs("propertyTables")}addPropertyTable(e){return this.addRef("propertyTables",e)}removePropertyTable(e){return this.removeRef("propertyTables",e)}listPropertyTextures(){return this.listRefs("propertyTextures")}addPropertyTexture(e){return this.addRef("propertyTextures",e)}removePropertyTexture(e){return this.removeRef("propertyTextures",e)}listPropertyAttributes(){return this.listRefs("propertyAttributes")}addPropertyAttribute(e){return this.addRef("propertyAttributes",e)}removePropertyAttribute(e){return this.removeRef("propertyAttributes",e)}},HF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="Schema",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",version:"",classes:new dn,enums:new dn})}getId(){return this.get("id")}setId(e){return this.set("id",e)}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getVersion(){return this.get("version")}setVersion(e){return this.set("version",e)}setClass(e,t){return this.setRefMap("classes",e,t)}getClass(e){return this.getRefMap("classes",e)}listClassKeys(){return this.listRefMapKeys("classes")}listClassValues(){return this.listRefMapValues("classes")}setEnum(e,t){return this.setRefMap("enums",e,t)}getEnum(e){return this.getRefMap("enums",e)}listEnumKeys(){return this.listRefMapKeys("enums")}listEnumValues(){return this.listRefMapValues("enums")}},GF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="Class",this.parentTypes=["Schema"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",properties:new dn})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},$F=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="ClassProperty",this.parentTypes=["Class"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",componentType:null,enumType:null,array:null,count:null,normalized:null,offset:null,scale:null,max:null,min:null,required:null,noData:null,default:null})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getType(){return this.get("type")}setType(e){return this.set("type",e)}getComponentType(){return this.get("componentType")}setComponentType(e){return this.set("componentType",e)}getEnumType(){return this.get("enumType")}setEnumType(e){return this.set("enumType",e)}getArray(){return this.get("array")}setArray(e){return this.set("array",e)}getCount(){return this.get("count")}setCount(e){return this.set("count",e)}getNormalized(){return this.get("normalized")}setNormalized(e){return this.set("normalized",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}getRequired(){return this.get("required")}setRequired(e){return this.set("required",e)}getNoData(){return this.get("noData")}setNoData(e){return this.set("noData",e)}getDefault(){return this.get("default")}setDefault(e){return this.set("default",e)}},KF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="Enum",this.parentTypes=["Schema"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",valueType:"UINT16",values:new bn})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getValueType(){return this.get("valueType")}setValueType(e){return this.set("valueType",e)}listValues(){return this.listRefs("values")}addEnumValue(e){return this.addRef("values",e)}removeEnumValue(e){return this.removeRef("values",e)}},WF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="EnumValue",this.parentTypes=["Enum"]}getDefaults(){return Object.assign(super.getDefaults(),{description:null})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getValue(){return this.get("value")}setValue(e){return this.set("value",e)}},XF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTable",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new dn})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}getCount(){return this.get("count")}setCount(e){return this.set("count",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},qF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTableProperty",this.parentTypes=["PropertyTable"]}getDefaults(){return Object.assign(super.getDefaults(),{arrayOffsets:null,stringOffsets:null,arrayOffsetType:null,stringOffsetType:null,offset:null,scale:null,max:null,min:null})}getValues(){return this.get("values")}setValues(e){return this.set("values",e)}getArrayOffsets(){return this.get("arrayOffsets")}setArrayOffsets(e){return this.set("arrayOffsets",e)}getStringOffsets(){return this.get("stringOffsets")}setStringOffsets(e){return this.set("stringOffsets",e)}getArrayOffsetType(){return this.get("arrayOffsetType")}setArrayOffsetType(e){return this.set("arrayOffsetType",e)}getStringOffsetType(){return this.get("stringOffsetType")}setStringOffsetType(e){return this.set("stringOffsetType",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},JF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTexture",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new dn})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},ZF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTextureProperty",this.parentTypes=["PropertyTexture"]}getDefaults(){let e=new wt(this.graph,"textureInfo");return e.setMinFilter(wt.MagFilter.NEAREST),e.setMagFilter(wt.MagFilter.NEAREST),Object.assign(super.getDefaults(),{channels:[0],texture:null,textureInfo:e,offset:null,scale:null,max:null,min:null})}getChannels(){return this.get("channels")}setChannels(e){return this.set("channels",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getTextureInfo(){return this.getRef("texture")?this.getRef("textureInfo"):null}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},YF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyAttribute",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new dn})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},QF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyAttributeProperty",this.parentTypes=["PropertyAttribute"]}getDefaults(){return Object.assign(super.getDefaults(),{offset:null,scale:null,max:null,min:null})}getAttribute(){return this.get("attribute")}setAttribute(e){return this.set("attribute",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},e2=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="NodeStructuralMetadata",this.parentTypes=[te.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{class:"",properties:{}})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}getProperties(){return this.get("properties")}setProperties(e){return this.set("properties",e)}},t2=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="MeshPrimitiveStructuralMetadata",this.parentTypes=[te.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{propertyTextures:new bn,propertyAttributes:new bn})}listPropertyTextures(){return this.listRefs("propertyTextures")}addPropertyTexture(e){return this.addRef("propertyTextures",e)}removePropertyTexture(e){return this.removeRef("propertyTextures",e)}listPropertyAttributes(){return this.listRefs("propertyAttributes")}addPropertyAttribute(e){return this.addRef("propertyAttributes",e)}removePropertyAttribute(e){return this.removeRef("propertyAttributes",e)}},n2=class extends _t{extensionName=et;static EXTENSION_NAME=et;prewriteTypes=[te.BUFFER];prereadTypes=[te.SCENE];createStructuralMetadata(){return new jF(this.document.getGraph())}createSchema(){return new HF(this.document.getGraph())}createClass(){return new GF(this.document.getGraph())}createClassProperty(){return new $F(this.document.getGraph())}createEnum(){return new KF(this.document.getGraph())}createEnumValue(){return new WF(this.document.getGraph())}createPropertyTable(){return new XF(this.document.getGraph())}createPropertyTableProperty(){return new qF(this.document.getGraph())}createPropertyTexture(){return new JF(this.document.getGraph())}createPropertyTextureProperty(){return new ZF(this.document.getGraph())}createPropertyAttribute(){return new YF(this.document.getGraph())}createPropertyAttributeProperty(){return new QF(this.document.getGraph())}createNodeStructuralMetadata(){return new e2(this.document.getGraph())}createMeshPrimitiveStructuralMetadata(){return new t2(this.document.getGraph())}read(e){return this}preread(e){let t=this.document.getRoot(),{json:n}=e.jsonDoc,i=n.extensions[et],r=i2(this,e,i);return t.setExtension(et,r),(n.meshes||[]).forEach((s,a)=>{let o=e.meshes[a].listPrimitives();(s.primitives||[]).forEach((c,l)=>{let u=o[l];this._readPrimitive(r,u,c)})}),(n.nodes||[]).forEach((s,a)=>{this._readNode(e.nodes[a],s)}),this}_readPrimitive(e,t,n){if(!n.extensions||!n.extensions.EXT_structural_metadata)return;let i=this.createMeshPrimitiveStructuralMetadata(),r=n.extensions[et],s=e.listPropertyTextures(),a=r.propertyTextures||[];for(let l of a){let u=s[l];i.addPropertyTexture(u)}let o=e.listPropertyAttributes(),c=r.propertyAttributes||[];for(let l of c){let u=o[l];i.addPropertyAttribute(u)}t.setExtension(et,i)}_readNode(e,t){if(!t.extensions||!t.extensions.EXT_structural_metadata)return;let n=t.extensions[et],i=this.createNodeStructuralMetadata().setClass(n.class).setProperties(n.properties);e.setExtension(et,i)}write(e){let t=this.document.getRoot(),n=t.getExtension(et);if(!n)return this;let i=e.jsonDoc.json,r=m2(e,n);i.extensions=i.extensions||{},i.extensions[et]=r;let s=t.listMeshes(),a=i.meshes;if(a)for(let l of s){let u=a[e.meshIndexMap.get(l)];l.listPrimitives().forEach((d,f)=>{let h=u.primitives[f];this._writePrimitive(n,d,h)})}let o=t.listNodes(),c=i.nodes;if(c)for(let l of o){let u=e.nodeIndexMap.get(l);this._writeNode(l,c[u])}return this}_writePrimitive(e,t,n){let i=t.getExtension(et);if(!i)return;let r=e.listPropertyTextures(),s=e.listPropertyAttributes(),a,o,c=i.listPropertyTextures();if(c.length>0){a=[];for(let d of c){let f=r.indexOf(d);if(f>=0)a.push(f);else throw Error(`${et}: Invalid property texture in mesh primitive`)}}let l=i.listPropertyAttributes();if(l.length>0){o=[];for(let d of l){let f=s.indexOf(d);if(f>=0)o.push(f);else throw Error(`${et}: Invalid property attribute in mesh primitive`)}}let u={propertyTextures:a,propertyAttributes:o};n.extensions=n.extensions||{},n.extensions[et]=u}_writeNode(e,t){let n=e.getExtension("EXT_structural_metadata");if(!n)return;t.extensions=t.extensions||{},t.extensions[et]={class:n.getClass(),properties:n.getProperties()}}prewrite(e,t){if(t===te.BUFFER)this._prewriteBuffers(e);return this}_prewriteBuffers(e){let t=this.document,n=t.getRoot().getExtension(et);e.jsonDoc.json.bufferViews||=[];for(let i of n.listPropertyTables())for(let r of i.listPropertyValues()){let s=M2(t,e);s.push(r.getValues());let a=r.getArrayOffsets();if(a)s.push(a);let o=r.getStringOffsets();if(o)s.push(o)}}};AS=class extends _t{extensionName=of;prereadTypes=[te.TEXTURE];static EXTENSION_NAME=of;static register(){Gi.registerFormat("image/avif",new R2)}preread(e){return(e.jsonDoc.json.textures||[]).forEach((t)=>{if(t.extensions&&t.extensions.EXT_texture_avif)t.source=t.extensions[of].source}),this}read(e){return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listTextures().forEach((n)=>{if(n.getMimeType()==="image/avif"){let i=e.imageIndexMap.get(n);(t.json.textures||[]).forEach((r)=>{if(r.source===i)r.extensions=r.extensions||{},r.extensions[of]={source:r.source},delete r.source})}}),this}};wS=class extends _t{extensionName=af;prereadTypes=[te.TEXTURE];static EXTENSION_NAME=af;static register(){Gi.registerFormat("image/webp",new I2)}preread(e){return(e.jsonDoc.json.textures||[]).forEach((t)=>{if(t.extensions&&t.extensions.EXT_texture_webp)t.source=t.extensions[af].source}),this}read(e){return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listTextures().forEach((n)=>{if(n.getMimeType()==="image/webp"){let i=e.imageIndexMap.get(n);(t.json.textures||[]).forEach((r)=>{if(r.source===i)r.extensions=r.extensions||{},r.extensions[af]={source:r.source},delete r.source})}}),this}},uS=EF,C2=class extends _t{extensionName=uS;static EXTENSION_NAME=uS;read(e){return this}write(e){return this}},dS=TF,N2=class extends _t{extensionName=dS;static EXTENSION_NAME=dS;read(e){return this}write(e){return this}};L2=function(e){return e[e.EDGEBREAKER=1]="EDGEBREAKER",e[e.SEQUENTIAL=0]="SEQUENTIAL",e}({}),RS={["POSITION"]:14,["NORMAL"]:10,["COLOR"]:8,["TEX_COORD"]:12,["GENERIC"]:12},fS={decodeSpeed:5,encodeSpeed:5,method:1,quantizationBits:RS,quantizationVolume:"mesh"};jg=class extends Error{},IS=class extends _t{extensionName=tn;prereadTypes=[te.PRIMITIVE];prewriteTypes=[te.ACCESSOR];readDependencies=["draco3d.decoder"];writeDependencies=["draco3d.encoder"];static EXTENSION_NAME=tn;static EncoderMethod=L2;_decoderModule=null;_encoderModule=null;_encoderOptions={};install(e,t){if(e==="draco3d.decoder")this._decoderModule=t,D2(this._decoderModule);if(e==="draco3d.encoder")this._encoderModule=t,F2(this._encoderModule);return this}setEncoderOptions(e){return this._encoderOptions=e,this}preread(e){if(!this._decoderModule)throw Error(`[${tn}] Please install extension dependency, "draco3d.decoder".`);let t=this.document.getLogger(),n=e.jsonDoc,i=new Map;try{let r=n.json.meshes||[];for(let s of r)for(let a of s.primitives){if(!a.extensions||!a.extensions.KHR_draco_mesh_compression)continue;let o=a.extensions[tn],[c,l]=i.get(o.bufferView)||[];if(!l||!c){let u=n.json.bufferViews[o.bufferView],d=n.json.buffers[u.buffer],f=d.uri?n.resources[d.uri]:n.resources[Cs],h=u.byteOffset||0,b=u.byteLength,m=Je.toView(f,h,b);c=new this._decoderModule.Decoder,l=P2(c,m),i.set(o.bufferView,[c,l]),t.debug(`[${tn}] Decompressed ${m.byteLength} bytes.`)}for(let u in o.attributes){let d=e.jsonDoc.json.accessors[a.attributes[u]],f=c.GetAttributeByUniqueId(l,o.attributes[u]),h=k2(c,l,f,d);e.accessors[a.attributes[u]].setArray(h)}if(a.indices!==void 0)e.accessors[a.indices].setArray(O2(c,l))}}finally{for(let[r,s]of Array.from(i.values()))this._decoderModule.destroy(r),this._decoderModule.destroy(s)}return this}read(e){return this}prewrite(e,t){if(!this._encoderModule)throw Error(`[${tn}] Please install extension dependency, "draco3d.encoder".`);let n=this.document.getLogger();n.debug(`[${tn}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let i=V2(this.document),r=new Map,s="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)n.warn(`[${tn}]: quantizationVolume=scene requires exactly 1 scene.`);else s=Og(this.document.getRoot().listScenes().pop());for(let a of Array.from(i.keys())){let o=i.get(a);if(!o)throw Error("Unexpected primitive.");if(r.has(o)){r.set(o,r.get(o));continue}let c=a.getIndices(),l=e.jsonDoc.json.accessors,u;try{u=U2(a,{...this._encoderOptions,quantizationVolume:s})}catch(h){if(h instanceof jg){n.warn(`[${tn}]: ${h.message} Skipping primitive compression.`);continue}throw h}r.set(o,u);let d=e.createAccessorDef(c);if(d.count=u.numIndices,e.accessorIndexMap.set(c,l.length),l.push(d),u.numVertices>65534&&Be.getComponentSize(d.componentType)<=2)d.componentType=Be.ComponentType.UNSIGNED_INT;else if(u.numVertices>254&&Be.getComponentSize(d.componentType)<=1)d.componentType=Be.ComponentType.UNSIGNED_SHORT;for(let h of a.listSemantics()){let b=a.getAttribute(h);if(u.attributeIDs[h]===void 0)continue;let m=e.createAccessorDef(b);m.count=u.numVertices,e.accessorIndexMap.set(b,l.length),l.push(m)}let f=a.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!e.otherBufferViews.has(f))e.otherBufferViews.set(f,[]);e.otherBufferViews.get(f).push(u.data)}return n.debug(`[${tn}] Compressed ${i.size} primitives.`),e.extensionData[tn]={primitiveHashMap:i,primitiveEncodingMap:r},this}write(e){let t=e.extensionData[tn];for(let n of this.document.getRoot().listMeshes()){let i=e.jsonDoc.json.meshes[e.meshIndexMap.get(n)];for(let r=0;r<n.listPrimitives().length;r++){let s=n.listPrimitives()[r],a=i.primitives[r],o=t.primitiveHashMap.get(s);if(!o)continue;let c=t.primitiveEncodingMap.get(o);if(!c)continue;a.extensions=a.extensions||{},a.extensions[tn]={bufferView:e.otherBufferViewsIndexMap.get(c.data),attributes:c.attributeIDs}}}if(!t.primitiveHashMap.size){let n=e.jsonDoc.json;n.extensionsUsed=(n.extensionsUsed||[]).filter((i)=>i!==tn),n.extensionsRequired=(n.extensionsRequired||[]).filter((i)=>i!==tn)}return this}};pS=class e extends nt{static EXTENSION_NAME=Hr;static Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};init(){this.extensionName=Hr,this.propertyType="Light",this.parentTypes=[te.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:e.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(t){return this.set("color",t)}getIntensity(){return this.get("intensity")}setIntensity(t){return this.set("intensity",t)}getType(){return this.get("type")}setType(t){return this.set("type",t)}getRange(){return this.get("range")}setRange(t){return this.set("range",t)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(t){return this.set("innerConeAngle",t)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(t){return this.set("outerConeAngle",t)}},j2=class extends _t{extensionName=Hr;static EXTENSION_NAME=Hr;createLight(e=""){return new pS(this.document.getGraph(),e)}read(e){let t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions.KHR_lights_punctual)return this;let n=(t.json.extensions.KHR_lights_punctual.lights||[]).map((i)=>{let r=this.createLight().setName(i.name||"").setType(i.type);if(i.extras)r.setExtras(i.extras);if(i.color!==void 0)r.setColor(i.color);if(i.intensity!==void 0)r.setIntensity(i.intensity);if(i.range!==void 0)r.setRange(i.range);if(i.spot?.innerConeAngle!==void 0)r.setInnerConeAngle(i.spot.innerConeAngle);if(i.spot?.outerConeAngle!==void 0)r.setOuterConeAngle(i.spot.outerConeAngle);return r});return t.json.nodes.forEach((i,r)=>{if(!i.extensions||!i.extensions.KHR_lights_punctual)return;let s=i.extensions[Hr];e.nodes[r].setExtension(Hr,n[s.light])}),this}write(e){let t=e.jsonDoc;if(this.properties.size===0)return this;let n=[],i=new Map;for(let r of this.properties){let s=r,a=e.createPropertyDef(r);if(a.type=s.getType(),!pt.eq(s.getColor(),[1,1,1]))a.color=s.getColor();if(s.getIntensity()!==1)a.intensity=s.getIntensity();if(s.getRange()!=null)a.range=s.getRange();if(s.getName())a.name=s.getName();if(s.getType()===pS.Type.SPOT)a.spot={innerConeAngle:s.getInnerConeAngle(),outerConeAngle:s.getOuterConeAngle()};n.push(a),i.set(s,n.length-1)}return this.document.getRoot().listNodes().forEach((r)=>{let s=r.getExtension(Hr);if(s){let a=e.nodeIndexMap.get(r),o=t.json.nodes[a];o.extensions=o.extensions||{},o.extensions[Hr]={light:i.get(s)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[Hr]={lights:n},this}},{R:H2,G:G2,B:$2}=Ai,K2=class extends nt{static EXTENSION_NAME=ks;init(){this.extensionName=ks,this.propertyType="Anisotropy",this.parentTypes=[te.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new wt(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(e){return this.set("anisotropyStrength",e)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(e){return this.set("anisotropyRotation",e)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(e){return this.setRef("anisotropyTexture",e,{channels:H2|G2|$2})}},W2=class extends _t{static EXTENSION_NAME=ks;extensionName=ks;prereadTypes=[te.MESH];prewriteTypes=[te.MESH];createAnisotropy(){return new K2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_anisotropy){let a=this.createAnisotropy();e.materials[s].setExtension(ks,a);let o=r.extensions[ks];if(o.extras)a.setExtras(o.extras);if(o.anisotropyStrength!==void 0)a.setAnisotropyStrength(o.anisotropyStrength);if(o.anisotropyRotation!==void 0)a.setAnisotropyRotation(o.anisotropyRotation);if(o.anisotropyTexture!==void 0){let c=o.anisotropyTexture,l=e.textures[i[c.index].source];a.setAnisotropyTexture(l),e.setTextureInfo(a.getAnisotropyTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(ks);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[ks]=a,i.getAnisotropyStrength()>0)a.anisotropyStrength=i.getAnisotropyStrength();if(i.getAnisotropyRotation()!==0)a.anisotropyRotation=i.getAnisotropyRotation();if(i.getAnisotropyTexture()){let o=i.getAnisotropyTexture(),c=i.getAnisotropyTextureInfo();a.anisotropyTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:mS,G:gS,B:X2}=Ai,q2=class extends nt{static EXTENSION_NAME=Ds;init(){this.extensionName=Ds,this.propertyType="Clearcoat",this.parentTypes=[te.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new wt(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new wt(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new wt(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(e){return this.set("clearcoatFactor",e)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(e){return this.setRef("clearcoatTexture",e,{channels:mS})}getClearcoatRoughnessFactor(){return this.get("clearcoatRoughnessFactor")}setClearcoatRoughnessFactor(e){return this.set("clearcoatRoughnessFactor",e)}getClearcoatRoughnessTexture(){return this.getRef("clearcoatRoughnessTexture")}getClearcoatRoughnessTextureInfo(){return this.getRef("clearcoatRoughnessTexture")?this.getRef("clearcoatRoughnessTextureInfo"):null}setClearcoatRoughnessTexture(e){return this.setRef("clearcoatRoughnessTexture",e,{channels:gS})}getClearcoatNormalScale(){return this.get("clearcoatNormalScale")}setClearcoatNormalScale(e){return this.set("clearcoatNormalScale",e)}getClearcoatNormalTexture(){return this.getRef("clearcoatNormalTexture")}getClearcoatNormalTextureInfo(){return this.getRef("clearcoatNormalTexture")?this.getRef("clearcoatNormalTextureInfo"):null}setClearcoatNormalTexture(e){return this.setRef("clearcoatNormalTexture",e,{channels:mS|gS|X2})}},J2=class extends _t{static EXTENSION_NAME=Ds;extensionName=Ds;prereadTypes=[te.MESH];prewriteTypes=[te.MESH];createClearcoat(){return new q2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_clearcoat){let a=this.createClearcoat();e.materials[s].setExtension(Ds,a);let o=r.extensions[Ds];if(o.extras)a.setExtras(o.extras);if(o.clearcoatFactor!==void 0)a.setClearcoatFactor(o.clearcoatFactor);if(o.clearcoatRoughnessFactor!==void 0)a.setClearcoatRoughnessFactor(o.clearcoatRoughnessFactor);if(o.clearcoatTexture!==void 0){let c=o.clearcoatTexture,l=e.textures[i[c.index].source];a.setClearcoatTexture(l),e.setTextureInfo(a.getClearcoatTextureInfo(),c)}if(o.clearcoatRoughnessTexture!==void 0){let c=o.clearcoatRoughnessTexture,l=e.textures[i[c.index].source];a.setClearcoatRoughnessTexture(l),e.setTextureInfo(a.getClearcoatRoughnessTextureInfo(),c)}if(o.clearcoatNormalTexture!==void 0){let c=o.clearcoatNormalTexture,l=e.textures[i[c.index].source];if(a.setClearcoatNormalTexture(l),e.setTextureInfo(a.getClearcoatNormalTextureInfo(),c),c.scale!==void 0)a.setClearcoatNormalScale(c.scale)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Ds);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Ds]=a,a.clearcoatFactor=i.getClearcoatFactor(),a.clearcoatRoughnessFactor=i.getClearcoatRoughnessFactor(),i.getClearcoatTexture()){let o=i.getClearcoatTexture(),c=i.getClearcoatTextureInfo();a.clearcoatTexture=e.createTextureInfoDef(o,c)}if(i.getClearcoatRoughnessTexture()){let o=i.getClearcoatRoughnessTexture(),c=i.getClearcoatRoughnessTextureInfo();a.clearcoatRoughnessTexture=e.createTextureInfoDef(o,c)}if(i.getClearcoatNormalTexture()){let o=i.getClearcoatNormalTexture(),c=i.getClearcoatNormalTextureInfo();if(a.clearcoatNormalTexture=e.createTextureInfoDef(o,c),i.getClearcoatNormalScale()!==1)a.clearcoatNormalTexture.scale=i.getClearcoatNormalScale()}}}),this}},{R:Z2,G:Y2,B:Q2,A:eU}=Ai,tU=class extends nt{static EXTENSION_NAME=Ls;init(){this.extensionName=Ls,this.propertyType="DiffuseTransmission",this.parentTypes=[te.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new wt(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new wt(this.graph,"diffuseTransmissionColorTextureInfo")})}getDiffuseTransmissionFactor(){return this.get("diffuseTransmissionFactor")}setDiffuseTransmissionFactor(e){return this.set("diffuseTransmissionFactor",e)}getDiffuseTransmissionTexture(){return this.getRef("diffuseTransmissionTexture")}getDiffuseTransmissionTextureInfo(){return this.getRef("diffuseTransmissionTexture")?this.getRef("diffuseTransmissionTextureInfo"):null}setDiffuseTransmissionTexture(e){return this.setRef("diffuseTransmissionTexture",e,{channels:eU})}getDiffuseTransmissionColorFactor(){return this.get("diffuseTransmissionColorFactor")}setDiffuseTransmissionColorFactor(e){return this.set("diffuseTransmissionColorFactor",e)}getDiffuseTransmissionColorTexture(){return this.getRef("diffuseTransmissionColorTexture")}getDiffuseTransmissionColorTextureInfo(){return this.getRef("diffuseTransmissionColorTexture")?this.getRef("diffuseTransmissionColorTextureInfo"):null}setDiffuseTransmissionColorTexture(e){return this.setRef("diffuseTransmissionColorTexture",e,{channels:Z2|Y2|Q2})}},nU=class extends _t{extensionName=Ls;static EXTENSION_NAME=Ls;createDiffuseTransmission(){return new tU(this.document.getGraph())}read(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_diffuse_transmission){let a=this.createDiffuseTransmission();e.materials[s].setExtension(Ls,a);let o=r.extensions[Ls];if(o.extras)a.setExtras(o.extras);if(o.diffuseTransmissionFactor!==void 0)a.setDiffuseTransmissionFactor(o.diffuseTransmissionFactor);if(o.diffuseTransmissionColorFactor!==void 0)a.setDiffuseTransmissionColorFactor(o.diffuseTransmissionColorFactor);if(o.diffuseTransmissionTexture!==void 0){let c=o.diffuseTransmissionTexture,l=e.textures[i[c.index].source];a.setDiffuseTransmissionTexture(l),e.setTextureInfo(a.getDiffuseTransmissionTextureInfo(),c)}if(o.diffuseTransmissionColorTexture!==void 0){let c=o.diffuseTransmissionColorTexture,l=e.textures[i[c.index].source];a.setDiffuseTransmissionColorTexture(l),e.setTextureInfo(a.getDiffuseTransmissionColorTextureInfo(),c)}}}),this}write(e){let t=e.jsonDoc;for(let n of this.document.getRoot().listMaterials()){let i=n.getExtension(Ls);if(!i)continue;let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Ls]=a,a.diffuseTransmissionFactor=i.getDiffuseTransmissionFactor(),a.diffuseTransmissionColorFactor=i.getDiffuseTransmissionColorFactor(),i.getDiffuseTransmissionTexture()){let o=i.getDiffuseTransmissionTexture(),c=i.getDiffuseTransmissionTextureInfo();a.diffuseTransmissionTexture=e.createTextureInfoDef(o,c)}if(i.getDiffuseTransmissionColorTexture()){let o=i.getDiffuseTransmissionColorTexture(),c=i.getDiffuseTransmissionColorTextureInfo();a.diffuseTransmissionColorTexture=e.createTextureInfoDef(o,c)}}return this}},iU=class extends nt{static EXTENSION_NAME=Fs;init(){this.extensionName=Fs,this.propertyType="Dispersion",this.parentTypes=[te.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(e){return this.set("dispersion",e)}},rU=class extends _t{static EXTENSION_NAME=Fs;extensionName=Fs;prereadTypes=[te.MESH];prewriteTypes=[te.MESH];createDispersion(){return new iU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_dispersion){let i=this.createDispersion();e.materials[n].setExtension(Fs,i);let r=t.extensions[Fs];if(r.extras)i.setExtras(r.extras);if(r.dispersion!==void 0)i.setDispersion(r.dispersion)}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Fs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);s.extensions=s.extensions||{},s.extensions[Fs]=a,a.dispersion=i.getDispersion()}}),this}},sU=class extends nt{static EXTENSION_NAME=Us;init(){this.extensionName=Us,this.propertyType="EmissiveStrength",this.parentTypes=[te.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(e){return this.set("emissiveStrength",e)}},aU=class extends _t{static EXTENSION_NAME=Us;extensionName=Us;prereadTypes=[te.MESH];prewriteTypes=[te.MESH];createEmissiveStrength(){return new sU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_emissive_strength){let i=this.createEmissiveStrength();e.materials[n].setExtension(Us,i);let r=t.extensions[Us];if(r.extras)i.setExtras(r.extras);if(r.emissiveStrength!==void 0)i.setEmissiveStrength(r.emissiveStrength)}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Us);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);s.extensions=s.extensions||{},s.extensions[Us]=a,a.emissiveStrength=i.getEmissiveStrength()}}),this}},oU=class extends nt{static EXTENSION_NAME=Bs;init(){this.extensionName=Bs,this.propertyType="IOR",this.parentTypes=[te.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(e){return this.set("ior",e)}},CS=class extends _t{static EXTENSION_NAME=Bs;extensionName=Bs;prereadTypes=[te.MESH];prewriteTypes=[te.MESH];createIOR(){return new oU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_ior){let i=this.createIOR();e.materials[n].setExtension(Bs,i);let r=t.extensions[Bs];if(r.extras)i.setExtras(r.extras);if(r.ior!==void 0)i.setIOR(r.ior)}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Bs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);s.extensions=s.extensions||{},s.extensions[Bs]=a,a.ior=i.getIOR()}}),this}},{R:cU,G:lU}=Ai,uU=class extends nt{static EXTENSION_NAME=zs;init(){this.extensionName=zs,this.propertyType="Iridescence",this.parentTypes=[te.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new wt(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new wt(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(e){return this.set("iridescenceFactor",e)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(e){return this.setRef("iridescenceTexture",e,{channels:cU})}getIridescenceIOR(){return this.get("iridescenceIOR")}setIridescenceIOR(e){return this.set("iridescenceIOR",e)}getIridescenceThicknessMinimum(){return this.get("iridescenceThicknessMinimum")}setIridescenceThicknessMinimum(e){return this.set("iridescenceThicknessMinimum",e)}getIridescenceThicknessMaximum(){return this.get("iridescenceThicknessMaximum")}setIridescenceThicknessMaximum(e){return this.set("iridescenceThicknessMaximum",e)}getIridescenceThicknessTexture(){return this.getRef("iridescenceThicknessTexture")}getIridescenceThicknessTextureInfo(){return this.getRef("iridescenceThicknessTexture")?this.getRef("iridescenceThicknessTextureInfo"):null}setIridescenceThicknessTexture(e){return this.setRef("iridescenceThicknessTexture",e,{channels:lU})}},dU=class extends _t{static EXTENSION_NAME=zs;extensionName=zs;prereadTypes=[te.MESH];prewriteTypes=[te.MESH];createIridescence(){return new uU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_iridescence){let a=this.createIridescence();e.materials[s].setExtension(zs,a);let o=r.extensions[zs];if(o.extras)a.setExtras(o.extras);if(o.iridescenceFactor!==void 0)a.setIridescenceFactor(o.iridescenceFactor);if(o.iridescenceIor!==void 0)a.setIridescenceIOR(o.iridescenceIor);if(o.iridescenceThicknessMinimum!==void 0)a.setIridescenceThicknessMinimum(o.iridescenceThicknessMinimum);if(o.iridescenceThicknessMaximum!==void 0)a.setIridescenceThicknessMaximum(o.iridescenceThicknessMaximum);if(o.iridescenceTexture!==void 0){let c=o.iridescenceTexture,l=e.textures[i[c.index].source];a.setIridescenceTexture(l),e.setTextureInfo(a.getIridescenceTextureInfo(),c)}if(o.iridescenceThicknessTexture!==void 0){let c=o.iridescenceThicknessTexture,l=e.textures[i[c.index].source];a.setIridescenceThicknessTexture(l),e.setTextureInfo(a.getIridescenceThicknessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(zs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[zs]=a,i.getIridescenceFactor()>0)a.iridescenceFactor=i.getIridescenceFactor();if(i.getIridescenceIOR()!==1.3)a.iridescenceIor=i.getIridescenceIOR();if(i.getIridescenceThicknessMinimum()!==100)a.iridescenceThicknessMinimum=i.getIridescenceThicknessMinimum();if(i.getIridescenceThicknessMaximum()!==400)a.iridescenceThicknessMaximum=i.getIridescenceThicknessMaximum();if(i.getIridescenceTexture()){let o=i.getIridescenceTexture(),c=i.getIridescenceTextureInfo();a.iridescenceTexture=e.createTextureInfoDef(o,c)}if(i.getIridescenceThicknessTexture()){let o=i.getIridescenceThicknessTexture(),c=i.getIridescenceThicknessTextureInfo();a.iridescenceThicknessTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:bS,G:xS,B:yS,A:_S}=Ai,fU=class extends nt{static EXTENSION_NAME=Vs;init(){this.extensionName=Vs,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[te.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new wt(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new wt(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(e){return this.set("diffuseFactor",e)}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(e){return this.setRef("diffuseTexture",e,{channels:bS|xS|yS|_S,isColor:!0})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getGlossinessFactor(){return this.get("glossinessFactor")}setGlossinessFactor(e){return this.set("glossinessFactor",e)}getSpecularGlossinessTexture(){return this.getRef("specularGlossinessTexture")}getSpecularGlossinessTextureInfo(){return this.getRef("specularGlossinessTexture")?this.getRef("specularGlossinessTextureInfo"):null}setSpecularGlossinessTexture(e){return this.setRef("specularGlossinessTexture",e,{channels:bS|xS|yS|_S})}},NS=class extends _t{static EXTENSION_NAME=Vs;extensionName=Vs;prereadTypes=[te.MESH];prewriteTypes=[te.MESH];createPBRSpecularGlossiness(){return new fU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_pbrSpecularGlossiness){let a=this.createPBRSpecularGlossiness();e.materials[s].setExtension(Vs,a);let o=r.extensions[Vs];if(o.extras)a.setExtras(o.extras);if(o.diffuseFactor!==void 0)a.setDiffuseFactor(o.diffuseFactor);if(o.specularFactor!==void 0)a.setSpecularFactor(o.specularFactor);if(o.glossinessFactor!==void 0)a.setGlossinessFactor(o.glossinessFactor);if(o.diffuseTexture!==void 0){let c=o.diffuseTexture,l=e.textures[i[c.index].source];a.setDiffuseTexture(l),e.setTextureInfo(a.getDiffuseTextureInfo(),c)}if(o.specularGlossinessTexture!==void 0){let c=o.specularGlossinessTexture,l=e.textures[i[c.index].source];a.setSpecularGlossinessTexture(l),e.setTextureInfo(a.getSpecularGlossinessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Vs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Vs]=a,a.diffuseFactor=i.getDiffuseFactor(),a.specularFactor=i.getSpecularFactor(),a.glossinessFactor=i.getGlossinessFactor(),i.getDiffuseTexture()){let o=i.getDiffuseTexture(),c=i.getDiffuseTextureInfo();a.diffuseTexture=e.createTextureInfoDef(o,c)}if(i.getSpecularGlossinessTexture()){let o=i.getSpecularGlossinessTexture(),c=i.getSpecularGlossinessTextureInfo();a.specularGlossinessTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:hU,G:pU,B:mU,A:gU}=Ai,bU=class extends nt{static EXTENSION_NAME=js;init(){this.extensionName=js,this.propertyType="Sheen",this.parentTypes=[te.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new wt(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new wt(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}setSheenColorFactor(e){return this.set("sheenColorFactor",e)}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(e){return this.setRef("sheenColorTexture",e,{channels:hU|pU|mU,isColor:!0})}getSheenRoughnessFactor(){return this.get("sheenRoughnessFactor")}setSheenRoughnessFactor(e){return this.set("sheenRoughnessFactor",e)}getSheenRoughnessTexture(){return this.getRef("sheenRoughnessTexture")}getSheenRoughnessTextureInfo(){return this.getRef("sheenRoughnessTexture")?this.getRef("sheenRoughnessTextureInfo"):null}setSheenRoughnessTexture(e){return this.setRef("sheenRoughnessTexture",e,{channels:gU})}},xU=class extends _t{static EXTENSION_NAME=js;extensionName=js;prereadTypes=[te.MESH];prewriteTypes=[te.MESH];createSheen(){return new bU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_sheen){let a=this.createSheen();e.materials[s].setExtension(js,a);let o=r.extensions[js];if(o.extras)a.setExtras(o.extras);if(o.sheenColorFactor!==void 0)a.setSheenColorFactor(o.sheenColorFactor);if(o.sheenRoughnessFactor!==void 0)a.setSheenRoughnessFactor(o.sheenRoughnessFactor);if(o.sheenColorTexture!==void 0){let c=o.sheenColorTexture,l=e.textures[i[c.index].source];a.setSheenColorTexture(l),e.setTextureInfo(a.getSheenColorTextureInfo(),c)}if(o.sheenRoughnessTexture!==void 0){let c=o.sheenRoughnessTexture,l=e.textures[i[c.index].source];a.setSheenRoughnessTexture(l),e.setTextureInfo(a.getSheenRoughnessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(js);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[js]=a,a.sheenColorFactor=i.getSheenColorFactor(),a.sheenRoughnessFactor=i.getSheenRoughnessFactor(),i.getSheenColorTexture()){let o=i.getSheenColorTexture(),c=i.getSheenColorTextureInfo();a.sheenColorTexture=e.createTextureInfoDef(o,c)}if(i.getSheenRoughnessTexture()){let o=i.getSheenRoughnessTexture(),c=i.getSheenRoughnessTextureInfo();a.sheenRoughnessTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:yU,G:_U,B:vU,A:EU}=Ai,TU=class extends nt{static EXTENSION_NAME=Hs;init(){this.extensionName=Hs,this.propertyType="Specular",this.parentTypes=[te.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new wt(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new wt(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(e){return this.set("specularColorFactor",e)}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(e){return this.setRef("specularTexture",e,{channels:EU})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(e){return this.setRef("specularColorTexture",e,{channels:yU|_U|vU,isColor:!0})}},PS=class extends _t{static EXTENSION_NAME=Hs;extensionName=Hs;prereadTypes=[te.MESH];prewriteTypes=[te.MESH];createSpecular(){return new TU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_specular){let a=this.createSpecular();e.materials[s].setExtension(Hs,a);let o=r.extensions[Hs];if(o.extras)a.setExtras(o.extras);if(o.specularFactor!==void 0)a.setSpecularFactor(o.specularFactor);if(o.specularColorFactor!==void 0)a.setSpecularColorFactor(o.specularColorFactor);if(o.specularTexture!==void 0){let c=o.specularTexture,l=e.textures[i[c.index].source];a.setSpecularTexture(l),e.setTextureInfo(a.getSpecularTextureInfo(),c)}if(o.specularColorTexture!==void 0){let c=o.specularColorTexture,l=e.textures[i[c.index].source];a.setSpecularColorTexture(l),e.setTextureInfo(a.getSpecularColorTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Hs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Hs]=a,i.getSpecularFactor()!==1)a.specularFactor=i.getSpecularFactor();if(!pt.eq(i.getSpecularColorFactor(),[1,1,1]))a.specularColorFactor=i.getSpecularColorFactor();if(i.getSpecularTexture()){let o=i.getSpecularTexture(),c=i.getSpecularTextureInfo();a.specularTexture=e.createTextureInfoDef(o,c)}if(i.getSpecularColorTexture()){let o=i.getSpecularColorTexture(),c=i.getSpecularColorTextureInfo();a.specularColorTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:AU}=Ai,wU=class extends nt{static EXTENSION_NAME=Gs;init(){this.extensionName=Gs,this.propertyType="Transmission",this.parentTypes=[te.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new wt(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(e){return this.set("transmissionFactor",e)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(e){return this.setRef("transmissionTexture",e,{channels:AU})}},SU=class extends _t{static EXTENSION_NAME=Gs;extensionName=Gs;prereadTypes=[te.MESH];prewriteTypes=[te.MESH];createTransmission(){return new wU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_transmission){let a=this.createTransmission();e.materials[s].setExtension(Gs,a);let o=r.extensions[Gs];if(o.extras)a.setExtras(o.extras);if(o.transmissionFactor!==void 0)a.setTransmissionFactor(o.transmissionFactor);if(o.transmissionTexture!==void 0){let c=o.transmissionTexture,l=e.textures[i[c.index].source];a.setTransmissionTexture(l),e.setTextureInfo(a.getTransmissionTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Gs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Gs]=a,a.transmissionFactor=i.getTransmissionFactor(),i.getTransmissionTexture()){let o=i.getTransmissionTexture(),c=i.getTransmissionTextureInfo();a.transmissionTexture=e.createTextureInfoDef(o,c)}}}),this}},MU=class extends nt{static EXTENSION_NAME=Jo;init(){this.extensionName=Jo,this.propertyType="Unlit",this.parentTypes=[te.MATERIAL]}},OS=class extends _t{static EXTENSION_NAME=Jo;extensionName=Jo;prereadTypes=[te.MESH];prewriteTypes=[te.MESH];createUnlit(){return new MU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_unlit)e.materials[n].setExtension(Jo,this.createUnlit())}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{if(n.getExtension("KHR_materials_unlit")){let i=e.materialIndexMap.get(n),r=t.json.materials[i];r.extensions=r.extensions||{},r.extensions[Jo]={}}}),this}},RU=class extends nt{static EXTENSION_NAME=fi;init(){this.extensionName=fi,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new It})}getMaterial(){return this.getRef("material")}setMaterial(e){return this.setRef("material",e)}addVariant(e){return this.addRef("variants",e)}removeVariant(e){return this.removeRef("variants",e)}listVariants(){return this.listRefs("variants")}},IU=class extends nt{static EXTENSION_NAME=fi;init(){this.extensionName=fi,this.propertyType="MappingList",this.parentTypes=[te.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new It})}addMapping(e){return this.addRef("mappings",e)}removeMapping(e){return this.removeRef("mappings",e)}listMappings(){return this.listRefs("mappings")}},vS=class extends nt{static EXTENSION_NAME=fi;init(){this.extensionName=fi,this.propertyType="Variant",this.parentTypes=["MappingList"]}},CU=class extends _t{extensionName=fi;static EXTENSION_NAME=fi;createMappingList(){return new IU(this.document.getGraph())}createVariant(e=""){return new vS(this.document.getGraph(),e)}createMapping(){return new RU(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((e)=>e instanceof vS)}read(e){let t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions.KHR_materials_variants)return this;let n=(t.json.extensions.KHR_materials_variants.variants||[]).map((i)=>this.createVariant().setName(i.name||""));return(t.json.meshes||[]).forEach((i,r)=>{let s=e.meshes[r];(i.primitives||[]).forEach((a,o)=>{if(!a.extensions||!a.extensions.KHR_materials_variants)return;let c=this.createMappingList(),l=a.extensions[fi];for(let u of l.mappings){let d=this.createMapping();if(u.material!==void 0)d.setMaterial(e.materials[u.material]);for(let f of u.variants||[])d.addVariant(n[f]);c.addMapping(d)}s.listPrimitives()[o].setExtension(fi,c)})}),this}write(e){let t=e.jsonDoc,n=this.listVariants();if(!n.length)return this;let i=[],r=new Map;for(let s of n)r.set(s,i.length),i.push(e.createPropertyDef(s));for(let s of this.document.getRoot().listMeshes()){let a=e.meshIndexMap.get(s);s.listPrimitives().forEach((o,c)=>{let l=o.getExtension(fi);if(!l)return;let u=e.jsonDoc.json.meshes[a].primitives[c],d=l.listMappings().map((f)=>{let h=e.createPropertyDef(f),b=f.getMaterial();if(b)h.material=e.materialIndexMap.get(b);return h.variants=f.listVariants().map((m)=>r.get(m)),h});u.extensions=u.extensions||{},u.extensions[fi]={mappings:d}})}return t.json.extensions=t.json.extensions||{},t.json.extensions[fi]={variants:i},this}},{G:NU}=Ai,PU=class extends nt{static EXTENSION_NAME=$s;init(){this.extensionName=$s,this.propertyType="Volume",this.parentTypes=[te.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new wt(this.graph,"thicknessTexture"),attenuationDistance:1/0,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(e){return this.set("thicknessFactor",e)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(e){return this.setRef("thicknessTexture",e,{channels:NU})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(e){return this.set("attenuationDistance",e)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(e){return this.set("attenuationColor",e)}},OU=class extends _t{static EXTENSION_NAME=$s;extensionName=$s;prereadTypes=[te.MESH];prewriteTypes=[te.MESH];createVolume(){return new PU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_volume){let a=this.createVolume();e.materials[s].setExtension($s,a);let o=r.extensions[$s];if(o.extras)a.setExtras(o.extras);if(o.thicknessFactor!==void 0)a.setThicknessFactor(o.thicknessFactor);if(o.attenuationDistance!==void 0)a.setAttenuationDistance(o.attenuationDistance);if(o.attenuationColor!==void 0)a.setAttenuationColor(o.attenuationColor);if(o.thicknessTexture!==void 0){let c=o.thicknessTexture,l=e.textures[i[c.index].source];a.setThicknessTexture(l),e.setTextureInfo(a.getThicknessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension($s);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[$s]=a,i.getThicknessFactor()>0)a.thicknessFactor=i.getThicknessFactor();if(Number.isFinite(i.getAttenuationDistance()))a.attenuationDistance=i.getAttenuationDistance();if(!pt.eq(i.getAttenuationColor(),[1,1,1]))a.attenuationColor=i.getAttenuationColor();if(i.getThicknessTexture()){let o=i.getThicknessTexture(),c=i.getThicknessTextureInfo();a.thicknessTexture=e.createTextureInfoDef(o,c)}}}),this}},kS=class extends _t{extensionName=rS;static EXTENSION_NAME=rS;read(e){return this}write(e){return this}},Hg=class extends _t{extensionName=sS;static EXTENSION_NAME=sS;read(e){return this}write(e){return this}},kU=class extends nt{static EXTENSION_NAME=Ks;init(){this.extensionName=Ks,this.propertyType="Visibility",this.parentTypes=[te.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{visible:!0})}getVisible(){return this.get("visible")}setVisible(e){return this.set("visible",e)}},DU=class extends _t{static EXTENSION_NAME=Ks;extensionName=Ks;createVisibility(){return new kU(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_node_visibility){let i=this.createVisibility();e.nodes[n].setExtension(Ks,i);let r=t.extensions[Ks];if(r.visible!==void 0)i.setVisible(r.visible)}}),this}write(e){let t=e.jsonDoc;for(let n of this.document.getRoot().listNodes()){let i=n.getExtension(Ks);if(!i)continue;let r=e.nodeIndexMap.get(n),s=t.json.nodes[r];s.extensions=s.extensions||{},s.extensions[Ks]={visible:i.getVisible()}}return this}};Gg=class extends _t{static EXTENSION_NAME=cf;extensionName=cf;prereadTypes=[te.TEXTURE];static register(){Gi.registerFormat("image/ktx2",new FU)}preread(e){if(e.jsonDoc.json.textures)e.jsonDoc.json.textures.forEach((t)=>{if(t.extensions&&t.extensions.KHR_texture_basisu)t.source=t.extensions[cf].source});return this}read(e){return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listTextures().forEach((n)=>{if(n.getMimeType()==="image/ktx2"){let i=e.imageIndexMap.get(n);t.json.textures.forEach((r)=>{if(r.source===i)r.extensions=r.extensions||{},r.extensions[cf]={source:r.source},delete r.source})}}),this}},UU=class extends nt{static EXTENSION_NAME=Ws;init(){this.extensionName=Ws,this.propertyType="Transform",this.parentTypes=[te.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getRotation(){return this.get("rotation")}setRotation(e){return this.set("rotation",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getTexCoord(){return this.get("texCoord")}setTexCoord(e){return this.set("texCoord",e)}},BU=class extends _t{extensionName=Ws;static EXTENSION_NAME=Ws;createTransform(){return new UU(this.document.getGraph())}read(e){for(let[t,n]of Array.from(e.textureInfos.entries())){if(!n.extensions||!n.extensions.KHR_texture_transform)continue;let i=this.createTransform(),r=n.extensions[Ws];if(r.offset!==void 0)i.setOffset(r.offset);if(r.rotation!==void 0)i.setRotation(r.rotation);if(r.scale!==void 0)i.setScale(r.scale);if(r.texCoord!==void 0)i.setTexCoord(r.texCoord);t.setExtension(Ws,i)}return this}write(e){let t=Array.from(e.textureInfoDefMap.entries());for(let[n,i]of t){let r=n.getExtension(Ws);if(!r)continue;i.extensions=i.extensions||{};let s={},a=pt.eq;if(!a(r.getOffset(),[0,0]))s.offset=r.getOffset();if(r.getRotation()!==0)s.rotation=r.getRotation();if(!a(r.getScale(),[1,1]))s.scale=r.getScale();if(r.getTexCoord()!=null)s.texCoord=r.getTexCoord();i.extensions[Ws]=s}return this}},zU=[te.ROOT,te.SCENE,te.NODE,te.MESH,te.MATERIAL,te.TEXTURE,te.ANIMATION],VU=class extends nt{static EXTENSION_NAME=$i;init(){this.extensionName=$i,this.propertyType="Packet",this.parentTypes=zU}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(e){return this.set("context",{...e})}listProperties(){return Object.keys(this.get("properties"))}getProperty(e){let t=this.get("properties");return e in t?t[e]:null}setProperty(e,t){this._assertContext(e);let n={...this.get("properties")};if(t)n[e]=t;else delete n[e];return this.set("properties",n)}toJSONLD(){return{"@context":Bg(this.get("context")),...Bg(this.get("properties"))}}fromJSONLD(e){e=Bg(e);let t=e["@context"];if(t)this.set("context",t);return delete e["@context"],this.set("properties",e)}_assertContext(e){if(!(e.split(":")[0]in this.get("context")))throw Error(`${$i}: Missing context for term, "${e}".`)}};jU=class extends _t{extensionName=$i;static EXTENSION_NAME=$i;createPacket(){return new VU(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(e){let t=e.jsonDoc.json.extensions?.[$i];if(!t||!t.packets)return this;let n=e.jsonDoc.json,i=this.document.getRoot(),r=t.packets.map((o)=>this.createPacket().fromJSONLD(o)),s=[[n.asset],n.scenes,n.nodes,n.meshes,n.materials,n.images,n.animations],a=[[i],i.listScenes(),i.listNodes(),i.listMeshes(),i.listMaterials(),i.listTextures(),i.listAnimations()];for(let o=0;o<s.length;o++){let c=s[o]||[];for(let l=0;l<c.length;l++){let u=c[l];if(u.extensions&&u.extensions.KHR_xmp_json_ld){let d=u.extensions[$i];a[o][l].setExtension($i,r[d.packet])}}}return this}write(e){let{json:t}=e.jsonDoc,n=[];for(let i of this.properties){n.push(i.toJSONLD());for(let r of i.listParents()){let s;switch(r.propertyType){case te.ROOT:s=t.asset;break;case te.SCENE:s=t.scenes[e.sceneIndexMap.get(r)];break;case te.NODE:s=t.nodes[e.nodeIndexMap.get(r)];break;case te.MESH:s=t.meshes[e.meshIndexMap.get(r)];break;case te.MATERIAL:s=t.materials[e.materialIndexMap.get(r)];break;case te.TEXTURE:s=t.images[e.imageIndexMap.get(r)];break;case te.ANIMATION:s=t.animations[e.animationIndexMap.get(r)];break;default:s=null,this.document.getLogger().warn(`[${$i}]: Unsupported parent property, "${r.propertyType}"`)}if(!s)continue;s.extensions=s.extensions||{},s.extensions[$i]={packet:n.length-1}}}if(n.length>0)t.extensions=t.extensions||{},t.extensions[$i]={packets:n};return this}},HU=[C2,N2,IS,j2,W2,J2,nU,rU,aU,CS,dU,NS,PS,xU,SU,OS,CU,OU,kS,Hg,DU,Gg,BU,jU],DS=[lf,MF,Ml,n2,AS,wS,...HU]});var FS=Jr(function(z5,LS){function GU(e){var t=Array(e);for(var n=0;n<e;++n)t[n]=n;return t}LS.exports=GU});var zS=Jr(function(V5,BS){/*!* Determine if an object is a Buffer** @author Feross Aboukhadijeh <https://feross.org>* @license MIT- */bw.exports=function(e){return e!=null&&(gw(e)||aU(e)||!!e._isBuffer)};function gw(e){return!!e.constructor&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}function aU(e){return typeof e.readFloatLE==="function"&&typeof e.slice==="function"&&gw(e.slice(0,0))}});var Rg=Xr(function(G$,xw){var oU=mw(),cU=yw(),lU=typeof Float64Array<"u";function uU(e,t){return e[0]-t[0]}function dU(){var e=this.stride,t=Array(e.length),n;for(n=0;n<t.length;++n)t[n]=[Math.abs(e[n]),n];t.sort(uU);var i=Array(t.length);for(n=0;n<i.length;++n)i[n]=t[n][1];return i}function fU(e,t){var n=["View",t,"d",e].join("");if(t<0)n="View_Nil"+e;var i=e==="generic";if(t===-1){var r="function "+n+"(a){this.data=a;};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+n+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+n+"(a){return new "+n+"(a);}",g=Function(r);return g()}else if(t===0){var r="function "+n+"(a,d) {this.data = a;this.offset = d};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+n+"_copy() {return new "+n+"(this.data,this.offset)};proto.pick=function "+n+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+n+"_get(){return "+(i?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+n+"_set(v){return "+(i?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+n+"(a,b,c,d){return new "+n+"(a,d)}",g=Function("TrivialArray",r);return g(Wd[e][0])}var r=["'use strict'"],s=oU(t),a=s.map(function(m){return"i"+m}),o="this.offset+"+s.map(function(m){return"this.stride["+m+"]*i"+m}).join("+"),c=s.map(function(m){return"b"+m}).join(","),l=s.map(function(m){return"c"+m}).join(",");if(r.push("function "+n+"(a,"+c+","+l+",d){this.data=a","this.shape=["+c+"]","this.stride=["+l+"]","this.offset=d|0}","var proto="+n+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),r.push("Object.defineProperty(proto,'size',{get:function "+n+"_size(){return "+s.map(function(m){return"this.shape["+m+"]"}).join("*"),"}})"),t===1)r.push("proto.order=[0]");else if(r.push("Object.defineProperty(proto,'order',{get:"),t<4){if(r.push("function "+n+"_order(){"),t===2)r.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})");else if(t===3)r.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")}else r.push("ORDER})");if(r.push("proto.set=function "+n+"_set("+a.join(",")+",v){"),i)r.push("return this.data.set("+o+",v)}");else r.push("return this.data["+o+"]=v}");if(r.push("proto.get=function "+n+"_get("+a.join(",")+"){"),i)r.push("return this.data.get("+o+")}");else r.push("return this.data["+o+"]}");r.push("proto.index=function "+n+"_index(",a.join(),"){return "+o+"}"),r.push("proto.hi=function "+n+"_hi("+a.join(",")+"){return new "+n+"(this.data,"+s.map(function(m){return["(typeof i",m,"!=='number'||i",m,"<0)?this.shape[",m,"]:i",m,"|0"].join("")}).join(",")+","+s.map(function(m){return"this.stride["+m+"]"}).join(",")+",this.offset)}");var u=s.map(function(m){return"a"+m+"=this.shape["+m+"]"}),d=s.map(function(m){return"c"+m+"=this.stride["+m+"]"});r.push("proto.lo=function "+n+"_lo("+a.join(",")+"){var b=this.offset,d=0,"+u.join(",")+","+d.join(","));for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'&&i"+f+">=0){d=i"+f+"|0;b+=c"+f+"*d;a"+f+"-=d}");r.push("return new "+n+"(this.data,"+s.map(function(m){return"a"+m}).join(",")+","+s.map(function(m){return"c"+m}).join(",")+",b)}"),r.push("proto.step=function "+n+"_step("+a.join(",")+"){var "+s.map(function(m){return"a"+m+"=this.shape["+m+"]"}).join(",")+","+s.map(function(m){return"b"+m+"=this.stride["+m+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'){d=i"+f+"|0;if(d<0){c+=b"+f+"*(a"+f+"-1);a"+f+"=ceil(-a"+f+"/d)}else{a"+f+"=ceil(a"+f+"/d)}b"+f+"*=d}");r.push("return new "+n+"(this.data,"+s.map(function(m){return"a"+m}).join(",")+","+s.map(function(m){return"b"+m}).join(",")+",c)}");var h=Array(t),y=Array(t);for(var f=0;f<t;++f)h[f]="a[i"+f+"]",y[f]="b[i"+f+"]";r.push("proto.transpose=function "+n+"_transpose("+a+"){"+a.map(function(m,p){return m+"=("+m+"===undefined?"+p+":"+m+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+n+"(this.data,"+h.join(",")+","+y.join(",")+",this.offset)}"),r.push("proto.pick=function "+n+"_pick("+a+"){var a=[],b=[],c=this.offset");for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'&&i"+f+">=0){c=(c+this.stride["+f+"]*i"+f+")|0}else{a.push(this.shape["+f+"]);b.push(this.stride["+f+"])}");r.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),r.push("return function construct_"+n+"(data,shape,stride,offset){return new "+n+"(data,"+s.map(function(m){return"shape["+m+"]"}).join(",")+","+s.map(function(m){return"stride["+m+"]"}).join(",")+",offset)}");var g=Function("CTOR_LIST","ORDER",r.join(`-`));return g(Wd[e],dU)}function hU(e){if(cU(e))return"buffer";if(lU)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}if(Array.isArray(e))return"array";return"generic"}var Wd={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function pU(e,t,n,i){if(e===void 0){var l=Wd.array[0];return l([])}else if(typeof e==="number")e=[e];if(t===void 0)t=[e.length];var r=t.length;if(n===void 0){n=Array(r);for(var s=r-1,a=1;s>=0;--s)n[s]=a,a*=t[s]}if(i===void 0){i=0;for(var s=0;s<r;++s)if(n[s]<0)i-=(t[s]-1)*n[s]}var o=hU(e),c=Wd[o];while(c.length<=r+1)c.push(fU(o,c.length-1));var l=c[r+1];return l(e,t,n,i)}xw.exports=pU});var vw=Xr(function($$,_w){function mU(e,t){var n=1,i=e.length,r=e[0],s=e[0];for(var a=1;a<i;++a)if(s=r,r=e[a],t(r,s)){if(a===n){n++;continue}e[n++]=r}return e.length=n,e}function gU(e){var t=1,n=e.length,i=e[0],r=e[0];for(var s=1;s<n;++s,r=i)if(r=i,i=e[s],i!==r){if(s===t){t++;continue}e[t++]=i}return e.length=t,e}function bU(e,t,n){if(e.length===0)return e;if(t){if(!n)e.sort(t);return mU(e,t)}if(!n)e.sort();return gU(e)}_w.exports=bU});var Aw=Xr(function(K$,Tw){var yU=vw();function Ew(e,t,n){var i=e.length,r=t.arrayArgs.length,s=t.indexArgs.length>0,a=[],o=[],c=0,l=0,u,d;for(u=0;u<i;++u)o.push(["i",u,"=0"].join(""));for(d=0;d<r;++d)for(u=0;u<i;++u)if(l=c,c=e[u],u===0)o.push(["d",d,"s",u,"=t",d,"p",c].join(""));else o.push(["d",d,"s",u,"=(t",d,"p",c,"-s",l,"*t",d,"p",l,")"].join(""));if(o.length>0)a.push("var "+o.join(","));for(u=i-1;u>=0;--u)c=e[u],a.push(["for(i",u,"=0;i",u,"<s",c,";++i",u,"){"].join(""));a.push(n);for(u=0;u<i;++u){l=c,c=e[u];for(d=0;d<r;++d)a.push(["p",d,"+=d",d,"s",u].join(""));if(s){if(u>0)a.push(["index[",l,"]-=s",l].join(""));a.push(["++index[",c,"]"].join(""))}a.push("}")}return a.join(`-`)}function xU(e,t,n,i){var r=t.length,s=n.arrayArgs.length,a=n.blockSize,o=n.indexArgs.length>0,c=[];for(var l=0;l<s;++l)c.push(["var offset",l,"=p",l].join(""));for(var l=e;l<r;++l)if(c.push(["for(var j"+l+"=SS[",t[l],"]|0;j",l,">0;){"].join("")),c.push(["if(j",l,"<",a,"){"].join("")),c.push(["s",t[l],"=j",l].join("")),c.push(["j",l,"=0"].join("")),c.push(["}else{s",t[l],"=",a].join("")),c.push(["j",l,"-=",a,"}"].join("")),o)c.push(["index[",t[l],"]=j",l].join(""));for(var l=0;l<s;++l){var u=["offset"+l];for(var d=e;d<r;++d)u.push(["j",d,"*t",l,"p",t[d]].join(""));c.push(["p",l,"=(",u.join("+"),")"].join(""))}c.push(Ew(t,n,i));for(var l=e;l<r;++l)c.push("}");return c.join(`-`)}function _U(e){var t=0,n=e[0].length;while(t<n){for(var i=1;i<e.length;++i)if(e[i][t]!==e[0][t])return t;++t}return t}function Ig(e,t,n){var i=e.body,r=[],s=[];for(var a=0;a<e.args.length;++a){var o=e.args[a];if(o.count<=0)continue;var c=new RegExp(o.name,"g"),l="",u=t.arrayArgs.indexOf(a);switch(t.argTypes[a]){case"offset":var d=t.offsetArgIndex.indexOf(a),f=t.offsetArgs[d];u=f.array,l="+q"+d;case"array":l="p"+u+l;var h="l"+a,y="a"+u;if(t.arrayBlockIndices[u]===0){if(o.count===1)if(n[u]==="generic")if(o.lvalue)r.push(["var ",h,"=",y,".get(",l,")"].join("")),i=i.replace(c,h),s.push([y,".set(",l,",",h,")"].join(""));else i=i.replace(c,[y,".get(",l,")"].join(""));else i=i.replace(c,[y,"[",l,"]"].join(""));else if(n[u]==="generic"){if(r.push(["var ",h,"=",y,".get(",l,")"].join("")),i=i.replace(c,h),o.lvalue)s.push([y,".set(",l,",",h,")"].join(""))}else if(r.push(["var ",h,"=",y,"[",l,"]"].join("")),i=i.replace(c,h),o.lvalue)s.push([y,"[",l,"]=",h].join(""))}else{var g=[o.name],m=[l];for(var p=0;p<Math.abs(t.arrayBlockIndices[u]);p++)g.push("\\s*\\[([^\\]]+)\\]"),m.push("$"+(p+1)+"*t"+u+"b"+p);if(c=new RegExp(g.join(""),"g"),l=m.join("+"),n[u]==="generic")throw Error("cwise: Generic arrays not supported in combination with blocks!");else i=i.replace(c,[y,"[",l,"]"].join(""))}break;case"scalar":i=i.replace(c,"Y"+t.scalarArgs.indexOf(a));break;case"index":i=i.replace(c,"index");break;case"shape":i=i.replace(c,"shape");break}}return[r.join(`+ */BS.exports=function(e){return e!=null&&(US(e)||$U(e)||!!e._isBuffer)};function US(e){return!!e.constructor&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}function $U(e){return typeof e.readFloatLE==="function"&&typeof e.slice==="function"&&US(e.slice(0,0))}});var $g=Jr(function(j5,VS){var KU=FS(),WU=zS(),XU=typeof Float64Array<"u";function qU(e,t){return e[0]-t[0]}function JU(){var e=this.stride,t=Array(e.length),n;for(n=0;n<t.length;++n)t[n]=[Math.abs(e[n]),n];t.sort(qU);var i=Array(t.length);for(n=0;n<i.length;++n)i[n]=t[n][1];return i}function ZU(e,t){var n=["View",t,"d",e].join("");if(t<0)n="View_Nil"+e;var i=e==="generic";if(t===-1){var r="function "+n+"(a){this.data=a;};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+n+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+n+"(a){return new "+n+"(a);}",m=Function(r);return m()}else if(t===0){var r="function "+n+"(a,d) {this.data = a;this.offset = d};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+n+"_copy() {return new "+n+"(this.data,this.offset)};proto.pick=function "+n+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+n+"_get(){return "+(i?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+n+"_set(v){return "+(i?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+n+"(a,b,c,d){return new "+n+"(a,d)}",m=Function("TrivialArray",r);return m(df[e][0])}var r=["'use strict'"],s=KU(t),a=s.map(function(g){return"i"+g}),o="this.offset+"+s.map(function(g){return"this.stride["+g+"]*i"+g}).join("+"),c=s.map(function(g){return"b"+g}).join(","),l=s.map(function(g){return"c"+g}).join(",");if(r.push("function "+n+"(a,"+c+","+l+",d){this.data=a","this.shape=["+c+"]","this.stride=["+l+"]","this.offset=d|0}","var proto="+n+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),r.push("Object.defineProperty(proto,'size',{get:function "+n+"_size(){return "+s.map(function(g){return"this.shape["+g+"]"}).join("*"),"}})"),t===1)r.push("proto.order=[0]");else if(r.push("Object.defineProperty(proto,'order',{get:"),t<4){if(r.push("function "+n+"_order(){"),t===2)r.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})");else if(t===3)r.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")}else r.push("ORDER})");if(r.push("proto.set=function "+n+"_set("+a.join(",")+",v){"),i)r.push("return this.data.set("+o+",v)}");else r.push("return this.data["+o+"]=v}");if(r.push("proto.get=function "+n+"_get("+a.join(",")+"){"),i)r.push("return this.data.get("+o+")}");else r.push("return this.data["+o+"]}");r.push("proto.index=function "+n+"_index(",a.join(),"){return "+o+"}"),r.push("proto.hi=function "+n+"_hi("+a.join(",")+"){return new "+n+"(this.data,"+s.map(function(g){return["(typeof i",g,"!=='number'||i",g,"<0)?this.shape[",g,"]:i",g,"|0"].join("")}).join(",")+","+s.map(function(g){return"this.stride["+g+"]"}).join(",")+",this.offset)}");var u=s.map(function(g){return"a"+g+"=this.shape["+g+"]"}),d=s.map(function(g){return"c"+g+"=this.stride["+g+"]"});r.push("proto.lo=function "+n+"_lo("+a.join(",")+"){var b=this.offset,d=0,"+u.join(",")+","+d.join(","));for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'&&i"+f+">=0){d=i"+f+"|0;b+=c"+f+"*d;a"+f+"-=d}");r.push("return new "+n+"(this.data,"+s.map(function(g){return"a"+g}).join(",")+","+s.map(function(g){return"c"+g}).join(",")+",b)}"),r.push("proto.step=function "+n+"_step("+a.join(",")+"){var "+s.map(function(g){return"a"+g+"=this.shape["+g+"]"}).join(",")+","+s.map(function(g){return"b"+g+"=this.stride["+g+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'){d=i"+f+"|0;if(d<0){c+=b"+f+"*(a"+f+"-1);a"+f+"=ceil(-a"+f+"/d)}else{a"+f+"=ceil(a"+f+"/d)}b"+f+"*=d}");r.push("return new "+n+"(this.data,"+s.map(function(g){return"a"+g}).join(",")+","+s.map(function(g){return"b"+g}).join(",")+",c)}");var h=Array(t),b=Array(t);for(var f=0;f<t;++f)h[f]="a[i"+f+"]",b[f]="b[i"+f+"]";r.push("proto.transpose=function "+n+"_transpose("+a+"){"+a.map(function(g,p){return g+"=("+g+"===undefined?"+p+":"+g+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+n+"(this.data,"+h.join(",")+","+b.join(",")+",this.offset)}"),r.push("proto.pick=function "+n+"_pick("+a+"){var a=[],b=[],c=this.offset");for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'&&i"+f+">=0){c=(c+this.stride["+f+"]*i"+f+")|0}else{a.push(this.shape["+f+"]);b.push(this.stride["+f+"])}");r.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),r.push("return function construct_"+n+"(data,shape,stride,offset){return new "+n+"(data,"+s.map(function(g){return"shape["+g+"]"}).join(",")+","+s.map(function(g){return"stride["+g+"]"}).join(",")+",offset)}");var m=Function("CTOR_LIST","ORDER",r.join(`+`));return m(df[e],JU)}function YU(e){if(WU(e))return"buffer";if(XU)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}if(Array.isArray(e))return"array";return"generic"}var df={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function QU(e,t,n,i){if(e===void 0){var l=df.array[0];return l([])}else if(typeof e==="number")e=[e];if(t===void 0)t=[e.length];var r=t.length;if(n===void 0){n=Array(r);for(var s=r-1,a=1;s>=0;--s)n[s]=a,a*=t[s]}if(i===void 0){i=0;for(var s=0;s<r;++s)if(n[s]<0)i-=(t[s]-1)*n[s]}var o=YU(e),c=df[o];while(c.length<=r+1)c.push(ZU(o,c.length-1));var l=c[r+1];return l(e,t,n,i)}VS.exports=QU});var HS=Jr(function(H5,jS){function e3(e,t){var n=1,i=e.length,r=e[0],s=e[0];for(var a=1;a<i;++a)if(s=r,r=e[a],t(r,s)){if(a===n){n++;continue}e[n++]=r}return e.length=n,e}function t3(e){var t=1,n=e.length,i=e[0],r=e[0];for(var s=1;s<n;++s,r=i)if(r=i,i=e[s],i!==r){if(s===t){t++;continue}e[t++]=i}return e.length=t,e}function n3(e,t,n){if(e.length===0)return e;if(t){if(!n)e.sort(t);return e3(e,t)}if(!n)e.sort();return t3(e)}jS.exports=n3});var KS=Jr(function(G5,$S){var i3=HS();function GS(e,t,n){var i=e.length,r=t.arrayArgs.length,s=t.indexArgs.length>0,a=[],o=[],c=0,l=0,u,d;for(u=0;u<i;++u)o.push(["i",u,"=0"].join(""));for(d=0;d<r;++d)for(u=0;u<i;++u)if(l=c,c=e[u],u===0)o.push(["d",d,"s",u,"=t",d,"p",c].join(""));else o.push(["d",d,"s",u,"=(t",d,"p",c,"-s",l,"*t",d,"p",l,")"].join(""));if(o.length>0)a.push("var "+o.join(","));for(u=i-1;u>=0;--u)c=e[u],a.push(["for(i",u,"=0;i",u,"<s",c,";++i",u,"){"].join(""));a.push(n);for(u=0;u<i;++u){l=c,c=e[u];for(d=0;d<r;++d)a.push(["p",d,"+=d",d,"s",u].join(""));if(s){if(u>0)a.push(["index[",l,"]-=s",l].join(""));a.push(["++index[",c,"]"].join(""))}a.push("}")}return a.join(`+`)}function r3(e,t,n,i){var r=t.length,s=n.arrayArgs.length,a=n.blockSize,o=n.indexArgs.length>0,c=[];for(var l=0;l<s;++l)c.push(["var offset",l,"=p",l].join(""));for(var l=e;l<r;++l)if(c.push(["for(var j"+l+"=SS[",t[l],"]|0;j",l,">0;){"].join("")),c.push(["if(j",l,"<",a,"){"].join("")),c.push(["s",t[l],"=j",l].join("")),c.push(["j",l,"=0"].join("")),c.push(["}else{s",t[l],"=",a].join("")),c.push(["j",l,"-=",a,"}"].join("")),o)c.push(["index[",t[l],"]=j",l].join(""));for(var l=0;l<s;++l){var u=["offset"+l];for(var d=e;d<r;++d)u.push(["j",d,"*t",l,"p",t[d]].join(""));c.push(["p",l,"=(",u.join("+"),")"].join(""))}c.push(GS(t,n,i));for(var l=e;l<r;++l)c.push("}");return c.join(`+`)}function s3(e){var t=0,n=e[0].length;while(t<n){for(var i=1;i<e.length;++i)if(e[i][t]!==e[0][t])return t;++t}return t}function Kg(e,t,n){var i=e.body,r=[],s=[];for(var a=0;a<e.args.length;++a){var o=e.args[a];if(o.count<=0)continue;var c=new RegExp(o.name,"g"),l="",u=t.arrayArgs.indexOf(a);switch(t.argTypes[a]){case"offset":var d=t.offsetArgIndex.indexOf(a),f=t.offsetArgs[d];u=f.array,l="+q"+d;case"array":l="p"+u+l;var h="l"+a,b="a"+u;if(t.arrayBlockIndices[u]===0){if(o.count===1)if(n[u]==="generic")if(o.lvalue)r.push(["var ",h,"=",b,".get(",l,")"].join("")),i=i.replace(c,h),s.push([b,".set(",l,",",h,")"].join(""));else i=i.replace(c,[b,".get(",l,")"].join(""));else i=i.replace(c,[b,"[",l,"]"].join(""));else if(n[u]==="generic"){if(r.push(["var ",h,"=",b,".get(",l,")"].join("")),i=i.replace(c,h),o.lvalue)s.push([b,".set(",l,",",h,")"].join(""))}else if(r.push(["var ",h,"=",b,"[",l,"]"].join("")),i=i.replace(c,h),o.lvalue)s.push([b,"[",l,"]=",h].join(""))}else{var m=[o.name],g=[l];for(var p=0;p<Math.abs(t.arrayBlockIndices[u]);p++)m.push("\\s*\\[([^\\]]+)\\]"),g.push("$"+(p+1)+"*t"+u+"b"+p);if(c=new RegExp(m.join(""),"g"),l=g.join("+"),n[u]==="generic")throw Error("cwise: Generic arrays not supported in combination with blocks!");else i=i.replace(c,[b,"[",l,"]"].join(""))}break;case"scalar":i=i.replace(c,"Y"+t.scalarArgs.indexOf(a));break;case"index":i=i.replace(c,"index");break;case"shape":i=i.replace(c,"shape");break}}return[r.join(``),i,s.join(``)].join(`-`).trim()}function vU(e){var t=Array(e.length),n=!0;for(var i=0;i<e.length;++i){var r=e[i],s=r.match(/\d+/);if(!s)s="";else s=s[0];if(r.charAt(0)===0)t[i]="u"+r.charAt(1)+s;else t[i]=r.charAt(0)+s;if(i>0)n=n&&t[i]===t[i-1]}if(n)return t[0];return t.join("")}function EU(e,t){var n=t[1].length-Math.abs(e.arrayBlockIndices[0])|0,i=Array(e.arrayArgs.length),r=Array(e.arrayArgs.length);for(var s=0;s<e.arrayArgs.length;++s)r[s]=t[2*s],i[s]=t[2*s+1];var a=[],o=[],c=[],l=[],u=[];for(var s=0;s<e.arrayArgs.length;++s){if(e.arrayBlockIndices[s]<0)c.push(0),l.push(n),a.push(n),o.push(n+e.arrayBlockIndices[s]);else c.push(e.arrayBlockIndices[s]),l.push(e.arrayBlockIndices[s]+n),a.push(0),o.push(e.arrayBlockIndices[s]);var d=[];for(var f=0;f<i[s].length;f++)if(c[s]<=i[s][f]&&i[s][f]<l[s])d.push(i[s][f]-c[s]);u.push(d)}var h=["SS"],y=["'use strict'"],g=[];for(var f=0;f<n;++f)g.push(["s",f,"=SS[",f,"]"].join(""));for(var s=0;s<e.arrayArgs.length;++s){h.push("a"+s),h.push("t"+s),h.push("p"+s);for(var f=0;f<n;++f)g.push(["t",s,"p",f,"=t",s,"[",c[s]+f,"]"].join(""));for(var f=0;f<Math.abs(e.arrayBlockIndices[s]);++f)g.push(["t",s,"b",f,"=t",s,"[",a[s]+f,"]"].join(""))}for(var s=0;s<e.scalarArgs.length;++s)h.push("Y"+s);if(e.shapeArgs.length>0)g.push("shape=SS.slice(0)");if(e.indexArgs.length>0){var m=Array(n);for(var s=0;s<n;++s)m[s]="0";g.push(["index=[",m.join(","),"]"].join(""))}for(var s=0;s<e.offsetArgs.length;++s){var p=e.offsetArgs[s],b=[];for(var f=0;f<p.offset.length;++f)if(p.offset[f]===0)continue;else if(p.offset[f]===1)b.push(["t",p.array,"p",f].join(""));else b.push([p.offset[f],"*t",p.array,"p",f].join(""));if(b.length===0)g.push("q"+s+"=0");else g.push(["q",s,"=",b.join("+")].join(""))}var _=yU([].concat(e.pre.thisVars).concat(e.body.thisVars).concat(e.post.thisVars));if(g=g.concat(_),g.length>0)y.push("var "+g.join(","));for(var s=0;s<e.arrayArgs.length;++s)y.push("p"+s+"|=0");if(e.pre.body.length>3)y.push(Ig(e.pre,e,r));var x=Ig(e.body,e,r),v=_U(u);if(v<n)y.push(xU(v,u[0],e,x));else y.push(Ew(u[0],e,x));if(e.post.body.length>3)y.push(Ig(e.post,e,r));if(e.debug)console.log("-----Generated cwise routine for ",t,`:-`+y.join(`+`).trim()}function a3(e){var t=Array(e.length),n=!0;for(var i=0;i<e.length;++i){var r=e[i],s=r.match(/\d+/);if(!s)s="";else s=s[0];if(r.charAt(0)===0)t[i]="u"+r.charAt(1)+s;else t[i]=r.charAt(0)+s;if(i>0)n=n&&t[i]===t[i-1]}if(n)return t[0];return t.join("")}function o3(e,t){var n=t[1].length-Math.abs(e.arrayBlockIndices[0])|0,i=Array(e.arrayArgs.length),r=Array(e.arrayArgs.length);for(var s=0;s<e.arrayArgs.length;++s)r[s]=t[2*s],i[s]=t[2*s+1];var a=[],o=[],c=[],l=[],u=[];for(var s=0;s<e.arrayArgs.length;++s){if(e.arrayBlockIndices[s]<0)c.push(0),l.push(n),a.push(n),o.push(n+e.arrayBlockIndices[s]);else c.push(e.arrayBlockIndices[s]),l.push(e.arrayBlockIndices[s]+n),a.push(0),o.push(e.arrayBlockIndices[s]);var d=[];for(var f=0;f<i[s].length;f++)if(c[s]<=i[s][f]&&i[s][f]<l[s])d.push(i[s][f]-c[s]);u.push(d)}var h=["SS"],b=["'use strict'"],m=[];for(var f=0;f<n;++f)m.push(["s",f,"=SS[",f,"]"].join(""));for(var s=0;s<e.arrayArgs.length;++s){h.push("a"+s),h.push("t"+s),h.push("p"+s);for(var f=0;f<n;++f)m.push(["t",s,"p",f,"=t",s,"[",c[s]+f,"]"].join(""));for(var f=0;f<Math.abs(e.arrayBlockIndices[s]);++f)m.push(["t",s,"b",f,"=t",s,"[",a[s]+f,"]"].join(""))}for(var s=0;s<e.scalarArgs.length;++s)h.push("Y"+s);if(e.shapeArgs.length>0)m.push("shape=SS.slice(0)");if(e.indexArgs.length>0){var g=Array(n);for(var s=0;s<n;++s)g[s]="0";m.push(["index=[",g.join(","),"]"].join(""))}for(var s=0;s<e.offsetArgs.length;++s){var p=e.offsetArgs[s],x=[];for(var f=0;f<p.offset.length;++f)if(p.offset[f]===0)continue;else if(p.offset[f]===1)x.push(["t",p.array,"p",f].join(""));else x.push([p.offset[f],"*t",p.array,"p",f].join(""));if(x.length===0)m.push("q"+s+"=0");else m.push(["q",s,"=",x.join("+")].join(""))}var _=i3([].concat(e.pre.thisVars).concat(e.body.thisVars).concat(e.post.thisVars));if(m=m.concat(_),m.length>0)b.push("var "+m.join(","));for(var s=0;s<e.arrayArgs.length;++s)b.push("p"+s+"|=0");if(e.pre.body.length>3)b.push(Kg(e.pre,e,r));var y=Kg(e.body,e,r),v=s3(u);if(v<n)b.push(r3(v,u[0],e,y));else b.push(GS(u[0],e,y));if(e.post.body.length>3)b.push(Kg(e.post,e,r));if(e.debug)console.log("-----Generated cwise routine for ",t,`:+`+b.join(``)+`-----------`);var E=[e.funcName||"unnamed","_cwise_loop_",i[0].join("s"),"m",v,vU(r)].join(""),S=Function(["function ",E,"(",h.join(","),"){",y.join(`-`),"} return ",E].join(""));return S()}Tw.exports=EU});var ww=Xr(function(W$,Sw){var TU=Aw();function AU(e){var t=["'use strict'","var CACHED={}"],n=[],i=e.funcName+"_cwise_thunk";t.push(["return function ",i,"(",e.shimArgs.join(","),"){"].join(""));var r=[],s=[],a=[["array",e.arrayArgs[0],".shape.slice(",Math.max(0,e.arrayBlockIndices[0]),e.arrayBlockIndices[0]<0?","+e.arrayBlockIndices[0]+")":")"].join("")],o=[],c=[];for(var l=0;l<e.arrayArgs.length;++l){var u=e.arrayArgs[l];if(n.push(["t",u,"=array",u,".dtype,","r",u,"=array",u,".order"].join("")),r.push("t"+u),r.push("r"+u),s.push("t"+u),s.push("r"+u+".join()"),a.push("array"+u+".data"),a.push("array"+u+".stride"),a.push("array"+u+".offset|0"),l>0)o.push("array"+e.arrayArgs[0]+".shape.length===array"+u+".shape.length+"+(Math.abs(e.arrayBlockIndices[0])-Math.abs(e.arrayBlockIndices[l]))),c.push("array"+e.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[0])+"]===array"+u+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[l])+"]")}if(e.arrayArgs.length>1)t.push("if (!("+o.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+e.arrayArgs[0]+".shape.length-"+Math.abs(e.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}");for(var l=0;l<e.scalarArgs.length;++l)a.push("scalar"+e.scalarArgs[l]);if(n.push(["type=[",s.join(","),"].join()"].join("")),n.push("proc=CACHED[type]"),t.push("var "+n.join(",")),t.push(["if(!proc){","CACHED[type]=proc=compile([",r.join(","),"])}","return proc(",a.join(","),")}"].join("")),e.debug)console.log(`-----Generated thunk:+----------`);var T=[e.funcName||"unnamed","_cwise_loop_",i[0].join("s"),"m",v,a3(r)].join(""),A=Function(["function ",T,"(",h.join(","),"){",b.join(`+`),"} return ",T].join(""));return A()}$S.exports=o3});var XS=Jr(function($5,WS){var c3=KS();function l3(e){var t=["'use strict'","var CACHED={}"],n=[],i=e.funcName+"_cwise_thunk";t.push(["return function ",i,"(",e.shimArgs.join(","),"){"].join(""));var r=[],s=[],a=[["array",e.arrayArgs[0],".shape.slice(",Math.max(0,e.arrayBlockIndices[0]),e.arrayBlockIndices[0]<0?","+e.arrayBlockIndices[0]+")":")"].join("")],o=[],c=[];for(var l=0;l<e.arrayArgs.length;++l){var u=e.arrayArgs[l];if(n.push(["t",u,"=array",u,".dtype,","r",u,"=array",u,".order"].join("")),r.push("t"+u),r.push("r"+u),s.push("t"+u),s.push("r"+u+".join()"),a.push("array"+u+".data"),a.push("array"+u+".stride"),a.push("array"+u+".offset|0"),l>0)o.push("array"+e.arrayArgs[0]+".shape.length===array"+u+".shape.length+"+(Math.abs(e.arrayBlockIndices[0])-Math.abs(e.arrayBlockIndices[l]))),c.push("array"+e.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[0])+"]===array"+u+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[l])+"]")}if(e.arrayArgs.length>1)t.push("if (!("+o.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+e.arrayArgs[0]+".shape.length-"+Math.abs(e.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}");for(var l=0;l<e.scalarArgs.length;++l)a.push("scalar"+e.scalarArgs[l]);if(n.push(["type=[",s.join(","),"].join()"].join("")),n.push("proc=CACHED[type]"),t.push("var "+n.join(",")),t.push(["if(!proc){","CACHED[type]=proc=compile([",r.join(","),"])}","return proc(",a.join(","),")}"].join("")),e.debug)console.log(`-----Generated thunk:`+t.join(``)+`----------`);var d=Function("compile",t.join(`-`));return d(TU.bind(void 0,e))}Sw.exports=AU});var Rw=Xr(function(X$,Mw){var SU=ww();function wU(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function MU(e){var t=new wU;t.pre=e.pre,t.body=e.body,t.post=e.post;var n=e.args.slice(0);t.argTypes=n;for(var i=0;i<n.length;++i){var r=n[i];if(r==="array"||typeof r==="object"&&r.blockIndices){if(t.argTypes[i]="array",t.arrayArgs.push(i),t.arrayBlockIndices.push(r.blockIndices?r.blockIndices:0),t.shimArgs.push("array"+i),i<t.pre.args.length&&t.pre.args[i].count>0)throw Error("cwise: pre() block may not reference array args");if(i<t.post.args.length&&t.post.args[i].count>0)throw Error("cwise: post() block may not reference array args")}else if(r==="scalar")t.scalarArgs.push(i),t.shimArgs.push("scalar"+i);else if(r==="index"){if(t.indexArgs.push(i),i<t.pre.args.length&&t.pre.args[i].count>0)throw Error("cwise: pre() block may not reference array index");if(i<t.body.args.length&&t.body.args[i].lvalue)throw Error("cwise: body() block may not write to array index");if(i<t.post.args.length&&t.post.args[i].count>0)throw Error("cwise: post() block may not reference array index")}else if(r==="shape"){if(t.shapeArgs.push(i),i<t.pre.args.length&&t.pre.args[i].lvalue)throw Error("cwise: pre() block may not write to array shape");if(i<t.body.args.length&&t.body.args[i].lvalue)throw Error("cwise: body() block may not write to array shape");if(i<t.post.args.length&&t.post.args[i].lvalue)throw Error("cwise: post() block may not write to array shape")}else if(typeof r==="object"&&r.offset)t.argTypes[i]="offset",t.offsetArgs.push({array:r.array,offset:r.offset}),t.offsetArgIndex.push(i);else throw Error("cwise: Unknown argument type "+n[i])}if(t.arrayArgs.length<=0)throw Error("cwise: No array arguments specified");if(t.pre.args.length>n.length)throw Error("cwise: Too many arguments in pre() block");if(t.body.args.length>n.length)throw Error("cwise: Too many arguments in body() block");if(t.post.args.length>n.length)throw Error("cwise: Too many arguments in post() block");return t.debug=!!e.printCode||!!e.debug,t.funcName=e.funcName||"cwise",t.blockSize=e.blockSize||64,SU(t)}Mw.exports=MU});var Dw=Xr(function(sn){var qn=Rw(),Xd={body:"",args:[],thisVars:[],localVars:[]};function Cg(e){if(!e)return Xd;for(var t=0;t<e.args.length;++t){var n=e.args[t];if(t===0)e.args[t]={name:n,lvalue:!0,rvalue:!!e.rvalue,count:e.count||1};else e.args[t]={name:n,lvalue:!1,rvalue:!0,count:1}}if(!e.thisVars)e.thisVars=[];if(!e.localVars)e.localVars=[];return e}function RU(e){return qn({args:e.args,pre:Cg(e.pre),body:Cg(e.body),post:Cg(e.proc),funcName:e.funcName})}function Zt(e){var t=[];for(var n=0;n<e.args.length;++n)t.push("a"+n);var i=Function("P",["return function ",e.funcName,"_ndarrayops(",t.join(","),") {P(",t.join(","),");return a0}"].join(""));return i(RU(e))}var Iw={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var e in Iw){var t=Iw[e];sn[e]=Zt({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),sn[e+"eq"]=Zt({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:e+"eq"}),sn[e+"s"]=Zt({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),sn[e+"seq"]=Zt({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:e+"seq"})}})();var Cw={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var e in Cw){var t=Cw[e];sn[e]=Zt({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:e}),sn[e+"eq"]=Zt({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:e+"eq"})}})();var Nw={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var e in Nw){var t=Nw[e];sn[e]=Zt({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),sn[e+"s"]=Zt({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),sn[e+"eq"]=Zt({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:e+"eq"}),sn[e+"seq"]=Zt({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:e+"seq"})}})();var Pw=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var e=0;e<Pw.length;++e){var t=Pw[e];sn[t]=Zt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:t}),sn[t+"eq"]=Zt({args:["array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"})}})();var Ow=["max","min","atan2","pow"];(function(){for(var e=0;e<Ow.length;++e){var t=Ow[e];sn[t]=Zt({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t}),sn[t+"s"]=Zt({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t+"s"}),sn[t+"eq"]=Zt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"}),sn[t+"seq"]=Zt({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"seq"})}})();var kw=["atan2","pow"];(function(){for(var e=0;e<kw.length;++e){var t=kw[e];sn[t+"op"]=Zt({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"op"}),sn[t+"ops"]=Zt({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"ops"}),sn[t+"opeq"]=Zt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opeq"}),sn[t+"opseq"]=Zt({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opseq"})}})();sn.any=qn({args:["array"],pre:Xd,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});sn.all=qn({args:["array"],pre:Xd,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});sn.sum=qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});sn.prod=qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});sn.norm2squared=qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});sn.norm2=qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});sn.norminf=qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});sn.norm1=qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});sn.sup=qn({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});sn.inf=qn({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});sn.argmin=qn({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});sn.argmax=qn({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});sn.random=Zt({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});sn.assign=Zt({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});sn.assigns=Zt({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});sn.equals=qn({args:["array","array"],pre:Xd,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})});function KU(e,t){if(!(e instanceof Uint8Array))throw Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let n=new Blob([e],{type:t});return createImageBitmap(n,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then((i)=>{let r=new OffscreenCanvas(i.width,i.height).getContext("2d");r.drawImage(i,0,0);let s=r.getImageData(0,0,i.width,i.height);return Lw.default(new Uint8Array(s.data),[i.width,i.height,4],[4,4*i.width,1],0)})}async function Fw(e,t){return KU(e,t)}var Lw,$U;var Uw=Ft(()=>{Lw=bf(Rg(),1),$U=bf(Dw(),1)});function rf(e,t){return Object.defineProperty(t,"name",{value:e}),t}function sf(e,t){let n={...e};for(let i in t)if(t[i]!==void 0)n[i]=t[i];return n}function eM(e){let t=[];for(let n of e.listAttributes())t.push(n);for(let n of e.listTargets())for(let i of n.listAttributes())t.push(i);return Array.from(new Set(t))}function XU(e,t){if(e==null&&t==null)return!0;if(e==null||t==null)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Yd(e,t){return e.createAccessor(t.getName()).setArray(t.getArray()).setType(t.getType()).setBuffer(t.getBuffer()).setNormalized(t.getNormalized()).setSparse(t.getSparse())}function qU(e,t=e){let n=tM(e,t);for(let i=0;i<n.length;i++)n[i]=i;return n}function tM(e,t=e){return t<=65534?new Uint16Array(e):new Uint32Array(e)}function nM(e){for(let t in e)return!1;return!0}function JU(e,t){var n=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],h=t[11],y=t[12],g=t[13],m=t[14],p=t[15],b=n*o-i*a,_=n*c-r*a,x=n*l-s*a,v=i*c-r*o,E=i*l-s*o,S=r*l-s*c,T=u*g-d*y,A=u*m-f*y,P=u*p-h*y,w=d*m-f*g,I=d*p-h*g,F=f*p-h*m,N=b*F-_*I+x*w+v*P-E*A+S*T;if(!N)return null;return N=1/N,e[0]=(o*F-c*I+l*w)*N,e[1]=(r*I-i*F-s*w)*N,e[2]=(g*S-m*E+p*v)*N,e[3]=(f*E-d*S-h*v)*N,e[4]=(c*P-a*F-l*A)*N,e[5]=(n*F-r*P+s*A)*N,e[6]=(m*x-y*S-p*_)*N,e[7]=(u*S-f*x+h*_)*N,e[8]=(a*I-o*P+l*T)*N,e[9]=(i*P-n*I-s*T)*N,e[10]=(y*E-g*x+p*b)*N,e[11]=(d*x-u*E-h*b)*N,e[12]=(o*A-a*w-c*T)*N,e[13]=(n*w-i*A+r*T)*N,e[14]=(g*_-y*v-m*b)*N,e[15]=(u*v-d*_+f*b)*N,e}function Fg(e,t,n){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],h=t[10],y=t[11],g=t[12],m=t[13],p=t[14],b=t[15],_=n[0],x=n[1],v=n[2],E=n[3];return e[0]=_*i+x*o+v*d+E*g,e[1]=_*r+x*c+v*f+E*m,e[2]=_*s+x*l+v*h+E*p,e[3]=_*a+x*u+v*y+E*b,_=n[4],x=n[5],v=n[6],E=n[7],e[4]=_*i+x*o+v*d+E*g,e[5]=_*r+x*c+v*f+E*m,e[6]=_*s+x*l+v*h+E*p,e[7]=_*a+x*u+v*y+E*b,_=n[8],x=n[9],v=n[10],E=n[11],e[8]=_*i+x*o+v*d+E*g,e[9]=_*r+x*c+v*f+E*m,e[10]=_*s+x*l+v*h+E*p,e[11]=_*a+x*u+v*y+E*b,_=n[12],x=n[13],v=n[14],E=n[15],e[12]=_*i+x*o+v*d+E*g,e[13]=_*r+x*c+v*f+E*m,e[14]=_*s+x*l+v*h+E*p,e[15]=_*a+x*u+v*y+E*b,e}function ZU(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function YU(e,t,n,i){var r=t[0],s=t[1],a=t[2],o=t[3],c=r+r,l=s+s,u=a+a,d=r*c,f=r*l,h=r*u,y=s*l,g=s*u,m=a*u,p=o*c,b=o*l,_=o*u,x=i[0],v=i[1],E=i[2];return e[0]=(1-(y+m))*x,e[1]=(f+_)*x,e[2]=(h-b)*x,e[3]=0,e[4]=(f-_)*v,e[5]=(1-(d+m))*v,e[6]=(g+p)*v,e[7]=0,e[8]=(h+b)*E,e[9]=(g-p)*E,e[10]=(1-(d+y))*E,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function ef(e,t){let n=e.getAttribute("POSITION"),i=e.getIndices();if(!n)return 0;switch(t){case"render":return i?i.getCount():n.getCount();case"render-cached":return i?new Set(i.getArray()).size:n.getCount();case"upload-naive":case"upload":return n.getCount();case"distinct":case"distinct-position":return QU(t);case"unused":return i?n.getCount()-new Set(i.getArray()).size:0;default:return e3(t)}}function QU(e){throw Error(`Not implemented: ${e}`)}function e3(e){throw Error(`Unexpected value: ${e}`)}function t3(e,t,n){let i=zd.fromGraph(e.getGraph());if(!t||!n)[t,n]=n3(e);let r=e.getIndices(),s=r?r.getArray():null,a=ef(e,"render"),o=i.createAccessor(),c=a,l=tM(c,n);for(let d=0;d<c;d++)l[d]=t[s?s[d]:d];e.setIndices(o.setArray(l));let u=eM(e);for(let d of e.listAttributes()){let f=Yd(i,d);Og(d,r,t,f,n),e.swap(d,f)}for(let d of e.listTargets())for(let f of d.listAttributes()){let h=Yd(i,f);Og(f,r,t,h,n),d.swap(f,h)}if(r&&r.listParents().length===1)r.dispose();for(let d of u)if(d.listParents().length===1)d.dispose();return e}function Og(e,t,n,i,r){let s=e.getElementSize(),a=e.getArray(),o=t?t.getArray():null,c=t?t.getCount():e.getCount(),l=new a.constructor(r*s),u=new Uint8Array(r);for(let d=0;d<c;d++){let f=o?o[d]:d,h=n[f];if(u[h])continue;for(let y=0;y<s;y++)l[h*s+y]=a[f*s+y];u[h]=1}return i.setArray(l)}function n3(e){let t=ef(e,"upload"),n=e.getIndices(),i=n?n.getArray():null;if(!n||!i)return[qU(t,1e6),t];let r=new Uint32Array(t).fill(Bw),s=0;for(let a=0;a<i.length;a++){let o=i[a];if(r[o]===Bw)r[o]=s++}return[r,s]}function i3(){var e=new Qd(3);if(Qd!=Float32Array)e[0]=0,e[1]=0,e[2]=0;return e}function r3(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e}function kg(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e}function Dg(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e}function zw(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function s3(e,t,n){var i=t[0],r=t[1],s=t[2],a=n[3]*i+n[7]*r+n[11]*s+n[15];return a=a||1,e[0]=(n[0]*i+n[4]*r+n[8]*s+n[12])/a,e[1]=(n[1]*i+n[5]*r+n[9]*s+n[13])/a,e[2]=(n[2]*i+n[6]*r+n[10]*s+n[14])/a,e}function Ug(e=Pg){let t=sf(Pg,e),n=new Set(t.propertyTypes);for(let i of t.propertyTypes)if(!Pg.propertyTypes.includes(i))throw Error(`${$s}: Unsupported deduplication on type "${i}".`);return rf($s,(i)=>{let r=i.getLogger();if(n.has(ne.ACCESSOR))o3(i);if(n.has(ne.TEXTURE))l3(i,t);if(n.has(ne.MATERIAL))u3(i,t);if(n.has(ne.MESH))c3(i,t);if(n.has(ne.SKIN))d3(i,t);r.debug(`${$s}: Complete.`)})}function o3(e){let t=e.getLogger(),n=new Map,i=new Map,r=new Map,s=new Map,a=e.getRoot().listMeshes();a.forEach((d)=>{d.listPrimitives().forEach((f)=>{f.listAttributes().forEach((h)=>o(h,i)),o(f.getIndices(),n)})});for(let d of e.getRoot().listAnimations())for(let f of d.listSamplers())o(f.getInput(),r),o(f.getOutput(),s);function o(d,f){if(!d)return;let h=[d.getCount(),d.getType(),d.getComponentType(),d.getNormalized(),d.getSparse()].join(":"),y=f.get(h);if(!y)f.set(h,y=new Set);y.add(d)}function c(d,f){for(let h=0;h<d.length;h++){let y=d[h],g=Je.toView(y.getArray());if(f.has(y))continue;for(let m=h+1;m<d.length;m++){let p=d[m];if(f.has(p))continue;if(Je.equals(g,Je.toView(p.getArray())))f.set(p,y)}}}let l=0,u=new Map;for(let d of[i,n,r,s])for(let f of d.values())l+=f.size,c(Array.from(f),u);t.debug(`${$s}: Merged ${u.size} of ${l} accessors.`),a.forEach((d)=>{d.listPrimitives().forEach((f)=>{f.listAttributes().forEach((y)=>{if(u.has(y))f.swap(y,u.get(y))});let h=f.getIndices();if(h&&u.has(h))f.swap(h,u.get(h))})});for(let d of e.getRoot().listAnimations())for(let f of d.listSamplers()){let h=f.getInput(),y=f.getOutput();if(h&&u.has(h))f.swap(h,u.get(h));if(y&&u.has(y))f.swap(y,u.get(y))}Array.from(u.keys()).forEach((d)=>d.dispose())}function c3(e,t){let n=e.getLogger(),i=e.getRoot(),r=new Map;i.listAccessors().forEach((o,c)=>r.set(o,c)),i.listMaterials().forEach((o,c)=>r.set(o,c));let s=i.listMeshes().length,a=new Map;for(let o of i.listMeshes()){let c=[];for(let u of o.listPrimitives())c.push(iM(u,r));let l="";if(t.keepUniqueNames)l+=o.getName()+";";if(l+=c.join(";"),a.has(l)){let u=a.get(l);o.listParents().forEach((d)=>{if(d.propertyType!==ne.ROOT)d.swap(o,u)}),o.dispose()}else a.set(l,o)}n.debug(`${$s}: Merged ${s-a.size} of ${s} meshes.`)}function l3(e,t){let n=e.getLogger(),i=e.getRoot(),r=i.listTextures(),s=new Map;for(let a=0;a<r.length;a++){let o=r[a],c=o.getImage();if(s.has(o))continue;for(let l=a+1;l<r.length;l++){let u=r[l],d=u.getImage();if(s.has(u))continue;if(o.getMimeType()!==u.getMimeType())continue;if(t.keepUniqueNames&&o.getName()!==u.getName())continue;let f=o.getSize(),h=u.getSize();if(!f||!h)continue;if(f[0]!==h[0])continue;if(f[1]!==h[1])continue;if(!c||!d)continue;if(Je.equals(c,d))s.set(u,o)}}n.debug(`${$s}: Merged ${s.size} of ${i.listTextures().length} textures.`),Array.from(s.entries()).forEach(([a,o])=>{a.listParents().forEach((c)=>{if(!(c instanceof Rs))c.swap(a,o)}),a.dispose()})}function u3(e,t){let n=e.getLogger(),i=e.getRoot().listMaterials(),r=new Map,s=new Map,a=new Set;if(!t.keepUniqueNames)a.add("name");for(let o=0;o<i.length;o++){let c=i[o];if(r.has(c))continue;if(Vw(c,s))continue;for(let l=o+1;l<i.length;l++){let u=i[l];if(r.has(u))continue;if(Vw(u,s))continue;if(c.equals(u,a))r.set(u,c)}}n.debug(`${$s}: Merged ${r.size} of ${i.length} materials.`),Array.from(r.entries()).forEach(([o,c])=>{o.listParents().forEach((l)=>{if(!(l instanceof Rs))l.swap(o,c)}),o.dispose()})}function d3(e,t){let n=e.getLogger(),i=e.getRoot().listSkins(),r=new Map,s=new Set(["joints"]);if(!t.keepUniqueNames)s.add("name");for(let a=0;a<i.length;a++){let o=i[a];if(r.has(o))continue;for(let c=a+1;c<i.length;c++){let l=i[c];if(r.has(l))continue;if(o.equals(l,s)&&XU(o.listJoints(),l.listJoints()))r.set(l,o)}}n.debug(`${$s}: Merged ${r.size} of ${i.length} skins.`),Array.from(r.entries()).forEach(([a,o])=>{a.listParents().forEach((c)=>{if(!(c instanceof Rs))c.swap(a,o)}),a.dispose()})}function iM(e,t){let n=[];for(let i of e.listSemantics()){let r=e.getAttribute(i);n.push(i+":"+t.get(r))}if(e instanceof Wn){let i=e.getIndices();if(i)n.push("indices:"+t.get(i));let r=e.getMaterial();if(r)n.push("material:"+t.get(r));n.push("mode:"+e.getMode());for(let s of e.listTargets())n.push("target:"+iM(s,t))}return n.join(",")}function Vw(e,t){if(t.has(e))return t.get(e);let n=e.getGraph(),i=new Set,r=n.listParentEdges(e);while(r.length>0){let s=r.pop();if(s.getAttributes().modifyChild===!0)return t.set(e,!0),!0;let a=s.getChild();if(i.has(a))continue;for(let o of n.listChildEdges(a))r.push(o)}return t.set(e,!1),!1}function rM(){var e=new Qd(4);if(Qd!=Float32Array)e[0]=0,e[1]=0,e[2]=0,e[3]=0;return e}function f3(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function h3(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}function p3(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}function m3(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function g3(e){var t=e[0],n=e[1],i=e[2],r=e[3];return Math.sqrt(t*t+n*n+i*i+r*r)}function x3(e){return e.getGraph().listParentEdges(e).some((t)=>t.getAttributes().isColor||y3.test(t.getName()))?"srgb":null}function _3(e){let t=e.getGraph(),n=new Set,i=new Set;function r(s){let a=new Set;for(let o of t.listChildEdges(s))if(o.getChild()instanceof zo)a.add(o.getName()+"Info");for(let o of t.listChildEdges(s)){let c=o.getChild();if(n.has(c))continue;if(n.add(c),c instanceof At&&a.has(o.getName()))i.add(c);else if(c instanceof nt)r(c)}}return r(e),Array.from(i)}function v3(e){let t=zd.fromGraph(e.getGraph()).getRoot(),n=e.getGraph().listParentEdges(e).filter((i)=>i.getParent()!==t).map((i)=>i.getName());return Array.from(new Set(n))}function oM(e=jw){let t=sf(jw,e),n=new Set(t.propertyTypes),i=t.keepExtras;return rf(Ho,async(r)=>{let s=r.getLogger(),a=r.getRoot(),o=r.getGraph(),c=new E3,l=(u)=>c.dispose(u.target);if(o.addEventListener("node:dispose",l),n.has(ne.MESH))for(let u of a.listMeshes()){if(u.listPrimitives().length>0)continue;u.dispose()}if(n.has(ne.NODE)){if(!t.keepLeaves)for(let u of a.listScenes())cM(o,u,i);for(let u of a.listNodes())Ai(u,i)}if(n.has(ne.SKIN))for(let u of a.listSkins())Ai(u,i);if(n.has(ne.MESH))for(let u of a.listMeshes())Ai(u,i);if(n.has(ne.CAMERA))for(let u of a.listCameras())Ai(u,i);if(n.has(ne.PRIMITIVE))Hw(o,ne.PRIMITIVE,i);if(n.has(ne.PRIMITIVE_TARGET))Hw(o,ne.PRIMITIVE_TARGET,i);if(!t.keepAttributes&&n.has(ne.ACCESSOR)){let u=new Map;for(let d of a.listMeshes())for(let f of d.listPrimitives()){let h=f.getMaterial();if(!h)continue;let y=T3(f,lM(r,f,h));Gw(f,y),f.listTargets().forEach((g)=>Gw(g,y)),u.has(h)?u.get(h).add(f):u.set(h,new Set([f]))}for(let[d,f]of u)A3(d,Array.from(f))}if(n.has(ne.ANIMATION))for(let u of a.listAnimations()){for(let d of u.listChannels())if(!d.getTargetNode())d.dispose();if(!u.listChannels().length){let d=u.listSamplers();Ai(u,i),d.forEach((f)=>Ai(f,i))}else u.listSamplers().forEach((d)=>Ai(d,i))}if(n.has(ne.MATERIAL))a.listMaterials().forEach((u)=>Ai(u,i));if(n.has(ne.TEXTURE)){if(a.listTextures().forEach((u)=>Ai(u,i)),!t.keepSolidTextures)await S3(r)}if(n.has(ne.ACCESSOR))a.listAccessors().forEach((u)=>Ai(u,i));if(n.has(ne.BUFFER))a.listBuffers().forEach((u)=>Ai(u,i));if(o.removeEventListener("node:dispose",l),!c.empty()){let u=c.entries().map(([d,f])=>`${d} (${f})`).join(", ");s.info(`${Ho}: Removed types... ${u}`)}else s.debug(`${Ho}: No unused properties found.`);s.debug(`${Ho}: Complete.`)})}function Ai(e,t){let n=e.listParents().filter((r)=>!(r instanceof Rs||r instanceof Ca)),i=t&&!nM(e.getExtras());if(!n.length&&!i)e.dispose()}function Hw(e,t,n){for(let i of e.listEdges()){let r=i.getParent();if(r.propertyType===t)Ai(r,n)}}function cM(e,t,n){if(t.listChildren().forEach((a)=>cM(e,a,n)),t instanceof Bd)return;let i=e.listParentEdges(t).some((a)=>{let o=a.getParent().propertyType;return o!==ne.ROOT&&o!==ne.SCENE&&o!==ne.NODE}),r=e.listChildren(t).length===0,s=n&&!nM(t.getExtras());if(r&&!i&&!s)t.dispose()}function Gw(e,t){for(let n of t)e.setAttribute(n,null)}function T3(e,t){let n=[];for(let i of e.listSemantics())if(i==="NORMAL"&&!t.has(i))n.push(i);else if(i==="TANGENT"&&!t.has(i))n.push(i);else if(i.startsWith("TEXCOORD_")&&!t.has(i))n.push(i);else if(i.startsWith("COLOR_")&&i!=="COLOR_0")n.push(i);return n}function lM(e,t,n,i=new Set){let r=e.getGraph().listChildEdges(n),s=new Set;for(let c of r)if(c.getChild()instanceof zo)s.add(c.getName());for(let c of r){let l=c.getName(),u=c.getChild();if(u instanceof At){if(s.has(l.replace(/Info$/,"")))i.add(`TEXCOORD_${u.getTexCoord()}`)}if(u instanceof zo&&l.match(/normalTexture/i))i.add("TANGENT");if(u instanceof nt)lM(e,t,u,i)}let a=n instanceof Ra&&!n.getExtension("KHR_materials_unlit"),o=t.getMode()===Wn.Mode.POINTS;if(a&&!o)i.add("NORMAL");return i}function A3(e,t){let n=_3(e),i=new Set(n.map((c)=>c.getTexCoord())),r=Array.from(i).sort(),s=new Map(r.map((c,l)=>[c,l])),a=new Map(r.map((c,l)=>[`TEXCOORD_${c}`,`TEXCOORD_${l}`]));for(let c of n){let l=c.getTexCoord();c.setTexCoord(s.get(l))}for(let c of t){let l=c.listSemantics().filter((u)=>u.startsWith("TEXCOORD_")).sort();o(c,l),c.listTargets().forEach((u)=>o(u,l))}function o(c,l){for(let u of l){let d=c.getAttribute(u);if(!d)continue;let f=a.get(u);if(f===u)continue;c.setAttribute(f,d),c.setAttribute(u,null)}}}async function S3(e){let t=e.getRoot(),n=e.getGraph(),i=e.getLogger(),r=t.listTextures().map(async(s)=>{let a=await M3(s);if(!a)return;if(x3(s)==="srgb")xS.convertSRGBToLinear(a,a);let o=s.getName()||s.getURI(),c=s.getSize()?.join("x"),l=v3(s);for(let u of n.listParentEdges(s)){let d=u.getParent();if(d!==t&&w3(d,a,u.getName(),i))u.dispose()}if(s.listParents().length===1)s.dispose(),i.debug(`${Ho}: Removed solid-color texture "${o}" (${c}px ${l.join(", ")})`)});await Promise.all(r)}function w3(e,t,n,i){if(e instanceof Ra)switch(n){case"baseColorTexture":return e.setBaseColorFactor(b3(t,t,e.getBaseColorFactor())),!0;case"emissiveTexture":return e.setEmissiveFactor(a3([0,0,0],t.slice(0,3),e.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(t[0]-1)<=Lg;case"metallicRoughnessTexture":return e.setRoughnessFactor(t[1]*e.getRoughnessFactor()),e.setMetallicFactor(t[2]*e.getMetallicFactor()),!0;case"normalTexture":return aM(sM(rM(),t,[0.5,0.5,1,1]))<=Lg}return i.warn(`${Ho}: Detected single-color ${n} texture. Pruning ${n} not yet supported.`),!1}async function M3(e){let t=await R3(e);if(!t)return null;let n=[1/0,1/0,1/0,1/0],i=[-1/0,-1/0,-1/0,-1/0],r=[0,0,0,0],[s,a]=t.shape;for(let o=0;o<s;o++){for(let c=0;c<a;c++)for(let l=0;l<4;l++)n[l]=Math.min(n[l],t.get(o,c,l)),i[l]=Math.max(i[l],t.get(o,c,l));if(aM(sM(r,i,n))/255>Lg)return null}return m3(r,f3(r,i,n),0.00196078431372549)}async function R3(e){try{return await Fw(e.getImage(),e.getMimeType())}catch{return null}}function I3(e,t=1/0){if(Number.isFinite(t)&&t%4||t<=0)throw Error("Limit must be positive multiple of four.");let n=e.getAttribute("POSITION").getCount(),i=e.listSemantics().filter((l)=>l.startsWith("WEIGHTS_")).length,r=new Uint16Array(i*4),s=new Float32Array(i*4),a=new Float32Array(i*4),o=new Uint32Array(i*4),c=new Uint32Array(i*4);for(let l=0;l<n;l++){tf(e,l,"WEIGHTS",s),tf(e,l,"JOINTS",o);for(let u=0;u<i*4;u++)r[u]=u;r.sort((u,d)=>s[u]>s[d]?-1:1);for(let u=0;u<r.length;u++)a[u]=s[r[u]],c[u]=o[r[u]];nf(e,l,"WEIGHTS",a),nf(e,l,"JOINTS",c)}for(let l=i;l*4>t;l--){let u=e.getAttribute(`WEIGHTS_${l-1}`),d=e.getAttribute(`JOINTS_${l-1}`);if(e.setAttribute(`WEIGHTS_${l-1}`,null),e.setAttribute(`JOINTS_${l-1}`,null),u.listParents().length===1)u.dispose();if(d.listParents().length===1)d.dispose()}C3(e)}function C3(e){if(!N3(e))return;let t=e.getAttribute("POSITION").getCount(),n=e.listSemantics().filter((d)=>d.startsWith("WEIGHTS_")).length,i=e.getAttribute("WEIGHTS_0"),r=i.getArray(),s=i.getComponentType(),a=i.getNormalized(),o=a?s:void 0,c=a?pt.decodeNormalizedInt(1,s):Number.EPSILON,l=new Uint32Array(n*4).fill(0),u=r.slice(0,n*4).fill(0);for(let d=0;d<t;d++){tf(e,d,"JOINTS",l),tf(e,d,"WEIGHTS",u,o);let f=$w(u,o);if(f!==0&&f!==1){if(Math.abs(1-f)>c)for(let h=0;h<u.length;h++)if(a){let y=pt.decodeNormalizedInt(u[h],s);u[h]=pt.encodeNormalizedInt(y/f,s)}else u[h]/=f;if(f=$w(u,o),a&&f!==1){for(let h=u.length-1;h>=0;h--)if(u[h]>0){let y=1-f;u[h]+=Math.sign(y)*pt.encodeNormalizedInt(Math.abs(y),s);break}}}for(let h=u.length-1;h>=0;h--)if(u[h]===0)l[h]=0;nf(e,d,"JOINTS",l),nf(e,d,"WEIGHTS",u,o)}}function tf(e,t,n,i,r){let s,a=[0,0,0,0];for(let o=0;s=e.getAttribute(`${n}_${o}`);o++){s.getElement(t,a);for(let c=0;c<4;c++)if(r)i[o*4+c]=pt.encodeNormalizedInt(a[c],r);else i[o*4+c]=a[c]}return i}function nf(e,t,n,i,r){let s,a=[0,0,0,0];for(let o=0;s=e.getAttribute(`${n}_${o}`);o++){for(let c=0;c<4;c++)if(r)a[c]=pt.decodeNormalizedInt(i[o*4+c],r);else a[c]=i[o*4+c];s.setElement(t,a)}}function $w(e,t){let n=0;for(let i=0;i<e.length;i++)if(t)n+=pt.decodeNormalizedInt(e[i],t);else n+=e[i];return n}function N3(e){let t=e.listSemantics().filter((r)=>r.startsWith("WEIGHTS_")).map((r)=>e.getAttribute(r)),n=t.map((r)=>r.getNormalized()),i=t.map((r)=>r.getComponentType());return new Set(n).size===1&&new Set(i).size===1}function uM(e=Zd){let t=sf(Zd,{patternTargets:e.pattern||Zd.pattern,...e});return rf(Gs,async(n)=>{let i=n.getLogger(),r=n.getRoot();if(n.hasExtension("KHR_mesh_primitive_restart"))throw Error("quantize: Missing support for KHR_mesh_primitive_restart.");let s;if(t.quantizationVolume==="scene")s=Ww($3(r.listMeshes().map(Xw)));for(let a of n.getRoot().listMeshes()){if(t.quantizationVolume==="mesh")s=Ww(Xw(a));if(s&&t.pattern.test("POSITION"))U3(n,a,s),V3(a,1/s.scale);for(let o of a.listPrimitives()){if(ef(o,"render")<ef(o,"upload")/2)t3(o);Kw(n,o,s,t);for(let c of o.listTargets())Kw(n,c,s,t)}}if(r.listMeshes().flatMap((a)=>a.listPrimitives()).some(dM))n.createExtension(wg).setRequired(!0);if(t.cleanup)await n.transform(oM({propertyTypes:[ne.ACCESSOR,ne.SKIN,ne.MATERIAL],keepAttributes:!0,keepIndices:!0,keepLeaves:!0,keepSolidTextures:!0}),Ug({propertyTypes:[ne.ACCESSOR,ne.MATERIAL,ne.SKIN],keepUniqueNames:!0}));i.debug(`${Gs}: Complete.`)})}function Kw(e,t,n,i){let r=t instanceof xg,s=e.getLogger();for(let a of t.listSemantics()){if(!r&&!i.pattern.test(a))continue;if(r&&!i.patternTargets.test(a))continue;let o=t.getAttribute(a),{bits:c,ctor:l}=H3(a,o,s,i);if(!l)continue;if(c<8||c>16)throw Error(`${Gs}: Requires bits = 8–16.`);if(o.getComponentSize()<=c/8)continue;let u=o.clone();if(a==="POSITION"){let d=n.scale,f=[];t instanceof Wn?JU(f,af(n)):ZU(f,[1/d,1/d,1/d]);for(let h=0,y=[0,0,0],g=u.getCount();h<g;h++)u.getElement(h,y),u.setElement(h,s3(y,y,f))}j3(u,l,c),t.setAttribute(a,u)}if(i.normalizeWeights&&t.getAttribute("WEIGHTS_0"))I3(t,1/0);if(t instanceof Wn&&t.getIndices()&&t.listAttributes().length&&t.listAttributes()[0].getCount()<65535){let a=t.getIndices();a.setArray(new Uint16Array(a.getArray()))}}function Ww(e){let{min:t,max:n}=e,i=Math.max((n[0]-t[0])/2,(n[1]-t[1])/2,(n[2]-t[2])/2);return{offset:[t[0]+(n[0]-t[0])/2,t[1]+(n[1]-t[1])/2,t[2]+(n[2]-t[2])/2],scale:i}}function U3(e,t,n){let i=af(n);for(let r of t.listParents()){if(!(r instanceof Ud))continue;let s=r.listParents().filter((f)=>f instanceof Ca),a=s.some((f)=>F3.includes(f.getTargetPath())),o=r.listChildren().length>0,c=r.getSkin();if(c){r.setSkin(B3(c,n));continue}let l=r.getExtension("EXT_mesh_gpu_instancing");if(l){r.setExtension("EXT_mesh_gpu_instancing",z3(e,l,n));continue}let u;if(o||a)u=e.createNode("").setMesh(t),r.addChild(u).setMesh(null),s.filter((f)=>f.getTargetPath()===L3).forEach((f)=>f.setTargetNode(u));else u=r;let d=u.getMatrix();Fg(d,d,i),u.setMatrix(d)}}function B3(e,t){e=e.clone();let n=af(t),i=e.getInverseBindMatrices().clone(),r=[];for(let s=0,a=i.getCount();s<a;s++)i.getElement(s,r),Fg(r,r,n),i.setElement(s,r);return e.setInverseBindMatrices(i)}function z3(e,t,n){if(!t.getAttribute("TRANSLATION")&&!t.getAttribute("ROTATION")&&!t.getAttribute("SCALE"))return t;t=t.clone();let i=t.getAttribute("TRANSLATION")?.clone(),r=t.getAttribute("ROTATION")?.clone(),s=t.getAttribute("SCALE")?.clone(),a=i||r||s,o=[0,0,0],c=[0,0,0,1],l=[1,1,1];if(!i&&n.offset)i=e.createAccessor().setType("VEC3").setArray(Jw(a.getCount(),o));if(!s&&n.scale)s=e.createAccessor().setType("VEC3").setArray(Jw(a.getCount(),l));let u=[0,0,0],d=[0,0,0,1],f=[1,1,1],h=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],y=af(n);for(let g=0,m=a.getCount();g<m;g++){if(pt.compose(i?i.getElement(g,u):o,r?r.getElement(g,d):c,s?s.getElement(g,f):l,h),Fg(h,h,y),pt.decompose(h,u,d,f),i)i.setElement(g,u);if(r)r.setElement(g,d);if(s)s.setElement(g,f)}if(i)t.setAttribute("TRANSLATION",i);if(r)t.setAttribute("ROTATION",r);if(s)t.setAttribute("SCALE",s);return t}function V3(e,t){for(let n of e.listPrimitives()){let i=n.getMaterial();if(!i)continue;let r=i.getExtension("KHR_materials_volume");if(!r||r.getThicknessFactor()<=0)continue;r=r.clone().setThicknessFactor(r.getThicknessFactor()*t),i=i.clone().setExtension("KHR_materials_volume",r),n.setMaterial(i)}}function j3(e,t,n){let i=new t(e.getArray().length),r=P3.includes(t)?1:0,s=n-r,a=t.BYTES_PER_ELEMENT*8-r,o=Math.pow(2,s)-1,c=a-s,l=2*s-a,u=[r>0?-1:0,1];for(let d=0,f=0,h=[];d<e.getCount();d++){e.getElement(d,h);for(let y=0;y<h.length;y++){let g=K3(h[y],u);g=Math.round(Math.abs(g)*o),g=g<<c|g>>l,i[f++]=g*Math.sign(h[y])}}e.setArray(i).setNormalized(!0).setSparse(!1)}function H3(e,t,n,i){let r=t.getMinNormalized([]),s=t.getMaxNormalized([]),a,o;if(e==="POSITION")a=i.quantizePosition,o=a<=8?Int8Array:Int16Array;else if(e==="NORMAL"||e==="TANGENT")a=i.quantizeNormal,o=a<=8?Int8Array:Int16Array;else if(e.startsWith("COLOR_"))a=i.quantizeColor,o=a<=8?Uint8Array:Uint16Array;else if(e.startsWith("TEXCOORD_")){if(r.some((c)=>c<0)||s.some((c)=>c>1))return n.warn(`${Gs}: Skipping ${e}; out of [0,1] range.`),{bits:-1};a=i.quantizeTexcoord,o=a<=8?Uint8Array:Uint16Array}else if(e.startsWith("JOINTS_")){if(a=Math.max(...t.getMax([]))<=255?8:16,o=a<=8?Uint8Array:Uint16Array,t.getComponentSize()>a/8)t.setArray(new o(t.getArray()));return{bits:-1}}else if(e.startsWith("WEIGHTS_")){if(r.some((c)=>c<0)||s.some((c)=>c>1))return n.warn(`${Gs}: Skipping ${e}; out of [0,1] range.`),{bits:-1};a=i.quantizeWeight,o=a<=8?Uint8Array:Uint16Array}else if(e.startsWith("_")){if(r.some((c)=>c<-1)||s.some((c)=>c>1))return n.warn(`${Gs}: Skipping ${e}; out of [-1,1] range.`),{bits:-1};a=i.quantizeGeneric,o=r.some((c)=>c<0)?o=a<=8?Int8Array:Int16Array:o=a<=8?Uint8Array:Uint16Array}else throw Error(`${Gs}: Unexpected semantic, "${e}".`);return{bits:a,ctor:o}}function Xw(e){let t=[],n=[];for(let r of e.listPrimitives()){let s=r.getAttribute("POSITION");if(s)t.push(s);for(let a of r.listTargets()){let o=a.getAttribute("POSITION");if(o)n.push(o)}}if(t.length===0)throw Error(`${Gs}: Missing "POSITION" attribute.`);let i=qw(t,3);if(n.length>0){let{min:r,max:s}=qw(n,3);kg(i.min,i.min,kg(r,zw(r,r,2),[0,0,0])),Dg(i.max,i.max,Dg(s,zw(s,s,2),[0,0,0]))}return i}function G3(e,t){let n=t.getComponentSize();if(e==="POSITION")return n<4;if(e==="NORMAL")return n<4;if(e==="TANGENT")return n<4;if(e.startsWith("TEXCOORD_")){let i=t.getComponentType(),r=t.getNormalized();return n<4&&!(r&&i===Be.ComponentType.UNSIGNED_BYTE)&&!(r&&i===Be.ComponentType.UNSIGNED_SHORT)}return!1}function dM(e){for(let t of e.listSemantics())if(G3(t,e.getAttribute("POSITION")))return!0;if(e.propertyType===ne.PRIMITIVE)return e.listTargets().some(dM);return!1}function qw(e,t){let n=Array(t).fill(1/0),i=Array(t).fill(-1/0),r=[],s=[];for(let a of e){a.getMinNormalized(r),a.getMaxNormalized(s);for(let o=0;o<t;o++)n[o]=Math.min(n[o],r[o]),i[o]=Math.max(i[o],s[o])}return{min:n,max:i}}function $3(e){let t=e[0];for(let n of e)kg(t.min,t.min,n.min),Dg(t.max,t.max,n.max);return t}function af(e){return YU([],[0,0,0,1],e.offset,[e.scale,e.scale,e.scale])}function K3(e,t){return Math.min(Math.max(e,t[0]),t[1])}function Jw(e,t){let n=t.length,i=new Float32Array(e*n);for(let r=0;r<e;r++)i.set(t,r*n);return i}function fM(e){let t=sf(W3,e),n=t.encoder;if(!n)throw Error(`${qd}: encoder dependency required — install "meshoptimizer".`);return rf(qd,async(i)=>{let r=i.getLogger();if(i.hasExtension("KHR_mesh_primitive_restart"))throw Error("reorder: Missing support for KHR_mesh_primitive_restart.");await n.ready;let s=X3(i);for(let a of s.indicesToAttributes.keys()){let o=a.getArray();if(!(o instanceof Uint32Array))o=new Uint32Array(o);else o=o.slice();let[c,l]=n.reorderMesh(o,s.indicesToMode.get(a)===Wn.Mode.TRIANGLES,t.target==="size"),u=Yd(i,a);u.setArray(l<=65534?new Uint16Array(o):o);for(let d of s.indicesToAttributes.get(a)){let f=Yd(i,d);Og(d,a,c,f,l);for(let h of s.indicesToPrimitives.get(a)){if(h.getIndices()===a)h.swap(a,u);h.swap(d,f);for(let y of h.listTargets())y.swap(d,f)}}}if(t.cleanup)await i.transform(oM({propertyTypes:[ne.ACCESSOR],keepAttributes:!0,keepIndices:!0}));if(!s.indicesToAttributes.size)r.warn(`${qd}: No qualifying primitives found; may need to weld first.`);else r.debug(`${qd}: Complete.`)})}function X3(e){let t=new Map,n=new Ng,i=new Ng,r=new Ng;for(let s of e.getRoot().listMeshes())for(let a of s.listPrimitives()){let o=a.getIndices();if(!o)continue;t.set(o,a.getMode()),n.add(o,a);for(let c of eM(a))i.add(o,c),r.add(c,a)}return{indicesToPrimitives:n,indicesToAttributes:i,indicesToMode:t,attributesToPrimitives:r}}function J3(e,t,n,i=0.0001){let r=t.length/e.length,s=Array(r).fill(0),a=Array(r).fill(0),o=Array(r).fill(0),c=Array(r).fill(0),l=e.length-1,u=1;for(let d=1;d<l;++d){let f=e[u-1],h=e[d],y=e[d+1],g=(h-f)/(y-f),m=!1;if(h!==y&&(d!==1||h!==e[0])){if(ml(t,u-1,c),ml(t,d,a),ml(t,d+1,o),n==="slerp"){let p=Q3(s,c,o,g),b=Qw(c,a)+Qw(a,o);m=!Jd(a,p,i)||b+Number.EPSILON>=Math.PI}else if(n==="lerp")m=!Jd(a,Y3(s,c,o,g),i);else if(n==="step")m=!Jd(a,c)||!Jd(a,o)}if(m){if(d!==u)e[u]=e[d],Yw(t,u,ml(t,d,s));u++}}if(l>0)e[u]=e[l],Yw(t,u,ml(t,l,s)),u++;return u}function ml(e,t,n){for(let i=0,r=n.length;i<r;i++)n[i]=e[t*r+i];return n}function Yw(e,t,n){for(let i=0,r=n.length;i<r;i++)e[t*r+i]=n[i]}function Jd(e,t,n=0){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(Math.abs(e[i]-t[i])>n)return!1;return!0}function Z3(e,t,n){return e*(1-n)+t*n}function Y3(e,t,n,i){for(let r=0;r<t.length;r++)e[r]=Z3(t[r],n[r],i);return e}function Q3(e,t,n,i){let r=t[0],s=t[1],a=t[2],o=t[3],c=n[0],l=n[1],u=n[2],d=n[3],f,h,y,g,m;if(h=r*c+s*l+a*u+o*d,h<0)h=-h,c=-c,l=-l,u=-u,d=-d;if(1-h>q3)f=Math.acos(h),y=Math.sin(f),g=Math.sin((1-i)*f)/y,m=Math.sin(i*f)/y;else g=1-i,m=i;return e[0]=g*r+m*c,e[1]=g*s+m*l,e[2]=g*a+m*u,e[3]=g*o+m*d,e}function Qw(e,t){let n=e9(e,t);return Math.acos(2*n*n-1)}function e9(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}var WU,t5,n5,i5,r5,s5,a5,o5,Ng=class{_map=new Map;get size(){return this._map.size}has(e){return this._map.has(e)}add(e,t){let n=this._map.get(e);if(!n)n=new Set,this._map.set(e,n);return n.add(t),this}get(e){return this._map.get(e)||new Set}keys(){return this._map.keys()}},c5,Qd,Bw=4294967295,a3,l5,u5,d5,f5,h5,p5,m5,$s="dedup",Pg,g5,b5,sM,b3,aM,y3,Ho="prune",Lg=0.011764705882352941,jw,E3=class{disposed={};empty(){for(let e in this.disposed)return!1;return!0}entries(){return Object.entries(this.disposed)}dispose(e){this.disposed[e.propertyType]=this.disposed[e.propertyType]||0,this.disposed[e.propertyType]++}},y5,x5,_5,v5,E5,Gs="quantize",P3,O3,k3,D3,L3,F3,Zd,qd="reorder",W3,T5,Zw,q3=0.000001,A5,S5,w5,M5,R5,I5,C5,N5;var hM=Ft(()=>{fl();Uw();Kd();WU=bf(Rg(),1),{POINTS:t5,LINES:n5,LINE_STRIP:i5,LINE_LOOP:r5,TRIANGLES:s5,TRIANGLE_STRIP:a5,TRIANGLE_FAN:o5}=Wn.Mode;c5=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});Qd=typeof Float32Array<"u"?Float32Array:Array;Math.PI/180;180/Math.PI;a3=r3;(function(){var e=i3();return function(t,n,i,r,s,a){var o,c;if(!n)n=3;if(!i)i=0;if(r)c=Math.min(r*n+i,t.length);else c=t.length;for(o=i;o<c;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],s(e,e,a),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2];return t}})();({FLOAT:l5}=Be.ComponentType),{LINES:u5,LINE_STRIP:d5,LINE_LOOP:f5,TRIANGLES:h5,TRIANGLE_STRIP:p5,TRIANGLE_FAN:m5}=Wn.Mode,Pg={keepUniqueNames:!1,propertyTypes:[ne.ACCESSOR,ne.MESH,ne.TEXTURE,ne.MATERIAL,ne.SKIN]};({TEXTURE_INFO:g5,ROOT:b5}=ne);sM=h3,b3=p3,aM=g3;(function(){var e=rM();return function(t,n,i,r,s,a){var o,c;if(!n)n=4;if(!i)i=0;if(r)c=Math.min(r*n+i,t.length);else c=t.length;for(o=i;o<c;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],e[3]=t[o+3],s(e,e,a),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2],t[o+3]=e[3];return t}})();y3=/color|emissive|diffuse/i;jw={propertyTypes:[ne.NODE,ne.SKIN,ne.MESH,ne.CAMERA,ne.PRIMITIVE,ne.PRIMITIVE_TARGET,ne.ANIMATION,ne.MATERIAL,ne.TEXTURE,ne.ACCESSOR,ne.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};({ROOT:y5,NODE:x5,MESH:_5,PRIMITIVE:v5,ACCESSOR:E5}=ne);P3=[Int8Array,Int16Array,Int32Array],{TRANSLATION:O3,ROTATION:k3,SCALE:D3,WEIGHTS:L3}=Ca.TargetPath,F3=[O3,k3,D3],Zd={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};W3={target:"size",cleanup:!0};T5={level:"high",...Zd};(function(e){e[e.STEP=0]="STEP",e[e.LERP=1]="LERP",e[e.SLERP=2]="SLERP"})(Zw||(Zw={}));A5={ready:Promise.resolve(),resample:J3,tolerance:0.0001,cleanup:!0},{POINTS:S5,LINES:w5,LINE_STRIP:M5,LINE_LOOP:R5,TRIANGLES:I5,TRIANGLE_STRIP:C5,TRIANGLE_FAN:N5}=Wn.Mode});function mM(e,t,n,i={}){if(!Array.isArray(t))return e.push({code:"EXPECTED_ARRAY",path:n,message:`${n} must be an array.`}),!1;if(!i.allowEmpty&&t.length===0)e.push({code:"EXPECTED_NONEMPTY_ARRAY",path:n,message:`${n} must not be empty.`});let r=new Set;for(let s=0;s<t.length;s++){let a=t[s];if(!Hr(a)){e.push({code:"EXPECTED_NONEMPTY_STRING",path:`${n}[${s}]`,message:`${n}[${s}] must be a trimmed non-empty string.`});continue}if(r.has(a))e.push({code:"DUPLICATE_VALUE",path:`${n}[${s}]`,message:`${n} contains duplicate value ${JSON.stringify(a)}.`});r.add(a)}return!0}function i9(e,t,n){let i=`frames[${t}]`;if(!Ks(e))return n.push({code:"INVALID_FRAME",path:i,message:`${i} must be an object.`}),!1;if(!Hr(e.id))n.push({code:"INVALID_FRAME_ID",path:`${i}.id`,message:"Frame ID is required."});if(!pM(e.translation,3))n.push({code:"INVALID_FRAME_TRANSLATION",path:`${i}.translation`,message:"Frame translation must be three finite meters."});if(!pM(e.rotation,4))n.push({code:"INVALID_FRAME_ROTATION",path:`${i}.rotation`,message:"Frame rotation must be a finite quaternion."});else{let r=Math.hypot(...e.rotation);if(Math.abs(r-1)>0.000001)n.push({code:"NON_UNIT_FRAME_ROTATION",path:`${i}.rotation`,message:"Frame rotation quaternion must be normalized within 1e-6."})}return!0}function r9(e,t,n){let i=`relationships[${t}]`;if(!Ks(e))return n.push({code:"INVALID_RELATIONSHIP",path:i,message:`${i} must be an object.`}),!1;for(let r of["kind","target"])if(!Hr(e[r]))n.push({code:"INVALID_RELATIONSHIP_FIELD",path:`${i}.${r}`,message:`${i}.${r} must be a trimmed non-empty string.`});if(e.targetType!=="node"&&e.targetType!=="role"&&e.targetType!=="socket")n.push({code:"INVALID_RELATIONSHIP_TARGET_TYPE",path:`${i}.targetType`,message:"Relationship targetType must be node, role, or socket."});for(let r of["sourceFrame","targetFrame"])if(e[r]!==void 0&&!Hr(e[r]))n.push({code:"INVALID_RELATIONSHIP_FRAME",path:`${i}.${r}`,message:`${i}.${r} must be a trimmed non-empty string.`});return!0}function s9(e,t,n){let i=`sockets[${t}]`;if(!Ks(e))return n.push({code:"INVALID_SOCKET",path:i,message:`${i} must be an object.`}),!1;for(let r of["id","type","frame"])if(!Hr(e[r]))n.push({code:"INVALID_SOCKET_FIELD",path:`${i}.${r}`,message:`${i}.${r} must be a trimmed non-empty string.`});if(mM(n,e.compatibleTypes,`${i}.compatibleTypes`,{allowEmpty:!0}),e.allowedRotationsDegrees!==void 0){if(!Array.isArray(e.allowedRotationsDegrees)||e.allowedRotationsDegrees.some((r)=>typeof r!=="number"||!Number.isFinite(r)))n.push({code:"INVALID_ALLOWED_ROTATIONS",path:`${i}.allowedRotationsDegrees`,message:"Allowed rotations must be finite degree values."})}return!0}function a9(e){let t=[];if(!Ks(e))return{valid:!1,issues:[{code:"EXPECTED_OBJECT",path:"",message:"SemanticMetadataV1 must be an object."}]};if(e.schemaVersion!==1)t.push({code:"UNSUPPORTED_SCHEMA_VERSION",path:"schemaVersion",message:"schemaVersion must be 1."});mM(t,e.roles,"roles");let n=Array.isArray(e.frames)?e.frames:[];if(!Array.isArray(e.frames))t.push({code:"EXPECTED_ARRAY",path:"frames",message:"frames must be an array."});let i=new Set;n.forEach((o,c)=>{if(i9(o,c,t),Ks(o)&&Hr(o.id)){if(i.has(o.id))t.push({code:"DUPLICATE_FRAME_ID",path:`frames[${c}].id`,message:`Duplicate frame ID ${JSON.stringify(o.id)}.`});i.add(o.id)}});let r=Array.isArray(e.relationships)?e.relationships:[];if(!Array.isArray(e.relationships))t.push({code:"EXPECTED_ARRAY",path:"relationships",message:"relationships must be an array."});r.forEach((o,c)=>{if(r9(o,c,t),Ks(o))for(let l of["sourceFrame","targetFrame"]){let u=o[l];if(Hr(u)&&!i.has(u))t.push({code:"UNKNOWN_FRAME_REFERENCE",path:`relationships[${c}].${l}`,message:`Unknown frame ${JSON.stringify(u)}.`})}});let s=Array.isArray(e.sockets)?e.sockets:[];if(!Array.isArray(e.sockets))t.push({code:"EXPECTED_ARRAY",path:"sockets",message:"sockets must be an array."});let a=new Set;if(s.forEach((o,c)=>{if(s9(o,c,t),Ks(o)&&Hr(o.id)){if(a.has(o.id))t.push({code:"DUPLICATE_SOCKET_ID",path:`sockets[${c}].id`,message:`Duplicate socket ID ${JSON.stringify(o.id)}.`});a.add(o.id)}if(Ks(o)&&Hr(o.frame)&&!i.has(o.frame))t.push({code:"UNKNOWN_FRAME_REFERENCE",path:`sockets[${c}].frame`,message:`Unknown frame ${JSON.stringify(o.frame)}.`})}),t.length>0)return{valid:!1,issues:t};return{valid:!0,value:o9(e),issues:t}}function o9(e){return{schemaVersion:1,roles:[...e.roles],relationships:e.relationships.map((t)=>({kind:t.kind,target:t.target,targetType:t.targetType,...t.sourceFrame?{sourceFrame:t.sourceFrame}:{},...t.targetFrame?{targetFrame:t.targetFrame}:{}})),frames:e.frames.map((t)=>({id:t.id,translation:t9(t.translation),rotation:n9(t.rotation)})),sockets:e.sockets.map((t)=>({id:t.id,type:t.type,frame:t.frame,compatibleTypes:[...t.compatibleTypes],...t.allowedRotationsDegrees?{allowedRotationsDegrees:[...t.allowedRotationsDegrees]}:{}}))}}function Bg(e){let t=e.kilnSemantic;if(t===void 0)return;let n=a9(t);return n.valid?n.value:void 0}var Na,Ks=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),Hr=(e)=>typeof e==="string"&&e.trim().length>0&&e===e.trim(),pM=(e,t)=>Array.isArray(e)&&e.length===t&&e.every((n)=>typeof n==="number"&&Number.isFinite(n)),t9=(e)=>[e[0],e[1],e[2]],n9=(e)=>[e[0],e[1],e[2],e[3]];var of=Ft(()=>{Na=Object.freeze({vehicleFrame:"vehicle.frame",vehicleForward:"vehicle.front.+x",socket:"socket",chassis:"chassis",chassisMain:"chassis.main",axle:"axle",seat:"seat",contact:"contact",steering:"steering",propulsion:"propulsion",wheelAssembly:"wheel.assembly",wheelPivot:"wheel.pivot",wheelLoadBearing:"wheel.load-bearing",wheelTire:"wheel.tire",wheelRim:"wheel.rim",wheelHub:"wheel.hub",wheelContact:"wheel.contact",steeringPivot:"steering.pivot",roof:"roof",architectureRoof:"architecture.roof",collider:"collider",colliderBox:"collider.box",colliderCapsule:"collider.capsule",colliderHull:"collider.hull",anchor:"anchor",kitModule:"kit.module",kitPort:"kit.port",lodImpostor:"lod.impostor"})});function yM(){return new RS().registerExtensions([...hw,bM])}var di="MSFT_lod",gM,bM;var zg=Ft(()=>{fl();Kd();gM=class gM extends nt{static EXTENSION_NAME=di;init(){this.extensionName=di,this.propertyType="Lod",this.parentTypes=[ne.NODE,ne.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{levels:new bn})}addLevel(e){return this.addRef("levels",e)}listLevels(){return this.listRefs("levels")}};bM=class bM extends xt{extensionName=di;static EXTENSION_NAME=di;createLod(e=""){return new gM(this.document.getGraph(),e)}read(e){let t=e.jsonDoc.json;return this.readLevels(t.nodes,e.nodes),this.readLevels(t.materials,e.materials),this}readLevels(e,t){(e??[]).forEach((n,i)=>{let r=n.extensions?.[di]?.ids,s=t[i];if(!s||!Array.isArray(r))return;let a=this.createLod();for(let o of r){let c=typeof o==="number"?t[o]:void 0;if(c&&c!==s)a.addLevel(c)}s.setExtension(di,a)})}write(e){let t=e.jsonDoc.json,n=this.document.getRoot();for(let i of n.listNodes()){let r=e.nodeIndexMap.get(i),s=i.getExtension(di)?.listLevels().filter((o)=>o.propertyType===ne.NODE).map((o)=>e.nodeIndexMap.get(o)).filter((o)=>o!==void 0),a=r===void 0?void 0:t.nodes?.[r];if(a&&s?.length)a.extensions={...a.extensions,[di]:{ids:s}}}for(let i of n.listMaterials()){let r=e.materialIndexMap.get(i),s=i.getExtension(di)?.listLevels().filter((o)=>o.propertyType===ne.MATERIAL).map((o)=>e.materialIndexMap.get(o)).filter((o)=>o!==void 0),a=r===void 0?void 0:t.materials?.[r];if(a&&s?.length)a.extensions={...a.extensions,[di]:{ids:s}}}return this}}});var c9;var Vg=Ft(()=>{c9=Object.freeze([1,1,1])});var G5,$5;var xM=Ft(()=>{Vg();G5=Object.freeze({units:"m",forward:"+X",up:"+Y",right:"+Z",groundY:0}),$5=Math.PI/180});var _M=()=>{};var vM=()=>{};var EM=Ft(()=>{xM();Vg();_M();vM();of()});var l9;var TM=Ft(()=>{l9=Object.freeze({parametricSamples:262144,subdivisionTriangles:1e6,subdivisionAttributeBytes:134217728,subdivisionIterations:10,repeatedMeshes:1e4,primitiveSegments:4096,primitiveGridVertices:262144,unwrapVertices:65536,unwrapTriangles:1e6,unwrapAttributeBytes:134217728,unwrapResolution:4096,skinBones:1024,skinVertices:262144,skinAttributeBytes:134217728,colliderHullVertices:65536,surfaceBakeVertices:262144,surfaceBakeTriangles:1e6,surfaceBakeRays:8388608,surfaceBakeRayDirections:256})});var jg="kilnRepeatInstances";var Hg=Ft(()=>{EM();ou();TM()});function gl(e){return e.getExtension("KHR_node_visibility")?.getVisible?.()===!1}var lK;var cf=Ft(()=>{lK=[{grade:"A",max:1,range:"0-1"},{grade:"B",max:3,range:"2-3"},{grade:"C",max:6,range:"4-6"},{grade:"D",max:12,range:"7-12"},{grade:"F",max:Number.POSITIVE_INFINITY,range:"13+"}]});var AM=Ft(()=>{cf()});function wM(e){let t=new Map,n=e.getRoot().getDefaultScene()??e.getRoot().listScenes()[0];if(!n)return t;let i=(r,s)=>{let a=new Map;for(let o of r){let c=o.getName(),l=a.get(c)??0;a.set(c,l+1);let u=`${s}${SM(c,l)}`;t.set(o,u),i(o.listChildren(),u)}};return i(n.listChildren(),SM(n.getName()||"Scene",0)),t}var SM=(e,t)=>`/${encodeURIComponent(e)}[${t}]`;var MM=Ft(()=>{zg();of();Hg();cf();AM()});var NM={};pb(NM,{deliverRuntimeThreeGlb:()=>m9});function d9(e,t){let n=(i)=>{if(!i)return-1;if(!t.has(i))t.set(i,t.size);return t.get(i)};return e.listPrimitives().map((i)=>`${i.getMode()}:${n(i.getMaterial())}:${n(i.getIndices())}:${i.listSemantics().sort().map((r)=>`${r}=${n(i.getAttribute(r))}`).join(",")}:${i.listTargets().length}`).join("|")}function f9(e){let t=[],n=new Map,i=e.getRoot().listNodes().filter((s)=>s.getExtras()[jg]!==void 0),r;for(let s of i){let a=new Map;for(let l of s.listChildren()){let u=l.getMesh();if(!u||l.listChildren().length||l.getSkin()||l.listExtensions().length||gl(l)||bl(l).length||Object.keys(l.getExtras()).length||l.getWeights().length)continue;let d=d9(u,n);a.set(d,[...a.get(d)??[],l])}let o=0;for(let l of a.values()){if(l.length<2)continue;let u=l[0].getMesh();r??=e.createExtension($d).setRequired(!0);let d=e.getRoot().listBuffers()[0],f=(_,x)=>e.createAccessor().setType(_).setArray(new Float32Array(x)).setBuffer(d??null),h=[],y=[],g=[];for(let _ of l)h.push(..._.getTranslation()),y.push(..._.getRotation()),g.push(..._.getScale());let m=r.createInstancedMesh().setAttribute("TRANSLATION",f("VEC3",h)).setAttribute("ROTATION",f("VEC4",y)).setAttribute("SCALE",f("VEC3",g)),p=`${s.getName()||"Node"}_Instances${o?`_${o}`:""}`;o++;let b=e.createNode(p).setMesh(u).setExtension("EXT_mesh_gpu_instancing",m);s.addChild(b),t.push({node:b,mesh:u.getName(),count:l.length,instances:l.map((_)=>_.getName())});for(let _ of l){let x=_.getMesh();if(_.dispose(),x&&x!==u&&!x.listParents().some((v)=>v.propertyType===ne.NODE))x.dispose()}}let c={...s.getExtras()};delete c[jg],s.setExtras(c)}return t}function h9(e){let t=[];for(let n of e.getRoot().listNodes()){let i=n.getMesh();if(!i||!CM(n))continue;let r=e.createNode(`${n.getName()}_Proxy`).setMesh(i);n.setMesh(null).addChild(r),t.push({collider:n,proxy:r})}return t}async function p9(e,t){let n=e.getRoot().listTextures().filter((r)=>r.getMimeType()!=="image/ktx2"&&r.getImage());if(!t)return{status:"skipped",textures:n.length,reason:"No KTX2 encoder was supplied; textures stay PNG or JPEG."};let i=new Set;for(let r of e.getRoot().listMaterials())for(let s of[r.getBaseColorTexture(),r.getEmissiveTexture()])if(s)i.add(s);for(let r of n){let s=await t({image:r.getImage(),mimeType:r.getMimeType(),name:r.getName(),colorSpace:i.has(r)?"srgb":"linear"});if(!(s instanceof Uint8Array)||s.byteLength<12)throw Error("ktx2Encoder must return KTX2 bytes");r.setImage(s).setMimeType("image/ktx2");let a=r.getURI();if(a)r.setURI(a.replace(/\.(png|jpe?g)$/i,".ktx2"))}if(n.length)e.createExtension(Mg).setRequired(!0);return{status:"encoded",textures:n.length}}function IM(e,t){let n=new Qe().fromArray(e).invert().multiply(new Qe().fromArray(t)),i=new j,r=new ln,s=new j;return n.decompose(i,r,s),{scale:s.x,offset:[i.x,i.y,i.z]}}async function m9(e,t,n={}){let i=yM().registerDependencies({"meshopt.encoder":t}),r=await i.readBinary(e);r.setLogger(new Ia(Ia.Verbosity.SILENT)),await r.transform(Ug({propertyTypes:[ne.ACCESSOR],keepUniqueNames:!0}));let s=f9(r),a=h9(r),o=new Map;for(let b of r.getRoot().listNodes())if(b.getMesh())o.set(b,[...b.getMatrix()]);await r.transform(fM({encoder:t,target:"size"}),uM({pattern:RM,patternTargets:RM,quantizationVolume:"mesh",quantizePosition:yr.position,quantizeNormal:yr.normal,quantizeTexcoord:yr.texcoord,quantizeColor:yr.color,quantizeWeight:yr.weight})),r.createExtension(pl).setRequired(!0).setEncoderOptions({method:pl.EncoderMethod.QUANTIZE});let c=await p9(r,n.ktx2Encoder);for(let b of r.getRoot().listNodes()){if(!b.getMesh()||o.has(b)||b.getName())continue;let x=b.getParentNode();b.setName(`${x?.getName()||"Node"}_Mesh`)}let l=wM(r),u=(b)=>l.get(b)??`#${encodeURIComponent(b.getName())}`,d=new Set(a.map((b)=>b.proxy)),f=[];for(let b of r.getRoot().listNodes()){let _=b.getMesh();if(!_||b.getExtension("EXT_mesh_gpu_instancing"))continue;let x=l.get(b);if(x===void 0)continue;let v=o.get(b),E=v===void 0,S=E||d.has(b),T=E?new Qe().identity().toArray():v,A=[...b.getMatrix()],{scale:P,offset:w}=IM(T,A);if(!E&&Math.abs(P-1)<0.000000000001&&w.every((F)=>F===0))continue;let I=b.getParentNode();f.push({node:x,mesh:_.getName(),meshMovedToChild:S,...S&&I?{authoredNode:u(I)}:{},dequantization:{scale:P,offset:w},localScale:[...b.getScale()]})}for(let b of r.getRoot().listNodes()){let _=b.getMesh();if(!_||l.has(b)||!o.has(b))continue;let{scale:x,offset:v}=IM(o.get(b),[...b.getMatrix()]);f.push({node:`#lod/${encodeURIComponent(b.getName())}`,mesh:_.getName(),meshMovedToChild:!1,dequantization:{scale:x,offset:v},localScale:[...b.getScale()]})}let h=new Map;for(let b of r.getRoot().listMeshes())for(let _ of b.listPrimitives())for(let x of _.listSemantics())if(x.startsWith("_"))h.set(x,(h.get(x)??new Set).add(b));let y=r.getRoot().listNodes(),g=await i.writeBinary(r),m=(await i.binaryToJSON(g)).json,p={target:"three",extensionsUsed:[...m.extensionsUsed??[]].sort(),extensionsRequired:[...m.extensionsRequired??[]].sort(),compression:{extension:"EXT_meshopt_compression",method:"quantize"},quantization:{extension:"KHR_mesh_quantization",volume:"mesh",bits:{position:yr.position,normal:yr.normal,texcoord:yr.texcoord,color:yr.color,weight:yr.weight},customAttributes:"float32"},nodeScale:f,colliderProxies:a.map(({collider:b,proxy:_})=>({collider:u(b),proxy:u(_)})),customAttributes:[...h].sort(([b],[_])=>b==="_EDGE"?-1:_==="_EDGE"?1:b<_?-1:b>_?1:0).map(([b,_])=>({name:b,meshes:_.size,componentType:"FLOAT",normalized:!1})),instancing:s.map(({node:b,..._})=>({node:u(b),..._})),ktx2:c,preserved:{lodChains:y.filter((b)=>b.getExtension(di)).length,hiddenNodes:y.filter((b)=>gl(b)).length,colliders:y.filter(CM).length,anchors:y.filter((b)=>bl(b).some((_)=>_.startsWith(`${Na.anchor}.`))).length,ports:y.filter((b)=>bl(b).some((_)=>_.startsWith(`${Na.kitPort}.`))).length,kitModules:y.filter((b)=>bl(b).includes(Na.kitModule)).length}};return{glb:g,delivery:p}}var yr,RM,bl=(e)=>Bg(e.getExtras())?.roles??[],CM=(e)=>bl(e).some((t)=>t.startsWith(`${Na.collider}.`));var PM=Ft(()=>{fl();Kd();hM();zi();of();zg();MM();Hg();cf();yr=Object.freeze({volume:"mesh",position:14,normal:10,texcoord:12,color:8,weight:8}),RM=/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/});var g9;var OM=Ft(()=>{g9=function(){var e="b9H79Tebbbe9ok9Geueu9Geub9Gbb9Gruuuuuuueu9Gvuuuuueu9Gduueu9Gluuuueu9Gvuuuuub9Gouuuuuub9Gluuuub9GiuuueuiE8AdilveoveovrrwrrrDDoDrbqqbelve9Weiiviebeoweuecj:Gdkr:PlCo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8F9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWV9mW4W2be8A9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWVbd8F9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWV9c9V919U9KbiE9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949wWV79P9V9UblY9TW79O9V9Wt9FW9U9J9V9KW69U9KW949c919M9MWVbv8E9TW79O9V9Wt9FW9U9J9V9KW69U9KW949c919M9MWV9c9V919U9Kbo8A9TW79O9V9Wt9FW9U9J9V9KW69U9KW949wWV79P9V9UbrE9TW79O9V9Wt9FW9U9J9V9KW69U9KW949tWG91W9U9JWbwa9TW79O9V9Wt9FW9U9J9V9KW69U9KW949tWG91W9U9JW9c9V919U9KbDL9TW79O9V9Wt9FW9U9J9V9KWS9P2tWV9p9JtbqK9TW79O9V9Wt9FW9U9J9V9KWS9P2tWV9r919HtbkL9TW79O9V9Wt9FW9U9J9V9KWS9P2tWVT949WbxY9TW79O9V9Wt9FW9U9J9V9KWS9P2tWVJ9V29VVbmE9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94J9H9J9OWbza9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94J9H9J9OW9ttV9P9WbHa9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94SWt9J9O9sW9T9H9WbOK9TW79O9V9Wt9F79W9Ht9P9H29t9VVt9sW9T9H9WbAl79IV9RbXDwebcekdKYq:8f8Adbk;wadhud9:8Jjjjjbc;qw9Rgr8KjjjjbcbhwdnaeTmbabcbyd;i:I:cjbaoaocb9iEgDc:GeV86bbarc;adfcbcjdz:xjjjb8AdnaiTmbarc;adfadalz:wjjjb8Akarc;abfalfcbcbcjdal9RalcFe0Ez:xjjjb8Aarc;abfarc;adfalz:wjjjb8Aar9cb83iUar9cb83i8War9cb83iyar9cb83iaar9cb83iKar9cb83izar9cb83iwar9cb83ibcj;abal9Uc;WFbGcjdalca0Ehqdnaicd6mbavcd9imbaDTmbadcefhkaqci2gxal2hmarc;alfclfhParc;qlfceVhsarc;qofclVhzcbhHincdhOcbhAdnavci6mbar9cb83i;Ooar9cb83i;Goar9cb83i;yoar9cb83i;qoadaHfgoybbhCcbhXincbhwcbhQdninaoalfhLaoybbgKaC7aQVhQawcP0meaLhoaKhCawcefgwaXfai6mbkkcbhCarc;qofhwincwhYcwh8AdnaQaC93gocFeGgEcs0mbclh8AaEci0mbcdcbaEEh8Akdnaocw4cFeGgEcs0mbclhYaEci0mbcdcbaEEhYkaYa8AfhEawydbh3cwhYcwh8Adnaocz4cFeGg5cs0mbclh8Aa5ci0mbcdcba5Eh8AkaEa3fhEdnaocFFFFb0mbclhYaocFFF8F0mbcbcdaocjjjw6EhYkawaEa8AfaYfBdbawclfhwaCcefgCcw9hmbkaLhoaKhCaXczfgXai6mbkcbhocehwazhQinawaoaQydbarc;qofaocdtfydb6EhoaQclfhQawcefgwcw9hmbkaoclthAcihOkcbhEarc;qlfcbcjdz:xjjjb8AarcbBd;ilar9cb83i;aladh8Eaqh8Fakh3inarc;qlfadaEaEcb9h9Ral2falz:wjjjb8Aaia8Faia8F6EhadnaqaiaE9RaEaqfai6EgKcsfc9WGgoaK9nmbarc;qofaKfcbaoaK9Rz:xjjjb8AkadaEal2fhhcbhginagaAVcl4hXarc;alfagcdtfh8JaHh8Kcbh8Lina8LaHfhwdndndndndndndnagPlbedibkaKTmvahawfhoarc;qlfawfRbbhQarc;qofhwaahCinawaoRbbgYaQ9RgQcetaQcKtc8F91786bbawcefhwaoalfhoaYhQaEaCcufgC9hmbxvkkaKTmla8Kc9:Ghoa8LcitcwGh8Aarc;qlfawceVfRbbcwtarc;qlfawc9:GfRbbVhQarc;qofhwaahCinawa3aofRbbcwta8EaofRbbVgYaQ9RgQcetaQcztc8F917cFFiGa8A486bbaoalfhoawcefhwaYhQaEaCcufgC9hmbxlkkasa8Kc98GgQfhoa3aQfhYarc;qlfawc98GgQfRbbhCcwhwinaoRbbawtaCVhCaocefhoawcwfgwca9hmbxdkkaKTmdxekaKTmea8Lcith5ahaQfh8AcbhLina8ARbbhQcwhoaYhwinawRbbaotaQVhQawcefhwaocwfgoca9hmbkarc;qofaLfaQaC7aX93a5486bbaYalfhYa8Aalfh8AaQhCaLcefgLaK9hmbkka8Jydbh8AcbhLarc;qofhoincdhQcbhwinaQaoawfRbbcb9hfhQawcefgwcz9hmbkclhCcbhwinaCaoawfRbbcd0fhCawcefgwcz9hmbkcwhYcbhwinaYaoawfRbbcP0fhYawcefgwcz9hmbkaQaCaQaC6EgwaYawaY6Egwczawcz6Ea8Afh8AaoczfhoaLczfgLaK6mbka8Ja8ABdbka8Kcefh8Ka8Lcefg8Lcl9hmbkagcefggaO9hmbka8Eamfh8Ea8Faxfh8Fa3amfh3aEaxfgEai6mbkcbhocehwaPhQinawaoaQydbarc;alfaocdtfydb6EhoaQclfhQaOawcefgw9hmbkaraHcd4faAcdVaoaocdSE86bbaHclfgHal6mbkkabaefhgabcefhoalcd4g8McbaDEhkadcefh8Narc;abfceVhecbhmdndninaiam9nmearc;qofcbcjdz:xjjjb8Aagao9Rak6mdadamal2gwfhxcbhHa8Nawfhzaocbakz:xjjjbg8Fakfh3aqaiam9Ramaqfai6Egscsfgocl4cifcd4hOaoc9WGg8JThPindndndndndndndndndndnaDTmbaraHcd4fRbbgQciGPlbedlbkasTmdaxaHfhoarc;abfaHfRbbhQarc;qofhwashCinawaoRbbgYaQ9RgQcetaQcKtc8F91786bbawcefhwaoalfhoaYhQaCcufgCmbxikkasTmiaHcitcwGh8Aarc;abfaHceVfRbbcwtarc;abfaHc9:GgofRbbVhQaxaofhoarc;qofhwashCinawao8VbbgYaQ9RgQcetaQcztc8F917cFFiGa8A486bbawcefhwaoalfhoaYhQaCcufgCmbxikkaeaHc98Gg8Afhoaza8AfhYarc;abfa8AfRbbhCcwhwinaoRbbawtaCVhCaocefhoawcwfgwca9hmbkasTmdaQcl4hKaHcitcKGhEaxa8Afh8AcbhLina8ARbbhQcwhoaYhwinawRbbaotaQVhQawcefhwaocwfgoca9hmbkarc;qofaLfaQaC7aK93aE486bbaYalfhYa8Aalfh8AaQhCaLcefgLas9hmbkkaDmbcbhoxlka8JTmbcbhodninarc;qofaofgwcwf8Pibaw8Pib:e9qTmeaoczfgoa8J9pmdxbkkdnavmbcehoxikcbh8AaOhLaOhKinarc;qofa8Afgocwf8Pibhyao8Pibh8PcdhQcbhwinaQaoawfRbbcb9hfhQawcefgwcz9hmbkclhCcbhwinaCaoawfRbbcd0fhCawcefgwcz9hmbkcwhYcbhwinaYaoawfRbbcP0fhYawcefgwcz9hmbkaQaCaQaC6EgoaYaoaY6Egoczaocz6EaKfhKaocucbaya8P:e9cb9sEgwaoaw6EaLfhLa8Aczfg8Aa8J9pmdxbkka8FaHcd4fgoaoRbbcdaHcetcoGtV86bbxikdnaLas6mbaKas6mba8FaHcd4fgoaoRbbciaHcetcoGtV86bbaga39Ras6mra3arc;qofasz:wjjjbasfh3xikaLaK9phoka8FaHcd4fgwawRbbaoaHcetcoGtV86bbkaga39RaO6mla3cbaOz:xjjjbgaaOfhKdndna8JmbaPhoxekdnagaK9RcK9pmbaPhoxekaocdtc:q:G:cjbfcj:G:cjbaDEg3ydxghcetc;:FFFeGhAcuhEcuahtcu7cFeGh8Ecbh8Karc;qofhQinarc;qofa8KfhXczh8AdndndnahPDbeeeeeeedekcucbaXcwf8PibaX8Pib:e9cb9sEh8AxekcbhoaAh8Aina8Aa8EaQaofRbb9nfh8Aaocefgocz9hmbkkcih5cbhYinczhwdndndna3aYcdtfydbgLPDbeeeeeeedekcucbaXcwf8PibaX8Pib:e9cb9sEhwxekaLcetc;:FFFeGhwcuaLtcu7cFeGhCcbhoinawaCaQaofRbb9nfhwaocefgocz9hmbkkdndnawa8A6mbaLaE9hmeawa8A9hmea3a5cdtfydbcwSmekaYh5awh8AkaYcefgYci9hmbkaaa8Kco4fgoaoRbba5a8Kci4coGtV86bbdndndna3a5cdtfydbgEPDdbbbbbbbebkdncwaE9Tg5TmbcuaEtcu7hwdndnaEceSmbcbh8LaQhXinaXhoa5hYcbhCinaoRbbg8AawcFeGgLa8AaL6EaCaEtVhCaocefhoaYcufgYmbkaKaC86bbaXa5fhXaKcefhKa8La5fg8Lcz6mbxdkkcbh8LaQhXinaXhoa5hYcbhCinaoRbbg8AawcFeGgLa8AaL6EaCcetVhCaocefhoaYcufgYmbkaKaC:T9cFe:d9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:9ca188bbaXa5fhXaKcefhKa8La5fg8Lcz6mbkkcbhoinaKaQaofRbbgC86bbaKaCawcFeG9pfhKaocefgocz9hmbxikkdnaEceSmbinaKcb86bbaKcefhKxbkkinaKcb86bbaKcefhKxbkkaKaX8Pbw83bwaKaX8Pbb83bbaKczfhKka8Kczfg8Ka8J9pgomeaQczfhQagaK9RcK9pmbkkaoTmlaKh3aKTmlkaHcefgHal9hmbkarc;abfaxascufal2falz:wjjjb8Aasamfhma3hoa3mbkcbhwxdkdnagao9RakalfgwcKcaaDEgQawaQ0EgC9pmbcbhwxdkdnawaQ9pmbaocbaCaw9Rgwz:xjjjbawfhokaoarc;adfalz:wjjjbalfhodnaDTmbaoara8Mz:wjjjba8Mfhokaoab9Rhwxekcbhwkarc;qwf8Kjjjjbawk5babaeadaialcdcbyd;i:I:cjbz:bjjjbk9reduaecd4gdaefgicaaica0Eabcj;abae9Uc;WFbGcjdaeca0Egifcufai9Uae2aiadfaicl4cifcd4f2fcefkmbcbabBd;i:I:cjbk;HPeLu8Jjjjjbc;ae9Rgl8Kjjjjbcbhvdnaeaici9UgocHf6mbabcbyd;m:I:cjbgrc;GeV86bbalc;abfcFecjez:xjjjb8Aal9cu83iUal9cu83i8Wal9cu83iyal9cu83iaal9cu83iKal9cu83izal9cu83iwal9cu83ibabaefc9WfhwabcefgDaofhednaiTmbcmcsarcb9kgqEhkcbhxcbhmcbhPcbhscbhzindnaeaw9nmbcbhvxikazcufhvadaPcdtfgHydbhOaHcwfydbhAaHclfydbhCcbhXdndndninalc;abfavcsGcitfgoydlhQdndndnaoydbgoaO9hmbaQaCSmekdnaoaC9hmbaQaA9hmbaXcefhXxekaoaA9hmeaQaO9hmeaXcdfhXkaXc870mdascufhvaHaXcdtgAcxGgoyd:4:G:cjbcdtfydbhQaHaoyd:0:G:cjbcdtfydbhCaHaoyd:W:G:cjbcdtfydbhOcbhodnindnalavcsGcdtfydbaQ9hmbaohXxdkcuhXavcufhvaocefgocz9hmbkkaxaQaxSgvaXce9iaXak9oVgoGfhxdndndncbcsavEaXaoEgvcs9hmbarce9imbaQaQamaQcefamSgvEgmcefSmecmcsavEhvkaDavaAc;WeGV86bbavcs9hmeaQam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaQhmxvkcPhvaDaAcPV86bbaQhmkavTmiavak9omicdhocehXazhAxlkavcufhvaXclfgXc;ab9hmbkkdnaHcecdcbaAaxSEaCaxSEcdtgvyd:W:G:cjbcdtfydbgOTaHavyd:0:G:cjbcdtfydbgCceSGaHavyd:4:G:cjbcdtfydbgQcdSGaxcb9hGaqGgLce9hmbal9cu83iUal9cu83i8Wal9cu83iyal9cu83iaal9cu83iKal9cu83izal9cu83iwal9cu83ibcbhxkcbhXascufgvhodnindnalaocsGcdtfydbaC9hmbaXhAxdkcuhAaocufhoaXcefgXcz9hmbkkcbhodnindnalavcsGcdtfydbaQ9hmbaohXxdkcuhXavcufhvaocefgocz9hmbkkaxaOaxSgKfhHdndnaAcm0mbaAcefhAxekcbcsaCaHSgvEhAaHavfhHkdndnaXcm0mbaXcefhXxekcbcsaQaHSgvEhXaHavfhHkc9:cuaKEhYcbhvaXaAcltVg8AcFeGhodndndninavc;q:G:cjbfRbbaoSmeavcefgvcz9hmbxdkkaLaOax9havcm0VVmbaDavc;WeV86bbxekaDaY86bbaea8A86bbaecefhekdnaKmbaOam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaOhmkdnaAcs9hmbaCam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaChmkdnaXcs9hmbaQam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaQhmkalascdtfaOBdbascefcsGhvdndnaAPzbeeeeeeeeeeeeeebekalavcdtfaCBdbascdfcsGhvkdndnaXPzbeeeeeeeeeeeeeebekalavcdtfaQBdbavcefcsGhvkcihoalc;abfazcitfgXaOBdlaXaCBdbazcefcsGhAcdhXavhsaHhxxekcdhoalascdtfaQBdbcehXascefcsGhsazhAkalc;abfaAcitfgvaCBdlavaQBdbalc;abfazaXfcsGcitfgvaQBdlavaOBdbaDcefhDazaofcsGhzaPcifgPai6mbkkdnaeaw9nmbcbhvxekcbhvinaeavfavc;q:G:cjbfRbb86bbavcefgvcz9hmbkaeab9Ravfhvkalc;aef8KjjjjbavkZeeucbhddninadcefgdc8F0meaeceadt0mbkkadcrfcFeGcr9Uci2cdfabci9U2cHfkmbcbabBd;m:I:cjbk:zderu8Jjjjjbcz9Rhlcbhvdnaeaicvf6mbabcbRb;m:I:cjbc;qeV86bbal9cb83iwabcefhvabaefc98fhodnaiTmbcbhecbhrcbhwindnavao6mbcbskadawcdtfydbgDalcwfaraDae9Rgeaec8F91ge7ae9Rc507grcdtfgqydb9Rgec8E91c9:Gaecdt7arVheinavcbcjeaecje6EaecFbGV86bbavcefhvaecr4gembkaqaDBdbaDheawcefgwai9hmbkkdnavao9nmbcbskavcbBbbavab9RclfhvkavkBeeucbhddninadcefgdc8F0meaeceadt0mbkkabadcwfcFeGcr9U2cvfk:dvli99dui99ludnaeTmbcuadcetcuftcu7:Zhvdndncuaicuftcu7:ZgoJbbbZMgr:lJbbb9p9DTmbar:Ohwxekcjjjj94hwkcbhicbhDinalclfIdbgrJbbbbJbbjZalIdbgq:lar:lMalcwfIdbgk:lMgr:varJbbbb9BEgrNhxaqarNhralcxfIdbhqdndnakJbbbb9GTmbaxhkxekJbbjZar:l:tgkak:maxJbbbb9GEhkJbbjZax:l:tgxax:marJbbbb9GEhrkdndnaqJbbj:;aqJbbj:;9GEgxJbbjZaxJbbjZ9FEavNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohmxekcjjjj94hmkdndnakJbbj:;akJbbj:;9GEgqJbbjZaqJbbjZ9FEaoNJbbbZJbbb:;akJbbbb9GEMgq:lJbbb9p9DTmbaq:OhPxekcjjjj94hPkdndnarJbbj:;arJbbj:;9GEgqJbbjZaqJbbjZ9FEaoNJbbbZJbbb:;arJbbbb9GEMgr:lJbbb9p9DTmbar:Ohsxekcjjjj94hskdndnadcl9hmbabaDfgzas86bbazcifam86bbazcdfaw86bbazcefaP86bbxekabaifgzas87ebazcofam87ebazclfaw87ebazcdfaP87ebkaicwfhiaDclfhDalczfhlaecufgembkkk;hlld99eud99eudnaeTmbdndncuaicuftcu7:ZgvJbbbZMgo:lJbbb9p9DTmbao:Ohixekcjjjj94hikaic;8FiGhrinabcofcicdalclfIdb:lalIdb:l9EgialcwfIdb:lalaicdtfIdb:l9EEgialcxfIdb:lalaicdtfIdb:l9EEgiarV87ebdndnJbbj:;JbbjZalaicdtfIdbJbbbb9DEgoalaicd7cdtfIdbJ;Zl:1ZNNgwJbbj:;awJbbj:;9GEgDJbbjZaDJbbjZ9FEavNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohqxekcjjjj94hqkabcdfaq87ebdndnalaicefciGcdtfIdbJ;Zl:1ZNaoNgwJbbj:;awJbbj:;9GEgDJbbjZaDJbbjZ9FEavNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohqxekcjjjj94hqkabaq87ebdndnaoalaicufciGcdtfIdbJ;Zl:1ZNNgoJbbj:;aoJbbj:;9GEgwJbbjZawJbbjZ9FEavNJbbbZJbbb:;aoJbbbb9GEMgo:lJbbb9p9DTmbao:Ohixekcjjjj94hikabclfai87ebabcwfhbalczfhlaecufgembkkk;Pviwue99eu8Jjjjjbcjd9Rgo8Kjjjjbadcd4hrdndndnavcd9hmbarTmbaohdarhwinadc:CuBdbadclfhdawcufgwmbkaeTmdarcdthDalhqcbhkinaohdaqhwarhxinadadydbgmcbawIdbgP:8cL4cFeGc:cufaPJbbbb9BEgsamas9kEBdbawclfhwadclfhdaxcufgxmbkaqaDfhqakcefgkae9hmbxdkkaeTmekarcdthqavce9hhDcbhkindndndnaDmbarTmdc:CuhwalhdarhxinawcbadIdbgP:8cL4cFeGc:cufaPJbbbb9BEgmawam9kEhwadclfhdaxcufgxmbxdkkdndndndnavPleddbdkarTmlaohdalhwarhxinadcbcbawIdbgP:8cL4cFeGgmc:cufgsasam0EaPJbbbb9BEBdbadclfhdawclfhwaxcufgxmbxikkarTmicbhdarhwinaoadfcbaladfIdbgP:8cL4cFeGgxc8Aaxc8A0Ec:cufaPJbbbb9BEBdbadclfhdawcufgwmbxdkkarTmdkc:CuhwkcbhdarhminawhxdnavceSmbaoadfydbhxkdndnaladfIdbgPcjjj;8iaxai9RcefgxcLt9R::NJbbbZJbbb:;aPJbbbb9GEMgP:lJbbb9p9DTmbaP:Ohsxekcjjjj94hskabadfascFFFrGaxcKtVBdbadclfhdamcufgmmbkkabaqfhbalaqfhlakcefgkae9hmbkkaocjdf8Kjjjjbk:Olveue99iue99iudnaeTmbceaicufthvcuaitcu7:Zhocbhradcl9hhwcbhDindndnalcwfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohixekcjjjj94hikdndnalIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkadai9Rcd9TgkaifhidndnalclfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkadai9Rcd9ThddndnalcxfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohxxekcjjjj94hxkadaifhiaxce91avVhxdndnawmbabaDfgmai86bbamcifax86bbamcdfad86bbamcefak86bbxekabarfgmai87ebamcofax87ebamclfad87ebamcdfak87ebkarcwfhraDclfhDalczfhlaecufgembkkk;mqdQui998Jjjjjbc:qd9Rgv8Kjjjjbavc:Sefcbc;Kbz:xjjjb8AdnadTmbaiTmbdndnabaeSmbaehoxekavcuadcdtgradcFFFFi0Ecbyd;q:I:cjbHjjjjbbgoBd:SeavceBd:mdaoaearz:wjjjb8AkavcbBd:Oeav9cb83i:Geavc:Gefaoadaiavc:Sefz:pjjjbavyd:Gehwadci9UgDcbyd;q:I:cjbHjjjjbbheavc:Sefavyd:mdgqcdtfaeBdbavaqcefgrBd:mdaecbaDz:xjjjbhkavc:SefarcdtfcuaicdtaicFFFFi0Ecbyd;q:I:cjbHjjjjbbgxBdbavaqcdfgmBd:mdalc;ebfhPawheaxhrinaralIdbaPaeydbgscwascw6EcdtfIdbMUdbaeclfhearclfhraicufgimbkavc:SefamcdtfcuaDcdtadcFFFF970Ecbyd;q:I:cjbHjjjjbbgmBdbdnadci6mbaoheamhraDhiinaraxaeydbcdtfIdbaxaeclfydbcdtfIdbMaxaecwfydbcdtfIdbMUdbaecxfhearclfhraicufgimbkkaqcifhzalc;ebfhHavc;qbfhOavheavyd:KehAavyd:OehCcbhscbhrcbhXcehQinaehLaoarcx2fgKydbhPaKclfydbhdabaXcx2fgecwfaKcwfydbgYBdbaeclfadBdbaeaPBdbakarfce86bbaOaYBdwaOadBdlaOaPBdbamarcdtfcbBdbcih8AdnasTmbaLhiinaOa8AcdtfaiydbgeBdba8AaeaY9haeaP9haead9hGGfh8AaiclfhiascufgsmbkkaXcefhXcbhsinaCaAaKascdtfydbcdtgifydbcdtfgYheawaifgdydbgPhidnaPTmbdninaeydbarSmeaeclfheaicufgiTmdxbkkaeaYaPcdtfc98fydbBdbadadydbcufBdbkascefgsci9hmbkdndndna8ATmbcuhrJbbbbhEcbhdavyd:KehYavyd:OehKindnawaOadcdtfydbcdtgsfydbgeTmbaxasfgiIdbh3aialcuadadcs0EcdtfclfIdbaHaecwaecw6EcdtfIdbMg5Udba5a3:th5aecdthiaKaYasfydbcdtfheinamaeydbgscdtfgPa5aPIdbMg3Udba3aEaEa39DgPEhEasaraPEhraeclfheaic98fgimbkkadcefgda8A9hmbkarcu9hmekaQaD9pmeindnakaQfRbbmbaQhrxdkaDaQcefgQ9hmbxdkka8Acza8Acz6EhsaOheaLhOarcu9hmekkazTmbaqcdtavc:Seffcwfheinaeydbcbyd;u:I:cjbH:bjjjbbaec98fheazcufgzmbkkavc:qdf8Kjjjjbk:0leoucuaicdtgvaicFFFFi0Egocbyd;q:I:cjbHjjjjbbhralalyd9GgwcdtfarBdbalawcefBd9GabarBdbaocbyd;q:I:cjbHjjjjbbhralalyd9GgocdtfarBdbalaocefBd9GabarBdlcuadcdtadcFFFFi0Ecbyd;q:I:cjbHjjjjbbhralalyd9GgocdtfarBdbalaocefBd9GabarBdwabydbcbavz:xjjjb8AabydbhraehladhvinaralydbcdtfgoaoydbcefBdbalclfhlavcufgvmbkcbhvabydlglhoarhwaihDinaoavBdbaoclfhoawydbavfhvawclfhwaDcufgDmbkadci9Uhqdnadcd9nmbabydwhocbhvinaecwfydbhwaeclfydbhDalaeydbcdtfgbabydbgbcefBdbaoabcdtfavBdbalaDcdtfgDaDydbgDcefBdbaoaDcdtfavBdbalawcdtfgwawydbgwcefBdbaoawcdtfavBdbaecxfheaqavcefgv9hmbkkinalalydbarydb9RBdbarclfhralclfhlaicufgimbkkQbabaeadaic;G:G:cjbz:ojjjbkQbabaeadaic;i:H:cjbz:ojjjbk9DeeuabcFeaicdtz:xjjjbhlcbhbdnadTmbindnalaeydbcdtfgiydbcu9hmbaiabBdbabcefhbkaeclfheadcufgdmbkkabk:3vioud9:du8Jjjjjbc;Wa9Rgl8Kjjjjbcbhvalcxfcbc;Kbz:xjjjb8AalcuadcitgoadcFFFFe0Ecbyd;q:I:cjbHjjjjbbgrBdxalceBd2araeadaicezNjjjbalcuaoadcjjjjoGEcbyd;q:I:cjbHjjjjbbgwBdzadcdthednadTmbabhiinaiavBdbaiclfhiadavcefgv9hmbkkawaefhDalabBdwalawBdl9cbhqindnadTmbaq9cq9:hkarhvaDhiadheinaiav8Pibak1:NcFrG87ebavcwfhvaicdfhiaecufgembkkalclfaq:NceGcdtfydbhxalclfaq9ce98gq:NceGcdtfydbhmalc;Wbfcbcjaz:xjjjb8AaDhvadhidnadTmbinalc;Wbfav8VebcdtfgeaeydbcefBdbavcdfhvaicufgimbkkcbhvcbhiinalc;WbfavfgeydbhoaeaiBdbaoaifhiavclfgvcja9hmbkadhvdndnadTmbinalc;WbfaDamydbgicetf8VebcdtfgeaeydbgecefBdbaxaecdtfaiBdbamclfhmavcufgvmbkaq9cv9smdcbhvinabawydbcdtfavBdbawclfhwadavcefgv9hmbxdkkaq9cv9smekkcwhvcbhiinalcxfavfc98fydbcbyd;u:I:cjbH:bjjjbbaiceGheclhvcehiaeTmbkalc;Waf8Kjjjjbk:Awliuo99iud9:cbhv8Jjjjjbca9Rgocbyd:4:I:cjbBdKaocb8Pd:W:I:cjb83izaocbyd;e:I:cjbBdwaocb8Pd:8:I:cjb83ibaicd4hrdndnadmbJFFuFhwJFFuuhDJFFuuhqJFFuFhkJFFuuhxJFFuFhmxekarcdthPaehsincbhiinaoczfaifgzasaifIdbgwazIdbgDaDaw9EEUdbaoaifgzawazIdbgDaDaw9DEUdbaiclfgicx9hmbkasaPfhsavcefgvad9hmbkaoIdKhDaoIdwhwaoIdChqaoIdlhkaoIdzhxaoIdbhmkdnadTmbJbbbbJbFu9hJbbbbamax:tgmamJbbbb9DEgmakaq:tgkakam9DEgkawaD:tgwawak9DEgw:vawJbbbb9BEhwdnalmbarcdthoindndnaeclfIdbaq:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:S9cC:ghHdndnaeIdbax:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikaHai:S:ehHdndnaecwfIdbaD:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabaHai:T9cy:g:e83ibaeaofheabcwfhbadcufgdmbxdkkarcdthoindndnaeIdbax:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cv9:9c;j:KM;j:KM;j:Kd:dhOdndnaeclfIdbaq:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cq9:9cM;j:KM;j:KM;jl:daO:ehOdndnaecwfIdbaD:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabaOai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cC9:9c:KM;j:KM;j:KMD:d:e83ibaeaofheabcwfhbadcufgdmbkkk9teiucbcbyd;y:I:cjbgeabcifc98GfgbBd;y:I:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd;y:I:cjbgeabcrfc94GfgbBd;y:I:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd;y:I:cjbge9Rcifc98GaefgbBd;y:I:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akkk;Sddbcj:Gdk;idbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbbbbbbbbbbbbbbbbebbbdbbbbbbbebbbbbbbbbbbbbbbb4:h9w9N94:P:gW:j9O:ye9Pbbbbbb:l29hZ;69:9kZ;N;76Z;rg97Z;z;o9xZ8J;B85Z;:;u9yZ;b;k9HZ:2;Z9DZ9e:l9mZ59A8KZ:r;T3Z:A:zYZ79OHZ;j4::8::Y:D9V8:bbbb9s:49:Z8R:hBZ9M9M;M8:L;z;o8:;8:PG89q;x:J878R:hQ8::M:B;e87bbbbbbjZbbjZbbjZ:E;V;N8::Y:DsZ9i;H;68:xd;R8:;h0838:;W:NoZbbbb:WV9O8:uf888:9i;H;68:9c9G;L89;n;m9m89;D8Ko8:bbbbf:8tZ9m836ZS:2AZL;zPZZ818EZ9e:lxZ;U98F8:819E;68:FFuuFFuuFFuuFFuFFFuFFFuFbc;i:IdkCebbbebbbebbbdbbb9G:rbb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,i=WebAssembly.instantiate(r(e),{}).then(function(h){n=h.instance,n.exports.__wasm_call_ctors(),n.exports.meshopt_encodeVertexVersion(1),n.exports.meshopt_encodeIndexVersion(1)});function r(h){var y=new Uint8Array(h.length);for(var g=0;g<h.length;++g){var m=h.charCodeAt(g);y[g]=m>96?m-97:m>64?m-39:m+4}var p=0;for(var g=0;g<h.length;++g)y[p++]=y[g]<60?t[y[g]]:(y[g]-60)*64+y[++g];return y.buffer.slice(0,p)}function s(h){if(!h)throw Error("Assertion failed")}function a(h){return new Uint8Array(h.buffer,h.byteOffset,h.byteLength)}function o(h,y,g,m){var p=n.exports.sbrk,b=p(y.length*4),_=p(g*4),x=new Uint8Array(n.exports.memory.buffer),v=a(y);if(x.set(v,b),m)m(b,b,y.length,g);var E=h(_,b,y.length,g);x=new Uint8Array(n.exports.memory.buffer);var S=new Uint32Array(g);new Uint8Array(S.buffer).set(x.subarray(_,_+g*4)),v.set(x.subarray(b,b+y.length*4)),p(b-p(0));for(var T=0;T<y.length;++T)y[T]=S[y[T]];return[S,E]}function c(h,y,g,m){var p=n.exports.sbrk,b=p(g*4),_=p(g*m),x=new Uint8Array(n.exports.memory.buffer);x.set(a(y),_),h(b,_,g,m),x=new Uint8Array(n.exports.memory.buffer);var v=new Uint32Array(g);return new Uint8Array(v.buffer).set(x.subarray(b,b+g*4)),p(b-p(0)),v}function l(h,y,g,m,p,b,_){var x=n.exports.sbrk,v=x(y),E=x(m*p),S=new Uint8Array(n.exports.memory.buffer);S.set(a(g),E);var T=h(v,y,E,m,p,b,_),A=new Uint8Array(T);return A.set(S.subarray(v,v+T)),x(v-x(0)),A}function u(h){var y=0;for(var g=0;g<h.length;++g){var m=h[g];y=y<m?m:y}return y}function d(h,y){if(s(y==2||y==4),y==4)return new Uint32Array(h.buffer,h.byteOffset,h.byteLength/4);else{var g=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/2);return new Uint32Array(g)}}function f(h,y,g,m,p,b,_){var x=n.exports.sbrk,v=x(g*m),E=x(g*b),S=new Uint8Array(n.exports.memory.buffer);S.set(a(y),E),h(v,g,m,p,E,_);var T=new Uint8Array(g*m);return T.set(S.subarray(v,v+g*m)),x(v-x(0)),T}return{ready:i,supported:!0,reorderMesh:function(h,y,g){s(h instanceof Uint32Array||h instanceof Int32Array),s(!y||h.length%3==0);var m=y?g?n.exports.meshopt_optimizeVertexCacheStrip:n.exports.meshopt_optimizeVertexCache:void 0;return o(n.exports.meshopt_optimizeVertexFetchRemap,h,u(h)+1,m)},reorderPoints:function(h,y){return s(h instanceof Float32Array),s(h.length%y==0),s(y>=3),c(n.exports.meshopt_spatialSortRemap,h,h.length/y,y*4)},encodeVertexBuffer:function(h,y,g){s(g>0&&g<=256),s(g%4==0);var m=n.exports.meshopt_encodeVertexBufferBound(y,g);return l(n.exports.meshopt_encodeVertexBuffer,m,h,y,g)},encodeVertexBufferLevel:function(h,y,g,m,p){s(g>0&&g<=256),s(g%4==0),s(m>=0&&m<=3),s(p===void 0||p==0||p==1);var b=n.exports.meshopt_encodeVertexBufferBound(y,g);return l(n.exports.meshopt_encodeVertexBufferLevel,b,h,y,g,m,p===void 0?-1:p)},encodeIndexBuffer:function(h,y,g){s(g==2||g==4),s(y%3==0);var m=d(h,g),p=n.exports.meshopt_encodeIndexBufferBound(y,u(m)+1);return l(n.exports.meshopt_encodeIndexBuffer,p,m,y,4)},encodeIndexSequence:function(h,y,g){s(g==2||g==4);var m=d(h,g),p=n.exports.meshopt_encodeIndexSequenceBound(y,u(m)+1);return l(n.exports.meshopt_encodeIndexSequence,p,m,y,4)},encodeGltfBuffer:function(h,y,g,m,p){var b={ATTRIBUTES:this.encodeVertexBufferLevel,TRIANGLES:this.encodeIndexBuffer,INDICES:this.encodeIndexSequence};return s(b[m]),b[m](h,y,g,2,p===void 0?0:p)},encodeFilterOct:function(h,y,g,m){return s(g==4||g==8),s(m>=2&&m<=16),f(n.exports.meshopt_encodeFilterOct,h,y,g,m,16)},encodeFilterQuat:function(h,y,g,m){return s(g==8),s(m>=4&&m<=16),f(n.exports.meshopt_encodeFilterQuat,h,y,g,m,16)},encodeFilterExp:function(h,y,g,m,p){s(g>0&&g%4==0),s(m>=1&&m<=24);var b={Separate:0,SharedVector:1,SharedComponent:2,Clamped:3};return s(!p||p in b),f(n.exports.meshopt_encodeFilterExp,h,y,g,m,g,p?b[p]:1)},encodeFilterColor:function(h,y,g,m){return s(g==4||g==8),s(m>=2&&m<=16),f(n.exports.meshopt_encodeFilterColor,h,y,g,m,16)}}}()});var DK;var kM=Ft(()=>{DK=function(){var e="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq:VZkdbk:XYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbh5dnawTmbaxa8Acd4fRbbh5kcbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q:G:cjbfcj:G:cjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bwar9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfcbaicdfa8J9c8N1:NfghRbbag9cjjjjjw:dg8J9qE86bbarcVfcbaha8J9c8M1:NfghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fcbaha8J9c8N1:NfgiRbbag9cjjjjjw:dg8J9qE86bbarc96fcbaia8J9c8M1:NfgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbw83bwarai8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbaocl4h8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E94aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:ysezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8Aav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk:4ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxalarcefciGcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGgkfcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkalarcufciGcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkalakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K:G:cjbgeabcifc98GfgbBd:K:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk83dbcj:Gdk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:K:Gdkl8W:qbb",t="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:W9Dklbzik94evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaeai86b:q:W:cjbaecitab8Piw83i:q:G:cjbaecefgecjd9hmbkk:JBl8Aud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaialfgxar9RhodnadTgmmbavaoad;8qbbkaicefhPcj;abad9Uc;WFbGcjdadca0EhsdndndnadTmbaoadfhzcbhHinaeaH9nmdaxaP9RaD6miabaHad2fhOaPaDfhAasaeaH9RaHasfae6EgCcsfgocl4cifcd4hXavcj;cbfaoc9WGgQcetfhLavcj;cbfaQci2fhKavcj;cbfaQfhYcbh8Aaoc;ab6hEincbh3dnawTmbaPa8Acd4fRbbh3kcbh5avcj;cbfh8Eindndndndna3a5cet4ciGgoc9:fPdebdkaxaA9RaQ6mwdnaQTmbavcj;cbfa5aQ2faAaQ;8qbbkaAaCfhAxdkaQTmeavcj;cbfa5aQ2fcbaQ;8kbxekaxaA9RaX6moaoclVcbawEhraAaXfhocbhidnaEmbaxao9Rc;Gb6mbcbhlina8EalfhidndndndndndnaAalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiczfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaicafaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaoclffaqRb:q:W:cjbfhoxikaic8Wfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaocwffaqRb:q:W:cjbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitpbi:q:G:cjbaiRb:q:W:cjbgipsaoRbegqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqRb:q:W:cjbfhokalc;abfhialcjefaQ0meaihlaxao9Rc;Fb0mbkkdnaiaQ9pmbaici4hlinaxao9RcK6mwa8EaifhqdndndndndndnaAaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaoclffagRb:q:W:cjbfhoxikaqaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaocwffagRb:q:W:cjbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpkbbahaocdffagRb:q:W:cjbfhokalcdfhlaiczfgiaQ6mbkkaohAaoTmoka8EaQfh8Ea5cefg5cl9hmbkdndndndnawTmbaza8Acd4fRbbglciGPlbedwbkaQTmdavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep9Ta8Fpxeeeeeeeeeeeeeeeegap9op9Hp9rg8Fa8Jp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ugap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp9Ugap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp9Ugap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9AbbbaladfhlaoczfgoaQ6mbxikkaQTmeavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep:nea8Fpxebebebebebebebebgap9op:bep9rg8Fa8Jp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oegap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp:oegap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp:oegap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9AbbbaladfhlaoczfgoaQ6mbxdkkaQTmbcbhocbalcl4gl9Rc8FGhiavcjdfa8Afhrava8Afpbdbhainaravcj;cbfaofpblbg8JaYaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaLaofpblbg8MaKaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Faap9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8LaypmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9AbbbaradfhraoczfgoaQ6mbkka8Aclfg8Aad6mbkdnaCad2goTmbaOavcjdfao;8qbbkdnammbavavcjdfaCcufad2fad;8qbbkaCaHfhHc9:hoaAhPaAmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdasaeao9Raoasfae6Eaofgoae6mbkaial9RhPkcbc99axaP9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbkNsezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk;Toio97eue97aec98Ghedndnadcl9hmbaeTmecbhdinababpbbbgicKp:RecKp:Sep;6eglaicwp:RecKp:Sep;6ealp;Geaiczp:RecKp:Sep;6egvp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgwp9op9rp;Keglpxbb;:9cbb;:9cbb;:9cbb;:9calalp;Meaoaop;Meavaravawp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFbbbFbbbFbbbFbbbp9oaipxbbbFbbbFbbbFbbbFp9op9qalavp;Mearp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaoavp;Mearp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgDaDpbbbgipxbbbbbbFFbbbbbbFFgwp9oabpbbbgoaipmbediwDqkzHOAKY8AEgvczp:Reczp:Sep;6eglaoaipmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eavczp:Sep;6egvp;Gealp;Gep;Kep;Legipxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgqp9op9rp;Keglpxb;:FSb;:FSb;:FSb;:FSalalp;Meaiaip;Meavaravaqp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbp9oaiavp;Mearp;Keczp:Rep9qgialavp;Mearp;KepxFFbbFFbbFFbbFFbbp9oglpmwDKYqk8AExm35Ps8E8Fp9qpkbbabaoawp9oaialpmbezHdiOAlvCXorQLp9qpkbbabcafhbadclfgdae6mbkkk;2ileue97euo97dnaec98GgiTmbcbheinabcKfpx:ji:1S:ji:1S:ji:1S:ji:1SabpbbbglabczfgvpbbbgopmlvorxmPsCXQL358E8Fgrczp:Segwpxibbbibbbibbbibbbp9qp;6egDp;NegqaDaDp;MegDaDp;KealaopmbediwDqkzHOAKY8AEgDczp:Reczp:Sep;6eglalp;MeaDczp:Sep;6egoaop;Mearczp:Reczp:Sep;6egrarp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gDp;KepxFFbbFFbbFFbbFFbbgkp9oaqaop;MeaDp;Keczp:Rep9qgoaqalp;MeaDp;Keakp9oaqarp;MeaDp;Keczp:Rep9qgDpmwDKYqk8AExm35Ps8E8Fglp5eawclp:RegqpEi:T:j83ibavalp5baqpEd:T:j83ibabcwfaoaDpmbezHdiOAlvCXorQLgDp5eaqpEe:T:j83ibabaDp5baqpEb:T:j83ibabcafhbaeclfgeai6mbkkkuee97dnadcd4ae2c98GgeTmbcbhdinababpbbbgicwp:Recwp:Sep;6eaicep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbabczfhbadclfgdae6mbkkk:Sodw97euaec98Ghedndnadcl9hmbaeTmecbhdinabpxbbuJbbuJbbuJbbuJabpbbbgicKp:TeglaicYp:Tep9qgvcdp:Teavp9qgvclp:Teavp9qgop;6ep;Negvaicwp:RecKp:SegraipxFbbbFbbbFbbbFbbbgwp9ogDp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oavaDarp:Xeaiczp:RecKp:Segip:Uep;6ep;Meaqp;Keawp9op9qavaDaraip:Uep:Xep;6ep;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qavaoalcep:Rep9oalpxebbbebbbebbbebbbp9op9qp;6ep;Meaqp;KecKp:Rep9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgkpxbFu9hbFu9hbFu9hbFu9habpbbbglakpbbbgrpmlvorxmPsCXQL358E8Fgvczp:TegqavcHp:Tep9qgicdp:Teaip9qgiclp:Teaip9qgicwp:Teaip9qgop;6ep;NegialarpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbglp9ograDczp:Segwp:Ueavczp:Reczp:SegDp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gvp;Kealp9oaiarawaDp:Uep:Xep;6ep;Meavp;Keczp:Rep9qgwaiaoaqcep:Rep9oaqpxebbbebbbebbbebbbp9op9qp;6ep;Meavp;Keczp:ReaiaDarp:Uep;6ep;Meavp;Kealp9op9qgipmwDKYqk8AExm35Ps8E8FpkbbabawaipmbezHdiOAlvCXorQLpkbbabcafhbadclfgdae6mbkkk9teiucbcbydj:G:cjbgeabcifc98GfgbBdj:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkxebcj:Gdklz:zbb",n=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),i=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var r=WebAssembly.validate(n)?o(t):o(e),s,a=WebAssembly.instantiate(r,{}).then(function(p){s=p.instance,s.exports.__wasm_call_ctors()});function o(p){var b=new Uint8Array(p.length);for(var _=0;_<p.length;++_){var x=p.charCodeAt(_);b[_]=x>96?x-97:x>64?x-39:x+4}var v=0;for(var _=0;_<p.length;++_)b[v++]=b[_]<60?i[b[_]]:(b[_]-60)*64+b[++_];return b.buffer.slice(0,v)}function c(p,b,_,x,v,E,S){var T=p.exports.sbrk,A=x+3&-4,P=T(A*v),w=T(E.length),I=new Uint8Array(p.exports.memory.buffer);I.set(E,w);var F=b(P,x,v,w,E.length);if(F==0&&S)S(P,A,v);if(_.set(I.subarray(P,P+x*v)),T(P-T(0)),F!=0)throw Error("Malformed buffer data: "+F)}var l={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp",COLOR:"meshopt_decodeFilterColor"},u={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},d=[],f=0;function h(p){var b={object:new Worker(p),pending:0,requests:{}};return b.object.onmessage=function(_){var x=_.data;b.pending-=x.count,b.requests[x.id][x.action](x.value),delete b.requests[x.id]},b}function y(p){var b="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(r)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+m.name+";"+c.toString()+m.toString(),_=new Blob([b],{type:"text/javascript"}),x=URL.createObjectURL(_);for(var v=d.length;v<p;++v)d[v]=h(x);for(var v=p;v<d.length;++v)d[v].object.postMessage({});d.length=p,URL.revokeObjectURL(x)}function g(p,b,_,x,v){var E=d[0];for(var S=1;S<d.length;++S)if(d[S].pending<E.pending)E=d[S];return new Promise(function(T,A){var P=new Uint8Array(_),w=++f;E.pending+=p,E.requests[w]={resolve:T,reject:A},E.object.postMessage({id:w,count:p,size:b,source:P,mode:x,filter:v},[P.buffer])})}function m(p){var b=p.data;self.ready.then(function(_){if(!b.id)return self.close();try{var x=new Uint8Array(b.count*b.size);c(_,_.exports[b.mode],x,b.count,b.size,b.source,_.exports[b.filter]),self.postMessage({id:b.id,count:b.count,action:"resolve",value:x},[x.buffer])}catch(v){self.postMessage({id:b.id,count:b.count,action:"reject",value:v})}})}return{ready:a,supported:!0,useWorkers:function(p){y(p)},decodeVertexBuffer:function(p,b,_,x,v){c(s,s.exports.meshopt_decodeVertexBuffer,p,b,_,x,s.exports[l[v]])},decodeIndexBuffer:function(p,b,_,x){c(s,s.exports.meshopt_decodeIndexBuffer,p,b,_,x)},decodeIndexSequence:function(p,b,_,x){c(s,s.exports.meshopt_decodeIndexSequence,p,b,_,x)},decodeGltfBuffer:function(p,b,_,x,v,E){c(s,s.exports[u[v]],p,b,_,x,s.exports[l[E]])},decodeGltfBufferAsync:function(p,b,_,x,v){if(d.length>0)return g(p,b,_,u[x],l[v]);return a.then(function(){var E=new Uint8Array(p*b);return c(s,s.exports[u[x]],E,p,b,_,s.exports[l[v]]),E})}}}()});var FK;var DM=Ft(()=>{FK=function(){var e="b9H79Tebbbe:6eO9Geueu9Geub9Gbb9Gsuuuuuuuuuuuu99uueu9Gvuuuuub9Gruuuuuuub9Gouuuuuue999Gvuuuuueu9Gzuuuuuuuuuuu99uuuub9Gquuuuuuu99uueu9GPuuuuuuuuuuu99uueu9Gquuuuuuuu99ueu9Gruuuuuu99eu9Gwuuuuuu99ueu9Giuuue999Gluuuueu9Gluuuub9GiuuueuiLQdilvorlwDiqkxmPszbHHbelve9Weiiviebeoweuecj:Gdkr:Bdxo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bbz9TW79O9V9Wt9F79P9T9W29P9M95bw8E9TW79O9V9Wt9F79P9T9W29P9M959x9Pt9OcttV9P9I91tW7bD8A9TW79O9V9Wt9F79P9T9W29P9M959x9Pt9O9v9W9K9HtWbqQ9TW79O9V9Wt9F79P9T9W29P9M959t29V9W9W95bkX9TW79O9V9Wt9F79P9T9W29P9M959qV919UWbxQ9TW79O9V9Wt9F79P9T9W29P9M959q9V9P9Ut7bmX9TW79O9V9Wt9F79P9T9W29P9M959t9J9H2WbPa9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94SWt9J9O9sW9T9H9Wbs59TW79O9V9Wt9F9NW9UWV9HtW9q9V79Pt9P9V9U9sW9T9H9Wbzl79IV9RbHDwebcekdCXq;y;WeQdbk;r:herYue99iuY99Xue9:D998Jjjjjbcj;sb9Rgs8Kjjjjbcbhzasc:Cefcbc;Kbz:tjjjb8AdnabaeSmbabaeadcdtzMjjjb8AkdnamcdGTmbalcrfci4cbyd1:H:cjbHjjjjbbhHasc:Cefasyd;8egecdtfaHBdbasaecefBd;8ecbhlcbhednadTmbabheadhOinaHaeydbci4fcb86bbaeclfheaOcufgOmbkcbhlabheadhOinaHaeydbgAci4fgCaCRbbgCceaAcrGgAtV86bbaCcu7aA4ceGalfhlaeclfheaOcufgOmbkcualcdtalcFFFFi0Ehekaecbyd1:H:cjbHjjjjbbhzasc:Cefasyd;8egecdtfazBdbasaecefBd;8ealcd4alfhOcehHinaHgecethHaeaO6mbkcbhXcuaecdtgOaecFFFFi0Ecbyd1:H:cjbHjjjjbbhHasc:Cefasyd;8egAcdtfaHBdbasaAcefBd;8eaHcFeaOz:tjjjbhQdnadTmbaecufhLcbhKindndnaQabaKcdtfgYydbgAc:v;t;h;Ev2aLGgOcdtfgCydbgHcuSmbceheinazaHcdtfydbaASmdaOaefhHaecefheaQaHaLGgOcdtfgCydbgHcu9hmbkkazaXcdtfaABdbaCaXBdbaXhHaXcefhXkaYaHBdbaKcefgKad9hmbkkaQcbyd:m:H:cjbH:bjjjbbasasyd;8ecufBd;8ekcbh8AcualcefgecdtaecFFFFi0Ecbyd1:H:cjbHjjjjbbhLasc:Cefasyd;8egecdtfaLBdbasaLBdNeasaecefBd;8ecuadcitadcFFFFe0Ecbyd1:H:cjbHjjjjbbhEasc:Cefasyd;8egecdtfaEBdbasaEBd:yeasaecefBd;8eascNefabadalcbz:cjjjbcualcdtgealcFFFFi0Eg3cbyd1:H:cjbHjjjjbbhOasc:Cefasyd;8egHcdtfaOBdbasaHcefBd;8ea3cbyd1:H:cjbHjjjjbbhQasc:Cefasyd;8egHcdtfaQBdbasaHcefBd;8eaOaQaialavazasc:Cefz:djjjbalcbyd1:H:cjbHjjjjbbhYasc:Cefasyd;8egHcdtfaYBdbasaHcefBd;8ea3cbyd1:H:cjbHjjjjbbhHasc:Cefasyd;8egAcdtfaHBdbasaAcefBd;8ea3cbyd1:H:cjbHjjjjbbhAasc:Cefasyd;8egCcdtfaABdbasaCcefBd;8eaHcFeaez:tjjjbh5aAcFeaez:tjjjbh8EdnalTmbindnaLa8AgAcefg8AcdtfydbgCaLaAcdtgefydbgHSmbaCaH9Rh8FaEaHcitfhaa8Eaefhha5aefhKcbhCindndnaaaCcitfydbgXaA9hmbaKaABdbahaABdbxekdnaLaXcdtggfgeclfydbgHaeydbgeSmbaHae9RhHaEaecitfheinaeydbaASmdaecwfheaHcufgHmbkka8EagfgeaAaXaeydbcuSEBdbaKaXaAaKydbcuSEBdbkaCcefgCa8F9hmbkka8Aal9hmbkaOhHaQhAa5hXa8EhCcbheindndnaeaHydbgK9hmbdnaeaAydbgK9hmbaXydbhKdnaCydbg8Fcu9hmbaKcu9hmbaYaefcb86bbxikdna8FcuSmbaKcuSmbaea8FSmbaOa8FcdtfydbaOaKcdtfydb9hmbaYaefcd86bbxikaYaefhadnaea8FSmbaeaKSmbaace86bbxikaacl86bbxdkdnaeaQaKcdtg8Ffydb9hmbdnaCydbgacuSmbaeaaSmbaXydbggcuSmbaeagSmba8Ea8FfydbghcuSmbahaKSmba5a8Ffydbg8FcuSmba8FaKSmbdnaOaacdtfydbgKaOa8Fcdtfydb9hmbaKaOagcdtfydbg8FSmba8FaOahcdtfydb9hmbaYaefcd86bbxlkaYaefcl86bbxikaYaefcl86bbxdkaYaefcl86bbxekaYaefaYaKfRbb86bbkaHclfhHaAclfhAaXclfhXaCclfhCalaecefge9hmbkdnamcaGTmbcbh8JindndnaYa8Jfg8KRbbg8Lc9:fPibebekdndndnaOa8Jcdtfydbgea8J9hmbdnaqmbcbh8FxdkdnazTmbcbh8Fa8JheinaqazaecdtgefydbfRbbce4a8FVceGh8FaQaefydbgea8J9hmbxikkcbh8Fa8JheinaqaefRbbce4a8FVceGh8FaQaecdtfydbgea8J9hmbxdkkaYaefRbbhexeka8JheindnaLaecdtg8AfgeclfydbgHaeydbgeSmbaHae9RhgaEaecitfhhaOa8AfhacbhKinahaKcitfydbgXhednindnaLaecdtgCfgeclfydbgHaeydbgeSmbaHae9RhHaEaecitfheaaydbhAdninaOaeydbcdtfydbaASmeaecwfheaHcufgHTmdxbkkcbhexdkaQaCfydbgeaX9hmbkceheka8FaeVh8FaKcefgKag9hmbkkaQa8Afydbgea8J9hmbka8Lcia8FceGEheka8Kae86bbka8Jcefg8Jal9hmbkkdnaqTmbdndnazTmbazheaOhHalhAindnaqaeydbfRbbceGTmbaYaHydbfcl86bbkaeclfheaHclfhHaAcufgAmbxdkkaqheaOhHalhAindnaeRbbceGTmbaYaHydbfcl86bbkaecefheaHclfhHaAcufgAmbkkaOhealhAaYhHindnaYaeydbfRbbcl9hmbaHcl86bbkaeclfheaHcefhHaAcufgAmbkkamceGTmbaYhealhHindnaeRbbce9hmbaecl86bbkaecefheaHcufgHmbkkcbh8Mcualcx2alc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbh8Nasc:Cefasyd;8egecdtfa8NBdbasaecefBd;8eascbBd:qeas9cb83i1ea8Naialavazasc1efz:ejjjbhydndnaDmbcbh8PcbhCxekcbhCawhecbhHindnaeIdbJbbbb9ETmbasaCcdtfaHBdbaCcefhCkaeclfheaDaHcefgH9hmbkcuaCal2gecdtaecFFFFi0Ecbyd1:H:cjbHjjjjbbh8Pasc:Cefasyd;8egecdtfa8PBdbasaecefBd;8ealTmbdnaCmbcbhCxekarcd4hgdnazTmbaCcdthhcbh8Fa8Phainaoaza8Fcdtfydbag2cdtfhKasheaahHaChAinaHaKaeydbcdtgXfIdbawaXfIdbNUdbaeclfheaHclfhHaAcufgAmbkaaahfhaa8Fcefg8Fal9hmbxdkkaCcdthhcbh8Fa8Phainaoa8Fag2cdtfhKasheaahHaChAinaHaKaeydbcdtgXfIdbawaXfIdbNUdbaeclfheaHclfhHaAcufgAmbkaaahfhaa8Fcefg8Fal9hmbkkcualc8S2gHalc;D;O;f8U0EgXcbyd1:H:cjbHjjjjbbheasc:Cefasyd;8egAcdtfaeBdbasaAcefBd;8eaecbaHz:tjjjbhIcbh8RcbhgdnaCTmbcbh8MaXcbyd1:H:cjbHjjjjbbhgasc:Cefasyd;8egecdtfagBdbasaecefBd;8eagcbaHz:tjjjb8AcuaCal2gecltgHaecFFFFb0Ecbyd1:H:cjbHjjjjbbh8Rasc:Cefasyd;8egecdtfa8RBdbasaecefBd;8ea8RcbaHz:tjjjb8AamcjjjjdGTmbcualcltgealcFFFFb0Ecbyd1:H:cjbHjjjjbbh8Masc:Cefasyd;8egHcdtfa8MBdbasaHcefBd;8ea8Mcbaez:tjjjb8AkdnadTmbcbhKabhHina8NaHclfydbg8Fcx2fgeIdba8NaHydbgacx2fgAIdbg8S:tgRa8NaHcwfydbghcx2fgXIdlaAIdlg8U:tg8VNaeIdla8U:tg8WaXIdba8S:tg8XN:tg8Ya8YNa8WaXIdwaAIdwg8Z:tg80NaeIdwa8Z:tg8Wa8VN:tg81a81Na8Wa8XNaRa80N:tg80a80NMMg8V:rhBa8Yh8Xa80h8Wa81hRdna8VJbbbb9EgATmba8YaB:vh8Xa80aB:vh8Wa81aB:vhRkaIaOaacdtfydbgXc8S2fgeaRaB:rg8VaRNNg83aeIdbMUdbaea8Wa8Va8WNgUNg85aeIdlMUdlaea8Xa8Va8XNg86Ng87aeIdwMUdwaeaRaUNgUaeIdxMUdxaea86aRNg88aeIdzMUdzaea8Wa86Ng89aeIdCMUdCaeaRa8Va8Xa8ZNaRa8SNa8Ua8WNMM:mg8:Ng86NgRaeIdKMUdKaea8Wa86Ng8WaeId3MUd3aea8Xa86Ng8XaeIdaMUdaaea86a8:Ng86aeId8KMUd8Kaea8VaeIdyMUdyaIaOa8Fcdtfydbg8Fc8S2fgea83aeIdbMUdbaea85aeIdlMUdlaea87aeIdwMUdwaeaUaeIdxMUdxaea88aeIdzMUdzaea89aeIdCMUdCaeaRaeIdKMUdKaea8WaeId3MUd3aea8XaeIdaMUdaaea86aeId8KMUd8Kaea8VaeIdyMUdyaIaOahcdtfydbgac8S2fgea83aeIdbMUdbaea85aeIdlMUdlaea87aeIdwMUdwaeaUaeIdxMUdxaea88aeIdzMUdzaea89aeIdCMUdCaeaRaeIdKMUdKaea8WaeId3MUd3aea8XaeIdaMUdaaea86aeId8KMUd8Kaea8VaeIdyMUdydna8MTmbdnaATmba8YaB:vh8Ya80aB:vh80a81aB:vh81ka8MaXcltfgeaBJbbbZNgRa80Ng8VaeIdlMUdlaeaRa8YNg8WaeIdwMUdwaeaRa81Ng8XaeIdbMUdbaeaRa8S:ma81Na8Ua80N:ta8Za8YN:tNgRaeIdxMUdxa8Ma8Fcltfgea8VaeIdlMUdlaea8WaeIdwMUdwaea8XaeIdbMUdbaeaRaeIdxMUdxa8Maacltfgea8VaeIdlMUdlaea8WaeIdwMUdwaea8XaeIdbMUdbaeaRaeIdxMUdxkaHcxfhHaKcifgKad6mbkkdnalTmbJq;x8J88J;n;m;m89J:v:;;w8ZamczGEamc;abGEh80cbhHaOhXazhKaIhea8NhAindnaHaXydb9hmbaHh8FdnazTmbaKydbh8Fka80hRdnaqTmbJbbjZa80aqa8FfRbbclGEhRkaecxfg8Fa8FIdbJbbbbMUdbaeczfg8Fa8FIdbJbbbbMUdbaecCfg8Fa8FIdbJbbbbMUdbaeaRaecyfg8FIdbg8YNgRaeIdbMUdbaeclfgaaRaaIdbMUdbaecwfgaaRaaIdbMUdbaecKfgaaaIdbaAIdbg8WaRN:tUdbaAcwfIdbh8Vaec3fgaaaIdbaRaAclfIdbg8XN:tUdbaecafgaaaIdbaRa8VN:tUdbaec8KfgaIdbh81a8Fa8YaRMUdbaaa81aRa8Va8VNa8Wa8WNa8Xa8XNMMNMUdbkaXclfhXaKclfhKaec8SfheaAcxfhAalaHcefgH9hmbkkdnadTmbcbh8Aabhainaba8Acdtfh8FcbhHinaYa8FaHc:G:G:cjbfydbcdtfydbgAfRbbhedndnaYaaaHfydbgXfRbbgKc99fcFeGcpe0mbaec99fcFeGc;:e6mekdnaKcufcFeGce0mba5aXcdtfydbaA9hmekdnaecufcFeGce0mba8EaAcdtfydbaX9hmekJbbacJbbacJbbbZaecFeGceSEaKcFeGceSEhUdna8Na8FaHc:K:G:cjbfydbcdtfydbcx2fgeIdwa8NaXcx2fgKIdwg86:tg8Sa8NaAcx2fghIdwa86:tg8Xa8XNahIdbaKIdbg8U:tg80a80NahIdlaKIdlg8Z:tg8Va8VNMMg81Na8Xa8Sa8XNaeIdba8U:tg83a80Na8VaeIdla8Z:tg85NMMg8WN:tg8Ya8YNa83a81Na80a8WN:tgRaRNa85a81Na8Va8WN:tg8Wa8WNMMgBJbbbb9ETmba8YaB:rgB:vh8Ya8WaB:vh8WaRaB:vhRkaUa81:rNgBa8Ya86NaRa8UNa8Za8WNMM:mg81Ng87a81Nh88a80a85Na8Va83N:tg81a81Na8Va8SNa8Xa85N:tg8Va8VNa8Xa83Na80a8SN:tg8Xa8XNMMg83:rh80a8Ya87Nh85a8Wa87Nh89aRa87Nh87a8WaBa8YNg8SNh8:a8SaRNhZaRaBa8WNgnNhca8Ya8SNh8Ya8WanNh8WaRaBaRNNh8Sdna83Jbbbb9ETmba81a80:vh81a8Xa80:vh8Xa8Va80:vh8VkaIaOaXcdtfydbc8S2fgeaeIdba8Sa8VaUa80:rNgRa8VNNMg80MUdbaea8Wa8XaRa8XNg8SNMg83aeIdlMUdlaea8Ya81aRa81Ng8WNMg8YaeIdwMUdwaeaca8Va8SNMg8SaeIdxMUdxaeaZa8Wa8VNMgUaeIdzMUdzaea8:a8Xa8WNMg8WaeIdCMUdCaea87a8VaRa81a86Na8Va8UNa8Za8XNMMg86:mNgRNMg8VaeIdKMUdKaea89a8XaRNMg8XaeId3MUd3aea85a81aRNMg81aeIdaMUdaaea88a86aRN:tgRaeId8KMUd8KaeaBaeIdyMUdyaIaOaAcdtfydbc8S2fgea80aeIdbMUdbaea83aeIdlMUdlaea8YaeIdwMUdwaea8SaeIdxMUdxaeaUaeIdzMUdzaea8WaeIdCMUdCaea8VaeIdKMUdKaea8XaeId3MUd3aea81aeIdaMUdaaeaRaeId8KMUd8KaeaBaeIdyMUdykaHclfgHcx9hmbkaacxfhaa8Acifg8Aad6mbkaCTmbcbhainJbbbbh80a8Nabaacdtfgeclfydbg8Fcx2fgHIdwa8Naeydbghcx2fgAIdwg8Z:tg8Va8VNaHIdbaAIdbg83:tg8Wa8WNaHIdlaAIdlg85:tg8Xa8XNMMg8Sa8Naecwfydbg8Acx2fgeIdwa8Z:tg8YNa8Va8YNa8WaeIdba83:tg81Na8XaeIdla85:tgBNMMgRa8VN:tJbbbbJbbjZa8Sa8Ya8YNa81a81NaBaBNMMg8UNaRaRN:tg86:va86Jbbbb9BEg86Nh88a8Ua8VNaRa8YN:ta86Nh89a8SaBNaRa8XN:ta86Nh8:a8Ua8XNaRaBN:ta86NhZa8Sa81NaRa8WN:ta86Nhna8Ua8WNaRa81N:ta86Nhca8WaBNa8Xa81N:tgRaRNa8Xa8YNa8VaBN:tgRaRNa8Va81Na8Wa8YN:tgRaRNMM:rJbbbZNhRa8PahaC2g8JcdtfhHa8Pa8AaC2gDcdtfhAa8Pa8FaC2g8KcdtfhXa8Z:mh9ca85:mhJa83:mh9eascjdfheaChKJbbbbhBJbbbbh86Jbbbbh8SJbbbbh8UJbbbbh8ZJbbbbh83Jbbbbh85Jbbbbh87JbbbbhUinaecwfaRa89aXIdbaHIdbg8Y:tg8XNa88aAIdba8Y:tg81NMg8VNUdbaeclfaRaZa8XNa8:a81NMg8WNUdbaeaRaca8XNana81NMg8XNUdbaecxfaRa9ca8VNaJa8WNa8Ya9ea8XNMMMg8YNUdbaRa8Va8WNNa8ZMh8ZaRa8Va8XNNa8UMh8UaRa8Wa8XNNa8SMh8SaRa8Ya8YNNaUMhUaRa8Va8YNNa87Mh87aRa8Wa8YNNa85Mh85aRa8Xa8YNNa83Mh83aRa8Va8VNNa86Mh86aRa8Wa8WNNaBMhBaRa8Xa8XNNa80Mh80aHclfhHaXclfhXaAclfhAaeczfheaKcufgKmbkagahc8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdyaga8Fc8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdyaga8Ac8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdya8Ra8Jcltfh8FcbhHaChXina8FaHfgeascjdfaHfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbka8Ra8Kcltfh8FcbhHaChXina8FaHfgeascjdfaHfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbka8RaDcltfh8FcbhHaChXina8FaHfgeascjdfaHfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbkaacifgaad6mbkkcbhAdndnamcwGgTmbJbbbbh8ScbhScbh9hcbh9ixekcbhSa3cbyd1:H:cjbHjjjjbbh9iasc:Cefasyd;8egecdtfa9iBdbasaecefBd;8ecua9ialabadaOz:fjjjbgXcltaXcjjjjiGEcbyd1:H:cjbHjjjjbbh9hasc:Cefasyd;8egecdtfa9hBdbasaecefBd;8ea9haXa9ia8Nalz:gjjjbJFFuuh8SaXTmba9hheaXhHinaeIdbgRa8Sa8SaR9EEh8SaeclfheaHcufgHmbkaXhSkdnalTmbaLclfheaLydbhXaYhHalhKcbhAincbaeydbg8FaX9RaHRbbcpeGEaAfhAaHcefhHaeclfhea8FhXaKcufgKmbkaAce4hAkcuadaA9Rcifg6cx2a6c;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbh9kasc:Cefasyd;8egecdtfa9kBdbasaecefBd;8ecua6cdta6cFFFFi0Ecbyd1:H:cjbHjjjjbbh0asc:Cefasyd;8egecdtfa0BdbasaecefBd;8ea3cbyd1:H:cjbHjjjjbbh9masc:Cefasyd;8egecdtfa9mBdbasaecefBd;8ealcbyd1:H:cjbHjjjjbbh9nasc:Cefasyd;8egecdtfa9nBdbasaecefBd;8eaxaxNayJbbjZamclGEgZaZN:vh87JbbbbhUdnadak9nmbdna6ci6mbaCclth9oa9kcwfh9pJbbbbh85JbbbbhUinascNefabadalaOz:cjjjbabh8Acbh9qcbh9rinaba9rcdtfhDcbheindnaOa8AaefydbgAcdtghfydbgXaOaDaec:W:G:cjbfydbcdtfydbgHcdtg8JfydbgKSmbaYaHfRbbgacv2aYaAfRbbg8FfRb;a:G:cjbg8La8Fcv2aafg8KRb;a:G:cjbg3VcFeGTmbdnaKaX9nmba8KRb;G:G:cjbcFeGmekdna8FcufcFeGce0mbaaTmba5ahfydbaH9hmekdna8FTmbaacufcFeGce0mba8Ea8JfydbaA9hmeka9ka9qcx2fgXaHaAa3cFeGgKEBdlaXaAaHaKEBdbaXaKa8LGcb9hBdwa9qcefh9qkaeclfgecx9hmbkdna9rcifg9rad9pmba8Acxfh8Aa9qcifa69nmekka9qTmdcbh8KinaIaOa9ka8Kcx2fghydbgKcdtgXfydbg8Ac8S2fgeIdwa8Nahydlg8Fcx2fgHIdwg8WNaeIdzaHIdbg8XNaeIdaMgRaRMMa8WNaeIdlaHIdlg8YNaeIdCa8WNaeId3MgRaRMMa8YNaeIdba8XNaeIdxa8YNaeIdKMgRaRMMa8XNaeId8KMMM:lhRJbbbbJbbjZaeIdyg8V:va8VJbbbb9BEh8VdndnahydwgDmbJFFuuh86xekJbbbbJbbjZaIaOa8Fcdtfydbc8S2fgeIdyg81:va81Jbbbb9BEaeIdwa8NaKcx2fgHIdwg81NaeIdzaHIdbg80NaeIdaMgBaBMMa81NaeIdlaHIdlgBNaeIdCa81NaeId3Mg81a81MMaBNaeIdba80NaeIdxaBNaeIdKMg81a81MMa80NaeId8KMMM:lNh86ka8VaRNhBdnaCTmbagaKc8S2fgAIdwa8WNaAIdza8XNaAIdaMgRaRMMa8WNaAIdla8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8Pa8FaC2gacdtfhHa8RaKaC2g8JcltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbkdndnaDmbJbbbbh8Vxekaga8Fc8S2fgAIdwa8NaKcx2fgeIdwg8XNaAIdzaeIdbg8YNaAIdaMg8Va8VMMa8XNaAIdlaeIdlg81NaAIdCa8XNaAId3Mg8Va8VMMa81NaAIdba8YNaAIdxa81NaAIdKMg8Va8VMMa8YNaAId8KMMMh8Va8Pa8JcdtfhHa8RaacltfheaAIdyh80aChAinaHIdbg8Wa8Wa80NaecxfIdba8XaecwfIdbNa8YaeIdbNa81aeclfIdbNMMMg8Wa8WM:tNa8VMh8VaHclfhHaeczfheaAcufgAmbka8V:lh8VkaBaR:lMhBa86a8VMh86dndndnaYaKfRbbc9:fPddbekaQaXfydbgXaKSmbaOa8Fcdtfydbh8Jindndna5aXcdtgafydbgecuSmbaOaecdtfydba8JSmekdna8EaafydbgecuSmbaOaecdtfydba8JSmeka8FhekagaXc8S2fgAIdwa8Naecx2fgHIdwg8WNaAIdzaHIdbg8XNaAIdaMgRaRMMa8WNaAIdlaHIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaeaC2cdtfhHa8RaXaC2cltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbkaBaR:lMhBaQaafydbgXaK9hmbkkaYa8FfRbbci9hmeaDTmeaQa8FcdtfydbgXa8FSmeindndna5aXcdtgafydbgecuSmbaOaecdtfydba8ASmekdna8EaafydbgecuSmbaOaecdtfydba8ASmekaKhekagaXc8S2fgAIdwa8Naecx2fgHIdwg8WNaAIdzaHIdbg8XNaAIdaMgRaRMMa8WNaAIdlaHIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaeaC2cdtfhHa8RaXaC2cltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbka86aR:lMh86aQaafydbgXa8F9hmbxdkkdna8Ea5a5aXfydba8FSEaQaXfydbgacdtfydbgXcu9hmbaQa8FcdtfydbhXkagaac8S2fgAIdwa8NaXcx2fgeIdwg8WNaAIdzaeIdbg8XNaAIdaMgRaRMMa8WNaAIdlaeIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaXaC2g8AcdtfhHa8RaaaC2g8JcltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbkdndnaDmbJbbbbh8VxekagaXc8S2fgAIdwa8Naacx2fgeIdwg8XNaAIdzaeIdbg8YNaAIdaMg8Va8VMMa8XNaAIdlaeIdlg81NaAIdCa8XNaAId3Mg8Va8VMMa81NaAIdba8YNaAIdxa81NaAIdKMg8Va8VMMa8YNaAId8KMMMh8Va8Pa8JcdtfhHa8Ra8AcltfheaAIdyh80aChAinaHIdbg8Wa8Wa80NaecxfIdba8XaecwfIdbNa8YaeIdbNa81aeclfIdbNMMMg8Wa8WM:tNa8VMh8VaHclfhHaeczfheaAcufgAmbka8V:lh8VkaBaR:lMhBa86a8VMh86kaha86aBa86aB9DgeEUdwahaKa8FaeaDcb9hGgeEBdlaha8FaKaeEBdba8Kcefg8Ka9q9hmbkascjdfcbcj;qbz:tjjjb8Aa9phea9qhHinascjdfaeydbcA4cF8FGgAcFAaAcFA6EcdtfgAaAydbcefBdbaecxfheaHcufgHmbkcbhecbhHinascjdfaefgAydbhXaAaHBdbaXaHfhHaeclfgecj;qb9hmbkcbhea9phHinascjdfaHydbcA4cF8FGgAcFAaAcFA6EcdtfgAaAydbgAcefBdba0aAcdtfaeBdbaHcxfhHa9qaecefge9hmbkadak9RgAci9Uh9sdnalTmbcbhea9mhHinaHaeBdbaHclfhHalaecefge9hmbkkcbh9ta9ncbalz:tjjjbh3aAcO9Uh9ua9sce4h9rcbh8Lcbh8Kdnina9ka0a8Kcdtfydbcx2fg8JIdwgRa879Emea8La9s9pmeJFFuuh8Vdna9ra9q9pmba9ka0a9rcdtfydbcx2fIdwJbb;aZNh8VkdnaRa8V9ETmbaRaU9ETmba8La9u0mdkdna3aOa8JydlgDcdtg9vfg8AydbgAfg9wRbba3aOa8Jydbghcdtg9xfydbgefg9yRbbVmbaYahfRbbh9zdndnaLaecdtfgHclfydbgXaHydbgHSmbaXaH9RhXa8NaAcx2fh8Fa8Naecx2fhaaEaHcitfheindna9maeydbcdtfydbgHaASmba9maeclfydbcdtfydbgKaASmbaHaKSmba8NaKcx2fgKIdba8NaHcx2fgHIdbg8W:tgRaaIdlaHIdlg8X:tg80NaKIdla8X:tg8VaaIdba8W:tgBN:tg8YaRa8FIdla8X:tg86Na8Va8FIdba8W:tg8UN:tg8XNa8VaaIdwaHIdwg81:tg8ZNaKIdwa81:tg8Wa80N:tg80a8Va8FIdwa81:tg83Na8Wa86N:tg8VNa8WaBNaRa8ZN:tg81a8Wa8UNaRa83N:tgRNMMa8Ya8YNa80a80Na81a81NMMa8Xa8XNa8Va8VNaRaRNMMN:rJbbj8:N9FmikaecwfheaXcufgXmbkkdndndndna9zc9:fPdebdkahheina8AydbhAdndna5aecdtgHfydbgecuSmbaOaecdtfydbaASmekdna8EaHfydbgecuSmbaOaecdtfydbaASmekaDheka9maHfaeBdbaQaHfydbgeah9hmbxikkdna8Ea5a5a9xfydbaDSEaQa9xfydbghcdtfydbgecu9hmbaQa9vfydbheka9ma9xfaDBdbaehDka9mahcdtfaDBdbka9yce86bba9wce86bba8JIdwgRaUaUaR9DEhUa9tcefh9tcecda9zceSEa8Lfh8Lxeka9rcefh9rka8Kcefg8Ka9q9hmbkka9tTmddnalTmbcbh8Fcbhhindna9mahcdtgefydbgAahSmbaOaAcdtfydbh8AdnahaOaefydb9hg8JmbaIa8Ac8S2fgeaIahc8S2fgHIdbaeIdbMUdbaeaHIdlaeIdlMUdlaeaHIdwaeIdwMUdwaeaHIdxaeIdxMUdxaeaHIdzaeIdzMUdzaeaHIdCaeIdCMUdCaeaHIdKaeIdKMUdKaeaHId3aeId3MUd3aeaHIdaaeIdaMUdaaeaHId8KaeId8KMUd8KaeaHIdyaeIdyMUdya8MTmba8Ma8Acltfgea8MahcltfgHIdbaeIdbMUdbaeaHIdlaeIdlMUdlaeaHIdwaeIdwMUdwaeaHIdxaeIdxMUdxkaCTmbagaAc8S2fgeagahc8S2gDfgHIdbaeIdbMUdbaeaHIdlaeIdlMUdlaeaHIdwaeIdwMUdwaeaHIdxaeIdxMUdxaeaHIdzaeIdzMUdzaeaHIdCaeIdCMUdCaeaHIdKaeIdKMUdKaeaHId3aeId3MUd3aeaHIdaaeIdaMUdaaeaHId8KaeId8KMUd8KaeaHIdyaeIdyMUdya9oaA2haa8RhHaChXinaHaafgeaHa8FfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbka8JmbJbbbbJbbjZaIaDfgeIdygR:vaRJbbbb9BEaeIdwa8Na8Acx2fgHIdwgRNaeIdzaHIdbg8VNaeIdaMg8Wa8WMMaRNaeIdlaHIdlg8WNaeIdCaRNaeId3MgRaRMMa8WNaeIdba8VNaeIdxa8WNaeIdKMgRaRMMa8VNaeId8KMMM:lNgRa85a85aR9DEh85ka8Fa9ofh8Fahcefghal9hmbkcbhHa5heindnaeydbgAcuSmbdnaHa9maAcdtgXfydbgA9hmbcuhAa5aXfydbgXcuSmba9maXcdtfydbhAkaeaABdbkaeclfhealaHcefgH9hmbkcbhHa8EheindnaeydbgAcuSmbdnaHa9maAcdtgXfydbgA9hmbcuhAa8EaXfydbgXcuSmba9maXcdtfydbhAkaeaABdbkaeclfhealaHcefgH9hmbkka85aUaCEh85cbhHabhecbhAindnaOa9maeydbcdtfydbg8FcdtfydbgXaOa9maeclfydbcdtfydbgacdtfydbgKSmbaXaOa9maecwfydbcdtfydbg8AcdtfydbghSmbaKahSmbabaHcdtfgXa8FBdbaXcwfa8ABdbaXclfaaBdbaHcifhHkaecxfheaAcifgAad6mbkdndnaTmbaHhdxekdnaHak0mbaHhdxekdna8Sa859FmbaHhdxekJFFuuh8ScbhdabhecbhAindna9ha9iaeydbgXcdtfydbcdtfIdbgRa859ETmbaeclf8Pdbh9AabadcdtfgKaXBdbaKclfa9A83dbaRa8Sa8SaR9EEh8SadcifhdkaecxfheaAcifgAaH6mbkkadak0mbxdkkascNefabadalaOz:cjjjbkdndnadak0mbadhaxekdnaTmbadhaxekdna8Sa879FmbadhaxekcehKina8SJbb;aZNgRa87aRa879DEh8WJbbbbhRdnaSTmba9hheaShHinaeIdbg8VaRa8Va8W9FEaRa8VaR9EEhRaeclfheaHcufgHmbkkJFFuuh8ScbhaabhecbhHindna9ha9iaeydbgAcdtfydbcdtfIdbg8Va8W9ETmbaeclf8Pdbh9AabaacdtfgXaABdbaXclfa9A83dba8Va8Sa8Sa8V9EEh8SaacifhakaecxfheaHcifgHad6mbkdnaKaaad9hVceGmbadhaxdkaRaUaUaR9DEhUaaak9nmecbhKaahda8Sa879FmbkkdnamcjjjjdGTmba9ncbalz:tjjjbh8AdnaaTmbabheaahHina8AaeydbgAfce86bba8AaOaAcdtfydbfce86bbaeclfheaHcufgHmbkkascNefabaaalaOz:cjjjbdndnalTmbcbhXindna8AaXfRbbTmbdnaYaXfRbbgecl0mbceaetcQGmekdnaOaXcdtg8FfydbgeaXSmba8NaXcx2fgHa8Naecx2fgeydwBdwaHae8Pdb83dbxekaIaXc8S2fgKIdygcacJL:3;rUNgRMh87aKIdwg9BaRMh8SaKIdlg9CaRMh8UaKIdbg9DaRMh81aKIdag9EaRa8NaXcx2fg8JIdwg88N:th8ZaKId3g9FaRa8JIdlg89N:th83aKIdKg9Ga8JIdbg8:aRN:th80JbbbbhnaKIdCg9HJbbbbMh85aKIdzg9IJbbbbMhBaKIdxg9JJbbbbMh86dndnaCTmbaXhAinJbbbba87agaAc8S2fgHIdygR:vaRJbbbb9BEhRa8RaAaC2cltfheaHIdaa87Na8ZMh8ZaHId3a87Na83Mh83aHIdKa87Na80Mh80aHIdCa87Na85Mh85aHIdza87NaBMhBaHIdxa87Na86Mh86aHIdwa87Na8SMh8SaHIdla87Na8UMh8UaHIdba87Na81Mh81aChHina8ZaecwfIdbg8VaecxfIdbg8YNaRN:th8Za83aeclfIdbg8Wa8YNaRN:th83a85a8Wa8VNaRN:th85a81aeIdbg8Xa8XNaRN:th81a80a8Xa8YNaRN:th80aBa8Xa8VNaRN:thBa86a8Xa8WNaRN:th86a8Sa8Va8VNaRN:th8Sa8Ua8Wa8WNaRN:th8UaeczfheaHcufgHmbkaQaAcdtfydbgAaX9hmbka8MTmba8MaXcltfgeIdxhxaeIdwh9caeIdlhJaeIdbhRxekJbbbbhxJbbbbh9cJbbbbhJJbbbbhRkaBa81:vg8Wa80Na8Z:ta85aBa86a81:vg8VN:tg8Za8Ua86a8VN:tg8Y:vg8Xa8Va80Na83:tg8UN:th83a9caRa8WN:taJaRa8VN:tg86a8XN:tg85a8SaBa8WN:ta8Za8XN:tgB:vg8S:mh8Za86a8Y:vg9c:mhJdnJbbbbaRaRa81:vg9eN:ta86a9cN:ta85a8SN:tg86:la87J:983:g81NgR9ETmba8Za83NaJa8UNa9ea80Nax:tMMa86:vhnka81:laR9ETmba8Y:laR9ETmbaB:laR9ETmba9e:manNa8W:ma8ZanNa83aB:vMgBNa8V:maJanNa8X:maBNa8Ua8Y:vMMg85Na80:ma81:vMMMh87aLa8FfgeclfydbgHaeydbge9RhhaEaecitfh8FJbbbbhRdnaHaeSgDmbJbbbbhRa8FheahhAina8Naeclfydbcx2fgHIdwa88:tg8Va8VNaHIdba8::tg8Va8VNaHIdla89:tg8Va8VNMMg8Va8Naeydbcx2fgHIdwa88:tg8Wa8WNaHIdba8::tg8Wa8WNaHIdla89:tg8Wa8WNMMg8WaRaRa8W9DEgRaRa8V9DEhRaecwfheaAcufgAmbkaR:rgRaRNhRkaBa88:tg8Va8VNa87a8::tg8Va8VNa85a89:tg8Va8VNMMaR9EmbaKId8KhndnaDmbina8Na8Fclfydbcx2fgeIdba8Na8Fydbcx2fgHIdbg8W:tgRa89aHIdlg8X:tg80NaeIdla8X:tg8Va8:a8W:tg86N:tg8YaRa85a8X:tg8SNa8Va87a8W:tg8UN:tg8XNa8Va88aHIdwg81:tg8ZNaeIdwa81:tg8Wa80N:tg80a8VaBa81:tg83Na8Wa8SN:tg8VNa8Wa86NaRa8ZN:tg81a8Wa8UNaRa83N:tgRNMMa8Ya8YNa80a80Na81a81NMMa8Xa8XNa8Va8VNaRaRNMMN:rJbbj8:N9Fmda8Fcwfh8FahcufghmbkkJbbbbJbbjZac:vacJbbbb9BEgRa9BaBNa9Ia87Na9EMg8Va8VMMaBNa9Ca85Na9HaBNa9FMg8Va8VMMa85Na9Da87Na9Ja85Na9GMg8Va8VMMa87NanMMM:lNaRa9Ba88Na9Ia8:Na9EMg8Va8VMMa88Na9Ca89Na9Ha88Na9FMg8Va8VMMa89Na9Da8:Na9Ja89Na9GMg8Va8VMMa8:NanMMM:lNJbb;aZNJ:983:g81M9Emba8JaBUdwa8Ja85Udla8Ja87UdbkaXcefgXal9hmbkdnaCmbcbhCxdkcbhXindna8AaXfRbbTmbaOaXcdtgefydbaX9hmbaYaXfhhaQaefh8Ja8NaXcx2fhAa8PaXaC2cdtfhDcbhEincuhLdnahRbbci9hmbaXhLa8JydbgeaXSmba8PaEcdtgHfhKaDaHfIdbhRaXhLinaLhHcuhLdnaKaeaC2cdtfIdbaR9CmbaHcuSmbaHhLagaec8S2fIdyagaHc8S2fIdy9ETmbaehLkaQaecdtfydbgeaX9hmbkka8PaEcdtfhKa8RaEcltfh8FaXheinaKaeaC2cdtfJbbbbJbbjZagaeaLaLcuSEgHc8S2fIdygR:vaRJbbbb9BEa8FaHaC2cltfgHIdwaAIdwNaHIdbaAIdbNaHIdlaAIdlNMMaHIdxMNUdbaQaecdtfydbgeaX9hmbkaEcefgEaC9hmbkkaXcefgXal9hmbxdkkaCmbcbhCkaiavaoarawaCala8Na8Pazasayasc1efaYa8Aaqz:hjjjbkdnamcjjjjlGTmbazmbaaTmbabhecbhLinaYaeydbgAfRbbc3thQaecwfgXydbhHcjjjj94hCdna5aAcdtgEfydbaeclfgKydbgOSmbcjjjj94cba8EaOcdtfydbaASEhCkaeaQaCVaAVBdbaYaOfRbbc3th8Fcjjjj94hCcjjjj94hQdna5aOcdtfydbaHSmbcjjjj94cba8EaHcdtfydbaOSEhQkaKa8FaQVaOVBdbaYaHfRbbc3thOdna5aHcdtfydbaASmbcjjjj94cba8EaEfydbaHSEhCkaXaOaCVaHVBdbaecxfheaLcifgLaa6mbkkdnazTmbaaTmbaaheinabazabydbcdtfydbBdbabclfhbaecufgembkkdnaPTmbaPaZaU:rNUdbkdnasyd;8egHTmbaHcdtasc:Ceffc98fheinaeydbcbyd:m:H:cjbH:bjjjbbaec98fheaHcufgHmbkkascj;sbf8Kjjjjbaak;Yieouabydlhvabydbclfcbaicdtz:tjjjbhoadci9UhrdnadTmbdnalTmbaehwadhDinaoalawydbcdtfydbcdtfgqaqydbcefBdbawclfhwaDcufgDmbxdkkaehwadhDinaoawydbcdtfgqaqydbcefBdbawclfhwaDcufgDmbkkdnaiTmbcbhDaohwinawydbhqawaDBdbawclfhwaqaDfhDaicufgimbkkdnadci6mbinaecwfydbhwaeclfydbhDaeydbhidnalTmbalawcdtfydbhwalaDcdtfydbhDalaicdtfydbhikavaoaicdtfgqydbcitfaDBdbavaqydbcitfawBdlaqaqydbcefBdbavaoaDcdtfgqydbcitfawBdbavaqydbcitfaiBdlaqaqydbcefBdbavaoawcdtfgwydbcitfaiBdbavawydbcitfaDBdlawawydbcefBdbaecxfhearcufgrmbkkabydbcbBdbk:todDue99aicd4aifhrcehwinawgDcethwaDar6mbkcuaDcdtgraDcFFFFi0Ecbyd1:H:cjbHjjjjbbhwaoaoyd9GgqcefBd9GaoaqcdtfawBdbawcFearz:tjjjbhkdnaiTmbalcd4hlaDcufhxcbhminamhDdnavTmbavamcdtfydbhDkcbadaDal2cdtfgDydlgwawcjjjj94SEgwcH4aw7c:F:b:DD2cbaDydbgwawcjjjj94SEgwcH4aw7c;D;O:B8J27cbaDydwgDaDcjjjj94SEgDcH4aD7c:3F;N8N27axGhwamcdthPdndndnavTmbakawcdtfgrydbgDcuSmeadavaPfydbal2cdtfgsIdbhzcehqinaqhrdnadavaDcdtfydbal2cdtfgqIdbaz9CmbaqIdlasIdl9CmbaqIdwasIdw9BmlkarcefhqakawarfaxGgwcdtfgrydbgDcu9hmbxdkkakawcdtfgrydbgDcuSmbadamal2cdtfgsIdbhzcehqinaqhrdnadaDal2cdtfgqIdbaz9CmbaqIdlasIdl9CmbaqIdwasIdw9BmikarcefhqakawarfaxGgwcdtfgrydbgDcu9hmbkkaramBdbamhDkabaPfaDBdbamcefgmai9hmbkkakcbyd:m:H:cjbH:bjjjbbaoaoyd9GcufBd9GdnaeTmbaiTmbcbhDaehwinawaDBdbawclfhwaiaDcefgD9hmbkcbhDaehwindnaDabydbgrSmbawaearcdtfgrydbBdbaraDBdbkabclfhbawclfhwaiaDcefgD9hmbkkk;:odvuv998Jjjjjbca9Rgocbyd1:G:cjbBdKaocb8Pdj:G:cjb83izaocbydN:G:cjbBdwaocb8Pd:m:G:cjb83ibdnadTmbaicd4hrdnabmbdnalTmbcbhwinaealawcdtfydbar2cdtfhDcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkawcefgwad9hmbxikkarcdthwcbhDincbhiinaoczfaifgqaeaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkaeawfheaDcefgDad9hmbxdkkdnalTmbcbhwinabawcx2fgiaealawcdtfydbar2cdtfgDIdbUdbaiaDIdlUdlaiaDIdwUdwcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkawcefgwad9hmbxdkkarcdthlcbhwaehDinabawcx2fgiaeawar2cdtfgqIdbUdbaiaqIdlUdlaiaqIdwUdwcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkaDalfhDawcefgwad9hmbkkJbbbbaoIdbaoIdzgx:tgkakJbbbb9DEgkaoIdlaoIdCgm:tgPaPak9DEgkaoIdwaoIdKgP:tgsasak9DEhsdnabTmbadTmbJbbbbJbbjZas:vasJbbbb9BEhkinabakabIdbax:tNUdbabclfgoakaoIdbam:tNUdbabcwfgoakaoIdbaP:tNUdbabcxfhbadcufgdmbkkdnavTmbavaPUdwavamUdlavaxUdbkask:WlewudnaeTmbcbhvabhoinaoavBdbaoclfhoaeavcefgv9hmbkkdnaiTmbcbhrinadarcdtfhwcbhDinalawaDcdtgvyd:G:G:cjbcdtfydbcdtfydbhodnalawavfydbcdtfydbgqabaqcdtfgkydbgvSmbinakabavgqcdtfgxydbgvBdbaxhkaqav9hmbkkdnaoabaocdtfgkydbgvSmbinakabavgocdtfgxydbgvBdbaxhkaoav9hmbkkdnaqaoSmbabaqaoaqao0Ecdtfaqaoaqao6EBdbkaDcefgDci9hmbkarcifgrai6mbkkdnaembcbskcbhxindnalaxcdtgvfydbax9hmbaxhodnaxabavfgDydbgvSmbaDhqinaqabavgocdtfgkydbgvBdbakhqaoav9hmbkkaDaoBdbkaxcefgxae9hmbkcbhkabhvcbhoindndnaoalydbgq9hmbdnaoavydbgq9hmbavakBdbakcefhkxdkavabaqcdtfydbBdbxekavabaqcdtfydbBdbkalclfhlavclfhvaeaocefgo9hmbkakk;jiilud99euabcbaecltz:tjjjbhvdnalTmbadhoaihralhwinarcwfIdbhDarclfIdbhqavaoydbcltfgkarIdbakIdbMUdbakaqakIdlMUdlakaDakIdwMUdwakakIdxJbbjZMUdxaoclfhoarcxfhrawcufgwmbkkdnaeTmbavhkaehrinakcxfgoIdbhDaocbBdbakakIdbJbbbbJbbjZaD:vaDJbbbb9BEgDNUdbakclfgoaDaoIdbNUdbakcwfgoaDaoIdbNUdbakczfhkarcufgrmbkkdnalTmbinavadydbcltfgkaicwfIdbakIdw:tgDaDNaiIdbakIdb:tgDaDNaiclfIdbakIdl:tgDaDNMMgDakIdxgqaqaD9DEUdxadclfhdaicxfhialcufglmbkkdnaeTmbavcxfhkinabakIdbUdbakczfhkabclfhbaecufgembkkk:moerudnaoTmbaecd4hzdnavTmbaicd4hHavcdthOcbhAindnaPaAfRbbTmbaAhednaDTmbaDaAcdtfydbhekdnasTmbasaefRbbceGmekdnamaAfRbbclSmbabaeaz2cdtfgiaraAcx2fgCIdbakNaxIdbMUdbaiaCIdlakNaxIdlMUdlaiaCIdwakNaxIdwMUdwkadaeaH2cdtfhXaqheawhiavhCinaXaeydbcdtgQfaiIdbalaQfIdb:vUdbaeclfheaiclfhiaCcufgCmbkkawaOfhwaAcefgAao9hmbxdkkdnasmbcbheaDhiindnaPaefRbbTmbaehCdnaDTmbaiydbhCkamaefRbbclSmbabaCaz2cdtfgCarIdbakNaxIdbMUdbaCarclfIdbakNaxIdlMUdlaCarcwfIdbakNaxIdwMUdwkaiclfhiarcxfhraoaecefge9hmbxdkkdnaDTmbindnaPRbbTmbasaDydbgefRbbceGmbamRbbclSmbabaeaz2cdtfgearIdbakNaxIdbMUdbaearclfIdbakNaxIdlMUdlaearcwfIdbakNaxIdwMUdwkaPcefhPaDclfhDamcefhmarcxfhraocufgombxdkkazcdthicbheindnaPaefRbbTmbasaefRbbceGmbamaefRbbclSmbabarIdbakNaxIdbMUdbabclfarclfIdbakNaxIdlMUdbabcwfarcwfIdbakNaxIdwMUdbkarcxfhrabaifhbaoaecefge9hmbkkk8MbabaeadaialavcbcbcbcbcbaoarawaDz:bjjjbk8MbabaeadaialavaoarawaDaqakaxamaPz:bjjjbkRbababaeadaialavaoarawaDaqakaxcjjjjdVamz:bjjjbk:g8Koque99due99duq998Jjjjjbc;Wb9Rgq8Kjjjjbcbhkaqcxfcbc;Kbz:tjjjb8Aaqcualcx2alc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbgxBdxaqceBd2axaialavcbcbz:ejjjb8AaqcualcdtalcFFFFi0Egmcbyd1:H:cjbHjjjjbbgiBdzaqcdBd2dndnJFF959eJbbjZawJbbjZawJbbjZ9DE:vawJ9VO:d869DEgw:lJbbb9p9DTmbaw:OhPxekcjjjj94hPkadci9Uhsarco9UhzdndnaombaPcd9imekdnalTmbaPcuf:YhwdnaoTmbcbhvaihHaxhOindndnaoavfRbbceGTmbavcjjjjlVhAxekdndnaOclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcqthAdndnaOcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXVhAdndnaOIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXcCtVhAkaHaABdbaHclfhHaOcxfhOalavcefgv9hmbxdkkaxhvaihOalhHindndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcCthAdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqtaAVhAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaOaAaXVBdbavcxfhvaOclfhOaHcufgHmbkkadTmbcbhkaehvcbhOinakaiavclfydbcdtfydbgHaiavcwfydbcdtfydbgA9haiavydbcdtfydbgXaH9haXaA9hGGfhkavcxfhvaOcifgOad6mbkkarci9UhQdndnaz:Z:rJbbbZMgw:lJbbb9p9DTmbaw:Ohvxekcjjjj94hvkaQ:ZhLcbhKc:bwhzdninakaQ9pmeazaP9Rcd9imeavazcufgOavaO9iEaPcefavaP9kEhYdnalTmbaYcuf:YhwdnaoTmbcbhOaihHaxhvindndnaoaOfRbbceGTmbaOcjjjjlVhAxekdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcqthAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXVhAdndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXcCtVhAkaHaABdbaHclfhHavcxfhvalaOcefgO9hmbxdkkaxhvaihOalhHindndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcCthAdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqtaAVhAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaOaAaXVBdbavcxfhvaOclfhOaHcufgHmbkkcbhOdnadTmbaehvcbhHinaOaiavclfydbcdtfydbgAaiavcwfydbcdtfydbgX9haiavydbcdtfydbgraA9haraX9hGGfhOavcxfhvaHcifgHad6mbkkdnas:ZgCaL:taY:Ygwaz:Y:tg8ANak:ZgEaO:Zg3:tNaEaL:tawaP:Y:tg5Na3aC:tNMg8EJbbbb9BmbaCaE:ta5a8Aa3aL:tNNNa8E:vawMhwkdndnaOaQ0mbaOhkaYhPxekaOhsaYhzkdndnaKcl0mbdnawJbbbZMgw:lJbbb9p9DTmbaw:Ohvxdkcjjjj94hvxekaPazfcd9ThvkaKcefgKcs9hmbkkdndndnakmbJbbjZhwcbhOcdhvaDmexdkalcd4alfhHcehOinaOgvcethOavaH6mbkcbhOaqcuavcdtgYavcFFFFi0Ecbyd1:H:cjbHjjjjbbgKBdCaqciBd2aqamcbyd1:H:cjbHjjjjbbgzBdKaqclBd2dndndndnalTmbaPcuf:YhwaoTmecbhOaihAaxhHindndnaoaOfRbbceGTmbaOcjjjjlVhXxekdndnaHclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqthXdndnaHcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaXarVhXdndnaHIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaXarcCtVhXkaAaXBdbaAclfhAaHcxfhHalaOcefgO9hmbxikkaKcFeaYz:tjjjb8AcbhPcbhvxdkaxhOaihHalhAindndnaOIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcCthXdndnaOclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkarcqtaXVhXdndnaOcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaHaXarVBdbaOcxfhOaHclfhHaAcufgAmbkkaKcFeaYz:tjjjbhravcufhocbhPcbhYindndndnaraiaYcdtgKfydbgAcm4aA7c:v;t;h;Ev2gvcs4av7aoGgHcdtfgXydbgOcuSmbcehvinaiaOcdtgOfydbaASmdaHavfhOavcefhvaraOaoGgHcdtfgXydbgOcu9hmbkkaXaYBdbaPhvaPcefhPxekazaOfydbhvkazaKfavBdbaYcefgYal9hmbkcuaPc8S2gOaPc;D;O;f8U0EhvkcbhXaqavcbyd1:H:cjbHjjjjbbgvBd3aqcvBd2avcbaOz:tjjjbhOdnadTmbaehiinaxaiclfydbgrcx2fgvIdbaxaiydbgocx2fgHIdbg3:tgCaxaicwfydbgYcx2fgAIdlaHIdlg8A:tgwNavIdla8A:tgEaAIdba3:tg8EN:tgLaLNaEaAIdwaHIdwg5:tg8FNavIdwa5:tgEawN:tgwawNaEa8ENaCa8FN:tgCaCNMMg8E:rhEJbbnnJbbjZazaocdtfydbgvazarcdtfydbgASavazaYcdtfydbgrSGgHEh8Fdna8EJbbbb9ETmbaLaE:vhLaCaE:vhCawaE:vhwkaOavc8S2fgvavIdbawa8FaE:rNgEawNNg8FMUdbavaCaEaCNgaNghavIdlMUdlavaLaEaLNg8ENggavIdwMUdwavawaaNgaavIdxMUdxava8EawNg8JavIdzMUdzavaCa8ENg8EavIdCMUdCavawaEaLa5Nawa3Na8AaCNMM:mg8ANg3NgwavIdKMUdKavaCa3NgCavId3MUd3avaLa3NgLavIdaMUdaava3a8ANg3avId8KMUd8KavaEavIdyMUdydnaHmbaOaAc8S2fgva8FavIdbMUdbavahavIdlMUdlavagavIdwMUdwavaaavIdxMUdxava8JavIdzMUdzava8EavIdCMUdCavawavIdKMUdKavaCavId3MUd3avaLavIdaMUdaava3avId8KMUd8KavaEavIdyMUdyaOarc8S2fgva8FavIdbMUdbavahavIdlMUdlavagavIdwMUdwavaaavIdxMUdxava8JavIdzMUdzava8EavIdCMUdCavawavIdKMUdKavaCavId3MUd3avaLavIdaMUdaava3avId8KMUd8KavaEavIdyMUdykaicxfhiaXcifgXad6mbkkcbhAaqcuaPcdtgvaPcFFFFi0Egicbyd1:H:cjbHjjjjbbgHBdaaqcoBd2aqaicbyd1:H:cjbHjjjjbbgiBd8KaqcrBd2aHcFeavz:tjjjbhYdnalTmbazhHinJbbbbJbbjZaOaHydbgXc8S2fgvIdygw:vawJbbbb9BEavIdwaxcwfIdbgwNavIdzaxIdbgCNavIdaMgLaLMMawNavIdlaxclfIdbgLNavIdCawNavId3MgwawMMaLNavIdbaCNavIdxaLNavIdKMgwawMMaCNavId8KMMM:lNhwdndnaYaXcdtgvfgXydbcuSmbaiavfIdbaw9ETmekaXaABdbaiavfawUdbkaHclfhHaxcxfhxalaAcefgA9hmbkkdndnaPmbJbbbbhwxekJbbbbhwinaiIdbgCawawaC9DEhwaiclfhiaPcufgPmbkaw:rhwkakcd4akfhOcehiinaigvcethiavaO6mbkcbhOaqcuavcdtgiavcFFFFi0Ecbyd1:H:cjbHjjjjbbgHBdyaHcFeaiz:tjjjbhXdnadTmbavcufhrcbhPcbhxindnazaeaxcdtfgvydbcdtfydbgiazavclfydbcdtfydbgOSmbaiazavcwfydbcdtfydbgvSmbaOavSmbaYavcdtfydbhAdndnaYaOcdtfydbgvaYaicdtfydbgi9pmbavaA9pmbaAhlaihoavhAxekdnaAai9pmbaAav9pmbaihlavhoxekavhlaAhoaihAkabaPcx2fgvaABdbavcwfaoBdbavclfalBdbdnaXaoc:3F;N8N2alc:F:b:DD27aAc;D;O:B8J27arGgOcdtfgvydbgicuSmbcehHinaHhvdnabaicx2fgiydbaA9hmbaiydlal9hmbaiydwaoSmikavcefhHaXaOavfarGgOcdtfgvydbgicu9hmbkkavaPBdbaPcefhPkaxcifgxad6mbkaPci2hOkcwhvaDTmekaDawUdbkavcdthvaqcxfc98fhiinaiavfydbcbyd:m:H:cjbH:bjjjbbavc98fgvmbkaqc;Wbf8KjjjjbaOk:3ldrue9:8Jjjjjbc;Wb9Rgr8Kjjjjbcbhwarcxfcbc;Kbz:tjjjb8AdnabaeSmbabaeadcdtzMjjjb8AkarcualcdtalcFFFFi0EgDcbyd1:H:cjbHjjjjbbgqBdxarceBd2aqcbaialavcbarcxfz:djjjbcualcx2alc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbhkarcxfaryd2gxcdtfakBdbaraxcefgmBd2akaialavcbcbz:ejjjb8AarcxfamcdtfaDcbyd1:H:cjbHjjjjbbgiBdbaraxcdfgvBd2arcxfavcdtfcuaialaeadaqz:fjjjbgecltaecjjjjiGEcbyd1:H:cjbHjjjjbbgqBdbaqaeaiakalz:gjjjbaxcifhkdnadTmbaoaoNhocbhwabhlcbheindnaqaialydbgvcdtfydbcdtfIdbao9ETmbalclf8PdbhPabawcdtfgDavBdbaDclfaP83dbawcifhwkalcxfhlaecifgead6mbkkdnakTmbaxcdtarcxffcwfhlinalydbcbyd:m:H:cjbH:bjjjbbalc98fhlakcufgkmbkkarc;Wbf8Kjjjjbawk:WCoDud99vue99vuv998Jjjjjbc;Wb9Rgw8KjjjjbdndnarmbcbhDxekawcxfcbc;Kbz:tjjjb8Aawcuadcx2adc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbgqBdxawceBd2aqaeadaicbcbz:ejjjb8AawcuadcdtadcFFFFi0Egkcbyd1:H:cjbHjjjjbbgxBdzawcdBd2adcd4adfhmceheinaegicetheaiam6mbkcbhPawcuaicdtgsaicFFFFi0Ecbyd1:H:cjbHjjjjbbgzBdCawciBd2dndnar:ZgH:rJbbbZMgO:lJbbb9p9DTmbaO:Ohexekcjjjj94hekaicufhAc:bwhCcbhXadhQcbhLinaeaCcufgiaeai9iEaPcefaeaP9kEhDdndnadTmbaDcuf:YhOaqhiaxheadhmindndnaiIdbaONJbbbZMgK:lJbbb9p9DTmbaK:OhYxekcjjjj94hYkaYcCthYdndnaiclfIdbaONJbbbZMgK:lJbbb9p9DTmbaK:Oh8Axekcjjjj94h8Aka8AcqtaYVhYdndnaicwfIdbaONJbbbZMgK:lJbbb9p9DTmbaK:Oh8Axekcjjjj94h8AkaeaYa8AVBdbaicxfhiaeclfheamcufgmmbkazcFeasz:tjjjbhEcbh3cbh5indnaEaxa5cdtfydbgYcm4aY7c:v;t;h;Ev2gics4ai7aAGgmcdtfg8AydbgecuSmbaeaYSmbcehiinaEamaifaAGgmcdtfg8AydbgecuSmeaicefhiaeaY9hmbkka8AaYBdba3aecuSfh3a5cefg5ad9hmbxdkkazcFeasz:tjjjb8Acbh3kdnaQ:ZgKaH:taD:YgOaC:Y:tg8ENaX:Zg8Fa3:Zga:tNa8FaH:taOaP:Y:tghNaaaK:tNMggJbbbb9BmbaKa8F:taha8EaaaH:tNNNag:vaOMhOkaPaDa3ar0giEhPaXa3aiEhXdna3arSmbaDaCaiEgCaP9Rcd9imbdndnaLcl0mbdnaOJbbbZMgO:lJbbb9p9DTmbaO:Ohexdkcjjjj94hexekaPaCfcd9Theka3aQaiEhQaLcefgLcs9hmekkdndnaXmbcihicbhDxekcbhiawakcbyd1:H:cjbHjjjjbbg5BdKawclBd2aPcuf:YhKdndnadTmbaqhiaxheadhmindndnaiIdbaKNJbbbZMgO:lJbbb9p9DTmbaO:OhYxekcjjjj94hYkaYcCthYdndnaiclfIdbaKNJbbbZMgO:lJbbb9p9DTmbaO:Oh8Axekcjjjj94h8Aka8AcqtaYVhYdndnaicwfIdbaKNJbbbZMgO:lJbbb9p9DTmbaO:Oh8Axekcjjjj94h8AkaeaYa8AVBdbaicxfhiaeclfheamcufgmmbkazcFeasz:tjjjbhEcbhDcbh3indndndnaEaxa3cdtgCfydbgYcm4aY7c:v;t;h;Ev2gics4ai7aAGgmcdtfg8AydbgecuSmbcehiinaxaecdtgefydbaYSmdamaifheaicefhiaEaeaAGgmcdtfg8Aydbgecu9hmbkka8Aa3BdbaDhiaDcefhDxeka5aefydbhika5aCfaiBdba3cefg3ad9hmbkcuaDc32giaDc;j:KM;jb0EhexekazcFeasz:tjjjb8AcbhDcbhekawaecbyd1:H:cjbHjjjjbbgeBd3awcvBd2aecbaiz:tjjjbh8Aavcd4hxdnadTmbdnalTmbaxcdthEa5hYaqhealhmadhAina8AaYydbc32fgiaeIdbaiIdbMUdbaiaeclfIdbaiIdlMUdlaiaecwfIdbaiIdwMUdwaiamIdbaiIdxMUdxaiamclfIdbaiIdzMUdzaiamcwfIdbaiIdCMUdCaiaiIdKJbbjZMUdKaYclfhYaecxfheamaEfhmaAcufgAmbxdkka5hmaqheadhYina8Aamydbc32fgiaeIdbaiIdbMUdbaiaeclfIdbaiIdlMUdlaiaecwfIdbaiIdwMUdwaiaiIdxJbbbbMUdxaiaiIdzJbbbbMUdzaiaiIdCJbbbbMUdCaiaiIdKJbbjZMUdKamclfhmaecxfheaYcufgYmbkkdnaDTmba8AhiaDheinaiaiIdbJbbbbJbbjZaicKfIdbgO:vaOJbbbb9BEgONUdbaiclfgmaOamIdbNUdbaicwfgmaOamIdbNUdbaicxfgmaOamIdbNUdbaiczfgmaOamIdbNUdbaicCfgmaOamIdbNUdbaic3fhiaecufgembkkcbhYawcuaDcdtgCaDcFFFFi0Egicbyd1:H:cjbHjjjjbbgeBdaawcoBd2awaicbyd1:H:cjbHjjjjbbgEBd8KaecFeaCz:tjjjbh3dnadTmbaoJbbjZJbbjZaK:vaPceSENgOaONhKaxcdthxalheinaKaec;8:G:cjbalEgmIdwa8Aa5ydbgAc32fgiIdC:tgOaONamIdbaiIdx:tgOaONamIdlaiIdz:tgOaONMMNaqcwfIdbaiIdw:tgOaONaqIdbaiIdb:tgOaONaqclfIdbaiIdl:tgOaONMMMhOdndna3aAcdtgifgmydbcuSmbaEaifIdbaO9ETmekamaYBdbaEaifaOUdbka5clfh5aqcxfhqaeaxfheadaYcefgY9hmbkkaba3aCzMjjjb8Acrhikaicdthiawcxfc98fheinaeaifydbcbyd:m:H:cjbH:bjjjbbaic98fgimbkkawc;Wbf8KjjjjbaDk:Pdidui99ducbhi8Jjjjjbca9Rglcbyd1:G:cjbBdKalcb8Pdj:G:cjb83izalcbydN:G:cjbBdwalcb8Pd:m:G:cjb83ibdndnaembJbbjFhvJbbjFhoJbbjFhrxekadcd4cdthwincbhdinalczfadfgDabadfIdbgvaDIdbgoaoav9EEUdbaladfgDavaDIdbgoaoav9DEUdbadclfgdcx9hmbkabawfhbaicefgiae9hmbkalIdwalIdK:thralIdlalIdC:thoalIdbalIdz:thvkJbbbbavavJbbbb9DEgvaoaoav9DEgvararav9DEk9DeeuabcFeaicdtz:tjjjbhlcbhbdnadTmbindnalaeydbcdtfgiydbcu9hmbaiabBdbabcefhbkaeclfheadcufgdmbkkabk;Bidqui998Jjjjjbc;Wb9Rgl8Kjjjjbalcxfcbc;Kbz:tjjjb8Aadcd4adfhvcehoinaogrcethoarav6mbkalcuarcdtgoarcFFFFi0Ecbyd1:H:cjbHjjjjbbgvBdxavcFeaoz:tjjjbhwdnadTmbaicd4hDarcufhqcbhkindndnawcbaeakaD2cdtfgrydlgiaicjjjj94SEgocH4ao7c:F:b:DD2cbarydbgxaxcjjjj94SEgocH4ao7c;D;O:B8J27cbarydwgmamcjjjj94SEgrcH4ar7c:3F;N8N27aqGgvcdtfgrydbgocuSmbam::hPai::hsax::hzcehiinaihrdnaeaoaD2cdtfgiIdbaz9CmbaiIdlas9CmbaiIdwaP9BmikarcefhiawavarfaqGgvcdtfgrydbgocu9hmbkkarakBdbakhokabakcdtfaoBdbakcefgkad9hmbkkalydxcbyd:m:H:cjbH:bjjjbbalc;Wbf8Kjjjjbk9teiucbcbyd:q:H:cjbgeabcifc98GfgbBd:q:H:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd:q:H:cjbgeabcrfc94GfgbBd:q:H:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd:q:H:cjbge9Rcifc98GaefgbBd:q:H:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akkk:Kedbcj:Gdk1eFFuuFFuuFFuuFFuFFFuFFFuFbbbbbbbbebbbdbbbbbbbebbbebbbdbbbbbbbbbbbeeeeebebbebbebebbbeebbbbbbbbbbbbeeeeeebebbeeebeebbbbebebbbbbbbbbbbbbbbbbbc1:Hdkxebbbdbbb:G:qbb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,i=WebAssembly.instantiate(r(e),{}).then(function(b){n=b.instance,n.exports.__wasm_call_ctors()});function r(b){var _=new Uint8Array(b.length);for(var x=0;x<b.length;++x){var v=b.charCodeAt(x);_[x]=v>96?v-97:v>64?v-39:v+4}var E=0;for(var x=0;x<b.length;++x)_[E++]=_[x]<60?t[_[x]]:(_[x]-60)*64+_[++x];return _.buffer.slice(0,E)}function s(b){if(!b)throw Error("Assertion failed")}function a(b){return new Uint8Array(b.buffer,b.byteOffset,b.byteLength)}function o(b,_,x,v){var E=n.exports.sbrk,S=E(x*4),T=E(x*v*4),A=new Uint8Array(n.exports.memory.buffer);A.set(a(_),T),b(S,T,x,v*4),A=new Uint8Array(n.exports.memory.buffer);var P=new Uint32Array(x);return new Uint8Array(P.buffer).set(A.subarray(S,S+x*4)),E(S-E(0)),P}function c(b,_,x){var v=n.exports.sbrk,E=v(_.length*4),S=v(x*4),T=new Uint8Array(n.exports.memory.buffer),A=a(_);T.set(A,E);var P=b(S,E,_.length,x);T=new Uint8Array(n.exports.memory.buffer);var w=new Uint32Array(x);new Uint8Array(w.buffer).set(T.subarray(S,S+x*4)),v(E-v(0));for(var I=0;I<_.length;++I)_[I]=w[_[I]];return[w,P]}function l(b){var _=0;for(var x=0;x<b.length;++x){var v=b[x];_=_<v?v:_}return _}function u(b,_,x,v,E,S,T,A,P){var w=n.exports.sbrk,I=w(4),F=w(x*4),N=w(E*S),U=w(x*4),D=new Uint8Array(n.exports.memory.buffer);D.set(a(v),N),D.set(a(_),U);var O=b(F,U,x,N,E,S,T,A,P,I);D=new Uint8Array(n.exports.memory.buffer);var K=new Uint32Array(O);a(K).set(D.subarray(F,F+O*4));var B=new Float32Array(1);return a(B).set(D.subarray(I,I+4)),w(I-w(0)),[K,B[0]]}function d(b,_,x,v,E,S,T,A,P,w,I,F,N){var U=n.exports.sbrk,D=U(4),O=U(x*4),K=U(E*S),B=U(E*A),X=U(P.length*4),q=U(x*4),le=w?U(E):0,de=new Uint8Array(n.exports.memory.buffer);if(de.set(a(v),K),de.set(a(T),B),de.set(a(P),X),de.set(a(_),q),w)de.set(a(w),le);var Me=b(O,q,x,K,E,S,B,A,X,P.length,le,I,F,N,D);de=new Uint8Array(n.exports.memory.buffer);var pe=new Uint32Array(Me);a(pe).set(de.subarray(O,O+Me*4));var J=new Float32Array(1);return a(J).set(de.subarray(D,D+4)),U(D-U(0)),[pe,J[0]]}function f(b,_,x,v,E,S,T,A,P,w,I,F,N){var U=n.exports.sbrk,D=U(4),O=U(E*S),K=U(E*A),B=U(P.length*4),X=U(x*4),q=w?U(E):0,le=new Uint8Array(n.exports.memory.buffer);if(le.set(a(v),O),le.set(a(T),K),le.set(a(P),B),le.set(a(_),X),w)le.set(a(w),q);var de=b(X,x,O,E,S,K,A,B,P.length,q,I,F,N,D);le=new Uint8Array(n.exports.memory.buffer),a(_).set(le.subarray(X,X+de*4)),a(v).set(le.subarray(O,O+E*S)),a(T).set(le.subarray(K,K+E*A));var Me=new Float32Array(1);return a(Me).set(le.subarray(D,D+4)),U(D-U(0)),[de,Me[0]]}function h(b,_,x,v){var E=n.exports.sbrk,S=E(x*v),T=new Uint8Array(n.exports.memory.buffer);T.set(a(_),S);var A=b(S,x,v);return E(S-E(0)),A}function y(b,_,x,v,E,S,T,A){var P=n.exports.sbrk,w=P(A*4),I=P(x*v),F=E?P(x*S):0,N=new Uint8Array(n.exports.memory.buffer);if(N.set(a(_),I),E)N.set(a(E),F);var U=b(w,I,x,v,F,S,T,A);N=new Uint8Array(n.exports.memory.buffer);var D=new Uint32Array(U);return a(D).set(N.subarray(w,w+U*4)),P(w-P(0)),D}function g(b,_,x,v,E,S,T,A,P){var w=n.exports.sbrk,I=w(4),F=w(x*4),N=w(E*S),U=w(x*4),D=T?w(E):0,O=new Uint8Array(n.exports.memory.buffer);if(O.set(a(v),N),O.set(a(_),U),T)O.set(a(T),D);var K=b(F,U,x,N,E,S,D,A,P,I);O=new Uint8Array(n.exports.memory.buffer);var B=new Uint32Array(K);a(B).set(O.subarray(F,F+K*4));var X=new Float32Array(1);return a(X).set(O.subarray(I,I+4)),w(I-w(0)),[B,X[0]]}function m(b,_,x,v,E,S,T){var A=n.exports.sbrk,P=A(x*4),w=A(E*S),I=A(x*4),F=new Uint8Array(n.exports.memory.buffer);F.set(a(v),w),F.set(a(_),I);var N=b(P,I,x,w,E,S,T);F=new Uint8Array(n.exports.memory.buffer);var U=new Uint32Array(N);return a(U).set(F.subarray(P,P+N*4)),A(P-A(0)),U}var p={LockBorder:1,Sparse:2,ErrorAbsolute:4,Prune:8,Regularize:16,Permissive:32,_InternalDebug:1073741824};return{ready:i,supported:!0,compactMesh:function(b){s(b instanceof Uint32Array||b instanceof Int32Array||b instanceof Uint16Array||b instanceof Int16Array),s(b.length%3==0);var _=b.BYTES_PER_ELEMENT==4?b:new Uint32Array(b),x=c(n.exports.meshopt_optimizeVertexFetchRemap,_,l(b)+1);if(b!==_)for(var v=0;v<_.length;++v)b[v]=_[v];return x},generatePositionRemap:function(b,_){return s(b instanceof Float32Array),s(b.length%_==0),s(_>=3),o(n.exports.meshopt_generatePositionRemap,b,b.length/_,_)},simplify:function(b,_,x,v,E,S){s(b instanceof Uint32Array||b instanceof Int32Array||b instanceof Uint16Array||b instanceof Int16Array),s(b.length%3==0),s(_ instanceof Float32Array),s(_.length%x==0),s(x>=3),s(v>=0&&v<=b.length),s(v%3==0),s(E>=0);var T=0;for(var A=0;A<(S?S.length:0);++A)s(S[A]in p),T|=p[S[A]];var P=b.BYTES_PER_ELEMENT==4?b:new Uint32Array(b),w=u(n.exports.meshopt_simplify,P,b.length,_,_.length/x,x*4,v,E,T);return w[0]=b instanceof Uint32Array?w[0]:new b.constructor(w[0]),w},simplifyWithAttributes:function(b,_,x,v,E,S,T,A,P,w){s(b instanceof Uint32Array||b instanceof Int32Array||b instanceof Uint16Array||b instanceof Int16Array),s(b.length%3==0),s(_ instanceof Float32Array),s(_.length%x==0),s(x>=3),s(v instanceof Float32Array),s(v.length==E*(_.length/x)),s(E>=0),s(T==null||T instanceof Uint8Array),s(T==null||T.length==_.length/x),s(A>=0&&A<=b.length),s(A%3==0),s(P>=0),s(Array.isArray(S)),s(E>=S.length),s(S.length<=32);for(var I=0;I<S.length;++I)s(S[I]>=0);var F=0;for(var I=0;I<(w?w.length:0);++I)s(w[I]in p),F|=p[w[I]];var N=b.BYTES_PER_ELEMENT==4?b:new Uint32Array(b),U=d(n.exports.meshopt_simplifyWithAttributes,N,b.length,_,_.length/x,x*4,v,E*4,new Float32Array(S),T,A,P,F);return U[0]=b instanceof Uint32Array?U[0]:new b.constructor(U[0]),U},simplifyWithUpdate:function(b,_,x,v,E,S,T,A,P,w){s(b instanceof Uint32Array||b instanceof Int32Array||b instanceof Uint16Array||b instanceof Int16Array),s(b.length%3==0),s(_ instanceof Float32Array),s(_.length%x==0),s(x>=3),s(v instanceof Float32Array),s(v.length==E*(_.length/x)),s(E>=0),s(T==null||T instanceof Uint8Array),s(T==null||T.length==_.length/x),s(A>=0&&A<=b.length),s(A%3==0),s(P>=0),s(Array.isArray(S)),s(E>=S.length),s(S.length<=32);for(var I=0;I<S.length;++I)s(S[I]>=0);var F=0;for(var I=0;I<(w?w.length:0);++I)s(w[I]in p),F|=p[w[I]];var N=b.BYTES_PER_ELEMENT==4?b:new Uint32Array(b),U=f(n.exports.meshopt_simplifyWithUpdate,N,b.length,_,_.length/x,x*4,v,E*4,new Float32Array(S),T,A,P,F);if(b!==N)for(var I=0;I<U[0];++I)b[I]=N[I];return U},getScale:function(b,_){return s(b instanceof Float32Array),s(b.length%_==0),s(_>=3),h(n.exports.meshopt_simplifyScale,b,b.length/_,_*4)},simplifyPoints:function(b,_,x,v,E,S){if(s(b instanceof Float32Array),s(b.length%_==0),s(_>=3),s(x>=0&&x<=b.length/_),v)return s(v instanceof Float32Array),s(v.length%E==0),s(E>=3),s(b.length/_==v.length/E),y(n.exports.meshopt_simplifyPoints,b,b.length/_,_*4,v,E*4,S||0,x);else return y(n.exports.meshopt_simplifyPoints,b,b.length/_,_*4,void 0,0,0,x)},simplifySloppy:function(b,_,x,v,E,S){s(b instanceof Uint32Array||b instanceof Int32Array||b instanceof Uint16Array||b instanceof Int16Array),s(b.length%3==0),s(_ instanceof Float32Array),s(_.length%x==0),s(x>=3),s(v==null||v instanceof Uint8Array),s(v==null||v.length==_.length/x),s(E>=0&&E<=b.length),s(E%3==0),s(S>=0);var T=b.BYTES_PER_ELEMENT==4?b:new Uint32Array(b),A=g(n.exports.meshopt_simplifySloppy,T,b.length,_,_.length/x,x*4,v,E,S);return A[0]=b instanceof Uint32Array?A[0]:new b.constructor(A[0]),A},simplifyPrune:function(b,_,x,v){s(b instanceof Uint32Array||b instanceof Int32Array||b instanceof Uint16Array||b instanceof Int16Array),s(b.length%3==0),s(_ instanceof Float32Array),s(_.length%x==0),s(x>=3),s(v>=0);var E=b.BYTES_PER_ELEMENT==4?b:new Uint32Array(b),S=m(n.exports.meshopt_simplifyPrune,E,b.length,_,_.length/x,x*4,v);return S=b instanceof Uint32Array?S:new b.constructor(S),S}}}()});var BK;var LM=Ft(()=>{BK=function(){var e="b9H79Tebbbe:neP9Geueu9Geub9Gbb9Giuuueu9Gmuuuuuuuuuuu9999eu9Gouuuuuueu9Gruuuuuuub9Gxuuuuuuuuuuuueu9Gxuuuuuuuuuuu99eu9GPuuuuuuuuuuuuu99b9Gouuuuuub9Gwuuuuuuuub9Gvuuuuub9GluuuubiQXdilvorwDqokoqxmbiibeilve9Weiiviebeoweuecj:Gdkr;Zeqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9I919P29K9nW79O2Wt79c9V919U9KbeY9TW79O9V9Wt9F9I919P29K9nW79O2Wt7S2W94bd39TW79O9V9Wt9F9I919P29K9nW79O2Wt79t9W9Ht9P9H2bo39TW79O9V9Wt9F9J9V9T9W91tWJ2917tWV9c9V919U9K7bw39TW79O9V9Wt9F9J9V9T9W91tW9nW79O2Wt9c9V919U9K7bkE9TW79O9V9Wt9F9J9V9T9W91tW9t9W9OWVW9c9V919U9K7bxL9TW79O9V9Wt9F9V9Wt9P9T9P96W9nW79O2WtbPl79IV9RbsDwebcekdOAq;W:leXdbkIbabaec9:fgefcufae9Ugeabci9Uadfcufad9Ugbaeab0Ek:88JDPue99eux99due99euo99iu8Jjjjjbc:WD9Rgm8KjjjjbdndnalmbcbhPxekamc:Cwfcbc;Kbz:rjjjb8AcuaocdtgsaocFFFFi0Ehzcbyd;0:G:cjbhHdndnalcb9imbaoal9nmbamazaHHjjjjbbgHBd:CwamceBd;8wamazcbyd;0:G:cjbHjjjjbbgOBd:GwamcdBd;8wamcualcdtalcFFFFi0Ecbyd;0:G:cjbHjjjjbbgABd:KwamciBd;8waihzalhsinaHazydbcdtfcbBdbazclfhzascufgsmbkaihzalhsinaHazydbcdtfgCaCydbcefBdbazclfhzascufgsmbkaihzalhCcbhXindnaHazydbcdtgQfgsydbcb9imbaOaQfaXBdbasasydbgQcjjjj94VBdbaQaXfhXkazclfhzaCcufgCmbkalci9UhLdnalci6mbcbhzaihsinascwfydbhCasclfydbhXaOasydbcdtfgQaQydbgQcefBdbaAaQcdtfazBdbaOaXcdtfgXaXydbgXcefBdbaAaXcdtfazBdbaOaCcdtfgCaCydbgCcefBdbaAaCcdtfazBdbascxfhsaLazcefgz9hmbkkaihzalhsindnaHazydbcdtgCfgXydbgQcu9kmbaXaQcFFFFrGgQBdbaOaCfgCaCydbaQ9RBdbkazclfhzascufgsmbxdkkamazaHHjjjjbbgHBd:CwamceBd;8wamazcbyd;0:G:cjbHjjjjbbgOBd:GwamcdBd;8wamcualcdtalcFFFFi0Ecbyd;0:G:cjbHjjjjbbgABd:KwamciBd;8waHcbasz:rjjjbhXaihzalhsinaXazydbcdtfgCaCydbcefBdbazclfhzascufgsmbkalci9UhLdnaoTmbcbhzaOhsaXhCaohQinasazBdbasclfhsaCydbazfhzaCclfhCaQcufgQmbkkdnalci6mbcbhzaihsinascwfydbhCasclfydbhQaOasydbcdtfgKaKydbgKcefBdbaAaKcdtfazBdbaOaQcdtfgQaQydbgQcefBdbaAaQcdtfazBdbaOaCcdtfgCaCydbgCcefBdbaAaCcdtfazBdbascxfhsaLazcefgz9hmbkkaoTmbcbhzaohsinaOazfgCaCydbaXazfydb9RBdbazclfhzascufgsmbkkamaLcbyd;0:G:cjbHjjjjbbgzBd:OwamclBd;8wazcbaLz:rjjjbhYamcuaLcK2alcjjjjd0Ecbyd;0:G:cjbHjjjjbbg8ABd:SwamcvBd;8wJbbbbhEdnalci6g3mbarcd4hKaihsa8AhzaLhrJbbbbh5inavasclfydbaK2cdtfgCIdlh8EavasydbaK2cdtfgXIdlhEavascwfydbaK2cdtfgQIdlh8FaCIdwhaaXIdwhhaQIdwhgazaCIdbg8JaXIdbg8KMaQIdbg8LMJbbnn:vUdbazclfaXIdlaCIdlMaQIdlMJbbnn:vUdbaQIdwh8MaCIdwh8NaXIdwhyazcxfa8EaE:tg8Eagah:tggNaaah:tgaa8FaE:tghN:tgEJbbbbJbbjZa8Ja8K:tg8FahNa8Ea8La8K:tg8KN:tghahNaEaENaaa8KNa8FagN:tgEaENMMg8K:rg8E:va8KJbbbb9BEg8KNUdbazczfaEa8KNUdbazcCfaha8KNUdbazcwfa8Maya8NMMJbbnn:vUdba5a8EMh5ascxfhsazcKfhzarcufgrmbka5aL:Z:vJbbbZNhEkamcuaLcdtalcFFFF970Ecbyd;0:G:cjbHjjjjbbgCBd:WwamcoBd;8waq:Zhhdna3mbcbhzaChsinasazBdbasclfhsaLazcefgz9hmbkkaEahNhhamcuaLcltalcFFFFd0Ecbyd;0:G:cjbHjjjjbbg8PBd:0wamcrBd;8wcba8Pa8AaCaLcbz:djjjb8AJFFuuh8MJFFuuh8NJFFuuhydnalci6mbJFFuuhya8AhzaLhsJFFuuh8NJFFuuh8MinazcwfIdbgEa8Ma8MaE9EEh8MazclfIdbgEa8Na8NaE9EEh8NazIdbgEayayaE9EEhyazcKfhzascufgsmbkkah:rhEamaocetgzcuaocu9kEcbyd;0:G:cjbHjjjjbbgCBd:4wdndnaoal9nmbaihzalhsinaCazydbcetfcFFi87ebazclfhzascufgsmbxdkkaCcFeazz:rjjjb8AkaEJbbbZNh8JcuhIdnalci6mbcbhsJFFuuhEa8AhzcuhIinazcwfIdba8M:tghahNazIdbay:tghahNazclfIdba8N:tghahNMM:rghaEaIcuSahaE9DVgXEhEasaIaXEhIazcKfhzaLascefgs9hmbkkamczfcbcjwz:rjjjb8Aam9cb83iwam9cb83ibaxa8JNh8RJbbjZak:th8Lcbh8SJbbbbhRJbbbbh8UJbbbbh8VJbbbbh8WJbbbbh8XJbbbbh8Ycbh8ZcbhPinJbbbbhEdna8STmbJbbjZa8S:Z:vhEkJbbbbhhdna8Ya8YNa8Wa8WNa8Xa8XNMMg8KJbbbb9BmbJbbjZa8K:r:vhhka8VaENh8Ka8UaENh5aRaENh8EaIhLdndndndndna8SaPVTmbamydwg80Tmea8YahNh8Fa8XahNhaa8WahNhgaeamydbcdtfh81cbh3JFFuuhEcvhQcuhLindnaHa81a3cdtfydbcdtgzfydbgvTmbaAaOazfydbcdtfhsindndnaCaiasydbgKcx2fgzclfydbgrcetf8Vebcs4aCazydbgXcetf8Vebcs4faCazcwfydbglcetf8Vebcs4fgombcbhzxekcehzaHaXcdtfydbgXceSmbcehzaHarcdtfydbgrceSmbcehzaHalcdtfydbglceSmbdnarcdSaXcdSfalcdSfcd6mbaocefhzxekaocdfhzkdnazaQ9kmba8AaKcK2fgXIdwa8K:tghahNaXIdba8E:tghahNaXIdla5:tghahNMM:ra8J:va8LNJbbjZMJ9VO:d86JbbjZaXIdCa8FNaXIdxagNaaaXIdzNMMakN:tghahJ9VO:d869DENghaEazaQ6ahaE9DVgXEhEaKaLaXEhLazaQaXEhQkasclfhsavcufgvmbkka3cefg3a809hmbkkaLcu9hmekama8KUd:ODama5Ud:KDama8EUd:GDamcuBd:qDamcFFF;7rBdjDa8Pcba8AaYamc:GDfamc:qDfamcjDfz:ejjjbamyd:qDhLdndnaxJbbbb9ETmba8SaD6mbaLcuSmeceh3amIdjDa8R9EmixdkaLcu9hmekdna8STmbabaPcltfgHam8Piw83dwaHam8Pib83dbaPcefhPkc3hHinamc:CwfaHfydbcbyd;4:G:cjbH:bjjjbbaHc98fgHc989hmbxvkkcbh3a8Saq9pmbamydwaCaiaLcx2fgzydbcetf8Vebcs4aCazcwfydbcetf8Vebcs4faCazclfydbcetf8Vebcs4ffaw9nmekcbhzcbhsdna8ZTmbcbhsamczfhXinamczfascdtfaXydbgQBdbaXclfhXasaYaQfRbbTfhsa8Zcufg8ZmbkkamydwhlamydbhXam9cu83i:GDam9cu83i:ODam9cu83i:qDam9cu83i:yDinamcjDfazfcFFF;7rBdbazclfgzcz9hmbkasc;8easclfc:bd6Eg8Zcdth80dnalTmbaeaXcdtfhocbhrindnaHaoarcdtfydbcdtgzfydbgvTmbaAaOazfydbcdtfhscuhQcuhzinaHaiasydbgKcx2fgXclfydbcdtfydbaHaXydbcdtfydbfaHaXcwfydbcdtfydbfgXazaXaz6gXEhzaKaQaXEhQasclfhsavcufgvmbkaQcuSmba8AaQcK2fgsIdwa8M:tgEaENasIdbay:tgEaENasIdla8N:tgEaENMM:rhEcbhsindndnazamc:qDfasfgvydbgX6mbazaX9hmeaEamcjDfasfIdb9FTmekavazBdbamc:GDfasfaQBdbamcjDfasfaEUdbxdkasclfgscz9hmbkkarcefgral9hmbkkamczfa80fhQcbhzcbhsindnamc:GDfazfydbgXcuSmbaQascdtfaXBdbascefhskazclfgzcz9hmbkasa8Zfg8ZTmbJFFuuhhcuhKamczfhza8ZhvcuhQina8AazydbgXcK2fgsIdwa8M:tgEaENasIdbay:tgEaENasIdla8N:tgEaENMM:rhEdndnaHaiaXcx2fgsclfydbcdtfydbaHasydbcdtfydbfaHascwfydbcdtfydbfgsaQ6mbasaQ9hmeaEah9DTmekaEhhashQaXhKkazclfhzavcufgvmbkaKcuSmbaKhLkdnamaiaLcx2fgrydbarclfydbarcwfydbaCabaeadaPawaqa3z:fjjjbTmbaPcefhPJbbbbhRJbbbbh8UJbbbbh8VJbbbbh8WJbbbbh8XJbbbbh8YkcbhXinaAaOaraXcdtfydbcdtgsfydbcdtfgKhzaHasfgvydbgQhsdnaQTmbdninazydbaLSmeazclfhzascufgsTmdxbkkazaKaQcdtfc98fydbBdbavavydbcufBdbkaXcefgXci9hmbka8AaLcK2fgzIdbhEazIdlhhazIdwh8KazIdxh5azIdzh8EazIdCh8FaYaLfce86bba8Ya8FMh8Ya8Xa8EMh8Xa8Wa5Mh8Wa8Va8KMh8Va8UahMh8UaRaEMhRamydxh8Sxbkkamc:WDf8KjjjjbaPkjoivuv99lu8Jjjjjbca9Rgo8Kjjjjbdndnalcw0mbaiydbhraeabcitfgwalcdtciVBdlawarBdbdnalcd6mbaiclfhralcufhDawcxfhwinarydbhqawcuBdbawc98faqBdbawcwfhwarclfhraDcufgDmbkkalabfhwxekcbhqaocbBdKao9cb83izaocbBdwao9cb83ibJbbjZhkJbbjZhxinadaiaqcdtfydbcK2fhDcbhwinaoczfawfgraDawfIdbgmarIdbgP:tgsaxNaPMgPUdbaoawfgrasamaP:tNarIdbMUdbawclfgwcx9hmbkJbbjZakJbbjZMgk:vhxaqcefgqal9hmbkcbhradcbcecdaoIdlgmaoIdwgP9GEgwaoIdbgsaP9GEawasam9GEgzcdtgwfhHaoczfawfIdbhmaihwalhDinaiarcdtfgqydbhOaqawydbgABdbawaOBdbawclfhwaraHaAcK2fIdbam9DfhraDcufgDmbkdndnarcv6mbavc8X9kmbaralc98f6mekaiydbhraeabcitfgwalcdtciVBdlawarBdbaiclfhralcufhDawcxfhwinarydbhqawcuBdbawc98faqBdbawcwfhwarclfhraDcufgDmbkalabfhwxekaeabcitfgwamUdbawawydlc98GazVBdlabcefaeadaiaravcefgqz:djjjbhDawawydlciGaDabcu7fcdtVBdlaDaeadaiarcdtfalar9Raqz:djjjbhwkaocaf8Kjjjjbawk;Oddvue99dninabaecitfgrydlgwcd4gDTmednawciGgqci9hmbcihqdnawcl6mbabaecitfhbcbheawhqcehkindnaiabydbgDfRbbmbcbhkadaDcK2fgwIdwalIdw:tgxaxNawIdbalIdb:tgxaxNawIdlalIdl:tgxaxNMM:rgxaoIdb9DTmbaoaxUdbavaDBdbarydlhqkabcwfhbaecefgeaqcd46mbkakceGTmikaraqciGBdlskdnabcbaDalaqcdtfIdbarIdb:tgxJbbbb9FEgwaD7aecefgDfgecitfydlabawaDfgDcitfydlVci0mbaraqBdlkabaDadaialavaoz:ejjjbax:laoIdb9Fmbkkkjlevudndnabydwgxaladcetfgm8Vebcs4alaecetfgP8Vebgscs4falaicetfgz8Vebcs4ffaD0mbakmbcbhDabydxaq6mekavawcltfgxab8Pdw83dwaxab8Pdb83dbabydbhDdnabydwgwTmbaoaDcdtfhxawhsinalaxydbcetfcFFi87ebaxclfhxascufgsmbkkabaDawfBdbabydxhxab9cb83dwababydlaxci2fBdlaP8VebhscehDcbhxkdnascztcz91cu9kmbabaxcefBdwaPax87ebaoabydbcdtfaxcdtfaeBdbkdnam8Uebcu9kmbababydwgxcefBdwamax87ebaoabydbcdtfaxcdtfadBdbkdnaz8Uebcu9kmbababydwgxcefBdwazax87ebaoabydbcdtfaxcdtfaiBdbkarabydlfabydxci2faPRbb86bbarabydlfabydxci2fcefamRbb86bbarabydlfabydxci2fcdfazRbb86bbababydxcefBdxaDk:mPrHue99eue99eue99iu8Jjjjjbc;W;Gb9Rgx8KjjjjbdndnalmbcbhmxekcbhPaxc:m;Gbfcbc;Kbz:rjjjb8Aaxcualci9UgscltascjjjjiGEcbyd;0:G:cjbHjjjjbbgzBd:m9GaxceBd;S9GaxcuascK2gHcKfalcpFFFe0Ecbyd;0:G:cjbHjjjjbbgOBd:q9GaxcdBd;S9Gdnalci6gAmbarcd4hCascdthXaOhQazhLinavaiaPcx2fgrydwaC2cdtfhKavarydlaC2cdtfhYavarydbaC2cdtfh8AcbhraLhEinaQarfgma8Aarfg3Idbg5aYarfg8EIdbg8Fa5a8F9DEg5UdbamaKarfgaIdbg8Fa5a8Fa59DEg8FUdbamcxfgma3Idbg5a8EIdbgha5ah9EEg5UdbamaaIdbgha5aha59EEg5UdbaEa8Fa5MJbbbZNUdbaEaXfhEarclfgrcx9hmbkaQcKfhQaLclfhLaPcefgPas9hmbkkaOaHfgr9cb83dbar9cb83dzar9cb83dwaxcuascx2gralc:bjjjl0Ecbyd;0:G:cjbHjjjjbbgHBdN9GaxciBd;S9GascdthgazarfhvaxcwVhPaxclVhCaHh8Jazh8KcbhLinaxcbcj;Gbz:rjjjbhEaLas2cdthadnaAmba8Khrash3inaEarydbgmc8F91cjjjj94Vam7gmcQ4cx2fg8Ea8EydwcefBdwaEamcd4cFrGcx2fg8Ea8EydbcefBdbaEamcx4cFrGcx2fgmamydlcefBdlarclfhra3cufg3mbkkazaafh8AaHaafhXcbhmcbh3cbh8EcbhainaEamfgrydbhQara3BdbarcwfgKydbhYaKaaBdbarclfgrydbhKara8EBdbaQa3fh3aYaafhaaKa8Efh8Eamcxfgmcj;Gb9hmbkdnaAmbcbhravhminamarBdbamclfhmasarcefgr9hmbkavhrashminaEa8Aarydbg3cdtfydbg8Ec8F91a8E7cd4cFrGcx2fg8Ea8Eydbg8EcefBdbaXa8Ecdtfa3Bdbarclfhramcufgmmbka8JhrashminaCa8Aarydbg3cdtfydbg8Ec8F91a8E7cx4cFrGcx2fg8Ea8Eydbg8EcefBdbava8Ecdtfa3BdbarclfhramcufgmmbkavhrashminaPa8Aarydbg3cdtfydbg8Ec8F91cjjjj94Va8E7cQ4cx2fg8Ea8Eydbg8EcefBdbaXa8Ecdtfa3Bdbarclfhramcufgmmbkka8Jagfh8Ja8Kagfh8KaLcefgLci9hmbkaEaocetgrcuaocu9kEcbyd;0:G:cjbHjjjjbbgKBd:y9GaEclBd;S9Gdndnaoal9nmbaihralhminaKarydbcetfcFFi87ebarclfhramcufgmmbxdkkaKcFearz:rjjjb8Akcbh8EaEascbyd;0:G:cjbHjjjjbbg8ABd:C9GaOaHaHascdtfaHascitfa8AascbazaKaiawaDaqakz:hjjjbdndnalci6mba8Ahrashmina8EarRbbfh8EarcefhramcufgmmbkaE9cb83iwaE9cb83ibalawc9:fgrfcufar9UgrasaDfcufaD9Ugmaram0EhYcbhmcbhra8Ehaincbh3dnarTmba8AarfRbbceSh3kamaEaiaHydbcx2fgQydbaQclfydbaQcwfydbaKabaeadamawaqa3a3ce7a8EaY9nVaaamfaY6VGz:fjjjbfhmaHclfhHaaa8AarfRbb9Rhaasarcefgr9hmbkaEydxTmeabamcltfgraE8Piw83dwaraE8Pib83dbamcefhmxekaE9cb83iwaE9cb83ibcbhmkczhrinaEc:m;Gbfarfydbcbyd;4:G:cjbH:bjjjbbarc98fgrc989hmbkkaxc;W;Gbf8Kjjjjbamk:wKDQue99iue99iul9:euw99iu8Jjjjjbc;qb9RgP8Kjjjjbaxhsaxhzdndnavax0gHmbdnavTmbcbhOaehzavhAinawaDazydbcx2fgCcwfydbcetfgX8VebhQawaCclfydbcetfgL8VebhKawaCydbcetfgC8VebhYaXce87ebaLce87ebaCce87ebaOaKcs4aYcs4faQcs4ffhOazclfhzaAcufgAmbkaehzavhAinawaDazydbcx2fgCcwfydbcetfcFFi87ebawaCclfydbcetfcFFi87ebawaCydbcetfcFFi87ebazclfhzaAcufgAmbkcehzaqhsaOaq0mekalce86bbalcefcbavcufz:rjjjb8AxekaPaiBdxaPadBdwaPaeBdlavakaqci9Ug8Aaka8Aak6EaHEgK9RhEaxaK9Rh3aKcufh5aKceth8EaKcdtgCc98fh8FavcitgOaC9Rarfc98fhaascufhhavcufhgaraOfh8JJbbjZas:Y:vh8KcbazceakaxSEg8Lcdtg8M9Rh8NJFFuuhycuh8PcbhIcbh8RinaPclfa8RcdtfydbhQaPcb8Pd:y:G:cjbg8S83i9iaPcb8Pd:q:G:cjbgR83inaPcb8Pd1:G:cjbg8U83iUaPcb8Pdj:G:cjbg8V83i8WaPa8S83iyaPaR83iaaPa8U83iKaPa8V83izaQavcdtgYfh8WcbhXinabaQaXcdtgLfydbcK2fhAcbhzinaPc8WfazfgCaAazfgOIdbg8XaCIdbg8Ya8Xa8Y9DEUdbaCczfgCaOcxfIdbg8XaCIdbg8Ya8Xa8Y9EEUdbazclfgzcx9hmbkaba8WaXcu7cdtfydbcK2fhAcbhzaPIdUh8ZaPId9ih80aPId80h81aPId9ehBaPId8Wh83aPIdnhUinaPczfazfgCaAazfgOIdbg8XaCIdbg8Ya8Xa8Y9DEUdbaCczfgCaOcxfIdbg8XaCIdbg8Ya8Xa8Y9EEUdbazclfgzcx9hmbkaraLfgzaBa81:tg8Xa80a8Z:tg8YNaUa83:tg8Za8XNa8Za8YNMMUdbazaYfaPId8KaPIdC:tg8XaPIdyaPIdK:tg8YNaPIdaaPIdz:tg8Za8XNa8Za8YNMMUdbaXcefgXav9hmbkcbh85dnaHmbcbhAaQhza8JhCavhXinawaDazydbcx2fgOcwfydbcetfgL8Vebh8WawaOclfydbcetfg858Vebh86awaOydbcetfgO8Vebh87aLce87eba85ce87ebaOce87ebaCaAa86cs4a87cs4fa8Wcs4ffgABdbazclfhzaCclfhCaXcufgXmbkavhCinawaDaQydbcx2fgzcwfydbcetfcFFi87ebawazclfydbcetfcFFi87ebawazydbcetfcFFi87ebaQclfhQaCcufgCmbka8Jh85kdndndndndndndndndndndnava8E6mba8Eax9nmeavavaK9UgzaK29Raza320mda5aE9pmqa85Th87ceh8WaEhQxwka5ag9pmDa8Eax9nmixokavaK6mea5aE9pmwcehQaEhXa85Tmixlka5ag6mlxrka5ag9pmokcbhQaghXa85mekJFFuuh8XcbhLa5hzindnazcefgCaK6mbaQavaC9RgOaK6GmbarazcdtfIdbg8YaC:YNaravaz9RcdtfaYfc94fIdbg8ZaO:YNMg80a8X9Embdndna8KaOahf:YNg81:lJbbb9p9DTmba81:OhAxekcjjjj94hAka8ZasaA2aO9R:YNh8Zdndna8Kazasf:YNg81:lJbbb9p9DTmba81:OhOxekcjjjj94hOkamasaO2aC9R:Ya8YNa8ZMNa80Mg8Ya8Xa8Ya8X9DgOEh8XaCaLaOEhLkaza8LfgzaX6mbxlkkJFFuuh8XcbhLaEhCaahAa8FhOaKhzindnazaK6mbaQaCaK6GmbaraOfIdbg8Yaz:YNaAIdbg8ZaC:YNMg80a8X9Embdndna8Ka85aOfydbgYahf:YNg81:lJbbb9p9DTmba81:Oh8Wxekcjjjj94h8Wkamasa8W2aY9R:Yg81a8YNa8Za81NMNa80Mg8Ya8Xa8Ya8X9DgYEh8XazaLaYEhLkaCa8L9RhCaAa8NfhAaOa8MfhOaza8LfgzcufaX6mbxikka85Th87cbh8WaghQkJFFuuh8XcbhLaEhCaahAa8FhOaKhzindnazazaK9UgXaK29RaXa320mbdna8WTmbaCaCaK9UgXaK29RaXa320mekaraOfIdbg8Yaz:YNaAIdbg8ZaC:YNMg80a8X9EmbazhXaChYdna87mba85aOfydbgXhYkdndna8KaYahf:YNg81:lJbbb9p9DTmba81:Oh86xekcjjjj94h86ka8Zasa862aY9R:YNh8Zdndna8KaXahf:YNg81:lJbbb9p9DTmba81:OhYxekcjjjj94hYkamasaY2aX9R:Ya8YNa8ZMNa80Mg8Ya8Xa8Ya8X9DgXEh8XazaLaXEhLkaCa8L9RhCaAa8NfhAaOa8MfhOaza8LfgzcufaQ6mbkkaLTmba8Xay9DTmba8XhyaLhIa8Rh8Pka8Rcefg8Rci9hmbkdndnaoc8X9kmba8Pcb9omeka8Acufh85cbhYindndndnavaY9RaxaYaxfav0Eg8WTmbcbhAaeaYcdtfgzhCa8WhXinawaDaCydbcx2fgOcwfydbcetfgQ8VebhbawaOclfydbcetfgL8VebhrawaOydbcetfgO8VebhKaQce87ebaLce87ebaOce87ebaAarcs4aKcs4fabcs4ffhAaCclfhCaXcufgXmbka8WhOinawaDazydbcx2fgCcwfydbcetfcFFi87ebawaCclfydbcetfcFFi87ebawaCydbcetfcFFi87ebazclfhzaOcufgOmbkaAaq0mekalaYfgzce86bbazcefcba8Wcufz:rjjjb8AxekalaYfgzce86bbazcefcba85z:rjjjb8Aa8Ah8Wka8WaYfgYav9pmdxbkkaravcdtg8WfhLdnaITmbaPclfa8PcdtfydbhzaIhCinaLazydbfcb86bbazclfhzaCcufgCmbkkdnavaI9nmbaPclfa8PcdtfydbaIcdtfhzavaI9RhCinaLazydbfce86bbazclfhzaCcufgCmbkkcbhYindnaYa8PSmbcbhzaraPclfaYcdtfydbgKa8Wz:qjjjbhCavhXaIhOinaKaOazaLaCydbgQfRbbgAEcdtfaQBdbaCclfhCaOaAfhOazaA9RcefhzaXcufgXmbkkaYcefgYci9hmbkabaeadaialaIaocefgCarawaDaqakaxamz:hjjjbabaeaIcdtgzfadazfaiazfalaIfavaI9RaCarawaDaqakaxamz:hjjjbkaPc;qbf8Kjjjjbk:Seeru8Jjjjjbc:q;ab9Rgo8Kjjjjbaoc:q8WfcFecjzz:rjjjb8AcbhrdnadTmbaehwadhDinaoarcdtfawydbgqBdbaoc:q8WfaqcFiGcdtfgkydbhxakaqBdbawclfhwaraxaq9hfhraDcufgDmbkkabaeadaoaraiavz:jjjjbaoc:q;abf8Kjjjjbk;Sqloud99euD998Jjjjjbc:W;ab9Rgr8KjjjjbdndnadTmbaocd4hwcbhDcbhqindnavaeclfydbaw2cdtfgkIdbavaeydbaw2cdtfgxIdbgm:tgPavaecwfydbaw2cdtfgsIdlaxIdlgz:tgHNakIdlaz:tgOasIdbam:tgAN:tgCaCNaOasIdwaxIdwgX:tgQNakIdwaX:tgOaHN:tgHaHNaOaANaPaQN:tgPaPNMMgOJbbbb9Bmbarc8WfaDcltfgkaCaO:rgO:vgCUdwakaPaO:vgPUdlakaHaO:vgHUdbakaCaXNaHamNazaPNMM:mUdxaDcefhDkaecxfheaqcifgqad6mbkab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbaDTmearcbBd8Sar9cb83iKar9cb83izarczfavalaoarc8Sfcbcraiz:kjjjbarIdKhQarIdChLarIdzhKar9cb83iwar9cb83ibararc8WfaDczarc8Sfcbcicbz:kjjjbJbbbbhmdnarIdwgzazNarIdbgHaHNarIdlgXaXNMMgCJbbbb9BmbJbbjZaC:r:vhmkazamNhCaXamNhXaHamNhHJbbjZhmarc8WfheaDhvinaecwfIdbaCNaeIdbaHNaXaeclfIdbNMMgzamazam9DEhmaeczfheavcufgvmbkabaQUdwabaLUdlabaKUdbabarId3UdxdndnamJ;n;m;m899FmbJbbbbhzarc8WfheinaecxfIdbaQaecwfIdbgPNaKaeIdbgONaLaeclfIdbgANMMMaCaPNaHaONaXaANMM:vgPazaPaz9EEhzaeczfheaDcufgDmbkabaCUd8KabaXUdaabaHUd3abaQaCazN:tUdKabaLaXazN:tUdCabaKaHazN:tUdzabJbbjZamamN:t:rgmUdydndnaCJbbj:;aCJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aCJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohexekcjjjj94hekabae86b8UdndnaXJbbj:;aXJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aXJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohvxekcjjjj94hvkabav86bRdndnaHJbbj:;aHJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aHJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohwxekcjjjj94hwkabaw86b8SdndnaecKtcK91:YJbb;:9c:vaC:t:lavcKtcK91:YJbb;:9c:vaX:t:lawcKtcK91:YJbb;:9c:vaH:t:lamMMMJbb;:9cNJbbjZMgm:lJbbb9p9DTmbam:Ohexekcjjjj94hekaecFbaecFb9iEhexekabcjjj;8iBdycFbhekabae86b8Vxekab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbkarc:W;abf8Kjjjjbk;7woDuo99eue99euv998Jjjjjbcje9Rgw8Kjjjjbawc;abfcbaocdtgDz:rjjjb8Aawc;GbfcbaDz:rjjjb8AawcafhDawhqaohkinaqcFFF97BdbaDcFFF;7rBdbaqclfhqaDclfhDakcufgkmbkavcd4hxaicd4hmdnadTmbaocx2hPcbhsinashzdnarTmbarascdtfydbhzkaeazam2cdtfgDIdwhHaDIdlhOaDIdbhAalazax2cdtfIdbhCcbhDawcafhqawc;Gbfhvawhkawc;abfhiinaCaDc:O:G:cjbfIdbaHNaDc:G:G:cjbfIdbaANaDc:K:G:cjbfIdbaONMMgXMhQazhLdnaXaC:tgXaqIdbgK9DgYmbavydbhLkavaLBdbazhLdnaQakIdbg8A9EmbaiydbhLa8AhQkaiaLBdbakaQUdbaqaXaKaYEUdbaiclfhiakclfhkavclfhvaqclfhqaPaDcxfgD9hmbkascefgsad9hmbkkJbbbbhQcbhLawc;GbfhDawc;abfhqcbhkinalaqydbgvax2cdtfIdbalaDydbgiax2cdtfIdbaeavam2cdtfgvIdwaeaiam2cdtfgiIdw:tgCaCNavIdbaiIdb:tgCaCNavIdlaiIdl:tgCaCNMM:rMMgCaQaCaQ9EgvEhQakaLavEhLaqclfhqaDclfhDaoakcefgk9hmbkJbbbbhCdnaeawc;abfaLcdtgqfydbgkam2cdtfgDIdwaeawc;Gbfaqfydbgvam2cdtfgqIdwgH:tgXaXNaDIdbaqIdbgA:tg8Aa8ANaDIdlaqIdlgE:tgOaONMMgKJbbbb9ETmbaK:rgCalakax2cdtfIdbMalavax2cdtfIdb:taCaCM:vhCkaQJbbbZNhKaXaCNaHMhHaOaCNaEMhOa8AaCNaAMhAdnadTmbcbhqarhkinaqhDdnarTmbakydbhDkdnalaDax2cdtfIdbg3aeaDam2cdtfgDIdwaH:tgQaQNaDIdbaA:tgCaCNaDIdlaO:tgXaXNMMg5:rgEMg8EaK9ETmbJbbbbh8Adna5Jbbbb9ETmba8EaK:taEaEM:vh8Aka8AaQNaHMhHa8AaXNaOMhOa8AaCNaAMhAa3aKaEMMJbbbZNhKkakclfhkadaqcefgq9hmbkkabaKUdxabaHUdwabaOUdlabaAUdbawcjef8Kjjjjbk:reevu8Jjjjjbcj8W9Rgr8Kjjjjbaici2hwcbhDdnaiTmbarhiawhqinaiaeadRbbgkcdtfydbBdbaDakcefgkaDak0EhDaiclfhiadcefhdaqcufgqmbkkabarawaeaDalaoz:jjjjbarcj8Wf8Kjjjjbk:Eeeeu8Jjjjjbca9Rgo8Kjjjjbab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbdnadTmbaocbBd3ao9cb83iwao9cb83ibaoaeadaialaoc3falEavcbalEcrcbz:kjjjbabao8Pib83dbabao8Piw83dwkaocaf8Kjjjjbk::meQu8Jjjjjbcjz9Rgv8KjjjjbcbhoavcjPfcbaez:rjjjb8Aavcjxfcbaez:rjjjb8AdnaiTmbadhoaihrinavcjxfaoRbbfgwawRbbcef86bbavcjxfaocefRbbfgwawRbbcef86bbavcjxfaocdfRbbfgwawRbbcef86bbaocifhoarcufgrmbkcbhDcjehoadhqcehkindndnalTmbcbhxcuhmaqhrakhwcuhPinawcufamaoavcjPfarcefRbbgsfRbb9RcFeGgzci6aoavcjPfarRbbgHfRbb9RcFeGgOci6faoavcjPfarcdfRbbgAfRbb9RcFeGgCci6fgXcOtaOcFr7azaCf9RcwtVavcjxfaAfRbbgzavcjxfaHfRbbgHavcjxfasfRbbgsaHas6Egsazas6EcFe7VgsaP9kgzEhmaXcd6gHaxcefgOal9iVce9hmdasaPazEhPaxaOaHEhxarcifhrawai6hsawcefhwasmbxdkkcuhmaqhrakhwcuhxinawcufamaoavcjPfarcefRbbfRbb9RcFeGci6aoavcjPfarRbbfRbb9RcFeGci6faoavcjPfarcdfRbbfRbb9RcFeGci6fgPax9kgsEhmaPce0meaPaxasEhxarcifhrawai6hPawcefhwaPmbkkadamci2fgrcdfRbbhwarcefRbbhxarRbbhPadaDci2fgrcifaramaD9Rci2zNjjjb8AaPavcjPffaocefgo86bbaPavcjxffgmamRbbcuf86bbaxavcjPffao86bbaxavcjxffgmamRbbcuf86bbarcdfaw86bbarcefax86bbaraP86bbawavcjPffao86bbawavcjxffgrarRbbcuf86bbaqcifhqakcefhkaDcefgDai9hmbkcbhzdnalcb9mmbcbhsavcjPfcbaez:rjjjb8Aadcvfhlinadasci2fgxcefgDRbbhoaxcdfgqRbbhrdndnavcjPfaxRbbgmfRbbmbavcjPfarfRbbhwdndndnavcjPfaofRbbTmbawcFeGTmexikawcFeGmdascefgAai9pmdasc980mdascifhQcbhLarcFeGhCamcFeGhXalhwcbhKcbhYinawcufRbbhPawRbbhOcehkdndnawc9:fRbbgHao9hmbaPcFeGamSmekdnaPcFeGao9hmbaOcFeGamSmekaHamSaOcFeGaoSGhkkceh8AaYceGhYdndnaHar9hmbaPcFeGaoSmekdnaPcFeGar9hmbaOcFeGaoSmekaHaoSaOcFeGarSGh8AkakaYVhYaLaHcFeGgHaXSaPcFeGgPaCSGaPaXSaOcFeGgPaCSGVaHaCSaPaXSGVVhLa8AaKceGVhKdnaAcefgPai9pmbawcifhwaAaQ6hHaPhAaHmekkaYTmeaKmekarhwaohPaohHarhOamhrxdkdnaYTaLVceGTmbaYaKTVaLVceGmekamhwarhParhHamhOaohrxekaohwamhPamhHaohOkavcjPfarfce86bbavcjPfawfce86bbaxaH86bbaqar86bbaDaO86bbavcjPfaPfce86bbalcifhlascefgsai9hmbkkavcFeaecetz:rjjjbhwaici2hrindnawadRbbgmcetfgx8Uebgocu9kmbaxaz87ebawcjlfazcdtfabamcdtfydbBdbazhoazcefhzkadao86bbadcefhdarcufgrmbkazcdthokabavcjlfaoz:qjjjb8Aavcjzf8KjjjjbkObabaiaeadcbz:njjjbk9teiucbcbyd;8:G:cjbgeabcifc98GfgbBd;8:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd;8:G:cjbgeabcrfc94GfgbBd;8:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd;8:G:cjbge9Rcifc98GaefgbBd;8:G:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akk:3qeludndnadch6mbadTmeabaead;8qbbabskabaeSmbdnaeadabfgi9Rcbadcet9R0mbadTmeabaead;8qbbabskaeab7ciGhldndndnabae9pmbdnalTmbadhvabhixikdnabciGmbadhvabhixdkadTmiabaeRbb86bbadcufhvdnabcefgiciGmbaecefhexdkavTmiabaeRbe86beadc9:fhvdnabcdfgiciGmbaecdfhexdkavTmiabaeRbd86bdadc99fhvdnabcifgiciGmbaecifhexdkavTmiabaeRbi86biabclfhiaeclfheadc98fhvxekdnalmbdnaiciGTmbadTmlabadcufgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc9:fgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc99fgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc98fgdfaeadfRbb86bbkadcl6mbdnadc98fgocxGcxSmbaocd4cefciGhiaec98fhlabc98fhvinavadfaladfydbBdbadc98fhdaicufgimbkkaocx6mbaec9Wfhvabc9WfhoinaoadfgicxfavadfglcxfydbBdbaicwfalcwfydbBdbaiclfalclfydbBdbaialydbBdbadc9Wfgdci0mbkkadTmdadhidnadciGglTmbaecufhvabcufhoadhiinaoaifavaifRbb86bbaicufhialcufglmbkkadcl6mdaec98fhlabc98fhvinavaifgecifalaifgdcifRbb86bbaecdfadcdfRbb86bbaecefadcefRbb86bbaeadRbb86bbaic98fgimbxikkavcl6mbdnavc98fglc3Gc3Smbavalcd4cefcrGgdcdt9RhvinaiaeydbBdbaeclfheaiclfhiadcufgdmbkkalc36mbinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfaeczfydbBdbaicCfaecCfydbBdbaicKfaecKfydbBdbaic3faec3fydbBdbaecafheaicafhiavc9Gfgvci0mbkkavTmbdndnavcrGgdmbavhlxekavc94GhlinaiaeRbb86bbaicefhiaecefheadcufgdmbkkavcw6mbinaiaeRbb86bbaicefaecefRbb86bbaicdfaecdfRbb86bbaicifaecifRbb86bbaiclfaeclfRbb86bbaicvfaecvfRbb86bbaicofaecofRbb86bbaicrfaecrfRbb86bbaicwfhiaecwfhealc94fglmbkkabkk:pedbcj:GdktFFuuFFuuFFuubbbbFFuFFFuFFFuFbbbbbbjZbbbbbbbbbbbbbbjZbbbbbbbbbbbbbbjZ86;nAZ86;nAZ86;nAZ86;nA:;86;nAZ86;nAZ86;nAZ86;nA:;86;nAZ86;nAZ86;nAZ86;nA:;bc;0:Gdkxebbbdbbbj:qbb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,i=WebAssembly.instantiate(r(e),{}).then(function(g){n=g.instance,n.exports.__wasm_call_ctors()});function r(g){var m=new Uint8Array(g.length);for(var p=0;p<g.length;++p){var b=g.charCodeAt(p);m[p]=b>96?b-97:b>64?b-39:b+4}var _=0;for(var p=0;p<g.length;++p)m[_++]=m[p]<60?t[m[p]]:(m[p]-60)*64+m[++p];return m.buffer.slice(0,_)}function s(g){if(!g)throw Error("Assertion failed")}function a(g){return new Uint8Array(g.buffer,g.byteOffset,g.byteLength)}var o=48,c=16;function l(g,m){var p=g.meshlets[m*4+0],b=g.meshlets[m*4+1],_=g.meshlets[m*4+2],x=g.meshlets[m*4+3];return{vertices:g.vertices.subarray(p,p+_),triangles:g.triangles.subarray(b,b+x*3)}}function u(g,m,p,b,_,x,v,E,S,T){var A=n.exports.sbrk,P=n.exports.meshopt_buildMeshletsBound(m.length,x,v),w=A(P*c),I=A(m.length*4),F=A(m.length),N=A(m.byteLength),U=A(p.byteLength),D=new Uint8Array(n.exports.memory.buffer);D.set(a(m),N),D.set(a(p),U);var O=g(w,I,F,N,m.length,U,b,_,x,v,E,S,T);D=new Uint8Array(n.exports.memory.buffer);var K=D.subarray(w,w+O*c),B=new Uint32Array(K.buffer,K.byteOffset,K.byteLength/4).slice();for(var X=0;X<O;++X){var q=B[X*4+0],le=B[X*4+1],b=B[X*4+2],de=B[X*4+3];n.exports.meshopt_optimizeMeshlet(I+q*4,F+le,de,b)}var Me=O?B[(O-1)*4+0]+B[(O-1)*4+2]:0,pe=O?B[(O-1)*4+1]+B[(O-1)*4+3]*3:0,J={meshlets:B,vertices:new Uint32Array(D.buffer,I,Me).slice(),triangles:new Uint8Array(D.buffer,F,pe).slice(),meshletCount:O};return A(w-A(0)),J}function d(g){var m=new Float32Array(n.exports.memory.buffer,g,o/4);return{centerX:m[0],centerY:m[1],centerZ:m[2],radius:m[3],coneApexX:m[4],coneApexY:m[5],coneApexZ:m[6],coneAxisX:m[7],coneAxisY:m[8],coneAxisZ:m[9],coneCutoff:m[10]}}function f(g,m,p,b){var _=n.exports.sbrk,x=[],v=_(m.byteLength),E=_(g.vertices.byteLength),S=_(g.triangles.byteLength),T=_(o),A=new Uint8Array(n.exports.memory.buffer);A.set(a(m),v),A.set(a(g.vertices),E),A.set(a(g.triangles),S);for(var P=0;P<g.meshletCount;++P){var w=g.meshlets[P*4+0],I=g.meshlets[P*4+1],F=g.meshlets[P*4+3];n.exports.meshopt_computeMeshletBounds(T,E+w*4,S+I,F,v,p,b),x.push(d(T))}return _(v-_(0)),x}function h(g,m,p,b){var _=n.exports.sbrk,x=_(o),v=_(g.byteLength),E=_(m.byteLength),S=new Uint8Array(n.exports.memory.buffer);S.set(a(g),v),S.set(a(m),E),n.exports.meshopt_computeClusterBounds(x,v,g.length,E,p,b);var T=d(x);return _(x-_(0)),T}function y(g,m,p,b,_){var x=n.exports.sbrk,v=x(o),E=x(g.byteLength),S=b?x(b.byteLength):0,T=new Uint8Array(n.exports.memory.buffer);if(T.set(a(g),E),b)T.set(a(b),S);n.exports.meshopt_computeSphereBounds(v,E,m,p,S,b?_:0);var A=d(v);return x(v-x(0)),A}return{ready:i,supported:!0,buildMeshlets:function(g,m,p,b,_,x){s(g.length%3==0),s(m instanceof Float32Array),s(m.length%p==0),s(p>=3),s(b>=3&&b<=256),s(_>=1&&_<=512),x=x||0;var v=g.BYTES_PER_ELEMENT==4?g:new Uint32Array(g);return u(n.exports.meshopt_buildMeshletsFlex,v,m,m.length/p,p*4,b,_,_,x,0)},buildMeshletsFlex:function(g,m,p,b,_,x,v,E){s(g.length%3==0),s(m instanceof Float32Array),s(m.length%p==0),s(p>=3),s(b>=3&&b<=256),s(_>=1&&x<=512),s(_<=x),v=v||0,E=E||0;var S=g.BYTES_PER_ELEMENT==4?g:new Uint32Array(g);return u(n.exports.meshopt_buildMeshletsFlex,S,m,m.length/p,p*4,b,_,x,v,E)},buildMeshletsSpatial:function(g,m,p,b,_,x,v){s(g.length%3==0),s(m instanceof Float32Array),s(m.length%p==0),s(p>=3),s(b>=3&&b<=256),s(_>=1&&x<=512),s(_<=x),v=v||0;var E=g.BYTES_PER_ELEMENT==4?g:new Uint32Array(g);return u(n.exports.meshopt_buildMeshletsSpatial,E,m,m.length/p,p*4,b,_,x,v)},extractMeshlet:function(g,m){return s(m>=0&&m<g.meshletCount),l(g,m)},computeClusterBounds:function(g,m,p){s(g.length%3==0),s(g.length/3<=512),s(m instanceof Float32Array),s(m.length%p==0),s(p>=3);var b=g.BYTES_PER_ELEMENT==4?g:new Uint32Array(g);return h(b,m,m.length/p,p*4)},computeMeshletBounds:function(g,m,p){return s(m instanceof Float32Array),s(m.length%p==0),s(p>=3),f(g,m,m.length/p,p*4)},computeSphereBounds:function(g,m,p,b){return s(g instanceof Float32Array),s(g.length%m==0),s(m>=3),s(!p||p instanceof Float32Array),s(!p||p.length%b==0),s(!p||b>=1),s(!p||g.length/m==p.length/b),b=b||0,y(g,g.length/m,m*4,p,b*4)}}}()});var FM={};pb(FM,{MeshoptEncoder:()=>g9});var UM=Ft(()=>{OM();kM();DM();LM()});function Xo(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function xf(e,t="|"){return e.map((n)=>Ef(n)).join(t)}function qo(e,t){if(typeof t==="bigint")return t.toString();return t}class mb{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function Jo(e){return new mb(e)}function gb(e){return e===null||e===void 0}function Jr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function bb(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function hi(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Zo(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Ar(e){return Zo(e._zod.def)??e._zod.def.shape}function yb(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return hi(this,t,i),i},enumerable:!0,configurable:!0})}function xb(e,t,n){if(t in e)hi(e,t,n);else e[t]=n}function Qs(e,t,n,i){let r=Ar(t);for(let s of n){let a=Object.getOwnPropertyDescriptor(r,s);if(!a.enumerable)continue;if(a.get)yb(e,s,()=>{let o=t._zod.def.shape[s];return i?i(o,s):o});else xb(e,s,i?i(a.value,s):a.value)}}function RR(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)yb(e,n,()=>t[n]);else xb(e,n,i.value)}}function Jn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function _b(e){return JSON.stringify(e)}function vb(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var _f="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function La(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Eb=Jo(()=>{if(Ln.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function ea(e){if(La(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(La(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function vf(e){if(ea(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Tb=new Set(["string","number","symbol"]),Ab=new Set(["string","number","bigint","boolean","symbol","undefined"]);function wr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wi(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function Fe(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Ef(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Sb(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Rl=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Tf={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function IR(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return Qs(s,e,Il(e,t)),Wi(e,Jn(n,{shape:s,checks:[]}))}function Il(e,t){let n=Ar(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function CR(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Il(e,t)),a={};return Qs(a,e,Reflect.ownKeys(Ar(e)).filter((o)=>!s.has(o))),Wi(e,Jn(n,{shape:a,checks:[]}))}function NR(e,t){if(!ea(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Ar(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Wi(e,Jn(e._zod.def,{shape:wb(e,t)}))}function wb(e,t){let n={};return Qs(n,e,Reflect.ownKeys(Ar(e))),RR(n,t),n}function PR(e,t){if(!ea(t))throw Error("Invalid input to safeExtend: expected a plain object");return Wi(e,Jn(e._zod.def,{shape:wb(e,t)}))}function OR(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Qs(n,e,Reflect.ownKeys(Ar(e))),Qs(n,t,Reflect.ownKeys(Ar(t)));let i=Jn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Wi(e,i)}function Mb(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let o=n?new Set(Il(t,n)):void 0,c={};return Qs(c,t,Reflect.ownKeys(Ar(t)),e&&((l,u)=>o&&!o.has(u)?l:new e({type:"optional",innerType:l}))),Wi(t,Jn(t._zod.def,{shape:c,checks:[]}))}function kR(e,t,n){let i=n?new Set(Il(t,n)):void 0,r={};return Qs(r,t,Reflect.ownKeys(Ar(t)),(s,a)=>i&&!i.has(a)?s:new e({type:"nonoptional",innerType:s})),Wi(t,Jn(t._zod.def,{shape:r}))}function pi(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Rb(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Xi(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Wo(e){return typeof e==="string"?e:e?.message}function Af(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function qi(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,a=e.message?e.message:Wo(e.inst?._zod.def?.error?.(e))??Wo(s?.(e))??Wo(t?.error?.(e))??Wo(n.customError?.(e))??Wo(n.localeError?.(e))??"Invalid input",o={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;o[c]=e[c]}if(o.path??(o.path=[]),o.message=a,t?.reportInput)o.input=e.input;return o}var DR=/[\uD800-\uDBFF]/;function Cl(e){let t=e.length;if(!DR.test(e))return t;let n=t;for(let i=0;i<t-1;i++)if((e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320)n--,i++;return n}function Nl(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Ib(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function ta(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function Cb(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else LR(e,n,i.value)}}function Sr(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function Pl(e,t,n){return Sr(e,t,n,!1)}function Nb(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Sr(this,n,i(this))},set(r){Sr(this,n,r)}})}return t}function LR(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Sr(this,t,n.bind(this))},set(i){Sr(this,t,i)}})}function FR(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var yf,qr=!1,UR={configurable:!0,get(){qr=!0;return}};function vt(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&yf!==e._zod){yf=void 0;return}yf=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,UR);let r=qr;qr=!1;try{let s=n(this);if(qr)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return qr=qr||r,s}catch(s){throw delete this[t],qr=qr||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function BR(e,t,n,i){let r=FR(e,t);if(!r)return;Object.defineProperty(r,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:s})}})}var zR="~constantCatch";function Pb(e){let t=()=>e;return t[zR]=!0,t}var Ob;var Sf={value:void 0,enumerable:!1},kb="captureStackTrace"in Error?Error:null;function VR(e){let t=kb;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return kb=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function se(e,t,n,i){let r={};function s(f){this.def=f,this.constr=d,this.traits=new Set}s.prototype=r;let a=n,o=a&&new WeakSet;function c(f,h){if(!f._zod){Sf.value=new s(h);try{Object.defineProperty(f,"_zod",Sf)}finally{Sf.value=void 0}}else if(f._zod.traits.has(e))return;if(f._zod.traits.add(e),t(f,h),o){let g=Object.getPrototypeOf(f),m=f._zod.constr.prototype,p=g;while(p&&p!==m)p=Object.getPrototypeOf(p);let b=p??g;if(!o.has(b))o.add(b),Cb(b,a)}let y=d.prototype;for(let g in y){if(!Object.prototype.hasOwnProperty.call(y,g))continue;if(!(g in f))f[g]=y[g].bind(f)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(f){let h=i?.Parent?VR(u):this;c(h,f);let y=h._zod.deferred;if(y){for(let m of y)m();h._zod.deferred=void 0}let g=globalThis.__zod_globalConfig?.postProcessor;if(g)g(h);return h}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:(f)=>{if(i?.Parent&&f instanceof i.Parent)return!0;return f?._zod?.traits?.has(e)}}),Object.defineProperty(d,"name",{value:e}),d}class Ji extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Yo extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Ob=globalThis).__zod_globalConfig??(Ob.__zod_globalConfig={});var Ln=globalThis.__zod_globalConfig;function Zn(e){if(e)Object.assign(Ln,e);return Ln}function jR(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,qo,2)),e.message}function HR(e){this._zod.message=e}var GR={get:jR,set:HR,enumerable:!0,configurable:!0},Mf={value:void 0,enumerable:!1},Db=new WeakSet([Object.prototype,Error.prototype]),Lb=(e,t)=>{e.name="$ZodError",Mf.value=t,Object.defineProperty(e,"issues",Mf),Mf.value=void 0,Object.defineProperty(e,"message",GR);let n=Object.getPrototypeOf(e);if(!Db.has(n))Db.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}})},Fb=se("$ZodError",Lb),P9=se("$ZodError",Lb,void 0,{Parent:Error});function $R(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function Ub(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)$R(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function Bb(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let a of r.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map((o)=>i({issues:o},[...s,...a.path]));else if(a.code==="invalid_key")i({issues:a.issues},[...s,...a.path]);else if(a.code==="invalid_element")i({issues:a.issues},[...s,...a.path]);else{let o=[...s,...a.path];if(o.length===0)n._errors.push(t(a));else{let c=n,l=0;while(l<o.length){let u=o[l],d=l===o.length-1;if(u==="_errors"){if(d)c._errors.push(t(a));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[u];if(d)f._errors.push(t(a));c=f,l++}}}};return i(e),n}function Ol(e,t){return{callee:t?.callee??e,Err:t?.Err}}var kl=(e)=>{let t=(n,i,r,s)=>{let a=r?{...r,async:!1}:{async:!1},o=n._zod.run({value:i,issues:[]},a);if(o instanceof Promise)throw new Ji;if(o.issues.length){let c=new(s?.Err??e)(o.issues.map((l)=>qi(l,a,Zn())));throw _f(c,s?.callee??t),c}return o.value};return t};var Dl=(e)=>{let t=async(n,i,r,s)=>{let a=r?{...r,async:!0}:{async:!0},o=n._zod.run({value:i,issues:[]},a);if(o instanceof Promise)o=await o;if(o.issues.length){let c=new(s?.Err??e)(o.issues.map((l)=>qi(l,a,Zn())));throw _f(c,s?.callee??t),c}return o.value};return t};var Ll=(e)=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new Ji;return s.issues.length?zb(e,s.issues,r):{success:!0,data:s.value}};function zb(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>qi(r,n,Zn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Fl=(e)=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?zb(e,s.issues,r):{success:!0,data:s.value}};var KR=Symbol.for("zod.compile.invalid"),WR=Symbol.for("zod.compile.fallback"),Rf=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==KR)return!0;if(i.definite===!0&&n===void 0)return!1}return XR(e,t,n)};function XR(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[WR]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Ji;return s.issues.length===0}var If=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)r=await r;return r.issues.length===0},Vb=(e)=>{let t=kl(e),n=(i,r,s,a)=>{let o=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,o,Ol(n,a))};return n};var jb=(e)=>{let t=kl(e),n=(i,r,s,a)=>t(i,r,s,Ol(n,a));return n};var Hb=(e)=>{let t=Dl(e),n=async(i,r,s,a)=>{let o=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,o,Ol(n,a))};return n};var Gb=(e)=>{let t=Dl(e),n=async(i,r,s,a)=>await t(i,r,s,Ol(n,a));return n};var $b=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Ll(e)(t,n,r)};var Kb=(e)=>(t,n,i)=>Ll(e)(t,n,i);var Wb=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Fl(e)(t,n,r)};var Xb=(e)=>async(t,n,i)=>Fl(e)(t,n,i);var qb=/^[cC][0-9a-z]{6,}$/,Jb=/^[0-9a-z]+$/,Zb=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Yb=/^[0-9a-vA-V]{20}$/,Qb=/^[A-Za-z0-9]{27}$/,ey=/^[a-zA-Z0-9_-]{21}$/;function ty(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var ny=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var iy=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Nf=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var ry=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var qR="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function sy(){return new RegExp(qR,"u")}var ay=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,oy=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var cy=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ly=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,uy=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,dy=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var fy=/^https?$/,hy=/^\+[1-9]\d{6,14}$/;var py="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function JR(e){return new RegExp(`^${e}$`)}var my=JR(py);function Cf(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function gy(e){return new RegExp(`^${Cf(e)}$`)}function by(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Cf({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Cf({precision:e.precision})}`:n;return new RegExp(`^${py}T(?:${i})$`)}var yy=/^[\s\S]{0,}$/,xy=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Ul=/^-?\d+$/,Fa=/^-?\d+(?:\.\d+)?$/,_y=/^(?:true|false)$/i;var vy=/^[^A-Z]*$/,Ey=/^[^a-z]*$/;var Sn=se("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Pf=(e)=>{let t=e.value;return!gb(t)&&t.length!==void 0},Bl={number:"number",bigint:"bigint",object:"date"},Of=se("$ZodCheckLessThan",(e,t)=>{Sn.init(e,t);let n=Bl[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:Bl[typeof i.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),kf=se("$ZodCheckGreaterThan",(e,t)=>{Sn.init(e,t);let n=Bl[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:Bl[typeof i.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ty=se("$ZodCheckMultipleOf",(e,t)=>{Sn.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):bb(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ay=se("$ZodCheckNumberFormat",(e,t)=>{Sn.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Rl[t.format];e._zod.check=(a)=>{let o=a.value;if(n){if(!Number.isInteger(o)){a.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:o,inst:e});return}if(!Number.isSafeInteger(o)){if(o>0)a.issues.push({input:o,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else a.issues.push({input:o,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(o<r)a.issues.push({origin:"number",input:o,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(o>s)a.issues.push({origin:"number",input:o,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Sy=se("$ZodCheckMaxLength",(e,t)=>{var n;Sn.init(e,t),(n=e._zod.def).when??(n.when=Pf),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Cl(r):s)<=t.maximum)return;let o=Nl(r);i.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),wy=se("$ZodCheckMinLength",(e,t)=>{var n;Sn.init(e,t),(n=e._zod.def).when??(n.when=Pf),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Cl(r):s)>=t.minimum)return;let o=Nl(r);i.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),My=se("$ZodCheckLengthEquals",(e,t)=>{var n;Sn.init(e,t),(n=e._zod.def).when??(n.when=Pf),e._zod.check=(i)=>{let r=i.value,s=r.length,a=typeof r==="string"&&s>=t.length&&s<=t.length*2?Cl(r):s;if(a===t.length)return;let o=Nl(r),c=a>t.length;i.issues.push({origin:o,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),ec=se("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Sn.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),Ry=se("$ZodCheckRegex",(e,t)=>{ec.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Iy=se("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=vy),ec.init(e,t)}),Cy=se("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ey),ec.init(e,t)}),Ny=se("$ZodCheckIncludes",(e,t)=>{Sn.init(e,t);let n=wr(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Py=se("$ZodCheckStartsWith",(e,t)=>{Sn.init(e,t);let n=new RegExp(`^${wr(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),Oy=se("$ZodCheckEndsWith",(e,t)=>{Sn.init(e,t);let n=new RegExp(`.*${wr(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var ky=se("$ZodCheckOverwrite",(e,t)=>{Sn.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class Df{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`+`));return d(c3.bind(void 0,e))}WS.exports=l3});var JS=Jr(function(K5,qS){var u3=XS();function d3(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function f3(e){var t=new d3;t.pre=e.pre,t.body=e.body,t.post=e.post;var n=e.args.slice(0);t.argTypes=n;for(var i=0;i<n.length;++i){var r=n[i];if(r==="array"||typeof r==="object"&&r.blockIndices){if(t.argTypes[i]="array",t.arrayArgs.push(i),t.arrayBlockIndices.push(r.blockIndices?r.blockIndices:0),t.shimArgs.push("array"+i),i<t.pre.args.length&&t.pre.args[i].count>0)throw Error("cwise: pre() block may not reference array args");if(i<t.post.args.length&&t.post.args[i].count>0)throw Error("cwise: post() block may not reference array args")}else if(r==="scalar")t.scalarArgs.push(i),t.shimArgs.push("scalar"+i);else if(r==="index"){if(t.indexArgs.push(i),i<t.pre.args.length&&t.pre.args[i].count>0)throw Error("cwise: pre() block may not reference array index");if(i<t.body.args.length&&t.body.args[i].lvalue)throw Error("cwise: body() block may not write to array index");if(i<t.post.args.length&&t.post.args[i].count>0)throw Error("cwise: post() block may not reference array index")}else if(r==="shape"){if(t.shapeArgs.push(i),i<t.pre.args.length&&t.pre.args[i].lvalue)throw Error("cwise: pre() block may not write to array shape");if(i<t.body.args.length&&t.body.args[i].lvalue)throw Error("cwise: body() block may not write to array shape");if(i<t.post.args.length&&t.post.args[i].lvalue)throw Error("cwise: post() block may not write to array shape")}else if(typeof r==="object"&&r.offset)t.argTypes[i]="offset",t.offsetArgs.push({array:r.array,offset:r.offset}),t.offsetArgIndex.push(i);else throw Error("cwise: Unknown argument type "+n[i])}if(t.arrayArgs.length<=0)throw Error("cwise: No array arguments specified");if(t.pre.args.length>n.length)throw Error("cwise: Too many arguments in pre() block");if(t.body.args.length>n.length)throw Error("cwise: Too many arguments in body() block");if(t.post.args.length>n.length)throw Error("cwise: Too many arguments in post() block");return t.debug=!!e.printCode||!!e.debug,t.funcName=e.funcName||"cwise",t.blockSize=e.blockSize||64,u3(t)}qS.exports=f3});var iM=Jr(function(an){var Yn=JS(),ff={body:"",args:[],thisVars:[],localVars:[]};function Wg(e){if(!e)return ff;for(var t=0;t<e.args.length;++t){var n=e.args[t];if(t===0)e.args[t]={name:n,lvalue:!0,rvalue:!!e.rvalue,count:e.count||1};else e.args[t]={name:n,lvalue:!1,rvalue:!0,count:1}}if(!e.thisVars)e.thisVars=[];if(!e.localVars)e.localVars=[];return e}function h3(e){return Yn({args:e.args,pre:Wg(e.pre),body:Wg(e.body),post:Wg(e.proc),funcName:e.funcName})}function Yt(e){var t=[];for(var n=0;n<e.args.length;++n)t.push("a"+n);var i=Function("P",["return function ",e.funcName,"_ndarrayops(",t.join(","),") {P(",t.join(","),");return a0}"].join(""));return i(h3(e))}var ZS={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var e in ZS){var t=ZS[e];an[e]=Yt({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),an[e+"eq"]=Yt({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:e+"eq"}),an[e+"s"]=Yt({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),an[e+"seq"]=Yt({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:e+"seq"})}})();var YS={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var e in YS){var t=YS[e];an[e]=Yt({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:e}),an[e+"eq"]=Yt({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:e+"eq"})}})();var QS={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var e in QS){var t=QS[e];an[e]=Yt({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),an[e+"s"]=Yt({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),an[e+"eq"]=Yt({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:e+"eq"}),an[e+"seq"]=Yt({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:e+"seq"})}})();var eM=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var e=0;e<eM.length;++e){var t=eM[e];an[t]=Yt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:t}),an[t+"eq"]=Yt({args:["array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"})}})();var tM=["max","min","atan2","pow"];(function(){for(var e=0;e<tM.length;++e){var t=tM[e];an[t]=Yt({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t}),an[t+"s"]=Yt({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t+"s"}),an[t+"eq"]=Yt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"}),an[t+"seq"]=Yt({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"seq"})}})();var nM=["atan2","pow"];(function(){for(var e=0;e<nM.length;++e){var t=nM[e];an[t+"op"]=Yt({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"op"}),an[t+"ops"]=Yt({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"ops"}),an[t+"opeq"]=Yt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opeq"}),an[t+"opseq"]=Yt({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opseq"})}})();an.any=Yn({args:["array"],pre:ff,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});an.all=Yn({args:["array"],pre:ff,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});an.sum=Yn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});an.prod=Yn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});an.norm2squared=Yn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});an.norm2=Yn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});an.norminf=Yn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});an.norm1=Yn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});an.sup=Yn({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});an.inf=Yn({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});an.argmin=Yn({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});an.argmax=Yn({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});an.random=Yt({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});an.assign=Yt({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});an.assigns=Yt({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});an.equals=Yn({args:["array","array"],pre:ff,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})});function N3(e,t){if(!(e instanceof Uint8Array))throw Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let n=new Blob([e],{type:t});return createImageBitmap(n,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then((i)=>{let r=new OffscreenCanvas(i.width,i.height).getContext("2d");r.drawImage(i,0,0);let s=r.getImageData(0,0,i.width,i.height);return rM.default(new Uint8Array(s.data),[i.width,i.height,4],[4,4*i.width,1],0)})}async function sM(e,t){return N3(e,t)}var rM,C3;var aM=mt(()=>{rM=kf($g(),1),C3=kf(iM(),1)});function vf(e,t){return Object.defineProperty(t,"name",{value:e}),t}function Ef(e,t){let n={...e};for(let i in t)if(t[i]!==void 0)n[i]=t[i];return n}function EM(e){let t=[];for(let n of e.listAttributes())t.push(n);for(let n of e.listTargets())for(let i of n.listAttributes())t.push(i);return Array.from(new Set(t))}function O3(e,t){if(e==null&&t==null)return!0;if(e==null||t==null)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function gf(e,t){return e.createAccessor(t.getName()).setArray(t.getArray()).setType(t.getType()).setBuffer(t.getBuffer()).setNormalized(t.getNormalized()).setSparse(t.getSparse())}function k3(e,t=e){let n=TM(e,t);for(let i=0;i<n.length;i++)n[i]=i;return n}function TM(e,t=e){return t<=65534?new Uint16Array(e):new Uint32Array(e)}function AM(e){for(let t in e)return!1;return!0}function D3(e,t){var n=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],h=t[11],b=t[12],m=t[13],g=t[14],p=t[15],x=n*o-i*a,_=n*c-r*a,y=n*l-s*a,v=i*c-r*o,T=i*l-s*o,A=r*l-s*c,E=u*m-d*b,w=u*g-f*b,P=u*p-h*b,S=d*g-f*m,I=d*p-h*m,U=f*p-h*g,N=x*U-_*I+y*S+v*P-T*w+A*E;if(!N)return null;return N=1/N,e[0]=(o*U-c*I+l*S)*N,e[1]=(r*I-i*U-s*S)*N,e[2]=(m*A-g*T+p*v)*N,e[3]=(f*T-d*A-h*v)*N,e[4]=(c*P-a*U-l*w)*N,e[5]=(n*U-r*P+s*w)*N,e[6]=(g*y-b*A-p*_)*N,e[7]=(u*A-f*y+h*_)*N,e[8]=(a*I-o*P+l*E)*N,e[9]=(i*P-n*I-s*E)*N,e[10]=(b*T-m*y+p*x)*N,e[11]=(d*y-u*T-h*x)*N,e[12]=(o*w-a*S-c*E)*N,e[13]=(n*S-i*w+r*E)*N,e[14]=(m*_-b*v-g*x)*N,e[15]=(u*v-d*_+f*x)*N,e}function eb(e,t,n){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],h=t[10],b=t[11],m=t[12],g=t[13],p=t[14],x=t[15],_=n[0],y=n[1],v=n[2],T=n[3];return e[0]=_*i+y*o+v*d+T*m,e[1]=_*r+y*c+v*f+T*g,e[2]=_*s+y*l+v*h+T*p,e[3]=_*a+y*u+v*b+T*x,_=n[4],y=n[5],v=n[6],T=n[7],e[4]=_*i+y*o+v*d+T*m,e[5]=_*r+y*c+v*f+T*g,e[6]=_*s+y*l+v*h+T*p,e[7]=_*a+y*u+v*b+T*x,_=n[8],y=n[9],v=n[10],T=n[11],e[8]=_*i+y*o+v*d+T*m,e[9]=_*r+y*c+v*f+T*g,e[10]=_*s+y*l+v*h+T*p,e[11]=_*a+y*u+v*b+T*x,_=n[12],y=n[13],v=n[14],T=n[15],e[12]=_*i+y*o+v*d+T*m,e[13]=_*r+y*c+v*f+T*g,e[14]=_*s+y*l+v*h+T*p,e[15]=_*a+y*u+v*b+T*x,e}function L3(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function F3(e,t,n,i){var r=t[0],s=t[1],a=t[2],o=t[3],c=r+r,l=s+s,u=a+a,d=r*c,f=r*l,h=r*u,b=s*l,m=s*u,g=a*u,p=o*c,x=o*l,_=o*u,y=i[0],v=i[1],T=i[2];return e[0]=(1-(b+g))*y,e[1]=(f+_)*y,e[2]=(h-x)*y,e[3]=0,e[4]=(f-_)*v,e[5]=(1-(d+g))*v,e[6]=(m+p)*v,e[7]=0,e[8]=(h+x)*T,e[9]=(m-p)*T,e[10]=(1-(d+b))*T,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function xf(e,t){let n=e.getAttribute("POSITION"),i=e.getIndices();if(!n)return 0;switch(t){case"render":return i?i.getCount():n.getCount();case"render-cached":return i?new Set(i.getArray()).size:n.getCount();case"upload-naive":case"upload":return n.getCount();case"distinct":case"distinct-position":return U3(t);case"unused":return i?n.getCount()-new Set(i.getArray()).size:0;default:return B3(t)}}function U3(e){throw Error(`Not implemented: ${e}`)}function B3(e){throw Error(`Unexpected value: ${e}`)}function z3(e,t,n){let i=rf.fromGraph(e.getGraph());if(!t||!n)[t,n]=V3(e);let r=e.getIndices(),s=r?r.getArray():null,a=xf(e,"render"),o=i.createAccessor(),c=a,l=TM(c,n);for(let d=0;d<c;d++)l[d]=t[s?s[d]:d];e.setIndices(o.setArray(l));let u=EM(e);for(let d of e.listAttributes()){let f=gf(i,d);Jg(d,r,t,f,n),e.swap(d,f)}for(let d of e.listTargets())for(let f of d.listAttributes()){let h=gf(i,f);Jg(f,r,t,h,n),d.swap(f,h)}if(r&&r.listParents().length===1)r.dispose();for(let d of u)if(d.listParents().length===1)d.dispose();return e}function Jg(e,t,n,i,r){let s=e.getElementSize(),a=e.getArray(),o=t?t.getArray():null,c=t?t.getCount():e.getCount(),l=new a.constructor(r*s),u=new Uint8Array(r);for(let d=0;d<c;d++){let f=o?o[d]:d,h=n[f];if(u[h])continue;for(let b=0;b<s;b++)l[h*s+b]=a[f*s+b];u[h]=1}return i.setArray(l)}function V3(e){let t=xf(e,"upload"),n=e.getIndices(),i=n?n.getArray():null;if(!n||!i)return[k3(t,1e6),t];let r=new Uint32Array(t).fill(oM),s=0;for(let a=0;a<i.length;a++){let o=i[a];if(r[o]===oM)r[o]=s++}return[r,s]}function j3(){var e=new bf(3);if(bf!=Float32Array)e[0]=0,e[1]=0,e[2]=0;return e}function H3(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e}function Zg(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e}function Yg(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e}function cM(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function G3(e,t,n){var i=t[0],r=t[1],s=t[2],a=n[3]*i+n[7]*r+n[11]*s+n[15];return a=a||1,e[0]=(n[0]*i+n[4]*r+n[8]*s+n[12])/a,e[1]=(n[1]*i+n[5]*r+n[9]*s+n[13])/a,e[2]=(n[2]*i+n[6]*r+n[10]*s+n[14])/a,e}function tb(e=qg){let t=Ef(qg,e),n=new Set(t.propertyTypes);for(let i of t.propertyTypes)if(!qg.propertyTypes.includes(i))throw Error(`${qs}: Unsupported deduplication on type "${i}".`);return vf(qs,(i)=>{let r=i.getLogger();if(n.has(te.ACCESSOR))K3(i);if(n.has(te.TEXTURE))X3(i,t);if(n.has(te.MATERIAL))q3(i,t);if(n.has(te.MESH))W3(i,t);if(n.has(te.SKIN))J3(i,t);r.debug(`${qs}: Complete.`)})}function K3(e){let t=e.getLogger(),n=new Map,i=new Map,r=new Map,s=new Map,a=e.getRoot().listMeshes();a.forEach((d)=>{d.listPrimitives().forEach((f)=>{f.listAttributes().forEach((h)=>o(h,i)),o(f.getIndices(),n)})});for(let d of e.getRoot().listAnimations())for(let f of d.listSamplers())o(f.getInput(),r),o(f.getOutput(),s);function o(d,f){if(!d)return;let h=[d.getCount(),d.getType(),d.getComponentType(),d.getNormalized(),d.getSparse()].join(":"),b=f.get(h);if(!b)f.set(h,b=new Set);b.add(d)}function c(d,f){for(let h=0;h<d.length;h++){let b=d[h],m=Je.toView(b.getArray());if(f.has(b))continue;for(let g=h+1;g<d.length;g++){let p=d[g];if(f.has(p))continue;if(Je.equals(m,Je.toView(p.getArray())))f.set(p,b)}}}let l=0,u=new Map;for(let d of[i,n,r,s])for(let f of d.values())l+=f.size,c(Array.from(f),u);t.debug(`${qs}: Merged ${u.size} of ${l} accessors.`),a.forEach((d)=>{d.listPrimitives().forEach((f)=>{f.listAttributes().forEach((b)=>{if(u.has(b))f.swap(b,u.get(b))});let h=f.getIndices();if(h&&u.has(h))f.swap(h,u.get(h))})});for(let d of e.getRoot().listAnimations())for(let f of d.listSamplers()){let h=f.getInput(),b=f.getOutput();if(h&&u.has(h))f.swap(h,u.get(h));if(b&&u.has(b))f.swap(b,u.get(b))}Array.from(u.keys()).forEach((d)=>d.dispose())}function W3(e,t){let n=e.getLogger(),i=e.getRoot(),r=new Map;i.listAccessors().forEach((o,c)=>r.set(o,c)),i.listMaterials().forEach((o,c)=>r.set(o,c));let s=i.listMeshes().length,a=new Map;for(let o of i.listMeshes()){let c=[];for(let u of o.listPrimitives())c.push(wM(u,r));let l="";if(t.keepUniqueNames)l+=o.getName()+";";if(l+=c.join(";"),a.has(l)){let u=a.get(l);o.listParents().forEach((d)=>{if(d.propertyType!==te.ROOT)d.swap(o,u)}),o.dispose()}else a.set(l,o)}n.debug(`${qs}: Merged ${s-a.size} of ${s} meshes.`)}function X3(e,t){let n=e.getLogger(),i=e.getRoot(),r=i.listTextures(),s=new Map;for(let a=0;a<r.length;a++){let o=r[a],c=o.getImage();if(s.has(o))continue;for(let l=a+1;l<r.length;l++){let u=r[l],d=u.getImage();if(s.has(u))continue;if(o.getMimeType()!==u.getMimeType())continue;if(t.keepUniqueNames&&o.getName()!==u.getName())continue;let f=o.getSize(),h=u.getSize();if(!f||!h)continue;if(f[0]!==h[0])continue;if(f[1]!==h[1])continue;if(!c||!d)continue;if(Je.equals(c,d))s.set(u,o)}}n.debug(`${qs}: Merged ${s.size} of ${i.listTextures().length} textures.`),Array.from(s.entries()).forEach(([a,o])=>{a.listParents().forEach((c)=>{if(!(c instanceof Ps))c.swap(a,o)}),a.dispose()})}function q3(e,t){let n=e.getLogger(),i=e.getRoot().listMaterials(),r=new Map,s=new Map,a=new Set;if(!t.keepUniqueNames)a.add("name");for(let o=0;o<i.length;o++){let c=i[o];if(r.has(c))continue;if(lM(c,s))continue;for(let l=o+1;l<i.length;l++){let u=i[l];if(r.has(u))continue;if(lM(u,s))continue;if(c.equals(u,a))r.set(u,c)}}n.debug(`${qs}: Merged ${r.size} of ${i.length} materials.`),Array.from(r.entries()).forEach(([o,c])=>{o.listParents().forEach((l)=>{if(!(l instanceof Ps))l.swap(o,c)}),o.dispose()})}function J3(e,t){let n=e.getLogger(),i=e.getRoot().listSkins(),r=new Map,s=new Set(["joints"]);if(!t.keepUniqueNames)s.add("name");for(let a=0;a<i.length;a++){let o=i[a];if(r.has(o))continue;for(let c=a+1;c<i.length;c++){let l=i[c];if(r.has(l))continue;if(o.equals(l,s)&&O3(o.listJoints(),l.listJoints()))r.set(l,o)}}n.debug(`${qs}: Merged ${r.size} of ${i.length} skins.`),Array.from(r.entries()).forEach(([a,o])=>{a.listParents().forEach((c)=>{if(!(c instanceof Ps))c.swap(a,o)}),a.dispose()})}function wM(e,t){let n=[];for(let i of e.listSemantics()){let r=e.getAttribute(i);n.push(i+":"+t.get(r))}if(e instanceof Jn){let i=e.getIndices();if(i)n.push("indices:"+t.get(i));let r=e.getMaterial();if(r)n.push("material:"+t.get(r));n.push("mode:"+e.getMode());for(let s of e.listTargets())n.push("target:"+wM(s,t))}return n.join(",")}function lM(e,t){if(t.has(e))return t.get(e);let n=e.getGraph(),i=new Set,r=n.listParentEdges(e);while(r.length>0){let s=r.pop();if(s.getAttributes().modifyChild===!0)return t.set(e,!0),!0;let a=s.getChild();if(i.has(a))continue;for(let o of n.listChildEdges(a))r.push(o)}return t.set(e,!1),!1}function SM(){var e=new bf(4);if(bf!=Float32Array)e[0]=0,e[1]=0,e[2]=0,e[3]=0;return e}function Z3(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function Y3(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}function Q3(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}function e9(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function t9(e){var t=e[0],n=e[1],i=e[2],r=e[3];return Math.sqrt(t*t+n*n+i*i+r*r)}function r9(e){return e.getGraph().listParentEdges(e).some((t)=>t.getAttributes().isColor||i9.test(t.getName()))?"srgb":null}function s9(e){let t=e.getGraph(),n=new Set,i=new Set;function r(s){let a=new Set;for(let o of t.listChildEdges(s))if(o.getChild()instanceof Xo)a.add(o.getName()+"Info");for(let o of t.listChildEdges(s)){let c=o.getChild();if(n.has(c))continue;if(n.add(c),c instanceof wt&&a.has(o.getName()))i.add(c);else if(c instanceof nt)r(c)}}return r(e),Array.from(i)}function a9(e){let t=rf.fromGraph(e.getGraph()).getRoot(),n=e.getGraph().listParentEdges(e).filter((i)=>i.getParent()!==t).map((i)=>i.getName());return Array.from(new Set(n))}function IM(e=uM){let t=Ef(uM,e),n=new Set(t.propertyTypes),i=t.keepExtras;return vf(Zo,async(r)=>{let s=r.getLogger(),a=r.getRoot(),o=r.getGraph(),c=new o9,l=(u)=>c.dispose(u.target);if(o.addEventListener("node:dispose",l),n.has(te.MESH))for(let u of a.listMeshes()){if(u.listPrimitives().length>0)continue;u.dispose()}if(n.has(te.NODE)){if(!t.keepLeaves)for(let u of a.listScenes())CM(o,u,i);for(let u of a.listNodes())Si(u,i)}if(n.has(te.SKIN))for(let u of a.listSkins())Si(u,i);if(n.has(te.MESH))for(let u of a.listMeshes())Si(u,i);if(n.has(te.CAMERA))for(let u of a.listCameras())Si(u,i);if(n.has(te.PRIMITIVE))dM(o,te.PRIMITIVE,i);if(n.has(te.PRIMITIVE_TARGET))dM(o,te.PRIMITIVE_TARGET,i);if(!t.keepAttributes&&n.has(te.ACCESSOR)){let u=new Map;for(let d of a.listMeshes())for(let f of d.listPrimitives()){let h=f.getMaterial();if(!h)continue;let b=c9(f,NM(r,f,h));fM(f,b),f.listTargets().forEach((m)=>fM(m,b)),u.has(h)?u.get(h).add(f):u.set(h,new Set([f]))}for(let[d,f]of u)l9(d,Array.from(f))}if(n.has(te.ANIMATION))for(let u of a.listAnimations()){for(let d of u.listChannels())if(!d.getTargetNode())d.dispose();if(!u.listChannels().length){let d=u.listSamplers();Si(u,i),d.forEach((f)=>Si(f,i))}else u.listSamplers().forEach((d)=>Si(d,i))}if(n.has(te.MATERIAL))a.listMaterials().forEach((u)=>Si(u,i));if(n.has(te.TEXTURE)){if(a.listTextures().forEach((u)=>Si(u,i)),!t.keepSolidTextures)await u9(r)}if(n.has(te.ACCESSOR))a.listAccessors().forEach((u)=>Si(u,i));if(n.has(te.BUFFER))a.listBuffers().forEach((u)=>Si(u,i));if(o.removeEventListener("node:dispose",l),!c.empty()){let u=c.entries().map(([d,f])=>`${d} (${f})`).join(", ");s.info(`${Zo}: Removed types... ${u}`)}else s.debug(`${Zo}: No unused properties found.`);s.debug(`${Zo}: Complete.`)})}function Si(e,t){let n=e.listParents().filter((r)=>!(r instanceof Ps||r instanceof Da)),i=t&&!AM(e.getExtras());if(!n.length&&!i)e.dispose()}function dM(e,t,n){for(let i of e.listEdges()){let r=i.getParent();if(r.propertyType===t)Si(r,n)}}function CM(e,t,n){if(t.listChildren().forEach((a)=>CM(e,a,n)),t instanceof nf)return;let i=e.listParentEdges(t).some((a)=>{let o=a.getParent().propertyType;return o!==te.ROOT&&o!==te.SCENE&&o!==te.NODE}),r=e.listChildren(t).length===0,s=n&&!AM(t.getExtras());if(r&&!i&&!s)t.dispose()}function fM(e,t){for(let n of t)e.setAttribute(n,null)}function c9(e,t){let n=[];for(let i of e.listSemantics())if(i==="NORMAL"&&!t.has(i))n.push(i);else if(i==="TANGENT"&&!t.has(i))n.push(i);else if(i.startsWith("TEXCOORD_")&&!t.has(i))n.push(i);else if(i.startsWith("COLOR_")&&i!=="COLOR_0")n.push(i);return n}function NM(e,t,n,i=new Set){let r=e.getGraph().listChildEdges(n),s=new Set;for(let c of r)if(c.getChild()instanceof Xo)s.add(c.getName());for(let c of r){let l=c.getName(),u=c.getChild();if(u instanceof wt){if(s.has(l.replace(/Info$/,"")))i.add(`TEXCOORD_${u.getTexCoord()}`)}if(u instanceof Xo&&l.match(/normalTexture/i))i.add("TANGENT");if(u instanceof nt)NM(e,t,u,i)}let a=n instanceof Oa&&!n.getExtension("KHR_materials_unlit"),o=t.getMode()===Jn.Mode.POINTS;if(a&&!o)i.add("NORMAL");return i}function l9(e,t){let n=s9(e),i=new Set(n.map((c)=>c.getTexCoord())),r=Array.from(i).sort(),s=new Map(r.map((c,l)=>[c,l])),a=new Map(r.map((c,l)=>[`TEXCOORD_${c}`,`TEXCOORD_${l}`]));for(let c of n){let l=c.getTexCoord();c.setTexCoord(s.get(l))}for(let c of t){let l=c.listSemantics().filter((u)=>u.startsWith("TEXCOORD_")).sort();o(c,l),c.listTargets().forEach((u)=>o(u,l))}function o(c,l){for(let u of l){let d=c.getAttribute(u);if(!d)continue;let f=a.get(u);if(f===u)continue;c.setAttribute(f,d),c.setAttribute(u,null)}}}async function u9(e){let t=e.getRoot(),n=e.getGraph(),i=e.getLogger(),r=t.listTextures().map(async(s)=>{let a=await f9(s);if(!a)return;if(r9(s)==="srgb")Vw.convertSRGBToLinear(a,a);let o=s.getName()||s.getURI(),c=s.getSize()?.join("x"),l=a9(s);for(let u of n.listParentEdges(s)){let d=u.getParent();if(d!==t&&d9(d,a,u.getName(),i))u.dispose()}if(s.listParents().length===1)s.dispose(),i.debug(`${Zo}: Removed solid-color texture "${o}" (${c}px ${l.join(", ")})`)});await Promise.all(r)}function d9(e,t,n,i){if(e instanceof Oa)switch(n){case"baseColorTexture":return e.setBaseColorFactor(n9(t,t,e.getBaseColorFactor())),!0;case"emissiveTexture":return e.setEmissiveFactor($3([0,0,0],t.slice(0,3),e.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(t[0]-1)<=Qg;case"metallicRoughnessTexture":return e.setRoughnessFactor(t[1]*e.getRoughnessFactor()),e.setMetallicFactor(t[2]*e.getMetallicFactor()),!0;case"normalTexture":return RM(MM(SM(),t,[0.5,0.5,1,1]))<=Qg}return i.warn(`${Zo}: Detected single-color ${n} texture. Pruning ${n} not yet supported.`),!1}async function f9(e){let t=await h9(e);if(!t)return null;let n=[1/0,1/0,1/0,1/0],i=[-1/0,-1/0,-1/0,-1/0],r=[0,0,0,0],[s,a]=t.shape;for(let o=0;o<s;o++){for(let c=0;c<a;c++)for(let l=0;l<4;l++)n[l]=Math.min(n[l],t.get(o,c,l)),i[l]=Math.max(i[l],t.get(o,c,l));if(RM(MM(r,i,n))/255>Qg)return null}return e9(r,Z3(r,i,n),0.00196078431372549)}async function h9(e){try{return await sM(e.getImage(),e.getMimeType())}catch{return null}}function p9(e,t=1/0){if(Number.isFinite(t)&&t%4||t<=0)throw Error("Limit must be positive multiple of four.");let n=e.getAttribute("POSITION").getCount(),i=e.listSemantics().filter((l)=>l.startsWith("WEIGHTS_")).length,r=new Uint16Array(i*4),s=new Float32Array(i*4),a=new Float32Array(i*4),o=new Uint32Array(i*4),c=new Uint32Array(i*4);for(let l=0;l<n;l++){yf(e,l,"WEIGHTS",s),yf(e,l,"JOINTS",o);for(let u=0;u<i*4;u++)r[u]=u;r.sort((u,d)=>s[u]>s[d]?-1:1);for(let u=0;u<r.length;u++)a[u]=s[r[u]],c[u]=o[r[u]];_f(e,l,"WEIGHTS",a),_f(e,l,"JOINTS",c)}for(let l=i;l*4>t;l--){let u=e.getAttribute(`WEIGHTS_${l-1}`),d=e.getAttribute(`JOINTS_${l-1}`);if(e.setAttribute(`WEIGHTS_${l-1}`,null),e.setAttribute(`JOINTS_${l-1}`,null),u.listParents().length===1)u.dispose();if(d.listParents().length===1)d.dispose()}m9(e)}function m9(e){if(!g9(e))return;let t=e.getAttribute("POSITION").getCount(),n=e.listSemantics().filter((d)=>d.startsWith("WEIGHTS_")).length,i=e.getAttribute("WEIGHTS_0"),r=i.getArray(),s=i.getComponentType(),a=i.getNormalized(),o=a?s:void 0,c=a?pt.decodeNormalizedInt(1,s):Number.EPSILON,l=new Uint32Array(n*4).fill(0),u=r.slice(0,n*4).fill(0);for(let d=0;d<t;d++){yf(e,d,"JOINTS",l),yf(e,d,"WEIGHTS",u,o);let f=hM(u,o);if(f!==0&&f!==1){if(Math.abs(1-f)>c)for(let h=0;h<u.length;h++)if(a){let b=pt.decodeNormalizedInt(u[h],s);u[h]=pt.encodeNormalizedInt(b/f,s)}else u[h]/=f;if(f=hM(u,o),a&&f!==1){for(let h=u.length-1;h>=0;h--)if(u[h]>0){let b=1-f;u[h]+=Math.sign(b)*pt.encodeNormalizedInt(Math.abs(b),s);break}}}for(let h=u.length-1;h>=0;h--)if(u[h]===0)l[h]=0;_f(e,d,"JOINTS",l),_f(e,d,"WEIGHTS",u,o)}}function yf(e,t,n,i,r){let s,a=[0,0,0,0];for(let o=0;s=e.getAttribute(`${n}_${o}`);o++){s.getElement(t,a);for(let c=0;c<4;c++)if(r)i[o*4+c]=pt.encodeNormalizedInt(a[c],r);else i[o*4+c]=a[c]}return i}function _f(e,t,n,i,r){let s,a=[0,0,0,0];for(let o=0;s=e.getAttribute(`${n}_${o}`);o++){for(let c=0;c<4;c++)if(r)a[c]=pt.decodeNormalizedInt(i[o*4+c],r);else a[c]=i[o*4+c];s.setElement(t,a)}}function hM(e,t){let n=0;for(let i=0;i<e.length;i++)if(t)n+=pt.decodeNormalizedInt(e[i],t);else n+=e[i];return n}function g9(e){let t=e.listSemantics().filter((r)=>r.startsWith("WEIGHTS_")).map((r)=>e.getAttribute(r)),n=t.map((r)=>r.getNormalized()),i=t.map((r)=>r.getComponentType());return new Set(n).size===1&&new Set(i).size===1}function PM(e=mf){let t=Ef(mf,{patternTargets:e.pattern||mf.pattern,...e});return vf(Xs,async(n)=>{let i=n.getLogger(),r=n.getRoot();if(n.hasExtension("KHR_mesh_primitive_restart"))throw Error("quantize: Missing support for KHR_mesh_primitive_restart.");let s;if(t.quantizationVolume==="scene")s=mM(C9(r.listMeshes().map(gM)));for(let a of n.getRoot().listMeshes()){if(t.quantizationVolume==="mesh")s=mM(gM(a));if(s&&t.pattern.test("POSITION"))T9(n,a,s),S9(a,1/s.scale);for(let o of a.listPrimitives()){if(xf(o,"render")<xf(o,"upload")/2)z3(o);pM(n,o,s,t);for(let c of o.listTargets())pM(n,c,s,t)}}if(r.listMeshes().flatMap((a)=>a.listPrimitives()).some(OM))n.createExtension(Hg).setRequired(!0);if(t.cleanup)await n.transform(IM({propertyTypes:[te.ACCESSOR,te.SKIN,te.MATERIAL],keepAttributes:!0,keepIndices:!0,keepLeaves:!0,keepSolidTextures:!0}),tb({propertyTypes:[te.ACCESSOR,te.MATERIAL,te.SKIN],keepUniqueNames:!0}));i.debug(`${Xs}: Complete.`)})}function pM(e,t,n,i){let r=t instanceof Lg,s=e.getLogger();for(let a of t.listSemantics()){if(!r&&!i.pattern.test(a))continue;if(r&&!i.patternTargets.test(a))continue;let o=t.getAttribute(a),{bits:c,ctor:l}=R9(a,o,s,i);if(!l)continue;if(c<8||c>16)throw Error(`${Xs}: Requires bits = 8–16.`);if(o.getComponentSize()<=c/8)continue;let u=o.clone();if(a==="POSITION"){let d=n.scale,f=[];t instanceof Jn?D3(f,Tf(n)):L3(f,[1/d,1/d,1/d]);for(let h=0,b=[0,0,0],m=u.getCount();h<m;h++)u.getElement(h,b),u.setElement(h,G3(b,b,f))}M9(u,l,c),t.setAttribute(a,u)}if(i.normalizeWeights&&t.getAttribute("WEIGHTS_0"))p9(t,1/0);if(t instanceof Jn&&t.getIndices()&&t.listAttributes().length&&t.listAttributes()[0].getCount()<65535){let a=t.getIndices();a.setArray(new Uint16Array(a.getArray()))}}function mM(e){let{min:t,max:n}=e,i=Math.max((n[0]-t[0])/2,(n[1]-t[1])/2,(n[2]-t[2])/2);return{offset:[t[0]+(n[0]-t[0])/2,t[1]+(n[1]-t[1])/2,t[2]+(n[2]-t[2])/2],scale:i}}function T9(e,t,n){let i=Tf(n);for(let r of t.listParents()){if(!(r instanceof tf))continue;let s=r.listParents().filter((f)=>f instanceof Da),a=s.some((f)=>E9.includes(f.getTargetPath())),o=r.listChildren().length>0,c=r.getSkin();if(c){r.setSkin(A9(c,n));continue}let l=r.getExtension("EXT_mesh_gpu_instancing");if(l){r.setExtension("EXT_mesh_gpu_instancing",w9(e,l,n));continue}let u;if(o||a)u=e.createNode("").setMesh(t),r.addChild(u).setMesh(null),s.filter((f)=>f.getTargetPath()===v9).forEach((f)=>f.setTargetNode(u));else u=r;let d=u.getMatrix();eb(d,d,i),u.setMatrix(d)}}function A9(e,t){e=e.clone();let n=Tf(t),i=e.getInverseBindMatrices().clone(),r=[];for(let s=0,a=i.getCount();s<a;s++)i.getElement(s,r),eb(r,r,n),i.setElement(s,r);return e.setInverseBindMatrices(i)}function w9(e,t,n){if(!t.getAttribute("TRANSLATION")&&!t.getAttribute("ROTATION")&&!t.getAttribute("SCALE"))return t;t=t.clone();let i=t.getAttribute("TRANSLATION")?.clone(),r=t.getAttribute("ROTATION")?.clone(),s=t.getAttribute("SCALE")?.clone(),a=i||r||s,o=[0,0,0],c=[0,0,0,1],l=[1,1,1];if(!i&&n.offset)i=e.createAccessor().setType("VEC3").setArray(xM(a.getCount(),o));if(!s&&n.scale)s=e.createAccessor().setType("VEC3").setArray(xM(a.getCount(),l));let u=[0,0,0],d=[0,0,0,1],f=[1,1,1],h=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],b=Tf(n);for(let m=0,g=a.getCount();m<g;m++){if(pt.compose(i?i.getElement(m,u):o,r?r.getElement(m,d):c,s?s.getElement(m,f):l,h),eb(h,h,b),pt.decompose(h,u,d,f),i)i.setElement(m,u);if(r)r.setElement(m,d);if(s)s.setElement(m,f)}if(i)t.setAttribute("TRANSLATION",i);if(r)t.setAttribute("ROTATION",r);if(s)t.setAttribute("SCALE",s);return t}function S9(e,t){for(let n of e.listPrimitives()){let i=n.getMaterial();if(!i)continue;let r=i.getExtension("KHR_materials_volume");if(!r||r.getThicknessFactor()<=0)continue;r=r.clone().setThicknessFactor(r.getThicknessFactor()*t),i=i.clone().setExtension("KHR_materials_volume",r),n.setMaterial(i)}}function M9(e,t,n){let i=new t(e.getArray().length),r=b9.includes(t)?1:0,s=n-r,a=t.BYTES_PER_ELEMENT*8-r,o=Math.pow(2,s)-1,c=a-s,l=2*s-a,u=[r>0?-1:0,1];for(let d=0,f=0,h=[];d<e.getCount();d++){e.getElement(d,h);for(let b=0;b<h.length;b++){let m=N9(h[b],u);m=Math.round(Math.abs(m)*o),m=m<<c|m>>l,i[f++]=m*Math.sign(h[b])}}e.setArray(i).setNormalized(!0).setSparse(!1)}function R9(e,t,n,i){let r=t.getMinNormalized([]),s=t.getMaxNormalized([]),a,o;if(e==="POSITION")a=i.quantizePosition,o=a<=8?Int8Array:Int16Array;else if(e==="NORMAL"||e==="TANGENT")a=i.quantizeNormal,o=a<=8?Int8Array:Int16Array;else if(e.startsWith("COLOR_"))a=i.quantizeColor,o=a<=8?Uint8Array:Uint16Array;else if(e.startsWith("TEXCOORD_")){if(r.some((c)=>c<0)||s.some((c)=>c>1))return n.warn(`${Xs}: Skipping ${e}; out of [0,1] range.`),{bits:-1};a=i.quantizeTexcoord,o=a<=8?Uint8Array:Uint16Array}else if(e.startsWith("JOINTS_")){if(a=Math.max(...t.getMax([]))<=255?8:16,o=a<=8?Uint8Array:Uint16Array,t.getComponentSize()>a/8)t.setArray(new o(t.getArray()));return{bits:-1}}else if(e.startsWith("WEIGHTS_")){if(r.some((c)=>c<0)||s.some((c)=>c>1))return n.warn(`${Xs}: Skipping ${e}; out of [0,1] range.`),{bits:-1};a=i.quantizeWeight,o=a<=8?Uint8Array:Uint16Array}else if(e.startsWith("_")){if(r.some((c)=>c<-1)||s.some((c)=>c>1))return n.warn(`${Xs}: Skipping ${e}; out of [-1,1] range.`),{bits:-1};a=i.quantizeGeneric,o=r.some((c)=>c<0)?o=a<=8?Int8Array:Int16Array:o=a<=8?Uint8Array:Uint16Array}else throw Error(`${Xs}: Unexpected semantic, "${e}".`);return{bits:a,ctor:o}}function gM(e){let t=[],n=[];for(let r of e.listPrimitives()){let s=r.getAttribute("POSITION");if(s)t.push(s);for(let a of r.listTargets()){let o=a.getAttribute("POSITION");if(o)n.push(o)}}if(t.length===0)throw Error(`${Xs}: Missing "POSITION" attribute.`);let i=bM(t,3);if(n.length>0){let{min:r,max:s}=bM(n,3);Zg(i.min,i.min,Zg(r,cM(r,r,2),[0,0,0])),Yg(i.max,i.max,Yg(s,cM(s,s,2),[0,0,0]))}return i}function I9(e,t){let n=t.getComponentSize();if(e==="POSITION")return n<4;if(e==="NORMAL")return n<4;if(e==="TANGENT")return n<4;if(e.startsWith("TEXCOORD_")){let i=t.getComponentType(),r=t.getNormalized();return n<4&&!(r&&i===Be.ComponentType.UNSIGNED_BYTE)&&!(r&&i===Be.ComponentType.UNSIGNED_SHORT)}return!1}function OM(e){for(let t of e.listSemantics())if(I9(t,e.getAttribute("POSITION")))return!0;if(e.propertyType===te.PRIMITIVE)return e.listTargets().some(OM);return!1}function bM(e,t){let n=Array(t).fill(1/0),i=Array(t).fill(-1/0),r=[],s=[];for(let a of e){a.getMinNormalized(r),a.getMaxNormalized(s);for(let o=0;o<t;o++)n[o]=Math.min(n[o],r[o]),i[o]=Math.max(i[o],s[o])}return{min:n,max:i}}function C9(e){let t=e[0];for(let n of e)Zg(t.min,t.min,n.min),Yg(t.max,t.max,n.max);return t}function Tf(e){return F3([],[0,0,0,1],e.offset,[e.scale,e.scale,e.scale])}function N9(e,t){return Math.min(Math.max(e,t[0]),t[1])}function xM(e,t){let n=t.length,i=new Float32Array(e*n);for(let r=0;r<e;r++)i.set(t,r*n);return i}function kM(e){let t=Ef(P9,e),n=t.encoder;if(!n)throw Error(`${hf}: encoder dependency required — install "meshoptimizer".`);return vf(hf,async(i)=>{let r=i.getLogger();if(i.hasExtension("KHR_mesh_primitive_restart"))throw Error("reorder: Missing support for KHR_mesh_primitive_restart.");await n.ready;let s=O9(i);for(let a of s.indicesToAttributes.keys()){let o=a.getArray();if(!(o instanceof Uint32Array))o=new Uint32Array(o);else o=o.slice();let[c,l]=n.reorderMesh(o,s.indicesToMode.get(a)===Jn.Mode.TRIANGLES,t.target==="size"),u=gf(i,a);u.setArray(l<=65534?new Uint16Array(o):o);for(let d of s.indicesToAttributes.get(a)){let f=gf(i,d);Jg(d,a,c,f,l);for(let h of s.indicesToPrimitives.get(a)){if(h.getIndices()===a)h.swap(a,u);h.swap(d,f);for(let b of h.listTargets())b.swap(d,f)}}}if(t.cleanup)await i.transform(IM({propertyTypes:[te.ACCESSOR],keepAttributes:!0,keepIndices:!0}));if(!s.indicesToAttributes.size)r.warn(`${hf}: No qualifying primitives found; may need to weld first.`);else r.debug(`${hf}: Complete.`)})}function O9(e){let t=new Map,n=new Xg,i=new Xg,r=new Xg;for(let s of e.getRoot().listMeshes())for(let a of s.listPrimitives()){let o=a.getIndices();if(!o)continue;t.set(o,a.getMode()),n.add(o,a);for(let c of EM(a))i.add(o,c),r.add(c,a)}return{indicesToPrimitives:n,indicesToAttributes:i,indicesToMode:t,attributesToPrimitives:r}}function D9(e,t,n,i=0.0001){let r=t.length/e.length,s=Array(r).fill(0),a=Array(r).fill(0),o=Array(r).fill(0),c=Array(r).fill(0),l=e.length-1,u=1;for(let d=1;d<l;++d){let f=e[u-1],h=e[d],b=e[d+1],m=(h-f)/(b-f),g=!1;if(h!==b&&(d!==1||h!==e[0])){if(Rl(t,u-1,c),Rl(t,d,a),Rl(t,d+1,o),n==="slerp"){let p=U9(s,c,o,m),x=vM(c,a)+vM(a,o);g=!pf(a,p,i)||x+Number.EPSILON>=Math.PI}else if(n==="lerp")g=!pf(a,F9(s,c,o,m),i);else if(n==="step")g=!pf(a,c)||!pf(a,o)}if(g){if(d!==u)e[u]=e[d],_M(t,u,Rl(t,d,s));u++}}if(l>0)e[u]=e[l],_M(t,u,Rl(t,l,s)),u++;return u}function Rl(e,t,n){for(let i=0,r=n.length;i<r;i++)n[i]=e[t*r+i];return n}function _M(e,t,n){for(let i=0,r=n.length;i<r;i++)e[t*r+i]=n[i]}function pf(e,t,n=0){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(Math.abs(e[i]-t[i])>n)return!1;return!0}function L9(e,t,n){return e*(1-n)+t*n}function F9(e,t,n,i){for(let r=0;r<t.length;r++)e[r]=L9(t[r],n[r],i);return e}function U9(e,t,n,i){let r=t[0],s=t[1],a=t[2],o=t[3],c=n[0],l=n[1],u=n[2],d=n[3],f,h,b,m,g;if(h=r*c+s*l+a*u+o*d,h<0)h=-h,c=-c,l=-l,u=-u,d=-d;if(1-h>k9)f=Math.acos(h),b=Math.sin(f),m=Math.sin((1-i)*f)/b,g=Math.sin(i*f)/b;else m=1-i,g=i;return e[0]=m*r+g*c,e[1]=m*s+g*l,e[2]=m*a+g*u,e[3]=m*o+g*d,e}function vM(e,t){let n=B9(e,t);return Math.acos(2*n*n-1)}function B9(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}var P3,Q5,eK,tK,nK,iK,rK,sK,Xg=class{_map=new Map;get size(){return this._map.size}has(e){return this._map.has(e)}add(e,t){let n=this._map.get(e);if(!n)n=new Set,this._map.set(e,n);return n.add(t),this}get(e){return this._map.get(e)||new Set}keys(){return this._map.keys()}},aK,bf,oM=4294967295,$3,oK,cK,lK,uK,dK,fK,hK,qs="dedup",qg,pK,mK,MM,n9,RM,i9,Zo="prune",Qg=0.011764705882352941,uM,o9=class{disposed={};empty(){for(let e in this.disposed)return!1;return!0}entries(){return Object.entries(this.disposed)}dispose(e){this.disposed[e.propertyType]=this.disposed[e.propertyType]||0,this.disposed[e.propertyType]++}},gK,bK,xK,yK,_K,Xs="quantize",b9,x9,y9,_9,v9,E9,mf,hf="reorder",P9,vK,yM,k9=0.000001,EK,TK,AK,wK,SK,MK,RK,IK;var DM=mt(()=>{wl();aM();uf();P3=kf($g(),1),{POINTS:Q5,LINES:eK,LINE_STRIP:tK,LINE_LOOP:nK,TRIANGLES:iK,TRIANGLE_STRIP:rK,TRIANGLE_FAN:sK}=Jn.Mode;aK=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});bf=typeof Float32Array<"u"?Float32Array:Array;Math.PI/180;180/Math.PI;$3=H3;(function(){var e=j3();return function(t,n,i,r,s,a){var o,c;if(!n)n=3;if(!i)i=0;if(r)c=Math.min(r*n+i,t.length);else c=t.length;for(o=i;o<c;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],s(e,e,a),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2];return t}})();({FLOAT:oK}=Be.ComponentType),{LINES:cK,LINE_STRIP:lK,LINE_LOOP:uK,TRIANGLES:dK,TRIANGLE_STRIP:fK,TRIANGLE_FAN:hK}=Jn.Mode,qg={keepUniqueNames:!1,propertyTypes:[te.ACCESSOR,te.MESH,te.TEXTURE,te.MATERIAL,te.SKIN]};({TEXTURE_INFO:pK,ROOT:mK}=te);MM=Y3,n9=Q3,RM=t9;(function(){var e=SM();return function(t,n,i,r,s,a){var o,c;if(!n)n=4;if(!i)i=0;if(r)c=Math.min(r*n+i,t.length);else c=t.length;for(o=i;o<c;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],e[3]=t[o+3],s(e,e,a),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2],t[o+3]=e[3];return t}})();i9=/color|emissive|diffuse/i;uM={propertyTypes:[te.NODE,te.SKIN,te.MESH,te.CAMERA,te.PRIMITIVE,te.PRIMITIVE_TARGET,te.ANIMATION,te.MATERIAL,te.TEXTURE,te.ACCESSOR,te.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};({ROOT:gK,NODE:bK,MESH:xK,PRIMITIVE:yK,ACCESSOR:_K}=te);b9=[Int8Array,Int16Array,Int32Array],{TRANSLATION:x9,ROTATION:y9,SCALE:_9,WEIGHTS:v9}=Da.TargetPath,E9=[x9,y9,_9],mf={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};P9={target:"size",cleanup:!0};vK={level:"high",...mf};(function(e){e[e.STEP=0]="STEP",e[e.LERP=1]="LERP",e[e.SLERP=2]="SLERP"})(yM||(yM={}));EK={ready:Promise.resolve(),resample:D9,tolerance:0.0001,cleanup:!0},{POINTS:TK,LINES:AK,LINE_STRIP:wK,LINE_LOOP:SK,TRIANGLES:MK,TRIANGLE_STRIP:RK,TRIANGLE_FAN:IK}=Jn.Mode});function FM(e,t,n,i={}){if(!Array.isArray(t))return e.push({code:"EXPECTED_ARRAY",path:n,message:`${n} must be an array.`}),!1;if(!i.allowEmpty&&t.length===0)e.push({code:"EXPECTED_NONEMPTY_ARRAY",path:n,message:`${n} must not be empty.`});let r=new Set;for(let s=0;s<t.length;s++){let a=t[s];if(!$r(a)){e.push({code:"EXPECTED_NONEMPTY_STRING",path:`${n}[${s}]`,message:`${n}[${s}] must be a trimmed non-empty string.`});continue}if(r.has(a))e.push({code:"DUPLICATE_VALUE",path:`${n}[${s}]`,message:`${n} contains duplicate value ${JSON.stringify(a)}.`});r.add(a)}return!0}function j9(e,t,n){let i=`frames[${t}]`;if(!Js(e))return n.push({code:"INVALID_FRAME",path:i,message:`${i} must be an object.`}),!1;if(!$r(e.id))n.push({code:"INVALID_FRAME_ID",path:`${i}.id`,message:"Frame ID is required."});if(!LM(e.translation,3))n.push({code:"INVALID_FRAME_TRANSLATION",path:`${i}.translation`,message:"Frame translation must be three finite meters."});if(!LM(e.rotation,4))n.push({code:"INVALID_FRAME_ROTATION",path:`${i}.rotation`,message:"Frame rotation must be a finite quaternion."});else{let r=Math.hypot(...e.rotation);if(Math.abs(r-1)>0.000001)n.push({code:"NON_UNIT_FRAME_ROTATION",path:`${i}.rotation`,message:"Frame rotation quaternion must be normalized within 1e-6."})}return!0}function H9(e,t,n){let i=`relationships[${t}]`;if(!Js(e))return n.push({code:"INVALID_RELATIONSHIP",path:i,message:`${i} must be an object.`}),!1;for(let r of["kind","target"])if(!$r(e[r]))n.push({code:"INVALID_RELATIONSHIP_FIELD",path:`${i}.${r}`,message:`${i}.${r} must be a trimmed non-empty string.`});if(e.targetType!=="node"&&e.targetType!=="role"&&e.targetType!=="socket")n.push({code:"INVALID_RELATIONSHIP_TARGET_TYPE",path:`${i}.targetType`,message:"Relationship targetType must be node, role, or socket."});for(let r of["sourceFrame","targetFrame"])if(e[r]!==void 0&&!$r(e[r]))n.push({code:"INVALID_RELATIONSHIP_FRAME",path:`${i}.${r}`,message:`${i}.${r} must be a trimmed non-empty string.`});return!0}function G9(e,t,n){let i=`sockets[${t}]`;if(!Js(e))return n.push({code:"INVALID_SOCKET",path:i,message:`${i} must be an object.`}),!1;for(let r of["id","type","frame"])if(!$r(e[r]))n.push({code:"INVALID_SOCKET_FIELD",path:`${i}.${r}`,message:`${i}.${r} must be a trimmed non-empty string.`});if(FM(n,e.compatibleTypes,`${i}.compatibleTypes`,{allowEmpty:!0}),e.allowedRotationsDegrees!==void 0){if(!Array.isArray(e.allowedRotationsDegrees)||e.allowedRotationsDegrees.some((r)=>typeof r!=="number"||!Number.isFinite(r)))n.push({code:"INVALID_ALLOWED_ROTATIONS",path:`${i}.allowedRotationsDegrees`,message:"Allowed rotations must be finite degree values."})}return!0}function $9(e){let t=[];if(!Js(e))return{valid:!1,issues:[{code:"EXPECTED_OBJECT",path:"",message:"SemanticMetadataV1 must be an object."}]};if(e.schemaVersion!==1)t.push({code:"UNSUPPORTED_SCHEMA_VERSION",path:"schemaVersion",message:"schemaVersion must be 1."});FM(t,e.roles,"roles");let n=Array.isArray(e.frames)?e.frames:[];if(!Array.isArray(e.frames))t.push({code:"EXPECTED_ARRAY",path:"frames",message:"frames must be an array."});let i=new Set;n.forEach((o,c)=>{if(j9(o,c,t),Js(o)&&$r(o.id)){if(i.has(o.id))t.push({code:"DUPLICATE_FRAME_ID",path:`frames[${c}].id`,message:`Duplicate frame ID ${JSON.stringify(o.id)}.`});i.add(o.id)}});let r=Array.isArray(e.relationships)?e.relationships:[];if(!Array.isArray(e.relationships))t.push({code:"EXPECTED_ARRAY",path:"relationships",message:"relationships must be an array."});r.forEach((o,c)=>{if(H9(o,c,t),Js(o))for(let l of["sourceFrame","targetFrame"]){let u=o[l];if($r(u)&&!i.has(u))t.push({code:"UNKNOWN_FRAME_REFERENCE",path:`relationships[${c}].${l}`,message:`Unknown frame ${JSON.stringify(u)}.`})}});let s=Array.isArray(e.sockets)?e.sockets:[];if(!Array.isArray(e.sockets))t.push({code:"EXPECTED_ARRAY",path:"sockets",message:"sockets must be an array."});let a=new Set;if(s.forEach((o,c)=>{if(G9(o,c,t),Js(o)&&$r(o.id)){if(a.has(o.id))t.push({code:"DUPLICATE_SOCKET_ID",path:`sockets[${c}].id`,message:`Duplicate socket ID ${JSON.stringify(o.id)}.`});a.add(o.id)}if(Js(o)&&$r(o.frame)&&!i.has(o.frame))t.push({code:"UNKNOWN_FRAME_REFERENCE",path:`sockets[${c}].frame`,message:`Unknown frame ${JSON.stringify(o.frame)}.`})}),t.length>0)return{valid:!1,issues:t};return{valid:!0,value:K9(e),issues:t}}function K9(e){return{schemaVersion:1,roles:[...e.roles],relationships:e.relationships.map((t)=>({kind:t.kind,target:t.target,targetType:t.targetType,...t.sourceFrame?{sourceFrame:t.sourceFrame}:{},...t.targetFrame?{targetFrame:t.targetFrame}:{}})),frames:e.frames.map((t)=>({id:t.id,translation:z9(t.translation),rotation:V9(t.rotation)})),sockets:e.sockets.map((t)=>({id:t.id,type:t.type,frame:t.frame,compatibleTypes:[...t.compatibleTypes],...t.allowedRotationsDegrees?{allowedRotationsDegrees:[...t.allowedRotationsDegrees]}:{}}))}}function nb(e){let t=e.kilnSemantic;if(t===void 0)return;let n=$9(t);return n.valid?n.value:void 0}var La,Js=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),$r=(e)=>typeof e==="string"&&e.trim().length>0&&e===e.trim(),LM=(e,t)=>Array.isArray(e)&&e.length===t&&e.every((n)=>typeof n==="number"&&Number.isFinite(n)),z9=(e)=>[e[0],e[1],e[2]],V9=(e)=>[e[0],e[1],e[2],e[3]];var Af=mt(()=>{La=Object.freeze({vehicleFrame:"vehicle.frame",vehicleForward:"vehicle.front.+x",socket:"socket",chassis:"chassis",chassisMain:"chassis.main",axle:"axle",seat:"seat",contact:"contact",steering:"steering",propulsion:"propulsion",wheelAssembly:"wheel.assembly",wheelPivot:"wheel.pivot",wheelLoadBearing:"wheel.load-bearing",wheelTire:"wheel.tire",wheelRim:"wheel.rim",wheelHub:"wheel.hub",wheelContact:"wheel.contact",steeringPivot:"steering.pivot",roof:"roof",architectureRoof:"architecture.roof",collider:"collider",colliderBox:"collider.box",colliderCapsule:"collider.capsule",colliderHull:"collider.hull",anchor:"anchor",kitModule:"kit.module",kitPort:"kit.port",lodImpostor:"lod.impostor"})});function zM(){return new Jw().registerExtensions([...DS,BM])}var hi="MSFT_lod",UM,BM;var ib=mt(()=>{wl();uf();UM=class UM extends nt{static EXTENSION_NAME=hi;init(){this.extensionName=hi,this.propertyType="Lod",this.parentTypes=[te.NODE,te.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{levels:new bn})}addLevel(e){return this.addRef("levels",e)}listLevels(){return this.listRefs("levels")}};BM=class BM extends _t{extensionName=hi;static EXTENSION_NAME=hi;createLod(e=""){return new UM(this.document.getGraph(),e)}read(e){let t=e.jsonDoc.json;return this.readLevels(t.nodes,e.nodes),this.readLevels(t.materials,e.materials),this}readLevels(e,t){(e??[]).forEach((n,i)=>{let r=n.extensions?.[hi]?.ids,s=t[i];if(!s||!Array.isArray(r))return;let a=this.createLod();for(let o of r){let c=typeof o==="number"?t[o]:void 0;if(c&&c!==s)a.addLevel(c)}s.setExtension(hi,a)})}write(e){let t=e.jsonDoc.json,n=this.document.getRoot();for(let i of n.listNodes()){let r=e.nodeIndexMap.get(i),s=i.getExtension(hi)?.listLevels().filter((o)=>o.propertyType===te.NODE).map((o)=>e.nodeIndexMap.get(o)).filter((o)=>o!==void 0),a=r===void 0?void 0:t.nodes?.[r];if(a&&s?.length)a.extensions={...a.extensions,[hi]:{ids:s}}}for(let i of n.listMaterials()){let r=e.materialIndexMap.get(i),s=i.getExtension(hi)?.listLevels().filter((o)=>o.propertyType===te.MATERIAL).map((o)=>e.materialIndexMap.get(o)).filter((o)=>o!==void 0),a=r===void 0?void 0:t.materials?.[r];if(a&&s?.length)a.extensions={...a.extensions,[hi]:{ids:s}}}return this}}});var W9;var rb=mt(()=>{W9=Object.freeze([1,1,1])});var jK,HK;var VM=mt(()=>{rb();jK=Object.freeze({units:"m",forward:"+X",up:"+Y",right:"+Z",groundY:0}),HK=Math.PI/180});var jM=()=>{};var HM=()=>{};var GM=mt(()=>{VM();rb();jM();HM();Af()});var X9;var $M=mt(()=>{X9=Object.freeze({parametricSamples:262144,subdivisionTriangles:1e6,subdivisionAttributeBytes:134217728,subdivisionIterations:10,repeatedMeshes:1e4,curveRepeatVertices:262144,primitiveSegments:4096,primitiveGridVertices:262144,unwrapVertices:65536,unwrapTriangles:1e6,unwrapAttributeBytes:134217728,unwrapResolution:4096,skinBones:1024,skinVertices:262144,skinAttributeBytes:134217728,colliderHullVertices:65536,surfaceBakeVertices:262144,surfaceBakeTriangles:1e6,surfaceBakeRays:8388608,surfaceBakeRayDirections:256})});var sb="kilnRepeatInstances";var ab=mt(()=>{GM();vu();$M()});function Il(e){return e.getExtension("KHR_node_visibility")?.getVisible?.()===!1}var oW;var wf=mt(()=>{oW=[{grade:"A",max:1,range:"0-1"},{grade:"B",max:3,range:"2-3"},{grade:"C",max:6,range:"4-6"},{grade:"D",max:12,range:"7-12"},{grade:"F",max:Number.POSITIVE_INFINITY,range:"13+"}]});var KM=mt(()=>{wf()});function XM(e){let t=new Map,n=e.getRoot().getDefaultScene()??e.getRoot().listScenes()[0];if(!n)return t;let i=(r,s)=>{let a=new Map;for(let o of r){let c=o.getName(),l=a.get(c)??0;a.set(c,l+1);let u=`${s}${WM(c,l)}`;t.set(o,u),i(o.listChildren(),u)}};return i(n.listChildren(),WM(n.getName()||"Scene",0)),t}var WM=(e,t)=>`/${encodeURIComponent(e)}[${t}]`;var qM=mt(()=>{ib();Af();ab();wf();KM()});var JM=()=>{};function Ht(e){throw TypeError(`atlas provenance: ${e}`)}function Ki(e,t){if(!e||typeof e!=="object"||Array.isArray(e))Ht("plain metadata object required.");let n=Object.getPrototypeOf(e);if(n!==null&&n!==Object.prototype)Ht("plain metadata prototype required.");let i=Object.getOwnPropertyDescriptor(e,t);if(!i)return;if(!i.enumerable||!("value"in i))Ht("metadata accessors/hidden fields are unsupported.");return i.value}function Cl(e,t){for(let n of Reflect.ownKeys(e))if(typeof n!=="string"||!t.includes(n))Ht("unsupported metadata field.");for(let n of t)Ki(e,n);return e}function Z9(e){Mn(e);let t=Cl(e,["spec","manifest"]),n=fa(t.spec);return{spec:n,manifest:Rc(t.manifest,n)}}function Y9(e){let t=Cl(e,["version","atlases"]);if(t.version!==Yo)Ht("unsupported version.");let n=t.atlases;if(!Array.isArray(n)||Object.getPrototypeOf(n)!==Array.prototype)Ht("dense atlas array required.");let i=Object.getOwnPropertyDescriptor(n,"length").value;if(i>Fa.atlases||Reflect.ownKeys(n).length!==i+1)Ht("atlas count/density budget exceeded.");let r=J9,s=[];for(let a=0;a<i;a++){let o=Object.getOwnPropertyDescriptor(n,String(a));if(!o?.enumerable||!("value"in o))Ht("atlas array accessors are unsupported.");let c=Mn(o.value);if(r+=new TextEncoder().encode(c).length+(a>0?1:0),r>Fa.bytes)Ht("aggregate metadata byte budget exceeded.");s.push(Cl(o.value,["id","spec","manifest"]))}return s}function Q9(e){let t=Y9(e),n=new Set,i=[];for(let r of t){let s=Z9({spec:r.spec,manifest:r.manifest});if(r.id!==s.manifest.manifestHash||n.has(r.id))Ht("duplicate or mismatched atlas identity.");n.add(r.id),i.push({id:r.id,...s})}return{version:Yo,atlases:i}}function ZM(e,t){let n=e.atlases.find((i)=>i.id===t);if(!n)Ht("unknown atlas reference.");return n}function eB(e,t,n,i){if(!["top-left","bottom-left"].includes(n)||!["content-boundary","texel-center"].includes(i))Ht("explicit binding origin/mode required.");let r=e.manifest.regions.find((d)=>d.name===t);if(!r)Ht("unknown named region.");let{x:s,y:a,width:o,height:c}=r.content,l=i==="texel-center",u=n==="bottom-left";return{manifestHash:e.manifest.manifestHash,specHash:e.manifest.specHash,layoutHash:e.manifest.layoutHash,region:r.name,content:structuredClone(r.content),allocation:structuredClone(r.allocation),inputOrigin:n,mode:i,scale:[(o-(l?1:0))/e.manifest.width,(u?-1:1)*(c-(l?1:0))/e.manifest.height],offset:[(s+(l?0.5:0))/e.manifest.width,(a+(u?c-(l?0.5:0):l?0.5:0))/e.manifest.height]}}function tB(e,t){Mn(e);let n=Cl(e,["version","atlasId","region","inputOrigin","mode"]);if(n.version!==Yo)Ht("unsupported binding version.");return eB(ZM(t,n.atlasId),n.region,n.inputOrigin,n.mode)}function nB(e){let t=e.getRoot().getDefaultScene()??e.getRoot().listScenes()[0];return t?Ki(t.getExtras(),"kilnAtlasProvenance"):void 0}function YM(e){let t=nB(e);return t===void 0?void 0:Q9(t)}function QM(e){let t=[];for(let n of e.getRoot().listMaterials())for(let[i,r]of[[n.getBaseColorTexture(),n.getBaseColorTextureInfo()],[n.getNormalTexture(),n.getNormalTextureInfo()],[n.getMetallicRoughnessTexture(),n.getMetallicRoughnessTextureInfo()],[n.getEmissiveTexture(),n.getEmissiveTextureInfo()],[n.getOcclusionTexture(),n.getOcclusionTextureInfo()]])if(i&&r&&Ki(r.getExtras(),"kilnAtlasReference")!==void 0){if(t.length>=Fa.bindings)Ht("document binding budget exceeded.");t.push({texture:i,info:r})}return t}async function eR(e){let t=e.getImage();if(!t||t.byteLength>Fa.encodedBytes)Ht("encoded image missing or over budget.");let n=await crypto.subtle.digest("SHA-256",t);return`sha256:${[...new Uint8Array(n)].map((i)=>i.toString(16).padStart(2,"0")).join("")}`}function tR(e){let t={minFilter:e.getMinFilter(),magFilter:e.getMagFilter(),wrapS:e.getWrapS(),wrapT:e.getWrapT()};if(![null,9728,9729,9984,9985,9986,9987].includes(t.minFilter)||![null,9728,9729].includes(t.magFilter)||![33071,33648,10497].includes(t.wrapS)||![33071,33648,10497].includes(t.wrapT))Ht("unsupported effective sampler.");return t}function nR(e,t){Mn(e);let n=Cl(e,["version","id","effectiveSampler","finalMime","finalImageSha256"]);if(n.version!==Yo)Ht("unsupported texture reference version.");return ZM(t,n.id),n}function iR(e){let t=new Set,n=0;for(let{texture:i}of e){if(t.has(i))continue;t.add(i);let r=i.getImage();if(!r||r.byteLength>Fa.encodedBytes)Ht("encoded image missing or over budget.");if(n+=r.byteLength,n>Fa.aggregateEncodedBytes)Ht("aggregate encoded image hash budget exceeded.")}}async function rR(e){let t=YM(e),n=QM(e);if(!n.length)return;if(!t)Ht("atlas table missing.");iR(n);let i=new Map;for(let{texture:r,info:s}of n){let a=nR(Ki(s.getExtras(),"kilnAtlasReference"),t),o=i.get(r);if(!o)o=await eR(r),i.set(r,o);s.setExtras({...s.getExtras(),kilnAtlasReference:{version:Yo,id:a.id,effectiveSampler:tR(s),finalMime:r.getMimeType(),finalImageSha256:o}})}}async function sR(e){let t=YM(e),n=QM(e);if(n.length&&!t)Ht("atlas table missing.");if(!t){for(let s of e.getRoot().listMeshes())for(let a of s.listPrimitives())if(Ki(a.getExtras(),"kilnAtlasBinding")!==void 0)Ht("atlas table missing.");return}iR(n);let i=new Map;for(let{texture:s,info:a}of n){let o=nR(Ki(a.getExtras(),"kilnAtlasReference"),t),c=i.get(s);if(!c)c=await eR(s),i.set(s,c);if(o.finalImageSha256!==c||o.finalMime!==s.getMimeType()||Mn(o.effectiveSampler)!==Mn(tR(a)))Ht("final image or effective sampler identity mismatch.")}let r=0;for(let s of e.getRoot().listMeshes())for(let a of s.listPrimitives()){let o=Ki(a.getExtras(),"kilnAtlasBinding");if(o!==void 0){if(++r>Fa.bindings)Ht("primitive budget exceeded.");tB(o,t);let c=a.getMaterial(),l=Ki(o,"atlasId");if(!(c?[c.getBaseColorTextureInfo(),c.getNormalTextureInfo(),c.getMetallicRoughnessTextureInfo(),c.getEmissiveTextureInfo(),c.getOcclusionTextureInfo()]:[]).some((d)=>d&&Ki(d.getExtras(),"kilnAtlasReference")!==void 0&&Ki(Ki(d.getExtras(),"kilnAtlasReference"),"id")===l))Ht("named binding has no matching material atlas reference.")}}}var Yo="kiln.atlas-provenance.v1",J9,Fa;var aR=mt(()=>{JM();ku();J9=new TextEncoder().encode(JSON.stringify({version:Yo,atlases:[]})).length,Fa=Object.freeze({atlases:128,bytes:4194304,bindings:1024,entryBytes:262144,encodedBytes:16777216,aggregateEncodedBytes:67108864,bakeDecodedBytes:67108864})});var dR={};Pb(dR,{deliverRuntimeThreeGlb:()=>cB});function iB(e,t){let n=(i)=>{if(!i)return-1;if(!t.has(i))t.set(i,t.size);return t.get(i)};return e.listPrimitives().map((i)=>`${i.getMode()}:${n(i.getMaterial())}:${n(i.getIndices())}:${i.listSemantics().sort().map((r)=>`${r}=${n(i.getAttribute(r))}`).join(",")}:${i.listTargets().length}`).join("|")}function rB(e){let t=[],n=new Map,i=e.getRoot().listNodes().filter((s)=>s.getExtras()[sb]!==void 0),r;for(let s of i){let a=new Map;for(let l of s.listChildren()){let u=l.getMesh();if(!u||l.listChildren().length||l.getSkin()||l.listExtensions().length||Il(l)||Nl(l).length||Object.keys(l.getExtras()).length||l.getWeights().length)continue;let d=iB(u,n);a.set(d,[...a.get(d)??[],l])}let o=0;for(let l of a.values()){if(l.length<2)continue;let u=l[0].getMesh();r??=e.createExtension(lf).setRequired(!0);let d=e.getRoot().listBuffers()[0],f=(_,y)=>e.createAccessor().setType(_).setArray(new Float32Array(y)).setBuffer(d??null),h=[],b=[],m=[];for(let _ of l)h.push(..._.getTranslation()),b.push(..._.getRotation()),m.push(..._.getScale());let g=r.createInstancedMesh().setAttribute("TRANSLATION",f("VEC3",h)).setAttribute("ROTATION",f("VEC4",b)).setAttribute("SCALE",f("VEC3",m)),p=`${s.getName()||"Node"}_Instances${o?`_${o}`:""}`;o++;let x=e.createNode(p).setMesh(u).setExtension("EXT_mesh_gpu_instancing",g);s.addChild(x),t.push({node:x,mesh:u.getName(),count:l.length,instances:l.map((_)=>_.getName())});for(let _ of l){let y=_.getMesh();if(_.dispose(),y&&y!==u&&!y.listParents().some((v)=>v.propertyType===te.NODE))y.dispose()}}let c={...s.getExtras()};delete c[sb],s.setExtras(c)}return t}function sB(e){let t=[];for(let n of e.getRoot().listNodes()){let i=n.getMesh();if(!i||!uR(n))continue;let r=e.createNode(`${n.getName()}_Proxy`).setMesh(i);n.setMesh(null).addChild(r),t.push({collider:n,proxy:r})}return t}async function aB(e,t,n){let i=e.getRoot().listTextures().filter((o)=>o.getMimeType()!=="image/ktx2"&&o.getImage());if(!t)return{status:"skipped",textures:i.length,reason:"No KTX2 encoder was supplied; textures stay PNG or JPEG."};let r=new Map,s=(o,c)=>{if(o)r.set(o,(r.get(o)??new Set).add(c))};for(let o of e.getRoot().listMaterials())s(o.getBaseColorTexture(),"baseColor"),s(o.getEmissiveTexture(),"emissive"),s(o.getNormalTexture(),"normal"),s(o.getMetallicRoughnessTexture(),"metallicRoughness"),s(o.getOcclusionTexture(),"occlusion");let a=["baseColor","emissive","normal","metallicRoughness","occlusion"];for(let o of i){let c=r.get(o)??new Set,l=c.has("baseColor")||c.has("emissive"),u=o.listParents().some((m)=>m.propertyType!==te.ROOT&&!oB(m)),d=[...c].some((m)=>m!=="baseColor"&&m!=="emissive")||u;if(l&&d)throw Error(`Texture ${JSON.stringify(o.getName())} is used by both sRGB and linear material slots; one KTX2 encoding cannot serve both. Use separate images.`);let f=o.getImage(),h=await t({image:f,mimeType:o.getMimeType(),name:o.getName(),colorSpace:l?"srgb":"linear",slot:a.find((m)=>c.has(m))??"other"});if(!(h instanceof Uint8Array)||!Sg(h))throw Error("ktx2Encoder must return KTX2 bytes starting with the KTX2 identifier");n.set(o,`sha256:${await El(f)}`),o.setImage(h).setMimeType("image/ktx2");let b=o.getURI();if(b)o.setURI(b.replace(/\.(png|jpe?g)$/i,".ktx2"))}if(i.length){e.createExtension(Gg).setRequired(!0);await Promise.resolve().then(() => aR());await rR(e),await sR(e)}return{status:"encoded",textures:i.length,...t.identity?{encoder:structuredClone(t.identity)}:{}}}function oB(e){return e.propertyType===te.MATERIAL}function lR(e,t){let n=new Qe().fromArray(e).invert().multiply(new Qe().fromArray(t)),i=new j,r=new ln,s=new j;return n.decompose(i,r,s),{scale:s.x,offset:[i.x,i.y,i.z]}}async function cB(e,t,n={},i={}){let r=n.compression??"meshopt";if(r!=="meshopt"&&r!=="none")throw Error("Runtime three compression must be meshopt or none");let s=zM().registerDependencies({"meshopt.encoder":t}),a=await s.readBinary(e);a.setLogger(new ka(ka.Verbosity.SILENT)),await a.transform(tb({propertyTypes:[te.ACCESSOR],keepUniqueNames:!0}));let o=rB(a),c=sB(a),l=new Map;for(let A of a.getRoot().listNodes())if(A.getMesh())l.set(A,[...A.getMatrix()]);if(await a.transform(kM({encoder:t,target:"size"}),PM({pattern:oR,patternTargets:oR,quantizationVolume:"mesh",quantizePosition:_r.position,quantizeNormal:_r.normal,quantizeTexcoord:_r.texcoord,quantizeColor:_r.color,quantizeWeight:_r.weight})),r==="meshopt")a.createExtension(Ml).setRequired(!0).setEncoderOptions({method:Ml.EncoderMethod.QUANTIZE});let u=new Map,d=await aB(a,n.ktx2Encoder,u);for(let A of a.getRoot().listNodes()){if(!A.getMesh()||l.has(A)||A.getName())continue;let w=A.getParentNode();A.setName(`${w?.getName()||"Node"}_Mesh`)}let f=XM(a),h=(A)=>f.get(A)??`#${encodeURIComponent(A.getName())}`,b=new Set(c.map((A)=>A.proxy)),m=[];for(let A of a.getRoot().listNodes()){let E=A.getMesh();if(!E||A.getExtension("EXT_mesh_gpu_instancing"))continue;let w=f.get(A);if(w===void 0)continue;let P=l.get(A),S=P===void 0,I=S||b.has(A),U=S?new Qe().identity().toArray():P,N=[...A.getMatrix()],{scale:F,offset:D}=lR(U,N);if(!S&&Math.abs(F-1)<0.000000000001&&D.every((K)=>K===0))continue;let O=A.getParentNode();m.push({node:w,mesh:E.getName(),meshMovedToChild:I,...I&&O?{authoredNode:h(O)}:{},dequantization:{scale:F,offset:D},localScale:[...A.getScale()]})}for(let A of a.getRoot().listNodes()){let E=A.getMesh();if(!E||f.has(A)||!l.has(A))continue;let{scale:w,offset:P}=lR(l.get(A),[...A.getMatrix()]);m.push({node:`#lod/${encodeURIComponent(A.getName())}`,mesh:E.getName(),meshMovedToChild:!1,dequantization:{scale:w,offset:P},localScale:[...A.getScale()]})}let g=new Map;for(let A of a.getRoot().listMeshes())for(let E of A.listPrimitives())for(let w of E.listSemantics())if(w.startsWith("_"))g.set(w,(g.get(w)??new Set).add(A));let p=a.getRoot().listNodes(),x=await s.writeBinary(a),_=(await s.binaryToJSON(x)).json,y=new Map;a.getRoot().listTextures().forEach((A,E)=>{let w=u.get(A);if(w)y.set(E,w)});let v=i.gltfBasename?await s.writeJSON(a,{format:zw.GLTF,basename:i.gltfBasename}):void 0,T={target:"three",extensionsUsed:[..._.extensionsUsed??[]].sort(),extensionsRequired:[..._.extensionsRequired??[]].sort(),compression:r==="meshopt"?{extension:"EXT_meshopt_compression",method:"quantize"}:{extension:"none"},quantization:{extension:"KHR_mesh_quantization",volume:"mesh",bits:{position:_r.position,normal:_r.normal,texcoord:_r.texcoord,color:_r.color,weight:_r.weight},customAttributes:"float32"},nodeScale:m,colliderProxies:c.map(({collider:A,proxy:E})=>({collider:h(A),proxy:h(E)})),customAttributes:[...g].sort(([A],[E])=>cR(A)-cR(E)||(A<E?-1:A>E?1:0)).map(([A,E])=>({name:A,meshes:E.size,componentType:"FLOAT",normalized:!1})),instancing:o.map(({node:A,...E})=>({node:h(A),...E})),ktx2:d,preserved:{lodChains:p.filter((A)=>A.getExtension(hi)).length,hiddenNodes:p.filter((A)=>Il(A)).length,colliders:p.filter(uR).length,anchors:p.filter((A)=>Nl(A).some((E)=>E.startsWith(`${La.anchor}.`))).length,ports:p.filter((A)=>Nl(A).some((E)=>E.startsWith(`${La.kitPort}.`))).length,kitModules:p.filter((A)=>Nl(A).includes(La.kitModule)).length}};return{glb:x,delivery:T,imageSources:y,...v?{gltf:{json:v.json,resources:v.resources}}:{}}}var _r,oR,cR=(e)=>e==="_EDGE"?0:e==="_CAVITY"?1:2,Nl=(e)=>nb(e.getExtras())?.roles??[],uR=(e)=>Nl(e).some((t)=>t.startsWith(`${La.collider}.`));var fR=mt(()=>{wl();uf();DM();ji();Af();ib();qM();ab();wf();Mg();_r=Object.freeze({volume:"mesh",position:14,normal:10,texcoord:12,color:8,weight:8}),oR=/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/});var lB;var hR=mt(()=>{lB=function(){var e="b9H79Tebbbe9ok9Geueu9Geub9Gbb9Gruuuuuuueu9Gvuuuuueu9Gduueu9Gluuuueu9Gvuuuuub9Gouuuuuub9Gluuuub9GiuuueuiE8AdilveoveovrrwrrrDDoDrbqqbelve9Weiiviebeoweuecj:Gdkr:PlCo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8F9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWV9mW4W2be8A9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWVbd8F9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWV9c9V919U9KbiE9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949wWV79P9V9UblY9TW79O9V9Wt9FW9U9J9V9KW69U9KW949c919M9MWVbv8E9TW79O9V9Wt9FW9U9J9V9KW69U9KW949c919M9MWV9c9V919U9Kbo8A9TW79O9V9Wt9FW9U9J9V9KW69U9KW949wWV79P9V9UbrE9TW79O9V9Wt9FW9U9J9V9KW69U9KW949tWG91W9U9JWbwa9TW79O9V9Wt9FW9U9J9V9KW69U9KW949tWG91W9U9JW9c9V919U9KbDL9TW79O9V9Wt9FW9U9J9V9KWS9P2tWV9p9JtbqK9TW79O9V9Wt9FW9U9J9V9KWS9P2tWV9r919HtbkL9TW79O9V9Wt9FW9U9J9V9KWS9P2tWVT949WbxY9TW79O9V9Wt9FW9U9J9V9KWS9P2tWVJ9V29VVbmE9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94J9H9J9OWbza9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94J9H9J9OW9ttV9P9WbHa9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94SWt9J9O9sW9T9H9WbOK9TW79O9V9Wt9F79W9Ht9P9H29t9VVt9sW9T9H9WbAl79IV9RbXDwebcekdKYq:8f8Adbk;wadhud9:8Jjjjjbc;qw9Rgr8KjjjjbcbhwdnaeTmbabcbyd;i:I:cjbaoaocb9iEgDc:GeV86bbarc;adfcbcjdz:xjjjb8AdnaiTmbarc;adfadalz:wjjjb8Akarc;abfalfcbcbcjdal9RalcFe0Ez:xjjjb8Aarc;abfarc;adfalz:wjjjb8Aar9cb83iUar9cb83i8War9cb83iyar9cb83iaar9cb83iKar9cb83izar9cb83iwar9cb83ibcj;abal9Uc;WFbGcjdalca0Ehqdnaicd6mbavcd9imbaDTmbadcefhkaqci2gxal2hmarc;alfclfhParc;qlfceVhsarc;qofclVhzcbhHincdhOcbhAdnavci6mbar9cb83i;Ooar9cb83i;Goar9cb83i;yoar9cb83i;qoadaHfgoybbhCcbhXincbhwcbhQdninaoalfhLaoybbgKaC7aQVhQawcP0meaLhoaKhCawcefgwaXfai6mbkkcbhCarc;qofhwincwhYcwh8AdnaQaC93gocFeGgEcs0mbclh8AaEci0mbcdcbaEEh8Akdnaocw4cFeGgEcs0mbclhYaEci0mbcdcbaEEhYkaYa8AfhEawydbh3cwhYcwh8Adnaocz4cFeGg5cs0mbclh8Aa5ci0mbcdcba5Eh8AkaEa3fhEdnaocFFFFb0mbclhYaocFFF8F0mbcbcdaocjjjw6EhYkawaEa8AfaYfBdbawclfhwaCcefgCcw9hmbkaLhoaKhCaXczfgXai6mbkcbhocehwazhQinawaoaQydbarc;qofaocdtfydb6EhoaQclfhQawcefgwcw9hmbkaoclthAcihOkcbhEarc;qlfcbcjdz:xjjjb8AarcbBd;ilar9cb83i;aladh8Eaqh8Fakh3inarc;qlfadaEaEcb9h9Ral2falz:wjjjb8Aaia8Faia8F6EhadnaqaiaE9RaEaqfai6EgKcsfc9WGgoaK9nmbarc;qofaKfcbaoaK9Rz:xjjjb8AkadaEal2fhhcbhginagaAVcl4hXarc;alfagcdtfh8JaHh8Kcbh8Lina8LaHfhwdndndndndndndnagPlbedibkaKTmvahawfhoarc;qlfawfRbbhQarc;qofhwaahCinawaoRbbgYaQ9RgQcetaQcKtc8F91786bbawcefhwaoalfhoaYhQaEaCcufgC9hmbxvkkaKTmla8Kc9:Ghoa8LcitcwGh8Aarc;qlfawceVfRbbcwtarc;qlfawc9:GfRbbVhQarc;qofhwaahCinawa3aofRbbcwta8EaofRbbVgYaQ9RgQcetaQcztc8F917cFFiGa8A486bbaoalfhoawcefhwaYhQaEaCcufgC9hmbxlkkasa8Kc98GgQfhoa3aQfhYarc;qlfawc98GgQfRbbhCcwhwinaoRbbawtaCVhCaocefhoawcwfgwca9hmbxdkkaKTmdxekaKTmea8Lcith5ahaQfh8AcbhLina8ARbbhQcwhoaYhwinawRbbaotaQVhQawcefhwaocwfgoca9hmbkarc;qofaLfaQaC7aX93a5486bbaYalfhYa8Aalfh8AaQhCaLcefgLaK9hmbkka8Jydbh8AcbhLarc;qofhoincdhQcbhwinaQaoawfRbbcb9hfhQawcefgwcz9hmbkclhCcbhwinaCaoawfRbbcd0fhCawcefgwcz9hmbkcwhYcbhwinaYaoawfRbbcP0fhYawcefgwcz9hmbkaQaCaQaC6EgwaYawaY6Egwczawcz6Ea8Afh8AaoczfhoaLczfgLaK6mbka8Ja8ABdbka8Kcefh8Ka8Lcefg8Lcl9hmbkagcefggaO9hmbka8Eamfh8Ea8Faxfh8Fa3amfh3aEaxfgEai6mbkcbhocehwaPhQinawaoaQydbarc;alfaocdtfydb6EhoaQclfhQaOawcefgw9hmbkaraHcd4faAcdVaoaocdSE86bbaHclfgHal6mbkkabaefhgabcefhoalcd4g8McbaDEhkadcefh8Narc;abfceVhecbhmdndninaiam9nmearc;qofcbcjdz:xjjjb8Aagao9Rak6mdadamal2gwfhxcbhHa8Nawfhzaocbakz:xjjjbg8Fakfh3aqaiam9Ramaqfai6Egscsfgocl4cifcd4hOaoc9WGg8JThPindndndndndndndndndndnaDTmbaraHcd4fRbbgQciGPlbedlbkasTmdaxaHfhoarc;abfaHfRbbhQarc;qofhwashCinawaoRbbgYaQ9RgQcetaQcKtc8F91786bbawcefhwaoalfhoaYhQaCcufgCmbxikkasTmiaHcitcwGh8Aarc;abfaHceVfRbbcwtarc;abfaHc9:GgofRbbVhQaxaofhoarc;qofhwashCinawao8VbbgYaQ9RgQcetaQcztc8F917cFFiGa8A486bbawcefhwaoalfhoaYhQaCcufgCmbxikkaeaHc98Gg8Afhoaza8AfhYarc;abfa8AfRbbhCcwhwinaoRbbawtaCVhCaocefhoawcwfgwca9hmbkasTmdaQcl4hKaHcitcKGhEaxa8Afh8AcbhLina8ARbbhQcwhoaYhwinawRbbaotaQVhQawcefhwaocwfgoca9hmbkarc;qofaLfaQaC7aK93aE486bbaYalfhYa8Aalfh8AaQhCaLcefgLas9hmbkkaDmbcbhoxlka8JTmbcbhodninarc;qofaofgwcwf8Pibaw8Pib:e9qTmeaoczfgoa8J9pmdxbkkdnavmbcehoxikcbh8AaOhLaOhKinarc;qofa8Afgocwf8Pibhyao8Pibh8PcdhQcbhwinaQaoawfRbbcb9hfhQawcefgwcz9hmbkclhCcbhwinaCaoawfRbbcd0fhCawcefgwcz9hmbkcwhYcbhwinaYaoawfRbbcP0fhYawcefgwcz9hmbkaQaCaQaC6EgoaYaoaY6Egoczaocz6EaKfhKaocucbaya8P:e9cb9sEgwaoaw6EaLfhLa8Aczfg8Aa8J9pmdxbkka8FaHcd4fgoaoRbbcdaHcetcoGtV86bbxikdnaLas6mbaKas6mba8FaHcd4fgoaoRbbciaHcetcoGtV86bbaga39Ras6mra3arc;qofasz:wjjjbasfh3xikaLaK9phoka8FaHcd4fgwawRbbaoaHcetcoGtV86bbkaga39RaO6mla3cbaOz:xjjjbgaaOfhKdndna8JmbaPhoxekdnagaK9RcK9pmbaPhoxekaocdtc:q:G:cjbfcj:G:cjbaDEg3ydxghcetc;:FFFeGhAcuhEcuahtcu7cFeGh8Ecbh8Karc;qofhQinarc;qofa8KfhXczh8AdndndnahPDbeeeeeeedekcucbaXcwf8PibaX8Pib:e9cb9sEh8AxekcbhoaAh8Aina8Aa8EaQaofRbb9nfh8Aaocefgocz9hmbkkcih5cbhYinczhwdndndna3aYcdtfydbgLPDbeeeeeeedekcucbaXcwf8PibaX8Pib:e9cb9sEhwxekaLcetc;:FFFeGhwcuaLtcu7cFeGhCcbhoinawaCaQaofRbb9nfhwaocefgocz9hmbkkdndnawa8A6mbaLaE9hmeawa8A9hmea3a5cdtfydbcwSmekaYh5awh8AkaYcefgYci9hmbkaaa8Kco4fgoaoRbba5a8Kci4coGtV86bbdndndna3a5cdtfydbgEPDdbbbbbbbebkdncwaE9Tg5TmbcuaEtcu7hwdndnaEceSmbcbh8LaQhXinaXhoa5hYcbhCinaoRbbg8AawcFeGgLa8AaL6EaCaEtVhCaocefhoaYcufgYmbkaKaC86bbaXa5fhXaKcefhKa8La5fg8Lcz6mbxdkkcbh8LaQhXinaXhoa5hYcbhCinaoRbbg8AawcFeGgLa8AaL6EaCcetVhCaocefhoaYcufgYmbkaKaC:T9cFe:d9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:9ca188bbaXa5fhXaKcefhKa8La5fg8Lcz6mbkkcbhoinaKaQaofRbbgC86bbaKaCawcFeG9pfhKaocefgocz9hmbxikkdnaEceSmbinaKcb86bbaKcefhKxbkkinaKcb86bbaKcefhKxbkkaKaX8Pbw83bwaKaX8Pbb83bbaKczfhKka8Kczfg8Ka8J9pgomeaQczfhQagaK9RcK9pmbkkaoTmlaKh3aKTmlkaHcefgHal9hmbkarc;abfaxascufal2falz:wjjjb8Aasamfhma3hoa3mbkcbhwxdkdnagao9RakalfgwcKcaaDEgQawaQ0EgC9pmbcbhwxdkdnawaQ9pmbaocbaCaw9Rgwz:xjjjbawfhokaoarc;adfalz:wjjjbalfhodnaDTmbaoara8Mz:wjjjba8Mfhokaoab9Rhwxekcbhwkarc;qwf8Kjjjjbawk5babaeadaialcdcbyd;i:I:cjbz:bjjjbk9reduaecd4gdaefgicaaica0Eabcj;abae9Uc;WFbGcjdaeca0Egifcufai9Uae2aiadfaicl4cifcd4f2fcefkmbcbabBd;i:I:cjbk;HPeLu8Jjjjjbc;ae9Rgl8Kjjjjbcbhvdnaeaici9UgocHf6mbabcbyd;m:I:cjbgrc;GeV86bbalc;abfcFecjez:xjjjb8Aal9cu83iUal9cu83i8Wal9cu83iyal9cu83iaal9cu83iKal9cu83izal9cu83iwal9cu83ibabaefc9WfhwabcefgDaofhednaiTmbcmcsarcb9kgqEhkcbhxcbhmcbhPcbhscbhzindnaeaw9nmbcbhvxikazcufhvadaPcdtfgHydbhOaHcwfydbhAaHclfydbhCcbhXdndndninalc;abfavcsGcitfgoydlhQdndndnaoydbgoaO9hmbaQaCSmekdnaoaC9hmbaQaA9hmbaXcefhXxekaoaA9hmeaQaO9hmeaXcdfhXkaXc870mdascufhvaHaXcdtgAcxGgoyd:4:G:cjbcdtfydbhQaHaoyd:0:G:cjbcdtfydbhCaHaoyd:W:G:cjbcdtfydbhOcbhodnindnalavcsGcdtfydbaQ9hmbaohXxdkcuhXavcufhvaocefgocz9hmbkkaxaQaxSgvaXce9iaXak9oVgoGfhxdndndncbcsavEaXaoEgvcs9hmbarce9imbaQaQamaQcefamSgvEgmcefSmecmcsavEhvkaDavaAc;WeGV86bbavcs9hmeaQam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaQhmxvkcPhvaDaAcPV86bbaQhmkavTmiavak9omicdhocehXazhAxlkavcufhvaXclfgXc;ab9hmbkkdnaHcecdcbaAaxSEaCaxSEcdtgvyd:W:G:cjbcdtfydbgOTaHavyd:0:G:cjbcdtfydbgCceSGaHavyd:4:G:cjbcdtfydbgQcdSGaxcb9hGaqGgLce9hmbal9cu83iUal9cu83i8Wal9cu83iyal9cu83iaal9cu83iKal9cu83izal9cu83iwal9cu83ibcbhxkcbhXascufgvhodnindnalaocsGcdtfydbaC9hmbaXhAxdkcuhAaocufhoaXcefgXcz9hmbkkcbhodnindnalavcsGcdtfydbaQ9hmbaohXxdkcuhXavcufhvaocefgocz9hmbkkaxaOaxSgKfhHdndnaAcm0mbaAcefhAxekcbcsaCaHSgvEhAaHavfhHkdndnaXcm0mbaXcefhXxekcbcsaQaHSgvEhXaHavfhHkc9:cuaKEhYcbhvaXaAcltVg8AcFeGhodndndninavc;q:G:cjbfRbbaoSmeavcefgvcz9hmbxdkkaLaOax9havcm0VVmbaDavc;WeV86bbxekaDaY86bbaea8A86bbaecefhekdnaKmbaOam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaOhmkdnaAcs9hmbaCam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaChmkdnaXcs9hmbaQam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaQhmkalascdtfaOBdbascefcsGhvdndnaAPzbeeeeeeeeeeeeeebekalavcdtfaCBdbascdfcsGhvkdndnaXPzbeeeeeeeeeeeeeebekalavcdtfaQBdbavcefcsGhvkcihoalc;abfazcitfgXaOBdlaXaCBdbazcefcsGhAcdhXavhsaHhxxekcdhoalascdtfaQBdbcehXascefcsGhsazhAkalc;abfaAcitfgvaCBdlavaQBdbalc;abfazaXfcsGcitfgvaQBdlavaOBdbaDcefhDazaofcsGhzaPcifgPai6mbkkdnaeaw9nmbcbhvxekcbhvinaeavfavc;q:G:cjbfRbb86bbavcefgvcz9hmbkaeab9Ravfhvkalc;aef8KjjjjbavkZeeucbhddninadcefgdc8F0meaeceadt0mbkkadcrfcFeGcr9Uci2cdfabci9U2cHfkmbcbabBd;m:I:cjbk:zderu8Jjjjjbcz9Rhlcbhvdnaeaicvf6mbabcbRb;m:I:cjbc;qeV86bbal9cb83iwabcefhvabaefc98fhodnaiTmbcbhecbhrcbhwindnavao6mbcbskadawcdtfydbgDalcwfaraDae9Rgeaec8F91ge7ae9Rc507grcdtfgqydb9Rgec8E91c9:Gaecdt7arVheinavcbcjeaecje6EaecFbGV86bbavcefhvaecr4gembkaqaDBdbaDheawcefgwai9hmbkkdnavao9nmbcbskavcbBbbavab9RclfhvkavkBeeucbhddninadcefgdc8F0meaeceadt0mbkkabadcwfcFeGcr9U2cvfk:dvli99dui99ludnaeTmbcuadcetcuftcu7:Zhvdndncuaicuftcu7:ZgoJbbbZMgr:lJbbb9p9DTmbar:Ohwxekcjjjj94hwkcbhicbhDinalclfIdbgrJbbbbJbbjZalIdbgq:lar:lMalcwfIdbgk:lMgr:varJbbbb9BEgrNhxaqarNhralcxfIdbhqdndnakJbbbb9GTmbaxhkxekJbbjZar:l:tgkak:maxJbbbb9GEhkJbbjZax:l:tgxax:marJbbbb9GEhrkdndnaqJbbj:;aqJbbj:;9GEgxJbbjZaxJbbjZ9FEavNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohmxekcjjjj94hmkdndnakJbbj:;akJbbj:;9GEgqJbbjZaqJbbjZ9FEaoNJbbbZJbbb:;akJbbbb9GEMgq:lJbbb9p9DTmbaq:OhPxekcjjjj94hPkdndnarJbbj:;arJbbj:;9GEgqJbbjZaqJbbjZ9FEaoNJbbbZJbbb:;arJbbbb9GEMgr:lJbbb9p9DTmbar:Ohsxekcjjjj94hskdndnadcl9hmbabaDfgzas86bbazcifam86bbazcdfaw86bbazcefaP86bbxekabaifgzas87ebazcofam87ebazclfaw87ebazcdfaP87ebkaicwfhiaDclfhDalczfhlaecufgembkkk;hlld99eud99eudnaeTmbdndncuaicuftcu7:ZgvJbbbZMgo:lJbbb9p9DTmbao:Ohixekcjjjj94hikaic;8FiGhrinabcofcicdalclfIdb:lalIdb:l9EgialcwfIdb:lalaicdtfIdb:l9EEgialcxfIdb:lalaicdtfIdb:l9EEgiarV87ebdndnJbbj:;JbbjZalaicdtfIdbJbbbb9DEgoalaicd7cdtfIdbJ;Zl:1ZNNgwJbbj:;awJbbj:;9GEgDJbbjZaDJbbjZ9FEavNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohqxekcjjjj94hqkabcdfaq87ebdndnalaicefciGcdtfIdbJ;Zl:1ZNaoNgwJbbj:;awJbbj:;9GEgDJbbjZaDJbbjZ9FEavNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohqxekcjjjj94hqkabaq87ebdndnaoalaicufciGcdtfIdbJ;Zl:1ZNNgoJbbj:;aoJbbj:;9GEgwJbbjZawJbbjZ9FEavNJbbbZJbbb:;aoJbbbb9GEMgo:lJbbb9p9DTmbao:Ohixekcjjjj94hikabclfai87ebabcwfhbalczfhlaecufgembkkk;Pviwue99eu8Jjjjjbcjd9Rgo8Kjjjjbadcd4hrdndndnavcd9hmbarTmbaohdarhwinadc:CuBdbadclfhdawcufgwmbkaeTmdarcdthDalhqcbhkinaohdaqhwarhxinadadydbgmcbawIdbgP:8cL4cFeGc:cufaPJbbbb9BEgsamas9kEBdbawclfhwadclfhdaxcufgxmbkaqaDfhqakcefgkae9hmbxdkkaeTmekarcdthqavce9hhDcbhkindndndnaDmbarTmdc:CuhwalhdarhxinawcbadIdbgP:8cL4cFeGc:cufaPJbbbb9BEgmawam9kEhwadclfhdaxcufgxmbxdkkdndndndnavPleddbdkarTmlaohdalhwarhxinadcbcbawIdbgP:8cL4cFeGgmc:cufgsasam0EaPJbbbb9BEBdbadclfhdawclfhwaxcufgxmbxikkarTmicbhdarhwinaoadfcbaladfIdbgP:8cL4cFeGgxc8Aaxc8A0Ec:cufaPJbbbb9BEBdbadclfhdawcufgwmbxdkkarTmdkc:CuhwkcbhdarhminawhxdnavceSmbaoadfydbhxkdndnaladfIdbgPcjjj;8iaxai9RcefgxcLt9R::NJbbbZJbbb:;aPJbbbb9GEMgP:lJbbb9p9DTmbaP:Ohsxekcjjjj94hskabadfascFFFrGaxcKtVBdbadclfhdamcufgmmbkkabaqfhbalaqfhlakcefgkae9hmbkkaocjdf8Kjjjjbk:Olveue99iue99iudnaeTmbceaicufthvcuaitcu7:Zhocbhradcl9hhwcbhDindndnalcwfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohixekcjjjj94hikdndnalIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkadai9Rcd9TgkaifhidndnalclfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkadai9Rcd9ThddndnalcxfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohxxekcjjjj94hxkadaifhiaxce91avVhxdndnawmbabaDfgmai86bbamcifax86bbamcdfad86bbamcefak86bbxekabarfgmai87ebamcofax87ebamclfad87ebamcdfak87ebkarcwfhraDclfhDalczfhlaecufgembkkk;mqdQui998Jjjjjbc:qd9Rgv8Kjjjjbavc:Sefcbc;Kbz:xjjjb8AdnadTmbaiTmbdndnabaeSmbaehoxekavcuadcdtgradcFFFFi0Ecbyd;q:I:cjbHjjjjbbgoBd:SeavceBd:mdaoaearz:wjjjb8AkavcbBd:Oeav9cb83i:Geavc:Gefaoadaiavc:Sefz:pjjjbavyd:Gehwadci9UgDcbyd;q:I:cjbHjjjjbbheavc:Sefavyd:mdgqcdtfaeBdbavaqcefgrBd:mdaecbaDz:xjjjbhkavc:SefarcdtfcuaicdtaicFFFFi0Ecbyd;q:I:cjbHjjjjbbgxBdbavaqcdfgmBd:mdalc;ebfhPawheaxhrinaralIdbaPaeydbgscwascw6EcdtfIdbMUdbaeclfhearclfhraicufgimbkavc:SefamcdtfcuaDcdtadcFFFF970Ecbyd;q:I:cjbHjjjjbbgmBdbdnadci6mbaoheamhraDhiinaraxaeydbcdtfIdbaxaeclfydbcdtfIdbMaxaecwfydbcdtfIdbMUdbaecxfhearclfhraicufgimbkkaqcifhzalc;ebfhHavc;qbfhOavheavyd:KehAavyd:OehCcbhscbhrcbhXcehQinaehLaoarcx2fgKydbhPaKclfydbhdabaXcx2fgecwfaKcwfydbgYBdbaeclfadBdbaeaPBdbakarfce86bbaOaYBdwaOadBdlaOaPBdbamarcdtfcbBdbcih8AdnasTmbaLhiinaOa8AcdtfaiydbgeBdba8AaeaY9haeaP9haead9hGGfh8AaiclfhiascufgsmbkkaXcefhXcbhsinaCaAaKascdtfydbcdtgifydbcdtfgYheawaifgdydbgPhidnaPTmbdninaeydbarSmeaeclfheaicufgiTmdxbkkaeaYaPcdtfc98fydbBdbadadydbcufBdbkascefgsci9hmbkdndndna8ATmbcuhrJbbbbhEcbhdavyd:KehYavyd:OehKindnawaOadcdtfydbcdtgsfydbgeTmbaxasfgiIdbh3aialcuadadcs0EcdtfclfIdbaHaecwaecw6EcdtfIdbMg5Udba5a3:th5aecdthiaKaYasfydbcdtfheinamaeydbgscdtfgPa5aPIdbMg3Udba3aEaEa39DgPEhEasaraPEhraeclfheaic98fgimbkkadcefgda8A9hmbkarcu9hmekaQaD9pmeindnakaQfRbbmbaQhrxdkaDaQcefgQ9hmbxdkka8Acza8Acz6EhsaOheaLhOarcu9hmekkazTmbaqcdtavc:Seffcwfheinaeydbcbyd;u:I:cjbH:bjjjbbaec98fheazcufgzmbkkavc:qdf8Kjjjjbk:0leoucuaicdtgvaicFFFFi0Egocbyd;q:I:cjbHjjjjbbhralalyd9GgwcdtfarBdbalawcefBd9GabarBdbaocbyd;q:I:cjbHjjjjbbhralalyd9GgocdtfarBdbalaocefBd9GabarBdlcuadcdtadcFFFFi0Ecbyd;q:I:cjbHjjjjbbhralalyd9GgocdtfarBdbalaocefBd9GabarBdwabydbcbavz:xjjjb8AabydbhraehladhvinaralydbcdtfgoaoydbcefBdbalclfhlavcufgvmbkcbhvabydlglhoarhwaihDinaoavBdbaoclfhoawydbavfhvawclfhwaDcufgDmbkadci9Uhqdnadcd9nmbabydwhocbhvinaecwfydbhwaeclfydbhDalaeydbcdtfgbabydbgbcefBdbaoabcdtfavBdbalaDcdtfgDaDydbgDcefBdbaoaDcdtfavBdbalawcdtfgwawydbgwcefBdbaoawcdtfavBdbaecxfheaqavcefgv9hmbkkinalalydbarydb9RBdbarclfhralclfhlaicufgimbkkQbabaeadaic;G:G:cjbz:ojjjbkQbabaeadaic;i:H:cjbz:ojjjbk9DeeuabcFeaicdtz:xjjjbhlcbhbdnadTmbindnalaeydbcdtfgiydbcu9hmbaiabBdbabcefhbkaeclfheadcufgdmbkkabk:3vioud9:du8Jjjjjbc;Wa9Rgl8Kjjjjbcbhvalcxfcbc;Kbz:xjjjb8AalcuadcitgoadcFFFFe0Ecbyd;q:I:cjbHjjjjbbgrBdxalceBd2araeadaicezNjjjbalcuaoadcjjjjoGEcbyd;q:I:cjbHjjjjbbgwBdzadcdthednadTmbabhiinaiavBdbaiclfhiadavcefgv9hmbkkawaefhDalabBdwalawBdl9cbhqindnadTmbaq9cq9:hkarhvaDhiadheinaiav8Pibak1:NcFrG87ebavcwfhvaicdfhiaecufgembkkalclfaq:NceGcdtfydbhxalclfaq9ce98gq:NceGcdtfydbhmalc;Wbfcbcjaz:xjjjb8AaDhvadhidnadTmbinalc;Wbfav8VebcdtfgeaeydbcefBdbavcdfhvaicufgimbkkcbhvcbhiinalc;WbfavfgeydbhoaeaiBdbaoaifhiavclfgvcja9hmbkadhvdndnadTmbinalc;WbfaDamydbgicetf8VebcdtfgeaeydbgecefBdbaxaecdtfaiBdbamclfhmavcufgvmbkaq9cv9smdcbhvinabawydbcdtfavBdbawclfhwadavcefgv9hmbxdkkaq9cv9smekkcwhvcbhiinalcxfavfc98fydbcbyd;u:I:cjbH:bjjjbbaiceGheclhvcehiaeTmbkalc;Waf8Kjjjjbk:Awliuo99iud9:cbhv8Jjjjjbca9Rgocbyd:4:I:cjbBdKaocb8Pd:W:I:cjb83izaocbyd;e:I:cjbBdwaocb8Pd:8:I:cjb83ibaicd4hrdndnadmbJFFuFhwJFFuuhDJFFuuhqJFFuFhkJFFuuhxJFFuFhmxekarcdthPaehsincbhiinaoczfaifgzasaifIdbgwazIdbgDaDaw9EEUdbaoaifgzawazIdbgDaDaw9DEUdbaiclfgicx9hmbkasaPfhsavcefgvad9hmbkaoIdKhDaoIdwhwaoIdChqaoIdlhkaoIdzhxaoIdbhmkdnadTmbJbbbbJbFu9hJbbbbamax:tgmamJbbbb9DEgmakaq:tgkakam9DEgkawaD:tgwawak9DEgw:vawJbbbb9BEhwdnalmbarcdthoindndnaeclfIdbaq:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:S9cC:ghHdndnaeIdbax:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikaHai:S:ehHdndnaecwfIdbaD:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabaHai:T9cy:g:e83ibaeaofheabcwfhbadcufgdmbxdkkarcdthoindndnaeIdbax:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cv9:9c;j:KM;j:KM;j:Kd:dhOdndnaeclfIdbaq:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cq9:9cM;j:KM;j:KM;jl:daO:ehOdndnaecwfIdbaD:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabaOai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cC9:9c:KM;j:KM;j:KMD:d:e83ibaeaofheabcwfhbadcufgdmbkkk9teiucbcbyd;y:I:cjbgeabcifc98GfgbBd;y:I:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd;y:I:cjbgeabcrfc94GfgbBd;y:I:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd;y:I:cjbge9Rcifc98GaefgbBd;y:I:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akkk;Sddbcj:Gdk;idbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbbbbbbbbbbbbbbbbebbbdbbbbbbbebbbbbbbbbbbbbbbb4:h9w9N94:P:gW:j9O:ye9Pbbbbbb:l29hZ;69:9kZ;N;76Z;rg97Z;z;o9xZ8J;B85Z;:;u9yZ;b;k9HZ:2;Z9DZ9e:l9mZ59A8KZ:r;T3Z:A:zYZ79OHZ;j4::8::Y:D9V8:bbbb9s:49:Z8R:hBZ9M9M;M8:L;z;o8:;8:PG89q;x:J878R:hQ8::M:B;e87bbbbbbjZbbjZbbjZ:E;V;N8::Y:DsZ9i;H;68:xd;R8:;h0838:;W:NoZbbbb:WV9O8:uf888:9i;H;68:9c9G;L89;n;m9m89;D8Ko8:bbbbf:8tZ9m836ZS:2AZL;zPZZ818EZ9e:lxZ;U98F8:819E;68:FFuuFFuuFFuuFFuFFFuFFFuFbc;i:IdkCebbbebbbebbbdbbb9G:rbb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,i=WebAssembly.instantiate(r(e),{}).then(function(h){n=h.instance,n.exports.__wasm_call_ctors(),n.exports.meshopt_encodeVertexVersion(1),n.exports.meshopt_encodeIndexVersion(1)});function r(h){var b=new Uint8Array(h.length);for(var m=0;m<h.length;++m){var g=h.charCodeAt(m);b[m]=g>96?g-97:g>64?g-39:g+4}var p=0;for(var m=0;m<h.length;++m)b[p++]=b[m]<60?t[b[m]]:(b[m]-60)*64+b[++m];return b.buffer.slice(0,p)}function s(h){if(!h)throw Error("Assertion failed")}function a(h){return new Uint8Array(h.buffer,h.byteOffset,h.byteLength)}function o(h,b,m,g){var p=n.exports.sbrk,x=p(b.length*4),_=p(m*4),y=new Uint8Array(n.exports.memory.buffer),v=a(b);if(y.set(v,x),g)g(x,x,b.length,m);var T=h(_,x,b.length,m);y=new Uint8Array(n.exports.memory.buffer);var A=new Uint32Array(m);new Uint8Array(A.buffer).set(y.subarray(_,_+m*4)),v.set(y.subarray(x,x+b.length*4)),p(x-p(0));for(var E=0;E<b.length;++E)b[E]=A[b[E]];return[A,T]}function c(h,b,m,g){var p=n.exports.sbrk,x=p(m*4),_=p(m*g),y=new Uint8Array(n.exports.memory.buffer);y.set(a(b),_),h(x,_,m,g),y=new Uint8Array(n.exports.memory.buffer);var v=new Uint32Array(m);return new Uint8Array(v.buffer).set(y.subarray(x,x+m*4)),p(x-p(0)),v}function l(h,b,m,g,p,x,_){var y=n.exports.sbrk,v=y(b),T=y(g*p),A=new Uint8Array(n.exports.memory.buffer);A.set(a(m),T);var E=h(v,b,T,g,p,x,_),w=new Uint8Array(E);return w.set(A.subarray(v,v+E)),y(v-y(0)),w}function u(h){var b=0;for(var m=0;m<h.length;++m){var g=h[m];b=b<g?g:b}return b}function d(h,b){if(s(b==2||b==4),b==4)return new Uint32Array(h.buffer,h.byteOffset,h.byteLength/4);else{var m=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/2);return new Uint32Array(m)}}function f(h,b,m,g,p,x,_){var y=n.exports.sbrk,v=y(m*g),T=y(m*x),A=new Uint8Array(n.exports.memory.buffer);A.set(a(b),T),h(v,m,g,p,T,_);var E=new Uint8Array(m*g);return E.set(A.subarray(v,v+m*g)),y(v-y(0)),E}return{ready:i,supported:!0,reorderMesh:function(h,b,m){s(h instanceof Uint32Array||h instanceof Int32Array),s(!b||h.length%3==0);var g=b?m?n.exports.meshopt_optimizeVertexCacheStrip:n.exports.meshopt_optimizeVertexCache:void 0;return o(n.exports.meshopt_optimizeVertexFetchRemap,h,u(h)+1,g)},reorderPoints:function(h,b){return s(h instanceof Float32Array),s(h.length%b==0),s(b>=3),c(n.exports.meshopt_spatialSortRemap,h,h.length/b,b*4)},encodeVertexBuffer:function(h,b,m){s(m>0&&m<=256),s(m%4==0);var g=n.exports.meshopt_encodeVertexBufferBound(b,m);return l(n.exports.meshopt_encodeVertexBuffer,g,h,b,m)},encodeVertexBufferLevel:function(h,b,m,g,p){s(m>0&&m<=256),s(m%4==0),s(g>=0&&g<=3),s(p===void 0||p==0||p==1);var x=n.exports.meshopt_encodeVertexBufferBound(b,m);return l(n.exports.meshopt_encodeVertexBufferLevel,x,h,b,m,g,p===void 0?-1:p)},encodeIndexBuffer:function(h,b,m){s(m==2||m==4),s(b%3==0);var g=d(h,m),p=n.exports.meshopt_encodeIndexBufferBound(b,u(g)+1);return l(n.exports.meshopt_encodeIndexBuffer,p,g,b,4)},encodeIndexSequence:function(h,b,m){s(m==2||m==4);var g=d(h,m),p=n.exports.meshopt_encodeIndexSequenceBound(b,u(g)+1);return l(n.exports.meshopt_encodeIndexSequence,p,g,b,4)},encodeGltfBuffer:function(h,b,m,g,p){var x={ATTRIBUTES:this.encodeVertexBufferLevel,TRIANGLES:this.encodeIndexBuffer,INDICES:this.encodeIndexSequence};return s(x[g]),x[g](h,b,m,2,p===void 0?0:p)},encodeFilterOct:function(h,b,m,g){return s(m==4||m==8),s(g>=2&&g<=16),f(n.exports.meshopt_encodeFilterOct,h,b,m,g,16)},encodeFilterQuat:function(h,b,m,g){return s(m==8),s(g>=4&&g<=16),f(n.exports.meshopt_encodeFilterQuat,h,b,m,g,16)},encodeFilterExp:function(h,b,m,g,p){s(m>0&&m%4==0),s(g>=1&&g<=24);var x={Separate:0,SharedVector:1,SharedComponent:2,Clamped:3};return s(!p||p in x),f(n.exports.meshopt_encodeFilterExp,h,b,m,g,m,p?x[p]:1)},encodeFilterColor:function(h,b,m,g){return s(m==4||m==8),s(g>=2&&g<=16),f(n.exports.meshopt_encodeFilterColor,h,b,m,g,16)}}}()});var BW;var pR=mt(()=>{BW=function(){var e="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq:VZkdbk:XYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbh5dnawTmbaxa8Acd4fRbbh5kcbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q:G:cjbfcj:G:cjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bwar9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfcbaicdfa8J9c8N1:NfghRbbag9cjjjjjw:dg8J9qE86bbarcVfcbaha8J9c8M1:NfghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fcbaha8J9c8N1:NfgiRbbag9cjjjjjw:dg8J9qE86bbarc96fcbaia8J9c8M1:NfgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbw83bwarai8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbaocl4h8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E94aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:ysezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8Aav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk:4ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxalarcefciGcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGgkfcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkalarcufciGcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkalakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K:G:cjbgeabcifc98GfgbBd:K:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk83dbcj:Gdk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:K:Gdkl8W:qbb",t="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:W9Dklbzik94evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaeai86b:q:W:cjbaecitab8Piw83i:q:G:cjbaecefgecjd9hmbkk:JBl8Aud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaialfgxar9RhodnadTgmmbavaoad;8qbbkaicefhPcj;abad9Uc;WFbGcjdadca0EhsdndndnadTmbaoadfhzcbhHinaeaH9nmdaxaP9RaD6miabaHad2fhOaPaDfhAasaeaH9RaHasfae6EgCcsfgocl4cifcd4hXavcj;cbfaoc9WGgQcetfhLavcj;cbfaQci2fhKavcj;cbfaQfhYcbh8Aaoc;ab6hEincbh3dnawTmbaPa8Acd4fRbbh3kcbh5avcj;cbfh8Eindndndndna3a5cet4ciGgoc9:fPdebdkaxaA9RaQ6mwdnaQTmbavcj;cbfa5aQ2faAaQ;8qbbkaAaCfhAxdkaQTmeavcj;cbfa5aQ2fcbaQ;8kbxekaxaA9RaX6moaoclVcbawEhraAaXfhocbhidnaEmbaxao9Rc;Gb6mbcbhlina8EalfhidndndndndndnaAalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiczfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaicafaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaoclffaqRb:q:W:cjbfhoxikaic8Wfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaocwffaqRb:q:W:cjbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitpbi:q:G:cjbaiRb:q:W:cjbgipsaoRbegqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqRb:q:W:cjbfhokalc;abfhialcjefaQ0meaihlaxao9Rc;Fb0mbkkdnaiaQ9pmbaici4hlinaxao9RcK6mwa8EaifhqdndndndndndnaAaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaoclffagRb:q:W:cjbfhoxikaqaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaocwffagRb:q:W:cjbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpkbbahaocdffagRb:q:W:cjbfhokalcdfhlaiczfgiaQ6mbkkaohAaoTmoka8EaQfh8Ea5cefg5cl9hmbkdndndndnawTmbaza8Acd4fRbbglciGPlbedwbkaQTmdavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep9Ta8Fpxeeeeeeeeeeeeeeeegap9op9Hp9rg8Fa8Jp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ugap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp9Ugap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp9Ugap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9AbbbaladfhlaoczfgoaQ6mbxikkaQTmeavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep:nea8Fpxebebebebebebebebgap9op:bep9rg8Fa8Jp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oegap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp:oegap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp:oegap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9AbbbaladfhlaoczfgoaQ6mbxdkkaQTmbcbhocbalcl4gl9Rc8FGhiavcjdfa8Afhrava8Afpbdbhainaravcj;cbfaofpblbg8JaYaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaLaofpblbg8MaKaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Faap9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8LaypmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9AbbbaradfhraoczfgoaQ6mbkka8Aclfg8Aad6mbkdnaCad2goTmbaOavcjdfao;8qbbkdnammbavavcjdfaCcufad2fad;8qbbkaCaHfhHc9:hoaAhPaAmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdasaeao9Raoasfae6Eaofgoae6mbkaial9RhPkcbc99axaP9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbkNsezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk;Toio97eue97aec98Ghedndnadcl9hmbaeTmecbhdinababpbbbgicKp:RecKp:Sep;6eglaicwp:RecKp:Sep;6ealp;Geaiczp:RecKp:Sep;6egvp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgwp9op9rp;Keglpxbb;:9cbb;:9cbb;:9cbb;:9calalp;Meaoaop;Meavaravawp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFbbbFbbbFbbbFbbbp9oaipxbbbFbbbFbbbFbbbFp9op9qalavp;Mearp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaoavp;Mearp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgDaDpbbbgipxbbbbbbFFbbbbbbFFgwp9oabpbbbgoaipmbediwDqkzHOAKY8AEgvczp:Reczp:Sep;6eglaoaipmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eavczp:Sep;6egvp;Gealp;Gep;Kep;Legipxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgqp9op9rp;Keglpxb;:FSb;:FSb;:FSb;:FSalalp;Meaiaip;Meavaravaqp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbp9oaiavp;Mearp;Keczp:Rep9qgialavp;Mearp;KepxFFbbFFbbFFbbFFbbp9oglpmwDKYqk8AExm35Ps8E8Fp9qpkbbabaoawp9oaialpmbezHdiOAlvCXorQLp9qpkbbabcafhbadclfgdae6mbkkk;2ileue97euo97dnaec98GgiTmbcbheinabcKfpx:ji:1S:ji:1S:ji:1S:ji:1SabpbbbglabczfgvpbbbgopmlvorxmPsCXQL358E8Fgrczp:Segwpxibbbibbbibbbibbbp9qp;6egDp;NegqaDaDp;MegDaDp;KealaopmbediwDqkzHOAKY8AEgDczp:Reczp:Sep;6eglalp;MeaDczp:Sep;6egoaop;Mearczp:Reczp:Sep;6egrarp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gDp;KepxFFbbFFbbFFbbFFbbgkp9oaqaop;MeaDp;Keczp:Rep9qgoaqalp;MeaDp;Keakp9oaqarp;MeaDp;Keczp:Rep9qgDpmwDKYqk8AExm35Ps8E8Fglp5eawclp:RegqpEi:T:j83ibavalp5baqpEd:T:j83ibabcwfaoaDpmbezHdiOAlvCXorQLgDp5eaqpEe:T:j83ibabaDp5baqpEb:T:j83ibabcafhbaeclfgeai6mbkkkuee97dnadcd4ae2c98GgeTmbcbhdinababpbbbgicwp:Recwp:Sep;6eaicep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbabczfhbadclfgdae6mbkkk:Sodw97euaec98Ghedndnadcl9hmbaeTmecbhdinabpxbbuJbbuJbbuJbbuJabpbbbgicKp:TeglaicYp:Tep9qgvcdp:Teavp9qgvclp:Teavp9qgop;6ep;Negvaicwp:RecKp:SegraipxFbbbFbbbFbbbFbbbgwp9ogDp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oavaDarp:Xeaiczp:RecKp:Segip:Uep;6ep;Meaqp;Keawp9op9qavaDaraip:Uep:Xep;6ep;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qavaoalcep:Rep9oalpxebbbebbbebbbebbbp9op9qp;6ep;Meaqp;KecKp:Rep9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgkpxbFu9hbFu9hbFu9hbFu9habpbbbglakpbbbgrpmlvorxmPsCXQL358E8Fgvczp:TegqavcHp:Tep9qgicdp:Teaip9qgiclp:Teaip9qgicwp:Teaip9qgop;6ep;NegialarpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbglp9ograDczp:Segwp:Ueavczp:Reczp:SegDp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gvp;Kealp9oaiarawaDp:Uep:Xep;6ep;Meavp;Keczp:Rep9qgwaiaoaqcep:Rep9oaqpxebbbebbbebbbebbbp9op9qp;6ep;Meavp;Keczp:ReaiaDarp:Uep;6ep;Meavp;Kealp9op9qgipmwDKYqk8AExm35Ps8E8FpkbbabawaipmbezHdiOAlvCXorQLpkbbabcafhbadclfgdae6mbkkk9teiucbcbydj:G:cjbgeabcifc98GfgbBdj:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkxebcj:Gdklz:zbb",n=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),i=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var r=WebAssembly.validate(n)?o(t):o(e),s,a=WebAssembly.instantiate(r,{}).then(function(p){s=p.instance,s.exports.__wasm_call_ctors()});function o(p){var x=new Uint8Array(p.length);for(var _=0;_<p.length;++_){var y=p.charCodeAt(_);x[_]=y>96?y-97:y>64?y-39:y+4}var v=0;for(var _=0;_<p.length;++_)x[v++]=x[_]<60?i[x[_]]:(x[_]-60)*64+x[++_];return x.buffer.slice(0,v)}function c(p,x,_,y,v,T,A){var E=p.exports.sbrk,w=y+3&-4,P=E(w*v),S=E(T.length),I=new Uint8Array(p.exports.memory.buffer);I.set(T,S);var U=x(P,y,v,S,T.length);if(U==0&&A)A(P,w,v);if(_.set(I.subarray(P,P+y*v)),E(P-E(0)),U!=0)throw Error("Malformed buffer data: "+U)}var l={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp",COLOR:"meshopt_decodeFilterColor"},u={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},d=[],f=0;function h(p){var x={object:new Worker(p),pending:0,requests:{}};return x.object.onmessage=function(_){var y=_.data;x.pending-=y.count,x.requests[y.id][y.action](y.value),delete x.requests[y.id]},x}function b(p){var x="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(r)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+g.name+";"+c.toString()+g.toString(),_=new Blob([x],{type:"text/javascript"}),y=URL.createObjectURL(_);for(var v=d.length;v<p;++v)d[v]=h(y);for(var v=p;v<d.length;++v)d[v].object.postMessage({});d.length=p,URL.revokeObjectURL(y)}function m(p,x,_,y,v){var T=d[0];for(var A=1;A<d.length;++A)if(d[A].pending<T.pending)T=d[A];return new Promise(function(E,w){var P=new Uint8Array(_),S=++f;T.pending+=p,T.requests[S]={resolve:E,reject:w},T.object.postMessage({id:S,count:p,size:x,source:P,mode:y,filter:v},[P.buffer])})}function g(p){var x=p.data;self.ready.then(function(_){if(!x.id)return self.close();try{var y=new Uint8Array(x.count*x.size);c(_,_.exports[x.mode],y,x.count,x.size,x.source,_.exports[x.filter]),self.postMessage({id:x.id,count:x.count,action:"resolve",value:y},[y.buffer])}catch(v){self.postMessage({id:x.id,count:x.count,action:"reject",value:v})}})}return{ready:a,supported:!0,useWorkers:function(p){b(p)},decodeVertexBuffer:function(p,x,_,y,v){c(s,s.exports.meshopt_decodeVertexBuffer,p,x,_,y,s.exports[l[v]])},decodeIndexBuffer:function(p,x,_,y){c(s,s.exports.meshopt_decodeIndexBuffer,p,x,_,y)},decodeIndexSequence:function(p,x,_,y){c(s,s.exports.meshopt_decodeIndexSequence,p,x,_,y)},decodeGltfBuffer:function(p,x,_,y,v,T){c(s,s.exports[u[v]],p,x,_,y,s.exports[l[T]])},decodeGltfBufferAsync:function(p,x,_,y,v){if(d.length>0)return m(p,x,_,u[y],l[v]);return a.then(function(){var T=new Uint8Array(p*x);return c(s,s.exports[u[y]],T,p,x,_,s.exports[l[v]]),T})}}}()});var VW;var mR=mt(()=>{VW=function(){var e="b9H79Tebbbe:6eO9Geueu9Geub9Gbb9Gsuuuuuuuuuuuu99uueu9Gvuuuuub9Gruuuuuuub9Gouuuuuue999Gvuuuuueu9Gzuuuuuuuuuuu99uuuub9Gquuuuuuu99uueu9GPuuuuuuuuuuu99uueu9Gquuuuuuuu99ueu9Gruuuuuu99eu9Gwuuuuuu99ueu9Giuuue999Gluuuueu9Gluuuub9GiuuueuiLQdilvorlwDiqkxmPszbHHbelve9Weiiviebeoweuecj:Gdkr:Bdxo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bbz9TW79O9V9Wt9F79P9T9W29P9M95bw8E9TW79O9V9Wt9F79P9T9W29P9M959x9Pt9OcttV9P9I91tW7bD8A9TW79O9V9Wt9F79P9T9W29P9M959x9Pt9O9v9W9K9HtWbqQ9TW79O9V9Wt9F79P9T9W29P9M959t29V9W9W95bkX9TW79O9V9Wt9F79P9T9W29P9M959qV919UWbxQ9TW79O9V9Wt9F79P9T9W29P9M959q9V9P9Ut7bmX9TW79O9V9Wt9F79P9T9W29P9M959t9J9H2WbPa9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94SWt9J9O9sW9T9H9Wbs59TW79O9V9Wt9F9NW9UWV9HtW9q9V79Pt9P9V9U9sW9T9H9Wbzl79IV9RbHDwebcekdCXq;y;WeQdbk;r:herYue99iuY99Xue9:D998Jjjjjbcj;sb9Rgs8Kjjjjbcbhzasc:Cefcbc;Kbz:tjjjb8AdnabaeSmbabaeadcdtzMjjjb8AkdnamcdGTmbalcrfci4cbyd1:H:cjbHjjjjbbhHasc:Cefasyd;8egecdtfaHBdbasaecefBd;8ecbhlcbhednadTmbabheadhOinaHaeydbci4fcb86bbaeclfheaOcufgOmbkcbhlabheadhOinaHaeydbgAci4fgCaCRbbgCceaAcrGgAtV86bbaCcu7aA4ceGalfhlaeclfheaOcufgOmbkcualcdtalcFFFFi0Ehekaecbyd1:H:cjbHjjjjbbhzasc:Cefasyd;8egecdtfazBdbasaecefBd;8ealcd4alfhOcehHinaHgecethHaeaO6mbkcbhXcuaecdtgOaecFFFFi0Ecbyd1:H:cjbHjjjjbbhHasc:Cefasyd;8egAcdtfaHBdbasaAcefBd;8eaHcFeaOz:tjjjbhQdnadTmbaecufhLcbhKindndnaQabaKcdtfgYydbgAc:v;t;h;Ev2aLGgOcdtfgCydbgHcuSmbceheinazaHcdtfydbaASmdaOaefhHaecefheaQaHaLGgOcdtfgCydbgHcu9hmbkkazaXcdtfaABdbaCaXBdbaXhHaXcefhXkaYaHBdbaKcefgKad9hmbkkaQcbyd:m:H:cjbH:bjjjbbasasyd;8ecufBd;8ekcbh8AcualcefgecdtaecFFFFi0Ecbyd1:H:cjbHjjjjbbhLasc:Cefasyd;8egecdtfaLBdbasaLBdNeasaecefBd;8ecuadcitadcFFFFe0Ecbyd1:H:cjbHjjjjbbhEasc:Cefasyd;8egecdtfaEBdbasaEBd:yeasaecefBd;8eascNefabadalcbz:cjjjbcualcdtgealcFFFFi0Eg3cbyd1:H:cjbHjjjjbbhOasc:Cefasyd;8egHcdtfaOBdbasaHcefBd;8ea3cbyd1:H:cjbHjjjjbbhQasc:Cefasyd;8egHcdtfaQBdbasaHcefBd;8eaOaQaialavazasc:Cefz:djjjbalcbyd1:H:cjbHjjjjbbhYasc:Cefasyd;8egHcdtfaYBdbasaHcefBd;8ea3cbyd1:H:cjbHjjjjbbhHasc:Cefasyd;8egAcdtfaHBdbasaAcefBd;8ea3cbyd1:H:cjbHjjjjbbhAasc:Cefasyd;8egCcdtfaABdbasaCcefBd;8eaHcFeaez:tjjjbh5aAcFeaez:tjjjbh8EdnalTmbindnaLa8AgAcefg8AcdtfydbgCaLaAcdtgefydbgHSmbaCaH9Rh8FaEaHcitfhaa8Eaefhha5aefhKcbhCindndnaaaCcitfydbgXaA9hmbaKaABdbahaABdbxekdnaLaXcdtggfgeclfydbgHaeydbgeSmbaHae9RhHaEaecitfheinaeydbaASmdaecwfheaHcufgHmbkka8EagfgeaAaXaeydbcuSEBdbaKaXaAaKydbcuSEBdbkaCcefgCa8F9hmbkka8Aal9hmbkaOhHaQhAa5hXa8EhCcbheindndnaeaHydbgK9hmbdnaeaAydbgK9hmbaXydbhKdnaCydbg8Fcu9hmbaKcu9hmbaYaefcb86bbxikdna8FcuSmbaKcuSmbaea8FSmbaOa8FcdtfydbaOaKcdtfydb9hmbaYaefcd86bbxikaYaefhadnaea8FSmbaeaKSmbaace86bbxikaacl86bbxdkdnaeaQaKcdtg8Ffydb9hmbdnaCydbgacuSmbaeaaSmbaXydbggcuSmbaeagSmba8Ea8FfydbghcuSmbahaKSmba5a8Ffydbg8FcuSmba8FaKSmbdnaOaacdtfydbgKaOa8Fcdtfydb9hmbaKaOagcdtfydbg8FSmba8FaOahcdtfydb9hmbaYaefcd86bbxlkaYaefcl86bbxikaYaefcl86bbxdkaYaefcl86bbxekaYaefaYaKfRbb86bbkaHclfhHaAclfhAaXclfhXaCclfhCalaecefge9hmbkdnamcaGTmbcbh8JindndnaYa8Jfg8KRbbg8Lc9:fPibebekdndndnaOa8Jcdtfydbgea8J9hmbdnaqmbcbh8FxdkdnazTmbcbh8Fa8JheinaqazaecdtgefydbfRbbce4a8FVceGh8FaQaefydbgea8J9hmbxikkcbh8Fa8JheinaqaefRbbce4a8FVceGh8FaQaecdtfydbgea8J9hmbxdkkaYaefRbbhexeka8JheindnaLaecdtg8AfgeclfydbgHaeydbgeSmbaHae9RhgaEaecitfhhaOa8AfhacbhKinahaKcitfydbgXhednindnaLaecdtgCfgeclfydbgHaeydbgeSmbaHae9RhHaEaecitfheaaydbhAdninaOaeydbcdtfydbaASmeaecwfheaHcufgHTmdxbkkcbhexdkaQaCfydbgeaX9hmbkceheka8FaeVh8FaKcefgKag9hmbkkaQa8Afydbgea8J9hmbka8Lcia8FceGEheka8Kae86bbka8Jcefg8Jal9hmbkkdnaqTmbdndnazTmbazheaOhHalhAindnaqaeydbfRbbceGTmbaYaHydbfcl86bbkaeclfheaHclfhHaAcufgAmbxdkkaqheaOhHalhAindnaeRbbceGTmbaYaHydbfcl86bbkaecefheaHclfhHaAcufgAmbkkaOhealhAaYhHindnaYaeydbfRbbcl9hmbaHcl86bbkaeclfheaHcefhHaAcufgAmbkkamceGTmbaYhealhHindnaeRbbce9hmbaecl86bbkaecefheaHcufgHmbkkcbh8Mcualcx2alc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbh8Nasc:Cefasyd;8egecdtfa8NBdbasaecefBd;8eascbBd:qeas9cb83i1ea8Naialavazasc1efz:ejjjbhydndnaDmbcbh8PcbhCxekcbhCawhecbhHindnaeIdbJbbbb9ETmbasaCcdtfaHBdbaCcefhCkaeclfheaDaHcefgH9hmbkcuaCal2gecdtaecFFFFi0Ecbyd1:H:cjbHjjjjbbh8Pasc:Cefasyd;8egecdtfa8PBdbasaecefBd;8ealTmbdnaCmbcbhCxekarcd4hgdnazTmbaCcdthhcbh8Fa8Phainaoaza8Fcdtfydbag2cdtfhKasheaahHaChAinaHaKaeydbcdtgXfIdbawaXfIdbNUdbaeclfheaHclfhHaAcufgAmbkaaahfhaa8Fcefg8Fal9hmbxdkkaCcdthhcbh8Fa8Phainaoa8Fag2cdtfhKasheaahHaChAinaHaKaeydbcdtgXfIdbawaXfIdbNUdbaeclfheaHclfhHaAcufgAmbkaaahfhaa8Fcefg8Fal9hmbkkcualc8S2gHalc;D;O;f8U0EgXcbyd1:H:cjbHjjjjbbheasc:Cefasyd;8egAcdtfaeBdbasaAcefBd;8eaecbaHz:tjjjbhIcbh8RcbhgdnaCTmbcbh8MaXcbyd1:H:cjbHjjjjbbhgasc:Cefasyd;8egecdtfagBdbasaecefBd;8eagcbaHz:tjjjb8AcuaCal2gecltgHaecFFFFb0Ecbyd1:H:cjbHjjjjbbh8Rasc:Cefasyd;8egecdtfa8RBdbasaecefBd;8ea8RcbaHz:tjjjb8AamcjjjjdGTmbcualcltgealcFFFFb0Ecbyd1:H:cjbHjjjjbbh8Masc:Cefasyd;8egHcdtfa8MBdbasaHcefBd;8ea8Mcbaez:tjjjb8AkdnadTmbcbhKabhHina8NaHclfydbg8Fcx2fgeIdba8NaHydbgacx2fgAIdbg8S:tgRa8NaHcwfydbghcx2fgXIdlaAIdlg8U:tg8VNaeIdla8U:tg8WaXIdba8S:tg8XN:tg8Ya8YNa8WaXIdwaAIdwg8Z:tg80NaeIdwa8Z:tg8Wa8VN:tg81a81Na8Wa8XNaRa80N:tg80a80NMMg8V:rhBa8Yh8Xa80h8Wa81hRdna8VJbbbb9EgATmba8YaB:vh8Xa80aB:vh8Wa81aB:vhRkaIaOaacdtfydbgXc8S2fgeaRaB:rg8VaRNNg83aeIdbMUdbaea8Wa8Va8WNgUNg85aeIdlMUdlaea8Xa8Va8XNg86Ng87aeIdwMUdwaeaRaUNgUaeIdxMUdxaea86aRNg88aeIdzMUdzaea8Wa86Ng89aeIdCMUdCaeaRa8Va8Xa8ZNaRa8SNa8Ua8WNMM:mg8:Ng86NgRaeIdKMUdKaea8Wa86Ng8WaeId3MUd3aea8Xa86Ng8XaeIdaMUdaaea86a8:Ng86aeId8KMUd8Kaea8VaeIdyMUdyaIaOa8Fcdtfydbg8Fc8S2fgea83aeIdbMUdbaea85aeIdlMUdlaea87aeIdwMUdwaeaUaeIdxMUdxaea88aeIdzMUdzaea89aeIdCMUdCaeaRaeIdKMUdKaea8WaeId3MUd3aea8XaeIdaMUdaaea86aeId8KMUd8Kaea8VaeIdyMUdyaIaOahcdtfydbgac8S2fgea83aeIdbMUdbaea85aeIdlMUdlaea87aeIdwMUdwaeaUaeIdxMUdxaea88aeIdzMUdzaea89aeIdCMUdCaeaRaeIdKMUdKaea8WaeId3MUd3aea8XaeIdaMUdaaea86aeId8KMUd8Kaea8VaeIdyMUdydna8MTmbdnaATmba8YaB:vh8Ya80aB:vh80a81aB:vh81ka8MaXcltfgeaBJbbbZNgRa80Ng8VaeIdlMUdlaeaRa8YNg8WaeIdwMUdwaeaRa81Ng8XaeIdbMUdbaeaRa8S:ma81Na8Ua80N:ta8Za8YN:tNgRaeIdxMUdxa8Ma8Fcltfgea8VaeIdlMUdlaea8WaeIdwMUdwaea8XaeIdbMUdbaeaRaeIdxMUdxa8Maacltfgea8VaeIdlMUdlaea8WaeIdwMUdwaea8XaeIdbMUdbaeaRaeIdxMUdxkaHcxfhHaKcifgKad6mbkkdnalTmbJq;x8J88J;n;m;m89J:v:;;w8ZamczGEamc;abGEh80cbhHaOhXazhKaIhea8NhAindnaHaXydb9hmbaHh8FdnazTmbaKydbh8Fka80hRdnaqTmbJbbjZa80aqa8FfRbbclGEhRkaecxfg8Fa8FIdbJbbbbMUdbaeczfg8Fa8FIdbJbbbbMUdbaecCfg8Fa8FIdbJbbbbMUdbaeaRaecyfg8FIdbg8YNgRaeIdbMUdbaeclfgaaRaaIdbMUdbaecwfgaaRaaIdbMUdbaecKfgaaaIdbaAIdbg8WaRN:tUdbaAcwfIdbh8Vaec3fgaaaIdbaRaAclfIdbg8XN:tUdbaecafgaaaIdbaRa8VN:tUdbaec8KfgaIdbh81a8Fa8YaRMUdbaaa81aRa8Va8VNa8Wa8WNa8Xa8XNMMNMUdbkaXclfhXaKclfhKaec8SfheaAcxfhAalaHcefgH9hmbkkdnadTmbcbh8Aabhainaba8Acdtfh8FcbhHinaYa8FaHc:G:G:cjbfydbcdtfydbgAfRbbhedndnaYaaaHfydbgXfRbbgKc99fcFeGcpe0mbaec99fcFeGc;:e6mekdnaKcufcFeGce0mba5aXcdtfydbaA9hmekdnaecufcFeGce0mba8EaAcdtfydbaX9hmekJbbacJbbacJbbbZaecFeGceSEaKcFeGceSEhUdna8Na8FaHc:K:G:cjbfydbcdtfydbcx2fgeIdwa8NaXcx2fgKIdwg86:tg8Sa8NaAcx2fghIdwa86:tg8Xa8XNahIdbaKIdbg8U:tg80a80NahIdlaKIdlg8Z:tg8Va8VNMMg81Na8Xa8Sa8XNaeIdba8U:tg83a80Na8VaeIdla8Z:tg85NMMg8WN:tg8Ya8YNa83a81Na80a8WN:tgRaRNa85a81Na8Va8WN:tg8Wa8WNMMgBJbbbb9ETmba8YaB:rgB:vh8Ya8WaB:vh8WaRaB:vhRkaUa81:rNgBa8Ya86NaRa8UNa8Za8WNMM:mg81Ng87a81Nh88a80a85Na8Va83N:tg81a81Na8Va8SNa8Xa85N:tg8Va8VNa8Xa83Na80a8SN:tg8Xa8XNMMg83:rh80a8Ya87Nh85a8Wa87Nh89aRa87Nh87a8WaBa8YNg8SNh8:a8SaRNhZaRaBa8WNgnNhca8Ya8SNh8Ya8WanNh8WaRaBaRNNh8Sdna83Jbbbb9ETmba81a80:vh81a8Xa80:vh8Xa8Va80:vh8VkaIaOaXcdtfydbc8S2fgeaeIdba8Sa8VaUa80:rNgRa8VNNMg80MUdbaea8Wa8XaRa8XNg8SNMg83aeIdlMUdlaea8Ya81aRa81Ng8WNMg8YaeIdwMUdwaeaca8Va8SNMg8SaeIdxMUdxaeaZa8Wa8VNMgUaeIdzMUdzaea8:a8Xa8WNMg8WaeIdCMUdCaea87a8VaRa81a86Na8Va8UNa8Za8XNMMg86:mNgRNMg8VaeIdKMUdKaea89a8XaRNMg8XaeId3MUd3aea85a81aRNMg81aeIdaMUdaaea88a86aRN:tgRaeId8KMUd8KaeaBaeIdyMUdyaIaOaAcdtfydbc8S2fgea80aeIdbMUdbaea83aeIdlMUdlaea8YaeIdwMUdwaea8SaeIdxMUdxaeaUaeIdzMUdzaea8WaeIdCMUdCaea8VaeIdKMUdKaea8XaeId3MUd3aea81aeIdaMUdaaeaRaeId8KMUd8KaeaBaeIdyMUdykaHclfgHcx9hmbkaacxfhaa8Acifg8Aad6mbkaCTmbcbhainJbbbbh80a8Nabaacdtfgeclfydbg8Fcx2fgHIdwa8Naeydbghcx2fgAIdwg8Z:tg8Va8VNaHIdbaAIdbg83:tg8Wa8WNaHIdlaAIdlg85:tg8Xa8XNMMg8Sa8Naecwfydbg8Acx2fgeIdwa8Z:tg8YNa8Va8YNa8WaeIdba83:tg81Na8XaeIdla85:tgBNMMgRa8VN:tJbbbbJbbjZa8Sa8Ya8YNa81a81NaBaBNMMg8UNaRaRN:tg86:va86Jbbbb9BEg86Nh88a8Ua8VNaRa8YN:ta86Nh89a8SaBNaRa8XN:ta86Nh8:a8Ua8XNaRaBN:ta86NhZa8Sa81NaRa8WN:ta86Nhna8Ua8WNaRa81N:ta86Nhca8WaBNa8Xa81N:tgRaRNa8Xa8YNa8VaBN:tgRaRNa8Va81Na8Wa8YN:tgRaRNMM:rJbbbZNhRa8PahaC2g8JcdtfhHa8Pa8AaC2gDcdtfhAa8Pa8FaC2g8KcdtfhXa8Z:mh9ca85:mhJa83:mh9eascjdfheaChKJbbbbhBJbbbbh86Jbbbbh8SJbbbbh8UJbbbbh8ZJbbbbh83Jbbbbh85Jbbbbh87JbbbbhUinaecwfaRa89aXIdbaHIdbg8Y:tg8XNa88aAIdba8Y:tg81NMg8VNUdbaeclfaRaZa8XNa8:a81NMg8WNUdbaeaRaca8XNana81NMg8XNUdbaecxfaRa9ca8VNaJa8WNa8Ya9ea8XNMMMg8YNUdbaRa8Va8WNNa8ZMh8ZaRa8Va8XNNa8UMh8UaRa8Wa8XNNa8SMh8SaRa8Ya8YNNaUMhUaRa8Va8YNNa87Mh87aRa8Wa8YNNa85Mh85aRa8Xa8YNNa83Mh83aRa8Va8VNNa86Mh86aRa8Wa8WNNaBMhBaRa8Xa8XNNa80Mh80aHclfhHaXclfhXaAclfhAaeczfheaKcufgKmbkagahc8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdyaga8Fc8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdyaga8Ac8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdya8Ra8Jcltfh8FcbhHaChXina8FaHfgeascjdfaHfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbka8Ra8Kcltfh8FcbhHaChXina8FaHfgeascjdfaHfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbka8RaDcltfh8FcbhHaChXina8FaHfgeascjdfaHfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbkaacifgaad6mbkkcbhAdndnamcwGgTmbJbbbbh8ScbhScbh9hcbh9ixekcbhSa3cbyd1:H:cjbHjjjjbbh9iasc:Cefasyd;8egecdtfa9iBdbasaecefBd;8ecua9ialabadaOz:fjjjbgXcltaXcjjjjiGEcbyd1:H:cjbHjjjjbbh9hasc:Cefasyd;8egecdtfa9hBdbasaecefBd;8ea9haXa9ia8Nalz:gjjjbJFFuuh8SaXTmba9hheaXhHinaeIdbgRa8Sa8SaR9EEh8SaeclfheaHcufgHmbkaXhSkdnalTmbaLclfheaLydbhXaYhHalhKcbhAincbaeydbg8FaX9RaHRbbcpeGEaAfhAaHcefhHaeclfhea8FhXaKcufgKmbkaAce4hAkcuadaA9Rcifg6cx2a6c;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbh9kasc:Cefasyd;8egecdtfa9kBdbasaecefBd;8ecua6cdta6cFFFFi0Ecbyd1:H:cjbHjjjjbbh0asc:Cefasyd;8egecdtfa0BdbasaecefBd;8ea3cbyd1:H:cjbHjjjjbbh9masc:Cefasyd;8egecdtfa9mBdbasaecefBd;8ealcbyd1:H:cjbHjjjjbbh9nasc:Cefasyd;8egecdtfa9nBdbasaecefBd;8eaxaxNayJbbjZamclGEgZaZN:vh87JbbbbhUdnadak9nmbdna6ci6mbaCclth9oa9kcwfh9pJbbbbh85JbbbbhUinascNefabadalaOz:cjjjbabh8Acbh9qcbh9rinaba9rcdtfhDcbheindnaOa8AaefydbgAcdtghfydbgXaOaDaec:W:G:cjbfydbcdtfydbgHcdtg8JfydbgKSmbaYaHfRbbgacv2aYaAfRbbg8FfRb;a:G:cjbg8La8Fcv2aafg8KRb;a:G:cjbg3VcFeGTmbdnaKaX9nmba8KRb;G:G:cjbcFeGmekdna8FcufcFeGce0mbaaTmba5ahfydbaH9hmekdna8FTmbaacufcFeGce0mba8Ea8JfydbaA9hmeka9ka9qcx2fgXaHaAa3cFeGgKEBdlaXaAaHaKEBdbaXaKa8LGcb9hBdwa9qcefh9qkaeclfgecx9hmbkdna9rcifg9rad9pmba8Acxfh8Aa9qcifa69nmekka9qTmdcbh8KinaIaOa9ka8Kcx2fghydbgKcdtgXfydbg8Ac8S2fgeIdwa8Nahydlg8Fcx2fgHIdwg8WNaeIdzaHIdbg8XNaeIdaMgRaRMMa8WNaeIdlaHIdlg8YNaeIdCa8WNaeId3MgRaRMMa8YNaeIdba8XNaeIdxa8YNaeIdKMgRaRMMa8XNaeId8KMMM:lhRJbbbbJbbjZaeIdyg8V:va8VJbbbb9BEh8VdndnahydwgDmbJFFuuh86xekJbbbbJbbjZaIaOa8Fcdtfydbc8S2fgeIdyg81:va81Jbbbb9BEaeIdwa8NaKcx2fgHIdwg81NaeIdzaHIdbg80NaeIdaMgBaBMMa81NaeIdlaHIdlgBNaeIdCa81NaeId3Mg81a81MMaBNaeIdba80NaeIdxaBNaeIdKMg81a81MMa80NaeId8KMMM:lNh86ka8VaRNhBdnaCTmbagaKc8S2fgAIdwa8WNaAIdza8XNaAIdaMgRaRMMa8WNaAIdla8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8Pa8FaC2gacdtfhHa8RaKaC2g8JcltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbkdndnaDmbJbbbbh8Vxekaga8Fc8S2fgAIdwa8NaKcx2fgeIdwg8XNaAIdzaeIdbg8YNaAIdaMg8Va8VMMa8XNaAIdlaeIdlg81NaAIdCa8XNaAId3Mg8Va8VMMa81NaAIdba8YNaAIdxa81NaAIdKMg8Va8VMMa8YNaAId8KMMMh8Va8Pa8JcdtfhHa8RaacltfheaAIdyh80aChAinaHIdbg8Wa8Wa80NaecxfIdba8XaecwfIdbNa8YaeIdbNa81aeclfIdbNMMMg8Wa8WM:tNa8VMh8VaHclfhHaeczfheaAcufgAmbka8V:lh8VkaBaR:lMhBa86a8VMh86dndndnaYaKfRbbc9:fPddbekaQaXfydbgXaKSmbaOa8Fcdtfydbh8Jindndna5aXcdtgafydbgecuSmbaOaecdtfydba8JSmekdna8EaafydbgecuSmbaOaecdtfydba8JSmeka8FhekagaXc8S2fgAIdwa8Naecx2fgHIdwg8WNaAIdzaHIdbg8XNaAIdaMgRaRMMa8WNaAIdlaHIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaeaC2cdtfhHa8RaXaC2cltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbkaBaR:lMhBaQaafydbgXaK9hmbkkaYa8FfRbbci9hmeaDTmeaQa8FcdtfydbgXa8FSmeindndna5aXcdtgafydbgecuSmbaOaecdtfydba8ASmekdna8EaafydbgecuSmbaOaecdtfydba8ASmekaKhekagaXc8S2fgAIdwa8Naecx2fgHIdwg8WNaAIdzaHIdbg8XNaAIdaMgRaRMMa8WNaAIdlaHIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaeaC2cdtfhHa8RaXaC2cltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbka86aR:lMh86aQaafydbgXa8F9hmbxdkkdna8Ea5a5aXfydba8FSEaQaXfydbgacdtfydbgXcu9hmbaQa8FcdtfydbhXkagaac8S2fgAIdwa8NaXcx2fgeIdwg8WNaAIdzaeIdbg8XNaAIdaMgRaRMMa8WNaAIdlaeIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaXaC2g8AcdtfhHa8RaaaC2g8JcltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbkdndnaDmbJbbbbh8VxekagaXc8S2fgAIdwa8Naacx2fgeIdwg8XNaAIdzaeIdbg8YNaAIdaMg8Va8VMMa8XNaAIdlaeIdlg81NaAIdCa8XNaAId3Mg8Va8VMMa81NaAIdba8YNaAIdxa81NaAIdKMg8Va8VMMa8YNaAId8KMMMh8Va8Pa8JcdtfhHa8Ra8AcltfheaAIdyh80aChAinaHIdbg8Wa8Wa80NaecxfIdba8XaecwfIdbNa8YaeIdbNa81aeclfIdbNMMMg8Wa8WM:tNa8VMh8VaHclfhHaeczfheaAcufgAmbka8V:lh8VkaBaR:lMhBa86a8VMh86kaha86aBa86aB9DgeEUdwahaKa8FaeaDcb9hGgeEBdlaha8FaKaeEBdba8Kcefg8Ka9q9hmbkascjdfcbcj;qbz:tjjjb8Aa9phea9qhHinascjdfaeydbcA4cF8FGgAcFAaAcFA6EcdtfgAaAydbcefBdbaecxfheaHcufgHmbkcbhecbhHinascjdfaefgAydbhXaAaHBdbaXaHfhHaeclfgecj;qb9hmbkcbhea9phHinascjdfaHydbcA4cF8FGgAcFAaAcFA6EcdtfgAaAydbgAcefBdba0aAcdtfaeBdbaHcxfhHa9qaecefge9hmbkadak9RgAci9Uh9sdnalTmbcbhea9mhHinaHaeBdbaHclfhHalaecefge9hmbkkcbh9ta9ncbalz:tjjjbh3aAcO9Uh9ua9sce4h9rcbh8Lcbh8Kdnina9ka0a8Kcdtfydbcx2fg8JIdwgRa879Emea8La9s9pmeJFFuuh8Vdna9ra9q9pmba9ka0a9rcdtfydbcx2fIdwJbb;aZNh8VkdnaRa8V9ETmbaRaU9ETmba8La9u0mdkdna3aOa8JydlgDcdtg9vfg8AydbgAfg9wRbba3aOa8Jydbghcdtg9xfydbgefg9yRbbVmbaYahfRbbh9zdndnaLaecdtfgHclfydbgXaHydbgHSmbaXaH9RhXa8NaAcx2fh8Fa8Naecx2fhaaEaHcitfheindna9maeydbcdtfydbgHaASmba9maeclfydbcdtfydbgKaASmbaHaKSmba8NaKcx2fgKIdba8NaHcx2fgHIdbg8W:tgRaaIdlaHIdlg8X:tg80NaKIdla8X:tg8VaaIdba8W:tgBN:tg8YaRa8FIdla8X:tg86Na8Va8FIdba8W:tg8UN:tg8XNa8VaaIdwaHIdwg81:tg8ZNaKIdwa81:tg8Wa80N:tg80a8Va8FIdwa81:tg83Na8Wa86N:tg8VNa8WaBNaRa8ZN:tg81a8Wa8UNaRa83N:tgRNMMa8Ya8YNa80a80Na81a81NMMa8Xa8XNa8Va8VNaRaRNMMN:rJbbj8:N9FmikaecwfheaXcufgXmbkkdndndndna9zc9:fPdebdkahheina8AydbhAdndna5aecdtgHfydbgecuSmbaOaecdtfydbaASmekdna8EaHfydbgecuSmbaOaecdtfydbaASmekaDheka9maHfaeBdbaQaHfydbgeah9hmbxikkdna8Ea5a5a9xfydbaDSEaQa9xfydbghcdtfydbgecu9hmbaQa9vfydbheka9ma9xfaDBdbaehDka9mahcdtfaDBdbka9yce86bba9wce86bba8JIdwgRaUaUaR9DEhUa9tcefh9tcecda9zceSEa8Lfh8Lxeka9rcefh9rka8Kcefg8Ka9q9hmbkka9tTmddnalTmbcbh8Fcbhhindna9mahcdtgefydbgAahSmbaOaAcdtfydbh8AdnahaOaefydb9hg8JmbaIa8Ac8S2fgeaIahc8S2fgHIdbaeIdbMUdbaeaHIdlaeIdlMUdlaeaHIdwaeIdwMUdwaeaHIdxaeIdxMUdxaeaHIdzaeIdzMUdzaeaHIdCaeIdCMUdCaeaHIdKaeIdKMUdKaeaHId3aeId3MUd3aeaHIdaaeIdaMUdaaeaHId8KaeId8KMUd8KaeaHIdyaeIdyMUdya8MTmba8Ma8Acltfgea8MahcltfgHIdbaeIdbMUdbaeaHIdlaeIdlMUdlaeaHIdwaeIdwMUdwaeaHIdxaeIdxMUdxkaCTmbagaAc8S2fgeagahc8S2gDfgHIdbaeIdbMUdbaeaHIdlaeIdlMUdlaeaHIdwaeIdwMUdwaeaHIdxaeIdxMUdxaeaHIdzaeIdzMUdzaeaHIdCaeIdCMUdCaeaHIdKaeIdKMUdKaeaHId3aeId3MUd3aeaHIdaaeIdaMUdaaeaHId8KaeId8KMUd8KaeaHIdyaeIdyMUdya9oaA2haa8RhHaChXinaHaafgeaHa8FfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbka8JmbJbbbbJbbjZaIaDfgeIdygR:vaRJbbbb9BEaeIdwa8Na8Acx2fgHIdwgRNaeIdzaHIdbg8VNaeIdaMg8Wa8WMMaRNaeIdlaHIdlg8WNaeIdCaRNaeId3MgRaRMMa8WNaeIdba8VNaeIdxa8WNaeIdKMgRaRMMa8VNaeId8KMMM:lNgRa85a85aR9DEh85ka8Fa9ofh8Fahcefghal9hmbkcbhHa5heindnaeydbgAcuSmbdnaHa9maAcdtgXfydbgA9hmbcuhAa5aXfydbgXcuSmba9maXcdtfydbhAkaeaABdbkaeclfhealaHcefgH9hmbkcbhHa8EheindnaeydbgAcuSmbdnaHa9maAcdtgXfydbgA9hmbcuhAa8EaXfydbgXcuSmba9maXcdtfydbhAkaeaABdbkaeclfhealaHcefgH9hmbkka85aUaCEh85cbhHabhecbhAindnaOa9maeydbcdtfydbg8FcdtfydbgXaOa9maeclfydbcdtfydbgacdtfydbgKSmbaXaOa9maecwfydbcdtfydbg8AcdtfydbghSmbaKahSmbabaHcdtfgXa8FBdbaXcwfa8ABdbaXclfaaBdbaHcifhHkaecxfheaAcifgAad6mbkdndnaTmbaHhdxekdnaHak0mbaHhdxekdna8Sa859FmbaHhdxekJFFuuh8ScbhdabhecbhAindna9ha9iaeydbgXcdtfydbcdtfIdbgRa859ETmbaeclf8Pdbh9AabadcdtfgKaXBdbaKclfa9A83dbaRa8Sa8SaR9EEh8SadcifhdkaecxfheaAcifgAaH6mbkkadak0mbxdkkascNefabadalaOz:cjjjbkdndnadak0mbadhaxekdnaTmbadhaxekdna8Sa879FmbadhaxekcehKina8SJbb;aZNgRa87aRa879DEh8WJbbbbhRdnaSTmba9hheaShHinaeIdbg8VaRa8Va8W9FEaRa8VaR9EEhRaeclfheaHcufgHmbkkJFFuuh8ScbhaabhecbhHindna9ha9iaeydbgAcdtfydbcdtfIdbg8Va8W9ETmbaeclf8Pdbh9AabaacdtfgXaABdbaXclfa9A83dba8Va8Sa8Sa8V9EEh8SaacifhakaecxfheaHcifgHad6mbkdnaKaaad9hVceGmbadhaxdkaRaUaUaR9DEhUaaak9nmecbhKaahda8Sa879FmbkkdnamcjjjjdGTmba9ncbalz:tjjjbh8AdnaaTmbabheaahHina8AaeydbgAfce86bba8AaOaAcdtfydbfce86bbaeclfheaHcufgHmbkkascNefabaaalaOz:cjjjbdndnalTmbcbhXindna8AaXfRbbTmbdnaYaXfRbbgecl0mbceaetcQGmekdnaOaXcdtg8FfydbgeaXSmba8NaXcx2fgHa8Naecx2fgeydwBdwaHae8Pdb83dbxekaIaXc8S2fgKIdygcacJL:3;rUNgRMh87aKIdwg9BaRMh8SaKIdlg9CaRMh8UaKIdbg9DaRMh81aKIdag9EaRa8NaXcx2fg8JIdwg88N:th8ZaKId3g9FaRa8JIdlg89N:th83aKIdKg9Ga8JIdbg8:aRN:th80JbbbbhnaKIdCg9HJbbbbMh85aKIdzg9IJbbbbMhBaKIdxg9JJbbbbMh86dndnaCTmbaXhAinJbbbba87agaAc8S2fgHIdygR:vaRJbbbb9BEhRa8RaAaC2cltfheaHIdaa87Na8ZMh8ZaHId3a87Na83Mh83aHIdKa87Na80Mh80aHIdCa87Na85Mh85aHIdza87NaBMhBaHIdxa87Na86Mh86aHIdwa87Na8SMh8SaHIdla87Na8UMh8UaHIdba87Na81Mh81aChHina8ZaecwfIdbg8VaecxfIdbg8YNaRN:th8Za83aeclfIdbg8Wa8YNaRN:th83a85a8Wa8VNaRN:th85a81aeIdbg8Xa8XNaRN:th81a80a8Xa8YNaRN:th80aBa8Xa8VNaRN:thBa86a8Xa8WNaRN:th86a8Sa8Va8VNaRN:th8Sa8Ua8Wa8WNaRN:th8UaeczfheaHcufgHmbkaQaAcdtfydbgAaX9hmbka8MTmba8MaXcltfgeIdxhxaeIdwh9caeIdlhJaeIdbhRxekJbbbbhxJbbbbh9cJbbbbhJJbbbbhRkaBa81:vg8Wa80Na8Z:ta85aBa86a81:vg8VN:tg8Za8Ua86a8VN:tg8Y:vg8Xa8Va80Na83:tg8UN:th83a9caRa8WN:taJaRa8VN:tg86a8XN:tg85a8SaBa8WN:ta8Za8XN:tgB:vg8S:mh8Za86a8Y:vg9c:mhJdnJbbbbaRaRa81:vg9eN:ta86a9cN:ta85a8SN:tg86:la87J:983:g81NgR9ETmba8Za83NaJa8UNa9ea80Nax:tMMa86:vhnka81:laR9ETmba8Y:laR9ETmbaB:laR9ETmba9e:manNa8W:ma8ZanNa83aB:vMgBNa8V:maJanNa8X:maBNa8Ua8Y:vMMg85Na80:ma81:vMMMh87aLa8FfgeclfydbgHaeydbge9RhhaEaecitfh8FJbbbbhRdnaHaeSgDmbJbbbbhRa8FheahhAina8Naeclfydbcx2fgHIdwa88:tg8Va8VNaHIdba8::tg8Va8VNaHIdla89:tg8Va8VNMMg8Va8Naeydbcx2fgHIdwa88:tg8Wa8WNaHIdba8::tg8Wa8WNaHIdla89:tg8Wa8WNMMg8WaRaRa8W9DEgRaRa8V9DEhRaecwfheaAcufgAmbkaR:rgRaRNhRkaBa88:tg8Va8VNa87a8::tg8Va8VNa85a89:tg8Va8VNMMaR9EmbaKId8KhndnaDmbina8Na8Fclfydbcx2fgeIdba8Na8Fydbcx2fgHIdbg8W:tgRa89aHIdlg8X:tg80NaeIdla8X:tg8Va8:a8W:tg86N:tg8YaRa85a8X:tg8SNa8Va87a8W:tg8UN:tg8XNa8Va88aHIdwg81:tg8ZNaeIdwa81:tg8Wa80N:tg80a8VaBa81:tg83Na8Wa8SN:tg8VNa8Wa86NaRa8ZN:tg81a8Wa8UNaRa83N:tgRNMMa8Ya8YNa80a80Na81a81NMMa8Xa8XNa8Va8VNaRaRNMMN:rJbbj8:N9Fmda8Fcwfh8FahcufghmbkkJbbbbJbbjZac:vacJbbbb9BEgRa9BaBNa9Ia87Na9EMg8Va8VMMaBNa9Ca85Na9HaBNa9FMg8Va8VMMa85Na9Da87Na9Ja85Na9GMg8Va8VMMa87NanMMM:lNaRa9Ba88Na9Ia8:Na9EMg8Va8VMMa88Na9Ca89Na9Ha88Na9FMg8Va8VMMa89Na9Da8:Na9Ja89Na9GMg8Va8VMMa8:NanMMM:lNJbb;aZNJ:983:g81M9Emba8JaBUdwa8Ja85Udla8Ja87UdbkaXcefgXal9hmbkdnaCmbcbhCxdkcbhXindna8AaXfRbbTmbaOaXcdtgefydbaX9hmbaYaXfhhaQaefh8Ja8NaXcx2fhAa8PaXaC2cdtfhDcbhEincuhLdnahRbbci9hmbaXhLa8JydbgeaXSmba8PaEcdtgHfhKaDaHfIdbhRaXhLinaLhHcuhLdnaKaeaC2cdtfIdbaR9CmbaHcuSmbaHhLagaec8S2fIdyagaHc8S2fIdy9ETmbaehLkaQaecdtfydbgeaX9hmbkka8PaEcdtfhKa8RaEcltfh8FaXheinaKaeaC2cdtfJbbbbJbbjZagaeaLaLcuSEgHc8S2fIdygR:vaRJbbbb9BEa8FaHaC2cltfgHIdwaAIdwNaHIdbaAIdbNaHIdlaAIdlNMMaHIdxMNUdbaQaecdtfydbgeaX9hmbkaEcefgEaC9hmbkkaXcefgXal9hmbxdkkaCmbcbhCkaiavaoarawaCala8Na8Pazasayasc1efaYa8Aaqz:hjjjbkdnamcjjjjlGTmbazmbaaTmbabhecbhLinaYaeydbgAfRbbc3thQaecwfgXydbhHcjjjj94hCdna5aAcdtgEfydbaeclfgKydbgOSmbcjjjj94cba8EaOcdtfydbaASEhCkaeaQaCVaAVBdbaYaOfRbbc3th8Fcjjjj94hCcjjjj94hQdna5aOcdtfydbaHSmbcjjjj94cba8EaHcdtfydbaOSEhQkaKa8FaQVaOVBdbaYaHfRbbc3thOdna5aHcdtfydbaASmbcjjjj94cba8EaEfydbaHSEhCkaXaOaCVaHVBdbaecxfheaLcifgLaa6mbkkdnazTmbaaTmbaaheinabazabydbcdtfydbBdbabclfhbaecufgembkkdnaPTmbaPaZaU:rNUdbkdnasyd;8egHTmbaHcdtasc:Ceffc98fheinaeydbcbyd:m:H:cjbH:bjjjbbaec98fheaHcufgHmbkkascj;sbf8Kjjjjbaak;Yieouabydlhvabydbclfcbaicdtz:tjjjbhoadci9UhrdnadTmbdnalTmbaehwadhDinaoalawydbcdtfydbcdtfgqaqydbcefBdbawclfhwaDcufgDmbxdkkaehwadhDinaoawydbcdtfgqaqydbcefBdbawclfhwaDcufgDmbkkdnaiTmbcbhDaohwinawydbhqawaDBdbawclfhwaqaDfhDaicufgimbkkdnadci6mbinaecwfydbhwaeclfydbhDaeydbhidnalTmbalawcdtfydbhwalaDcdtfydbhDalaicdtfydbhikavaoaicdtfgqydbcitfaDBdbavaqydbcitfawBdlaqaqydbcefBdbavaoaDcdtfgqydbcitfawBdbavaqydbcitfaiBdlaqaqydbcefBdbavaoawcdtfgwydbcitfaiBdbavawydbcitfaDBdlawawydbcefBdbaecxfhearcufgrmbkkabydbcbBdbk:todDue99aicd4aifhrcehwinawgDcethwaDar6mbkcuaDcdtgraDcFFFFi0Ecbyd1:H:cjbHjjjjbbhwaoaoyd9GgqcefBd9GaoaqcdtfawBdbawcFearz:tjjjbhkdnaiTmbalcd4hlaDcufhxcbhminamhDdnavTmbavamcdtfydbhDkcbadaDal2cdtfgDydlgwawcjjjj94SEgwcH4aw7c:F:b:DD2cbaDydbgwawcjjjj94SEgwcH4aw7c;D;O:B8J27cbaDydwgDaDcjjjj94SEgDcH4aD7c:3F;N8N27axGhwamcdthPdndndnavTmbakawcdtfgrydbgDcuSmeadavaPfydbal2cdtfgsIdbhzcehqinaqhrdnadavaDcdtfydbal2cdtfgqIdbaz9CmbaqIdlasIdl9CmbaqIdwasIdw9BmlkarcefhqakawarfaxGgwcdtfgrydbgDcu9hmbxdkkakawcdtfgrydbgDcuSmbadamal2cdtfgsIdbhzcehqinaqhrdnadaDal2cdtfgqIdbaz9CmbaqIdlasIdl9CmbaqIdwasIdw9BmikarcefhqakawarfaxGgwcdtfgrydbgDcu9hmbkkaramBdbamhDkabaPfaDBdbamcefgmai9hmbkkakcbyd:m:H:cjbH:bjjjbbaoaoyd9GcufBd9GdnaeTmbaiTmbcbhDaehwinawaDBdbawclfhwaiaDcefgD9hmbkcbhDaehwindnaDabydbgrSmbawaearcdtfgrydbBdbaraDBdbkabclfhbawclfhwaiaDcefgD9hmbkkk;:odvuv998Jjjjjbca9Rgocbyd1:G:cjbBdKaocb8Pdj:G:cjb83izaocbydN:G:cjbBdwaocb8Pd:m:G:cjb83ibdnadTmbaicd4hrdnabmbdnalTmbcbhwinaealawcdtfydbar2cdtfhDcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkawcefgwad9hmbxikkarcdthwcbhDincbhiinaoczfaifgqaeaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkaeawfheaDcefgDad9hmbxdkkdnalTmbcbhwinabawcx2fgiaealawcdtfydbar2cdtfgDIdbUdbaiaDIdlUdlaiaDIdwUdwcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkawcefgwad9hmbxdkkarcdthlcbhwaehDinabawcx2fgiaeawar2cdtfgqIdbUdbaiaqIdlUdlaiaqIdwUdwcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkaDalfhDawcefgwad9hmbkkJbbbbaoIdbaoIdzgx:tgkakJbbbb9DEgkaoIdlaoIdCgm:tgPaPak9DEgkaoIdwaoIdKgP:tgsasak9DEhsdnabTmbadTmbJbbbbJbbjZas:vasJbbbb9BEhkinabakabIdbax:tNUdbabclfgoakaoIdbam:tNUdbabcwfgoakaoIdbaP:tNUdbabcxfhbadcufgdmbkkdnavTmbavaPUdwavamUdlavaxUdbkask:WlewudnaeTmbcbhvabhoinaoavBdbaoclfhoaeavcefgv9hmbkkdnaiTmbcbhrinadarcdtfhwcbhDinalawaDcdtgvyd:G:G:cjbcdtfydbcdtfydbhodnalawavfydbcdtfydbgqabaqcdtfgkydbgvSmbinakabavgqcdtfgxydbgvBdbaxhkaqav9hmbkkdnaoabaocdtfgkydbgvSmbinakabavgocdtfgxydbgvBdbaxhkaoav9hmbkkdnaqaoSmbabaqaoaqao0Ecdtfaqaoaqao6EBdbkaDcefgDci9hmbkarcifgrai6mbkkdnaembcbskcbhxindnalaxcdtgvfydbax9hmbaxhodnaxabavfgDydbgvSmbaDhqinaqabavgocdtfgkydbgvBdbakhqaoav9hmbkkaDaoBdbkaxcefgxae9hmbkcbhkabhvcbhoindndnaoalydbgq9hmbdnaoavydbgq9hmbavakBdbakcefhkxdkavabaqcdtfydbBdbxekavabaqcdtfydbBdbkalclfhlavclfhvaeaocefgo9hmbkakk;jiilud99euabcbaecltz:tjjjbhvdnalTmbadhoaihralhwinarcwfIdbhDarclfIdbhqavaoydbcltfgkarIdbakIdbMUdbakaqakIdlMUdlakaDakIdwMUdwakakIdxJbbjZMUdxaoclfhoarcxfhrawcufgwmbkkdnaeTmbavhkaehrinakcxfgoIdbhDaocbBdbakakIdbJbbbbJbbjZaD:vaDJbbbb9BEgDNUdbakclfgoaDaoIdbNUdbakcwfgoaDaoIdbNUdbakczfhkarcufgrmbkkdnalTmbinavadydbcltfgkaicwfIdbakIdw:tgDaDNaiIdbakIdb:tgDaDNaiclfIdbakIdl:tgDaDNMMgDakIdxgqaqaD9DEUdxadclfhdaicxfhialcufglmbkkdnaeTmbavcxfhkinabakIdbUdbakczfhkabclfhbaecufgembkkk:moerudnaoTmbaecd4hzdnavTmbaicd4hHavcdthOcbhAindnaPaAfRbbTmbaAhednaDTmbaDaAcdtfydbhekdnasTmbasaefRbbceGmekdnamaAfRbbclSmbabaeaz2cdtfgiaraAcx2fgCIdbakNaxIdbMUdbaiaCIdlakNaxIdlMUdlaiaCIdwakNaxIdwMUdwkadaeaH2cdtfhXaqheawhiavhCinaXaeydbcdtgQfaiIdbalaQfIdb:vUdbaeclfheaiclfhiaCcufgCmbkkawaOfhwaAcefgAao9hmbxdkkdnasmbcbheaDhiindnaPaefRbbTmbaehCdnaDTmbaiydbhCkamaefRbbclSmbabaCaz2cdtfgCarIdbakNaxIdbMUdbaCarclfIdbakNaxIdlMUdlaCarcwfIdbakNaxIdwMUdwkaiclfhiarcxfhraoaecefge9hmbxdkkdnaDTmbindnaPRbbTmbasaDydbgefRbbceGmbamRbbclSmbabaeaz2cdtfgearIdbakNaxIdbMUdbaearclfIdbakNaxIdlMUdlaearcwfIdbakNaxIdwMUdwkaPcefhPaDclfhDamcefhmarcxfhraocufgombxdkkazcdthicbheindnaPaefRbbTmbasaefRbbceGmbamaefRbbclSmbabarIdbakNaxIdbMUdbabclfarclfIdbakNaxIdlMUdbabcwfarcwfIdbakNaxIdwMUdbkarcxfhrabaifhbaoaecefge9hmbkkk8MbabaeadaialavcbcbcbcbcbaoarawaDz:bjjjbk8MbabaeadaialavaoarawaDaqakaxamaPz:bjjjbkRbababaeadaialavaoarawaDaqakaxcjjjjdVamz:bjjjbk:g8Koque99due99duq998Jjjjjbc;Wb9Rgq8Kjjjjbcbhkaqcxfcbc;Kbz:tjjjb8Aaqcualcx2alc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbgxBdxaqceBd2axaialavcbcbz:ejjjb8AaqcualcdtalcFFFFi0Egmcbyd1:H:cjbHjjjjbbgiBdzaqcdBd2dndnJFF959eJbbjZawJbbjZawJbbjZ9DE:vawJ9VO:d869DEgw:lJbbb9p9DTmbaw:OhPxekcjjjj94hPkadci9Uhsarco9UhzdndnaombaPcd9imekdnalTmbaPcuf:YhwdnaoTmbcbhvaihHaxhOindndnaoavfRbbceGTmbavcjjjjlVhAxekdndnaOclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcqthAdndnaOcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXVhAdndnaOIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXcCtVhAkaHaABdbaHclfhHaOcxfhOalavcefgv9hmbxdkkaxhvaihOalhHindndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcCthAdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqtaAVhAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaOaAaXVBdbavcxfhvaOclfhOaHcufgHmbkkadTmbcbhkaehvcbhOinakaiavclfydbcdtfydbgHaiavcwfydbcdtfydbgA9haiavydbcdtfydbgXaH9haXaA9hGGfhkavcxfhvaOcifgOad6mbkkarci9UhQdndnaz:Z:rJbbbZMgw:lJbbb9p9DTmbaw:Ohvxekcjjjj94hvkaQ:ZhLcbhKc:bwhzdninakaQ9pmeazaP9Rcd9imeavazcufgOavaO9iEaPcefavaP9kEhYdnalTmbaYcuf:YhwdnaoTmbcbhOaihHaxhvindndnaoaOfRbbceGTmbaOcjjjjlVhAxekdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcqthAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXVhAdndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXcCtVhAkaHaABdbaHclfhHavcxfhvalaOcefgO9hmbxdkkaxhvaihOalhHindndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcCthAdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqtaAVhAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaOaAaXVBdbavcxfhvaOclfhOaHcufgHmbkkcbhOdnadTmbaehvcbhHinaOaiavclfydbcdtfydbgAaiavcwfydbcdtfydbgX9haiavydbcdtfydbgraA9haraX9hGGfhOavcxfhvaHcifgHad6mbkkdnas:ZgCaL:taY:Ygwaz:Y:tg8ANak:ZgEaO:Zg3:tNaEaL:tawaP:Y:tg5Na3aC:tNMg8EJbbbb9BmbaCaE:ta5a8Aa3aL:tNNNa8E:vawMhwkdndnaOaQ0mbaOhkaYhPxekaOhsaYhzkdndnaKcl0mbdnawJbbbZMgw:lJbbb9p9DTmbaw:Ohvxdkcjjjj94hvxekaPazfcd9ThvkaKcefgKcs9hmbkkdndndnakmbJbbjZhwcbhOcdhvaDmexdkalcd4alfhHcehOinaOgvcethOavaH6mbkcbhOaqcuavcdtgYavcFFFFi0Ecbyd1:H:cjbHjjjjbbgKBdCaqciBd2aqamcbyd1:H:cjbHjjjjbbgzBdKaqclBd2dndndndnalTmbaPcuf:YhwaoTmecbhOaihAaxhHindndnaoaOfRbbceGTmbaOcjjjjlVhXxekdndnaHclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqthXdndnaHcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaXarVhXdndnaHIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaXarcCtVhXkaAaXBdbaAclfhAaHcxfhHalaOcefgO9hmbxikkaKcFeaYz:tjjjb8AcbhPcbhvxdkaxhOaihHalhAindndnaOIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcCthXdndnaOclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkarcqtaXVhXdndnaOcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaHaXarVBdbaOcxfhOaHclfhHaAcufgAmbkkaKcFeaYz:tjjjbhravcufhocbhPcbhYindndndnaraiaYcdtgKfydbgAcm4aA7c:v;t;h;Ev2gvcs4av7aoGgHcdtfgXydbgOcuSmbcehvinaiaOcdtgOfydbaASmdaHavfhOavcefhvaraOaoGgHcdtfgXydbgOcu9hmbkkaXaYBdbaPhvaPcefhPxekazaOfydbhvkazaKfavBdbaYcefgYal9hmbkcuaPc8S2gOaPc;D;O;f8U0EhvkcbhXaqavcbyd1:H:cjbHjjjjbbgvBd3aqcvBd2avcbaOz:tjjjbhOdnadTmbaehiinaxaiclfydbgrcx2fgvIdbaxaiydbgocx2fgHIdbg3:tgCaxaicwfydbgYcx2fgAIdlaHIdlg8A:tgwNavIdla8A:tgEaAIdba3:tg8EN:tgLaLNaEaAIdwaHIdwg5:tg8FNavIdwa5:tgEawN:tgwawNaEa8ENaCa8FN:tgCaCNMMg8E:rhEJbbnnJbbjZazaocdtfydbgvazarcdtfydbgASavazaYcdtfydbgrSGgHEh8Fdna8EJbbbb9ETmbaLaE:vhLaCaE:vhCawaE:vhwkaOavc8S2fgvavIdbawa8FaE:rNgEawNNg8FMUdbavaCaEaCNgaNghavIdlMUdlavaLaEaLNg8ENggavIdwMUdwavawaaNgaavIdxMUdxava8EawNg8JavIdzMUdzavaCa8ENg8EavIdCMUdCavawaEaLa5Nawa3Na8AaCNMM:mg8ANg3NgwavIdKMUdKavaCa3NgCavId3MUd3avaLa3NgLavIdaMUdaava3a8ANg3avId8KMUd8KavaEavIdyMUdydnaHmbaOaAc8S2fgva8FavIdbMUdbavahavIdlMUdlavagavIdwMUdwavaaavIdxMUdxava8JavIdzMUdzava8EavIdCMUdCavawavIdKMUdKavaCavId3MUd3avaLavIdaMUdaava3avId8KMUd8KavaEavIdyMUdyaOarc8S2fgva8FavIdbMUdbavahavIdlMUdlavagavIdwMUdwavaaavIdxMUdxava8JavIdzMUdzava8EavIdCMUdCavawavIdKMUdKavaCavId3MUd3avaLavIdaMUdaava3avId8KMUd8KavaEavIdyMUdykaicxfhiaXcifgXad6mbkkcbhAaqcuaPcdtgvaPcFFFFi0Egicbyd1:H:cjbHjjjjbbgHBdaaqcoBd2aqaicbyd1:H:cjbHjjjjbbgiBd8KaqcrBd2aHcFeavz:tjjjbhYdnalTmbazhHinJbbbbJbbjZaOaHydbgXc8S2fgvIdygw:vawJbbbb9BEavIdwaxcwfIdbgwNavIdzaxIdbgCNavIdaMgLaLMMawNavIdlaxclfIdbgLNavIdCawNavId3MgwawMMaLNavIdbaCNavIdxaLNavIdKMgwawMMaCNavId8KMMM:lNhwdndnaYaXcdtgvfgXydbcuSmbaiavfIdbaw9ETmekaXaABdbaiavfawUdbkaHclfhHaxcxfhxalaAcefgA9hmbkkdndnaPmbJbbbbhwxekJbbbbhwinaiIdbgCawawaC9DEhwaiclfhiaPcufgPmbkaw:rhwkakcd4akfhOcehiinaigvcethiavaO6mbkcbhOaqcuavcdtgiavcFFFFi0Ecbyd1:H:cjbHjjjjbbgHBdyaHcFeaiz:tjjjbhXdnadTmbavcufhrcbhPcbhxindnazaeaxcdtfgvydbcdtfydbgiazavclfydbcdtfydbgOSmbaiazavcwfydbcdtfydbgvSmbaOavSmbaYavcdtfydbhAdndnaYaOcdtfydbgvaYaicdtfydbgi9pmbavaA9pmbaAhlaihoavhAxekdnaAai9pmbaAav9pmbaihlavhoxekavhlaAhoaihAkabaPcx2fgvaABdbavcwfaoBdbavclfalBdbdnaXaoc:3F;N8N2alc:F:b:DD27aAc;D;O:B8J27arGgOcdtfgvydbgicuSmbcehHinaHhvdnabaicx2fgiydbaA9hmbaiydlal9hmbaiydwaoSmikavcefhHaXaOavfarGgOcdtfgvydbgicu9hmbkkavaPBdbaPcefhPkaxcifgxad6mbkaPci2hOkcwhvaDTmekaDawUdbkavcdthvaqcxfc98fhiinaiavfydbcbyd:m:H:cjbH:bjjjbbavc98fgvmbkaqc;Wbf8KjjjjbaOk:3ldrue9:8Jjjjjbc;Wb9Rgr8Kjjjjbcbhwarcxfcbc;Kbz:tjjjb8AdnabaeSmbabaeadcdtzMjjjb8AkarcualcdtalcFFFFi0EgDcbyd1:H:cjbHjjjjbbgqBdxarceBd2aqcbaialavcbarcxfz:djjjbcualcx2alc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbhkarcxfaryd2gxcdtfakBdbaraxcefgmBd2akaialavcbcbz:ejjjb8AarcxfamcdtfaDcbyd1:H:cjbHjjjjbbgiBdbaraxcdfgvBd2arcxfavcdtfcuaialaeadaqz:fjjjbgecltaecjjjjiGEcbyd1:H:cjbHjjjjbbgqBdbaqaeaiakalz:gjjjbaxcifhkdnadTmbaoaoNhocbhwabhlcbheindnaqaialydbgvcdtfydbcdtfIdbao9ETmbalclf8PdbhPabawcdtfgDavBdbaDclfaP83dbawcifhwkalcxfhlaecifgead6mbkkdnakTmbaxcdtarcxffcwfhlinalydbcbyd:m:H:cjbH:bjjjbbalc98fhlakcufgkmbkkarc;Wbf8Kjjjjbawk:WCoDud99vue99vuv998Jjjjjbc;Wb9Rgw8KjjjjbdndnarmbcbhDxekawcxfcbc;Kbz:tjjjb8Aawcuadcx2adc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbgqBdxawceBd2aqaeadaicbcbz:ejjjb8AawcuadcdtadcFFFFi0Egkcbyd1:H:cjbHjjjjbbgxBdzawcdBd2adcd4adfhmceheinaegicetheaiam6mbkcbhPawcuaicdtgsaicFFFFi0Ecbyd1:H:cjbHjjjjbbgzBdCawciBd2dndnar:ZgH:rJbbbZMgO:lJbbb9p9DTmbaO:Ohexekcjjjj94hekaicufhAc:bwhCcbhXadhQcbhLinaeaCcufgiaeai9iEaPcefaeaP9kEhDdndnadTmbaDcuf:YhOaqhiaxheadhmindndnaiIdbaONJbbbZMgK:lJbbb9p9DTmbaK:OhYxekcjjjj94hYkaYcCthYdndnaiclfIdbaONJbbbZMgK:lJbbb9p9DTmbaK:Oh8Axekcjjjj94h8Aka8AcqtaYVhYdndnaicwfIdbaONJbbbZMgK:lJbbb9p9DTmbaK:Oh8Axekcjjjj94h8AkaeaYa8AVBdbaicxfhiaeclfheamcufgmmbkazcFeasz:tjjjbhEcbh3cbh5indnaEaxa5cdtfydbgYcm4aY7c:v;t;h;Ev2gics4ai7aAGgmcdtfg8AydbgecuSmbaeaYSmbcehiinaEamaifaAGgmcdtfg8AydbgecuSmeaicefhiaeaY9hmbkka8AaYBdba3aecuSfh3a5cefg5ad9hmbxdkkazcFeasz:tjjjb8Acbh3kdnaQ:ZgKaH:taD:YgOaC:Y:tg8ENaX:Zg8Fa3:Zga:tNa8FaH:taOaP:Y:tghNaaaK:tNMggJbbbb9BmbaKa8F:taha8EaaaH:tNNNag:vaOMhOkaPaDa3ar0giEhPaXa3aiEhXdna3arSmbaDaCaiEgCaP9Rcd9imbdndnaLcl0mbdnaOJbbbZMgO:lJbbb9p9DTmbaO:Ohexdkcjjjj94hexekaPaCfcd9Theka3aQaiEhQaLcefgLcs9hmekkdndnaXmbcihicbhDxekcbhiawakcbyd1:H:cjbHjjjjbbg5BdKawclBd2aPcuf:YhKdndnadTmbaqhiaxheadhmindndnaiIdbaKNJbbbZMgO:lJbbb9p9DTmbaO:OhYxekcjjjj94hYkaYcCthYdndnaiclfIdbaKNJbbbZMgO:lJbbb9p9DTmbaO:Oh8Axekcjjjj94h8Aka8AcqtaYVhYdndnaicwfIdbaKNJbbbZMgO:lJbbb9p9DTmbaO:Oh8Axekcjjjj94h8AkaeaYa8AVBdbaicxfhiaeclfheamcufgmmbkazcFeasz:tjjjbhEcbhDcbh3indndndnaEaxa3cdtgCfydbgYcm4aY7c:v;t;h;Ev2gics4ai7aAGgmcdtfg8AydbgecuSmbcehiinaxaecdtgefydbaYSmdamaifheaicefhiaEaeaAGgmcdtfg8Aydbgecu9hmbkka8Aa3BdbaDhiaDcefhDxeka5aefydbhika5aCfaiBdba3cefg3ad9hmbkcuaDc32giaDc;j:KM;jb0EhexekazcFeasz:tjjjb8AcbhDcbhekawaecbyd1:H:cjbHjjjjbbgeBd3awcvBd2aecbaiz:tjjjbh8Aavcd4hxdnadTmbdnalTmbaxcdthEa5hYaqhealhmadhAina8AaYydbc32fgiaeIdbaiIdbMUdbaiaeclfIdbaiIdlMUdlaiaecwfIdbaiIdwMUdwaiamIdbaiIdxMUdxaiamclfIdbaiIdzMUdzaiamcwfIdbaiIdCMUdCaiaiIdKJbbjZMUdKaYclfhYaecxfheamaEfhmaAcufgAmbxdkka5hmaqheadhYina8Aamydbc32fgiaeIdbaiIdbMUdbaiaeclfIdbaiIdlMUdlaiaecwfIdbaiIdwMUdwaiaiIdxJbbbbMUdxaiaiIdzJbbbbMUdzaiaiIdCJbbbbMUdCaiaiIdKJbbjZMUdKamclfhmaecxfheaYcufgYmbkkdnaDTmba8AhiaDheinaiaiIdbJbbbbJbbjZaicKfIdbgO:vaOJbbbb9BEgONUdbaiclfgmaOamIdbNUdbaicwfgmaOamIdbNUdbaicxfgmaOamIdbNUdbaiczfgmaOamIdbNUdbaicCfgmaOamIdbNUdbaic3fhiaecufgembkkcbhYawcuaDcdtgCaDcFFFFi0Egicbyd1:H:cjbHjjjjbbgeBdaawcoBd2awaicbyd1:H:cjbHjjjjbbgEBd8KaecFeaCz:tjjjbh3dnadTmbaoJbbjZJbbjZaK:vaPceSENgOaONhKaxcdthxalheinaKaec;8:G:cjbalEgmIdwa8Aa5ydbgAc32fgiIdC:tgOaONamIdbaiIdx:tgOaONamIdlaiIdz:tgOaONMMNaqcwfIdbaiIdw:tgOaONaqIdbaiIdb:tgOaONaqclfIdbaiIdl:tgOaONMMMhOdndna3aAcdtgifgmydbcuSmbaEaifIdbaO9ETmekamaYBdbaEaifaOUdbka5clfh5aqcxfhqaeaxfheadaYcefgY9hmbkkaba3aCzMjjjb8Acrhikaicdthiawcxfc98fheinaeaifydbcbyd:m:H:cjbH:bjjjbbaic98fgimbkkawc;Wbf8KjjjjbaDk:Pdidui99ducbhi8Jjjjjbca9Rglcbyd1:G:cjbBdKalcb8Pdj:G:cjb83izalcbydN:G:cjbBdwalcb8Pd:m:G:cjb83ibdndnaembJbbjFhvJbbjFhoJbbjFhrxekadcd4cdthwincbhdinalczfadfgDabadfIdbgvaDIdbgoaoav9EEUdbaladfgDavaDIdbgoaoav9DEUdbadclfgdcx9hmbkabawfhbaicefgiae9hmbkalIdwalIdK:thralIdlalIdC:thoalIdbalIdz:thvkJbbbbavavJbbbb9DEgvaoaoav9DEgvararav9DEk9DeeuabcFeaicdtz:tjjjbhlcbhbdnadTmbindnalaeydbcdtfgiydbcu9hmbaiabBdbabcefhbkaeclfheadcufgdmbkkabk;Bidqui998Jjjjjbc;Wb9Rgl8Kjjjjbalcxfcbc;Kbz:tjjjb8Aadcd4adfhvcehoinaogrcethoarav6mbkalcuarcdtgoarcFFFFi0Ecbyd1:H:cjbHjjjjbbgvBdxavcFeaoz:tjjjbhwdnadTmbaicd4hDarcufhqcbhkindndnawcbaeakaD2cdtfgrydlgiaicjjjj94SEgocH4ao7c:F:b:DD2cbarydbgxaxcjjjj94SEgocH4ao7c;D;O:B8J27cbarydwgmamcjjjj94SEgrcH4ar7c:3F;N8N27aqGgvcdtfgrydbgocuSmbam::hPai::hsax::hzcehiinaihrdnaeaoaD2cdtfgiIdbaz9CmbaiIdlas9CmbaiIdwaP9BmikarcefhiawavarfaqGgvcdtfgrydbgocu9hmbkkarakBdbakhokabakcdtfaoBdbakcefgkad9hmbkkalydxcbyd:m:H:cjbH:bjjjbbalc;Wbf8Kjjjjbk9teiucbcbyd:q:H:cjbgeabcifc98GfgbBd:q:H:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd:q:H:cjbgeabcrfc94GfgbBd:q:H:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd:q:H:cjbge9Rcifc98GaefgbBd:q:H:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akkk:Kedbcj:Gdk1eFFuuFFuuFFuuFFuFFFuFFFuFbbbbbbbbebbbdbbbbbbbebbbebbbdbbbbbbbbbbbeeeeebebbebbebebbbeebbbbbbbbbbbbeeeeeebebbeeebeebbbbebebbbbbbbbbbbbbbbbbbc1:Hdkxebbbdbbb:G:qbb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,i=WebAssembly.instantiate(r(e),{}).then(function(x){n=x.instance,n.exports.__wasm_call_ctors()});function r(x){var _=new Uint8Array(x.length);for(var y=0;y<x.length;++y){var v=x.charCodeAt(y);_[y]=v>96?v-97:v>64?v-39:v+4}var T=0;for(var y=0;y<x.length;++y)_[T++]=_[y]<60?t[_[y]]:(_[y]-60)*64+_[++y];return _.buffer.slice(0,T)}function s(x){if(!x)throw Error("Assertion failed")}function a(x){return new Uint8Array(x.buffer,x.byteOffset,x.byteLength)}function o(x,_,y,v){var T=n.exports.sbrk,A=T(y*4),E=T(y*v*4),w=new Uint8Array(n.exports.memory.buffer);w.set(a(_),E),x(A,E,y,v*4),w=new Uint8Array(n.exports.memory.buffer);var P=new Uint32Array(y);return new Uint8Array(P.buffer).set(w.subarray(A,A+y*4)),T(A-T(0)),P}function c(x,_,y){var v=n.exports.sbrk,T=v(_.length*4),A=v(y*4),E=new Uint8Array(n.exports.memory.buffer),w=a(_);E.set(w,T);var P=x(A,T,_.length,y);E=new Uint8Array(n.exports.memory.buffer);var S=new Uint32Array(y);new Uint8Array(S.buffer).set(E.subarray(A,A+y*4)),v(T-v(0));for(var I=0;I<_.length;++I)_[I]=S[_[I]];return[S,P]}function l(x){var _=0;for(var y=0;y<x.length;++y){var v=x[y];_=_<v?v:_}return _}function u(x,_,y,v,T,A,E,w,P){var S=n.exports.sbrk,I=S(4),U=S(y*4),N=S(T*A),F=S(y*4),D=new Uint8Array(n.exports.memory.buffer);D.set(a(v),N),D.set(a(_),F);var O=x(U,F,y,N,T,A,E,w,P,I);D=new Uint8Array(n.exports.memory.buffer);var K=new Uint32Array(O);a(K).set(D.subarray(U,U+O*4));var B=new Float32Array(1);return a(B).set(D.subarray(I,I+4)),S(I-S(0)),[K,B[0]]}function d(x,_,y,v,T,A,E,w,P,S,I,U,N){var F=n.exports.sbrk,D=F(4),O=F(y*4),K=F(T*A),B=F(T*w),X=F(P.length*4),q=F(y*4),le=S?F(T):0,de=new Uint8Array(n.exports.memory.buffer);if(de.set(a(v),K),de.set(a(E),B),de.set(a(P),X),de.set(a(_),q),S)de.set(a(S),le);var Me=x(O,q,y,K,T,A,B,w,X,P.length,le,I,U,N,D);de=new Uint8Array(n.exports.memory.buffer);var pe=new Uint32Array(Me);a(pe).set(de.subarray(O,O+Me*4));var J=new Float32Array(1);return a(J).set(de.subarray(D,D+4)),F(D-F(0)),[pe,J[0]]}function f(x,_,y,v,T,A,E,w,P,S,I,U,N){var F=n.exports.sbrk,D=F(4),O=F(T*A),K=F(T*w),B=F(P.length*4),X=F(y*4),q=S?F(T):0,le=new Uint8Array(n.exports.memory.buffer);if(le.set(a(v),O),le.set(a(E),K),le.set(a(P),B),le.set(a(_),X),S)le.set(a(S),q);var de=x(X,y,O,T,A,K,w,B,P.length,q,I,U,N,D);le=new Uint8Array(n.exports.memory.buffer),a(_).set(le.subarray(X,X+de*4)),a(v).set(le.subarray(O,O+T*A)),a(E).set(le.subarray(K,K+T*w));var Me=new Float32Array(1);return a(Me).set(le.subarray(D,D+4)),F(D-F(0)),[de,Me[0]]}function h(x,_,y,v){var T=n.exports.sbrk,A=T(y*v),E=new Uint8Array(n.exports.memory.buffer);E.set(a(_),A);var w=x(A,y,v);return T(A-T(0)),w}function b(x,_,y,v,T,A,E,w){var P=n.exports.sbrk,S=P(w*4),I=P(y*v),U=T?P(y*A):0,N=new Uint8Array(n.exports.memory.buffer);if(N.set(a(_),I),T)N.set(a(T),U);var F=x(S,I,y,v,U,A,E,w);N=new Uint8Array(n.exports.memory.buffer);var D=new Uint32Array(F);return a(D).set(N.subarray(S,S+F*4)),P(S-P(0)),D}function m(x,_,y,v,T,A,E,w,P){var S=n.exports.sbrk,I=S(4),U=S(y*4),N=S(T*A),F=S(y*4),D=E?S(T):0,O=new Uint8Array(n.exports.memory.buffer);if(O.set(a(v),N),O.set(a(_),F),E)O.set(a(E),D);var K=x(U,F,y,N,T,A,D,w,P,I);O=new Uint8Array(n.exports.memory.buffer);var B=new Uint32Array(K);a(B).set(O.subarray(U,U+K*4));var X=new Float32Array(1);return a(X).set(O.subarray(I,I+4)),S(I-S(0)),[B,X[0]]}function g(x,_,y,v,T,A,E){var w=n.exports.sbrk,P=w(y*4),S=w(T*A),I=w(y*4),U=new Uint8Array(n.exports.memory.buffer);U.set(a(v),S),U.set(a(_),I);var N=x(P,I,y,S,T,A,E);U=new Uint8Array(n.exports.memory.buffer);var F=new Uint32Array(N);return a(F).set(U.subarray(P,P+N*4)),w(P-w(0)),F}var p={LockBorder:1,Sparse:2,ErrorAbsolute:4,Prune:8,Regularize:16,Permissive:32,_InternalDebug:1073741824};return{ready:i,supported:!0,compactMesh:function(x){s(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),s(x.length%3==0);var _=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),y=c(n.exports.meshopt_optimizeVertexFetchRemap,_,l(x)+1);if(x!==_)for(var v=0;v<_.length;++v)x[v]=_[v];return y},generatePositionRemap:function(x,_){return s(x instanceof Float32Array),s(x.length%_==0),s(_>=3),o(n.exports.meshopt_generatePositionRemap,x,x.length/_,_)},simplify:function(x,_,y,v,T,A){s(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),s(x.length%3==0),s(_ instanceof Float32Array),s(_.length%y==0),s(y>=3),s(v>=0&&v<=x.length),s(v%3==0),s(T>=0);var E=0;for(var w=0;w<(A?A.length:0);++w)s(A[w]in p),E|=p[A[w]];var P=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),S=u(n.exports.meshopt_simplify,P,x.length,_,_.length/y,y*4,v,T,E);return S[0]=x instanceof Uint32Array?S[0]:new x.constructor(S[0]),S},simplifyWithAttributes:function(x,_,y,v,T,A,E,w,P,S){s(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),s(x.length%3==0),s(_ instanceof Float32Array),s(_.length%y==0),s(y>=3),s(v instanceof Float32Array),s(v.length==T*(_.length/y)),s(T>=0),s(E==null||E instanceof Uint8Array),s(E==null||E.length==_.length/y),s(w>=0&&w<=x.length),s(w%3==0),s(P>=0),s(Array.isArray(A)),s(T>=A.length),s(A.length<=32);for(var I=0;I<A.length;++I)s(A[I]>=0);var U=0;for(var I=0;I<(S?S.length:0);++I)s(S[I]in p),U|=p[S[I]];var N=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),F=d(n.exports.meshopt_simplifyWithAttributes,N,x.length,_,_.length/y,y*4,v,T*4,new Float32Array(A),E,w,P,U);return F[0]=x instanceof Uint32Array?F[0]:new x.constructor(F[0]),F},simplifyWithUpdate:function(x,_,y,v,T,A,E,w,P,S){s(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),s(x.length%3==0),s(_ instanceof Float32Array),s(_.length%y==0),s(y>=3),s(v instanceof Float32Array),s(v.length==T*(_.length/y)),s(T>=0),s(E==null||E instanceof Uint8Array),s(E==null||E.length==_.length/y),s(w>=0&&w<=x.length),s(w%3==0),s(P>=0),s(Array.isArray(A)),s(T>=A.length),s(A.length<=32);for(var I=0;I<A.length;++I)s(A[I]>=0);var U=0;for(var I=0;I<(S?S.length:0);++I)s(S[I]in p),U|=p[S[I]];var N=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),F=f(n.exports.meshopt_simplifyWithUpdate,N,x.length,_,_.length/y,y*4,v,T*4,new Float32Array(A),E,w,P,U);if(x!==N)for(var I=0;I<F[0];++I)x[I]=N[I];return F},getScale:function(x,_){return s(x instanceof Float32Array),s(x.length%_==0),s(_>=3),h(n.exports.meshopt_simplifyScale,x,x.length/_,_*4)},simplifyPoints:function(x,_,y,v,T,A){if(s(x instanceof Float32Array),s(x.length%_==0),s(_>=3),s(y>=0&&y<=x.length/_),v)return s(v instanceof Float32Array),s(v.length%T==0),s(T>=3),s(x.length/_==v.length/T),b(n.exports.meshopt_simplifyPoints,x,x.length/_,_*4,v,T*4,A||0,y);else return b(n.exports.meshopt_simplifyPoints,x,x.length/_,_*4,void 0,0,0,y)},simplifySloppy:function(x,_,y,v,T,A){s(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),s(x.length%3==0),s(_ instanceof Float32Array),s(_.length%y==0),s(y>=3),s(v==null||v instanceof Uint8Array),s(v==null||v.length==_.length/y),s(T>=0&&T<=x.length),s(T%3==0),s(A>=0);var E=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),w=m(n.exports.meshopt_simplifySloppy,E,x.length,_,_.length/y,y*4,v,T,A);return w[0]=x instanceof Uint32Array?w[0]:new x.constructor(w[0]),w},simplifyPrune:function(x,_,y,v){s(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),s(x.length%3==0),s(_ instanceof Float32Array),s(_.length%y==0),s(y>=3),s(v>=0);var T=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),A=g(n.exports.meshopt_simplifyPrune,T,x.length,_,_.length/y,y*4,v);return A=x instanceof Uint32Array?A:new x.constructor(A),A}}}()});var HW;var gR=mt(()=>{HW=function(){var e="b9H79Tebbbe:neP9Geueu9Geub9Gbb9Giuuueu9Gmuuuuuuuuuuu9999eu9Gouuuuuueu9Gruuuuuuub9Gxuuuuuuuuuuuueu9Gxuuuuuuuuuuu99eu9GPuuuuuuuuuuuuu99b9Gouuuuuub9Gwuuuuuuuub9Gvuuuuub9GluuuubiQXdilvorwDqokoqxmbiibeilve9Weiiviebeoweuecj:Gdkr;Zeqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9I919P29K9nW79O2Wt79c9V919U9KbeY9TW79O9V9Wt9F9I919P29K9nW79O2Wt7S2W94bd39TW79O9V9Wt9F9I919P29K9nW79O2Wt79t9W9Ht9P9H2bo39TW79O9V9Wt9F9J9V9T9W91tWJ2917tWV9c9V919U9K7bw39TW79O9V9Wt9F9J9V9T9W91tW9nW79O2Wt9c9V919U9K7bkE9TW79O9V9Wt9F9J9V9T9W91tW9t9W9OWVW9c9V919U9K7bxL9TW79O9V9Wt9F9V9Wt9P9T9P96W9nW79O2WtbPl79IV9RbsDwebcekdOAq;W:leXdbkIbabaec9:fgefcufae9Ugeabci9Uadfcufad9Ugbaeab0Ek:88JDPue99eux99due99euo99iu8Jjjjjbc:WD9Rgm8KjjjjbdndnalmbcbhPxekamc:Cwfcbc;Kbz:rjjjb8AcuaocdtgsaocFFFFi0Ehzcbyd;0:G:cjbhHdndnalcb9imbaoal9nmbamazaHHjjjjbbgHBd:CwamceBd;8wamazcbyd;0:G:cjbHjjjjbbgOBd:GwamcdBd;8wamcualcdtalcFFFFi0Ecbyd;0:G:cjbHjjjjbbgABd:KwamciBd;8waihzalhsinaHazydbcdtfcbBdbazclfhzascufgsmbkaihzalhsinaHazydbcdtfgCaCydbcefBdbazclfhzascufgsmbkaihzalhCcbhXindnaHazydbcdtgQfgsydbcb9imbaOaQfaXBdbasasydbgQcjjjj94VBdbaQaXfhXkazclfhzaCcufgCmbkalci9UhLdnalci6mbcbhzaihsinascwfydbhCasclfydbhXaOasydbcdtfgQaQydbgQcefBdbaAaQcdtfazBdbaOaXcdtfgXaXydbgXcefBdbaAaXcdtfazBdbaOaCcdtfgCaCydbgCcefBdbaAaCcdtfazBdbascxfhsaLazcefgz9hmbkkaihzalhsindnaHazydbcdtgCfgXydbgQcu9kmbaXaQcFFFFrGgQBdbaOaCfgCaCydbaQ9RBdbkazclfhzascufgsmbxdkkamazaHHjjjjbbgHBd:CwamceBd;8wamazcbyd;0:G:cjbHjjjjbbgOBd:GwamcdBd;8wamcualcdtalcFFFFi0Ecbyd;0:G:cjbHjjjjbbgABd:KwamciBd;8waHcbasz:rjjjbhXaihzalhsinaXazydbcdtfgCaCydbcefBdbazclfhzascufgsmbkalci9UhLdnaoTmbcbhzaOhsaXhCaohQinasazBdbasclfhsaCydbazfhzaCclfhCaQcufgQmbkkdnalci6mbcbhzaihsinascwfydbhCasclfydbhQaOasydbcdtfgKaKydbgKcefBdbaAaKcdtfazBdbaOaQcdtfgQaQydbgQcefBdbaAaQcdtfazBdbaOaCcdtfgCaCydbgCcefBdbaAaCcdtfazBdbascxfhsaLazcefgz9hmbkkaoTmbcbhzaohsinaOazfgCaCydbaXazfydb9RBdbazclfhzascufgsmbkkamaLcbyd;0:G:cjbHjjjjbbgzBd:OwamclBd;8wazcbaLz:rjjjbhYamcuaLcK2alcjjjjd0Ecbyd;0:G:cjbHjjjjbbg8ABd:SwamcvBd;8wJbbbbhEdnalci6g3mbarcd4hKaihsa8AhzaLhrJbbbbh5inavasclfydbaK2cdtfgCIdlh8EavasydbaK2cdtfgXIdlhEavascwfydbaK2cdtfgQIdlh8FaCIdwhaaXIdwhhaQIdwhgazaCIdbg8JaXIdbg8KMaQIdbg8LMJbbnn:vUdbazclfaXIdlaCIdlMaQIdlMJbbnn:vUdbaQIdwh8MaCIdwh8NaXIdwhyazcxfa8EaE:tg8Eagah:tggNaaah:tgaa8FaE:tghN:tgEJbbbbJbbjZa8Ja8K:tg8FahNa8Ea8La8K:tg8KN:tghahNaEaENaaa8KNa8FagN:tgEaENMMg8K:rg8E:va8KJbbbb9BEg8KNUdbazczfaEa8KNUdbazcCfaha8KNUdbazcwfa8Maya8NMMJbbnn:vUdba5a8EMh5ascxfhsazcKfhzarcufgrmbka5aL:Z:vJbbbZNhEkamcuaLcdtalcFFFF970Ecbyd;0:G:cjbHjjjjbbgCBd:WwamcoBd;8waq:Zhhdna3mbcbhzaChsinasazBdbasclfhsaLazcefgz9hmbkkaEahNhhamcuaLcltalcFFFFd0Ecbyd;0:G:cjbHjjjjbbg8PBd:0wamcrBd;8wcba8Pa8AaCaLcbz:djjjb8AJFFuuh8MJFFuuh8NJFFuuhydnalci6mbJFFuuhya8AhzaLhsJFFuuh8NJFFuuh8MinazcwfIdbgEa8Ma8MaE9EEh8MazclfIdbgEa8Na8NaE9EEh8NazIdbgEayayaE9EEhyazcKfhzascufgsmbkkah:rhEamaocetgzcuaocu9kEcbyd;0:G:cjbHjjjjbbgCBd:4wdndnaoal9nmbaihzalhsinaCazydbcetfcFFi87ebazclfhzascufgsmbxdkkaCcFeazz:rjjjb8AkaEJbbbZNh8JcuhIdnalci6mbcbhsJFFuuhEa8AhzcuhIinazcwfIdba8M:tghahNazIdbay:tghahNazclfIdba8N:tghahNMM:rghaEaIcuSahaE9DVgXEhEasaIaXEhIazcKfhzaLascefgs9hmbkkamczfcbcjwz:rjjjb8Aam9cb83iwam9cb83ibaxa8JNh8RJbbjZak:th8Lcbh8SJbbbbhRJbbbbh8UJbbbbh8VJbbbbh8WJbbbbh8XJbbbbh8Ycbh8ZcbhPinJbbbbhEdna8STmbJbbjZa8S:Z:vhEkJbbbbhhdna8Ya8YNa8Wa8WNa8Xa8XNMMg8KJbbbb9BmbJbbjZa8K:r:vhhka8VaENh8Ka8UaENh5aRaENh8EaIhLdndndndndna8SaPVTmbamydwg80Tmea8YahNh8Fa8XahNhaa8WahNhgaeamydbcdtfh81cbh3JFFuuhEcvhQcuhLindnaHa81a3cdtfydbcdtgzfydbgvTmbaAaOazfydbcdtfhsindndnaCaiasydbgKcx2fgzclfydbgrcetf8Vebcs4aCazydbgXcetf8Vebcs4faCazcwfydbglcetf8Vebcs4fgombcbhzxekcehzaHaXcdtfydbgXceSmbcehzaHarcdtfydbgrceSmbcehzaHalcdtfydbglceSmbdnarcdSaXcdSfalcdSfcd6mbaocefhzxekaocdfhzkdnazaQ9kmba8AaKcK2fgXIdwa8K:tghahNaXIdba8E:tghahNaXIdla5:tghahNMM:ra8J:va8LNJbbjZMJ9VO:d86JbbjZaXIdCa8FNaXIdxagNaaaXIdzNMMakN:tghahJ9VO:d869DENghaEazaQ6ahaE9DVgXEhEaKaLaXEhLazaQaXEhQkasclfhsavcufgvmbkka3cefg3a809hmbkkaLcu9hmekama8KUd:ODama5Ud:KDama8EUd:GDamcuBd:qDamcFFF;7rBdjDa8Pcba8AaYamc:GDfamc:qDfamcjDfz:ejjjbamyd:qDhLdndnaxJbbbb9ETmba8SaD6mbaLcuSmeceh3amIdjDa8R9EmixdkaLcu9hmekdna8STmbabaPcltfgHam8Piw83dwaHam8Pib83dbaPcefhPkc3hHinamc:CwfaHfydbcbyd;4:G:cjbH:bjjjbbaHc98fgHc989hmbxvkkcbh3a8Saq9pmbamydwaCaiaLcx2fgzydbcetf8Vebcs4aCazcwfydbcetf8Vebcs4faCazclfydbcetf8Vebcs4ffaw9nmekcbhzcbhsdna8ZTmbcbhsamczfhXinamczfascdtfaXydbgQBdbaXclfhXasaYaQfRbbTfhsa8Zcufg8ZmbkkamydwhlamydbhXam9cu83i:GDam9cu83i:ODam9cu83i:qDam9cu83i:yDinamcjDfazfcFFF;7rBdbazclfgzcz9hmbkasc;8easclfc:bd6Eg8Zcdth80dnalTmbaeaXcdtfhocbhrindnaHaoarcdtfydbcdtgzfydbgvTmbaAaOazfydbcdtfhscuhQcuhzinaHaiasydbgKcx2fgXclfydbcdtfydbaHaXydbcdtfydbfaHaXcwfydbcdtfydbfgXazaXaz6gXEhzaKaQaXEhQasclfhsavcufgvmbkaQcuSmba8AaQcK2fgsIdwa8M:tgEaENasIdbay:tgEaENasIdla8N:tgEaENMM:rhEcbhsindndnazamc:qDfasfgvydbgX6mbazaX9hmeaEamcjDfasfIdb9FTmekavazBdbamc:GDfasfaQBdbamcjDfasfaEUdbxdkasclfgscz9hmbkkarcefgral9hmbkkamczfa80fhQcbhzcbhsindnamc:GDfazfydbgXcuSmbaQascdtfaXBdbascefhskazclfgzcz9hmbkasa8Zfg8ZTmbJFFuuhhcuhKamczfhza8ZhvcuhQina8AazydbgXcK2fgsIdwa8M:tgEaENasIdbay:tgEaENasIdla8N:tgEaENMM:rhEdndnaHaiaXcx2fgsclfydbcdtfydbaHasydbcdtfydbfaHascwfydbcdtfydbfgsaQ6mbasaQ9hmeaEah9DTmekaEhhashQaXhKkazclfhzavcufgvmbkaKcuSmbaKhLkdnamaiaLcx2fgrydbarclfydbarcwfydbaCabaeadaPawaqa3z:fjjjbTmbaPcefhPJbbbbhRJbbbbh8UJbbbbh8VJbbbbh8WJbbbbh8XJbbbbh8YkcbhXinaAaOaraXcdtfydbcdtgsfydbcdtfgKhzaHasfgvydbgQhsdnaQTmbdninazydbaLSmeazclfhzascufgsTmdxbkkazaKaQcdtfc98fydbBdbavavydbcufBdbkaXcefgXci9hmbka8AaLcK2fgzIdbhEazIdlhhazIdwh8KazIdxh5azIdzh8EazIdCh8FaYaLfce86bba8Ya8FMh8Ya8Xa8EMh8Xa8Wa5Mh8Wa8Va8KMh8Va8UahMh8UaRaEMhRamydxh8Sxbkkamc:WDf8KjjjjbaPkjoivuv99lu8Jjjjjbca9Rgo8Kjjjjbdndnalcw0mbaiydbhraeabcitfgwalcdtciVBdlawarBdbdnalcd6mbaiclfhralcufhDawcxfhwinarydbhqawcuBdbawc98faqBdbawcwfhwarclfhraDcufgDmbkkalabfhwxekcbhqaocbBdKao9cb83izaocbBdwao9cb83ibJbbjZhkJbbjZhxinadaiaqcdtfydbcK2fhDcbhwinaoczfawfgraDawfIdbgmarIdbgP:tgsaxNaPMgPUdbaoawfgrasamaP:tNarIdbMUdbawclfgwcx9hmbkJbbjZakJbbjZMgk:vhxaqcefgqal9hmbkcbhradcbcecdaoIdlgmaoIdwgP9GEgwaoIdbgsaP9GEawasam9GEgzcdtgwfhHaoczfawfIdbhmaihwalhDinaiarcdtfgqydbhOaqawydbgABdbawaOBdbawclfhwaraHaAcK2fIdbam9DfhraDcufgDmbkdndnarcv6mbavc8X9kmbaralc98f6mekaiydbhraeabcitfgwalcdtciVBdlawarBdbaiclfhralcufhDawcxfhwinarydbhqawcuBdbawc98faqBdbawcwfhwarclfhraDcufgDmbkalabfhwxekaeabcitfgwamUdbawawydlc98GazVBdlabcefaeadaiaravcefgqz:djjjbhDawawydlciGaDabcu7fcdtVBdlaDaeadaiarcdtfalar9Raqz:djjjbhwkaocaf8Kjjjjbawk;Oddvue99dninabaecitfgrydlgwcd4gDTmednawciGgqci9hmbcihqdnawcl6mbabaecitfhbcbheawhqcehkindnaiabydbgDfRbbmbcbhkadaDcK2fgwIdwalIdw:tgxaxNawIdbalIdb:tgxaxNawIdlalIdl:tgxaxNMM:rgxaoIdb9DTmbaoaxUdbavaDBdbarydlhqkabcwfhbaecefgeaqcd46mbkakceGTmikaraqciGBdlskdnabcbaDalaqcdtfIdbarIdb:tgxJbbbb9FEgwaD7aecefgDfgecitfydlabawaDfgDcitfydlVci0mbaraqBdlkabaDadaialavaoz:ejjjbax:laoIdb9Fmbkkkjlevudndnabydwgxaladcetfgm8Vebcs4alaecetfgP8Vebgscs4falaicetfgz8Vebcs4ffaD0mbakmbcbhDabydxaq6mekavawcltfgxab8Pdw83dwaxab8Pdb83dbabydbhDdnabydwgwTmbaoaDcdtfhxawhsinalaxydbcetfcFFi87ebaxclfhxascufgsmbkkabaDawfBdbabydxhxab9cb83dwababydlaxci2fBdlaP8VebhscehDcbhxkdnascztcz91cu9kmbabaxcefBdwaPax87ebaoabydbcdtfaxcdtfaeBdbkdnam8Uebcu9kmbababydwgxcefBdwamax87ebaoabydbcdtfaxcdtfadBdbkdnaz8Uebcu9kmbababydwgxcefBdwazax87ebaoabydbcdtfaxcdtfaiBdbkarabydlfabydxci2faPRbb86bbarabydlfabydxci2fcefamRbb86bbarabydlfabydxci2fcdfazRbb86bbababydxcefBdxaDk:mPrHue99eue99eue99iu8Jjjjjbc;W;Gb9Rgx8KjjjjbdndnalmbcbhmxekcbhPaxc:m;Gbfcbc;Kbz:rjjjb8Aaxcualci9UgscltascjjjjiGEcbyd;0:G:cjbHjjjjbbgzBd:m9GaxceBd;S9GaxcuascK2gHcKfalcpFFFe0Ecbyd;0:G:cjbHjjjjbbgOBd:q9GaxcdBd;S9Gdnalci6gAmbarcd4hCascdthXaOhQazhLinavaiaPcx2fgrydwaC2cdtfhKavarydlaC2cdtfhYavarydbaC2cdtfh8AcbhraLhEinaQarfgma8Aarfg3Idbg5aYarfg8EIdbg8Fa5a8F9DEg5UdbamaKarfgaIdbg8Fa5a8Fa59DEg8FUdbamcxfgma3Idbg5a8EIdbgha5ah9EEg5UdbamaaIdbgha5aha59EEg5UdbaEa8Fa5MJbbbZNUdbaEaXfhEarclfgrcx9hmbkaQcKfhQaLclfhLaPcefgPas9hmbkkaOaHfgr9cb83dbar9cb83dzar9cb83dwaxcuascx2gralc:bjjjl0Ecbyd;0:G:cjbHjjjjbbgHBdN9GaxciBd;S9GascdthgazarfhvaxcwVhPaxclVhCaHh8Jazh8KcbhLinaxcbcj;Gbz:rjjjbhEaLas2cdthadnaAmba8Khrash3inaEarydbgmc8F91cjjjj94Vam7gmcQ4cx2fg8Ea8EydwcefBdwaEamcd4cFrGcx2fg8Ea8EydbcefBdbaEamcx4cFrGcx2fgmamydlcefBdlarclfhra3cufg3mbkkazaafh8AaHaafhXcbhmcbh3cbh8EcbhainaEamfgrydbhQara3BdbarcwfgKydbhYaKaaBdbarclfgrydbhKara8EBdbaQa3fh3aYaafhaaKa8Efh8Eamcxfgmcj;Gb9hmbkdnaAmbcbhravhminamarBdbamclfhmasarcefgr9hmbkavhrashminaEa8Aarydbg3cdtfydbg8Ec8F91a8E7cd4cFrGcx2fg8Ea8Eydbg8EcefBdbaXa8Ecdtfa3Bdbarclfhramcufgmmbka8JhrashminaCa8Aarydbg3cdtfydbg8Ec8F91a8E7cx4cFrGcx2fg8Ea8Eydbg8EcefBdbava8Ecdtfa3BdbarclfhramcufgmmbkavhrashminaPa8Aarydbg3cdtfydbg8Ec8F91cjjjj94Va8E7cQ4cx2fg8Ea8Eydbg8EcefBdbaXa8Ecdtfa3Bdbarclfhramcufgmmbkka8Jagfh8Ja8Kagfh8KaLcefgLci9hmbkaEaocetgrcuaocu9kEcbyd;0:G:cjbHjjjjbbgKBd:y9GaEclBd;S9Gdndnaoal9nmbaihralhminaKarydbcetfcFFi87ebarclfhramcufgmmbxdkkaKcFearz:rjjjb8Akcbh8EaEascbyd;0:G:cjbHjjjjbbg8ABd:C9GaOaHaHascdtfaHascitfa8AascbazaKaiawaDaqakz:hjjjbdndnalci6mba8Ahrashmina8EarRbbfh8EarcefhramcufgmmbkaE9cb83iwaE9cb83ibalawc9:fgrfcufar9UgrasaDfcufaD9Ugmaram0EhYcbhmcbhra8Ehaincbh3dnarTmba8AarfRbbceSh3kamaEaiaHydbcx2fgQydbaQclfydbaQcwfydbaKabaeadamawaqa3a3ce7a8EaY9nVaaamfaY6VGz:fjjjbfhmaHclfhHaaa8AarfRbb9Rhaasarcefgr9hmbkaEydxTmeabamcltfgraE8Piw83dwaraE8Pib83dbamcefhmxekaE9cb83iwaE9cb83ibcbhmkczhrinaEc:m;Gbfarfydbcbyd;4:G:cjbH:bjjjbbarc98fgrc989hmbkkaxc;W;Gbf8Kjjjjbamk:wKDQue99iue99iul9:euw99iu8Jjjjjbc;qb9RgP8Kjjjjbaxhsaxhzdndnavax0gHmbdnavTmbcbhOaehzavhAinawaDazydbcx2fgCcwfydbcetfgX8VebhQawaCclfydbcetfgL8VebhKawaCydbcetfgC8VebhYaXce87ebaLce87ebaCce87ebaOaKcs4aYcs4faQcs4ffhOazclfhzaAcufgAmbkaehzavhAinawaDazydbcx2fgCcwfydbcetfcFFi87ebawaCclfydbcetfcFFi87ebawaCydbcetfcFFi87ebazclfhzaAcufgAmbkcehzaqhsaOaq0mekalce86bbalcefcbavcufz:rjjjb8AxekaPaiBdxaPadBdwaPaeBdlavakaqci9Ug8Aaka8Aak6EaHEgK9RhEaxaK9Rh3aKcufh5aKceth8EaKcdtgCc98fh8FavcitgOaC9Rarfc98fhaascufhhavcufhgaraOfh8JJbbjZas:Y:vh8KcbazceakaxSEg8Lcdtg8M9Rh8NJFFuuhycuh8PcbhIcbh8RinaPclfa8RcdtfydbhQaPcb8Pd:y:G:cjbg8S83i9iaPcb8Pd:q:G:cjbgR83inaPcb8Pd1:G:cjbg8U83iUaPcb8Pdj:G:cjbg8V83i8WaPa8S83iyaPaR83iaaPa8U83iKaPa8V83izaQavcdtgYfh8WcbhXinabaQaXcdtgLfydbcK2fhAcbhzinaPc8WfazfgCaAazfgOIdbg8XaCIdbg8Ya8Xa8Y9DEUdbaCczfgCaOcxfIdbg8XaCIdbg8Ya8Xa8Y9EEUdbazclfgzcx9hmbkaba8WaXcu7cdtfydbcK2fhAcbhzaPIdUh8ZaPId9ih80aPId80h81aPId9ehBaPId8Wh83aPIdnhUinaPczfazfgCaAazfgOIdbg8XaCIdbg8Ya8Xa8Y9DEUdbaCczfgCaOcxfIdbg8XaCIdbg8Ya8Xa8Y9EEUdbazclfgzcx9hmbkaraLfgzaBa81:tg8Xa80a8Z:tg8YNaUa83:tg8Za8XNa8Za8YNMMUdbazaYfaPId8KaPIdC:tg8XaPIdyaPIdK:tg8YNaPIdaaPIdz:tg8Za8XNa8Za8YNMMUdbaXcefgXav9hmbkcbh85dnaHmbcbhAaQhza8JhCavhXinawaDazydbcx2fgOcwfydbcetfgL8Vebh8WawaOclfydbcetfg858Vebh86awaOydbcetfgO8Vebh87aLce87eba85ce87ebaOce87ebaCaAa86cs4a87cs4fa8Wcs4ffgABdbazclfhzaCclfhCaXcufgXmbkavhCinawaDaQydbcx2fgzcwfydbcetfcFFi87ebawazclfydbcetfcFFi87ebawazydbcetfcFFi87ebaQclfhQaCcufgCmbka8Jh85kdndndndndndndndndndndnava8E6mba8Eax9nmeavavaK9UgzaK29Raza320mda5aE9pmqa85Th87ceh8WaEhQxwka5ag9pmDa8Eax9nmixokavaK6mea5aE9pmwcehQaEhXa85Tmixlka5ag6mlxrka5ag9pmokcbhQaghXa85mekJFFuuh8XcbhLa5hzindnazcefgCaK6mbaQavaC9RgOaK6GmbarazcdtfIdbg8YaC:YNaravaz9RcdtfaYfc94fIdbg8ZaO:YNMg80a8X9Embdndna8KaOahf:YNg81:lJbbb9p9DTmba81:OhAxekcjjjj94hAka8ZasaA2aO9R:YNh8Zdndna8Kazasf:YNg81:lJbbb9p9DTmba81:OhOxekcjjjj94hOkamasaO2aC9R:Ya8YNa8ZMNa80Mg8Ya8Xa8Ya8X9DgOEh8XaCaLaOEhLkaza8LfgzaX6mbxlkkJFFuuh8XcbhLaEhCaahAa8FhOaKhzindnazaK6mbaQaCaK6GmbaraOfIdbg8Yaz:YNaAIdbg8ZaC:YNMg80a8X9Embdndna8Ka85aOfydbgYahf:YNg81:lJbbb9p9DTmba81:Oh8Wxekcjjjj94h8Wkamasa8W2aY9R:Yg81a8YNa8Za81NMNa80Mg8Ya8Xa8Ya8X9DgYEh8XazaLaYEhLkaCa8L9RhCaAa8NfhAaOa8MfhOaza8LfgzcufaX6mbxikka85Th87cbh8WaghQkJFFuuh8XcbhLaEhCaahAa8FhOaKhzindnazazaK9UgXaK29RaXa320mbdna8WTmbaCaCaK9UgXaK29RaXa320mekaraOfIdbg8Yaz:YNaAIdbg8ZaC:YNMg80a8X9EmbazhXaChYdna87mba85aOfydbgXhYkdndna8KaYahf:YNg81:lJbbb9p9DTmba81:Oh86xekcjjjj94h86ka8Zasa862aY9R:YNh8Zdndna8KaXahf:YNg81:lJbbb9p9DTmba81:OhYxekcjjjj94hYkamasaY2aX9R:Ya8YNa8ZMNa80Mg8Ya8Xa8Ya8X9DgXEh8XazaLaXEhLkaCa8L9RhCaAa8NfhAaOa8MfhOaza8LfgzcufaQ6mbkkaLTmba8Xay9DTmba8XhyaLhIa8Rh8Pka8Rcefg8Rci9hmbkdndnaoc8X9kmba8Pcb9omeka8Acufh85cbhYindndndnavaY9RaxaYaxfav0Eg8WTmbcbhAaeaYcdtfgzhCa8WhXinawaDaCydbcx2fgOcwfydbcetfgQ8VebhbawaOclfydbcetfgL8VebhrawaOydbcetfgO8VebhKaQce87ebaLce87ebaOce87ebaAarcs4aKcs4fabcs4ffhAaCclfhCaXcufgXmbka8WhOinawaDazydbcx2fgCcwfydbcetfcFFi87ebawaCclfydbcetfcFFi87ebawaCydbcetfcFFi87ebazclfhzaOcufgOmbkaAaq0mekalaYfgzce86bbazcefcba8Wcufz:rjjjb8AxekalaYfgzce86bbazcefcba85z:rjjjb8Aa8Ah8Wka8WaYfgYav9pmdxbkkaravcdtg8WfhLdnaITmbaPclfa8PcdtfydbhzaIhCinaLazydbfcb86bbazclfhzaCcufgCmbkkdnavaI9nmbaPclfa8PcdtfydbaIcdtfhzavaI9RhCinaLazydbfce86bbazclfhzaCcufgCmbkkcbhYindnaYa8PSmbcbhzaraPclfaYcdtfydbgKa8Wz:qjjjbhCavhXaIhOinaKaOazaLaCydbgQfRbbgAEcdtfaQBdbaCclfhCaOaAfhOazaA9RcefhzaXcufgXmbkkaYcefgYci9hmbkabaeadaialaIaocefgCarawaDaqakaxamz:hjjjbabaeaIcdtgzfadazfaiazfalaIfavaI9RaCarawaDaqakaxamz:hjjjbkaPc;qbf8Kjjjjbk:Seeru8Jjjjjbc:q;ab9Rgo8Kjjjjbaoc:q8WfcFecjzz:rjjjb8AcbhrdnadTmbaehwadhDinaoarcdtfawydbgqBdbaoc:q8WfaqcFiGcdtfgkydbhxakaqBdbawclfhwaraxaq9hfhraDcufgDmbkkabaeadaoaraiavz:jjjjbaoc:q;abf8Kjjjjbk;Sqloud99euD998Jjjjjbc:W;ab9Rgr8KjjjjbdndnadTmbaocd4hwcbhDcbhqindnavaeclfydbaw2cdtfgkIdbavaeydbaw2cdtfgxIdbgm:tgPavaecwfydbaw2cdtfgsIdlaxIdlgz:tgHNakIdlaz:tgOasIdbam:tgAN:tgCaCNaOasIdwaxIdwgX:tgQNakIdwaX:tgOaHN:tgHaHNaOaANaPaQN:tgPaPNMMgOJbbbb9Bmbarc8WfaDcltfgkaCaO:rgO:vgCUdwakaPaO:vgPUdlakaHaO:vgHUdbakaCaXNaHamNazaPNMM:mUdxaDcefhDkaecxfheaqcifgqad6mbkab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbaDTmearcbBd8Sar9cb83iKar9cb83izarczfavalaoarc8Sfcbcraiz:kjjjbarIdKhQarIdChLarIdzhKar9cb83iwar9cb83ibararc8WfaDczarc8Sfcbcicbz:kjjjbJbbbbhmdnarIdwgzazNarIdbgHaHNarIdlgXaXNMMgCJbbbb9BmbJbbjZaC:r:vhmkazamNhCaXamNhXaHamNhHJbbjZhmarc8WfheaDhvinaecwfIdbaCNaeIdbaHNaXaeclfIdbNMMgzamazam9DEhmaeczfheavcufgvmbkabaQUdwabaLUdlabaKUdbabarId3UdxdndnamJ;n;m;m899FmbJbbbbhzarc8WfheinaecxfIdbaQaecwfIdbgPNaKaeIdbgONaLaeclfIdbgANMMMaCaPNaHaONaXaANMM:vgPazaPaz9EEhzaeczfheaDcufgDmbkabaCUd8KabaXUdaabaHUd3abaQaCazN:tUdKabaLaXazN:tUdCabaKaHazN:tUdzabJbbjZamamN:t:rgmUdydndnaCJbbj:;aCJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aCJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohexekcjjjj94hekabae86b8UdndnaXJbbj:;aXJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aXJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohvxekcjjjj94hvkabav86bRdndnaHJbbj:;aHJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aHJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohwxekcjjjj94hwkabaw86b8SdndnaecKtcK91:YJbb;:9c:vaC:t:lavcKtcK91:YJbb;:9c:vaX:t:lawcKtcK91:YJbb;:9c:vaH:t:lamMMMJbb;:9cNJbbjZMgm:lJbbb9p9DTmbam:Ohexekcjjjj94hekaecFbaecFb9iEhexekabcjjj;8iBdycFbhekabae86b8Vxekab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbkarc:W;abf8Kjjjjbk;7woDuo99eue99euv998Jjjjjbcje9Rgw8Kjjjjbawc;abfcbaocdtgDz:rjjjb8Aawc;GbfcbaDz:rjjjb8AawcafhDawhqaohkinaqcFFF97BdbaDcFFF;7rBdbaqclfhqaDclfhDakcufgkmbkavcd4hxaicd4hmdnadTmbaocx2hPcbhsinashzdnarTmbarascdtfydbhzkaeazam2cdtfgDIdwhHaDIdlhOaDIdbhAalazax2cdtfIdbhCcbhDawcafhqawc;Gbfhvawhkawc;abfhiinaCaDc:O:G:cjbfIdbaHNaDc:G:G:cjbfIdbaANaDc:K:G:cjbfIdbaONMMgXMhQazhLdnaXaC:tgXaqIdbgK9DgYmbavydbhLkavaLBdbazhLdnaQakIdbg8A9EmbaiydbhLa8AhQkaiaLBdbakaQUdbaqaXaKaYEUdbaiclfhiakclfhkavclfhvaqclfhqaPaDcxfgD9hmbkascefgsad9hmbkkJbbbbhQcbhLawc;GbfhDawc;abfhqcbhkinalaqydbgvax2cdtfIdbalaDydbgiax2cdtfIdbaeavam2cdtfgvIdwaeaiam2cdtfgiIdw:tgCaCNavIdbaiIdb:tgCaCNavIdlaiIdl:tgCaCNMM:rMMgCaQaCaQ9EgvEhQakaLavEhLaqclfhqaDclfhDaoakcefgk9hmbkJbbbbhCdnaeawc;abfaLcdtgqfydbgkam2cdtfgDIdwaeawc;Gbfaqfydbgvam2cdtfgqIdwgH:tgXaXNaDIdbaqIdbgA:tg8Aa8ANaDIdlaqIdlgE:tgOaONMMgKJbbbb9ETmbaK:rgCalakax2cdtfIdbMalavax2cdtfIdb:taCaCM:vhCkaQJbbbZNhKaXaCNaHMhHaOaCNaEMhOa8AaCNaAMhAdnadTmbcbhqarhkinaqhDdnarTmbakydbhDkdnalaDax2cdtfIdbg3aeaDam2cdtfgDIdwaH:tgQaQNaDIdbaA:tgCaCNaDIdlaO:tgXaXNMMg5:rgEMg8EaK9ETmbJbbbbh8Adna5Jbbbb9ETmba8EaK:taEaEM:vh8Aka8AaQNaHMhHa8AaXNaOMhOa8AaCNaAMhAa3aKaEMMJbbbZNhKkakclfhkadaqcefgq9hmbkkabaKUdxabaHUdwabaOUdlabaAUdbawcjef8Kjjjjbk:reevu8Jjjjjbcj8W9Rgr8Kjjjjbaici2hwcbhDdnaiTmbarhiawhqinaiaeadRbbgkcdtfydbBdbaDakcefgkaDak0EhDaiclfhiadcefhdaqcufgqmbkkabarawaeaDalaoz:jjjjbarcj8Wf8Kjjjjbk:Eeeeu8Jjjjjbca9Rgo8Kjjjjbab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbdnadTmbaocbBd3ao9cb83iwao9cb83ibaoaeadaialaoc3falEavcbalEcrcbz:kjjjbabao8Pib83dbabao8Piw83dwkaocaf8Kjjjjbk::meQu8Jjjjjbcjz9Rgv8KjjjjbcbhoavcjPfcbaez:rjjjb8Aavcjxfcbaez:rjjjb8AdnaiTmbadhoaihrinavcjxfaoRbbfgwawRbbcef86bbavcjxfaocefRbbfgwawRbbcef86bbavcjxfaocdfRbbfgwawRbbcef86bbaocifhoarcufgrmbkcbhDcjehoadhqcehkindndnalTmbcbhxcuhmaqhrakhwcuhPinawcufamaoavcjPfarcefRbbgsfRbb9RcFeGgzci6aoavcjPfarRbbgHfRbb9RcFeGgOci6faoavcjPfarcdfRbbgAfRbb9RcFeGgCci6fgXcOtaOcFr7azaCf9RcwtVavcjxfaAfRbbgzavcjxfaHfRbbgHavcjxfasfRbbgsaHas6Egsazas6EcFe7VgsaP9kgzEhmaXcd6gHaxcefgOal9iVce9hmdasaPazEhPaxaOaHEhxarcifhrawai6hsawcefhwasmbxdkkcuhmaqhrakhwcuhxinawcufamaoavcjPfarcefRbbfRbb9RcFeGci6aoavcjPfarRbbfRbb9RcFeGci6faoavcjPfarcdfRbbfRbb9RcFeGci6fgPax9kgsEhmaPce0meaPaxasEhxarcifhrawai6hPawcefhwaPmbkkadamci2fgrcdfRbbhwarcefRbbhxarRbbhPadaDci2fgrcifaramaD9Rci2zNjjjb8AaPavcjPffaocefgo86bbaPavcjxffgmamRbbcuf86bbaxavcjPffao86bbaxavcjxffgmamRbbcuf86bbarcdfaw86bbarcefax86bbaraP86bbawavcjPffao86bbawavcjxffgrarRbbcuf86bbaqcifhqakcefhkaDcefgDai9hmbkcbhzdnalcb9mmbcbhsavcjPfcbaez:rjjjb8Aadcvfhlinadasci2fgxcefgDRbbhoaxcdfgqRbbhrdndnavcjPfaxRbbgmfRbbmbavcjPfarfRbbhwdndndnavcjPfaofRbbTmbawcFeGTmexikawcFeGmdascefgAai9pmdasc980mdascifhQcbhLarcFeGhCamcFeGhXalhwcbhKcbhYinawcufRbbhPawRbbhOcehkdndnawc9:fRbbgHao9hmbaPcFeGamSmekdnaPcFeGao9hmbaOcFeGamSmekaHamSaOcFeGaoSGhkkceh8AaYceGhYdndnaHar9hmbaPcFeGaoSmekdnaPcFeGar9hmbaOcFeGaoSmekaHaoSaOcFeGarSGh8AkakaYVhYaLaHcFeGgHaXSaPcFeGgPaCSGaPaXSaOcFeGgPaCSGVaHaCSaPaXSGVVhLa8AaKceGVhKdnaAcefgPai9pmbawcifhwaAaQ6hHaPhAaHmekkaYTmeaKmekarhwaohPaohHarhOamhrxdkdnaYTaLVceGTmbaYaKTVaLVceGmekamhwarhParhHamhOaohrxekaohwamhPamhHaohOkavcjPfarfce86bbavcjPfawfce86bbaxaH86bbaqar86bbaDaO86bbavcjPfaPfce86bbalcifhlascefgsai9hmbkkavcFeaecetz:rjjjbhwaici2hrindnawadRbbgmcetfgx8Uebgocu9kmbaxaz87ebawcjlfazcdtfabamcdtfydbBdbazhoazcefhzkadao86bbadcefhdarcufgrmbkazcdthokabavcjlfaoz:qjjjb8Aavcjzf8KjjjjbkObabaiaeadcbz:njjjbk9teiucbcbyd;8:G:cjbgeabcifc98GfgbBd;8:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd;8:G:cjbgeabcrfc94GfgbBd;8:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd;8:G:cjbge9Rcifc98GaefgbBd;8:G:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akk:3qeludndnadch6mbadTmeabaead;8qbbabskabaeSmbdnaeadabfgi9Rcbadcet9R0mbadTmeabaead;8qbbabskaeab7ciGhldndndnabae9pmbdnalTmbadhvabhixikdnabciGmbadhvabhixdkadTmiabaeRbb86bbadcufhvdnabcefgiciGmbaecefhexdkavTmiabaeRbe86beadc9:fhvdnabcdfgiciGmbaecdfhexdkavTmiabaeRbd86bdadc99fhvdnabcifgiciGmbaecifhexdkavTmiabaeRbi86biabclfhiaeclfheadc98fhvxekdnalmbdnaiciGTmbadTmlabadcufgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc9:fgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc99fgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc98fgdfaeadfRbb86bbkadcl6mbdnadc98fgocxGcxSmbaocd4cefciGhiaec98fhlabc98fhvinavadfaladfydbBdbadc98fhdaicufgimbkkaocx6mbaec9Wfhvabc9WfhoinaoadfgicxfavadfglcxfydbBdbaicwfalcwfydbBdbaiclfalclfydbBdbaialydbBdbadc9Wfgdci0mbkkadTmdadhidnadciGglTmbaecufhvabcufhoadhiinaoaifavaifRbb86bbaicufhialcufglmbkkadcl6mdaec98fhlabc98fhvinavaifgecifalaifgdcifRbb86bbaecdfadcdfRbb86bbaecefadcefRbb86bbaeadRbb86bbaic98fgimbxikkavcl6mbdnavc98fglc3Gc3Smbavalcd4cefcrGgdcdt9RhvinaiaeydbBdbaeclfheaiclfhiadcufgdmbkkalc36mbinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfaeczfydbBdbaicCfaecCfydbBdbaicKfaecKfydbBdbaic3faec3fydbBdbaecafheaicafhiavc9Gfgvci0mbkkavTmbdndnavcrGgdmbavhlxekavc94GhlinaiaeRbb86bbaicefhiaecefheadcufgdmbkkavcw6mbinaiaeRbb86bbaicefaecefRbb86bbaicdfaecdfRbb86bbaicifaecifRbb86bbaiclfaeclfRbb86bbaicvfaecvfRbb86bbaicofaecofRbb86bbaicrfaecrfRbb86bbaicwfhiaecwfhealc94fglmbkkabkk:pedbcj:GdktFFuuFFuuFFuubbbbFFuFFFuFFFuFbbbbbbjZbbbbbbbbbbbbbbjZbbbbbbbbbbbbbbjZ86;nAZ86;nAZ86;nAZ86;nA:;86;nAZ86;nAZ86;nAZ86;nA:;86;nAZ86;nAZ86;nAZ86;nA:;bc;0:Gdkxebbbdbbbj:qbb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,i=WebAssembly.instantiate(r(e),{}).then(function(m){n=m.instance,n.exports.__wasm_call_ctors()});function r(m){var g=new Uint8Array(m.length);for(var p=0;p<m.length;++p){var x=m.charCodeAt(p);g[p]=x>96?x-97:x>64?x-39:x+4}var _=0;for(var p=0;p<m.length;++p)g[_++]=g[p]<60?t[g[p]]:(g[p]-60)*64+g[++p];return g.buffer.slice(0,_)}function s(m){if(!m)throw Error("Assertion failed")}function a(m){return new Uint8Array(m.buffer,m.byteOffset,m.byteLength)}var o=48,c=16;function l(m,g){var p=m.meshlets[g*4+0],x=m.meshlets[g*4+1],_=m.meshlets[g*4+2],y=m.meshlets[g*4+3];return{vertices:m.vertices.subarray(p,p+_),triangles:m.triangles.subarray(x,x+y*3)}}function u(m,g,p,x,_,y,v,T,A,E){var w=n.exports.sbrk,P=n.exports.meshopt_buildMeshletsBound(g.length,y,v),S=w(P*c),I=w(g.length*4),U=w(g.length),N=w(g.byteLength),F=w(p.byteLength),D=new Uint8Array(n.exports.memory.buffer);D.set(a(g),N),D.set(a(p),F);var O=m(S,I,U,N,g.length,F,x,_,y,v,T,A,E);D=new Uint8Array(n.exports.memory.buffer);var K=D.subarray(S,S+O*c),B=new Uint32Array(K.buffer,K.byteOffset,K.byteLength/4).slice();for(var X=0;X<O;++X){var q=B[X*4+0],le=B[X*4+1],x=B[X*4+2],de=B[X*4+3];n.exports.meshopt_optimizeMeshlet(I+q*4,U+le,de,x)}var Me=O?B[(O-1)*4+0]+B[(O-1)*4+2]:0,pe=O?B[(O-1)*4+1]+B[(O-1)*4+3]*3:0,J={meshlets:B,vertices:new Uint32Array(D.buffer,I,Me).slice(),triangles:new Uint8Array(D.buffer,U,pe).slice(),meshletCount:O};return w(S-w(0)),J}function d(m){var g=new Float32Array(n.exports.memory.buffer,m,o/4);return{centerX:g[0],centerY:g[1],centerZ:g[2],radius:g[3],coneApexX:g[4],coneApexY:g[5],coneApexZ:g[6],coneAxisX:g[7],coneAxisY:g[8],coneAxisZ:g[9],coneCutoff:g[10]}}function f(m,g,p,x){var _=n.exports.sbrk,y=[],v=_(g.byteLength),T=_(m.vertices.byteLength),A=_(m.triangles.byteLength),E=_(o),w=new Uint8Array(n.exports.memory.buffer);w.set(a(g),v),w.set(a(m.vertices),T),w.set(a(m.triangles),A);for(var P=0;P<m.meshletCount;++P){var S=m.meshlets[P*4+0],I=m.meshlets[P*4+1],U=m.meshlets[P*4+3];n.exports.meshopt_computeMeshletBounds(E,T+S*4,A+I,U,v,p,x),y.push(d(E))}return _(v-_(0)),y}function h(m,g,p,x){var _=n.exports.sbrk,y=_(o),v=_(m.byteLength),T=_(g.byteLength),A=new Uint8Array(n.exports.memory.buffer);A.set(a(m),v),A.set(a(g),T),n.exports.meshopt_computeClusterBounds(y,v,m.length,T,p,x);var E=d(y);return _(y-_(0)),E}function b(m,g,p,x,_){var y=n.exports.sbrk,v=y(o),T=y(m.byteLength),A=x?y(x.byteLength):0,E=new Uint8Array(n.exports.memory.buffer);if(E.set(a(m),T),x)E.set(a(x),A);n.exports.meshopt_computeSphereBounds(v,T,g,p,A,x?_:0);var w=d(v);return y(v-y(0)),w}return{ready:i,supported:!0,buildMeshlets:function(m,g,p,x,_,y){s(m.length%3==0),s(g instanceof Float32Array),s(g.length%p==0),s(p>=3),s(x>=3&&x<=256),s(_>=1&&_<=512),y=y||0;var v=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return u(n.exports.meshopt_buildMeshletsFlex,v,g,g.length/p,p*4,x,_,_,y,0)},buildMeshletsFlex:function(m,g,p,x,_,y,v,T){s(m.length%3==0),s(g instanceof Float32Array),s(g.length%p==0),s(p>=3),s(x>=3&&x<=256),s(_>=1&&y<=512),s(_<=y),v=v||0,T=T||0;var A=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return u(n.exports.meshopt_buildMeshletsFlex,A,g,g.length/p,p*4,x,_,y,v,T)},buildMeshletsSpatial:function(m,g,p,x,_,y,v){s(m.length%3==0),s(g instanceof Float32Array),s(g.length%p==0),s(p>=3),s(x>=3&&x<=256),s(_>=1&&y<=512),s(_<=y),v=v||0;var T=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return u(n.exports.meshopt_buildMeshletsSpatial,T,g,g.length/p,p*4,x,_,y,v)},extractMeshlet:function(m,g){return s(g>=0&&g<m.meshletCount),l(m,g)},computeClusterBounds:function(m,g,p){s(m.length%3==0),s(m.length/3<=512),s(g instanceof Float32Array),s(g.length%p==0),s(p>=3);var x=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return h(x,g,g.length/p,p*4)},computeMeshletBounds:function(m,g,p){return s(g instanceof Float32Array),s(g.length%p==0),s(p>=3),f(m,g,g.length/p,p*4)},computeSphereBounds:function(m,g,p,x){return s(m instanceof Float32Array),s(m.length%g==0),s(g>=3),s(!p||p instanceof Float32Array),s(!p||p.length%x==0),s(!p||x>=1),s(!p||m.length/g==p.length/x),x=x||0,b(m,m.length/g,g*4,p,x*4)}}}()});var bR={};Pb(bR,{MeshoptEncoder:()=>lB});var xR=mt(()=>{hR();pR();mR();gR()});function ic(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function Lf(e,t="|"){return e.map((n)=>Bf(n)).join(t)}function rc(e,t){if(typeof t==="bigint")return t.toString();return t}class Ob{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function sc(e){return new Ob(e)}function kb(e){return e===null||e===void 0}function Yr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Db(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function mi(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ac(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Sr(e){return ac(e._zod.def)??e._zod.def.shape}function Lb(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return mi(this,t,i),i},enumerable:!0,configurable:!0})}function Fb(e,t,n){if(t in e)mi(e,t,n);else e[t]=n}function ia(e,t,n,i){let r=Sr(t);for(let s of n){let a=Object.getOwnPropertyDescriptor(r,s);if(!a.enumerable)continue;if(a.get)Lb(e,s,()=>{let o=t._zod.def.shape[s];return i?i(o,s):o});else Fb(e,s,i?i(a.value,s):a.value)}}function oI(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)Lb(e,n,()=>t[n]);else Fb(e,n,i.value)}}function Qn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function Ub(e){return JSON.stringify(e)}function Bb(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Ff="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ja(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var zb=sc(()=>{if(Un.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function ra(e){if(ja(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(ja(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Uf(e){if(ra(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Vb=new Set(["string","number","symbol"]),jb=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Rr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ji(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function Fe(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Bf(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Hb(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var jl=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),zf={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function cI(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return ia(s,e,Hl(e,t)),Ji(e,Qn(n,{shape:s,checks:[]}))}function Hl(e,t){let n=Sr(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function lI(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Hl(e,t)),a={};return ia(a,e,Reflect.ownKeys(Sr(e)).filter((o)=>!s.has(o))),Ji(e,Qn(n,{shape:a,checks:[]}))}function uI(e,t){if(!ra(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Sr(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Ji(e,Qn(e._zod.def,{shape:Gb(e,t)}))}function Gb(e,t){let n={};return ia(n,e,Reflect.ownKeys(Sr(e))),oI(n,t),n}function dI(e,t){if(!ra(t))throw Error("Invalid input to safeExtend: expected a plain object");return Ji(e,Qn(e._zod.def,{shape:Gb(e,t)}))}function fI(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};ia(n,e,Reflect.ownKeys(Sr(e))),ia(n,t,Reflect.ownKeys(Sr(t)));let i=Qn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Ji(e,i)}function $b(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let o=n?new Set(Hl(t,n)):void 0,c={};return ia(c,t,Reflect.ownKeys(Sr(t)),e&&((l,u)=>o&&!o.has(u)?l:new e({type:"optional",innerType:l}))),Ji(t,Qn(t._zod.def,{shape:c,checks:[]}))}function hI(e,t,n){let i=n?new Set(Hl(t,n)):void 0,r={};return ia(r,t,Reflect.ownKeys(Sr(t)),(s,a)=>i&&!i.has(a)?s:new e({type:"nonoptional",innerType:s})),Ji(t,Qn(t._zod.def,{shape:r}))}function gi(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Kb(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Zi(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function nc(e){return typeof e==="string"?e:e?.message}function Vf(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function Yi(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,a=e.message?e.message:nc(e.inst?._zod.def?.error?.(e))??nc(s?.(e))??nc(t?.error?.(e))??nc(n.customError?.(e))??nc(n.localeError?.(e))??"Invalid input",o={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;o[c]=e[c]}if(o.path??(o.path=[]),o.message=a,t?.reportInput)o.input=e.input;return o}var pI=/[\uD800-\uDBFF]/;function Gl(e){let t=e.length;if(!pI.test(e))return t;let n=t;for(let i=0;i<t-1;i++)if((e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320)n--,i++;return n}function $l(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Wb(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function sa(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function Xb(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else mI(e,n,i.value)}}function Mr(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function Kl(e,t,n){return Mr(e,t,n,!1)}function qb(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Mr(this,n,i(this))},set(r){Mr(this,n,r)}})}return t}function mI(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Mr(this,t,n.bind(this))},set(i){Mr(this,t,i)}})}function gI(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Df,Zr=!1,bI={configurable:!0,get(){Zr=!0;return}};function Et(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&Df!==e._zod){Df=void 0;return}Df=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,bI);let r=Zr;Zr=!1;try{let s=n(this);if(Zr)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Zr=Zr||r,s}catch(s){throw delete this[t],Zr=Zr||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function xI(e,t,n,i){let r=gI(e,t);if(!r)return;Object.defineProperty(r,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:s})}})}var yI="~constantCatch";function Jb(e){let t=()=>e;return t[yI]=!0,t}var Zb;var jf={value:void 0,enumerable:!1},Yb="captureStackTrace"in Error?Error:null;function _I(e){let t=Yb;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Yb=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function se(e,t,n,i){let r={};function s(f){this.def=f,this.constr=d,this.traits=new Set}s.prototype=r;let a=n,o=a&&new WeakSet;function c(f,h){if(!f._zod){jf.value=new s(h);try{Object.defineProperty(f,"_zod",jf)}finally{jf.value=void 0}}else if(f._zod.traits.has(e))return;if(f._zod.traits.add(e),t(f,h),o){let m=Object.getPrototypeOf(f),g=f._zod.constr.prototype,p=m;while(p&&p!==g)p=Object.getPrototypeOf(p);let x=p??m;if(!o.has(x))o.add(x),Xb(x,a)}let b=d.prototype;for(let m in b){if(!Object.prototype.hasOwnProperty.call(b,m))continue;if(!(m in f))f[m]=b[m].bind(f)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(f){let h=i?.Parent?_I(u):this;c(h,f);let b=h._zod.deferred;if(b){for(let g of b)g();h._zod.deferred=void 0}let m=globalThis.__zod_globalConfig?.postProcessor;if(m)m(h);return h}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:(f)=>{if(i?.Parent&&f instanceof i.Parent)return!0;return f?._zod?.traits?.has(e)}}),Object.defineProperty(d,"name",{value:e}),d}class Qi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class oc extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Zb=globalThis).__zod_globalConfig??(Zb.__zod_globalConfig={});var Un=globalThis.__zod_globalConfig;function ei(e){if(e)Object.assign(Un,e);return Un}function vI(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,rc,2)),e.message}function EI(e){this._zod.message=e}var TI={get:vI,set:EI,enumerable:!0,configurable:!0},Gf={value:void 0,enumerable:!1},Qb=new WeakSet([Object.prototype,Error.prototype]),ex=(e,t)=>{e.name="$ZodError",Gf.value=t,Object.defineProperty(e,"issues",Gf),Gf.value=void 0,Object.defineProperty(e,"message",TI);let n=Object.getPrototypeOf(e);if(!Qb.has(n))Qb.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}})},tx=se("$ZodError",ex),IB=se("$ZodError",ex,void 0,{Parent:Error});function AI(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function nx(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)AI(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function ix(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let a of r.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map((o)=>i({issues:o},[...s,...a.path]));else if(a.code==="invalid_key")i({issues:a.issues},[...s,...a.path]);else if(a.code==="invalid_element")i({issues:a.issues},[...s,...a.path]);else{let o=[...s,...a.path];if(o.length===0)n._errors.push(t(a));else{let c=n,l=0;while(l<o.length){let u=o[l],d=l===o.length-1;if(u==="_errors"){if(d)c._errors.push(t(a));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[u];if(d)f._errors.push(t(a));c=f,l++}}}};return i(e),n}function Wl(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Xl=(e)=>{let t=(n,i,r,s)=>{let a=r?{...r,async:!1}:{async:!1},o=n._zod.run({value:i,issues:[]},a);if(o instanceof Promise)throw new Qi;if(o.issues.length){let c=new(s?.Err??e)(o.issues.map((l)=>Yi(l,a,ei())));throw Ff(c,s?.callee??t),c}return o.value};return t};var ql=(e)=>{let t=async(n,i,r,s)=>{let a=r?{...r,async:!0}:{async:!0},o=n._zod.run({value:i,issues:[]},a);if(o instanceof Promise)o=await o;if(o.issues.length){let c=new(s?.Err??e)(o.issues.map((l)=>Yi(l,a,ei())));throw Ff(c,s?.callee??t),c}return o.value};return t};var Jl=(e)=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new Qi;return s.issues.length?rx(e,s.issues,r):{success:!0,data:s.value}};function rx(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>Yi(r,n,ei()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Zl=(e)=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?rx(e,s.issues,r):{success:!0,data:s.value}};var wI=Symbol.for("zod.compile.invalid"),SI=Symbol.for("zod.compile.fallback"),$f=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==wI)return!0;if(i.definite===!0&&n===void 0)return!1}return MI(e,t,n)};function MI(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[SI]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Qi;return s.issues.length===0}var Kf=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)r=await r;return r.issues.length===0},sx=(e)=>{let t=Xl(e),n=(i,r,s,a)=>{let o=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,o,Wl(n,a))};return n};var ax=(e)=>{let t=Xl(e),n=(i,r,s,a)=>t(i,r,s,Wl(n,a));return n};var ox=(e)=>{let t=ql(e),n=async(i,r,s,a)=>{let o=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,o,Wl(n,a))};return n};var cx=(e)=>{let t=ql(e),n=async(i,r,s,a)=>await t(i,r,s,Wl(n,a));return n};var lx=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Jl(e)(t,n,r)};var ux=(e)=>(t,n,i)=>Jl(e)(t,n,i);var dx=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Zl(e)(t,n,r)};var fx=(e)=>async(t,n,i)=>Zl(e)(t,n,i);var hx=/^[cC][0-9a-z]{6,}$/,px=/^[0-9a-z]+$/,mx=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,gx=/^[0-9a-vA-V]{20}$/,bx=/^[A-Za-z0-9]{27}$/,xx=/^[a-zA-Z0-9_-]{21}$/;function yx(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var _x=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var vx=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Xf=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Ex=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var RI="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Tx(){return new RegExp(RI,"u")}var Ax=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,wx=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Sx=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Mx=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Rx=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ix=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Cx=/^https?$/,Nx=/^\+[1-9]\d{6,14}$/;var Px="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function II(e){return new RegExp(`^${e}$`)}var Ox=II(Px);function Wf(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function kx(e){return new RegExp(`^${Wf(e)}$`)}function Dx(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Wf({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Wf({precision:e.precision})}`:n;return new RegExp(`^${Px}T(?:${i})$`)}var Lx=/^[\s\S]{0,}$/,Fx=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Yl=/^-?\d+$/,Ha=/^-?\d+(?:\.\d+)?$/,Ux=/^(?:true|false)$/i;var Bx=/^[^A-Z]*$/,zx=/^[^a-z]*$/;var wn=se("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var qf=(e)=>{let t=e.value;return!kb(t)&&t.length!==void 0},Ql={number:"number",bigint:"bigint",object:"date"},Jf=se("$ZodCheckLessThan",(e,t)=>{wn.init(e,t);let n=Ql[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:Ql[typeof i.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Zf=se("$ZodCheckGreaterThan",(e,t)=>{wn.init(e,t);let n=Ql[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:Ql[typeof i.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Vx=se("$ZodCheckMultipleOf",(e,t)=>{wn.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Db(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),jx=se("$ZodCheckNumberFormat",(e,t)=>{wn.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=jl[t.format];e._zod.check=(a)=>{let o=a.value;if(n){if(!Number.isInteger(o)){a.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:o,inst:e});return}if(!Number.isSafeInteger(o)){if(o>0)a.issues.push({input:o,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else a.issues.push({input:o,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(o<r)a.issues.push({origin:"number",input:o,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(o>s)a.issues.push({origin:"number",input:o,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Hx=se("$ZodCheckMaxLength",(e,t)=>{var n;wn.init(e,t),(n=e._zod.def).when??(n.when=qf),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Gl(r):s)<=t.maximum)return;let o=$l(r);i.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Gx=se("$ZodCheckMinLength",(e,t)=>{var n;wn.init(e,t),(n=e._zod.def).when??(n.when=qf),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Gl(r):s)>=t.minimum)return;let o=$l(r);i.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$x=se("$ZodCheckLengthEquals",(e,t)=>{var n;wn.init(e,t),(n=e._zod.def).when??(n.when=qf),e._zod.check=(i)=>{let r=i.value,s=r.length,a=typeof r==="string"&&s>=t.length&&s<=t.length*2?Gl(r):s;if(a===t.length)return;let o=$l(r),c=a>t.length;i.issues.push({origin:o,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),lc=se("$ZodCheckStringFormat",(e,t)=>{var n,i;if(wn.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),Kx=se("$ZodCheckRegex",(e,t)=>{lc.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Wx=se("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Bx),lc.init(e,t)}),Xx=se("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=zx),lc.init(e,t)}),qx=se("$ZodCheckIncludes",(e,t)=>{wn.init(e,t);let n=Rr(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Jx=se("$ZodCheckStartsWith",(e,t)=>{wn.init(e,t);let n=new RegExp(`^${Rr(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),Zx=se("$ZodCheckEndsWith",(e,t)=>{wn.init(e,t);let n=new RegExp(`.*${Rr(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var Yx=se("$ZodCheckOverwrite",(e,t)=>{wn.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class Yf{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(``).filter((s)=>s),i=Math.min(...n.map((s)=>s.length-s.trimStart().length)),r=n.map((s)=>s.slice(i)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of r)this.content.push(s)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {${t.join(``)}-};`)(...Object.values(this.closed))}}var Ly={major:4,minor:6,patch:5};var Ut=se("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ly;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let a of s._zod.onattach)a(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(o,c,l)=>{if(o.memo)return o;let u=pi(o),d;for(let f of c){if(f._zod.def.when){if(Rb(o))continue;if(!f._zod.def.when(o))continue}else if(u)continue;let h=o.issues.length,y=f._zod.check(o);if(y instanceof Promise&&l?.async===!1)throw new Ji;if(d||y instanceof Promise)d=(d??Promise.resolve()).then(async()=>{if(await y,o.issues.length===h)return;if(Af(o.issues,h,e),!u)u=pi(o,h)});else{if(o.issues.length===h)continue;if(Af(o.issues,h,e),!u)u=pi(o,h)}}if(d)return d.then(()=>o);return o},a=(o,c,l)=>{if(pi(o))return o.aborted=!0,o;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new Ji;return u.then((d)=>e._zod.parse(d,l))}return e._zod.parse(u,l)};e._zod.run=(o,c)=>{if(c.skipChecks)return e._zod.parse(o,c);if(c.direction==="backward"){let u=e._zod.parse({value:o.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((d)=>a(d,o,c));return a(u,o,c)}let l=e._zod.parse(o,c);if(l instanceof Promise){if(c.async===!1)throw new Ji;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return Pl(this,"~standard",Uf(this))},set "~standard"(e){Sr(this,"~standard",e)}}),Jy=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>qi(n,t,Zn()))}:{value:e.value};async function ZR(e,t){let n={async:!0};return Jy(await e._zod.run({value:t,issues:[]},n),n)}function Uf(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return Jy(i,n)}catch(i){}return ZR(e,t)},vendor:"zod",version:1}}var Hl=se("$ZodString",(e,t)=>{Ut.init(e,t),e._zod.pattern=t.pattern??yy,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Gt=se("$ZodStringFormat",(e,t)=>{ec.init(e,t),Hl.init(e,t)}),Zy=se("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=iy),Gt.init(e,t)}),Yy=se("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Nf(i))}else t.pattern??(t.pattern=Nf());Gt.init(e,t)}),Qy=se("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ry),Gt.init(e,t)}),ex=1,Vl=2;function tx(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function YR(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return tx(e)||Vl;return QR(e,t)}function QR(e,t){if(!t.normalize&&t.protocol?.source===fy.source&&!/^https?:\/\//i.test(e))return ex;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Vl}return new URL(e)}catch{return Vl}}var eI=/[\t\n\r]/g;function Fy(e){return e.replace(eI,"")}function tI(e,t){return t.lastIndex=0,t.test(e.hostname)}function nI(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var nx=se("$ZodURL",(e,t)=>{Gt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=YR(i,t);if(r===ex){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===Vl){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=Fy(i);return}if(t.hostname&&!tI(r,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!nI(r,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?r.href:Fy(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),ix=se("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=sy()),Gt.init(e,t)}),rx=se("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?ey:ty(t.length)),Gt.init(e,t)}),sx=se("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=qb),Gt.init(e,t)}),ax=se("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Jb),Gt.init(e,t)}),ox=se("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Zb),Gt.init(e,t)}),cx=se("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Yb),Gt.init(e,t)}),lx=se("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Qb),Gt.init(e,t)}),ux=se("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=by(t)),Gt.init(e,t)}),dx=se("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=my),Gt.init(e,t)}),fx=se("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=gy(t)),Gt.init(e,t)}),hx=se("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ny),Gt.init(e,t)}),px=se("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ay),Gt.init(e,t)}),iI=/^[0-9a-fA-F:.]+$/;function mx(e){if(!iI.test(e))return!1;return tx(`http://[${e}]`)}var gx=se("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=oy),Gt.init(e,t),e._zod.check=(n)=>{if(!mx(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var bx=se("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=cy),Gt.init(e,t)});function rI(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);if(`${r}`!==i)return!1;if(r<0||r>128)return!1;return mx(n)}var yx=se("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ly),Gt.init(e,t),e._zod.check=(n)=>{if(!rI(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function xx(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Bf=/^[0-9a-zA-Z+/]*={0,2}$/,_x=se("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Bf),Gt.init(e,t),e._zod.check=(n)=>{if(xx(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Gl=/^[A-Za-z0-9_-]*$/;function sI(e){if(!Gl.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return xx(n)}var vx=se("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Gl),Gt.init(e,t),e._zod.check=(n)=>{if(sI(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Ex=se("$ZodE164",(e,t)=>{t.pattern??(t.pattern=hy),Gt.init(e,t)});function aI(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&(!("alg"in r)||r.alg!==t))return!1;return!0}catch{return!1}}var Tx=se("$ZodJWT",(e,t)=>{Gt.init(e,t),e._zod.check=(n)=>{if(aI(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var zf=se("$ZodNumber",(e,t)=>{Ut.init(e,t),e._zod.pattern=Fa,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(a){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),Ax=se("$ZodNumberFormat",(e,t)=>{Ay.init(e,t),zf.init(e,t)}),Sx=se("$ZodBoolean",(e,t)=>{Ut.init(e,t),e._zod.pattern=_y,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let r=n.value;if(typeof r==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});var wx=se("$ZodUnknown",(e,t)=>{Ut.init(e,t),e._zod.parse=(n)=>n}),Mx=se("$ZodNever",(e,t)=>{Ut.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Uy(e,t,n){if(e.issues.length)t.issues.push(...Xi(n,e.issues));t.value[n]=e.value}var Rx=se("$ZodArray",(e,t)=>{Ut.init(e,t);let n=Ln.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let a=[],o=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)a.push(u.then((d)=>Uy(d,i,c)));else if(Uy(u,i,c),o&&u.issues.length!==0&&pi(u))break}if(a.length)return Promise.all(a).then(()=>i);return i}});function jl(e,t,n,i,r,s){let a=n in i,o=s==="optional";if(!a&&o&&r==="optional")return;if(e.issues.length){if(r!==void 0&&o&&!a)return;t.issues.push(...Xi(n,e.issues))}if(!a&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(a||r==="defaulted"&&!o)t.value[n]=void 0}else t.value[n]=e.value}var oI=[];function Ix(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:oI,r=i.length?[...t,...i]:t;for(let a of r)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(a)}": expected a Zod schema`);let s=Sb(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Cx(e,t,n,i,r,s,a){let o=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:d,optout:f}=l,h=0;for(let y in t){if(a&&n.issues.length!==h){if(pi(n,h))break;h=n.issues.length}if(c.has(y))continue;if(y==="__proto__"){if(u==="never")o.push(y);continue}if(u==="never"){o.push(y);continue}let g=l.run({value:t[y],issues:[]},i);if(g instanceof Promise)e.push(g.then((m)=>jl(m,n,y,t,d,f)));else jl(g,n,y,t,d,f)}if(o.length)n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var cI=se("$ZodObject",(e,t)=>{Ut.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=Jo(()=>Ix(t));vt(e,"propValues",(l)=>{let u=l.def.shape,d={};for(let f in u){let h=u[f]._zod;if(h.values){if(!Object.prototype.hasOwnProperty.call(d,f))hi(d,f,new Set);for(let y of h.values)d[f].add(y);if(h.optin!==void 0)d[f].add(void 0)}}return d});let s=La,a=t.catchall,o,c=Ln.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{o??(o=r.value);let d=l.value;if(!s(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let f=[],h=o.shape,y=u?.abortEarly,g=l.issues.length;for(let m of o.allKeys){if(y&&l.issues.length!==g){if(pi(l,g))break;g=l.issues.length}if(m==="__proto__")continue;let p=h[m],b=p._zod.optin,_=p._zod.optout,x=p._zod.run({value:d[m],issues:[]},u);if(x instanceof Promise)f.push(x.then((v)=>jl(v,l,m,d,b,_)));else jl(x,l,m,d,b,_)}if(!a)return f.length?Promise.all(f).then(()=>l):l;return Cx(f,d,l,u,r.value,e,y===!0)}}),Nx=se("$ZodObjectJIT",(e,t)=>{cI.init(e,t);let n=e._zod.parse,i=Jo(()=>Ix(t)),r=Ln.memoizer,s=(h)=>{let y=i.value,g=y.symbolKeys,m=new Df(["payload","ctx"],{shape:h,inst:e,memo:r,syms:g}),p=(v)=>`shape[${v}]._zod.run({ value: input[${v}], issues: [] }, ctx)`,b=(v,E)=>`+};`)(...Object.values(this.closed))}}var ey={major:4,minor:6,patch:5};var Ut=se("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ey;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let a of s._zod.onattach)a(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(o,c,l)=>{if(o.memo)return o;let u=gi(o),d;for(let f of c){if(f._zod.def.when){if(Kb(o))continue;if(!f._zod.def.when(o))continue}else if(u)continue;let h=o.issues.length,b=f._zod.check(o);if(b instanceof Promise&&l?.async===!1)throw new Qi;if(d||b instanceof Promise)d=(d??Promise.resolve()).then(async()=>{if(await b,o.issues.length===h)return;if(Vf(o.issues,h,e),!u)u=gi(o,h)});else{if(o.issues.length===h)continue;if(Vf(o.issues,h,e),!u)u=gi(o,h)}}if(d)return d.then(()=>o);return o},a=(o,c,l)=>{if(gi(o))return o.aborted=!0,o;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new Qi;return u.then((d)=>e._zod.parse(d,l))}return e._zod.parse(u,l)};e._zod.run=(o,c)=>{if(c.skipChecks)return e._zod.parse(o,c);if(c.direction==="backward"){let u=e._zod.parse({value:o.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((d)=>a(d,o,c));return a(u,o,c)}let l=e._zod.parse(o,c);if(l instanceof Promise){if(c.async===!1)throw new Qi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return Kl(this,"~standard",th(this))},set "~standard"(e){Mr(this,"~standard",e)}}),py=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>Yi(n,t,ei()))}:{value:e.value};async function CI(e,t){let n={async:!0};return py(await e._zod.run({value:t,issues:[]},n),n)}function th(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return py(i,n)}catch(i){}return CI(e,t)},vendor:"zod",version:1}}var iu=se("$ZodString",(e,t)=>{Ut.init(e,t),e._zod.pattern=t.pattern??Lx,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),$t=se("$ZodStringFormat",(e,t)=>{lc.init(e,t),iu.init(e,t)}),my=se("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=vx),$t.init(e,t)}),gy=se("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Xf(i))}else t.pattern??(t.pattern=Xf());$t.init(e,t)}),by=se("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ex),$t.init(e,t)}),xy=1,tu=2;function yy(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function NI(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return yy(e)||tu;return PI(e,t)}function PI(e,t){if(!t.normalize&&t.protocol?.source===Cx.source&&!/^https?:\/\//i.test(e))return xy;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??tu}return new URL(e)}catch{return tu}}var OI=/[\t\n\r]/g;function ty(e){return e.replace(OI,"")}function kI(e,t){return t.lastIndex=0,t.test(e.hostname)}function DI(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var _y=se("$ZodURL",(e,t)=>{$t.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=NI(i,t);if(r===xy){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===tu){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=ty(i);return}if(t.hostname&&!kI(r,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!DI(r,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?r.href:ty(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),vy=se("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Tx()),$t.init(e,t)}),Ey=se("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?xx:yx(t.length)),$t.init(e,t)}),Ty=se("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=hx),$t.init(e,t)}),Ay=se("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=px),$t.init(e,t)}),wy=se("$ZodULID",(e,t)=>{t.pattern??(t.pattern=mx),$t.init(e,t)}),Sy=se("$ZodXID",(e,t)=>{t.pattern??(t.pattern=gx),$t.init(e,t)}),My=se("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=bx),$t.init(e,t)}),Ry=se("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Dx(t)),$t.init(e,t)}),Iy=se("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ox),$t.init(e,t)}),Cy=se("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=kx(t)),$t.init(e,t)}),Ny=se("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=_x),$t.init(e,t)}),Py=se("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ax),$t.init(e,t)}),LI=/^[0-9a-fA-F:.]+$/;function Oy(e){if(!LI.test(e))return!1;return yy(`http://[${e}]`)}var ky=se("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=wx),$t.init(e,t),e._zod.check=(n)=>{if(!Oy(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var Dy=se("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Sx),$t.init(e,t)});function FI(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);if(`${r}`!==i)return!1;if(r<0||r>128)return!1;return Oy(n)}var Ly=se("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Mx),$t.init(e,t),e._zod.check=(n)=>{if(!FI(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Fy(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var nh=/^[0-9a-zA-Z+/]*={0,2}$/,Uy=se("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=nh),$t.init(e,t),e._zod.check=(n)=>{if(Fy(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),ru=/^[A-Za-z0-9_-]*$/;function UI(e){if(!ru.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Fy(n)}var By=se("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ru),$t.init(e,t),e._zod.check=(n)=>{if(UI(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),zy=se("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Nx),$t.init(e,t)});function BI(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&(!("alg"in r)||r.alg!==t))return!1;return!0}catch{return!1}}var Vy=se("$ZodJWT",(e,t)=>{$t.init(e,t),e._zod.check=(n)=>{if(BI(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var ih=se("$ZodNumber",(e,t)=>{Ut.init(e,t),e._zod.pattern=Ha,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(a){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),jy=se("$ZodNumberFormat",(e,t)=>{jx.init(e,t),ih.init(e,t)}),Hy=se("$ZodBoolean",(e,t)=>{Ut.init(e,t),e._zod.pattern=Ux,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let r=n.value;if(typeof r==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});var Gy=se("$ZodUnknown",(e,t)=>{Ut.init(e,t),e._zod.parse=(n)=>n}),$y=se("$ZodNever",(e,t)=>{Ut.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function ny(e,t,n){if(e.issues.length)t.issues.push(...Zi(n,e.issues));t.value[n]=e.value}var Ky=se("$ZodArray",(e,t)=>{Ut.init(e,t);let n=Un.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let a=[],o=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)a.push(u.then((d)=>ny(d,i,c)));else if(ny(u,i,c),o&&u.issues.length!==0&&gi(u))break}if(a.length)return Promise.all(a).then(()=>i);return i}});function nu(e,t,n,i,r,s){let a=n in i,o=s==="optional";if(!a&&o&&r==="optional")return;if(e.issues.length){if(r!==void 0&&o&&!a)return;t.issues.push(...Zi(n,e.issues))}if(!a&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(a||r==="defaulted"&&!o)t.value[n]=void 0}else t.value[n]=e.value}var zI=[];function Wy(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:zI,r=i.length?[...t,...i]:t;for(let a of r)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(a)}": expected a Zod schema`);let s=Hb(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Xy(e,t,n,i,r,s,a){let o=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:d,optout:f}=l,h=0;for(let b in t){if(a&&n.issues.length!==h){if(gi(n,h))break;h=n.issues.length}if(c.has(b))continue;if(b==="__proto__"){if(u==="never")o.push(b);continue}if(u==="never"){o.push(b);continue}let m=l.run({value:t[b],issues:[]},i);if(m instanceof Promise)e.push(m.then((g)=>nu(g,n,b,t,d,f)));else nu(m,n,b,t,d,f)}if(o.length)n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var VI=se("$ZodObject",(e,t)=>{Ut.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=sc(()=>Wy(t));Et(e,"propValues",(l)=>{let u=l.def.shape,d={};for(let f in u){let h=u[f]._zod;if(h.values){if(!Object.prototype.hasOwnProperty.call(d,f))mi(d,f,new Set);for(let b of h.values)d[f].add(b);if(h.optin!==void 0)d[f].add(void 0)}}return d});let s=ja,a=t.catchall,o,c=Un.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{o??(o=r.value);let d=l.value;if(!s(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let f=[],h=o.shape,b=u?.abortEarly,m=l.issues.length;for(let g of o.allKeys){if(b&&l.issues.length!==m){if(gi(l,m))break;m=l.issues.length}if(g==="__proto__")continue;let p=h[g],x=p._zod.optin,_=p._zod.optout,y=p._zod.run({value:d[g],issues:[]},u);if(y instanceof Promise)f.push(y.then((v)=>nu(v,l,g,d,x,_)));else nu(y,l,g,d,x,_)}if(!a)return f.length?Promise.all(f).then(()=>l):l;return Xy(f,d,l,u,r.value,e,b===!0)}}),qy=se("$ZodObjectJIT",(e,t)=>{VI.init(e,t);let n=e._zod.parse,i=sc(()=>Wy(t)),r=Un.memoizer,s=(h)=>{let b=i.value,m=b.symbolKeys,g=new Yf(["payload","ctx"],{shape:h,inst:e,memo:r,syms:m}),p=(v)=>`shape[${v}]._zod.run({ value: input[${v}], issues: [] }, ctx)`,x=(v,T)=>`let ${v}_ab = false;for (let i = 0; i < ${v}.issues.length; i++) {const iss = ${v}.issues[i];- iss.path = iss.path ? [${E}, ...iss.path] : [${E}];+ iss.path = iss.path ? [${T}, ...iss.path] : [${T}];payload.issues.push(iss);if (iss.continue !== true) ${v}_ab = true;}if (${v}_ab && ctx && ctx.abortEarly) {payload.value = newResult;return payload;- }`;m.write("const input = payload.value;");let _=Object.create(null),x=0;for(let v of y.allKeys)_[v]=`key_${x++}`;m.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let v of y.allKeys){if(v==="__proto__")continue;let E=_[v],S=typeof v==="symbol"?`syms[${g.indexOf(v)}]`:_b(v),T=`${S} in input`,A=h[v],P=A?._zod?.optin,w=P!==void 0,I=A?._zod?.optout==="optional";if(m.write(`const ${E} = ${p(S)};`),w&&I){let F=P==="optional"?`${E}_present`:`${E}.value !== undefined || ${E}_present`;m.write(`- const ${E}_present = ${T};- if (!${E}.issues.length || ${E}_present) {- if (${E}.issues.length) {${b(E,S)}+ }`;g.write("const input = payload.value;");let _=Object.create(null),y=0;for(let v of b.allKeys)_[v]=`key_${y++}`;g.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let v of b.allKeys){if(v==="__proto__")continue;let T=_[v],A=typeof v==="symbol"?`syms[${m.indexOf(v)}]`:Ub(v),E=`${A} in input`,w=h[v],P=w?._zod?.optin,S=P!==void 0,I=w?._zod?.optout==="optional";if(g.write(`const ${T} = ${p(A)};`),S&&I){let U=P==="optional"?`${T}_present`:`${T}.value !== undefined || ${T}_present`;g.write(`+ const ${T}_present = ${E};+ if (!${T}.issues.length || ${T}_present) {+ if (${T}.issues.length) {${x(T,A)}}- if (${F}) {- newResult[${S}] = ${E}.value;+ if (${U}) {+ newResult[${A}] = ${T}.value;}}- `)}else if(!w)m.write(`- const ${E}_present = ${T};- if (${E}.issues.length) {${b(E,S)}+ `)}else if(!S)g.write(`+ const ${T}_present = ${E};+ if (${T}.issues.length) {${x(T,A)}}- if (!${E}_present && !${E}.issues.length) {+ if (!${T}_present && !${T}.issues.length) {payload.issues.push({code: "invalid_type",expected: "nonoptional",input: undefined,- path: [${S}]+ path: [${A}]});if (ctx && ctx.abortEarly) {payload.value = newResult;@@ -4279,26 +4283,22 @@ ${t.join(`}}- if (${E}_present) {- newResult[${S}] = ${E}.value;+ if (${T}_present) {+ newResult[${A}] = ${T}.value;}- `);else if(m.write(`- if (${E}.issues.length) {${b(E,S)}+ `);else if(g.write(`+ if (${T}.issues.length) {${x(T,A)}}- `),P==="defaulted")m.write(`newResult[${S}] = ${E}.value;`);else m.write(`- if (${E}.value !== undefined || ${T}) {- newResult[${S}] = ${E}.value;+ `),P==="defaulted")g.write(`newResult[${A}] = ${T}.value;`);else g.write(`+ if (${T}.value !== undefined || ${E}) {+ newResult[${A}] = ${T}.value;}- `)}return m.write("payload.value = newResult;"),m.write("return payload;"),m.compile()},a,o=La,c=!Ln.jitless,u=c&&Eb.value,d=t.catchall,f;e._zod.parse=(h,y)=>{f??(f=i.value);let g=h.value;if(!o(g))return h.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),h;if(c&&u&&y?.async===!1&&y.jitless!==!0){if(!a)a=s(t.shape);if(h=a(h,y),!d)return h;return Cx([],g,h,y,f,e,y?.abortEarly===!0)}return n(h,y)}});function By(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!pi(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((a)=>qi(a,i,Zn())))}),t}var Vf=se("$ZodUnion",(e,t)=>{Ut.init(e,t),vt(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),vt(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),vt(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),vt(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>Jr(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,a=[];for(let o of t.options){let c=o._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)a.push(c),s=!0;else{if(c.issues.length===0)return c;a.push(c)}}if(!s)return By(a,i,e,r);return Promise.all(a).then((o)=>By(o,i,e,r))}});function lI(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var Px=se("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Vf.init(e,t);let n=e._zod.parse;vt(e,"propValues",(r)=>{let s={},a=0;for(let o of r.def.options){let c=o._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(o)}"`);if(c[r.def.discriminator]?.has(void 0))a++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))hi(s,l,new Set);for(let d of u)s[l].add(d)}}if(!r.def.unionFallback&&a>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let a=Zo(r._zod.def);if(a&&!Object.prototype.hasOwnProperty.call(a,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=Jo(()=>lI(t));e._zod.parse=(r,s)=>{let a=r.value;if(!La(a))return r.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),r;let o=a?.[t.discriminator],c=i.value.get(o);if(c&&(o!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:a,path:[t.discriminator],inst:e}),r}}),Ox=se("$ZodIntersection",(e,t)=>{Ut.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),a=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||a instanceof Promise)return Promise.all([s,a]).then(([c,l])=>zy(n,c,l));return zy(n,s,a)}});function Lf(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(ea(e)&&ea(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let a=Lf(e[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};r[s]=a.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],s=t[i],a=Lf(r,s);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function zy(e,t,n){let i=new Map,r,s=new Map,a=(l,u)=>{let d;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),d=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let f=String(l.path[0]);if(!s.has(f))s.set(f,l);d=[f]}else return!1;for(let f of d){if(!i.has(f))i.set(f,{});i.get(f)[u]=!0}return!0};for(let l of t.issues)if(!a(l,"l"))e.issues.push(l);for(let l of n.issues)if(!a(l,"r"))e.issues.push(l);let o=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(o.length){let l=r?o.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of o)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=Lf(t.value,n.value);if(!c.valid){if(pi(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var kx=se("$ZodTuple",(e,t)=>{Ut.init(e,t);let n=t.items,i=Ln.memoizer;i?.attach(e),e._zod.parse=(r,s)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(e,r,[],s):[];let o=[],c=Vy(n,"optin"),l=Vy(n,"optout");if(!t.rest){if(a.length<c)return r.issues.push({code:"too_small",minimum:c,inclusive:!0,input:a,inst:e,origin:"array"}),r;if(a.length>n.length)r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:a,inst:e,origin:"array"})}let u=Array(n.length),d=t.rest?s?.abortEarly:void 0,f=!1;for(let h=0;h<n.length;h++){let y=n[h]._zod.run({value:a[h],issues:[]},s);if(y instanceof Promise)o.push(y.then((g)=>{u[h]=g}));else if(u[h]=y,d&&!f&&y.issues.length)f=pi(y)}if(t.rest&&!f){let h=n.length-1,y=a.slice(n.length),g=r.issues.length;for(let m of y){if(d&&r.issues.length!==g){if(pi(r,g))break;g=r.issues.length}h++;let p=t.rest._zod.run({value:m,issues:[]},s);if(p instanceof Promise)o.push(p.then((b)=>jy(b,r,h)));else jy(p,r,h)}}if(o.length)return Promise.all(o).then(()=>Hy(u,r,n,a,l));return Hy(u,r,n,a,l)}});function Vy(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function jy(e,t,n){if(e.issues.length)t.issues.push(...Xi(n,e.issues));t.value[n]=e.value}function Hy(e,t,n,i,r){for(let s=0;s<n.length;s++){let a=e[s],o=s<i.length;if(!o&&s>=r&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(a.issues.length){if(!o&&s>=r){t.value.length=s;break}t.issues.push(...Xi(s,a.issues))}t.value[s]=a.value}for(let s=t.value.length-1;s>=i.length;s--)if(n[s]._zod.optout==="optional"&&t.value[s]===void 0)t.value.length=s;else break;return t}var Dx=se("$ZodRecord",(e,t)=>{Ut.init(e,t);let n=Ln.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!ea(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let a=[],o=t.keyType._zod.values;if(o&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of o)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((y)=>qi(y,r,Zn())),input:u,path:[u],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let h=t.valueType._zod.run({value:s[u],issues:[]},r);if(h instanceof Promise)a.push(h.then((y)=>{if(y.issues.length)i.issues.push(...Xi(u,y.issues));i.value[f]=y.value}));else{if(h.issues.length)i.issues.push(...Xi(u,h.issues));i.value[f]=h.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&Fa.test(l)&&u.issues.length){let y=t.keyType._zod.run({value:Number(l),issues:[]},r);if(y instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(y.issues.length===0)u=y}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(o)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((y)=>qi(y,r,Zn())),input:l,path:[l],inst:e});continue}let f=u.value;if(f==="__proto__")continue;let h=t.valueType._zod.run({value:s[l],issues:[]},r);if(h instanceof Promise)a.push(h.then((y)=>{if(y.issues.length)i.issues.push(...Xi(l,y.issues));i.value[f]=y.value}));else{if(h.issues.length)i.issues.push(...Xi(l,h.issues));i.value[f]=h.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(a.length)return Promise.all(a).then(()=>i);return i}});var Lx=se("$ZodEnum",(e,t)=>{Ut.init(e,t);let n=Xo(t.entries),i=new Set(n);e._zod.values=i,vt(e,"pattern",(r)=>{let s=Xo(r.def.entries).filter((a)=>Tb.has(typeof a));return new RegExp(s.length?`^(${s.map((a)=>wr(a.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let a=r.value;if(i.has(a))return r;return r.issues.push({code:"invalid_value",values:n,input:a,inst:e}),r}}),Fx=se("$ZodLiteral",(e,t)=>{Ut.init(e,t);let n=new Set(t.values);e._zod.values=n,vt(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?wr(s):s?wr(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var Ux=se("$ZodTransform",(e,t)=>{Ut.init(e,t),e._zod.optin="optional",Ln.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Yo(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((a)=>(n.value=a,n));if(r instanceof Promise)throw new Ji;return n.value=r,n}});function Gy(e,t){return e.value=t.issues.length?void 0:t.value,e}var jf=se("$ZodOptional",(e,t)=>{Ut.init(e,t),vt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",vt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),vt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Jr(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>Gy(n,s));return Gy(n,r)}return t.innerType._zod.run(n,i)}}),Bx=se("$ZodExactOptional",(e,t)=>{jf.init(e,t),vt(e,"values",(n)=>n.def.innerType._zod.values),vt(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),zx=se("$ZodNullable",(e,t)=>{Ut.init(e,t),vt(e,"optin",(n)=>n.def.innerType._zod.optin),vt(e,"optout",(n)=>n.def.innerType._zod.optout),vt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Jr(i.source)}|null)$`):void 0}),vt(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),Vx=se("$ZodDefault",(e,t)=>{Ut.init(e,t),e._zod.optin="defaulted",vt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>$y(s,t));return $y(r,t)}});function $y(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var jx=se("$ZodPrefault",(e,t)=>{Ut.init(e,t),e._zod.optin="defaulted",vt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),Hx=se("$ZodNonOptional",(e,t)=>{Ut.init(e,t),vt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Ky(s,e));return Ky(r,e)}});function Ky(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function Wy(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>qi(r,i,Zn()))},input:e.value}),e}var Gx=se("$ZodCatch",(e,t)=>{Ut.init(e,t),vt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),vt(e,"optout",(n)=>n.def.innerType._zod.optout),vt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>Wy(n,s,t,i));return Wy(n,r,t,i)}});var $x=se("$ZodPipe",(e,t)=>{Ut.init(e,t),vt(e,"values",(n)=>n.def.in._zod.values),vt(e,"optin",(n)=>n.def.in._zod.optin),vt(e,"optout",(n)=>n.def.out._zod.optout),vt(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((a)=>zl(a,t.in,i));return zl(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>zl(s,t.out,i));return zl(r,t.out,i)}});function zl(e,t,n){if(e.issues.some((i)=>i.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var Kx=se("$ZodReadonly",(e,t)=>{Ut.init(e,t),vt(e,"propValues",(n)=>n.def.innerType._zod.propValues),vt(e,"values",(n)=>n.def.innerType._zod.values),vt(e,"optin",(n)=>n.def.innerType?._zod?.optin),vt(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(Xy);return Xy(r)}});function Xy(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function uI(e){let t=e._zod.def,n=t.pattern,i=!!t.format?.includes("int"),r,s;for(let o of t.checks??[]){let c=o._zod.def;if(c.pattern)n=c.pattern;i||(i=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;if(l!==void 0&&(r===void 0||l>r))r=l;if(u!==void 0&&(s===void 0||u<s))s=u}if(n)return n.source;if(r!==void 0&&s!==void 0&&r>s)return"(?!)";if(r!==void 0||s!==void 0)return xy({minimum:r,maximum:s}).source;let a=e._zod.pattern;return(i&&a===Fa?Ul:a)?.source}function Ff(e){let t=e._zod.def,n=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let r=i._zod.pattern?.source,s=Ff(i);if(n&&r&&s&&s!==r)return n.replace(Jr(r),()=>Jr(s));return n}if(t.options){let r=t.options.map(Ff);if(r.every(Boolean))return`^(${r.map((s)=>Jr(s)).join("|")})$`}return uI(e)}var Wx=se("$ZodTemplateLiteral",(e,t)=>{Ut.init(e,t);let n=[];for(let i of t.parts)if(typeof i==="object"&&i!==null){let r=Ff(i);if(!r)throw Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);n.push(Jr(r))}else if(i===null||Ab.has(typeof i))n.push(wr(`${i}`));else throw Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>{if(typeof i.value!=="string")return i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(i.value))return i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i;return i}});var Xx=se("$ZodCustom",(e,t)=>{Sn.init(e,t),Ut.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>qy(s,n,i,e));qy(r,n,i,e);return}});function qy(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(ta(r))}}class Jx extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Gf="~memo",qx=[];function Zx(e){return e!==null&&typeof e==="object"}function Hf(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Yx=new WeakMap,tc=0,Wl=1,nc=2;function Xl(e,t,n){let i=Yx.get(e);if(i!==void 0)return i?nc:tc;if(t.has(e))return nc;t.add(e);let r=tc,s=(u)=>{if(r!==nc&&u?._zod){let d=Xl(u,t,n);if(d>r)r=d}},a=(u,d)=>{let f=tc;for(let h of Reflect.ownKeys(u)){let y=Object.getOwnPropertyDescriptor(u,h);if(d&&!y.enumerable)continue;let g=y.get?Wl:y.value?._zod?Xl(y.value,t,n):tc;if(g>f)f=g}return f},o=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=Zo(c);o(u?a(u,!0):Wl),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);o(u?Xl(u,t,!1):Wl);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let d=Object.getOwnPropertyDescriptor(c,u);if(!d||d.get)continue;let f=d.value;if(!f||typeof f!=="object")continue;if(f._zod)s(f);else if(Array.isArray(f))for(let h of f)s(h)}}return t.delete(e),dI(e,r)}function dI(e,t){if(t!==Wl)Yx.set(e,t===nc);return t}function fI(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var $l,Kl=[],hI={alloc(e,t,n){let i=$l;if(!i)return n;$l=void 0;let r={value:n,issues:null};return i.set(t.value,r),Kl.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,s)=>{if(s.direction!=="backward"&&pI(s,r.value))throw new Jx;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let a=e._zod.parse,o=(c,l)=>{if(n===void 0){let p=Xl(e,new Set,!1);if(p===tc){if(e._zod.parse=a,e._zod.run===o)e._zod.run=a;return a(c,l)}if(p===nc||i)n=!0;else i=!0}let u=c.value;if(!Zx(u))return a(c,l);let d=l[Gf];if(!d)d={buckets:new WeakMap,backEdges:void 0},l[Gf]=d;let f;if(r===l)f=s;else f=fI(d,e),r=l,s=f;let h=f.get(u);if(h){if(c.value=h.value,h.issues){if(h.issues.length)c.issues.push(...Hf(h.issues))}else c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(h.value);return c}$l=f;let y=Kl.length,g=a(c,l);$l=void 0;let m=Kl.length>y?Kl.pop():void 0;if(g instanceof Promise)return g.then((p)=>{if(m)m.issues=p.issues.length?Hf(p.issues):qx;return p});if(m)m.issues=g.issues.length?Hf(g.issues):qx;return g};if(e._zod.parse=o,e._zod.run===a)e._zod.run=o})}};function Qx(){return hI}function pI(e,t){let n=e[Gf]?.backEdges;return n!==void 0&&Zx(t)&&n.has(t)}var mI=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(s,a){if(s==="number"&&typeof a==="number"&&!Number.isFinite(a))return String(a);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let a=r(s.expected),o=Ib(s.input),c=r(o,s.input);return`Invalid input: expected ${a}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${Ef(s.values[0])}`;return`Invalid option: expected one of ${xf(s.values,"|")}`;case"too_big":{let a=s.exact?"exactly ":s.inclusive?"<=":"<",o=t(s.origin);if(o)return`Too big: expected ${s.origin??"value"} to have ${a}${s.maximum.toString()} ${o.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${a}${s.maximum.toString()}`}case"too_small":{let a=s.exact?"exactly ":s.inclusive?">=":">",o=t(s.origin);if(o)return`Too small: expected ${s.origin} to have ${a}${s.minimum.toString()} ${o.unit}`;return`Too small: expected ${s.origin} to be ${a}${s.minimum.toString()}`}case"invalid_format":{let a=s;if(a.format==="starts_with")return`Invalid string: must start with "${a.prefix}"`;if(a.format==="ends_with")return`Invalid string: must end with "${a.suffix}"`;if(a.format==="includes")return`Invalid string: must include "${a.includes}"`;if(a.format==="regex")return`Invalid string: must match pattern ${a.pattern}`;return`Invalid ${n[a.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${xf(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((o)=>`'${o}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function $f(){return{localeError:mI()}}var e_;class t_{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function gI(){return new t_}(e_=globalThis).__zod_globalRegistry??(e_.__zod_globalRegistry=gI());var na=globalThis.__zod_globalRegistry;function n_(e){if(e.checks)e.checks=[...e.checks];return e}function i_(e,t){return new e(n_({type:"string",...Fe(t)}))}function r_(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Fe(t)})}function s_(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Fe(t)})}function a_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Fe(t)})}function o_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Fe(t)})}function c_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Fe(t)})}function l_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Fe(t)})}function u_(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Fe(t)})}function d_(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Fe(t)})}function f_(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Fe(t)})}function h_(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Fe(t)})}function p_(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Fe(t)})}function m_(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Fe(t)})}function g_(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Fe(t)})}function b_(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Fe(t)})}function y_(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Fe(t)})}function x_(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Fe(t)})}function __(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Fe(t)})}function v_(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Fe(t)})}function E_(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Fe(t)})}function T_(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Fe(t)})}function A_(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Fe(t)})}function S_(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Fe(t)})}function w_(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Fe(t)})}function M_(e,t){return new e({type:"string",format:"date",check:"string_format",...Fe(t)})}function R_(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Fe(t)})}function I_(e,t){return new e({type:"string",format:"duration",check:"string_format",...Fe(t)})}function C_(e,t){return new e(n_({type:"number",checks:[],...Fe(t)}))}function N_(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Fe(t)})}function P_(e,t){return new e({type:"boolean",...Fe(t)})}function O_(e){return new e({type:"unknown"})}function k_(e,t){return new e({type:"never",...Fe(t)})}function ql(e,t){return new Of({check:"less_than",...Fe(t),value:e,inclusive:!1})}function ic(e,t){return new Of({check:"less_than",...Fe(t),value:e,inclusive:!0})}function Jl(e,t){return new kf({check:"greater_than",...Fe(t),value:e,inclusive:!1})}function rc(e,t){return new kf({check:"greater_than",...Fe(t),value:e,inclusive:!0})}function Zl(e,t){return new Ty({check:"multiple_of",...Fe(t),value:e})}function Yl(e,t){return new Sy({check:"max_length",...Fe(t),maximum:e})}function Ua(e,t){return new wy({check:"min_length",...Fe(t),minimum:e})}function Ql(e,t){return new My({check:"length_equals",...Fe(t),length:e})}function Kf(e,t){return new Ry({check:"string_format",format:"regex",...Fe(t),pattern:e})}function Wf(e){return new Iy({check:"string_format",format:"lowercase",...Fe(e)})}function Xf(e){return new Cy({check:"string_format",format:"uppercase",...Fe(e)})}function qf(e,t){return new Ny({check:"string_format",format:"includes",...Fe(t),includes:e})}function Jf(e,t){return new Py({check:"string_format",format:"starts_with",...Fe(t),prefix:e})}function Zf(e,t){return new Oy({check:"string_format",format:"ends_with",...Fe(t),suffix:e})}function Zr(e){return new ky({check:"overwrite",tx:e})}function Yf(e){return Zr((t)=>t.normalize(e))}function Qf(){return Zr((e)=>e.trim())}function eh(){return Zr((e)=>e.toLowerCase())}function th(){return Zr((e)=>e.toUpperCase())}function nh(){return Zr((e)=>vb(e))}function D_(e,t,n){return new e({type:"array",element:t,...Fe(n)})}function L_(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Fe(n)})}function F_(e,t){let n=bI((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(ta(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(ta(s))}},e(i.value,i)),t);return n}function bI(e,t){let n=new Sn({check:"custom",...Fe(t)});return n._zod.check=e,n}function sc(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))hi(e,i,n[i]);return e}function rh(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??na,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Mr(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function Xt(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let o=e._zod.toJSONSchema?.();if(o)a.schema=o;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,u);else{let f=a.schema,h=t.processors[r.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);h(e,t,f,u)}let d=e._zod.parent;if(d){if(!a.ref)a.ref=d;Xt(d,t,u),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)sc(a.schema,c);if(t.io==="input"&&Fn(e))delete a.schema.examples,delete a.schema.default;if(t.io==="input"&&"_prefault"in a.schema)(i=a.schema).default??(i.default=a.schema._prefault);return delete a.schema._prefault,t.seen.get(e).schema}function U_(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function sh(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let a of e.seen.entries()){let o=e.metadataRegistry.get(a[0])?.id;if(o){let c=i.get(o);if(c&&c!==a[0])throw Error(`Duplicate schema id "${o}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(o,a[0])}}let r=(a)=>{let o=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(a[0])?.id,f=e.external.uri??((y)=>y);if(d)return{ref:f(d)};let h=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=h,{defId:h,ref:`${f("__shared")}#/${o}/${U_(h)}`}}let c="#",l=`${c}/${o}/`;if(a[1]===n&&!a[1].schema.id)return{ref:c};let u=a[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+U_(u)}},s=(a)=>{if(a[1].schema.$ref)return;let o=a[1],{ref:c,defId:l}=r(a);if(o.def={...o.schema},l)o.defId=l;let u=o.schema;for(let d in u)delete u[d];u.$ref=c};if(e.cycles==="throw")for(let a of e.seen.entries()){let o=a[1];if(o.cycle)throw Error(`Cycle detected: #/${o.cycle?.join("/")}/<root>+ `)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},a,o=ja,c=!Un.jitless,u=c&&zb.value,d=t.catchall,f;e._zod.parse=(h,b)=>{f??(f=i.value);let m=h.value;if(!o(m))return h.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),h;if(c&&u&&b?.async===!1&&b.jitless!==!0){if(!a)a=s(t.shape);if(h=a(h,b),!d)return h;return Xy([],m,h,b,f,e,b?.abortEarly===!0)}return n(h,b)}});function iy(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!gi(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((a)=>Yi(a,i,ei())))}),t}var rh=se("$ZodUnion",(e,t)=>{Ut.init(e,t),Et(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),Et(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),Et(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),Et(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>Yr(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,a=[];for(let o of t.options){let c=o._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)a.push(c),s=!0;else{if(c.issues.length===0)return c;a.push(c)}}if(!s)return iy(a,i,e,r);return Promise.all(a).then((o)=>iy(o,i,e,r))}});function jI(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var Jy=se("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,rh.init(e,t);let n=e._zod.parse;Et(e,"propValues",(r)=>{let s={},a=0;for(let o of r.def.options){let c=o._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(o)}"`);if(c[r.def.discriminator]?.has(void 0))a++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))mi(s,l,new Set);for(let d of u)s[l].add(d)}}if(!r.def.unionFallback&&a>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let a=ac(r._zod.def);if(a&&!Object.prototype.hasOwnProperty.call(a,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=sc(()=>jI(t));e._zod.parse=(r,s)=>{let a=r.value;if(!ja(a))return r.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),r;let o=a?.[t.discriminator],c=i.value.get(o);if(c&&(o!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:a,path:[t.discriminator],inst:e}),r}}),Zy=se("$ZodIntersection",(e,t)=>{Ut.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),a=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||a instanceof Promise)return Promise.all([s,a]).then(([c,l])=>ry(n,c,l));return ry(n,s,a)}});function Qf(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(ra(e)&&ra(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let a=Qf(e[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};r[s]=a.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],s=t[i],a=Qf(r,s);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ry(e,t,n){let i=new Map,r,s=new Map,a=(l,u)=>{let d;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),d=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let f=String(l.path[0]);if(!s.has(f))s.set(f,l);d=[f]}else return!1;for(let f of d){if(!i.has(f))i.set(f,{});i.get(f)[u]=!0}return!0};for(let l of t.issues)if(!a(l,"l"))e.issues.push(l);for(let l of n.issues)if(!a(l,"r"))e.issues.push(l);let o=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(o.length){let l=r?o.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of o)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=Qf(t.value,n.value);if(!c.valid){if(gi(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Yy=se("$ZodTuple",(e,t)=>{Ut.init(e,t);let n=t.items,i=Un.memoizer;i?.attach(e),e._zod.parse=(r,s)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(e,r,[],s):[];let o=[],c=sy(n,"optin"),l=sy(n,"optout");if(!t.rest){if(a.length<c)return r.issues.push({code:"too_small",minimum:c,inclusive:!0,input:a,inst:e,origin:"array"}),r;if(a.length>n.length)r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:a,inst:e,origin:"array"})}let u=Array(n.length),d=t.rest?s?.abortEarly:void 0,f=!1;for(let h=0;h<n.length;h++){let b=n[h]._zod.run({value:a[h],issues:[]},s);if(b instanceof Promise)o.push(b.then((m)=>{u[h]=m}));else if(u[h]=b,d&&!f&&b.issues.length)f=gi(b)}if(t.rest&&!f){let h=n.length-1,b=a.slice(n.length),m=r.issues.length;for(let g of b){if(d&&r.issues.length!==m){if(gi(r,m))break;m=r.issues.length}h++;let p=t.rest._zod.run({value:g,issues:[]},s);if(p instanceof Promise)o.push(p.then((x)=>ay(x,r,h)));else ay(p,r,h)}}if(o.length)return Promise.all(o).then(()=>oy(u,r,n,a,l));return oy(u,r,n,a,l)}});function sy(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function ay(e,t,n){if(e.issues.length)t.issues.push(...Zi(n,e.issues));t.value[n]=e.value}function oy(e,t,n,i,r){for(let s=0;s<n.length;s++){let a=e[s],o=s<i.length;if(!o&&s>=r&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(a.issues.length){if(!o&&s>=r){t.value.length=s;break}t.issues.push(...Zi(s,a.issues))}t.value[s]=a.value}for(let s=t.value.length-1;s>=i.length;s--)if(n[s]._zod.optout==="optional"&&t.value[s]===void 0)t.value.length=s;else break;return t}var Qy=se("$ZodRecord",(e,t)=>{Ut.init(e,t);let n=Un.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!ra(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let a=[],o=t.keyType._zod.values;if(o&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of o)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((b)=>Yi(b,r,ei())),input:u,path:[u],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let h=t.valueType._zod.run({value:s[u],issues:[]},r);if(h instanceof Promise)a.push(h.then((b)=>{if(b.issues.length)i.issues.push(...Zi(u,b.issues));i.value[f]=b.value}));else{if(h.issues.length)i.issues.push(...Zi(u,h.issues));i.value[f]=h.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&Ha.test(l)&&u.issues.length){let b=t.keyType._zod.run({value:Number(l),issues:[]},r);if(b instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(b.issues.length===0)u=b}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(o)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((b)=>Yi(b,r,ei())),input:l,path:[l],inst:e});continue}let f=u.value;if(f==="__proto__")continue;let h=t.valueType._zod.run({value:s[l],issues:[]},r);if(h instanceof Promise)a.push(h.then((b)=>{if(b.issues.length)i.issues.push(...Zi(l,b.issues));i.value[f]=b.value}));else{if(h.issues.length)i.issues.push(...Zi(l,h.issues));i.value[f]=h.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(a.length)return Promise.all(a).then(()=>i);return i}});var e_=se("$ZodEnum",(e,t)=>{Ut.init(e,t);let n=ic(t.entries),i=new Set(n);e._zod.values=i,Et(e,"pattern",(r)=>{let s=ic(r.def.entries).filter((a)=>Vb.has(typeof a));return new RegExp(s.length?`^(${s.map((a)=>Rr(a.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let a=r.value;if(i.has(a))return r;return r.issues.push({code:"invalid_value",values:n,input:a,inst:e}),r}}),t_=se("$ZodLiteral",(e,t)=>{Ut.init(e,t);let n=new Set(t.values);e._zod.values=n,Et(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?Rr(s):s?Rr(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var n_=se("$ZodTransform",(e,t)=>{Ut.init(e,t),e._zod.optin="optional",Un.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new oc(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((a)=>(n.value=a,n));if(r instanceof Promise)throw new Qi;return n.value=r,n}});function cy(e,t){return e.value=t.issues.length?void 0:t.value,e}var sh=se("$ZodOptional",(e,t)=>{Ut.init(e,t),Et(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",Et(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),Et(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Yr(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>cy(n,s));return cy(n,r)}return t.innerType._zod.run(n,i)}}),i_=se("$ZodExactOptional",(e,t)=>{sh.init(e,t),Et(e,"values",(n)=>n.def.innerType._zod.values),Et(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),r_=se("$ZodNullable",(e,t)=>{Ut.init(e,t),Et(e,"optin",(n)=>n.def.innerType._zod.optin),Et(e,"optout",(n)=>n.def.innerType._zod.optout),Et(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Yr(i.source)}|null)$`):void 0}),Et(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),s_=se("$ZodDefault",(e,t)=>{Ut.init(e,t),e._zod.optin="defaulted",Et(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>ly(s,t));return ly(r,t)}});function ly(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var a_=se("$ZodPrefault",(e,t)=>{Ut.init(e,t),e._zod.optin="defaulted",Et(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),o_=se("$ZodNonOptional",(e,t)=>{Ut.init(e,t),Et(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>uy(s,e));return uy(r,e)}});function uy(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function dy(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>Yi(r,i,ei()))},input:e.value}),e}var c_=se("$ZodCatch",(e,t)=>{Ut.init(e,t),Et(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),Et(e,"optout",(n)=>n.def.innerType._zod.optout),Et(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>dy(n,s,t,i));return dy(n,r,t,i)}});var l_=se("$ZodPipe",(e,t)=>{Ut.init(e,t),Et(e,"values",(n)=>n.def.in._zod.values),Et(e,"optin",(n)=>n.def.in._zod.optin),Et(e,"optout",(n)=>n.def.out._zod.optout),Et(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((a)=>eu(a,t.in,i));return eu(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>eu(s,t.out,i));return eu(r,t.out,i)}});function eu(e,t,n){if(e.issues.some((i)=>i.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var u_=se("$ZodReadonly",(e,t)=>{Ut.init(e,t),Et(e,"propValues",(n)=>n.def.innerType._zod.propValues),Et(e,"values",(n)=>n.def.innerType._zod.values),Et(e,"optin",(n)=>n.def.innerType?._zod?.optin),Et(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(fy);return fy(r)}});function fy(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function HI(e){let t=e._zod.def,n=t.pattern,i=!!t.format?.includes("int"),r,s;for(let o of t.checks??[]){let c=o._zod.def;if(c.pattern)n=c.pattern;i||(i=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;if(l!==void 0&&(r===void 0||l>r))r=l;if(u!==void 0&&(s===void 0||u<s))s=u}if(n)return n.source;if(r!==void 0&&s!==void 0&&r>s)return"(?!)";if(r!==void 0||s!==void 0)return Fx({minimum:r,maximum:s}).source;let a=e._zod.pattern;return(i&&a===Ha?Yl:a)?.source}function eh(e){let t=e._zod.def,n=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let r=i._zod.pattern?.source,s=eh(i);if(n&&r&&s&&s!==r)return n.replace(Yr(r),()=>Yr(s));return n}if(t.options){let r=t.options.map(eh);if(r.every(Boolean))return`^(${r.map((s)=>Yr(s)).join("|")})$`}return HI(e)}var d_=se("$ZodTemplateLiteral",(e,t)=>{Ut.init(e,t);let n=[];for(let i of t.parts)if(typeof i==="object"&&i!==null){let r=eh(i);if(!r)throw Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);n.push(Yr(r))}else if(i===null||jb.has(typeof i))n.push(Rr(`${i}`));else throw Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>{if(typeof i.value!=="string")return i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(i.value))return i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i;return i}});var f_=se("$ZodCustom",(e,t)=>{wn.init(e,t),Ut.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>hy(s,n,i,e));hy(r,n,i,e);return}});function hy(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(sa(r))}}class p_ extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var oh="~memo",h_=[];function m_(e){return e!==null&&typeof e==="object"}function ah(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var g_=new WeakMap,uc=0,ou=1,dc=2;function cu(e,t,n){let i=g_.get(e);if(i!==void 0)return i?dc:uc;if(t.has(e))return dc;t.add(e);let r=uc,s=(u)=>{if(r!==dc&&u?._zod){let d=cu(u,t,n);if(d>r)r=d}},a=(u,d)=>{let f=uc;for(let h of Reflect.ownKeys(u)){let b=Object.getOwnPropertyDescriptor(u,h);if(d&&!b.enumerable)continue;let m=b.get?ou:b.value?._zod?cu(b.value,t,n):uc;if(m>f)f=m}return f},o=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=ac(c);o(u?a(u,!0):ou),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);o(u?cu(u,t,!1):ou);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let d=Object.getOwnPropertyDescriptor(c,u);if(!d||d.get)continue;let f=d.value;if(!f||typeof f!=="object")continue;if(f._zod)s(f);else if(Array.isArray(f))for(let h of f)s(h)}}return t.delete(e),GI(e,r)}function GI(e,t){if(t!==ou)g_.set(e,t===dc);return t}function $I(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var su,au=[],KI={alloc(e,t,n){let i=su;if(!i)return n;su=void 0;let r={value:n,issues:null};return i.set(t.value,r),au.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,s)=>{if(s.direction!=="backward"&&WI(s,r.value))throw new p_;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let a=e._zod.parse,o=(c,l)=>{if(n===void 0){let p=cu(e,new Set,!1);if(p===uc){if(e._zod.parse=a,e._zod.run===o)e._zod.run=a;return a(c,l)}if(p===dc||i)n=!0;else i=!0}let u=c.value;if(!m_(u))return a(c,l);let d=l[oh];if(!d)d={buckets:new WeakMap,backEdges:void 0},l[oh]=d;let f;if(r===l)f=s;else f=$I(d,e),r=l,s=f;let h=f.get(u);if(h){if(c.value=h.value,h.issues){if(h.issues.length)c.issues.push(...ah(h.issues))}else c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(h.value);return c}su=f;let b=au.length,m=a(c,l);su=void 0;let g=au.length>b?au.pop():void 0;if(m instanceof Promise)return m.then((p)=>{if(g)g.issues=p.issues.length?ah(p.issues):h_;return p});if(g)g.issues=m.issues.length?ah(m.issues):h_;return m};if(e._zod.parse=o,e._zod.run===a)e._zod.run=o})}};function b_(){return KI}function WI(e,t){let n=e[oh]?.backEdges;return n!==void 0&&m_(t)&&n.has(t)}var XI=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(s,a){if(s==="number"&&typeof a==="number"&&!Number.isFinite(a))return String(a);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let a=r(s.expected),o=Wb(s.input),c=r(o,s.input);return`Invalid input: expected ${a}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${Bf(s.values[0])}`;return`Invalid option: expected one of ${Lf(s.values,"|")}`;case"too_big":{let a=s.exact?"exactly ":s.inclusive?"<=":"<",o=t(s.origin);if(o)return`Too big: expected ${s.origin??"value"} to have ${a}${s.maximum.toString()} ${o.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${a}${s.maximum.toString()}`}case"too_small":{let a=s.exact?"exactly ":s.inclusive?">=":">",o=t(s.origin);if(o)return`Too small: expected ${s.origin} to have ${a}${s.minimum.toString()} ${o.unit}`;return`Too small: expected ${s.origin} to be ${a}${s.minimum.toString()}`}case"invalid_format":{let a=s;if(a.format==="starts_with")return`Invalid string: must start with "${a.prefix}"`;if(a.format==="ends_with")return`Invalid string: must end with "${a.suffix}"`;if(a.format==="includes")return`Invalid string: must include "${a.includes}"`;if(a.format==="regex")return`Invalid string: must match pattern ${a.pattern}`;return`Invalid ${n[a.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${Lf(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((o)=>`'${o}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function ch(){return{localeError:XI()}}var x_;class y_{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function qI(){return new y_}(x_=globalThis).__zod_globalRegistry??(x_.__zod_globalRegistry=qI());var aa=globalThis.__zod_globalRegistry;function __(e){if(e.checks)e.checks=[...e.checks];return e}function v_(e,t){return new e(__({type:"string",...Fe(t)}))}function E_(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Fe(t)})}function T_(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Fe(t)})}function A_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Fe(t)})}function w_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Fe(t)})}function S_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Fe(t)})}function M_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Fe(t)})}function R_(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Fe(t)})}function I_(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Fe(t)})}function C_(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Fe(t)})}function N_(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Fe(t)})}function P_(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Fe(t)})}function O_(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Fe(t)})}function k_(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Fe(t)})}function D_(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Fe(t)})}function L_(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Fe(t)})}function F_(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Fe(t)})}function U_(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Fe(t)})}function B_(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Fe(t)})}function z_(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Fe(t)})}function V_(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Fe(t)})}function j_(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Fe(t)})}function H_(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Fe(t)})}function G_(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Fe(t)})}function $_(e,t){return new e({type:"string",format:"date",check:"string_format",...Fe(t)})}function K_(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Fe(t)})}function W_(e,t){return new e({type:"string",format:"duration",check:"string_format",...Fe(t)})}function X_(e,t){return new e(__({type:"number",checks:[],...Fe(t)}))}function q_(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Fe(t)})}function J_(e,t){return new e({type:"boolean",...Fe(t)})}function Z_(e){return new e({type:"unknown"})}function Y_(e,t){return new e({type:"never",...Fe(t)})}function lu(e,t){return new Jf({check:"less_than",...Fe(t),value:e,inclusive:!1})}function fc(e,t){return new Jf({check:"less_than",...Fe(t),value:e,inclusive:!0})}function uu(e,t){return new Zf({check:"greater_than",...Fe(t),value:e,inclusive:!1})}function hc(e,t){return new Zf({check:"greater_than",...Fe(t),value:e,inclusive:!0})}function du(e,t){return new Vx({check:"multiple_of",...Fe(t),value:e})}function fu(e,t){return new Hx({check:"max_length",...Fe(t),maximum:e})}function Ga(e,t){return new Gx({check:"min_length",...Fe(t),minimum:e})}function hu(e,t){return new $x({check:"length_equals",...Fe(t),length:e})}function lh(e,t){return new Kx({check:"string_format",format:"regex",...Fe(t),pattern:e})}function uh(e){return new Wx({check:"string_format",format:"lowercase",...Fe(e)})}function dh(e){return new Xx({check:"string_format",format:"uppercase",...Fe(e)})}function fh(e,t){return new qx({check:"string_format",format:"includes",...Fe(t),includes:e})}function hh(e,t){return new Jx({check:"string_format",format:"starts_with",...Fe(t),prefix:e})}function ph(e,t){return new Zx({check:"string_format",format:"ends_with",...Fe(t),suffix:e})}function Qr(e){return new Yx({check:"overwrite",tx:e})}function mh(e){return Qr((t)=>t.normalize(e))}function gh(){return Qr((e)=>e.trim())}function bh(){return Qr((e)=>e.toLowerCase())}function xh(){return Qr((e)=>e.toUpperCase())}function yh(){return Qr((e)=>Bb(e))}function Q_(e,t,n){return new e({type:"array",element:t,...Fe(n)})}function e0(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Fe(n)})}function t0(e,t){let n=JI((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(sa(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(sa(s))}},e(i.value,i)),t);return n}function JI(e,t){let n=new wn({check:"custom",...Fe(t)});return n._zod.check=e,n}function pc(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))mi(e,i,n[i]);return e}function vh(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??aa,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Ir(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function qt(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let o=e._zod.toJSONSchema?.();if(o)a.schema=o;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,u);else{let f=a.schema,h=t.processors[r.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);h(e,t,f,u)}let d=e._zod.parent;if(d){if(!a.ref)a.ref=d;qt(d,t,u),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)pc(a.schema,c);if(t.io==="input"&&Bn(e))delete a.schema.examples,delete a.schema.default;if(t.io==="input"&&"_prefault"in a.schema)(i=a.schema).default??(i.default=a.schema._prefault);return delete a.schema._prefault,t.seen.get(e).schema}function n0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Eh(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let a of e.seen.entries()){let o=e.metadataRegistry.get(a[0])?.id;if(o){let c=i.get(o);if(c&&c!==a[0])throw Error(`Duplicate schema id "${o}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(o,a[0])}}let r=(a)=>{let o=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(a[0])?.id,f=e.external.uri??((b)=>b);if(d)return{ref:f(d)};let h=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=h,{defId:h,ref:`${f("__shared")}#/${o}/${n0(h)}`}}let c="#",l=`${c}/${o}/`;if(a[1]===n&&!a[1].schema.id)return{ref:c};let u=a[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+n0(u)}},s=(a)=>{if(a[1].schema.$ref)return;let o=a[1],{ref:c,defId:l}=r(a);if(o.def={...o.schema},l)o.defId=l;let u=o.schema;for(let d in u)delete u[d];u.$ref=c};if(e.cycles==="throw")for(let a of e.seen.entries()){let o=a[1];if(o.cycle)throw Error(`Cycle detected: #/${o.cycle?.join("/")}/<root>-Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let o=a[1];if(t===a[0]){s(a);continue}if(e.external){let l=e.external.registry.get(a[0])?.id;if(t!==a[0]&&l){s(a);continue}}if(e.metadataRegistry.get(a[0])?.id){s(a);continue}if(o.cycle){s(a);continue}if(o.count>1){if(e.reused==="ref")s(a)}}if(e.external)e.sharedDefsExtractedFor=e.external}function V_(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!=="object")return;V_(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let a of Array.isArray(s)?s:[s]){if(typeof a!=="string")return;if(!n.includes(a))n.push(a)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var j_=new Set(["type","properties","required","additionalProperties"]),B_=["oneOf","anyOf"];function z_(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function ih(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let a in s)if(!j_.has(a))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let a in s.properties){if(Object.prototype.hasOwnProperty.call(n,a))continue;let o=[];for(let l of t){let u=l.properties?.[a]??z_(l);if(u===null||u===void 0)continue;if(!o.some((d)=>JSON.stringify(d)===JSON.stringify(u)))o.push(u)}let c=o.length===1?o[0]:ih(o)??{allOf:o};hi(n,a,c)}for(let a of s.required??[])i.add(a)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let a of t){let o=z_(a);if(o&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(o)))s.push(o)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function yI(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of j_)if(r in e)return;let n=t.filter((r)=>B_.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=ih(t);else{let r=n[0],s=B_.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let a=t.filter((c)=>c!==r),o=r[s].map((c)=>ih([...a,c]));if(o.some((c)=>!c))return;i={[s]:o}}if(!i)return;delete e.allOf,sc(e,i)}function ah(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(o)=>{let c=e.seen.get(o);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){i(d);let h=e.seen.get(d),y=h.schema;if(y.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(y);else sc(l,y);if(sc(l,u),o._zod.parent===d)for(let m in l){if(m==="$ref"||m==="allOf")continue;if(!(m in u))delete l[m]}if(y.$ref&&h.def)for(let m in l){if(m==="$ref"||m==="allOf")continue;if(m in h.def&&JSON.stringify(l[m])===JSON.stringify(h.def[m]))delete l[m]}}let f=o._zod.parent;if(f&&f!==d){i(f);let h=e.seen.get(f);if(h?.schema.$ref){if(l.$ref=h.schema.$ref,h.def)for(let y in l){if(y==="$ref"||y==="allOf")continue;if(y in h.def&&JSON.stringify(l[y])===JSON.stringify(h.def[y]))delete l[y]}}}e.override({zodSchema:o,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let o of[...e.seen.entries()].reverse())i(o[0]);if(e.target!=="openapi-3.0")for(let o of e.seen.entries())V_(o[1].def??o[1].schema);for(let o of e.deferred)o();if(e.intersections.length){let o=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let d=o.get(u);if(d)d.push(l);else o.set(u,[l])}for(let c of e.intersections)for(let l of o.get(c)??[])yI(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let o=e.external.registry.get(t)?.id;if(!o)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(o)}sc(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let o of e.seen.entries()){let c=o[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;hi(a,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(a).length>0)if(e.target==="draft-2020-12")r.$defs=a;else r.definitions=a;try{let o=JSON.parse(JSON.stringify(r));return Object.defineProperty(o,"~standard",{value:{...t["~standard"],jsonSchema:{input:ac(t,"input",e.processors),output:ac(t,"output",e.processors)}},enumerable:!1,writable:!1}),o}catch(o){throw Error("Error converting schema to JSON.")}}function Fn(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Fn(i.element,n);if(i.type==="set")return Fn(i.valueType,n);if(i.type==="lazy")return Fn(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return Fn(i.innerType,n);if(i.type==="intersection")return Fn(i.left,n)||Fn(i.right,n);if(i.type==="record"||i.type==="map")return Fn(i.keyType,n)||Fn(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return Fn(i.in,n)||Fn(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(Fn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(Fn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(Fn(r,n))return!0;if(i.rest&&Fn(i.rest,n))return!0;return!1}return!1}var H_=(e,t={})=>(n)=>{let i=rh({...n,processors:t});return Xt(e,i),sh(i,e),ah(i,e)},ac=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},a=rh({...r??{},target:s,io:t,processors:n});return Xt(e,a),sh(a,e),ah(a,e)};var Ba=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},za=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},G_=(e,t)=>{Ba(e,"minimum",t),za(e,"maximum",t)},X_=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},q_=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},J_=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},Z_=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},$_=(e,t)=>Ba(e,"minimum",t.minimum),K_=(e,t)=>za(e,"maximum",t.maximum),W_=(e)=>(t,n)=>{Z_(t,n.format);let[i,r]=e[n.format];Ba(t,"minimum",i),za(t,"maximum",r)},xI={greater_than:(e,t)=>Ba(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>za(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>X_(e,t.value),number_format:W_(Rl),bigint_format:W_(Tf),min_length:$_,max_length:K_,length_equals:(e,t)=>G_(e,t.length),min_size:$_,max_size:K_,size_equals:(e,t)=>G_(e,t.size),string_format:(e,t)=>{if(Z_(e,t.format),t.pattern)q_(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>J_(e,t.mime)};function Yn(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)xI[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Ba(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Ba(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)za(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)za(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)X_(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)J_(t,r.mime);for(let s of r.patterns??[])q_(t,s);return t}var _I={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},vI=new Map([[Bf,uy],[Gl,dy]]),Y_=(e)=>vI.get(e)??e,Q_=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:a,format:o,patterns:c,contentEncoding:l,laxFormat:u}=Yn(e);if(typeof s==="number")r.minLength=s;if(typeof a==="number")r.maxLength=a;if(o){if(r.format=_I[o]??o,r.format==="")delete r.format;if(o==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let d=[...c].map(Y_);if(d.length===1)r.pattern=d[0].source;else if(d.length>1)r.allOf=[...d.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},e0=(e,t,n,i)=>{let r=n,{minimum:s,maximum:a,multipleOf:o,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Yn(e);r.type=u?"integer":"number";let d=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),f=typeof c==="number"&&c<=(a??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(d)if(h)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(f)if(h)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof a==="number")r.maximum=a;if(o){let y=new Set;for(let p of o)if(Number.isFinite(p)&&p!==0)y.add(Math.abs(p));else Mr(e,t,r,i,`A multipleOf divisor of ${p} cannot be represented in JSON Schema`);let[g,...m]=y;if(g!==void 0)r.multipleOf=g;if(m.length)r.allOf=[...r.allOf??[],...m.map((p)=>({multipleOf:p}))]}},t0=(e,t,n,i)=>{n.type="boolean"};var n0=(e,t,n,i)=>{n.not={}};var i0=(e,t,n,i)=>{};var r0=(e,t,n,i)=>{let r=e._zod.def,s=Xo(r.entries);if(s.length===0){n.not={};return}if(s.every((a)=>typeof a==="number"))n.type="number";if(s.every((a)=>typeof a==="string"))n.type="string";n.enum=s},s0=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let a of r.values)if(a===void 0){if(Mr(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a==="bigint"){if(Mr(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(a))}else s.push(a);if(s.length===0);else if(s.length===1){let a=s[0];if(n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[a];else n.const=a}else{if(s.every((a)=>typeof a==="number"))n.type="number";if(s.every((a)=>typeof a==="string"))n.type="string";if(s.every((a)=>typeof a==="boolean"))n.type="boolean";if(s.every((a)=>a===null))n.type="null";n.enum=s}};var a0=(e,t,n,i)=>{let r=n,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");r.type="string",r.pattern=s.source};var o0=(e,t,n,i)=>{Mr(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var c0=(e,t,n,i)=>{Mr(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var l0=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:a,maximum:o}=Yn(e);if(typeof a==="number")r.minItems=a;if(typeof o==="number")r.maxItems=o;r.type="array",r.items=Xt(s.element,t,{...i,path:[...i.path,"items"]})};function oc(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return oc(t.out);if(t.type==="catch")return oc(t.innerType);return e._zod.optin}var u0=(e,t,n,i)=>{let r=n,s=e._zod.def,a=s.shape;if(Object.getOwnPropertySymbols(a).length&&Mr(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in a)hi(r.properties,l,Xt(a[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(a)){let u=s.shape[l];if(t.io==="input"?oc(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=Xt(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},d0=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,a=r.options.map((o,c)=>Xt(o,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=a;else n.anyOf=a},f0=(e,t,n,i)=>{let r=e._zod.def,s=Xt(r.left,t,{...i,path:[...i.path,"allOf",0]}),a=Xt(r.right,t,{...i,path:[...i.path,"allOf",1]}),o=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...o(s)?s.allOf:[s],...o(a)?a.allOf:[a]];n.allOf=c,t.intersections.push(c)},h0=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",o=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((g,m)=>Xt(g,t,{...i,path:[...i.path,a,m]})),l=s.rest?Xt(s.rest,t,{...i,path:[...i.path,o,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,u=s.items.length;while(u>0){let g=s.items[u-1];if(!(t.io==="input"?oc(g)!==void 0:g._zod.optout==="optional"))break;u--}let d=s.items.length,f=!s.rest;if(t.target==="draft-2020-12"){if(r.prefixItems=c,f)r.items=!1;else if(l)r.items=l;if(u>0)r.minItems=u;if(f)r.maxItems=d}else if(t.target==="openapi-3.0"){if(r.items={anyOf:c},l)r.items.anyOf.push(l);if(u>0)r.minItems=u;if(f)r.maxItems=d}else{if(r.items=c,f)r.additionalItems=!1;else if(l)r.additionalItems=l;if(u>0)r.minItems=u;if(f)r.maxItems=d}let{minimum:h,maximum:y}=Yn(e);if(typeof h==="number")r.minItems=h;if(typeof y==="number")r.maxItems=y};function oh(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let y=e.get(t)?.def;if(!y)return t;let g=oh(e,y,n);return g===y?t:g}for(let y of["anyOf","oneOf"]){let g=t[y];if(!Array.isArray(g))continue;let m=g.map((p)=>oh(e,p,n));if(m.some((p,b)=>p!==g[b]))t={...t,[y]:m}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((y)=>y==="number"||y==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((y)=>typeof y==="number"))return t;let{minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...h}=t;if(h.enum)h.enum=h.enum.map((y)=>typeof y==="number"?String(y):y);else if(typeof h.const==="number")h.const=String(h.const);if(!r)return h;if(h.type="string",!s)h.pattern=(i.includes("number")?Fa:Ul).source;return h}var ch=new WeakMap;function EI(e){let t=new Map;for(let i of e.seen.values())if(i.def&&!t.has(i.schema))t.set(i.schema,i);let n=new Map;for(let i of ch.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let a=oh(t,s,new Set);if(a!==s)n.set(s,a)}if(!n.size)return;for(let i of e.seen.values())for(let r of[i.schema,i.def]){let s=r&&n.get(r.propertyNames);if(s)r.propertyNames=s}}var p0=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let a=s.keyType,o=Yn(a).patterns;if(s.mode==="loose"&&o&&o.size>0){let u=Xt(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let d of o)hi(r.patternProperties,Y_(d).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=Xt(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=ch.get(t);if(!u)u=[],ch.set(t,u),t.deferred.push(()=>EI(t));u.push(e)}r.additionalProperties=Xt(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=a._zod.values,l=t.io==="input"&&oc(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((d)=>typeof d==="string"||typeof d==="number");if(u.length>0)r.required=u.map(String)}},m0=(e,t,n,i)=>{let r=e._zod.def,s=Xt(r.innerType,t,i),a=t.seen.get(e);if(t.target==="openapi-3.0")a.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},g0=(e,t,n,i)=>{let r=e._zod.def;Xt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},lh=Symbol();function b0(e,t,n,i,r){let s=!1,a=JSON.stringify(e,(o,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(a);return Mr(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),lh}var y0=(e,t,n,i)=>{let r=e._zod.def;Xt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let a=b0(r.defaultValue,e,t,n,i);if(a!==lh)n.default=a},x0=(e,t,n,i)=>{let r=e._zod.def;Xt(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let a=b0(r.defaultValue,e,t,n,i);if(a!==lh)n._prefault=a},_0=(e,t,n,i)=>{let r=e._zod.def;Xt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let a;try{a=r.catchValue(void 0)}catch{Mr(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=a},v0=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?s?r.out:r.in:r.out;Xt(a,t,i);let o=t.seen.get(e);o.ref=a},E0=(e,t,n,i)=>{let r=e._zod.def;Xt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var uh=(e,t,n,i)=>{let r=e._zod.def;Xt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var T0=new WeakSet([Object.prototype,Error.prototype]);function eu(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var CI=(e,t)=>{Fb.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(T0.has(n))return;T0.add(n),eu(n,"format",(i)=>(r)=>Bb(i,r)),eu(n,"flatten",(i)=>(r)=>Ub(i,r)),eu(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,qo,2)}),eu(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,qo,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Qn=se("ZodError",CI,void 0,{Parent:Error});var A0=kl(Qn),S0=Dl(Qn),w0=Ll(Qn),M0=Fl(Qn),R0=Vb(Qn),I0=jb(Qn),C0=Hb(Qn),N0=Gb(Qn),P0=$b(Qn),O0=Kb(Qn),k0=Wb(Qn),D0=Xb(Qn);function PI(){if(!Ln.localeError)Zn($f())}function cc(){if(!Ln.memoizer)Zn({memoizer:Qx()})}var $t=se("ZodType",(e,t)=>(PI(),Ut.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Jn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Wi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(N1(e,t))},superRefine(e,t){return this.check(P1(e,t))},overwrite(e){return this.check(Zr(e))},optional(){return U0(this)},exactOptional(){return g1(this)},nullable(){return B0(this)},nullish(){return U0(B0(this))},nonoptional(e){return E1(this,e)},array(){return at(this)},or(e){return Va([this,e])},and(e){return d1(this,e)},transform(e){return z0(this,m1(e))},default(e){return x1(this,e)},prefault(e){return v1(this,e)},catch(e){return A1(this,e)},pipe(e){return z0(this,e)},readonly(){return M1(this)},describe(e){let t=this.clone();return na.add(t,{description:e}),t},meta(...e){if(e.length===0)return na.get(this);let t=this.clone();return na.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Pl(this,"~standard",{...Uf(this),jsonSchema:{input:ac(this,"input"),output:ac(this,"output")}})},set "~standard"(e){Sr(this,"~standard",e)},parse:function e(t,n){return A0(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await S0(this,t,n,{callee:e})},safeParse(e,t){return w0(this,e,t)},async safeParseAsync(e,t){return M0(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Sr(this,"spa",e)},validate(e,t){return Rf(this,e,t)},validateAsync(e,t){return If(this,e,t)},encode:function e(t,n){return R0(this,t,n,{callee:e})},decode:function e(t,n){return I0(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await C0(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await N0(this,t,n,{callee:e})},safeEncode(e,t){return P0(this,e,t)},safeDecode(e,t){return O0(this,e,t)},async safeEncodeAsync(e,t){return k0(this,e,t)},async safeDecodeAsync(e,t){return D0(this,e,t)},toJSONSchema(e){return H_(this,{})(e)},get description(){return na.get(this)?.description},get _def(){return this._zod.def}}),V0=se("_ZodString",(e,t)=>{Hl.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Q_(e,n,i,r)},Nb({format:(e)=>Yn(e).format??null,minLength:(e)=>Yn(e).minimum??null,maxLength:(e)=>Yn(e).maximum??null},{regex(...e){return this.check(Kf(...e))},includes(...e){return this.check(qf(...e))},startsWith(...e){return this.check(Jf(...e))},endsWith(...e){return this.check(Zf(...e))},min(...e){return this.check(Ua(...e))},max(...e){return this.check(Yl(...e))},length(...e){return this.check(Ql(...e))},nonempty(...e){return this.check(Ua(1,...e))},lowercase(e){return this.check(Wf(e))},uppercase(e){return this.check(Xf(e))},trim(){return this.check(Qf())},normalize(...e){return this.check(Yf(...e))},toLowerCase(){return this.check(eh())},toUpperCase(){return this.check(th())},slugify(){return this.check(nh())}})),OI=se("ZodString",(e,t)=>{Hl.init(e,t),V0.init(e,t)},{email(e){return this.check(r_(UI,e))},url(e){return this.check(u_(zI,e))},jwt(e){return this.check(S_(t1,e))},emoji(e){return this.check(d_(VI,e))},guid(e){return this.check(s_(BI,e))},uuid(e){return this.check(a_(tu,e))},uuidv4(e){return this.check(o_(tu,e))},uuidv6(e){return this.check(c_(tu,e))},uuidv7(e){return this.check(l_(tu,e))},nanoid(e){return this.check(f_(jI,e))},cuid(e){return this.check(h_(HI,e))},cuid2(e){return this.check(p_(GI,e))},ulid(e){return this.check(m_($I,e))},base64(e){return this.check(E_(YI,e))},base64url(e){return this.check(T_(QI,e))},xid(e){return this.check(g_(KI,e))},ksuid(e){return this.check(b_(WI,e))},ipv4(e){return this.check(y_(XI,e))},ipv6(e){return this.check(x_(qI,e))},cidrv4(e){return this.check(__(JI,e))},cidrv6(e){return this.check(v_(ZI,e))},e164(e){return this.check(A_(e1,e))},datetime(e){return this.check(w_(kI,e))},date(e){return this.check(M_(DI,e))},time(e){return this.check(R_(LI,e))},duration(e){return this.check(I_(FI,e))}});function Le(e){return i_(OI,e)}var qt=se("ZodStringFormat",(e,t)=>{Gt.init(e,t),V0.init(e,t)}),kI=se("ZodISODateTime",(e,t)=>{ux.init(e,t),qt.init(e,t)}),DI=se("ZodISODate",(e,t)=>{dx.init(e,t),qt.init(e,t)}),LI=se("ZodISOTime",(e,t)=>{fx.init(e,t),qt.init(e,t)}),FI=se("ZodISODuration",(e,t)=>{hx.init(e,t),qt.init(e,t)}),UI=se("ZodEmail",(e,t)=>{Qy.init(e,t),qt.init(e,t)});var BI=se("ZodGUID",(e,t)=>{Zy.init(e,t),qt.init(e,t)});var tu=se("ZodUUID",(e,t)=>{Yy.init(e,t),qt.init(e,t)});var zI=se("ZodURL",(e,t)=>{nx.init(e,t),qt.init(e,t)});var VI=se("ZodEmoji",(e,t)=>{ix.init(e,t),qt.init(e,t)});var jI=se("ZodNanoID",(e,t)=>{rx.init(e,t),qt.init(e,t)});var HI=se("ZodCUID",(e,t)=>{sx.init(e,t),qt.init(e,t)});var GI=se("ZodCUID2",(e,t)=>{ax.init(e,t),qt.init(e,t)});var $I=se("ZodULID",(e,t)=>{ox.init(e,t),qt.init(e,t)});var KI=se("ZodXID",(e,t)=>{cx.init(e,t),qt.init(e,t)});var WI=se("ZodKSUID",(e,t)=>{lx.init(e,t),qt.init(e,t)});var XI=se("ZodIPv4",(e,t)=>{px.init(e,t),qt.init(e,t)});var qI=se("ZodIPv6",(e,t)=>{gx.init(e,t),qt.init(e,t)});var JI=se("ZodCIDRv4",(e,t)=>{bx.init(e,t),qt.init(e,t)});var ZI=se("ZodCIDRv6",(e,t)=>{yx.init(e,t),qt.init(e,t)});var YI=se("ZodBase64",(e,t)=>{_x.init(e,t),qt.init(e,t)});var QI=se("ZodBase64URL",(e,t)=>{vx.init(e,t),qt.init(e,t)});var e1=se("ZodE164",(e,t)=>{Ex.init(e,t),qt.init(e,t)});var t1=se("ZodJWT",(e,t)=>{Tx.init(e,t),qt.init(e,t)});var j0=se("ZodNumber",(e,t)=>{zf.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>e0(e,n,i,r),e.isFinite=!0},Nb({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=Yn(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=Yn(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=Yn(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>Yn(e).format??null},{gt(e,t){return this.check(Jl(e,t))},gte(e,t){return this.check(rc(e,t))},min(e,t){return this.check(rc(e,t))},lt(e,t){return this.check(ql(e,t))},lte(e,t){return this.check(ic(e,t))},max(e,t){return this.check(ic(e,t))},int(e){return this.check(L0(e))},safe(e){return this.check(L0(e))},positive(e){return this.check(Jl(0,e))},nonnegative(e){return this.check(rc(0,e))},negative(e){return this.check(ql(0,e))},nonpositive(e){return this.check(ic(0,e))},multipleOf(e,t){return this.check(Zl(e,t))},step(e,t){return this.check(Zl(e,t))},finite(){return this}}));function mt(e){return C_(j0,e)}var n1=se("ZodNumberFormat",(e,t)=>{Ax.init(e,t),j0.init(e,t)});function L0(e){return N_(n1,e)}var i1=se("ZodBoolean",(e,t)=>{Sx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>t0(e,n,i,r)});function ra(e){return P_(i1,e)}var r1=se("ZodUnknown",(e,t)=>{wx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>i0(e,n,i,r)});function ia(){return O_(r1)}var s1=se("ZodNever",(e,t)=>{Mx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>n0(e,n,i,r)});function a1(e){return k_(s1,e)}var o1=se("ZodArray",(e,t)=>{cc(),Rx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>l0(e,n,i,r),e.element=t.element},{min(e,t){return this.check(Ua(e,t))},nonempty(e){return this.check(Ua(1,e))},max(e,t){return this.check(Yl(e,t))},length(e,t){return this.check(Ql(e,t))},unwrap(){return this.element}});function at(e,t){return D_(o1,e,t)}var c1=se("ZodObject",(e,t)=>{cc(),Nx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>u0(e,n,i,r),BR(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return It(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Jn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Jn(this._zod.def,{catchall:ia()}))},loose(){return this.clone(Jn(this._zod.def,{catchall:ia()}))},strict(){return this.clone(Jn(this._zod.def,{catchall:a1()}))},strip(){return this.clone(Jn(this._zod.def,{catchall:void 0}))},extend(e){return NR(this,e)},safeExtend(e){return PR(this,e)},merge(e){return OR(this,e)},pick(e){return IR(this,e)},omit(e){return CR(this,e)},partial(...e){return Mb(hh,this,e[0])},exactPartial(...e){return Mb($0,this,e[0],"exactPartial")},required(...e){return kR(K0,this,e[0])}});function be(e,t){let n={type:"object",shape:e??{},...Fe(t)};return new c1(n)}var H0=se("ZodUnion",(e,t)=>{Vf.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>d0(e,n,i,r),e.options=t.options});function Va(e,t){return new H0({type:"union",options:e,...Fe(t)})}var l1=se("ZodDiscriminatedUnion",(e,t)=>{H0.init(e,t),Px.init(e,t)});function wi(e,t,n){return new l1({type:"union",options:t,discriminator:e,...Fe(n)})}var u1=se("ZodIntersection",(e,t)=>{Ox.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>f0(e,n,i,r)});function d1(e,t){return new u1({type:"intersection",left:e,right:t})}var f1=se("ZodTuple",(e,t)=>{cc(),kx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>h0(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new hh({type:"optional",innerType:t}))})}});function G0(e,t,n){let i=t instanceof Ut,r=i?n:t;return new f1({type:"tuple",items:e,rest:i?t:null,...Fe(r)})}var F0=se("ZodRecord",(e,t)=>{cc(),Dx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>p0(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function nu(e,t,n){if(!t||!t._zod)return new F0({type:"record",keyType:Le(),valueType:e,...Fe(t)});return new F0({type:"record",keyType:e,valueType:t,...Fe(n)})}var fh=se("ZodEnum",(e,t)=>{Lx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(i,r,s)=>r0(e,i,r,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let a of i)if(n.has(a))s[a]=t.entries[a];else throw Error(`Key ${a} not found in enum`);return new fh({...t,checks:[],...Fe(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let a of i)if(n.has(a))delete s[a];else throw Error(`Key ${a} not found in enum`);return new fh({...t,checks:[],...Fe(r),entries:s})}});function It(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new fh({type:"enum",entries:n,...Fe(t)})}var h1=se("ZodLiteral",(e,t)=>{Fx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>s0(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $e(e,t){return new h1({type:"literal",values:Array.isArray(e)?e:[e],...Fe(t)})}var p1=se("ZodTransform",(e,t)=>{cc(),Ux.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>c0(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Yo(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(ta(s,n.value,t));else{let a=s;if(a.fatal)a.continue=!1;if(a.code??(a.code="custom"),!("input"in a))a.input=n.value;a.inst??(a.inst=e),n.issues.push(ta(a))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function m1(e){return new p1({type:"transform",transform:e})}var hh=se("ZodOptional",(e,t)=>{jf.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>uh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function U0(e){return new hh({type:"optional",innerType:e})}var $0=se("ZodExactOptional",(e,t)=>{Bx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>uh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function g1(e){return new $0({type:"optional",innerType:e})}var b1=se("ZodNullable",(e,t)=>{zx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>m0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function B0(e){return new b1({type:"nullable",innerType:e})}var y1=se("ZodDefault",(e,t)=>{Vx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>y0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function x1(e,t){return new y1({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():vf(t)}})}var _1=se("ZodPrefault",(e,t)=>{jx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>x0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function v1(e,t){return new _1({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():vf(t)}})}var K0=se("ZodNonOptional",(e,t)=>{Hx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>g0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function E1(e,t){return new K0({type:"nonoptional",innerType:e,...Fe(t)})}var T1=se("ZodCatch",(e,t)=>{Gx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function A1(e,t){return new T1({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Pb(t)})}var S1=se("ZodPipe",(e,t)=>{$x.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>v0(e,n,i,r),e.in=t.in,e.out=t.out});function z0(e,t){return new S1({type:"pipe",in:e,out:t})}var w1=se("ZodReadonly",(e,t)=>{Kx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>E0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function M1(e){return new w1({type:"readonly",innerType:e})}var R1=se("ZodTemplateLiteral",(e,t)=>{Wx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>a0(e,n,i,r)});function I1(e,t){return new R1({type:"template_literal",parts:e,...Fe(t)})}var C1=se("ZodCustom",(e,t)=>{Xx.init(e,t),$t.init(e,t),e._zod.processJSONSchema=(n,i,r)=>o0(e,n,i,r)});function N1(e,t={}){return L_(C1,e,t)}function P1(e,t){return F_(e,t)}var iu={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var W0;(function(e){})(W0||(W0={}));var X0=["neutral","dark","light"];var ph=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),q0=Object.freeze({neutral:ph("neutral",[170,177,188]),dark:ph("dark",[26,26,26]),light:ph("light",[223,227,232])});var Jz=q0.neutral.rgb,Zz=q0.neutral.hex;/*!+Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let o=a[1];if(t===a[0]){s(a);continue}if(e.external){let l=e.external.registry.get(a[0])?.id;if(t!==a[0]&&l){s(a);continue}}if(e.metadataRegistry.get(a[0])?.id){s(a);continue}if(o.cycle){s(a);continue}if(o.count>1){if(e.reused==="ref")s(a)}}if(e.external)e.sharedDefsExtractedFor=e.external}function s0(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!=="object")return;s0(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let a of Array.isArray(s)?s:[s]){if(typeof a!=="string")return;if(!n.includes(a))n.push(a)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var a0=new Set(["type","properties","required","additionalProperties"]),i0=["oneOf","anyOf"];function r0(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function _h(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let a in s)if(!a0.has(a))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let a in s.properties){if(Object.prototype.hasOwnProperty.call(n,a))continue;let o=[];for(let l of t){let u=l.properties?.[a]??r0(l);if(u===null||u===void 0)continue;if(!o.some((d)=>JSON.stringify(d)===JSON.stringify(u)))o.push(u)}let c=o.length===1?o[0]:_h(o)??{allOf:o};mi(n,a,c)}for(let a of s.required??[])i.add(a)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let a of t){let o=r0(a);if(o&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(o)))s.push(o)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function ZI(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of a0)if(r in e)return;let n=t.filter((r)=>i0.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=_h(t);else{let r=n[0],s=i0.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let a=t.filter((c)=>c!==r),o=r[s].map((c)=>_h([...a,c]));if(o.some((c)=>!c))return;i={[s]:o}}if(!i)return;delete e.allOf,pc(e,i)}function Th(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(o)=>{let c=e.seen.get(o);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){i(d);let h=e.seen.get(d),b=h.schema;if(b.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(b);else pc(l,b);if(pc(l,u),o._zod.parent===d)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(!(g in u))delete l[g]}if(b.$ref&&h.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in h.def&&JSON.stringify(l[g])===JSON.stringify(h.def[g]))delete l[g]}}let f=o._zod.parent;if(f&&f!==d){i(f);let h=e.seen.get(f);if(h?.schema.$ref){if(l.$ref=h.schema.$ref,h.def)for(let b in l){if(b==="$ref"||b==="allOf")continue;if(b in h.def&&JSON.stringify(l[b])===JSON.stringify(h.def[b]))delete l[b]}}}e.override({zodSchema:o,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let o of[...e.seen.entries()].reverse())i(o[0]);if(e.target!=="openapi-3.0")for(let o of e.seen.entries())s0(o[1].def??o[1].schema);for(let o of e.deferred)o();if(e.intersections.length){let o=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let d=o.get(u);if(d)d.push(l);else o.set(u,[l])}for(let c of e.intersections)for(let l of o.get(c)??[])ZI(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let o=e.external.registry.get(t)?.id;if(!o)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(o)}pc(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let o of e.seen.entries()){let c=o[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;mi(a,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(a).length>0)if(e.target==="draft-2020-12")r.$defs=a;else r.definitions=a;try{let o=JSON.parse(JSON.stringify(r));return Object.defineProperty(o,"~standard",{value:{...t["~standard"],jsonSchema:{input:mc(t,"input",e.processors),output:mc(t,"output",e.processors)}},enumerable:!1,writable:!1}),o}catch(o){throw Error("Error converting schema to JSON.")}}function Bn(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Bn(i.element,n);if(i.type==="set")return Bn(i.valueType,n);if(i.type==="lazy")return Bn(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return Bn(i.innerType,n);if(i.type==="intersection")return Bn(i.left,n)||Bn(i.right,n);if(i.type==="record"||i.type==="map")return Bn(i.keyType,n)||Bn(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return Bn(i.in,n)||Bn(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(Bn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(Bn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(Bn(r,n))return!0;if(i.rest&&Bn(i.rest,n))return!0;return!1}return!1}var o0=(e,t={})=>(n)=>{let i=vh({...n,processors:t});return qt(e,i),Eh(i,e),Th(i,e)},mc=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},a=vh({...r??{},target:s,io:t,processors:n});return qt(e,a),Eh(a,e),Th(a,e)};var $a=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Ka=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},c0=(e,t)=>{$a(e,"minimum",t),Ka(e,"maximum",t)},f0=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},h0=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},p0=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},m0=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},l0=(e,t)=>$a(e,"minimum",t.minimum),u0=(e,t)=>Ka(e,"maximum",t.maximum),d0=(e)=>(t,n)=>{m0(t,n.format);let[i,r]=e[n.format];$a(t,"minimum",i),Ka(t,"maximum",r)},YI={greater_than:(e,t)=>$a(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Ka(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>f0(e,t.value),number_format:d0(jl),bigint_format:d0(zf),min_length:l0,max_length:u0,length_equals:(e,t)=>c0(e,t.length),min_size:l0,max_size:u0,size_equals:(e,t)=>c0(e,t.size),string_format:(e,t)=>{if(m0(e,t.format),t.pattern)h0(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>p0(e,t.mime)};function ti(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)YI[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)$a(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)$a(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)Ka(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)Ka(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)f0(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)p0(t,r.mime);for(let s of r.patterns??[])h0(t,s);return t}var QI={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},e1=new Map([[nh,Rx],[ru,Ix]]),g0=(e)=>e1.get(e)??e,b0=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:a,format:o,patterns:c,contentEncoding:l,laxFormat:u}=ti(e);if(typeof s==="number")r.minLength=s;if(typeof a==="number")r.maxLength=a;if(o){if(r.format=QI[o]??o,r.format==="")delete r.format;if(o==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let d=[...c].map(g0);if(d.length===1)r.pattern=d[0].source;else if(d.length>1)r.allOf=[...d.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},x0=(e,t,n,i)=>{let r=n,{minimum:s,maximum:a,multipleOf:o,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=ti(e);r.type=u?"integer":"number";let d=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),f=typeof c==="number"&&c<=(a??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(d)if(h)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(f)if(h)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof a==="number")r.maximum=a;if(o){let b=new Set;for(let p of o)if(Number.isFinite(p)&&p!==0)b.add(Math.abs(p));else Ir(e,t,r,i,`A multipleOf divisor of ${p} cannot be represented in JSON Schema`);let[m,...g]=b;if(m!==void 0)r.multipleOf=m;if(g.length)r.allOf=[...r.allOf??[],...g.map((p)=>({multipleOf:p}))]}},y0=(e,t,n,i)=>{n.type="boolean"};var _0=(e,t,n,i)=>{n.not={}};var v0=(e,t,n,i)=>{};var E0=(e,t,n,i)=>{let r=e._zod.def,s=ic(r.entries);if(s.length===0){n.not={};return}if(s.every((a)=>typeof a==="number"))n.type="number";if(s.every((a)=>typeof a==="string"))n.type="string";n.enum=s},T0=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let a of r.values)if(a===void 0){if(Ir(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a==="bigint"){if(Ir(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(a))}else s.push(a);if(s.length===0);else if(s.length===1){let a=s[0];if(n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[a];else n.const=a}else{if(s.every((a)=>typeof a==="number"))n.type="number";if(s.every((a)=>typeof a==="string"))n.type="string";if(s.every((a)=>typeof a==="boolean"))n.type="boolean";if(s.every((a)=>a===null))n.type="null";n.enum=s}};var A0=(e,t,n,i)=>{let r=n,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");r.type="string",r.pattern=s.source};var w0=(e,t,n,i)=>{Ir(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var S0=(e,t,n,i)=>{Ir(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var M0=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:a,maximum:o}=ti(e);if(typeof a==="number")r.minItems=a;if(typeof o==="number")r.maxItems=o;r.type="array",r.items=qt(s.element,t,{...i,path:[...i.path,"items"]})};function gc(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return gc(t.out);if(t.type==="catch")return gc(t.innerType);return e._zod.optin}var R0=(e,t,n,i)=>{let r=n,s=e._zod.def,a=s.shape;if(Object.getOwnPropertySymbols(a).length&&Ir(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in a)mi(r.properties,l,qt(a[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(a)){let u=s.shape[l];if(t.io==="input"?gc(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=qt(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},I0=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,a=r.options.map((o,c)=>qt(o,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=a;else n.anyOf=a},C0=(e,t,n,i)=>{let r=e._zod.def,s=qt(r.left,t,{...i,path:[...i.path,"allOf",0]}),a=qt(r.right,t,{...i,path:[...i.path,"allOf",1]}),o=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...o(s)?s.allOf:[s],...o(a)?a.allOf:[a]];n.allOf=c,t.intersections.push(c)},N0=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",o=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((m,g)=>qt(m,t,{...i,path:[...i.path,a,g]})),l=s.rest?qt(s.rest,t,{...i,path:[...i.path,o,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,u=s.items.length;while(u>0){let m=s.items[u-1];if(!(t.io==="input"?gc(m)!==void 0:m._zod.optout==="optional"))break;u--}let d=s.items.length,f=!s.rest;if(t.target==="draft-2020-12"){if(r.prefixItems=c,f)r.items=!1;else if(l)r.items=l;if(u>0)r.minItems=u;if(f)r.maxItems=d}else if(t.target==="openapi-3.0"){if(r.items={anyOf:c},l)r.items.anyOf.push(l);if(u>0)r.minItems=u;if(f)r.maxItems=d}else{if(r.items=c,f)r.additionalItems=!1;else if(l)r.additionalItems=l;if(u>0)r.minItems=u;if(f)r.maxItems=d}let{minimum:h,maximum:b}=ti(e);if(typeof h==="number")r.minItems=h;if(typeof b==="number")r.maxItems=b};function Ah(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let b=e.get(t)?.def;if(!b)return t;let m=Ah(e,b,n);return m===b?t:m}for(let b of["anyOf","oneOf"]){let m=t[b];if(!Array.isArray(m))continue;let g=m.map((p)=>Ah(e,p,n));if(g.some((p,x)=>p!==m[x]))t={...t,[b]:g}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((b)=>b==="number"||b==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((b)=>typeof b==="number"))return t;let{minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...h}=t;if(h.enum)h.enum=h.enum.map((b)=>typeof b==="number"?String(b):b);else if(typeof h.const==="number")h.const=String(h.const);if(!r)return h;if(h.type="string",!s)h.pattern=(i.includes("number")?Ha:Yl).source;return h}var wh=new WeakMap;function t1(e){let t=new Map;for(let i of e.seen.values())if(i.def&&!t.has(i.schema))t.set(i.schema,i);let n=new Map;for(let i of wh.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let a=Ah(t,s,new Set);if(a!==s)n.set(s,a)}if(!n.size)return;for(let i of e.seen.values())for(let r of[i.schema,i.def]){let s=r&&n.get(r.propertyNames);if(s)r.propertyNames=s}}var P0=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let a=s.keyType,o=ti(a).patterns;if(s.mode==="loose"&&o&&o.size>0){let u=qt(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let d of o)mi(r.patternProperties,g0(d).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=qt(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=wh.get(t);if(!u)u=[],wh.set(t,u),t.deferred.push(()=>t1(t));u.push(e)}r.additionalProperties=qt(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=a._zod.values,l=t.io==="input"&&gc(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((d)=>typeof d==="string"||typeof d==="number");if(u.length>0)r.required=u.map(String)}},O0=(e,t,n,i)=>{let r=e._zod.def,s=qt(r.innerType,t,i),a=t.seen.get(e);if(t.target==="openapi-3.0")a.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},k0=(e,t,n,i)=>{let r=e._zod.def;qt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Sh=Symbol();function D0(e,t,n,i,r){let s=!1,a=JSON.stringify(e,(o,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(a);return Ir(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),Sh}var L0=(e,t,n,i)=>{let r=e._zod.def;qt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let a=D0(r.defaultValue,e,t,n,i);if(a!==Sh)n.default=a},F0=(e,t,n,i)=>{let r=e._zod.def;qt(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let a=D0(r.defaultValue,e,t,n,i);if(a!==Sh)n._prefault=a},U0=(e,t,n,i)=>{let r=e._zod.def;qt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let a;try{a=r.catchValue(void 0)}catch{Ir(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=a},B0=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?s?r.out:r.in:r.out;qt(a,t,i);let o=t.seen.get(e);o.ref=a},z0=(e,t,n,i)=>{let r=e._zod.def;qt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var Mh=(e,t,n,i)=>{let r=e._zod.def;qt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var V0=new WeakSet([Object.prototype,Error.prototype]);function pu(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var l1=(e,t)=>{tx.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(V0.has(n))return;V0.add(n),pu(n,"format",(i)=>(r)=>ix(i,r)),pu(n,"flatten",(i)=>(r)=>nx(i,r)),pu(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,rc,2)}),pu(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,rc,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var ni=se("ZodError",l1,void 0,{Parent:Error});var j0=Xl(ni),H0=ql(ni),G0=Jl(ni),$0=Zl(ni),K0=sx(ni),W0=ax(ni),X0=ox(ni),q0=cx(ni),J0=lx(ni),Z0=ux(ni),Y0=dx(ni),Q0=fx(ni);function d1(){if(!Un.localeError)ei(ch())}function bc(){if(!Un.memoizer)ei({memoizer:b_()})}var Kt=se("ZodType",(e,t)=>(d1(),Ut.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Qn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Ji(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(uC(e,t))},superRefine(e,t){return this.check(dC(e,t))},overwrite(e){return this.check(Qr(e))},optional(){return nv(this)},exactOptional(){return q1(this)},nullable(){return iv(this)},nullish(){return nv(iv(this))},nonoptional(e){return tC(this,e)},array(){return at(this)},or(e){return Wa([this,e])},and(e){return G1(this,e)},transform(e){return rv(this,X1(e))},default(e){return Y1(this,e)},prefault(e){return eC(this,e)},catch(e){return iC(this,e)},pipe(e){return rv(this,e)},readonly(){return aC(this)},describe(e){let t=this.clone();return aa.add(t,{description:e}),t},meta(...e){if(e.length===0)return aa.get(this);let t=this.clone();return aa.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Kl(this,"~standard",{...th(this),jsonSchema:{input:mc(this,"input"),output:mc(this,"output")}})},set "~standard"(e){Mr(this,"~standard",e)},parse:function e(t,n){return j0(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await H0(this,t,n,{callee:e})},safeParse(e,t){return G0(this,e,t)},async safeParseAsync(e,t){return $0(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Mr(this,"spa",e)},validate(e,t){return $f(this,e,t)},validateAsync(e,t){return Kf(this,e,t)},encode:function e(t,n){return K0(this,t,n,{callee:e})},decode:function e(t,n){return W0(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await X0(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await q0(this,t,n,{callee:e})},safeEncode(e,t){return J0(this,e,t)},safeDecode(e,t){return Z0(this,e,t)},async safeEncodeAsync(e,t){return Y0(this,e,t)},async safeDecodeAsync(e,t){return Q0(this,e,t)},toJSONSchema(e){return o0(this,{})(e)},get description(){return aa.get(this)?.description},get _def(){return this._zod.def}}),sv=se("_ZodString",(e,t)=>{iu.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>b0(e,n,i,r)},qb({format:(e)=>ti(e).format??null,minLength:(e)=>ti(e).minimum??null,maxLength:(e)=>ti(e).maximum??null},{regex(...e){return this.check(lh(...e))},includes(...e){return this.check(fh(...e))},startsWith(...e){return this.check(hh(...e))},endsWith(...e){return this.check(ph(...e))},min(...e){return this.check(Ga(...e))},max(...e){return this.check(fu(...e))},length(...e){return this.check(hu(...e))},nonempty(...e){return this.check(Ga(1,...e))},lowercase(e){return this.check(uh(e))},uppercase(e){return this.check(dh(e))},trim(){return this.check(gh())},normalize(...e){return this.check(mh(...e))},toLowerCase(){return this.check(bh())},toUpperCase(){return this.check(xh())},slugify(){return this.check(yh())}})),f1=se("ZodString",(e,t)=>{iu.init(e,t),sv.init(e,t)},{email(e){return this.check(E_(b1,e))},url(e){return this.check(R_(y1,e))},jwt(e){return this.check(H_(k1,e))},emoji(e){return this.check(I_(_1,e))},guid(e){return this.check(T_(x1,e))},uuid(e){return this.check(A_(mu,e))},uuidv4(e){return this.check(w_(mu,e))},uuidv6(e){return this.check(S_(mu,e))},uuidv7(e){return this.check(M_(mu,e))},nanoid(e){return this.check(C_(v1,e))},cuid(e){return this.check(N_(E1,e))},cuid2(e){return this.check(P_(T1,e))},ulid(e){return this.check(O_(A1,e))},base64(e){return this.check(z_(N1,e))},base64url(e){return this.check(V_(P1,e))},xid(e){return this.check(k_(w1,e))},ksuid(e){return this.check(D_(S1,e))},ipv4(e){return this.check(L_(M1,e))},ipv6(e){return this.check(F_(R1,e))},cidrv4(e){return this.check(U_(I1,e))},cidrv6(e){return this.check(B_(C1,e))},e164(e){return this.check(j_(O1,e))},datetime(e){return this.check(G_(h1,e))},date(e){return this.check($_(p1,e))},time(e){return this.check(K_(m1,e))},duration(e){return this.check(W_(g1,e))}});function Le(e){return v_(f1,e)}var Jt=se("ZodStringFormat",(e,t)=>{$t.init(e,t),sv.init(e,t)}),h1=se("ZodISODateTime",(e,t)=>{Ry.init(e,t),Jt.init(e,t)}),p1=se("ZodISODate",(e,t)=>{Iy.init(e,t),Jt.init(e,t)}),m1=se("ZodISOTime",(e,t)=>{Cy.init(e,t),Jt.init(e,t)}),g1=se("ZodISODuration",(e,t)=>{Ny.init(e,t),Jt.init(e,t)}),b1=se("ZodEmail",(e,t)=>{by.init(e,t),Jt.init(e,t)});var x1=se("ZodGUID",(e,t)=>{my.init(e,t),Jt.init(e,t)});var mu=se("ZodUUID",(e,t)=>{gy.init(e,t),Jt.init(e,t)});var y1=se("ZodURL",(e,t)=>{_y.init(e,t),Jt.init(e,t)});var _1=se("ZodEmoji",(e,t)=>{vy.init(e,t),Jt.init(e,t)});var v1=se("ZodNanoID",(e,t)=>{Ey.init(e,t),Jt.init(e,t)});var E1=se("ZodCUID",(e,t)=>{Ty.init(e,t),Jt.init(e,t)});var T1=se("ZodCUID2",(e,t)=>{Ay.init(e,t),Jt.init(e,t)});var A1=se("ZodULID",(e,t)=>{wy.init(e,t),Jt.init(e,t)});var w1=se("ZodXID",(e,t)=>{Sy.init(e,t),Jt.init(e,t)});var S1=se("ZodKSUID",(e,t)=>{My.init(e,t),Jt.init(e,t)});var M1=se("ZodIPv4",(e,t)=>{Py.init(e,t),Jt.init(e,t)});var R1=se("ZodIPv6",(e,t)=>{ky.init(e,t),Jt.init(e,t)});var I1=se("ZodCIDRv4",(e,t)=>{Dy.init(e,t),Jt.init(e,t)});var C1=se("ZodCIDRv6",(e,t)=>{Ly.init(e,t),Jt.init(e,t)});var N1=se("ZodBase64",(e,t)=>{Uy.init(e,t),Jt.init(e,t)});var P1=se("ZodBase64URL",(e,t)=>{By.init(e,t),Jt.init(e,t)});var O1=se("ZodE164",(e,t)=>{zy.init(e,t),Jt.init(e,t)});var k1=se("ZodJWT",(e,t)=>{Vy.init(e,t),Jt.init(e,t)});var av=se("ZodNumber",(e,t)=>{ih.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>x0(e,n,i,r),e.isFinite=!0},qb({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=ti(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=ti(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=ti(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>ti(e).format??null},{gt(e,t){return this.check(uu(e,t))},gte(e,t){return this.check(hc(e,t))},min(e,t){return this.check(hc(e,t))},lt(e,t){return this.check(lu(e,t))},lte(e,t){return this.check(fc(e,t))},max(e,t){return this.check(fc(e,t))},int(e){return this.check(ev(e))},safe(e){return this.check(ev(e))},positive(e){return this.check(uu(0,e))},nonnegative(e){return this.check(hc(0,e))},negative(e){return this.check(lu(0,e))},nonpositive(e){return this.check(fc(0,e))},multipleOf(e,t){return this.check(du(e,t))},step(e,t){return this.check(du(e,t))},finite(){return this}}));function gt(e){return X_(av,e)}var D1=se("ZodNumberFormat",(e,t)=>{jy.init(e,t),av.init(e,t)});function ev(e){return q_(D1,e)}var L1=se("ZodBoolean",(e,t)=>{Hy.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>y0(e,n,i,r)});function ca(e){return J_(L1,e)}var F1=se("ZodUnknown",(e,t)=>{Gy.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>v0(e,n,i,r)});function oa(){return Z_(F1)}var U1=se("ZodNever",(e,t)=>{$y.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_0(e,n,i,r)});function B1(e){return Y_(U1,e)}var z1=se("ZodArray",(e,t)=>{bc(),Ky.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>M0(e,n,i,r),e.element=t.element},{min(e,t){return this.check(Ga(e,t))},nonempty(e){return this.check(Ga(1,e))},max(e,t){return this.check(fu(e,t))},length(e,t){return this.check(hu(e,t))},unwrap(){return this.element}});function at(e,t){return Q_(z1,e,t)}var V1=se("ZodObject",(e,t)=>{bc(),qy.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>R0(e,n,i,r),xI(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return Ct(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Qn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Qn(this._zod.def,{catchall:oa()}))},loose(){return this.clone(Qn(this._zod.def,{catchall:oa()}))},strict(){return this.clone(Qn(this._zod.def,{catchall:B1()}))},strip(){return this.clone(Qn(this._zod.def,{catchall:void 0}))},extend(e){return uI(this,e)},safeExtend(e){return dI(this,e)},merge(e){return fI(this,e)},pick(e){return cI(this,e)},omit(e){return lI(this,e)},partial(...e){return $b(Ch,this,e[0])},exactPartial(...e){return $b(lv,this,e[0],"exactPartial")},required(...e){return hI(uv,this,e[0])}});function be(e,t){let n={type:"object",shape:e??{},...Fe(t)};return new V1(n)}var ov=se("ZodUnion",(e,t)=>{rh.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>I0(e,n,i,r),e.options=t.options});function Wa(e,t){return new ov({type:"union",options:e,...Fe(t)})}var j1=se("ZodDiscriminatedUnion",(e,t)=>{ov.init(e,t),Jy.init(e,t)});function Ri(e,t,n){return new j1({type:"union",options:t,discriminator:e,...Fe(n)})}var H1=se("ZodIntersection",(e,t)=>{Zy.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>C0(e,n,i,r)});function G1(e,t){return new H1({type:"intersection",left:e,right:t})}var $1=se("ZodTuple",(e,t)=>{bc(),Yy.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>N0(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new Ch({type:"optional",innerType:t}))})}});function cv(e,t,n){let i=t instanceof Ut,r=i?n:t;return new $1({type:"tuple",items:e,rest:i?t:null,...Fe(r)})}var tv=se("ZodRecord",(e,t)=>{bc(),Qy.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>P0(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function gu(e,t,n){if(!t||!t._zod)return new tv({type:"record",keyType:Le(),valueType:e,...Fe(t)});return new tv({type:"record",keyType:e,valueType:t,...Fe(n)})}var Ih=se("ZodEnum",(e,t)=>{e_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(i,r,s)=>E0(e,i,r,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let a of i)if(n.has(a))s[a]=t.entries[a];else throw Error(`Key ${a} not found in enum`);return new Ih({...t,checks:[],...Fe(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let a of i)if(n.has(a))delete s[a];else throw Error(`Key ${a} not found in enum`);return new Ih({...t,checks:[],...Fe(r),entries:s})}});function Ct(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new Ih({type:"enum",entries:n,...Fe(t)})}var K1=se("ZodLiteral",(e,t)=>{t_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>T0(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $e(e,t){return new K1({type:"literal",values:Array.isArray(e)?e:[e],...Fe(t)})}var W1=se("ZodTransform",(e,t)=>{bc(),n_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>S0(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new oc(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(sa(s,n.value,t));else{let a=s;if(a.fatal)a.continue=!1;if(a.code??(a.code="custom"),!("input"in a))a.input=n.value;a.inst??(a.inst=e),n.issues.push(sa(a))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function X1(e){return new W1({type:"transform",transform:e})}var Ch=se("ZodOptional",(e,t)=>{sh.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Mh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function nv(e){return new Ch({type:"optional",innerType:e})}var lv=se("ZodExactOptional",(e,t)=>{i_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Mh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function q1(e){return new lv({type:"optional",innerType:e})}var J1=se("ZodNullable",(e,t)=>{r_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>O0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function iv(e){return new J1({type:"nullable",innerType:e})}var Z1=se("ZodDefault",(e,t)=>{s_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>L0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Y1(e,t){return new Z1({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Uf(t)}})}var Q1=se("ZodPrefault",(e,t)=>{a_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>F0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function eC(e,t){return new Q1({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Uf(t)}})}var uv=se("ZodNonOptional",(e,t)=>{o_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>k0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function tC(e,t){return new uv({type:"nonoptional",innerType:e,...Fe(t)})}var nC=se("ZodCatch",(e,t)=>{c_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>U0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function iC(e,t){return new nC({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Jb(t)})}var rC=se("ZodPipe",(e,t)=>{l_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>B0(e,n,i,r),e.in=t.in,e.out=t.out});function rv(e,t){return new rC({type:"pipe",in:e,out:t})}var sC=se("ZodReadonly",(e,t)=>{u_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>z0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function aC(e){return new sC({type:"readonly",innerType:e})}var oC=se("ZodTemplateLiteral",(e,t)=>{d_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>A0(e,n,i,r)});function cC(e,t){return new oC({type:"template_literal",parts:e,...Fe(t)})}var lC=se("ZodCustom",(e,t)=>{f_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>w0(e,n,i,r)});function uC(e,t={}){return e0(lC,e,t)}function dC(e,t){return t0(e,t)}var bu={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var dv;(function(e){})(dv||(dv={}));var fv=["neutral","dark","light"];var Nh=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),hv=Object.freeze({neutral:Nh("neutral",[170,177,188]),dark:Nh("dark",[26,26,26]),light:Nh("light",[223,227,232])});var WV=hv.neutral.rgb,XV=hv.neutral.hex;/*!fflate - fast JavaScript compression/decompression<https://101arrowz.github.io/fflate>Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSEversion 0.8.2-*/var Jt=Uint8Array,ei=Uint16Array,Sh=Int32Array,su=new Jt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),au=new Jt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),xh=new Jt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),nv=function(e,t){var n=new ei(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new Sh(n[30]);for(var i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return{b:n,r}},iv=nv(su,2),{b:rv,r:_h}=iv;rv[28]=258,_h[258]=28;var sv=nv(au,0),{b:O1,r:J0}=sv,vh=new ei(32768);for(ht=0;ht<32768;++ht)Zi=(ht&43690)>>1|(ht&21845)<<1,Zi=(Zi&52428)>>2|(Zi&13107)<<2,Zi=(Zi&61680)>>4|(Zi&3855)<<4,vh[ht]=((Zi&65280)>>8|(Zi&255)<<8)>>1;var Zi,ht,Qi=function(e,t,n){var i=e.length,r=0,s=new ei(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var a=new ei(t);for(r=1;r<t;++r)a[r]=a[r-1]+s[r-1]<<1;var o;if(n){o=new ei(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],d=a[e[r]-1]++<<u;for(var f=d|(1<<u)-1;d<=f;++d)o[vh[d]>>c]=l}}else{o=new ei(i);for(r=0;r<i;++r)if(e[r])o[r]=vh[a[e[r]-1]++]>>15-e[r]}return o},Yr=new Jt(288);for(ht=0;ht<144;++ht)Yr[ht]=8;var ht;for(ht=144;ht<256;++ht)Yr[ht]=9;var ht;for(ht=256;ht<280;++ht)Yr[ht]=7;var ht;for(ht=280;ht<288;++ht)Yr[ht]=8;var ht,dc=new Jt(32);for(ht=0;ht<32;++ht)dc[ht]=5;var ht,k1=Qi(Yr,9,0),D1=Qi(Yr,9,1),L1=Qi(dc,5,0),F1=Qi(dc,5,1),mh=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},Mi=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},gh=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},wh=function(e){return(e+7)/8|0},fc=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Jt(e.subarray(t,n))};var U1=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Un=function(e,t,n){var i=Error(t||U1[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,Un);if(!n)throw i;return i},B1=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Jt(0);var a=!n,o=a||t.i!=2,c=t.i;if(a)n=new Jt(r*3);var l=function(ce){var _e=n.length;if(ce>_e){var Re=new Jt(Math.max(_e*2,ce));Re.set(n),n=Re}},u=t.f||0,d=t.p||0,f=t.b||0,{l:h,d:y,m:g,n:m}=t,p=r*8;do{if(!h){u=Mi(e,d,1);var b=Mi(e,d+1,3);if(d+=3,!b){var _=wh(d)+4,x=e[_-4]|e[_-3]<<8,v=_+x;if(v>r){if(c)Un(0);break}if(o)l(f+x);n.set(e.subarray(_,v),f),t.b=f+=x,t.p=d=v*8,t.f=u;continue}else if(b==1)h=D1,y=F1,g=9,m=5;else if(b==2){var E=Mi(e,d,31)+257,S=Mi(e,d+10,15)+4,T=E+Mi(e,d+5,31)+1;d+=14;var A=new Jt(T),P=new Jt(19);for(var w=0;w<S;++w)P[xh[w]]=Mi(e,d+w*3,7);d+=S*3;var I=mh(P),F=(1<<I)-1,N=Qi(P,I,1);for(var w=0;w<T;){var U=N[Mi(e,d,F)];d+=U&15;var _=U>>4;if(_<16)A[w++]=_;else{var D=0,O=0;if(_==16)O=3+Mi(e,d,3),d+=2,D=A[w-1];else if(_==17)O=3+Mi(e,d,7),d+=3;else if(_==18)O=11+Mi(e,d,127),d+=7;while(O--)A[w++]=D}}var K=A.subarray(0,E),B=A.subarray(E);g=mh(K),m=mh(B),h=Qi(K,g,1),y=Qi(B,m,1)}else Un(1);if(d>p){if(c)Un(0);break}}if(o)l(f+131072);var X=(1<<g)-1,q=(1<<m)-1,le=d;for(;;le=d){var D=h[gh(e,d)&X],de=D>>4;if(d+=D&15,d>p){if(c)Un(0);break}if(!D)Un(2);if(de<256)n[f++]=de;else if(de==256){le=d,h=null;break}else{var Me=de-254;if(de>264){var w=de-257,pe=su[w];Me=Mi(e,d,(1<<pe)-1)+rv[w],d+=pe}var J=y[gh(e,d)&q],L=J>>4;if(!J)Un(3);d+=J&15;var B=O1[L];if(L>3){var pe=au[L];B+=gh(e,d)&(1<<pe)-1,d+=pe}if(d>p){if(c)Un(0);break}if(o)l(f+131072);var W=f+Me;if(f<B){var te=s-B,ie=Math.min(B,W);if(te+f<0)Un(3);for(;f<ie;++f)n[f]=i[te+f]}for(;f<W;++f)n[f]=n[f-B]}}if(t.l=h,t.p=le,t.b=f,t.f=u,h)u=1,t.m=g,t.d=y,t.n=m}while(!u);return f!=n.length&&a?fc(n,0,f):n.subarray(0,f)},Rr=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},lc=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},bh=function(e,t){var n=[];for(var i=0;i<e.length;++i)if(e[i])n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return{t:ov,l:0};if(r==1){var a=new Jt(n[0].s+1);return a[n[0].s]=1,{t:a,l:1}}n.sort(function(v,E){return v.f-E.f}),n.push({s:-1,f:25001});var o=n[0],c=n[1],l=0,u=1,d=2;n[0]={s:-1,f:o.f+c.f,l:o,r:c};while(u!=r-1)o=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:o.f+c.f,l:o,r:c};var f=s[0].s;for(var i=1;i<r;++i)if(s[i].s>f)f=s[i].s;var h=new ei(f+1),y=Eh(n[u-1],h,0);if(y>t){var i=0,g=0,m=y-t,p=1<<m;s.sort(function(E,S){return h[S.s]-h[E.s]||E.f-S.f});for(;i<r;++i){var b=s[i].s;if(h[b]>t)g+=p-(1<<y-h[b]),h[b]=t;else break}g>>=m;while(g>0){var _=s[i].s;if(h[_]<t)g-=1<<t-h[_]++-1;else++i}for(;i>=0&&g;--i){var x=s[i].s;if(h[x]==t)--h[x],++g}y=t}return{t:new Jt(h),l:y}},Eh=function(e,t,n){return e.s==-1?Math.max(Eh(e.l,t,n+1),Eh(e.r,t,n+1)):t[e.s]=n},Z0=function(e){var t=e.length;while(t&&!e[--t]);var n=new ei(++t),i=0,r=e[0],s=1,a=function(c){n[i++]=c};for(var o=1;o<=t;++o)if(e[o]==r&&o!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)a(32754);if(s>2)a(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){a(r),--s;for(;s>6;s-=6)a(8304);if(s>2)a(s-3<<5|8208),s=0}while(s--)a(r);s=1,r=e[o]}return{c:n.subarray(0,i),n:t}},uc=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},av=function(e,t,n){var i=n.length,r=wh(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var s=0;s<i;++s)e[r+s+4]=n[s];return(r+4+i)*8},Y0=function(e,t,n,i,r,s,a,o,c,l,u){Rr(t,u++,n),++r[256];var d=bh(r,15),{t:f,l:h}=d,y=bh(s,15),{t:g,l:m}=y,p=Z0(f),{c:b,n:_}=p,x=Z0(g),{c:v,n:E}=x,S=new ei(19);for(var T=0;T<b.length;++T)++S[b[T]&31];for(var T=0;T<v.length;++T)++S[v[T]&31];var A=bh(S,7),{t:P,l:w}=A,I=19;for(;I>4&&!P[xh[I-1]];--I);var F=l+5<<3,N=uc(r,Yr)+uc(s,dc)+a,U=uc(r,f)+uc(s,g)+a+14+3*I+uc(S,P)+2*S[16]+3*S[17]+7*S[18];if(c>=0&&F<=N&&F<=U)return av(t,u,e.subarray(c,c+l));var D,O,K,B;if(Rr(t,u,1+(U<N)),u+=2,U<N){D=Qi(f,h,0),O=f,K=Qi(g,m,0),B=g;var X=Qi(P,w,0);Rr(t,u,_-257),Rr(t,u+5,E-1),Rr(t,u+10,I-4),u+=14;for(var T=0;T<I;++T)Rr(t,u+3*T,P[xh[T]]);u+=3*I;var q=[b,v];for(var le=0;le<2;++le){var de=q[le];for(var T=0;T<de.length;++T){var Me=de[T]&31;if(Rr(t,u,X[Me]),u+=P[Me],Me>15)Rr(t,u,de[T]>>5&127),u+=de[T]>>12}}}else D=k1,O=Yr,K=L1,B=dc;for(var T=0;T<o;++T){var pe=i[T];if(pe>255){var Me=pe>>18&31;if(lc(t,u,D[Me+257]),u+=O[Me+257],Me>7)Rr(t,u,pe>>23&31),u+=su[Me];var J=pe&31;if(lc(t,u,K[J]),u+=B[J],J>3)lc(t,u,pe>>5&8191),u+=au[J]}else lc(t,u,D[pe]),u+=O[pe]}return lc(t,u,D[256]),u+O[256]},z1=new Sh([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ov=new Jt(0),V1=function(e,t,n,i,r,s){var a=s.z||e.length,o=new Jt(i+a+5*(1+Math.ceil(a/7000))+r),c=o.subarray(i,o.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var d=z1[t-1],f=d>>13,h=d&8191,y=(1<<n)-1,g=s.p||new ei(32768),m=s.h||new ei(y+1),p=Math.ceil(n/3),b=2*p,_=function(Oe){return(e[Oe]^e[Oe+1]<<p^e[Oe+2]<<b)&y},x=new Sh(25000),v=new ei(288),E=new ei(32),S=0,T=0,A=s.i||0,P=0,w=s.w||0,I=0;for(;A+2<a;++A){var F=_(A),N=A&32767,U=m[F];if(g[N]=U,m[F]=N,w<=A){var D=a-A;if((S>7000||P>24576)&&(D>423||!l)){u=Y0(e,c,0,x,v,E,T,P,I,A-I,u),P=S=T=0,I=A;for(var O=0;O<286;++O)v[O]=0;for(var O=0;O<30;++O)E[O]=0}var K=2,B=0,X=h,q=N-U&32767;if(D>2&&F==_(A-q)){var le=Math.min(f,D)-1,de=Math.min(32767,A),Me=Math.min(258,D);while(q<=de&&--X&&N!=U){if(e[A+K]==e[A+K-q]){var pe=0;for(;pe<Me&&e[A+pe]==e[A+pe-q];++pe);if(pe>K){if(K=pe,B=q,pe>le)break;var J=Math.min(q,pe-2),L=0;for(var O=0;O<J;++O){var W=A-q+O&32767,te=g[W],ie=W-te&32767;if(ie>L)L=ie,U=W}}}N=U,U=g[N],q+=N-U&32767}}if(B){x[P++]=268435456|_h[K]<<18|J0[B];var ce=_h[K]&31,_e=J0[B]&31;T+=su[ce]+au[_e],++v[257+ce],++E[_e],w=A+K,++S}else x[P++]=e[A],++v[e[A]]}}for(A=Math.max(A,w);A<a;++A)x[P++]=e[A],++v[e[A]];if(u=Y0(e,c,l,x,v,E,T,P,I,A-I,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=m,s.p=g,s.i=A,s.w=w}else{for(var A=s.w||0;A<a+l;A+=65535){var Re=A+65535;if(Re>=a)c[u/8|0]=l,Re=a;u=av(c,u+1,e.subarray(A,Re))}s.i=a}return fc(o,0,i+wh(u)+r)},j1=function(){var e=new Int32Array(256);for(var t=0;t<256;++t){var n=t,i=9;while(--i)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),H1=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=j1[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var G1=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),a=new Jt(s.length+e.length);a.set(s),a.set(e,s.length),e=a,r.w=s.length}}return V1(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},cv=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var Yi=function(e,t){return e[t]|e[t+1]<<8},Ri=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},yh=function(e,t){return Ri(e,t)+Ri(e,t+4)*4294967296},wn=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function $1(e,t){return G1(e,t||{},0,0)}function K1(e,t){return B1(e,{i:2},t&&t.out,t&&t.dictionary)}var lv=function(e,t,n,i){for(var r in e){var s=e[r],a=t+r,o=i;if(Array.isArray(s))o=cv(i,s[1]),s=s[0];if(s instanceof Jt)n[a]=[s,o];else n[a+="/"]=[new Jt(0),o],lv(s,a,n,i)}},Q0=typeof TextEncoder<"u"&&new TextEncoder,Th=typeof TextDecoder<"u"&&new TextDecoder,W1=0;try{Th.decode(ov,{stream:!0}),W1=1}catch(e){}var X1=function(e){for(var t="",n=0;;){var i=e[n++],r=(i>127)+(i>223)+(i>239);if(n+r>e.length)return{s:t,r:fc(e,n-1)};if(!r)t+=String.fromCharCode(i);else if(r==3)i=((i&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|i>>10,56320|i&1023);else if(r&1)t+=String.fromCharCode((i&31)<<6|e[n++]&63);else t+=String.fromCharCode((i&15)<<12|(e[n++]&63)<<6|e[n++]&63)}};function ev(e,t){if(t){var n=new Jt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(Q0)return Q0.encode(e);var r=e.length,s=new Jt(e.length+(e.length>>1)),a=0,o=function(u){s[a++]=u};for(var i=0;i<r;++i){if(a+5>s.length){var c=new Jt(a+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)o(l);else if(l<2048)o(192|l>>6),o(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,o(240|l>>18),o(128|l>>12&63),o(128|l>>6&63),o(128|l&63);else o(224|l>>12),o(128|l>>6&63),o(128|l&63)}return fc(s,0,a)}function q1(e,t){if(t){var n="";for(var i=0;i<e.length;i+=16384)n+=String.fromCharCode.apply(null,e.subarray(i,i+16384));return n}else if(Th)return Th.decode(e);else{var r=X1(e),{s,r:n}=r;if(n.length)Un(8);return s}}var J1=function(e,t){return t+30+Yi(e,t+26)+Yi(e,t+28)},Z1=function(e,t,n){var i=Yi(e,t+28),r=q1(e.subarray(t+46,t+46+i),!(Yi(e,t+8)&2048)),s=t+46+i,a=Ri(e,t+20),o=n&&a==4294967295?Y1(e,s):[a,Ri(e,t+24),Ri(e,t+42)],c=o[0],l=o[1],u=o[2];return[Yi(e,t+10),c,l,r,s+Yi(e,t+30)+Yi(e,t+32),u]},Y1=function(e,t){for(;Yi(e,t)!=1;t+=4+Yi(e,t+2));return[yh(e,t+12),yh(e,t+4),yh(e,t+20)]},Ah=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)Un(9);t+=i+4}return t},tv=function(e,t,n,i,r,s,a,o){var c=i.length,l=n.extra,u=o&&o.length,d=Ah(l);if(wn(e,t,a!=null?33639248:67324752),t+=4,a!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),h=f.getFullYear()-1980;if(h<0||h>119)Un(10);if(wn(e,t,h<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,s!=-1)wn(e,t,n.crc),wn(e,t+4,s<0?-s-2:s),wn(e,t+8,n.size);if(wn(e,t+12,c),wn(e,t+14,d),t+=16,a!=null)wn(e,t,u),wn(e,t+6,n.attrs),wn(e,t+10,a),t+=14;if(e.set(i,t),t+=c,d)for(var y in l){var g=l[y],m=g.length;wn(e,t,+y),wn(e,t+2,m),e.set(g,t+4),t+=4+m}if(u)e.set(o,t),t+=u;return t},Q1=function(e,t,n,i,r){wn(e,t,101010256),wn(e,t+8,n),wn(e,t+10,n),wn(e,t+12,i),wn(e,t+16,r)};function uv(e,t){if(!t)t={};var n={},i=[];lv(e,"",n,t);var r=0,s=0;for(var a in n){var o=n[a],c=o[0],l=o[1],u=l.level==0?0:8,d=ev(a),f=d.length,h=l.comment,y=h&&ev(h),g=y&&y.length,m=Ah(l.extra);if(f>65535)Un(11);var p=u?$1(c,l):c,b=p.length,_=H1();_.p(c),i.push(cv(l,{size:c.length,crc:_.d(),c:p,f:d,m:y,u:f!=a.length||y&&h.length!=g,o:r,compression:u})),r+=30+f+m+b,s+=76+2*(f+m)+(g||0)+b}var x=new Jt(s+22),v=r,E=s-r;for(var S=0;S<i.length;++S){var d=i[S];tv(x,d.o,d,d.f,d.u,d.c.length);var T=30+d.f.length+Ah(d.extra);x.set(d.c,d.o+T),tv(x,r,d,d.f,d.u,d.c.length,d.o,d.m),r+=16+T+(d.m?d.m.length:0)}return Q1(x,r,i.length,E,v),x}function dv(e,t){var n={},i=e.length-22;for(;Ri(e,i)!=101010256;--i)if(!i||e.length-i>65558)Un(13);var r=Yi(e,i+8);if(!r)return{};var s=Ri(e,i+16),a=s==4294967295||r==65535;if(a){var o=Ri(e,i-12);if(a=Ri(e,o)==101075792,a)r=Ri(e,o+32),s=Ri(e,o+48)}var c=t&&t.filter;for(var l=0;l<r;++l){var u=Z1(e,s,a),d=u[0],f=u[1],h=u[2],y=u[3],g=u[4],m=u[5],p=J1(e,m);if(s=g,!c||c({name:y,size:f,originalSize:h,compression:d}))if(!d)n[y]=fc(e,p,p+f);else if(d==8)n[y]=K1(e.subarray(p,p+f),{out:new Jt(h)});else Un(14,"unknown compression type "+d)}return n}var er=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];ou();var cu=1024,lu=4,uu=8,Rh=6,fv=80,aa=256;class yt extends ja{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var hv=["solid","checker","stripes","gradient","bricks","noise"],pv=["normal","multiply","screen","overlay"],tC=new Set(["__proto__","prototype","constructor"]);function du(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new yt(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new yt(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new yt(`${t} must not contain symbol keys.`);if(tC.has(i))throw new yt(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new yt(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new yt(`${t}.${i} must be a plain JSON data field.`)}return e}function nC(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new yt(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new yt(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new yt(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new yt(`${t} must be a dense JSON array (missing index ${n}).`);return e}function Qr(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new yt(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function Ii(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new yt(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function sa(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new yt(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function gv(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new yt(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function Mh(e,t,n){return gv(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function iC(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>fv||n)throw new yt(`${t} must be 1..${fv} visible characters.`);return e}function rC(e,t,n){if(e===void 0)return n;if(!er.includes(e))throw new yt(`${t} must be one of ${er.join(", ")}, got ${JSON.stringify(e)}.`);return e}function mv(e,t){let i=(gv(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function sC(e,t){let n=e.blend??"normal";if(!pv.includes(n))throw new yt(`${t}.blend ${JSON.stringify(n)} is not one of ${pv.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function aC(e,t){let n=`proceduralTexture.layers[${t}]`,i=du(e,n),r=i.op;if(!hv.includes(r))throw new yt(`${n}.op ${JSON.stringify(r)} is not one of ${hv.join(", ")}.`);let s=sC(i,n),a=Mh(i.opacity,`${n}.opacity`,1),o={blend:t===0?"normal":s,opacity:t===0?1:a};switch(r){case"solid":return Qr(i,["op","color","blend","opacity"],n),{op:r,color:Ii(i.color,`${n}.color`),...o};case"checker":return Qr(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:Ii(i.colorA,`${n}.colorA`),colorB:Ii(i.colorB,`${n}.colorB`),squares:sa(i.squares,`${n}.squares`,8,1,aa),...o};case"stripes":return Qr(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:Ii(i.colorA,`${n}.colorA`),colorB:Ii(i.colorB,`${n}.colorB`),count:sa(i.count,`${n}.count`,8,1,aa),angleDeg:mv(i.angleDeg,`${n}.angleDeg`),...o};case"gradient":return Qr(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:Ii(i.from,`${n}.from`),to:Ii(i.to,`${n}.to`),angleDeg:mv(i.angleDeg,`${n}.angleDeg`),...o};case"bricks":return Qr(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:Ii(i.brick,`${n}.brick`),mortar:Ii(i.mortar,`${n}.mortar`),rows:sa(i.rows,`${n}.rows`,8,1,aa),cols:sa(i.cols,`${n}.cols`,4,1,aa),mortarWidth:Mh(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:Mh(i.stagger,`${n}.stagger`,0.5),...o};case"noise":return Qr(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:Ii(i.colorA,`${n}.colorA`),colorB:Ii(i.colorB,`${n}.colorB`),scale:sa(i.scale,`${n}.scale`,8,1,aa),octaves:sa(i.octaves,`${n}.octaves`,3,1,Rh),seed:sa(i.seed,`${n}.seed`,0,-2147483648,2147483647),...o};default:throw new yt(`${n}.op is unsupported.`)}}function oC(e){let t=du(e,"proceduralTexture");if(Qr(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new yt(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function hc(e){let t=du(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?du(oC(t),"proceduralTexture"):t;if(Qr(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new yt(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<lu||i>cu||(i&i-1)!==0)throw new yt(`proceduralTexture.size must be a power of two between ${lu} and ${cu}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new yt("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=nC(r,"proceduralTexture.layers");if(s.length>uu)throw new yt(`proceduralTexture: ${s.length} layers exceeds the maximum of ${uu}.`);let a=iC(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:rC(n.usage,"proceduralTexture.usage","albedo"),...a!==void 0?{name:a}:{},layers:s.map(aC)}}var cC=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),tr=(e,t)=>e>>>t|e<<32-t;function Ha(e){let t=new TextEncoder().encode(e),n=t.length*8,i=Math.ceil((t.length+9)/64)*64,r=new Uint8Array(i);r.set(t),r[t.length]=128;let s=new DataView(r.buffer);s.setUint32(i-8,Math.floor(n/4294967296),!1),s.setUint32(i-4,n>>>0,!1);let a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),o=new Uint32Array(64);for(let c=0;c<r.length;c+=64){for(let b=0;b<16;b++)o[b]=s.getUint32(c+b*4,!1);for(let b=16;b<64;b++){let _=o[b-15],x=o[b-2],v=tr(_,7)^tr(_,18)^_>>>3,E=tr(x,17)^tr(x,19)^x>>>10;o[b]=o[b-16]+v+o[b-7]+E>>>0}let[l,u,d,f,h,y,g,m]=a;for(let b=0;b<64;b++){let _=tr(h,6)^tr(h,11)^tr(h,25),x=h&y^~h&g,v=m+_+x+cC[b]+o[b]>>>0,E=tr(l,2)^tr(l,13)^tr(l,22),S=l&u^l&d^u&d,T=E+S>>>0;m=g,g=y,y=h,h=f+v>>>0,f=d,d=u,u=l,l=v+T>>>0}let p=[l,u,d,f,h,y,g,m];for(let b=0;b<8;b++)a[b]=a[b]+p[b]>>>0}return[...a].map((c)=>c.toString(16).padStart(8,"0")).join("")}var Ga="kiln.procedural-rgba.v3.1";var mc=1024,lC=1048576,gc=64,hu=64,pc=256,pu=32,bv=64000000,uC=67108864;function gt(e){throw new yt(`proceduralTexture V3: ${e}`,"PROCEDURAL_TEXTURE_V3_CONTRACT")}var dC=new Set(["__proto__","prototype","constructor"]);function fC(e){let t=0,n=(i,r,s)=>{if(++t>16384||s>10)gt(`${r} exceeds the JSON size/depth budget.`);if(i===null||typeof i==="boolean")return;if(typeof i==="string"){if(i.length>4096)gt(`${r} string is too long.`);return}if(typeof i==="number"){if(!Number.isFinite(i))gt(`${r} must be finite.`);return}if(typeof i!=="object")gt(`${r} must contain only JSON data.`);let a=Array.isArray(i),o=Object.getPrototypeOf(i);if(a?o!==Array.prototype:o!==Object.prototype&&o!==null)gt(`${r} must be a plain JSON ${a?"array":"object"}.`);let c=a?Object.getOwnPropertyDescriptor(i,"length")?.value:void 0;if(a&&(typeof c!=="number"||c>1024))gt(`${r} array is too long.`);let l=Reflect.ownKeys(i);if(l.length>1024)gt(`${r} has too many fields.`);let u=Object.getOwnPropertyDescriptors(i);for(let d of l){if(typeof d!=="string"||dC.has(d))gt(`${r} has a forbidden key.`);if(a&&d==="length")continue;let f=u[d];if(!f.enumerable||!("value"in f))gt(`${r}.${d} must be an enumerable JSON data field, never an accessor.`);if(a&&(!/^(0|[1-9][0-9]*)$/.test(d)||Number(d)>=c))gt(`${r} has an invalid array key.`)}if(a&&l.length!==c+1)gt(`${r} must be a dense JSON array.`);for(let d of l)if(d!=="length"||!a)n(u[d].value,`${r}.${String(d)}`,s+1)};n(e,"recipe",0)}function mi(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))gt(`${n} must be a JSON object.`);let i=e;for(let r of Object.keys(i))if(!t.includes(r))gt(`${n} has unknown field ${r}.`);return i}function Bn(e,t,n,i,r){if(e===void 0&&r!==void 0)return r;if(typeof e!=="number"||!Number.isInteger(e)||e<t||e>n)gt(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function yv(e,t){if(e===void 0)return!1;if(typeof e!=="boolean")gt(`${t} must be boolean.`);return e}function fu(e,t,n,i,r){if(!Array.isArray(e)||e.length!==t)gt(`${n} must be a ${t}-element array.`);return e.map((s,a)=>Bn(s,i,r,`${n}[${a}]`))}function xv(e,t){let n=fu(e,4,t,0,255);return n[3]===0?[0,0,0,0]:n}function _v(e,t,n){let i=mi(e,["x","y","width","height",...n?["kind"]:[]],t);return{x:Bn(i.x,-4096,4096,`${t}.x`),y:Bn(i.y,-4096,4096,`${t}.y`),width:Bn(i.width,1,2048,`${t}.width`),height:Bn(i.height,1,2048,`${t}.height`)}}function hC(e,t){let n=mi(e,["kind","x","y","width","height","from","to","points"],t);if(n.kind==="rectangle"||n.kind==="ellipse")return{kind:n.kind,..._v(n,t,n.kind)};if(n.kind==="polygon"){mi(n,["kind","points"],t);let i=n.points;if(!Array.isArray(i)||i.length<3||i.length>hu)gt(`${t}.points requires 3..${hu} vertices.`);return{kind:"polygon",points:i.map((r,s)=>fu(r,2,`${t}.points[${s}]`,-4096,4096))}}if(n.kind==="line")return mi(n,["kind","from","to","width"],t),{kind:"line",from:fu(n.from,2,`${t}.from`,-4096,4096),to:fu(n.to,2,`${t}.to`,-4096,4096),width:Bn(n.width,1,2048,`${t}.width`)};return gt(`${t}.kind must be rectangle, ellipse, polygon or line.`)}function vv(e){if(e.kind==="rectangle"||e.kind==="ellipse")return[e.x,e.y,e.x+e.width,e.y+e.height];let t=e.kind==="polygon"?e.points:[e.from,e.to],n=e.kind==="line"?e.width/2:0;return[Math.min(...t.map((i)=>i[0]))-n,Math.min(...t.map((i)=>i[1]))-n,Math.max(...t.map((i)=>i[0]))+n,Math.max(...t.map((i)=>i[1]))+n]}function pC(e){return e.kind==="polygon"?e.points.length+1:e.kind==="line"?4:e.kind==="ellipse"?3:1}function mC(e,t,n,i=0,r=0){let[s,a,o,c]=vv(e);return[Math.max(0,Math.ceil(s+i-0.5)),Math.max(0,Math.ceil(a+r-0.5)),Math.min(t,Math.floor(o+i-0.5)+1),Math.min(n,Math.floor(c+r-0.5)+1)]}function mu(e){fC(e);let t=mi(e,["schemaVersion","width","height","usage","name","background","operations","palette"],"recipe");if(t.schemaVersion!==3)gt("schemaVersion must be 3.");let n=Bn(t.width,4,mc,"width"),i=Bn(t.height,4,mc,"height"),r=n*i;if(r>lC)gt("output texel budget exceeded.");let s=t.usage===void 0?"albedo":t.usage;if(!er.includes(s))gt("usage must be a known texture usage.");let a=s==="albedo"||s==="emissive",o=t.name;if(o!==void 0&&(typeof o!=="string"||!o.length||o.length>80||[...o].some((m)=>m.charCodeAt(0)<32||m.charCodeAt(0)===127)))gt("name must be 1..80 visible characters.");let c=t.operations;if(!Array.isArray(c)||c.length>gc)gt(`operations must be an array with at most ${gc} entries.`);let l=r,u=0,d=0,f=c.map((m,p)=>{let b=`operations[${p}]`,_=mi(m,["op","shape","rgba","opacity","alpha","invert","spec","count","seed","area","periodic"],b);if(_.op==="legacy-v2"){mi(_,["op","spec","alpha","opacity"],b);let K=mi(_.spec,["schemaVersion","size","usage","name","layers"],`${b}.spec`);if(K.schemaVersion!==2)gt(`${b}.spec requires explicit schemaVersion 2.`);let B=hc(K);if(B.size!==n||B.size!==i||B.usage!==s)gt(`${b} legacy-v2 dimensions and usage must match the V3 surface.`);return l+=r*(1+B.layers.reduce((X,q)=>X+(q.op==="noise"?q.octaves*16:4),0)),d+=r*4,{op:"legacy-v2",spec:B,alpha:Bn(_.alpha,0,255,`${b}.alpha`,255),opacity:Bn(_.opacity,0,255,`${b}.opacity`,255)}}let x=hC(_.shape,`${b}.shape`),v=pC(x),[E,S,T,A]=mC(x,n,i),P=Math.max(0,T-E)*Math.max(0,A-S);if(_.op==="mask")return mi(_,["op","shape","alpha","invert"],b),l+=r+P*v,{op:"mask",shape:x,alpha:Bn(_.alpha,0,255,`${b}.alpha`,255),invert:yv(_.invert,`${b}.invert`)};if(_.op!=="paint"&&_.op!=="stamps")return gt(`${b}.op must be paint, mask, stamps or legacy-v2.`);let w={shape:x,rgba:xv(_.rgba,`${b}.rgba`),opacity:Bn(_.opacity,0,255,`${b}.opacity`,255)};if(_.op==="paint")return mi(_,["op","shape","rgba","opacity"],b),l+=P*(v+1),{op:"paint",...w};if(mi(_,["op","shape","rgba","opacity","count","seed","area","periodic"],b),!a)gt("stamps are supported only for color usages albedo and emissive.");let I=Bn(_.count,1,pc,`${b}.count`),F=yv(_.periodic,`${b}.periodic`),[N,U,D,O]=vv(x);if(F&&(D-N>n||O-U>i))gt(`${b} periodic shape bounds must fit one surface period.`);if(u+=I*(F?9:1),u>pc)gt(`expanded stamps budget exceeds ${pc}.`);return l+=I*(F?9:1)*Math.min(n,Math.ceil(D-N)+1)*Math.min(i,Math.ceil(O-U)+1)*(v+1),{op:"stamps",...w,count:I,seed:Bn(_.seed,0,4294967295,`${b}.seed`),area:_v(_.area,`${b}.area`),periodic:F}}),h;if(t.palette!==void 0){if(!a)gt("palette and dither are supported only for color usages albedo and emissive.");let m=mi(t.palette,["colors","dither"],"palette"),p=m.colors;if(!Array.isArray(p)||p.length<1||p.length>pu)gt(`palette.colors requires 1..${pu} entries.`);let b=m.dither===void 0?"none":m.dither;if(b!=="none"&&b!=="bayer4")gt("palette.dither must be none or bayer4.");h={colors:p.map((_,x)=>Bn(_,0,16777215,`palette.colors[${x}]`)),dither:b},l+=r*(p.length+1)}if(l>bv)gt(`estimated work budget ${l} exceeds ${bv}.`);if(r*4+d>uC)gt("transient allocation budget exceeded.");let y={schemaVersion:3,width:n,height:i,usage:s,...o!==void 0?{name:o}:{},background:t.background===void 0?[0,0,0,0]:xv(t.background,"background"),operations:f,...h?{palette:h}:{}},g=JSON.stringify(y);if(g.length>262144)gt("canonical JSON byte budget exceeded.");return{spec:y,canonicalJson:g,estimatedWorkUnits:l,conservativePixelAllocationBytes:r*4+d}}function Ih(e){return mu(e).spec}function gC(e){return mu(e).canonicalJson}function Ch(e){return`sha256:${Ha(`${Ga}-${gC(e)}`)}`}var Nh=["nearest","linear","nearest-mipmap-nearest","linear-mipmap-nearest","nearest-mipmap-linear","linear-mipmap-linear"],Ph=["nearest","linear"],bc=["repeat","clamp-to-edge","mirrored-repeat"];function gu(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new yt("portableSampler requires a complete JSON object.");let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new yt("portableSampler must be plain JSON data.");for(let r of Reflect.ownKeys(e)){let s=Object.getOwnPropertyDescriptor(e,r);if(typeof r!=="string"||!s.enumerable||!("value"in s))throw new yt("portableSampler requires enumerable JSON data fields, never accessors.")}let n=e,i={minFilter:Nh,magFilter:Ph,wrapS:bc,wrapT:bc};if(Object.keys(n).some((r)=>!Object.hasOwn(i,r)))throw new yt("portableSampler contains an unsupported field.");for(let[r,s]of Object.entries(i))if(!s.includes(n[r]))throw new yt(`portableSampler.${r} requires one of ${s.join(", ")}.`);return{minFilter:n.minFilter,magFilter:n.magFilter,wrapS:n.wrapS,wrapT:n.wrapT}}ou();var Av="kiln.texture-atlas.v1.1",Sv="kiln.texture-atlas.v1.2",bu=Object.freeze([Av,Sv]),oa=Object.freeze({edge:1024,outputTexels:1048576,regions:64,sources:16,sourceTexels:4194304,encodedSourceBytes:8388608,encodedBytes:16777216,jsonBytes:262144,work:64000000,allocatedBytes:67108864,uvVertices:262144,uvAttributeBytes:134217728}),Ir=Object.freeze({...oa,edge:2048,outputTexels:4194304,regions:128,sources:32,work:192000000,allocatedBytes:134217728}),kh=Object.freeze([1024,2048]);function wv(e){return e.pack===void 0?Av:Sv}function bC(e){return e.pack===void 0?oa:Ir}class Mv extends ja{constructor(e){super("TEXTURE_ATLAS_CONTRACT",`textureAtlas: ${e}`);this.name="TextureAtlasError"}}function He(e){throw new Mv(e)}function Dh(e){let t=0,n=0,i=new TextEncoder,r=(a)=>{if(n+=a,n>oa.jsonBytes)He("JSON byte budget exceeded.")},s=(a,o)=>{if(++t>65536||o>16)He("JSON node/depth budget exceeded.");if(a===null||typeof a==="boolean"){r(a===!1?5:4);return}if(typeof a==="number"){if(!Number.isFinite(a))He("JSON numbers must be finite.");r(JSON.stringify(a).length);return}if(typeof a==="string"){if(a.length>4096)He("JSON string budget exceeded.");r(i.encode(JSON.stringify(a)).length);return}if(typeof a!=="object")He("plain JSON data is required.");let c=Array.isArray(a),l=Object.getPrototypeOf(a);if(c?l!==Array.prototype:l!==null&&l!==Object.prototype)He("plain JSON prototypes are required.");let u=c?Object.getOwnPropertyDescriptor(a,"length")?.value:void 0;if(c&&(!Number.isSafeInteger(u)||u>1024))He("JSON array budget exceeded.");let d=Reflect.ownKeys(a);if(d.length>1024||c&&d.length!==u+1)He("dense bounded JSON fields are required.");r(2+Math.max(0,d.length-(c?1:0)-1));for(let f of d){if(c&&f==="length")continue;if(typeof f!=="string"||["__proto__","prototype","constructor"].includes(f))He("forbidden JSON field.");if(f.length>4096)He("JSON field name budget exceeded.");if(!c)r(i.encode(JSON.stringify(f)).length+1);let h=Object.getOwnPropertyDescriptor(a,f);if(!h.enumerable||!("value"in h))He("JSON accessors/hidden fields are unsupported.");if(c&&(!/^(0|[1-9][0-9]*)$/.test(f)||Number(f)>=u))He("invalid JSON array key.");s(h.value,o+1)}};s(e,0)}function zn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))He(`${n} must be a JSON object.`);let i=e;if(Object.keys(i).some((r)=>!t.includes(r)))He(`${n} has an unknown field.`);return i}function ti(e,t,n,i){if(typeof e!=="number"||!Number.isSafeInteger(e)||e<t||e>n)He(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function es(e,t){if(typeof e!=="string"||!/^sha256:[a-f0-9]{64}$/.test(e))He(`${t} must be an exact SHA-256 hash.`);return e}function Ev(e,t){let n=zn(e,["x","y","width","height"],t);return{x:ti(n.x,0,4096,`${t}.x`),y:ti(n.y,0,4096,`${t}.y`),width:ti(n.width,1,4096,`${t}.width`),height:ti(n.height,1,4096,`${t}.height`)}}function $a(e){let{content:t,gutter:n}=e;return{x:t.x-n,y:t.y-n,width:t.width+2*n,height:t.height+2*n}}function Rv(e,t,n,i){if(e.x+e.width>n||e.y+e.height>i)He("source crop is out of bounds.");if(e.width!==t.width||e.height!==t.height)He("source crop/content dimensions must match; resampling is unsupported.")}function Oh(e){return e.kind==="procedural"?`procedural:${Ch(e.spec)}`:`resource:${e.pin.resourceId}:${e.pin.revisionId}:${e.resourceId}`}var yC=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,Tv=(e,t)=>t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height;function xC(e,t,n,i){let r=[{x:0,y:0,width:e,height:t}],s=(o)=>{let c=[];for(let l of r){if(!yC(l,o)){c.push(l);continue}if(o.x>l.x)c.push({x:l.x,y:l.y,width:o.x-l.x,height:l.height});if(o.x+o.width<l.x+l.width)c.push({x:o.x+o.width,y:l.y,width:l.x+l.width-o.x-o.width,height:l.height});if(o.y>l.y)c.push({x:l.x,y:l.y,width:l.width,height:o.y-l.y});if(o.y+o.height<l.y+l.height)c.push({x:l.x,y:o.y+o.height,width:l.width,height:l.y+l.height-o.y-o.height})}if(r=c.filter((l,u)=>!c.some((d,f)=>f!==u&&Tv(d,l)&&(!Tv(l,d)||f<u))),r.length>16384)He("pack: free-space bookkeeping budget exceeded.")};for(let o of n)s(o);let a=[...i].sort((o,c)=>c.width*c.height-o.width*o.height||(o.region.name<c.region.name?-1:o.region.name>c.region.name?1:0));for(let o of a){let c,l;for(let u of r){if(u.width<o.width||u.height<o.height)continue;let d=u.width-o.width,f=u.height-o.height,h=[Math.min(d,f),Math.max(d,f),u.y,u.x];if(!l||h[0]<l[0]||h[0]===l[0]&&(h[1]<l[1]||h[1]===l[1]&&(h[2]<l[2]||h[2]===l[2]&&h[3]<l[3])))c=u,l=h}if(!c)He(`pack: region ${o.region.name} (${o.width}x${o.height} texels with its gutter) does not fit in the ${e}x${t} atlas beside the regions already placed.`);o.region.content={x:c.x+o.region.gutter,y:c.y+o.region.gutter,width:o.region.content.width,height:o.region.content.height},s({x:c.x,y:c.y,width:o.width,height:o.height})}}function yc(e){Dh(e);let t=zn(e,["schemaVersion","width","height","usage","sampler","regions","pack"],"atlas");if(t.schemaVersion!==1)He("schemaVersion must be 1.");let n;if(t.pack!==void 0){let f=zn(t.pack,["edge","gutter","algorithm"],"pack");if(!kh.includes(f.edge))He("pack.edge must be 1024 or 2048.");if(f.algorithm!==void 0&&f.algorithm!=="maxrects")He("pack.algorithm must be 'maxrects'.");n={edge:f.edge,gutter:f.gutter===void 0?2:ti(f.gutter,0,32,"pack.gutter"),algorithm:"maxrects"}}let i=n?Ir:oa,r=n?n.edge:i.edge,s=n&&t.width===void 0?n.edge:ti(t.width,4,r,"width"),a=n&&t.height===void 0?n.edge:ti(t.height,4,r,"height");if(s*a>i.outputTexels)He("output texel budget exceeded.");if(!er.includes(t.usage))He("usage must be a texture usage.");let o=t.usage;if(!Array.isArray(t.regions)||!t.regions.length||t.regions.length>i.regions)He(`regions must contain 1..${i.regions} entries.`);let c=[],l=t.regions.map((f,h)=>{let y=zn(f,["name","content","gutter","edgeMode","source","crop","packed"],`regions[${h}]`);if(typeof y.name!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(y.name))He("region name must be a stable lowercase identifier.");let g=y.content!==void 0;if(!g&&!n)He(`region ${y.name}: content is required unless the atlas sets pack.`);if(y.packed!==void 0&&(y.packed!==!0||!n||!g))He("packed is the resolved-placement marker: true, with content, in an atlas that sets pack.");let m=g?Ev(y.content,"content"):void 0,p=y.gutter===void 0?n?.gutter??2:ti(y.gutter,0,32,"gutter"),b=y.edgeMode===void 0?"copy-edge":y.edgeMode;if(!["copy-edge","mask-rgb-dilate"].includes(b))He("unsupported edgeMode.");if(b==="mask-rgb-dilate"&&o!=="albedo"&&o!=="emissive")He("mask RGB dilation requires color usage.");let _=zn(y.source,["kind","spec","resourceId","pin","expected"],"source"),x,v=y.crop===void 0?void 0:Ev(y.crop,"crop");if(_.kind==="procedural"){zn(_,["kind","spec"],"procedural source");let S=mu(_.spec);if(S.spec.usage!==o)He("source usage does not match atlas usage.");x={kind:"procedural",spec:S.spec},v??={x:0,y:0,width:S.spec.width,height:S.spec.height},m??={x:0,y:0,width:v.width,height:v.height},Rv(v,m,S.spec.width,S.spec.height)}else if(_.kind==="resource"){if(zn(_,["kind","resourceId","pin","expected"],"resource source"),typeof _.resourceId!=="string"||!/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/.test(_.resourceId))He("source resourceId must be an exact returned map ID.");let S=zn(_.pin,["resourceId","revisionId","sha256"],"source pin");if(typeof S.resourceId!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(S.resourceId))He("pin resourceId must be a material ID.");let T=es(S.revisionId,"pin revisionId"),A=es(S.sha256,"pin sha256");if(T!==A)He("source pin revision/hash mismatch.");let P;if(_.expected!==void 0){let w=zn(_.expected,["width","height","imageSha256","decodedPixelHash"],"source expected");P={...w.width===void 0?{}:{width:ti(w.width,1,4096,"expected.width")},...w.height===void 0?{}:{height:ti(w.height,1,4096,"expected.height")},...w.imageSha256===void 0?{}:{imageSha256:es(w.imageSha256,"expected.imageSha256")},...w.decodedPixelHash===void 0?{}:{decodedPixelHash:es(w.decodedPixelHash,"expected.decodedPixelHash")}}}if(x={kind:"resource",resourceId:_.resourceId,pin:{resourceId:S.resourceId,revisionId:T,sha256:A},...P?{expected:P}:{}},!m){let w=v??(P?.width!==void 0&&P.height!==void 0?{width:P.width,height:P.height}:He(`region ${y.name}: a packed resource region needs a crop or expected width and height (its size).`));m={x:0,y:0,width:w.width,height:w.height}}if(v&&(v.width!==m.width||v.height!==m.height))He("source crop/content dimensions must match; resampling is unsupported.")}else He("source kind must be procedural or pinned resource.");let E={name:y.name,content:m,gutter:p,edgeMode:b,source:x,...v?{crop:v}:{},...n&&(!g||y.packed===!0)?{packed:!0}:{}};if(!g)c.push({region:E,width:E.content.width+2*p,height:E.content.height+2*p});return E}).sort((f,h)=>f.name<h.name?-1:f.name>h.name?1:0);if(new Set(l.map((f)=>f.name)).size!==l.length)He("duplicate region name.");if(c.length){let f=new Set(c.map((h)=>h.region));xC(s,a,l.filter((h)=>!f.has(h)).map((h)=>$a(h)),c)}for(let f of l){let h=$a(f);if(h.x<0||h.y<0||h.x+h.width>s||h.y+h.height>a)He("padded allocation is out of bounds.")}for(let f=0;f<l.length;f++)for(let h=f+1;h<l.length;h++){let y=$a(l[f]),g=$a(l[h]);if(y.x<g.x+g.width&&g.x<y.x+y.width&&y.y<g.y+g.height&&g.y<y.y+y.height)He(`padded allocations overlap: ${l[f].name}, ${l[h].name}.`)}if(new Set(l.map((f)=>Oh(f.source))).size>i.sources)He(`distinct source budget exceeds ${i.sources}.`);let u;try{u=gu(t.sampler===void 0?{minFilter:"linear-mipmap-linear",magFilter:"linear",wrapS:"clamp-to-edge",wrapT:"clamp-to-edge"}:t.sampler)}catch(f){He(`sampler: ${f.message}`)}let d={schemaVersion:1,width:s,height:a,usage:o,sampler:u,regions:l,...n?{pack:n}:{}};if(new TextEncoder().encode(JSON.stringify(d)).length>oa.jsonBytes)He("canonical JSON byte budget exceeded.");return d}function _C(e){let t=yc(e);return`sha256:${Ha(`${wv(t)}-${JSON.stringify(t)}`)}`}function nr(e){Dh(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function vC(e){return`sha256:${Ha(`kiln.atlas-layout.v1-${nr({width:e.width,height:e.height,origin:"top-left",regions:e.regions.map((t)=>({name:t.name,content:t.content,allocation:$a(t)}))})}`)}`}function Lh(e,t){Dh(e);let n=yc(t),i=zn(e,["version","compilerId","width","height","usage","origin","sampler","specHash","layoutHash","decodedPixelHash","atlasPixelHash","sources","regions","manifestHash"],"manifest");if(i.version!=="kiln.atlas-manifest.v1"||i.compilerId!==wv(n)||i.width!==n.width||i.height!==n.height||i.usage!==n.usage||i.origin!=="top-left")He("manifest version/compiler/dimensions/usage/origin mismatch.");if(nr(i.sampler)!==nr(n.sampler)||i.specHash!==_C(n)||i.layoutHash!==vC(n))He("manifest sampler/spec/layout identity mismatch.");es(i.decodedPixelHash,"manifest decodedPixelHash"),es(i.atlasPixelHash,"manifest atlasPixelHash");let r=new Map(n.regions.map((c)=>[Oh(c.source),c.source]));if(!Array.isArray(i.sources)||i.sources.length!==r.size||!Array.isArray(i.regions)||i.regions.length!==n.regions.length)He("manifest source/region inventory mismatch.");let s=new Map;for(let c of i.sources){let l=zn(c,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId","descriptor"],"manifest source");if(typeof l.id!=="string"||s.has(l.id))He("duplicate/invalid manifest source identity.");let u=r.get(l.id);if(!u||l.kind!==u.kind)He("manifest source identity mismatch.");let d=ti(l.width,1,4096,"manifest source width"),f=ti(l.height,1,4096,"manifest source height");if(es(l.decodedPixelHash,"manifest source decodedPixelHash"),u.kind==="procedural"){if(zn(l,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId"],"manifest procedural source"),d!==u.spec.width||f!==u.spec.height||l.recipeHash!==Ch(u.spec)||l.compilerId!=="kiln.procedural-rgba.v3.1")He("manifest procedural source identity mismatch.")}else{zn(l,["id","kind","width","height","decodedPixelHash","descriptor"],"manifest resource source");let h=zn(l.descriptor,["materialId","revisionId","resourceId","slot","usage","colorSpace","width","height","encodedByteLength","imageSha256","decodedPixelHash"],"manifest source descriptor"),y={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};if(h.materialId!==u.pin.resourceId||h.revisionId!==u.pin.revisionId||h.resourceId!==u.resourceId||h.width!==d||h.height!==f||h.usage!==n.usage||typeof h.slot!=="string"||y[h.slot]!==n.usage||h.colorSpace!==(n.usage==="albedo"||n.usage==="emissive"?"srgb":"linear"))He("manifest pinned resource descriptor mismatch.");if(es(h.imageSha256,"manifest source imageSha256"),ti(h.encodedByteLength,1,bC(n).encodedSourceBytes,"manifest encodedByteLength"),h.decodedPixelHash!==void 0&&h.decodedPixelHash!==l.decodedPixelHash)He("manifest source decodedPixelHash mismatch.");for(let g of["width","height","imageSha256","decodedPixelHash"]){let m=u.expected?.[g];if(m!==void 0&&m!==(g==="decodedPixelHash"?l[g]:h[g]))He("manifest source expectation mismatch.")}}s.set(l.id,{width:d,height:f})}for(let c=0;c<n.regions.length;c++){let l=n.regions[c],u=zn(i.regions[c],["name","content","allocation","crop","sourceId"],"manifest region"),d=Oh(l.source),f=s.get(d),h=l.crop??{x:0,y:0,width:f.width,height:f.height};if(Rv(h,l.content,f.width,f.height),u.name!==l.name||u.sourceId!==d||nr(u.content)!==nr(l.content)||nr(u.allocation)!==nr($a(l))||nr(u.crop)!==nr(h))He("manifest named region/crop/allocation identity mismatch.")}let{manifestHash:a,...o}=i;if(a!==`sha256:${Ha(`kiln.atlas-manifest.v1-${nr(o)}`)}`)He("manifest hash mismatch.");return structuredClone(e)}var EC=(()=>{let e=mt().int().min(0).max(16777215),t=mt().int().min(1).max(aa),n=mt().min(-36000).max(36000),i=mt().min(0).max(1),r={blend:It(["normal","multiply","screen","overlay"]),opacity:i};return be({schemaVersion:$e(2),size:mt().int().min(lu).max(cu),usage:It(er),name:Le().min(1).max(80).optional(),layers:at(wi("op",[be({op:$e("solid"),color:e,...r}).strict(),be({op:$e("checker"),colorA:e,colorB:e,squares:t,...r}).strict(),be({op:$e("stripes"),colorA:e,colorB:e,count:t,angleDeg:n,...r}).strict(),be({op:$e("gradient"),from:e,to:e,angleDeg:n,...r}).strict(),be({op:$e("bricks"),brick:e,mortar:e,rows:t,cols:t,mortarWidth:i,stagger:i,...r}).strict(),be({op:$e("noise"),colorA:e,colorB:e,scale:t,octaves:mt().int().min(1).max(Rh),seed:mt().int().min(-2147483648).max(2147483647),...r}).strict()])).min(1).max(uu)}).strict()})();function Iv(e,t=EC){let n=(X,q)=>mt().int().min(X).max(q),i=n(0,255),r=n(-4096,4096),s=G0([r,r]),a=G0([i,i,i,i]),o=It(er),c=I1(["sha256:",Le().regex(/^[a-f0-9]{64}$/)]),l=Le().min(1).max(80),u=Le().regex(/^[a-z][a-z0-9_-]{0,79}$/),d=Le().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),f={width:n(1,4096),height:n(1,4096)},h=be({x:r,y:r,width:n(1,2048),height:n(1,2048)}).strict(),y=be({x:n(0,4096),y:n(0,4096),...f}).strict(),g=wi("kind",[h.extend({kind:$e("rectangle")}).strict(),h.extend({kind:$e("ellipse")}).strict(),be({kind:$e("polygon"),points:at(s).min(3).max(hu)}).strict(),be({kind:$e("line"),from:s,to:s,width:n(1,2048)}).strict()]),m=be({op:$e("paint"),shape:g,rgba:a,opacity:i}).strict(),p=be({op:$e("mask"),shape:g,alpha:i,invert:ra()}).strict(),b=be({op:$e("stamps"),shape:g,rgba:a,opacity:i,count:n(1,pc),seed:n(0,4294967295),area:h,periodic:ra()}).strict(),_=be({op:$e("legacy-v2"),spec:e,alpha:i,opacity:i}).strict(),x=be({colors:at(n(0,16777215)).min(1).max(pu),dither:It(["none","bayer4"])}).strict(),v={schemaVersion:$e(3),width:n(4,mc),height:n(4,mc),usage:o,name:l.optional(),background:a},E=be({...v,operations:at(wi("op",[m,p,b,_.extend({spec:t})])).max(gc),palette:x.optional()}).strict(),S=be({...v,usage:o.optional(),background:a.optional(),operations:at(wi("op",[m.partial({opacity:!0}),p.partial({alpha:!0,invert:!0}),b.partial({opacity:!0,periodic:!0}),_.partial({alpha:!0,opacity:!0})])).max(gc),palette:x.partial({dither:!0}).optional()}).strict(),T=be({minFilter:It(Nh),magFilter:It(Ph),wrapS:It(bc),wrapT:It(bc)}).strict(),A=be({resourceId:u,revisionId:c,sha256:c}).strict(),P=be({kind:$e("resource"),resourceId:d,pin:A,expected:be({...f,imageSha256:c,decodedPixelHash:c}).partial().strict().optional()}).strict(),w=be({name:u,content:y,gutter:n(0,32),edgeMode:It(["copy-edge","mask-rgb-dilate"]),source:wi("kind",[be({kind:$e("procedural"),spec:E}).strict(),P]),crop:y.optional(),packed:$e(!0).optional()}).strict(),I={schemaVersion:$e(1),width:n(4,Ir.edge),height:n(4,Ir.edge),usage:o,sampler:T},F=Va(kh.map((X)=>$e(X))),N=be({...I,regions:at(w).min(1).max(Ir.regions),pack:be({edge:F,gutter:n(0,32),algorithm:$e("maxrects")}).strict().optional()}).strict(),U=be({...I,width:I.width.optional(),height:I.height.optional(),pack:be({edge:F,gutter:n(0,32).optional(),algorithm:$e("maxrects").optional()}).strict().optional(),sampler:T.optional(),regions:at(w.extend({source:wi("kind",[be({kind:$e("procedural"),spec:S}).strict(),P])}).partial({content:!0,gutter:!0,edgeMode:!0})).min(1).max(Ir.regions)}).strict(),D=be({materialId:u,revisionId:c,resourceId:d,slot:It(["baseColor","normal","metallicRoughness","emissive","occlusion"]),usage:o,colorSpace:It(["srgb","linear"]),...f,encodedByteLength:n(1,oa.encodedSourceBytes),imageSha256:c,decodedPixelHash:c.optional()}).strict(),O={id:Le().min(1).max(1024),...f,decodedPixelHash:c},K=wi("kind",[be({...O,kind:$e("procedural"),recipeHash:c,compilerId:$e(Ga)}).strict(),be({...O,kind:$e("resource"),descriptor:D}).strict()]),B=be({version:$e("kiln.atlas-manifest.v1"),compilerId:It(bu),width:I.width,height:I.height,usage:o,origin:$e("top-left"),sampler:T,specHash:c,layoutHash:c,decodedPixelHash:c,atlasPixelHash:c,sources:at(K).min(1).max(Ir.sources),regions:at(be({name:u,content:y,allocation:y,crop:y,sourceId:Le().min(1).max(1024)}).strict()).min(1).max(Ir.regions),manifestHash:c}).strict();return{portableSamplerSchema:T,proceduralTextureSpecV3Schema:S,canonicalProceduralTextureSpecV3Schema:E,textureAtlasSpecV1Schema:U,canonicalTextureAtlasSpecV1Schema:N,textureAtlasManifestV1Schema:B,materialMapPinSchema:A,verifiedPinnedMaterialMapDescriptorSchema:D}}var In=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),Nv=["baseColor","normal","metallicRoughness","emissive","occlusion"],Pv={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var Wa=Le().regex(/^[a-z][a-z0-9_-]{0,79}$/),rr=Le().regex(/^sha256:[a-f0-9]{64}$/),ir=Le().min(1).max(1000),Cv=Le().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),Ov=be({id:Wa,kind:It(["external","procedural"]),provider:ir,creator:ir,assetId:ir.optional(),assetUrl:Cv.optional(),accessedAt:Le().datetime().optional(),license:be({spdx:ir,url:Cv,attribution:Le().max(4000)}).strict(),originalFiles:at(be({name:Le().min(1).max(200),sha256:rr,bytes:mt().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),kv=be({operation:ir,tool:ir,version:ir,parameters:nu(Le().max(100),Va([Le().max(2000),mt().finite(),ra()])).optional()}).strict(),Ci=mt().int().min(0).max(16777215),xc=mt().int().min(1).max(256),Ka={blend:It(["normal","multiply","screen","overlay"]).default("normal"),opacity:mt().min(0).max(1).default(1)},vc=be({schemaVersion:$e(2),size:mt().int().min(4).max(1024).default(256),usage:It(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Le().min(1).max(80).optional(),layers:at(wi("op",[be({op:$e("solid"),color:Ci,...Ka}).strict(),be({op:$e("checker"),colorA:Ci,colorB:Ci,squares:xc.default(8),...Ka}).strict(),be({op:$e("stripes"),colorA:Ci,colorB:Ci,count:xc.default(8),angleDeg:mt().min(-36000).max(36000).default(0),...Ka}).strict(),be({op:$e("gradient"),from:Ci,to:Ci,angleDeg:mt().min(-36000).max(36000).default(0),...Ka}).strict(),be({op:$e("bricks"),brick:Ci,mortar:Ci,rows:xc.default(8),cols:xc.default(4),mortarWidth:mt().min(0).max(1).default(0.06),stagger:mt().min(0).max(1).default(0.5),...Ka}).strict(),be({op:$e("noise"),colorA:Ci,colorB:Ci,scale:xc.default(8),octaves:mt().int().min(1).max(6).default(3),seed:mt().int().min(-2147483648).max(2147483647).default(0),...Ka}).strict()])).min(1).max(8)}).strict(),Bh=be({kind:$e("normal-from-height"),strength:mt().finite().positive().max(64)}).strict(),TC=be({compiler:$e("kiln.procedural-texture.v2"),spec:vc,derive:Bh.optional(),recipeHash:rr,pixelHash:rr,encoder:be({name:$e("sharp"),version:ir}).strict()}).strict(),Dv=be({baseColor:mt().int().min(0).max(16777215).optional(),roughness:mt().min(0).max(1).default(1),metalness:mt().min(0).max(1).default(0),emissive:mt().int().min(0).max(16777215).optional(),emissiveIntensity:mt().min(0).max(64).default(1),alphaMode:It(["opaque","mask","blend"]).default("opaque"),alphaCutoff:mt().min(0).max(1).default(0.5),doubleSided:ra().default(!1)}).strict(),_c=be({schemaVersion:$e(1),materialId:Wa,revisionId:rr,name:Le().min(1).max(200),tags:at(Le().min(1).max(80)).max(30),tileable:ra(),physicalSizeMeters:be({width:mt().finite().positive().max(1e5),height:mt().finite().positive().max(1e5)}).strict().optional(),parameters:Dv,sources:at(Ov).min(1).max(20),maps:at(be({slot:It(Nv),file:It(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:rr,bytes:mt().int().positive().max(In.maxMapBytes),width:mt().int().positive().max(In.maxMapEdge),height:mt().int().positive().max(In.maxMapEdge),usage:It(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:It(["srgb","linear"]),normalConvention:$e("opengl").optional(),channelPacking:$e("r-occlusion-g-roughness-b-metallic").optional(),sourceId:Wa,originalFile:Le().min(1).max(200).optional(),transforms:at(kv).max(30),procedural:TC.optional()}).strict()).min(1).max(5)}).strict(),Fh=be({materialId:Wa,name:Le().min(1).max(200),tags:at(Le().min(1).max(80)).max(30).optional(),tileable:ra(),physicalSizeMeters:be({width:mt().finite().positive().max(1e5),height:mt().finite().positive().max(1e5)}).strict().optional(),parameters:Dv.partial().optional(),sources:at(Ov).min(1).max(20),maps:at(be({slot:It(Nv),sourceId:Wa,transforms:at(kv).max(30),normalConvention:$e("opengl").optional(),channelPacking:$e("r-occlusion-g-roughness-b-metallic").optional(),procedural:vc,derive:Bh.optional()}).strict()).min(1).max(5)}).strict(),Uh=be({schemaVersion:$e(1),records:at(be({manifest:_c,files:nu(Le().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Le().max(Math.ceil(In.maxMapBytes/3)*4))}).strict()).max(In.maxPayloadRecords)}).strict();function qa(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let a=Object.getOwnPropertyDescriptor(e,s);if(!("value"in a)||!a.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");qa(a.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function on(e){qa(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function AC(e){if(qa(e),new TextEncoder().encode(JSON.stringify(e)).length>In.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=_c.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==Pv[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let a=t.sources.find((o)=>o.id===r.sourceId);if(!a)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(on(r.procedural.spec)!==on(hc(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(a.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(a.kind!=="external"||!a.originalFiles.some((o)=>o.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>In.maxRecordBytes||i>In.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var Xa=Iv(vc),Lv=Xa.portableSamplerSchema.refine((e)=>{try{return on(e)===on(gu(e))}catch{return!1}}),SC=Xa.canonicalProceduralTextureSpecV3Schema.refine((e)=>{try{return on(e)===on(Ih(e))}catch{return!1}}),wC=Xa.canonicalTextureAtlasSpecV1Schema.refine((e)=>{try{return on(e)===on(yc(e))}catch{return!1}}),MC=Xa.textureAtlasManifestV1Schema,RC=be({resourceId:Wa,revisionId:rr,sha256:rr}).strict().refine((e)=>e.sha256===e.revisionId,"Material pin hash must match revision"),IC=wi("kind",[be({kind:$e("procedural"),compilerId:It(["kiln.procedural-texture.v2",Ga]),spec:Va([vc,SC]),recipeHash:rr,pixelHash:rr,encoder:be({name:$e("sharp"),version:ir}).strict(),derive:Bh.optional()}).strict(),be({kind:$e("atlas"),compilerId:It(bu),spec:wC,manifest:MC,encoder:be({name:$e("sharp"),version:ir}).strict()}).strict().superRefine((e,t)=>{try{if(Lh(e.manifest,e.spec),e.compilerId!==e.manifest.compilerId)throw Error("compiler id")}catch{t.addIssue({code:"custom",message:"Invalid stored atlas manifest"})}})]),Fv=_c.omit({schemaVersion:!0,maps:!0}).extend({schemaVersion:$e(2),dependencies:at(RC).max(16),maps:at(_c.shape.maps.element.omit({procedural:!0}).extend({sampler:Lv,pixelHash:rr,recipe:IC.optional()}).strict()).min(1).max(5)}).strict(),CC=wi("schemaVersion",[_c,Fv]),NC=Uh.extend({schemaVersion:$e(2),records:at(Uh.shape.records.element.extend({manifest:CC}).strict()).max(In.maxPayloadRecords)}).strict(),Uv=wi("schemaVersion",[Uh,NC]);function Bv(e){return e.schemaVersion===1?[]:e.dependencies.map((t)=>({...t}))}var PC=Fh.extend({schemaVersion:$e(2),maps:at(Fh.shape.maps.element.omit({procedural:!0}).extend({sampler:Lv,procedural:Va([vc,Xa.proceduralTextureSpecV3Schema.refine((e)=>{try{return Ih(e),!0}catch{return!1}})]).optional(),atlas:Xa.textureAtlasSpecV1Schema.refine((e)=>{try{return yc(e),!0}catch{return!1}}).optional()}).strict().refine((e)=>e.procedural!==void 0!==(e.atlas!==void 0),"Supply exactly one procedural or atlas recipe")).min(1).max(5)}).strict(),IV=Va([Fh,PC]);function Ja(e){if(qa(e),new TextEncoder().encode(JSON.stringify(e)).length>In.maxManifestBytes)throw Error("Material manifest exceeds size limit");if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Invalid material manifest");if(e.schemaVersion===1)return AC(e);let t=Fv.parse(e);if(new Set(t.sources.map((a)=>a.id)).size!==t.sources.length||new Set(t.maps.map((a)=>a.slot)).size!==t.maps.length)throw Error("Duplicate material source or slot");let n=0,i=0,r=new Map;for(let a of t.maps){let o=t.sources.find((l)=>l.id===a.sourceId);if(!o||a.file!==`${a.slot}.png`||a.usage!==Pv[a.slot]||a.colorSpace!==(a.slot==="baseColor"||a.slot==="emissive"?"srgb":"linear")||a.slot==="normal"!==(a.normalConvention==="opengl")||a.slot==="metallicRoughness"!==(a.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map source/usage/convention mismatch");let c=a.recipe;if(c){if(o.kind!=="procedural"||a.originalFile)throw Error("Procedural/atlas map source convention mismatch");if(c.kind==="procedural"){let l=c.spec;if(l.schemaVersion===3){if(c.compilerId!==Ga||c.derive||l.width!==a.width||l.height!==a.height)throw Error("V3 compiler/dimensions/derivation mismatch")}else if(c.compilerId!=="kiln.procedural-texture.v2"||l.size!==a.width||a.width!==a.height||on(l)!==on(hc(l)))throw Error("V2 compiler/canonical recipe dimensions mismatch");if(l.usage!==a.usage||c.pixelHash!==a.pixelHash||c.derive&&a.slot!=="normal")throw Error("Procedural recipe pixel/usage mismatch")}else{if(Lh(c.manifest,c.spec),c.spec.width!==a.width||c.spec.height!==a.height||c.spec.usage!==a.usage||on(c.spec.sampler)!==on(a.sampler)||c.manifest.decodedPixelHash!==a.pixelHash)throw Error("Atlas recipe map mismatch");for(let l of c.spec.regions)if(l.source.kind==="resource"){let u=l.source.pin;r.set(`${u.resourceId}/${u.revisionId}`,u)}}}else if(o.kind!=="external"||!o.originalFiles.some((l)=>l.name===a.originalFile))throw Error("External material source original file missing");n+=a.bytes,i+=a.width*a.height}let s=t.dependencies.map((a)=>`${a.resourceId}/${a.revisionId}`);if(new Set(s).size!==s.length||s.length!==r.size||s.some((a)=>!r.has(a)))throw Error("Material dependency pin inventory mismatch");if(n>In.maxRecordBytes||i>In.maxRecordPixels)throw Error("Material record exceeds byte/pixel budget");return structuredClone(t)}var ni=67108864,zh=Le().regex(/^[a-z][a-z0-9_-]{0,79}$/),OC=Le().regex(/^sha256:[a-f0-9]{64}$/),zv=be({version:$e("kiln.asset.v1"),assetId:zh,revisionId:zh,parentRevision:zh.optional(),name:Le().min(1).max(200),tags:at(Le().max(80)).max(30),createdAt:Le().datetime(),description:Le().max(4000).optional(),brief:Le().max(8000).optional(),attribution:be({model:Le().max(200).optional(),harness:Le().max(200).optional(),author:Le().max(200).optional()}).optional(),editable:ra(),files:nu(Le(),be({sha256:OC,bytes:mt().int().nonnegative().max(ni)})),build:be({engine:Le(),options:nu(Le(),ia()),warnings:at(Le()),integration:ia().optional(),qa:ia().optional(),dependencies:at(ia()).optional(),rebuild:It(["engine-required","external-dependencies-required"])}).optional(),preview:be({fidelity:ia().optional(),error:Le().optional(),backdrop:It(X0).optional()}).optional()}),Ec="materials.kiln.json",Vv=25165824;function Vh(e){let t=new Map;for(let n of e.manifest.build?.dependencies??[]){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Invalid saved asset dependency");let i=n;if(i.kind!=="kiln.material.v1"&&i.kind!=="kiln.material.v2"){if(i.delivery==="runtime")throw Error("Unsupported runtime dependency");if(i.delivery!=="embedded")throw Error("Unsupported saved asset dependency");continue}if(i.delivery!=="runtime")throw Error("Invalid saved material dependency");let r=Ja(i.manifest);if(i.kind!==`kiln.material.v${r.schemaVersion}`)throw Error("Saved material dependency kind/version mismatch");let s=`${r.materialId}/${r.revisionId}`,a=t.get(s);if(a&&on(a)!==on(r))throw Error("Conflicting saved material dependency manifests");if(t.set(s,r),t.size>In.maxPayloadRecords)throw Error("Saved asset material dependency count exceeds limit")}return[...t.values()]}function jv(e,t=!1){let n=Vh(e),i=new Map(n.map((d)=>[`${d.materialId}/${d.revisionId}`,on(d)]));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}qa(e.materialResources);let r=Uv.parse(e.materialResources),s=0,a=0,o=new Map;for(let d of r.records){let f=Ja(d.manifest),h=`${d.manifest.materialId}/${d.manifest.revisionId}`;if(o.has(h)||i.has(h)&&i.get(h)!==on(f))throw Error("Asset material closure mismatch");if(o.set(h,f),Object.keys(d.files).length!==d.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let y of d.manifest.maps){if(d.files[y.file]?.length!==Math.ceil(y.bytes/3)*4)throw Error("Asset material map size mismatch");s+=y.bytes,a+=y.width*y.height}}if(s>In.maxPayloadBytes||a>In.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits");let c=new Set,l=new Set,u=(d)=>{if(l.has(d))throw Error("Asset material closure contains a cycle");if(c.has(d))return;let f=o.get(d);if(!f)throw Error("Asset material closure incomplete");l.add(d);for(let h of Bv(f))u(`${h.resourceId}/${h.revisionId}`);l.delete(d),c.add(d)};for(let d of i.keys())u(d);if(c.size!==o.size)throw Error("Asset material closure has unrelated records")}var kC=new Set(["asset.glb","source.kiln.js","preview.png"]);function yu(e){let t=zv.parse(e.manifest),n=Object.keys(e.files);if(n.length!==Object.keys(t.files).length||!n.includes("asset.glb"))throw Error("Asset file inventory mismatch");let i=0;for(let r of n){if(!kC.has(r)||!t.files[r]||t.files[r].bytes!==e.files[r].length)throw Error("Invalid asset file inventory");i+=e.files[r].length}if(i>ni||t.editable!==n.includes("source.kiln.js"))throw Error("Invalid asset size or source inventory");if((e.files["source.kiln.js"]?.length??0)>1048576)throw Error("Source exceeds 1 MiB");jh(e.files["asset.glb"]),jv(e)}function jh(e){if(e.length<20||e.length>ni)throw Error("Invalid GLB size");let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.length||t.getUint32(16,!0)!==1313821514)throw Error("Invalid GLB header");let n=20+t.getUint32(12,!0);if(n>e.length)throw Error("Invalid GLB JSON length");let i=JSON.parse(new TextDecoder().decode(e.subarray(20,n)));for(let r of[...i.buffers??[],...i.images??[]])if(r.uri&&!String(r.uri).startsWith("data:"))throw Error("GLB must embed its resources")}function Hh(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){yu(i),jv(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,a]of Object.entries(i.files))t[r+s]=a;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>Vv)throw Error("Asset material payload exceeds byte limit");t[r+Ec]=s}}for(let i of Object.values(t))n+=i.length;if(n>ni)throw Error("Bundle exceeds 64 MiB");return uv(t,{level:0})}function Hv(e){if(e.length>ni+1048576)throw Error("Bundle exceeds 64 MiB");let t=0,n=0,i=dv(e,{filter:(a)=>{if(t+=a.originalSize,n++,t>ni||n>500||a.name.endsWith(`/${Ec}`)&&a.originalSize>Vv||!/^[a-z][a-z0-9_-]{0,79}\/[a-z][a-z0-9_-]{0,79}\/(manifest\.json|asset\.glb|source\.kiln\.js|preview\.png|materials\.kiln\.json)$/.test(a.name))throw Error("Unsafe or oversized asset bundle");return!0}}),r=[],s=new Set;for(let[a,o]of Object.entries(i)){if(!a.endsWith("/manifest.json"))continue;if(o.length>1048576)throw Error("Manifest exceeds 1 MiB");let c=zv.parse(JSON.parse(new TextDecoder().decode(o))),l=`${c.assetId}/${c.revisionId}/`;if(a!==`${l}manifest.json`)throw Error("Bundle identity mismatch");let u={manifest:c,files:{}};s.add(a);for(let d of Object.keys(c.files)){if(!i[l+d])throw Error("Bundle file missing");u.files[d]=i[l+d],s.add(l+d)}if(i[l+Ec])u.materialResources=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(i[l+Ec])),s.add(l+Ec);yu(u),r.push(u)}if(!r.length||s.size!==Object.keys(i).length)throw Error("Incomplete asset bundle");return r}function Gv(e){let t=e.attribution;if(!t)return[];return[t.model?{label:"Model",value:t.model}:null,t.harness?{label:"Harness",value:t.harness}:null,t.author?{label:"Author",value:t.author}:null].filter((n)=>n!==null)}zi();zi();var gA={type:"change"},qm={type:"start"},yA={type:"end"},Rd=new hs,bA=new bi,RL=Math.cos(70*zc.DEG2RAD),gn=new j,Kn=2*Math.PI,Pt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Xm=0.000001;class Jm extends Td{constructor(e,t=null){super(e,t);if(this.state=Pt.NONE,this.target=new j,this.cursor=new j,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:cs.ROTATE,MIDDLE:cs.DOLLY,RIGHT:cs.PAN},this.touches={ONE:ls.ROTATE,TWO:ls.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new j,this._lastQuaternion=new ln,this._lastTargetPosition=new j,this._quat=new ln().setFromUnitVectors(e.up,new j(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new el,this._sphericalDelta=new el,this._scale=1,this._panOffset=new j,this._rotateStart=new Ke,this._rotateEnd=new Ke,this._rotateDelta=new Ke,this._panStart=new Ke,this._panEnd=new Ke,this._panDelta=new Ke,this._dollyStart=new Ke,this._dollyEnd=new Ke,this._dollyDelta=new Ke,this._dollyDirection=new j,this._mouse=new Ke,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=CL.bind(this),this._onPointerDown=IL.bind(this),this._onPointerUp=NL.bind(this),this._onContextMenu=UL.bind(this),this._onMouseWheel=kL.bind(this),this._onKeyDown=DL.bind(this),this._onTouchStart=LL.bind(this),this._onTouchMove=FL.bind(this),this._onMouseDown=PL.bind(this),this._onMouseMove=OL.bind(this),this._interceptControlDown=BL.bind(this),this._interceptControlUp=zL.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=Pt.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(gA),this.update(),this.state=Pt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(gn.copy(t).sub(this.target),gn.applyQuaternion(this._quat),this._spherical.setFromVector3(gn),this.autoRotate&&this.state===Pt.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=Kn;else if(n>Math.PI)n-=Kn;if(i<-Math.PI)i+=Kn;else if(i>Math.PI)i-=Kn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(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);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(gn.setFromSpherical(this._spherical),gn.applyQuaternion(this._quatInverse),t.copy(this.target).add(gn),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);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let a=gn.length();s=this._clampDistance(a*this._scale);let o=a-s;this.object.position.addScaledVector(this._dollyDirection,o),this.object.updateMatrixWorld(),r=!!o}else if(this.object.isOrthographicCamera){let a=new j(this._mouse.x,this._mouse.y,0);a.unproject(this.object);let o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=o!==this.object.zoom;let c=new j(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),s=gn.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if(Rd.origin.copy(this.object.position),Rd.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Rd.direction))<RL)this.object.lookAt(this.target);else bA.setFromNormalAndCoplanarPoint(this.object.up,this.target),Rd.intersectPlane(bA,this.target)}else if(this.object.isOrthographicCamera){let s=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom)this.object.updateProjectionMatrix(),r=!0}if(this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Xm||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Xm||this._lastTargetPosition.distanceToSquared(this.target)>Xm)return this.dispatchEvent(gA),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(e){if(e!==null)return Kn/60*this.autoRotateSpeed*e;else return Kn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){gn.setFromMatrixColumn(t,0),gn.multiplyScalar(-e),this._panOffset.add(gn)}_panUp(e,t){if(this.screenSpacePanning===!0)gn.setFromMatrixColumn(t,1);else gn.setFromMatrixColumn(t,0),gn.crossVectors(this.object.up,gn);gn.multiplyScalar(e),this._panOffset.add(gn)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;gn.copy(i).sub(this.target);let r=gn.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:a}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Kn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Kn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){if(this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){if(this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0)this._dollyIn(this._getZoomScale(e.deltaY));else if(e.deltaY>0)this._dollyOut(this._getZoomScale(e.deltaY));this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(Kn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);t=!0;break;case this.keys.BOTTOM:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(-Kn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);t=!0;break;case this.keys.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(Kn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);t=!0;break;case this.keys.RIGHT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(-Kn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);t=!0;break}if(t)e.preventDefault(),this.update()}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enablePan)this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enableRotate)this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=0.5*(e.pageX+n.x),r=0.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Kn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Kn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,a=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,a)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Ke,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function IL(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function CL(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function NL(e){switch(this._removePointer(e),this._pointers.length){case 0:if(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(yA),this.state=Pt.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function PL(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case cs.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=Pt.DOLLY;break;case cs.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=Pt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=Pt.ROTATE}break;case cs.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=Pt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=Pt.PAN}break;default:this.state=Pt.NONE}if(this.state!==Pt.NONE)this.dispatchEvent(qm)}function OL(e){switch(this.state){case Pt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case Pt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case Pt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function kL(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==Pt.NONE)return;e.preventDefault(),this.dispatchEvent(qm),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(yA)}function DL(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function LL(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case ls.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=Pt.TOUCH_ROTATE;break;case ls.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=Pt.TOUCH_PAN;break;default:this.state=Pt.NONE}break;case 2:switch(this.touches.TWO){case ls.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=Pt.TOUCH_DOLLY_PAN;break;case ls.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=Pt.TOUCH_DOLLY_ROTATE;break;default:this.state=Pt.NONE}break;default:this.state=Pt.NONE}if(this.state!==Pt.NONE)this.dispatchEvent(qm)}function FL(e){switch(this._trackPointer(e),this.state){case Pt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case Pt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case Pt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case Pt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=Pt.NONE}}function UL(e){if(this.enabled===!1)return;e.preventDefault()}function BL(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function zL(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}zi();class Zm extends Ao{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new ms;e.deleteAttribute("uv");let t=new Ur({side:Pn}),n=new Ur,i=new Co(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new jt(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new wo(e,n,6),a=new kt;a.position.set(-10.906,2.009,1.846),a.rotation.set(0,-0.195,0),a.scale.set(2.328,7.905,4.651),a.updateMatrix(),s.setMatrixAt(0,a.matrix),a.position.set(-5.607,-0.754,-0.758),a.rotation.set(0,0.994,0),a.scale.set(1.97,1.534,3.955),a.updateMatrix(),s.setMatrixAt(1,a.matrix),a.position.set(6.167,0.857,7.803),a.rotation.set(0,0.561,0),a.scale.set(3.927,6.285,3.687),a.updateMatrix(),s.setMatrixAt(2,a.matrix),a.position.set(-2.017,0.018,6.124),a.rotation.set(0,0.333,0),a.scale.set(2.002,4.566,2.064),a.updateMatrix(),s.setMatrixAt(3,a.matrix),a.position.set(2.291,-0.756,-2.621),a.rotation.set(0,-0.286,0),a.scale.set(1.546,1.552,1.496),a.updateMatrix(),s.setMatrixAt(4,a.matrix),a.position.set(-2.193,-0.369,-5.547),a.rotation.set(0,0.516,0),a.scale.set(3.875,3.487,2.986),a.updateMatrix(),s.setMatrixAt(5,a.matrix),this.add(s);let o=new jt(e,Do(50));o.position.set(-16.116,14.37,8.208),o.scale.set(0.1,2.428,2.739),this.add(o);let c=new jt(e,Do(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new jt(e,Do(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new jt(e,Do(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let d=new jt(e,Do(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,0.1),this.add(d);let f=new jt(e,Do(100));f.position.set(0,20,0),f.scale.set(1,0.1,1),this.add(f)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function Do(e){return new md({color:0,emissive:16777215,emissiveIntensity:e})}zi();zi();zi();function Ym(e,t){if(t===lm)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===To||t===Bc){let n=e.getIndex();if(n===null){let s=[],a=e.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)s.push(o);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===To)for(let s=1;s<=i;s++)r.push(n.getX(0)),r.push(n.getX(s)),r.push(n.getX(s+1));else for(let s=0;s<i;s++)if(s%2===0)r.push(n.getX(s)),r.push(n.getX(s+1)),r.push(n.getX(s+2));else r.push(n.getX(s+2)),r.push(n.getX(s+1)),r.push(n.getX(s));if(r.length/3!==i)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(r),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function xA(e){let t=new Map,n=new Map,i=e.clone();return _A(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,a=t.get(r),o=a.skeleton.bones;s.skeleton=a.skeleton.clone(),s.bindMatrix.copy(a.bindMatrix),s.skeleton.bones=o.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function _A(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)_A(e.children[i],t.children[i],n)}class sg extends zr{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new RA(t)}),this.register(function(t){return new IA(t)}),this.register(function(t){return new UA(t)}),this.register(function(t){return new BA(t)}),this.register(function(t){return new zA(t)}),this.register(function(t){return new NA(t)}),this.register(function(t){return new PA(t)}),this.register(function(t){return new OA(t)}),this.register(function(t){return new kA(t)}),this.register(function(t){return new MA(t)}),this.register(function(t){return new DA(t)}),this.register(function(t){return new CA(t)}),this.register(function(t){return new FA(t)}),this.register(function(t){return new LA(t)}),this.register(function(t){return new SA(t)}),this.register(function(t){return new ng(t,ut.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new ng(t,ut.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new VA(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=_s.extractUrlBase(e);s=_s.resolveURL(c,this.path)}else s=_s.extractUrlBase(e);this.manager.itemStart(e);let a=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},o=new Yc(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},a)}catch(l){a(l)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){if(this.pluginCallbacks.indexOf(e)===-1)this.pluginCallbacks.push(e);return this}unregister(e){if(this.pluginCallbacks.indexOf(e)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1);return this}parse(e,t,n,i){let r,s={},a={},o=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===jA){try{s[ut.KHR_BINARY_GLTF]=new HA(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[ut.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new XA(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");a[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],d=r.extensionsRequired||[];switch(u){case ut.KHR_MATERIALS_UNLIT:s[u]=new wA;break;case ut.KHR_DRACO_MESH_COMPRESSION:s[u]=new GA(r,this.dracoLoader);break;case ut.KHR_TEXTURE_TRANSFORM:s[u]=new $A;break;case ut.KHR_MESH_QUANTIZATION:s[u]=new KA;break;default:if(d.indexOf(u)>=0&&a[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function VL(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function rn(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var ut={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class SA{constructor(e){this.parser=e,this.name=ut.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,o=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new qe(16777215);if(o.color!==void 0)l.setRGB(o.color[0],o.color[1],o.color[2],si);let u=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new No(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Co(l),c.distance=u;break;case"spot":c=new _d(l),c.distance=u,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}if(c.position.set(0,0,0),gr(c,o),o.intensity!==void 0)c.intensity=o.intensity;return c.name=t.createUniqueName(o.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;if(a===void 0)return null;return this._loadLight(a).then(function(o){return n._getNodeRef(t.cache,a,o)})}}class wA{constructor(){this.name=ut.KHR_MATERIALS_UNLIT}getMaterialType(){return hr}extendParams(e,t,n){let i=[];e.color=new qe(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],si),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,fs))}return Promise.all(i)}}class MA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=rn(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class RA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ke(r,r)}}return Promise.all(i)}}class IA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_DISPERSION}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class CA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class NA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_SHEEN}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new qe(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],si)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,fs));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class PA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class OA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_VOLUME}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new qe().setRGB(r[0],r[1],r[2],si),Promise.all(i)}}class kA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_IOR}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class DA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_SPECULAR}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new qe().setRGB(r[0],r[1],r[2],si),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,fs));return Promise.all(i)}}class LA{constructor(e){this.parser=e,this.name=ut.EXT_MATERIALS_BUMP}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class FA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return rn(this.parser,e,this.name)!==null?ci:null}extendMaterialParams(e,t){let n=rn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class UA{constructor(e){this.parser=e,this.name=ut.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class BA{constructor(e){this.parser=e,this.name=ut.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],a=i.images[s.source],o=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);if(c!==null)o=c}return n.loadTextureImage(e,s.source,o)}}class zA{constructor(e){this.parser=e,this.name=ut.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],a=i.images[s.source],o=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);if(c!==null)o=c}return n.loadTextureImage(e,s.source,o)}}class ng{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(a){let o=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,d=new Uint8Array(a,o,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,d,i.mode,i.filter).then(function(f){return f.buffer});else return s.ready.then(function(){let f=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(f),l,u,d,i.mode,i.filter),f})})}else return null}}class VA{constructor(e){this.name=ut.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==vi.TRIANGLES&&c.mode!==vi.TRIANGLE_STRIP&&c.mode!==vi.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,a=[],o={};for(let c in s)a.push(this.parser.getDependency("accessor",s[c]).then((l)=>(o[c]=l,o[c])));if(a.length<1)return null;return a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],d=c[0].count,f=[];for(let h of u){let y=new Qe,g=new j,m=new ln,p=new j(1,1,1),b=new wo(h.geometry,h.material,d);for(let x=0;x<d;x++){if(o.TRANSLATION)g.fromBufferAttribute(o.TRANSLATION,x);if(o.ROTATION)m.fromBufferAttribute(o.ROTATION,x);if(o.SCALE)p.fromBufferAttribute(o.SCALE,x);b.setMatrixAt(x,y.compose(g,m,p))}let _=null;for(let x in o)if(x==="_COLOR_0"){let v=o[x];b.instanceColor=new os(v.array,v.itemSize,v.normalized)}else if(x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"){if(_===null){let E=b.geometry;_=new On,_.name=E.name;for(let S in E.attributes)_.setAttribute(S,E.attributes[S]);for(let S in E.morphAttributes)_.morphAttributes[S]=E.morphAttributes[S];if(E.index!==null)_.setIndex(E.index);_.morphTargetsRelative=E.morphTargetsRelative;for(let S of E.groups)_.addGroup(S.start,S.count,S.materialIndex);if(E.boundingBox!==null)_.boundingBox=E.boundingBox.clone();if(E.boundingSphere!==null)_.boundingSphere=E.boundingSphere.clone();_.drawRange.start=E.drawRange.start,_.drawRange.count=E.drawRange.count,_.userData=Object.assign({},E.userData),b.geometry=_}let v=o[x];_.setAttribute(x,new os(v.array,v.itemSize,v.normalized))}kt.prototype.copy.call(b,h),this.parser.assignFinalMaterial(b),f.push(b)}if(l.isGroup)return l.clear(),l.add(...f),l;return f[0]})}}var jA="glTF",al=12,vA={JSON:1313821514,BIN:5130562};class HA{constructor(e){this.name=ut.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,al),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==jA)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-al,r=new DataView(e,al),s=0;while(s<i){let a=r.getUint32(s,!0);s+=4;let o=r.getUint32(s,!0);if(s+=4,o===vA.JSON){let c=new Uint8Array(e,al+s,a);this.content=n.decode(c)}else if(o===vA.BIN){let c=al+s;this.body=e.slice(c,c+a)}s+=a}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class GA{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ut.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,a={},o={},c={};for(let l in s){let u=ig[l]||l.toLowerCase();a[u]=s[l]}for(let l in e.attributes){let u=ig[l]||l.toLowerCase();if(s[l]!==void 0){let d=n.accessors[e.attributes[l]],f=Lo[d.componentType];c[u]=f.name,o[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,d){i.decodeDracoFile(l,function(f){for(let h in f.attributes){let y=f.attributes[h],g=o[h];if(g!==void 0)y.normalized=g}u(f)},a,c,si,d)})})}}class $A{constructor(){this.name=ut.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class KA{constructor(){this.name=ut.KHR_MESH_QUANTIZATION}}class ag extends Br{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,l=i-t,u=(n-t)/l,d=u*u,f=d*u,h=e*c,y=h-c,g=-2*f+3*d,m=f-d,p=1-g,b=m-d+u;for(let _=0;_!==a;_++){let x=s[y+_+a],v=s[y+_+o]*l,E=s[h+_+a],S=s[h+_]*l;r[_]=p*x+b*v+g*E+m*S}return r}}var jL=new ln;class WA extends ag{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return jL.fromArray(r).normalize().toArray(r),r}}var vi={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Lo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},EA={9728:Fi,9729:En,9984:Ju,9985:vo,9986:ma,9987:ur},TA={33071:_o,33648:qu,10497:xo},Qm={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ig={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},vs={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},HL={CUBICSPLINE:void 0,LINEAR:id,STEP:cm},eg={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function GL(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new Ur({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:us});return e.DefaultMaterial}function Sa(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function gr(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function $L(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let d=t[l];if(d.POSITION!==void 0)i=!0;if(d.NORMAL!==void 0)r=!0;if(d.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let a=[],o=[],c=[];for(let l=0,u=t.length;l<u;l++){let d=t[l];if(i){let f=d.POSITION!==void 0?n.getDependency("accessor",d.POSITION):e.attributes.position;a.push(f)}if(r){let f=d.NORMAL!==void 0?n.getDependency("accessor",d.NORMAL):e.attributes.normal;o.push(f)}if(s){let f=d.COLOR_0!==void 0?n.getDependency("accessor",d.COLOR_0):e.attributes.color;c.push(f)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c)]).then(function(l){let u=l[0],d=l[1],f=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=d;if(s)e.morphAttributes.color=f;return e.morphTargetsRelative=!0,e})}function KL(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++)e.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function WL(e){let t,n=e.extensions&&e.extensions[ut.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+tg(n.attributes);else t=e.indices+":"+tg(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+tg(e.targets[i]);return t}function tg(e){let t="",n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function rg(e){switch(e){case Int8Array:return 0.007874015748031496;case Uint8Array:return 0.00392156862745098;case Int16Array:return 0.00003051850947599719;case Uint16Array:return 0.000015259021896696422;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function XL(e){if(e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0)return"image/webp";if(e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var qL=new Qe;class XA{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new VL,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let o=a.match(/Version\/(\d+)/);i=n&&o?parseInt(o[1],10):-1,r=a.indexOf("Firefox")>-1,s=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new Ro(this.options.manager);else this.textureLoader=new vd(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Yc(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let a={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return Sa(r,a,i),gr(a,i),Promise.all(n._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(let o of a.scenes)o.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let a=0,o=s.length;a<o;a++)e[s[a]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,a)=>{let o=this.associations.get(s);if(o!=null)this.associations.set(a,o);for(let[c,l]of s.children.entries())r(l,a.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[ut.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(_s.resolveURL(t.uri,i.path),r,void 0,function(){s(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let s=Qm[i.type],a=Lo[i.componentType],o=i.normalized===!0,c=new a(i.count*s);return Promise.resolve(new vn(c,s,o))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let a=s[0],o=Qm[i.type],c=Lo[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*o,d=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,h=i.normalized===!0,y,g;if(f&&f!==u){let m=Math.floor(d/f),p="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+m+":"+i.count,b=t.cache.get(p);if(!b)y=new c(a,m*f,i.count*f/l),b=new Hc(y,f/l),t.cache.add(p,b);g=new So(b,o,d%f/l,h)}else{if(a===null)y=new c(i.count*o);else y=new c(a,d,i.count*o);g=new vn(y,o,h)}if(i.sparse!==void 0){let m=Qm.SCALAR,p=Lo[i.sparse.indices.componentType],b=i.sparse.indices.byteOffset||0,_=i.sparse.values.byteOffset||0,x=new p(s[1],b,i.sparse.count*m),v=new c(s[2],_,i.sparse.count*o);if(a!==null)g=new vn(g.array.slice(),g.itemSize,g.normalized);g.normalized=!1;for(let E=0,S=x.length;E<S;E++){let T=x[E];if(g.setX(T,v[E*o]),o>=2)g.setY(T,v[E*o+1]);if(o>=3)g.setZ(T,v[E*o+2]);if(o>=4)g.setW(T,v[E*o+3]);if(o>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=h}return g})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],a=this.textureLoader;if(s.uri){let o=n.manager.getHandler(s.uri);if(o!==null)a=o}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],a=r.images[t],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||a.name||"",l.name===""&&typeof a.uri==="string"&&a.uri.startsWith("data:image/")===!1)l.name=a.uri;let d=(r.samplers||{})[s.sampler]||{};return l.magFilter=EA[d.magFilter]||En,l.minFilter=EA[d.minFilter]||ur,l.wrapS=TA[d.wrapS]||xo,l.wrapT=TA[d.wrapT]||xo,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Fi&&l.minFilter!==En,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],a=self.URL||self.webkitURL,o=s.uri||"",c=!1;if(s.bufferView!==void 0)o=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let d=new Blob([u],{type:s.mimeType});return o=a.createObjectURL(d),o});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(o).then(function(u){return new Promise(function(d,f){let h=d;if(t.isImageBitmapLoader===!0)h=function(y){let g=new Qt(y);g.needsUpdate=!0,d(g)};t.load(_s.resolveURL(u,r.path),h,void 0,f)})}).then(function(u){if(c===!0)a.revokeObjectURL(o);return gr(u,s),u.userData.mimeType=s.mimeType||XL(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[ut.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[ut.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let o=r.associations.get(s);s=r.extensions[ut.KHR_TEXTURE_TRANSFORM].extendTexture(s,a),r.associations.set(s,o)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+n.uuid,o=this.cache.get(a);if(!o)o=new qc,$n.prototype.copy.call(o,n),o.color.copy(n.color),o.map=n.map,o.sizeAttenuation=!1,this.cache.add(a,o);n=o}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,o=this.cache.get(a);if(!o)o=new Xc,$n.prototype.copy.call(o,n),o.color.copy(n.color),o.map=n.map,this.cache.add(a,o);n=o}if(i||r||s){let a="ClonedMaterial:"+n.uuid+":";if(i)a+="derivative-tangents:";if(r)a+="vertex-colors:";if(s)a+="flat-shading:";let o=this.cache.get(a);if(!o){if(o=n.clone(),r)o.vertexColors=!0;if(s)o.flatShading=!0;if(i){if(o.normalScale)o.normalScale.y*=-1;if(o.clearcoatNormalScale)o.clearcoatNormalScale.y*=-1}this.cache.add(a,o),this.associations.set(o,this.associations.get(n))}n=o}e.material=n}getMaterialType(){return Ur}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,a={},o=r.extensions||{},c=[];if(o[ut.KHR_MATERIALS_UNLIT]){let u=i[ut.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(a,r,t))}else{let u=r.pbrMetallicRoughness||{};if(a.color=new qe(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){let d=u.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],si),a.opacity=d[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(a,"map",u.baseColorTexture,fs));if(a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}if(r.doubleSided===!0)a.side=xi;let l=r.alphaMode||eg.OPAQUE;if(l===eg.BLEND)a.transparent=!0,a.depthWrite=!1;else if(a.transparent=!1,l===eg.MASK)a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==hr){if(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Ke(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;a.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==hr){if(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)a.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==hr){let u=r.emissiveFactor;a.emissive=new qe().setRGB(u[0],u[1],u[2],si)}if(r.emissiveTexture!==void 0&&s!==hr)c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,fs));return Promise.all(c).then(function(){let u=new s(a);if(r.name)u.name=r.name;if(gr(u,r),t.associations.set(u,{materials:e}),r.extensions)Sa(i,u,r);return u})}createUniqueName(e){let t=Et.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(a){return n[ut.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(o){return AA(o,a,t)})}let s=[];for(let a=0,o=e.length;a<o;a++){let c=e[a],l=WL(c),u=i[l];if(u)s.push(u.promise);else{let d;if(c.extensions&&c.extensions[ut.KHR_DRACO_MESH_COMPRESSION])d=r(c);else d=AA(new On,c,t);if(c.mode===vi.TRIANGLE_STRIP)d=d.then((f)=>Ym(f,Bc));else if(c.mode===vi.TRIANGLE_FAN)d=d.then((f)=>Ym(f,To));i[l]={primitive:c,promise:d},s.push(d)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,a=[];for(let o=0,c=s.length;o<c;o++){let l=s[o].material===void 0?GL(this.cache):this.getDependency("material",s[o].material);a.push(l)}return a.push(t.loadGeometries(s)),Promise.all(a).then(async function(o){let c=o.slice(0,o.length-1),l=o[o.length-1],u=[];for(let f=0,h=l.length;f<h;f++){let y=l[f],g=s[f],m,p=c[f];if(g.mode===vi.TRIANGLES||g.mode===vi.TRIANGLE_STRIP||g.mode===vi.TRIANGLE_FAN||g.mode===void 0){let b=r.isSkinnedMesh===!0,_=y.hasAttribute("skinIndex")&&y.hasAttribute("skinWeight");if(b&&_===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(m=b&&_?new ud(y,p):new jt(y,p),m.isSkinnedMesh===!0)m.normalizeSkinWeights()}else if(g.mode===vi.LINES)m=new dd(y,p);else if(g.mode===vi.LINE_STRIP)m=new ps(y,p);else if(g.mode===vi.LINE_LOOP)m=new fd(y,p);else if(g.mode===vi.POINTS)m=new Mo(y,p);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);if(Object.keys(m.geometry.morphAttributes).length>0)KL(m,r);if(m.name=t.createUniqueName(r.name||"mesh_"+e),gr(m,r),g.extensions)Sa(i,m,g);t.assignFinalMaterial(m),u.push(m)}for(let f=0,h=u.length;f<h;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1){if(r.extensions)Sa(i,u[0],r);return u[0]}let d=new ar;if(r.extensions)Sa(i,d,r);t.associations.set(d,{meshes:e});for(let f=0,h=u.length;f<h;f++)d.add(u[f]);return d})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new fn(zc.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new Ta(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return gr(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,a=[],o=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){a.push(u);let d=new Qe;if(r!==null)d.fromArray(r.array,c*16);o.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Kc(a,o)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],a=[],o=[],c=[],l=[];for(let u=0,d=i.channels.length;u<d;u++){let f=i.channels[u],h=i.samplers[f.sampler],y=f.target,g=y.node,m=i.parameters!==void 0?i.parameters[h.input]:h.input,p=i.parameters!==void 0?i.parameters[h.output]:h.output;if(y.node===void 0)continue;s.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",m)),o.push(this.getDependency("accessor",p)),c.push(h),l.push(y)}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(l)]).then(function(u){let d=u[0],f=u[1],h=u[2],y=u[3],g=u[4],m=[];for(let b=0,_=d.length;b<_;b++){let x=d[b],v=f[b],E=h[b],S=y[b],T=g[b];if(x===void 0)continue;if(x.updateMatrix)x.updateMatrix();let A=n._createAnimationTracks(x,v,E,S,T);if(A)for(let P=0;P<A.length;P++)m.push(A[P])}let p=new mo(r,void 0,m);return gr(p,i),p})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(a){if(!a.isMesh)return;for(let o=0,c=i.weights.length;o<c;o++)a.morphTargetInfluences[o]=i.weights[o]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],a=i.children||[];for(let c=0,l=a.length;c<l;c++)s.push(n.getDependency("node",a[c]));let o=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),o]).then(function(c){let l=c[0],u=c[1],d=c[2];if(d!==null)l.traverse(function(f){if(!f.isSkinnedMesh)return;f.bind(d,qL)});for(let f=0,h=u.length;f<h;f++)l.add(u[f]);if(l.userData.pivot!==void 0&&u.length>0){let f=l.userData.pivot,h=u[0];l.pivot=new j().fromArray(f),l.position.x-=f[0],l.position.y-=f[1],l.position.z-=f[2],h.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",a=[],o=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(o)a.push(o);if(r.camera!==void 0)a.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let l;if(r.isBone===!0)l=new Gc;else if(c.length>1)l=new ar;else if(c.length===1)l=c[0];else l=new kt;if(l!==c[0])for(let u=0,d=c.length;u<d;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(gr(l,r),r.extensions)Sa(n,l,r);if(r.matrix!==void 0){let u=new Qe;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new ar;if(n.name)r.name=i.createUniqueName(n.name);if(gr(r,n),n.extensions)Sa(t,r,n);let s=n.nodes||[],a=[];for(let o=0,c=s.length;o<c;o++)a.push(i.getDependency("node",s[o]));return Promise.all(a).then(function(o){for(let l=0,u=o.length;l<u;l++){let d=o[l];if(d.parent!==null)r.add(xA(d));else r.add(d)}let c=(l)=>{let u=new Map;for(let[d,f]of i.associations)if(d instanceof $n||d instanceof Qt)u.set(d,f);return l.traverse((d)=>{let f=i.associations.get(d);if(f!=null)u.set(d,f)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],a=e.name?e.name:e.uuid,o=[];function c(f){if(f.morphTargetInfluences)o.push(f.name?f.name:f.uuid)}if(vs[r.path]===vs.weights){if(c(e),e.isGroup)e.children.forEach(c)}else o.push(a);let l;switch(vs[r.path]){case vs.weights:l=bs;break;case vs.rotation:l=ys;break;case vs.translation:case vs.scale:l=Ea;break;default:switch(n.itemSize){case 1:l=bs;break;case 2:case 3:default:l=Ea;break}break}let u=i.interpolation!==void 0?HL[i.interpolation]:id,d=this._getArrayFromAccessor(n);for(let f=0,h=o.length;f<h;f++){let y=new l(o[f]+"."+vs[r.path],t.array,d,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(y);s.push(y)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=rg(t.constructor),i=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof ys?WA:ag)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function JL(e,t,n){let i=t.attributes,r=new hn;if(i.POSITION!==void 0){let o=n.json.accessors[i.POSITION],{min:c,max:l}=o;if(c!==void 0&&l!==void 0){if(r.set(new j(c[0],c[1],c[2]),new j(l[0],l[1],l[2])),o.normalized){let u=rg(Lo[o.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let o=new j,c=new j;for(let l=0,u=s.length;l<u;l++){let d=s[l];if(d.POSITION!==void 0){let f=n.json.accessors[d.POSITION],{min:h,max:y}=f;if(h!==void 0&&y!==void 0){if(c.setX(Math.max(Math.abs(h[0]),Math.abs(y[0]))),c.setY(Math.max(Math.abs(h[1]),Math.abs(y[1]))),c.setZ(Math.max(Math.abs(h[2]),Math.abs(y[2]))),f.normalized){let g=rg(Lo[f.componentType]);c.multiplyScalar(g)}o.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(o)}e.boundingBox=r;let a=new oi;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=a}function AA(e,t,n){let i=t.attributes,r=[];function s(a,o){return n.getDependency("accessor",a).then(function(c){e.setAttribute(o,c)})}for(let a in i){let o=ig[a]||a.toLowerCase();if(o in e.attributes)continue;r.push(s(i[a],o))}if(t.indices!==void 0&&!e.index){let a=n.getDependency("accessor",t.indices).then(function(o){e.setIndex(o)});r.push(a)}if(ot.workingColorSpace!==si&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ot.workingColorSpace}" not supported.`);return gr(e,t),JL(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?$L(e,t.targets,n):e})}function br(e){let t=new Set,n=new Set,i=new Set;e.traverse((r)=>{let s=r;if(!s.isMesh)return;t.add(s.geometry);for(let a of Array.isArray(s.material)?s.material:[s.material]){n.add(a);for(let o of Object.values(a))if(o instanceof Qt)i.add(o)}});for(let r of[...t,...n,...i])r.dispose()}async function qA(e){jh(e);let t=new Zc,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new Ro(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new sg(t);i.register((s)=>({name:"KILN_embedded_images",async beforeRoot(){for(let a of s.json.images??[]){if(a.bufferView===void 0)continue;let o=new Uint8Array(await s.getDependency("bufferView",a.bufferView)),c="";for(let l=0;l<o.length;l+=8192)c+=String.fromCharCode(...o.subarray(l,l+8192));if(!/^image\/(png|jpeg|webp|avif)$/.test(a.mimeType??""))throw Error("Unsupported embedded image type");a.uri=`data:${a.mimeType};base64,${btoa(c)}`,delete a.bufferView}}}));let r=await i.parseAsync(Uint8Array.from(e).buffer,"");if(n){for(let s of r.scenes)br(s);throw Error("An embedded texture could not be decoded.")}return Object.assign(r,{assertTexturesLoaded(){if(n)throw Error("An embedded texture could not be decoded.")}})}zi();function JA(e,t,n=40,i=[e]){let r=e.getCenter(new j),s=Math.max(e.getSize(new j).length()/2,0.01),a=new j(1,0.65,1.25).normalize(),o=new j().crossVectors(new j(0,1,0),a).normalize(),c=new j().crossVectors(a,o),l=[];for(let b of i.length?i:[e])for(let _ of[b.min.x,b.max.x])for(let x of[b.min.y,b.max.y])for(let v of[b.min.z,b.max.z])l.push(new j(_,x,v));let u=1/0,d=-1/0,f=1/0,h=-1/0;for(let b of l){let _=b.clone().sub(r),x=_.dot(o),v=_.dot(c);u=Math.min(u,x),d=Math.max(d,x),f=Math.min(f,v),h=Math.max(h,v)}r.addScaledVector(o,(u+d)/2),r.addScaledVector(c,(f+h)/2);let y=Math.tan(n*Math.PI/360),g=y*t,m=s;for(let b of l){let _=b.clone().sub(r),x=_.dot(a);m=Math.max(m,x+Math.abs(_.dot(o))*1.12/g,x+Math.abs(_.dot(c))*1.12/y)}let p=r.clone().addScaledVector(a,m);return{center:r,radius:s,distance:m,position:p}}zi();function og(e,t){return{position:e.position.clone(),target:t.clone()}}function cg(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new j).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new j))+r*20,10),e.updateProjectionMatrix()}function ZA(e,t,n){let i=e.getWorldDirection(new j);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new j(0,1,0)),s=new j;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function YA(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}async function QA(e,t){let n=t();if(n===void 0)throw Error("Wait for the selected artifact to be loaded before measuring.");let i=JSON.stringify(n),r=await e();if(JSON.stringify(t())!==i)throw Error("The artifact changed during measurement. Measure the loaded revision again.");return{...r,artifact:n}}function eS(e,t,n){if(t())return e;n(e);return}zi();function Id(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,a)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(a)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((a)=>{let o=e.parser.associations.get(a)?.nodes;if(o===void 0||!i.has(o))return;a.visible=!1,r++});return r}function Cd(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new hn().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new hn,i=new hn,r=new j;return e.traverseVisible((s)=>{let a=s,o=a.geometry;if(!o)return;let c=o.getAttribute("position");if(c&&a.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(a.isMesh)a.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(o.boundingBox===null)o.computeBoundingBox();i.copy(o.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new hn().setFromObject(e,!0):n}function ol(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function tS(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((y)=>!Number.isInteger(y)||!t[y]||n.has(y)))continue;let d=l.parent;while(d&&!i.has(d))d=d.parent;if(d)continue;let f=[l];for(let y of u)f.push(await e.parser.getDependency("node",y));Id(e,f.slice(1)),i.add(l);let h=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:h,levels:f})}if(r.length===0)return;let s=ol(e.scene)-r.reduce((c,l)=>c+lg(l,0),0),a=Math.max(...r.map((c)=>c.levels.length)),o=Array.from({length:a},(c,l)=>s+r.reduce((u,d)=>u+lg(d,l),0));return{chains:r,triangles:o}}var nS=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function lg(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return ol(nS(e,t))}function iS(e,t){let n=nS(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function rS(e,t){for(let n of e.chains)iS(n,t)}function sS(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return iS(i,n),!0}function aS(e,t){if(!e)return;return{triangles:ol(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>lg(n,r))}))}}function Fo(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function ug(e){return e.map((t,n)=>`LOD${n} · ${t.toLocaleString()} triangles`)}function cl(e){let t=new Km({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=Lc,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new Ao,i=new fn(40,1,0.01,1000),r=new Jm(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,a=!1,o=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(O)=>{if(!a||!c.has(O.code))return;O.preventDefault(),s.add(O.code)},u=(O)=>s.delete(O.code),d=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",d);let f=new sl(t),h=new Zm,y=f.fromScene(h,0.04);n.environment=y.texture,h.dispose(),f.dispose();let g=new No(16773591,2.4);g.position.set(4,8,5),n.add(g),n.add(new yd(14806490,5065021,1.7));let m,p,b,_=[],x=!0,v=performance.now(),E=0,S=0,T=!1,A,P,w,I=(O)=>{if(!w)return;clearTimeout(w.timeout),w.reject(Error(O)),w=void 0},F=(O)=>{let K=t.getContext(),B=K.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:O-w.started,frameMs:YA(w.samples),...P===void 0?{}:{loadToFirstFrameMs:P},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(K.getParameter(K.VERSION)),vendor:String(K.getParameter(K.VENDOR)),renderer:String(K.getParameter(K.RENDERER)),browser:navigator.userAgent,...B?{unmaskedVendor:String(K.getParameter(B.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(K.getParameter(B.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},N=()=>{if(!m)return;let O=Cd(m),K=[];m.traverseVisible((de)=>{if(de instanceof jt||de instanceof ps||de instanceof Mo){let Me=new hn().setFromObject(de,!0);if(!Me.isEmpty())K.push(Me)}});let{center:B,radius:X,distance:q,position:le}=JA(O,i.aspect,i.fov,K);if(r.target.copy(B),i.position.copy(le),i.near=Math.max(X/1000,0.0001),i.far=q+X*100,r.minDistance=X*0.1,r.maxDistance=X*80,o=Math.max(X*0.35,0.01),a)r.minDistance=X*0.00001;i.updateProjectionMatrix(),r.update()},U=new ResizeObserver(()=>{let{clientWidth:O,clientHeight:K}=e;if(!O||!K)return;t.setSize(O,K),i.aspect=O/K,i.updateProjectionMatrix()});U.observe(e);let D=(O)=>{if(T)return;let K=Math.min((O-v)/1000,0.1);if(v=O,e.clientWidth&&e.clientHeight){if(x)b?.update(K);if(a&&s.size){let B=ZA(i,s,K*o*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(B),r.target.add(B)}if(r.update(),t.render(n,i),A!==void 0)P=performance.now()-A,A=void 0;if(w){if(w.previous>0&&w.samples.length<1800)w.samples.push(O-w.previous);if(w.previous=O,O-w.started>=w.duration&&w.samples.length){let B=F(O);clearTimeout(w.timeout),w.resolve(B),w=void 0}}}else s.clear(),I("Keep the measured viewport visible for the complete sampling window.");E=requestAnimationFrame(D)};return E=requestAnimationFrame(D),{async load(O,K={}){let B=performance.now(),X=++S;I("The artifact changed during measurement. Measure the new revision again.");let q=await qA(O);Id(q,[q.scene]);let le=await tS(q);try{q.assertTexturesLoaded()}catch(te){br(q.scene);for(let ie of Fo(le))br(ie);throw te}let de=eS(q,()=>!T&&X===S&&K.isCurrent?.()!==!1,(te)=>{br(te.scene);for(let ie of Fo(le))br(ie)});if(!de)return;let Me=m&&K.preserveView?og(i,r.target):void 0;if(m){b?.stopAllAction(),b?.uncacheRoot(m),n.remove(m),br(m);for(let te of Fo(p))br(te)}m=de.scene,p=le,A=B,P=void 0,n.add(m),_=de.animations,b=new Ed(m),x=!0;let{clientWidth:pe,clientHeight:J}=e;if(t.setSize(pe,J),i.aspect=pe&&J?pe/J:i.aspect,N(),Me)cg(i,r.target,Me,Cd(m)),r.update();let L=0,W=new Set;return m.traverseVisible((te)=>{let ie=te;if(!ie.isMesh)return;L++;for(let ce of Array.isArray(ie.material)?ie.material:[ie.material])W.add(ce)}),K.onCommit?.(),{triangles:ol(m),meshes:L,materials:W.size,clips:_.map((te)=>te.name),...p?{levels:p.triangles}:{}}},level(O){if(I("The level of detail changed. Measure the displayed combination again."),p)rS(p,O)},partLevel(O,K){if(I("The level of detail changed. Measure the displayed combination again."),p)sS(p,O,K)},lod(){return m?aS(p,m):void 0},reset:N,cancelMeasurement:I,measure(O=3000){if(T||!m||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(O)||O<1000||O>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(w)return Promise.reject(Error("A measurement is already running."));return new Promise((K,B)=>{w={started:performance.now(),previous:0,duration:O,samples:[],resolve:K,reject:B,timeout:setTimeout(()=>I("Measurement was interrupted or the browser stopped delivering frames."),O+2000)}})},view(){return og(i,r.target)},setView(O){if(!m)return;cg(i,r.target,O,Cd(m)),r.update()},navigation(O){if(a=O==="explore",s.clear(),r.minDistance=a?0.00001:o/3.5,a)i.near=0.0001,i.updateProjectionMatrix()},wire(O){for(let K of m?[m,...Fo(p)]:[])K.traverse((B)=>{let X=B;if(X.isMesh){for(let q of Array.isArray(X.material)?X.material:[X.material])if("wireframe"in q)q.wireframe=O}})},lighting(O){t.toneMappingExposure=O==="bright"?1.65:O==="soft"?0.85:1.15,g.intensity=O==="soft"?0.8:2.4},clip(O){if(b?.stopAllAction(),_[O])b?.clipAction(_[O]).play()},pause(O){x=!O},dispose(){if(I("The viewport closed before measurement finished."),T=!0,S++,cancelAnimationFrame(E),U.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",d),m)br(m);for(let O of Fo(p))br(O);y.dispose(),t.dispose(),e.replaceChildren()}}}var ue=(e)=>document.getElementById(e);function k(e,t,n){let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i}function Mn(e){let t=ue("dashboard-status");t.textContent=e instanceof Error?e.message:String(e),t.hidden=!t.textContent}async function un(e,t){let n=await fetch(e,t?{method:t.method,headers:{"Content-Type":"application/json"},body:JSON.stringify(t.body)}:void 0),i=await n.json();if(!n.ok)throw Error(i.error??`Request failed (${n.status})`);return i}function Uo(e,t){let n=k("div",void 0,"empty");return n.append(k("b",e),k("p",t)),n}function Vi(e,t){try{localStorage.setItem(e,t)}catch{}}function Es(e){try{return localStorage.getItem(e)}catch{return null}}function Tn(e){return e?e.slice(0,15):"Unspecified"}function Bo(e,t){let n=k("details",void 0,"record-details");return n.append(k("summary",e),k("pre",JSON.stringify(t,null,2))),n}function ll(e,t,n,i){let r=n.lod();if(e.hidden=!r,t.hidden=!r,t.replaceChildren(),e.replaceChildren(),e.onchange=null,!r)return;e.append(...ug(r.levels).map((l,u)=>new Option(l,String(u))));let s=new Option("Mixed part levels","mixed");s.disabled=!0,e.append(s);let a=k("p","","lod-total");a.setAttribute("role","status"),t.append(a);let o=new Map;if(r.chains.length>1){let l=k("details",void 0,"lod-parts");l.append(k("summary","Per-part levels")),l.append(k("p","Choose a level for each part. The main selector sets every part to the same index.","subtle"));let u=k("div",void 0,"lod-part-fields"),d=new Set(r.chains.filter((f,h,y)=>y.findIndex((g)=>g.label===f.label)!==h).map((f)=>f.label));for(let[f,h]of r.chains.entries()){let y=d.has(h.label)?`${h.label} (part ${f+1})`:h.label,g=k("label",y,"inline-field"),m=k("select");m.setAttribute("aria-label",`${y} level of detail`),m.append(...ug(h.triangles).map((p,b)=>new Option(p,String(b)))),m.onchange=()=>{n.partLevel(h.id,Number(m.value)),c(),i?.()},o.set(h.id,m),g.append(m),u.append(g)}l.append(u),t.append(l)}function c(){let l=n.lod();if(!l)return;let u=l.levels.findIndex((d,f)=>l.chains.every((h)=>h.level===Math.min(f,h.triangles.length-1)));e.value=u<0?"mixed":String(u),a.textContent=`${l.triangles.toLocaleString()} triangles displayed`;for(let d of l.chains){let f=o.get(d.id);if(f)f.value=String(d.level)}}return e.onchange=()=>{if(e.value==="mixed")return;let l=Number(e.value);n.level(l),c(),i?.(l)},c(),{refresh:c}}var oS=/^[a-z][a-z0-9_-]{0,79}$/u,ZL=/^r_[a-z0-9_-]{1,77}$/u;function cS(e){let t=new URLSearchParams(e),n=t.get("collection"),i=t.get("asset"),r=t.get("revision");if(!n||!i||!r||!oS.test(n)||!oS.test(i)||!ZL.test(r))return;return{collection:n,assetId:i,revisionId:r}}var jM=new TextEncoder,b9=new TextDecoder,Go=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),Gg=(e,t)=>Object.hasOwn(e,t);async function BM(e){let t=await crypto.subtle.digest("SHA-256",Uint8Array.from(e));return`sha256:${Array.from(new Uint8Array(t),(n)=>n.toString(16).padStart(2,"0")).join("")}`}function y9(e){if(e.length>200||!/^[a-z0-9][a-z0-9._-]*\.kiln-metadata\.json$/i.test(e)||/^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(e))throw Error("Runtime metadata filename must be a portable sibling *.kiln-metadata.json filename")}function zM(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=12;while(n<e.length){if(n+8>e.length)throw Error("Invalid GLB chunk header");let s=t.getUint32(n,!0);if(s%4||n+8+s>e.length)throw Error("Invalid GLB chunk length");n+=8+s}let i=20+t.getUint32(12,!0),r=JSON.parse(b9.decode(e.subarray(20,i)));if(!Go(r)||!Go(r.asset)||r.asset.version!=="2.0")throw Error("Invalid glTF asset");return{json:r,jsonEnd:i}}function VM(e,t,n){let i=jM.encode(JSON.stringify(n)),r=Math.ceil(i.length/4)*4,s=new Uint8Array(20+r+e.length-t);if(s.length>ni)throw Error("Runtime export exceeds 64 MiB");s.set(e.subarray(0,20));let a=new DataView(s.buffer);return a.setUint32(8,s.length,!0),a.setUint32(12,r,!0),s.fill(32,20,20+r),s.set(i,20),s.set(e.subarray(t),20+r),s}async function x9(e,t={}){let[{deliverRuntimeThreeGlb:n},{MeshoptEncoder:i}]=await Promise.all([Promise.resolve().then(() => (PM(),NM)),Promise.resolve().then(() => (UM(),FM))]);await i.ready;let r=await n(e,i,t);if(r.glb.byteLength>ni)throw Error("Runtime export exceeds 64 MiB");return r}async function HM(e,t={}){let n=t.profile??"editable";if(n!=="editable"&&n!=="runtime")throw Error("Unknown export profile");if(t.target!==void 0&&t.target!=="three")throw Error("Unknown runtime export target");if(t.target!==void 0&&n!=="runtime")throw Error("A runtime export target requires the runtime profile");yu(e);let i=e.files["asset.glb"];if(n==="editable")return{profile:n,glb:i};let r=t.metadataFileName??"runtime.kiln-metadata.json";y9(r);for(let[p,b]of Object.entries(e.files))if(await BM(b)!==e.manifest.files[p].sha256)throw Error(`Asset integrity mismatch: ${p}`);let{json:s,jsonEnd:a}=zM(i),o=s.asset;if(Gg(o,"extras")&&!Go(o.extras))throw Error("Cannot add provenance to non-object asset extras");let c=o.extras??{};if(Gg(c,"kilnProvenanceV1"))throw Error("Asset extras already contain kilnProvenanceV1; export from the canonical revision");let l=[];if(s.scenes!==void 0&&!Array.isArray(s.scenes))throw Error("Invalid glTF scenes");for(let[p,b]of(s.scenes??[]).entries()){if(!Go(b)||!Go(b.extras)||!Gg(b.extras,"kilnReviewClipsV1"))continue;let _=b.extras.kilnReviewClipsV1;if(!Go(_)||_.version!==1&&_.version!==2||!Array.isArray(_.clips))throw Error("Unsupported scenes[].extras.kilnReviewClipsV1");l.push({index:p,kilnReviewClipsV1:_}),delete b.extras.kilnReviewClipsV1}let u={version:"kiln.runtime-metadata.v1",source:{assetId:e.manifest.assetId,revisionId:e.manifest.revisionId,glbSha256:e.manifest.files["asset.glb"].sha256,...e.manifest.files["source.kiln.js"]?{sourceSha256:e.manifest.files["source.kiln.js"].sha256}:{}},scenes:l},d=i,f=s,h=a;if(t.target==="three"){let p=await x9(VM(i,a,s),{...t.ktx2Encoder?{ktx2Encoder:t.ktx2Encoder}:{}});u.target="three",u.delivery=p.delivery,d=p.glb,{json:f,jsonEnd:h}=zM(d)}let y=jM.encode(JSON.stringify(u));if(y.length>ni)throw Error("Runtime export exceeds 64 MiB");let g=f.asset;g.extras={...g.extras??c,kilnProvenanceV1:{version:"kiln.provenance.v1",profile:"runtime",...t.target?{target:t.target}:{},metadata:{uri:r,sha256:await BM(y)}}};let m=VM(d,h,f);return{profile:n,glb:m,metadata:{name:r,bytes:y}}}var Gi=Le().regex(/^[a-z][a-z0-9_-]{0,79}$/).refine((e)=>!/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(e),"Reserved filesystem name"),$g=Le().regex(/^r_[0-9]{10}_[a-f0-9]{64}$/),KM=Le().regex(/^sha256:[a-f0-9]{64}$/),$o=Le().max(4000),WM=Le().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),GM=be({collectionId:Gi,assetId:Gi,revisionId:Gi}).strict(),$M=be({style:$o.default(""),scale:Le().max(1000).default(""),palette:at(be({role:Le().min(1).max(100),color:Le().regex(/^#[a-fA-F0-9]{6}$/)}).strict()).max(64).default([]),materialRoles:at(be({role:Le().min(1).max(100),description:$o.default(""),resourceId:WM.optional()}).strict()).max(128).default([]),conventions:at(Le().max(1000)).max(100).default([]),exceptions:at(Le().max(1000)).max(100).default([])}).strict(),_9=be({resourceId:WM,revisionId:Le().min(1).max(200),sha256:KM,role:Le().max(100).optional()}).strict(),v9=at(_9).max(512),xr={name:Le().trim().min(1).max(200),brief:Le().max(16000).default(""),design:$M.default(()=>$M.parse({})),inventory:at(be({id:Gi,name:Le().trim().min(1).max(200),kind:It(["asset","environment"]).default("asset"),brief:$o.default(""),references:at(Gi).max(64).default([]),asset:GM.optional()}).strict()).max(1000).default([]),deliveryProfiles:at(be({id:Gi,target:It(["three","godot","unity","unreal","roblox","sbox","usdz","custom"]),description:$o.default(""),performanceIntent:Le().max(1000).default(""),constraints:at(Le().max(1000)).max(100).default([])}).strict()).max(32).default([]),materialDependencies:v9.default([]),references:at(be({id:Gi,title:Le().min(1).max(200),uri:Le().min(1).max(2048),description:$o.default(""),sha256:KM.optional()}).strict()).max(256).default([]),reviews:at(be({id:Gi,inventoryId:Gi,projectRevisionId:$g,asset:GM,reviewer:Le().trim().min(1).max(200),verdict:It(["comment","changes-requested","accepted"]),notes:$o}).strict()).max(2000).default([])};function XM(e,t){let n=(a,o)=>{if(new Set(a).size!==a.length)t.addIssue({code:iu.custom,path:[o],message:"Duplicate identity"})};n(e.inventory.map((a)=>a.id),"inventory"),n(e.references.map((a)=>a.id),"references"),n(e.deliveryProfiles.map((a)=>a.id),"deliveryProfiles"),n(e.materialDependencies.map((a)=>a.resourceId),"materialDependencies"),n(e.reviews.map((a)=>a.id),"reviews"),n(e.design.palette.map((a)=>a.role),"design.palette"),n(e.design.materialRoles.map((a)=>a.role),"design.materialRoles");let i=new Set(e.references.map((a)=>a.id)),r=new Set(e.inventory.map((a)=>a.id)),s=new Set(e.materialDependencies.map((a)=>a.resourceId));for(let a of e.inventory)if(n(a.references,`inventory.${a.id}.references`),a.references.some((o)=>!i.has(o)))t.addIssue({code:iu.custom,path:["inventory"],message:"Unknown reference"});if(e.reviews.some((a)=>!r.has(a.inventoryId)))t.addIssue({code:iu.custom,path:["reviews"],message:"Unknown inventory item"});if(e.design.materialRoles.some((a)=>a.resourceId&&!s.has(a.resourceId)))t.addIssue({code:iu.custom,path:["design"],message:"Material role requires a locked resource"})}var qM=be({projectId:Gi.optional(),...xr}).strict().superRefine(XM),XK=be({name:xr.name.optional(),brief:xr.brief.removeDefault().optional(),design:xr.design.removeDefault().optional(),inventory:xr.inventory.removeDefault().optional(),deliveryProfiles:xr.deliveryProfiles.removeDefault().optional(),materialDependencies:xr.materialDependencies.removeDefault().optional(),references:xr.references.removeDefault().optional(),reviews:xr.reviews.removeDefault().optional()}).strict(),qK=be({version:$e("kiln.project.v1"),projectId:Gi,revisionId:$g,parentRevision:$g.optional(),createdAt:Le().datetime(),...xr}).strict().superRefine(XM);function JM(e){let{palette:t,materialRoles:n,conventions:i,exceptions:r}=e.design??{};return{design:{palette:t??[],materialRoles:n??[],conventions:i??[],exceptions:r??[]},inventory:e.inventory??[],deliveryProfiles:e.deliveryProfiles??[],materialDependencies:e.materialDependencies??[],references:e.references??[],reviews:e.reviews??[]}}function ZM(e,t){let n=JSON.parse(e);if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Project configuration must be a JSON object.");let i=n,r=i.design??{};if(!r||typeof r!=="object"||Array.isArray(r))throw Error("Design configuration must be a JSON object.");return qM.parse({...i,name:t.name,brief:t.brief,design:{...r,style:t.style,scale:t.scale}})}function YM(e){let t=[],n=Es("kiln.project")??"",i,r=()=>{let c=ue("project-list");c.replaceChildren();for(let _ of t){let x=k("button",void 0,_.projectId===n?"active":"");if(x.append(k("strong",_.name),k("small",`${_.inventory.length} inventory items · ${_.materialDependencies.length} resources`)),_.projectId===n)x.setAttribute("aria-current","true");x.onclick=()=>{n=_.projectId,Vi("kiln.project",n),r()},c.append(x)}let l=t.find((_)=>_.projectId===n),u=ue("project-detail");if(u.replaceChildren(),!l){u.append(Uo("A direction for what comes next.","Projects are optional. Group related assets, materials and design decisions here, or build and review standalone assets in Library and Live Review."));return}let d=k("div",void 0,"project-summary"),f=k("div");f.append(k("h2",l.name),k("p",l.brief||"Add a brief to describe what this project should deliver."));let h=k("button","Edit project","secondary");h.onclick=()=>a(l),d.append(f,h),u.append(d);let y=k("p",`${l.projectId} · ${Tn(l.revisionId)} · ${new Date(l.createdAt).toLocaleString()}`,"mono");u.append(y);let g=k("div",void 0,"project-metrics");for(let[_,x]of[[l.inventory.length,"inventory items"],[l.materialDependencies.length,"locked resources"],[l.deliveryProfiles.length,"delivery profiles"]]){let v=k("div");v.append(k("strong",String(_)),k("span",String(x))),g.append(v)}u.append(g);let m=k("div",void 0,"profile-grid");for(let[_,x]of[["Visual direction",l.design.style||"Not specified"],["Scale",l.design.scale||"Not specified"]]){let v=k("div");v.append(k("span",_,"label"),k("p",x)),m.append(v)}u.append(m);let p=k("div",void 0,"palette");for(let _ of l.design.palette){let x=k("div",void 0,"swatch"),v=document.createElementNS("http://www.w3.org/2000/svg","svg");v.setAttribute("viewBox","0 0 24 24"),v.setAttribute("aria-hidden","true");let E=document.createElementNS("http://www.w3.org/2000/svg","rect");E.setAttribute("width","24"),E.setAttribute("height","24"),E.setAttribute("fill",_.color),v.append(E);let S=k("span",_.role);S.append(k("small",_.color)),x.append(v,S),p.append(x)}if(p.childElementCount)u.append(p);for(let[_,x]of[["Conventions",l.design.conventions],["Declared exceptions",l.design.exceptions]]){if(!x.length)continue;u.append(k("h3",_));let v=k("ul",void 0,"subtle");for(let E of x)v.append(k("li",E));u.append(v)}if(u.append(k("h3","Inventory")),!l.inventory.length)u.append(k("p","No inventory yet. Add deliberate asset and environment entries in the project configuration.","subtle"));else{let _=k("div",void 0,"table-wrap"),x=k("table"),v=k("thead"),E=k("tr");for(let T of["Item","Kind","Saved revision","Review"])E.append(k("th",T));v.append(E),x.append(v);let S=k("tbody");for(let T of l.inventory){let A=k("tr"),P=k("td",T.name);P.append(k("small",T.brief));let w=k("td"),I=k("td");if(T.asset){let F=k("button",Tn(T.asset.revisionId),"secondary");F.onclick=()=>e.openAsset(T.asset),w.append(F);let N=[...l.reviews].reverse().find((D)=>D.inventoryId===T.id&&D.asset.revisionId===T.asset.revisionId&&D.asset.assetId===T.asset.assetId&&D.asset.collectionId===T.asset.collectionId);I.append(k("small",N?`${N.verdict} · ${N.reviewer}`:"Unreviewed"));let U=k("button","Record review","secondary");U.onclick=()=>o(l,T),I.append(U)}else w.textContent="Not linked",I.textContent="No saved revision";A.append(P,k("td",T.kind),w,I),S.append(A)}x.append(S),_.append(x),u.append(_)}if(l.design.materialRoles.length){u.append(k("h3","Material roles"));for(let _ of l.design.materialRoles)u.append(k("p",`${_.role}: ${_.description||"No description"}${_.resourceId?` · ${_.resourceId}`:" · No resource assigned"}`,"subtle"))}if(l.deliveryProfiles.length){u.append(k("h3","Delivery intent"));for(let _ of l.deliveryProfiles){if(u.append(k("p",`${_.target} · ${_.description||_.id}`,"subtle")),_.performanceIntent)u.append(k("p",_.performanceIntent,"subtle"));for(let x of _.constraints)u.append(k("p",x,"subtle"))}u.append(k("p","Declared targets are project intent. They do not establish consumer or performance qualification.","subtle"))}if(l.references.length){u.append(k("h3","Reference records"));for(let _ of l.references){let x=k("p",`${_.title}: ${_.uri}`,"subtle");if(_.description)x.append(k("small",` · ${_.description}`));u.append(x)}}u.append(k("h3","Project downloads"));let b=k("div",void 0,"downloads");for(let _ of["editable","runtime"]){let x=k("a",_==="editable"?"Download editable project bundle":"Download runtime project bundle"),v=new URLSearchParams({profile:_,revision:l.revisionId});x.href=`/api/projects/${encodeURIComponent(l.projectId)}/bundle?${v}`,x.download=`${l.projectId}-${_}.zip`,b.append(x)}b.append(k("p","Both downloads bind this exact project revision and its linked saved inventory. Editable includes authored source and material resources for rebuilding. Runtime is delivery-only and cannot restore editable source. Unlinked inventory entries remain plans, not bundled assets.")),u.append(b),u.append(Bo("Exact project configuration and review records",l))},s=async()=>{let c=await un("/api/projects");if(t.length===c.projects.length&&t.every((l,u)=>l.revisionId===c.projects[u]?.revisionId))return;if(t=c.projects,!t.some((l)=>l.projectId===n))n=t[0]?.projectId??"";r(),e.changed(t)};function a(c){i=c,ue("project-editor-title").textContent=c?"Edit project":"New project",ue("project-name").value=c?.name??"",ue("project-brief").value=c?.brief??"",ue("project-style").value=c?.design.style??"",ue("project-scale").value=c?.design.scale??"",ue("project-config").value=JSON.stringify(JM(c??{name:""}),null,2),ue("project-save-status").textContent="",ue("project-editor").showModal(),ue("project-name").focus()}function o(c,l){if(!l.asset)return;let u=k("dialog"),d=k("form"),f=k("div",void 0,"editor-content"),h=k("h2",`Review ${l.name}`);h.id="review-dialog-title",u.setAttribute("aria-labelledby",h.id),f.append(h,k("p","Record an assessment of this exact saved revision. This is a review annotation; structural QA and release qualification remain separate.","subtle"),k("code",`${l.asset.assetId} / ${l.asset.revisionId}`,"mono"));let y=k("input");y.required=!0,y.value=Es("kiln.reviewer")??"",y.maxLength=200;let g=k("label","Reviewer","field");g.append(y);let m=k("select");for(let[S,T]of[["comment","Comment"],["changes-requested","Changes requested"],["accepted","Visually accepted"]])m.append(new Option(T,S));let p=k("label","Assessment","field");p.append(m);let b=k("textarea");b.rows=4,b.maxLength=4000;let _=k("label","Notes","field");_.append(b);let x=k("p");x.setAttribute("role","status");let v=k("button","Save review");v.type="submit";let E=k("button","Cancel","secondary");E.type="button",E.onclick=()=>u.close(),f.append(g,p,_,x,v,E),d.append(f),u.append(d),document.body.append(u),u.addEventListener("close",()=>u.remove()),d.onsubmit=async(S)=>{S.preventDefault(),v.disabled=!0,x.textContent="Saving review…";try{await un(`/api/projects/${encodeURIComponent(c.projectId)}`,{method:"PATCH",body:{expectedRevision:c.revisionId,patch:{reviews:[...c.reviews,{id:`review_${crypto.randomUUID().replaceAll("-","")}`,inventoryId:l.id,projectRevisionId:c.revisionId,asset:l.asset,reviewer:y.value.trim(),verdict:m.value,notes:b.value}]}}}),Vi("kiln.reviewer",y.value.trim()),u.close(),await s()}catch(T){x.textContent=T instanceof Error?T.message:String(T)}finally{v.disabled=!1}},u.showModal(),y.focus()}return ue("new-project").onclick=()=>a(),ue("close-project-editor").onclick=()=>ue("project-editor").close(),ue("project-form").onsubmit=async(c)=>{c.preventDefault();let l=ue("save-project");l.disabled=!0,ue("project-save-status").textContent="Saving revision…";try{let u=ZM(ue("project-config").value,{name:ue("project-name").value,brief:ue("project-brief").value,style:ue("project-style").value,scale:ue("project-scale").value});n=(await un(i?`/api/projects/${encodeURIComponent(i.projectId)}`:"/api/projects",i?{method:"PATCH",body:{expectedRevision:i.revisionId,patch:u}}:{method:"POST",body:u})).projectId,Vi("kiln.project",n),ue("project-editor").close(),Mn("Project revision saved."),await s()}catch(u){ue("project-save-status").textContent=u instanceof Error?u.message:String(u)}finally{l.disabled=!1}},{refresh:s}}var E9="Raw map pixels · unshaded · not GPU capture evidence",Kg=/^[a-z][a-z0-9_-]{0,79}$/,Wg=/^sha256:[a-f0-9]{64}$/;function yl(e){let t=new URLSearchParams(e.startsWith("?")?e:e.slice(e.indexOf("?")+1)),n=t.get("material"),i=t.get("materialRevision");if(t.getAll("material").length!==1||t.getAll("materialRevision").length!==1||!n||!i||!Kg.test(n)||!Wg.test(i))return;return{materialId:n,revisionId:i}}function lf(e){if(!Kg.test(e.materialId)||!Wg.test(e.revisionId))throw Error("Invalid exact material selection");return`/?${new URLSearchParams({material:e.materialId,materialRevision:e.revisionId})}`}function Xg(e){if(!Kg.test(e.materialId)||!Wg.test(e.revisionId))throw Error("Invalid exact material selection");return`/api/materials/${encodeURIComponent(e.materialId)}/${encodeURIComponent(e.revisionId)}`}function QM(e){let t=Ja(e),n=Xg(t),i=t.maps.map((r)=>{let s="recipe"in r?r:void 0,a=s?.recipe?.kind==="atlas"?s.recipe:void 0;return{slot:r.slot,file:r.file,url:`${n}/${encodeURIComponent(r.file)}`,width:r.width,height:r.height,colorSpace:r.colorSpace,imageSha256:r.sha256,..."pixelHash"in r?{pixelHash:r.pixelHash}:{},..."sampler"in r?{sampler:{...r.sampler}}:{},atlas:!!a,...s?.recipe?{compilerId:s.recipe.compilerId}:{},...a?{manifestHash:a.manifest.manifestHash}:{},regions:a?a.manifest.regions.map((o)=>({name:o.name,content:{...o.content},allocation:{...o.allocation},leftPercent:o.content.x/r.width*100,topPercent:o.content.y/r.height*100,widthPercent:o.content.width/r.width*100,heightPercent:o.content.height/r.height*100})):[]}});return{materialId:t.materialId,revisionId:t.revisionId,name:t.name,fidelity:E9,maps:i}}function eR(e,t){if(!e||typeof e!=="object"||Array.isArray(e)||e.artifactGlbSha256!==t)throw Error("Retained evaluation does not identify the displayed artifact");let n=e.materialLibraryDependencies;if(n===void 0)return[];if(!Array.isArray(n)||n.length>16)throw Error("Invalid retained material dependency list");let i=new Map;for(let r of n){let s=Ja(r),a=`${s.materialId}/${s.revisionId}`,o=i.get(a);if(o&&on(o)!==on(s))throw Error("Conflicting retained material identity");i.set(a,s)}return[...i.values()]}function uf(e){let t=QM(e),n=k("section",void 0,"material-inspection");n.setAttribute("aria-label",`${t.name}: exact material maps`),n.append(k("p",`${t.materialId} · ${t.revisionId}`,"mono"),k("p",t.fidelity,"subtle"));let i=k("div",void 0,"material-inspection-controls"),r=(v,E)=>{let S=k("label",v,"inline-field");return S.append(E),i.append(S),E},s=r("Map",k("select"));for(let v of t.maps)s.append(new Option(`${v.slot}${v.atlas?" · atlas":""}`,v.slot));let a=r("Backdrop",k("select"));for(let v of["checker","light","dark"])a.append(new Option(v[0].toUpperCase()+v.slice(1),v));let o=r("Pixel zoom",k("select"));for(let v of[1,2,4])o.append(new Option(`${v}×`,String(v)));let c=k("div",void 0,"material-pixel-frame"),l=k("div",void 0,"material-pixel-sheet");c.dataset.backdrop="checker",c.tabIndex=0;let u=k("img");u.className="material-pixel-image",u.loading="lazy",u.draggable=!1;let d=k("div",void 0,"material-region-overlay"),f=k("label","Region overlays","inline-field"),h=k("input");h.type="checkbox",h.checked=!1,f.append(h),i.append(f),h.onchange=()=>{d.hidden=!h.checked},l.append(u,d),c.append(l);let y=k("p",void 0,"subtle");y.setAttribute("role","status");let g=k("dl"),m=k("div",void 0,"material-region-list"),p=k("a","Open this saved material revision");p.href=lf(t),p.target="_blank",p.rel="noopener",n.append(i,c,y,g,m,p);let b=t.maps[0],_=()=>{l.style.width=`${b.width*Number(o.value)}px`,l.style.height=`${b.height*Number(o.value)}px`},x=()=>{b=t.maps.find((E)=>E.slot===s.value)??t.maps[0],f.hidden=!b.atlas,d.hidden=!b.atlas||!h.checked,y.textContent="Loading exact saved map…",u.alt=`${t.name}: ${b.slot}${b.atlas?" atlas sheet":""}, raw unshaded pixels`,u.width=b.width,u.height=b.height,u.src=b.url,_(),g.replaceChildren();let v=(E,S)=>g.append(k("dt",E),k("dd",S));if(v("Image",`${b.width} × ${b.height} · ${b.colorSpace} · nearest pixel display`),v("Sampling declaration",b.sampler?`${b.sampler.minFilter} / ${b.sampler.magFilter} · ${b.sampler.wrapS} / ${b.sampler.wrapT}`:"Not recorded in V1"),v("PNG hash",b.imageSha256),b.pixelHash)v("Decoded RGBA hash",b.pixelHash);if(b.compilerId)v("Compiler",b.compilerId);if(b.manifestHash)v("Atlas manifest hash",b.manifestHash);if(d.replaceChildren(),m.replaceChildren(),b.atlas){m.append(k("h4","Atlas regions · top-left pixel coordinates"));for(let E of b.regions){let S=k("span",void 0,"material-region-box");S.style.left=`${E.leftPercent}%`,S.style.top=`${E.topPercent}%`,S.style.width=`${E.widthPercent}%`,S.style.height=`${E.heightPercent}%`,S.append(k("span",E.name)),S.setAttribute("aria-hidden","true"),d.append(S);let T=k("button",`${E.name}: content ${E.content.x},${E.content.y} ${E.content.width}×${E.content.height}; allocation ${E.allocation.x},${E.allocation.y} ${E.allocation.width}×${E.allocation.height}`,"secondary");T.type="button",T.setAttribute("aria-pressed","false"),T.onclick=()=>{for(let A of d.children)A.classList.remove("selected");for(let A of m.querySelectorAll("button"))A.setAttribute("aria-pressed","false");if(S.classList.add("selected"),T.setAttribute("aria-pressed","true"),!d.hidden)S.scrollIntoView({block:"nearest",inline:"nearest"})},m.append(T)}}};return u.onload=()=>{y.textContent="Raw map loaded. These pixels are not a shaded capture."},u.onerror=()=>{y.textContent=`Exact ${t.materialId} revision map unavailable. No newer revision was substituted.`},s.onchange=x,a.onchange=()=>{c.dataset.backdrop=a.value},o.onchange=_,x(),n}function tR(e){if(!e.presetId.trim())throw Error("Choose a material preset");if(!e.seed.trim())throw Error("Enter an explicit seed");let t=Number(e.seed),n=Number(e.size);if(!Number.isInteger(t)||t<-2147483648||t>2147483647)throw Error("Seed must be a signed 32-bit integer");if(![64,128,256,512].includes(n))throw Error("Choose a supported map size");if(!e.creator.trim()||!e.spdx.trim()||!e.url.trim())throw Error("Creator and license details are required");let i=new URL(e.url.trim());if(i.protocol!=="https:"&&i.protocol!=="http:")throw Error("License URL must be HTTP(S)");return{presetId:e.presetId,seed:t,size:n,creator:e.creator.trim(),license:{spdx:e.spdx.trim(),url:e.url.trim(),attribution:e.attribution}}}function nR(e){let t=[],n=[],i=[],r=ue("materials-project"),s=k("button","Create from preset");ue("materials-refresh").before(s);let a=k("dialog");a.setAttribute("aria-labelledby","material-preset-heading");let o=k("form"),c=k("div",void 0,"detail-top"),l=k("h2","Create a material resource");l.id="material-preset-heading";let u=k("button","Cancel","secondary");u.type="button",u.onclick=()=>a.close(),c.append(l,u);let d=k("div",void 0,"editor-content");d.append(k("p","Offline starting recipes with editable layers and height-derived normals. Choose an explicit seed and provenance for the resource. Map images are not shaded material previews.","subtle"));function f(w,I){let F=k("label",w,"field");return F.append(I),d.append(F),I}let h=f("Preset",k("select")),y=k("p",void 0,"subtle");d.append(y);let g=f("Seed",k("input"));g.type="number",g.step="1",g.required=!0,g.min="-2147483648",g.max="2147483647",g.value="0";let m=f("Map size",k("select"));for(let w of[64,128,256,512])m.append(new Option(`${w} × ${w}`,String(w)));m.value="256";let p=f("Creator",k("input"));p.required=!0,p.maxLength=1000;let b=f("License identifier",k("input"));b.required=!0,b.placeholder="For example, CC0-1.0";let _=f("License URL",k("input"));_.type="url",_.required=!0;let x=f("Attribution text",k("textarea"));x.rows=2;let v=k("p");v.setAttribute("role","status");let E=k("button","Create resource");E.type="submit",d.append(v,E),o.append(c,d),a.append(o),document.body.append(a);let S=()=>{let w=i.find((I)=>I.id===h.value);y.textContent=w?`${w.description} Repeat scale: ${w.physicalSizeMeters.width} × ${w.physicalSizeMeters.height} m.`:""};h.onchange=S,s.onclick=async()=>{s.disabled=!0;try{i=(await un("/api/material-presets")).presets,h.replaceChildren(...i.map((w)=>new Option(w.name,w.id))),S(),v.textContent="",E.disabled=!i.length,a.showModal()}catch(w){Mn(w)}finally{s.disabled=!1}},o.onsubmit=async(w)=>{w.preventDefault(),E.disabled=!0,v.textContent="Creating immutable material resource…";try{let I=tR({presetId:h.value,seed:g.value,size:m.value,creator:p.value,spdx:b.value,url:_.value,attribution:x.value}),F=await un("/api/materials/preset",{method:"POST",body:I});await P(),a.close(),Mn(`${F.material.name} created at ${F.material.revisionId}. Ready for standalone assets. You can also lock this revision to an optional project.`)}catch(I){v.textContent=I instanceof Error?I.message:String(I)}finally{E.disabled=!1}};let T=Xg;function A(){let w=n.find((D)=>D.projectId===r.value),I=ue("material-dependencies");if(I.replaceChildren(),w)if(I.append(k("h2",`${w.name}: locked resources`)),!w.materialDependencies.length)I.append(k("p","No materials are locked to this project yet. Select a resource revision below or configure dependencies with your agent.","subtle"));else{let D=k("table"),O=k("thead"),K=k("tr"),B=k("tbody");for(let q of["Resource / role","Exact revision","Local availability"])K.append(k("th",q));O.append(K),D.append(O);for(let q of w.materialDependencies){let le=t.find((pe)=>pe.materialId===q.resourceId&&pe.revisionId===q.revisionId),de=k("tr"),Me=k("td",q.resourceId);Me.append(k("small",q.role??w.design.materialRoles.filter((pe)=>pe.resourceId===q.resourceId).map((pe)=>pe.role).join(", "))),de.append(Me,k("td",q.revisionId,"mono"),k("td",le&&le.revisionId===q.sha256?"Exact local record available":le?"Dependency hash differs":"Not in local catalog")),B.append(de)}D.append(B);let X=k("div",void 0,"table-wrap");X.append(D),I.append(X)}let F=ue("material-list");F.replaceChildren();let N=ue("material-search").value.trim().toLowerCase(),U=t.filter((D)=>`${D.name} ${D.materialId} ${D.tags.join(" ")} ${D.sources.map((O)=>O.provider).join(" ")}`.toLowerCase().includes(N));if(ue("material-count").textContent=`${U.length} material revision${U.length===1?"":"s"}`,!U.length){F.append(Uo(N?"No matching materials":"Your material catalog starts here",N?"Try another material name, tag or provider.":"Materials added through Kiln appear here with their map roles, source records and exact revisions."));return}for(let D of U){let O=k("article",void 0,"material-card"),K=D.maps.find((L)=>L.slot==="baseColor")??D.maps[0];if(K){let L=k("img");L.src=`${T(D)}/${encodeURIComponent(K.file)}`,L.alt=`${D.name}: ${K.slot} map, not a shaded material preview`,L.loading="lazy",L.className="material-map",O.append(L,k("p",`${K.slot} map · unshaded`,"subtle"))}O.append(k("h3",D.name),k("p",D.tags.join(" · "),"subtle"));let B=k("dl"),X=(L,W)=>B.append(k("dt",L),k("dd",W));X("Revision",D.revisionId),X("Physical scale",D.physicalSizeMeters?`${D.physicalSizeMeters.width} × ${D.physicalSizeMeters.height} m`:"Not specified"),X("Tiling",D.tileable?"Declared tileable":"Not declared tileable"),X("Maps",D.maps.map((L)=>`${L.slot} ${L.width}×${L.height} (${L.colorSpace})`).join(" · ")),X("Surface factors",`Roughness ×${D.parameters.roughness} · Metalness ×${D.parameters.metalness}${D.maps.some((L)=>L.slot==="metallicRoughness")?" · multiplied by packed map channels":""}`),O.append(B);for(let L of D.sources){let W=k("p",`${L.provider} · ${L.creator} · ${L.kind}`,"subtle"),te=k("a",L.license.spdx);if(te.href=L.license.url,te.target="_blank",te.rel="noreferrer",W.append(document.createTextNode(" · "),te),L.assetUrl){let ie=k("a","Source");ie.href=L.assetUrl,ie.target="_blank",ie.rel="noreferrer",W.append(document.createTextNode(" · "),ie)}if(O.append(W),L.license.attribution)O.append(k("p",L.license.attribution,"subtle"))}let q=k("div",void 0,"material-map-links");for(let L of D.maps){let W=k("a",L.slot);W.href=`${T(D)}/${encodeURIComponent(L.file)}`,W.target="_blank",W.rel="noopener",q.append(W)}O.append(q);let le=k("details",void 0,"material-map-inspection");le.append(k("summary","Inspect maps and atlas regions"));let de=!1;le.ontoggle=()=>{if(le.open&&!de)de=!0,le.append(uf(D))};let Me=yl(location.search);if(Me?.materialId===D.materialId&&Me.revisionId===D.revisionId)le.open=!0,O.dataset.selectedMaterial="true";O.append(le);let pe=w?.materialDependencies.find((L)=>L.resourceId===D.materialId),J=k("button",pe?.revisionId===D.revisionId?"Locked to project":pe?"Use this revision":"Add to project","secondary");if(J.disabled=!w||pe?.revisionId===D.revisionId,!w)J.title="Select a project to add a material dependency";J.onclick=async()=>{if(!w)return;J.disabled=!0;try{let L=w.materialDependencies.filter((W)=>W.resourceId!==D.materialId);L.push({resourceId:D.materialId,revisionId:D.revisionId,sha256:D.revisionId,...pe?.role?{role:pe.role}:{}}),await un(`/api/projects/${encodeURIComponent(w.projectId)}`,{method:"PATCH",body:{expectedRevision:w.revisionId,patch:{materialDependencies:L}}}),Mn(`${D.name} is locked to ${w.name} at this exact revision.`),await e()}catch(L){Mn(L),J.disabled=!1}},O.append(J,Bo("Map recipes, transformations and provenance",D)),F.append(O)}}let P=async()=>{t=(await un("/api/materials")).materials,A();let w=yl(location.search);if(w&&!t.some((I)=>I.materialId===w.materialId&&I.revisionId===w.revisionId))Mn(`Exact material revision unavailable: ${w.materialId} at ${w.revisionId}. No newer revision was selected.`)};return ue("material-search").oninput=A,r.onchange=A,ue("materials-refresh").onclick=()=>void P().catch(Mn),{refresh:P,projects(w){n=w;let I=r.value;r.replaceChildren(new Option("All materials",""));for(let F of n)r.append(new Option(F.name,F.projectId));if(n.some((F)=>F.projectId===I))r.value=I;A()}}}function qg(e,t,n){return n?`${n.triangles.toLocaleString()} triangles displayed · ${t}`:`${e.triangles.toLocaleString()} triangles · ${e.meshes} meshes · ${t}`}var iR=(e,t)=>e.startedAt.localeCompare(t.startedAt)||e.operationId.localeCompare(t.operationId);function xl(e,t){let n=new Map(e.operations.map((c)=>[c.operationId,c])),i=t.map((c)=>{let l=n.get(c.operationId);return l&&l.revision>c.revision?l:c}).sort(iR),r=(c)=>i.find((l)=>l.operationId===c?.operationId)??c,s=e.following?i.at(-1):r(e.selected),a=(c)=>!!c&&!!s&&c.projectId===s.projectId&&c.workId===s.workId&&iR(c,s)<=0&&(c.sessionId===s.sessionId||e.following&&e.crossRunContinuity===!0&&!!s.workId),o=s?.artifact?s:s?i.filter((c)=>c.artifact&&a(c)).at(-1)??(a(e.displayed)?e.displayed:void 0):void 0;return{...e,operations:i,selected:s,displayed:o,pinned:r(e.pinned)}}function Jg(e,t){return xl({...e,following:!1,selected:e.operations.find((n)=>n.operationId===t)??e.selected},e.operations)}function Ws(e,t){return e?.artifact&&t?.artifact&&e.operationId===t.operationId&&e.revision===t.revision&&e.artifact.sha256===t.artifact.sha256?t:void 0}function rR(e,t,n,i){if(e.status!=="complete"||!e.artifact)throw Error("Save requires a completed operation with an artifact.");if(!Ws(e,Ws(i,n)))throw Error("The visible artifact changed or has not loaded. Close this dialog and review it before saving.");let r=t.trim();if(!r||r.length>200)throw Error("Choose an asset name of 1–200 characters.");return{path:`/api/live/${encodeURIComponent(e.operationId)}/save`,body:{expectedRevision:e.revision,name:r,collection:"project"}}}function df(e,t,n,i){let r;e.onclick=async()=>{let s=n();if(!s){t.replaceChildren(k("p","Load an artifact before measuring.","subtle"));return}e.disabled=!0,t.replaceChildren(k("p","Measuring frame pacing for 3 seconds. Keep this viewport visible and the camera steady.","subtle"));try{let a=await QA(()=>s.measure(3000),i),o=k("div",void 0,"evidence-card");o.append(k("h3","Exploratory browser measurement"),k("p","Other workloads are not controlled. This sample is not an isolated performance baseline or budget acceptance."),k("strong",`p50 ${a.frameMs.p50.toFixed(1)} ms · p95 ${a.frameMs.p95.toFixed(1)} ms`),k("p",`${a.frameMs.samples} frame intervals · ${(a.windowMs/1000).toFixed(2)} s · ${a.drawCalls} draws · ${a.triangles.toLocaleString()} rendered triangles`),k("p",`${a.geometryObjects} geometry objects · ${a.textureObjects} texture objects. These counts are not GPU memory bytes.`),k("p",`GLB parse to first frame submission: ${a.loadToFirstFrameMs?.toFixed(1)??"unavailable"} ms. Download time excluded.`),k("p",`${a.viewport.cssWidth}×${a.viewport.cssHeight} CSS pixels · DPR ${a.viewport.devicePixelRatio.toFixed(2)}. Frame pacing includes browser scheduling and vertical sync, not GPU execution timing.`));let c=Bo("Exact measurement receipt and limitations",a);if(r)URL.revokeObjectURL(r);r=URL.createObjectURL(new Blob([JSON.stringify(a,null,2)],{type:"application/json"}));let l=k("a","Download measurement receipt");l.href=r,l.download="kiln-viewer-performance.json",o.append(c,l),t.replaceChildren(o)}catch(a){t.replaceChildren(k("p",a instanceof Error?a.message:String(a),"subtle"))}finally{e.disabled=!1}}}function Zg(e,t,n,i){let r=e.inventory.find((a)=>a.id===t);if(!r&&!n)throw Error("Inventory item not found");let s=e.inventory.map((a)=>{if(a.id!==t)return a;let{asset:o,...c}=a;return n?{...c,asset:n}:c});if(!r&&n)s.push({id:t,name:i,kind:"asset",brief:"",references:[],asset:n});return{inventory:s}}async function _l(e,t,n,i){e.replaceChildren(k("h3","Project membership"));let{projects:r}=await un("/api/projects");if(!e.isConnected)return;let s=k("div");e.append(s);let a=k("p");a.setAttribute("role","status");let o=()=>_l(e,t,n,i);for(let g of r)for(let m of g.inventory){if(!m.asset||m.asset.collectionId!==t.collectionId||m.asset.assetId!==t.assetId)continue;let p=k("div",void 0,"membership-row");p.append(k("span",`${g.name} / ${m.name} · ${Tn(m.asset.revisionId)}${m.asset.revisionId===t.revisionId?" · this revision":" · another revision"}`));let b=k("button","Remove membership","secondary");b.onclick=async()=>{b.disabled=!0;try{await un(`/api/projects/${encodeURIComponent(g.projectId)}`,{method:"PATCH",body:{expectedRevision:g.revisionId,patch:Zg(g,m.id,null,n)}}),await i(),await o()}catch(_){a.textContent=`${_ instanceof Error?_.message:_} Reopen membership to load the current project.`,b.disabled=!1}},p.append(b),s.append(p)}if(!s.childElementCount)s.append(k("p","This asset is standalone. Project membership is optional.","subtle"));if(!r.length){s.append(k("p","Create a named project in Projects to organize related assets."));return}let c=k("form"),l=k("select"),u=k("select"),d=k("label","Project","field"),f=k("label","Inventory item","field");d.append(l),f.append(u);for(let g of r)l.append(new Option(g.name,g.projectId));let h=()=>{let g=r.find((p)=>p.projectId===l.value);u.replaceChildren(new Option("Add as a new inventory item",""));for(let p of g.inventory)u.append(new Option(`${p.name}${p.asset?" (replace linked revision)":""}`,p.id));let m=g.inventory.find((p)=>p.asset?.collectionId===t.collectionId&&p.asset.assetId===t.assetId);if(m)u.value=m.id};l.onchange=h,h();let y=k("button","Link this exact revision");y.type="submit",c.append(d,f,k("p","Linking preserves the saved asset and its original build provenance. Replacing a link advances only this project.","subtle"),y,a),c.onsubmit=async(g)=>{g.preventDefault(),y.disabled=!0;let m=r.find((b)=>b.projectId===l.value),p=u.value||`asset_${crypto.randomUUID().replaceAll("-","")}`;try{await un(`/api/projects/${encodeURIComponent(m.projectId)}`,{method:"PATCH",body:{expectedRevision:m.revisionId,patch:Zg(m,p,t,n)}}),await i(),await o()}catch(b){a.textContent=`${b instanceof Error?b.message:b} Reopen membership to load the current project.`,y.disabled=!1}},s.append(c)}function sR(){let e={following:!0,crossRunContinuity:!0,operations:[]},t=[],n="",i=0,r=!1,s,a=0,o,c,l,u,d,f,h,y=0,g=0,m=!1,p=!1,b,_=ue("live-project"),x=ue("live-source"),v=(L)=>x.value?`${L}${L.includes("?")?"&":"?"}source=${encodeURIComponent(x.value)}`:L,E=ue("live-run"),S=ue("live-work"),T=()=>`kiln.live.selection.${x.value}.${_.value}.${S.value}.${E.value}`,A=()=>`kiln.live.pin.${x.value}`,P=()=>t.filter((L)=>(!E.value||L.sessionId===E.value)&&(!S.value||(S.value==="ungrouped"?!L.workId:L.workId===S.value))),w=(L,W)=>{let te=ue("live-connection");te.textContent=L?"Connected":"Reconnecting",te.className=`pill ${L?"connected":"warning"}`,ue("connection-status").textContent=W};function I(){let L=S.value,W=[...new Set(t.flatMap((ce)=>ce.workId?[ce.workId]:[]))];if(S.replaceChildren(new Option("All authoring items",""),new Option("Ungrouped history","ungrouped"),...W.map((ce)=>new Option(ce,ce))),L==="ungrouped"||W.includes(L))S.value=L;let te=E.value,ie=[...new Set(t.map((ce)=>ce.sessionId))];E.replaceChildren(new Option("All runs",""));for(let ce of ie){let _e=t.find((Re)=>Re.sessionId===ce);E.append(new Option(`${_e.transport} · ${Tn(ce)}`,ce))}if(ie.includes(te))E.value=te}function F(){let L=ue("live-timeline"),W=L.scrollTop,te=L.contains(document.activeElement)?document.activeElement.dataset.operation:void 0;if(L.replaceChildren(),!e.operations.length){L.append(Uo("Nothing observed yet","Actual Kiln operations will appear here. There is no agent running state to infer."));return}for(let ie of[...e.operations].reverse()){let ce=k("button",void 0,`timeline-item ${ie.status}${e.selected?.operationId===ie.operationId?" selected":""}${ie.pinned?" pinned":""}`);ce.dataset.operation=ie.operationId;let _e=k("span",void 0,"timeline-meta");if(_e.append(k("span",ie.transport.toUpperCase()),k("time",new Date(ie.startedAt).toLocaleTimeString())),ce.append(_e,k("strong",ie.tool.replace(/^kiln_/,"")),k("small",`${ie.status} · ${ie.artifact?"artifact available":"no artifact"}`),k("small",ie.workId?`Item ${ie.workId}`:`Ungrouped · run ${Tn(ie.sessionId)}`)),ce.setAttribute("aria-label",`${ie.tool}, ${ie.status}, ${new Date(ie.startedAt).toLocaleString()}`),e.selected?.operationId===ie.operationId)ce.setAttribute("aria-current","true");if(ce.onclick=()=>{e=Jg(e,ie.operationId),Vi(T(),ie.operationId),q()},L.append(ce),te===ie.operationId)ce.focus({preventScroll:!0})}L.scrollTop=W}function N(L){let W=k("div",void 0,"evidence-card");W.append(k("h3","Capture fidelity"));let te=L.viewFidelity,ie=te&&typeof te==="object"?te:void 0;if(W.append(k("strong",ie?String(ie.delivered??"Reported"):"No capture receipt yet")),W.append(k("p",ie?.materialFaithful===!0?"Material-faithful capture reported.":ie?"Geometry evidence only. Do not use this capture to judge materials.":"The interactive viewport uses local browser lighting; it is not a recorded capture.")),ie?.degradeReason)W.append(k("p",String(ie.degradeReason)));if(ie?.rendererId)W.append(k("p",`Renderer: ${String(ie.rendererId)}`,"mono"));if(ie?.inputGlbSha256)W.append(k("p",`Capture input: ${String(ie.inputGlbSha256)}`,"mono"));if(ie)W.append(k("p",ie.exactArtifact===!0?"Receipt identifies the exact evaluated artifact.":"Capture does not claim exact artifact equivalence."));return W}function U(){let L=ue("live-evidence"),W=ue("live-downloads");L.replaceChildren(),W.replaceChildren();let te=e.displayed;if(!te?.artifact){b=void 0;return}let ie=k("div",void 0,"evidence-card");ie.append(k("h3","Selected observed artifact"),k("strong",`${(te.artifact.bytes/1024).toFixed(0)} KB GLB`),k("p",te.artifact.sha256,"mono"),k("p",`Source: ${te.programRef??"See authored source download"}`,"mono")),L.append(ie,N(te));let ce=`${x.value}/${te.operationId}/${te.artifact.sha256}`;if(b?.key!==ce){let _e=k("div",void 0,"evidence-card live-material-inspection"),Re=k("button","Inspect exact material inputs","secondary");_e.append(k("h3","Materials and atlas sheets"),k("p","Declared inputs for this displayed artifact. Raw sheets are unshaded; capture fidelity is reported separately."),Re),b={key:ce,card:_e},Re.onclick=async()=>{Re.disabled=!0;let Oe=k("p","Reading the displayed artifact evaluation…");Oe.setAttribute("role","status"),_e.append(Oe);try{let We=await un(v(`/api/live/${encodeURIComponent(te.operationId)}/evaluation.json`));if(b?.key!==ce)return;let Ye=eR(We,te.artifact.sha256);Oe.textContent=Ye.length?"Exact declared revisions. Map images require the matching record in this local material library.":"No saved material resource declarations in this artifact. Embedded textures can still be viewed in the viewport.";for(let Kt of Ye){let lt=k("details");lt.append(k("summary",`${Kt.name} · ${Kt.revisionId}`));let Dt=!1;lt.ontoggle=()=>{if(lt.open&&!Dt)Dt=!0,lt.append(uf(Kt))},_e.append(lt)}}catch(We){if(b?.key!==ce)return;Oe.textContent=`Material inspection unavailable for this exact artifact: ${We instanceof Error?We.message:String(We)}`,Re.disabled=!1}}}if(L.append(b.card),te.captures.length)for(let _e of te.captures){let Re=k("div",void 0,"evidence-card");Re.append(k("h3",_e.name));let Oe=te.viewFidelity&&typeof te.viewFidelity==="object"?te.viewFidelity:void 0;Re.append(k("p",Oe?.materialFaithful===!0?`Recorded capture · ${String(Oe.delivered??"material-faithful")}`:`Recorded capture · ${String(Oe?.delivered??"fidelity unreported")}. Materials are not verified.`,Oe?.materialFaithful===!0?"subtle":"warning"));let We=k("a"),Ye=k("img");Ye.src=_e.url,Ye.alt=`Recorded ${_e.name} for ${te.tool}`,Ye.loading="lazy",We.href=_e.url,We.target="_blank",We.rel="noopener",We.append(Ye),Re.append(We,k("p",_e.sha256,"mono")),L.append(Re)}else{let _e=k("div",void 0,"evidence-card");_e.append(k("h3","Recorded captures"),k("p",te.status==="evaluated"||te.status==="running"?"Artifact is ready. Capture work may still be in progress.":"No capture image was retained for this operation.")),L.append(_e)}for(let[_e,Re,Oe]of[[te.artifact.url,"Observed GLB","asset.glb"],[v(`/api/live/${encodeURIComponent(te.operationId)}/source.kiln.js`),"Authored source","source.kiln.js"]]){let We=k("a",Re);We.href=_e,We.download=Oe,W.append(We)}W.append(k("p","These are the observed artifact and source. Use the saved Library revision for an editable bundle with resources or a separate runtime export. A live observation is not a saved release."))}function D(){let L=Ws(e.displayed,l);ue("pin-build").disabled=!L,Me.disabled=L?.status!=="complete"}function O(){if(d&&l)ue("live-stage-label").textContent=qg(d,Tn(l.operationId),o?.lod())}function K(){if(f&&u)ue("compare-stage-label").textContent=`Pinned · ${qg(f,Tn(u.operationId),c?.lod())}`}async function B(L){if(ue("live-panel").hidden)return;let W=++y;if(!Ws(L,l))o?.cancelMeasurement("The review selection changed. Measure the loaded revision again.");if(!L?.artifact){ue("live-performance").replaceChildren(),o?.dispose(),o=void 0,l=void 0,d=void 0,ue("live-level-field").hidden=!0,ue("live-lod").replaceChildren(),ue("live-lod").hidden=!0,ue("live-stage-status").textContent="No completed artifact available for this run.",ue("live-stage-label").textContent="Current",D();return}if(l?.artifact?.sha256===L.artifact.sha256){l=L,ue("live-stage-status").textContent="",O(),D();return}ue("live-stage-status").textContent=`Loading ${Tn(L.operationId)}…${l?` Previous artifact ${Tn(l.operationId)} remains visible; Save and Pin are unavailable until the selection loads.`:""}`;try{let te=await fetch(L.artifact.url);if(!te.ok)throw Error("This retained artifact is no longer available");let ie=new Uint8Array(await te.arrayBuffer());if(W!==y)return;o??=cl(ue("live-stage"));let ce=await o.load(ie,{isCurrent:()=>W===y,onCommit:()=>{l=L},preserveView:l?.projectId===L.projectId&&(l?.sessionId===L.sessionId||e.following)});if(!ce||W!==y)return;ue("live-performance").replaceChildren(),l=L,d=ce,D();let _e=ue("live-level");if(ue("live-level-field").hidden=!ce.levels,ll(_e,ue("live-lod"),o,(Re)=>{if(Re!==void 0)c?.level(Re),h?.refresh(),K();O()}),o.wire(m),o.navigation(ue("live-navigation").value),ue("live-stage-status").textContent="",O(),c)c.setView(o.view())}catch(te){if(W!==y)return;ue("live-stage-status").textContent=`${te instanceof Error?te.message:te}.${l?` Previous artifact ${Tn(l.operationId)} remains visible. Save and Pin are unavailable for the unloaded selection.`:""}`,D()}}async function X(L){if(ue("live-panel").hidden)return;let W=++g;if(ue("compare-viewport").hidden=!L?.artifact,ue("review-viewports").classList.toggle("comparing",!!L?.artifact),!L?.artifact){c?.dispose(),c=void 0,u=void 0,f=void 0,h=void 0,ue("compare-lod").replaceChildren(),ue("compare-level-field").hidden=!0;return}if(u?.artifact?.sha256===L.artifact.sha256){u=L,K(),ue("compare-stage-status").textContent="";return}if(!u)ue("compare-stage-label").textContent="Comparison";ue("compare-stage-status").textContent=`Loading pinned ${Tn(L.operationId)}…`;try{let te=await fetch(L.artifact.url);if(!te.ok)throw Error("Pinned artifact unavailable");let ie=new Uint8Array(await te.arrayBuffer());if(W!==g)return;c??=cl(ue("compare-stage"));let ce=await c.load(ie,{preserveView:!0,isCurrent:()=>W===g,onCommit:()=>{u=L}});if(!ce||W!==g)return;if(u=L,f=ce,o)c.setView(o.view());let _e=Number(ue("live-level").value||0);c.level(Number.isFinite(_e)?_e:0),ue("compare-level-field").hidden=!ce.levels,h=ll(ue("compare-level"),ue("compare-lod"),c,K),K(),c.wire(m),c.navigation(ue("live-navigation").value),ue("compare-stage-status").textContent=""}catch(te){if(W===g)ue("compare-stage-status").textContent=`${te instanceof Error?te.message:String(te)}.${u?` Previous comparison ${Tn(u.operationId)} remains visible.`:""}`}}function q(){F();let L=e.selected,W=e.displayed,te=ue("follow-latest");te.textContent=e.following?"Following latest":"Follow latest",te.setAttribute("aria-pressed",String(e.following));let ie=ue("live-current-summary");if(ie.replaceChildren(),L){ie.append(k("h2",L.tool.replace(/^kiln_/,"")),k("p",`${L.status} · ${L.transport} · Run ${Tn(L.sessionId)} · ${new Date(L.updatedAt).toLocaleString()}`));let Re=k("div",void 0,"tags");if(L.projectId)Re.append(k("span",L.projectId,"tag"));for(let Oe of L.phases)Re.append(k("span",Oe.phase,"tag"));ie.append(Re)}else ie.append(k("h2","No build selected"),k("p","Run Kiln tools from your agent or CLI. Completed evaluations appear here automatically."));let ce=L&&"observationIssues"in L&&Array.isArray(L.observationIssues)?L.observationIssues.map(String):[],_e=[L?.error,...ce,L&&W&&L.operationId!==W.operationId?`Current ${L.status} operation has no retained artifact. Showing the last successful artifact ${Tn(W.operationId)} from run ${Tn(W.sessionId)}.`:"",L&&!e.operations.some((Re)=>Re.operationId===L.operationId)?"This selection is outside the current retained history. Its loaded view remains until you choose another build.":""].filter(Boolean);ue("live-failure").textContent=_e.join(" "),ue("live-failure").hidden=!_e.length,D(),ue("clear-pin").hidden=!e.pinned,ue("live-count").textContent=`${e.operations.length} retained operation${e.operations.length===1?"":"s"}`,ue("live-record").textContent=JSON.stringify({selected:L,displayedArtifactOperation:W?.operationId,pinnedOperation:e.pinned?.operationId},null,2),U(),B(W),X(e.pinned)}async function le(){if(r)return;r=!0;let L=i;try{let W=new URLSearchParams;if(_.value)W.set("project",_.value);if(n)W.set("cursor",n);let te=await un(v(`/api/live?${W}`));if(L!==i)return;if(a=0,w(!0,"Connected · checks every 2 seconds"),n=te.cursor,ue("live-history-note").textContent=`Up to ${te.retention.maxOperations} operations`,ue("live-history-issues").textContent=te.observationIssues?.join(" ")??"",ue("live-history-issues").hidden=!te.observationIssues?.length,!te.unchanged){if(t=te.operations,I(),e=xl(e,P()),!p){p=!0;let ie=Es(T());if(ie&&e.operations.some((_e)=>_e.operationId===ie))e=Jg(e,ie);let ce=Es(A());e.pinned=t.find((_e)=>_e.operationId===ce&&_e.pinned)??[...t].reverse().find((_e)=>_e.pinned&&_e.artifact)}q()}}catch(W){a++,w(!1,`Connection lost. Retrying; retained views remain available. ${W instanceof Error?W.message:W}`)}finally{if(r=!1,s)clearTimeout(s);s=setTimeout(()=>void le(),document.hidden?1e4:Math.min(30000,2000*2**Math.min(a,4)))}}_.onchange=()=>{i++,n="",t=[],p=!1,E.replaceChildren(new Option("All runs","")),S.value="",e={following:!0,crossRunContinuity:!0,operations:[]},q(),le()},x.onchange=()=>{_.value="",e.pinned=void 0,_.dispatchEvent(new Event("change"))},un("/api/live-sources").then(({sources:L})=>{x.replaceChildren(...L.map((W)=>new Option(W.label,W.id)))}).catch(Mn),E.onchange=()=>{e=xl({...e,selected:void 0,displayed:void 0,following:!0,crossRunContinuity:!E.value},P()),q()},S.onchange=()=>E.dispatchEvent(new Event("change")),ue("follow-latest").onclick=()=>{e=xl({...e,following:!e.following},P()),Vi(T(),e.following?"":e.selected?.operationId??""),q()},ue("live-refresh").onclick=()=>{n="",le(),q()},ue("pin-build").onclick=async()=>{let L=Ws(e.displayed,l);if(!L?.artifact)return;let W=ue("pin-build");W.disabled=!0;try{await un(v(`/api/live/${encodeURIComponent(L.operationId)}/pin`),{method:"POST",body:{pinned:!0}}),e.pinned={...L,pinned:!0},Vi(A(),L.operationId),n="",q(),le()}catch(te){Mn(te),D()}},ue("clear-pin").onclick=async()=>{if(!e.pinned)return;try{await un(v(`/api/live/${encodeURIComponent(e.pinned.operationId)}/pin`),{method:"POST",body:{pinned:!1}}),e.pinned=void 0,Vi(A(),""),n="",q(),le()}catch(L){Mn(L)}},ue("live-frame").onclick=()=>{if(o?.reset(),o)c?.setView(o.view())},ue("live-wire").onclick=()=>{m=!m,o?.wire(m),c?.wire(m),ue("live-wire").setAttribute("aria-pressed",String(m))};let de=k("button","Match comparison camera","secondary");de.onclick=()=>{if(o)c?.setView(o.view())},ue("live-frame").parentElement?.append(de);let Me=k("button","Save exact artifact");Me.disabled=!0,ue("live-frame").parentElement?.prepend(Me);let pe=k("button","Measure 3 s","secondary"),J=k("div");return J.id="live-performance",ue("live-evidence").after(J),ue("live-frame").parentElement?.append(pe),df(pe,J,()=>o,()=>Ws(e.displayed,l)?{operationId:l.operationId,revision:l.revision,glbSha256:l.artifact?.sha256}:void 0),Me.onclick=()=>{let L=Ws(e.displayed,l);if(L?.status!=="complete")return;let W=k("dialog"),te=k("form"),ie=k("div",void 0,"editor-content"),ce=k("h2","Save reviewed artifact");ce.id="save-review-title",W.setAttribute("aria-labelledby",ce.id),ie.append(ce,k("p","Save the exact source, GLB and recorded capture to Library. Then optionally link the saved revision to one or more named projects. Kiln will not evaluate the source again.","subtle"),k("p",`${L.operationId} · revision ${L.revision}`,"mono"),k("p",L.artifact.sha256,"mono"));let _e=k("input");_e.required=!0,_e.maxLength=200,_e.value="";let Re=k("label","Asset name","field");Re.append(_e);let Oe=k("p");Oe.setAttribute("role","status");let We=k("button","Save exact artifact");We.type="submit";let Ye=k("button","Cancel","secondary");Ye.type="button",Ye.onclick=()=>W.close(),ie.append(Re,Oe,We,Ye),te.append(ie),W.append(te),document.body.append(W),W.addEventListener("close",()=>W.remove()),te.onsubmit=async(Kt)=>{Kt.preventDefault(),We.disabled=!0,Oe.textContent="Saving retained bytes…";try{let lt=rR(L,_e.value,l,e.displayed),Dt=await un(v(lt.path),{method:"POST",body:lt.body});Oe.replaceChildren(k("span",`Saved ${Dt.asset.assetId} / ${Dt.asset.revisionId}. `));let Yt=k("a","Open saved revision"),tn=new URLSearchParams({collection:Dt.collection,asset:Dt.asset.assetId,revision:Dt.asset.revisionId});Yt.href=`/?${tn}`,Oe.append(Yt);let z=k("div");ie.append(z),_l(z,{collectionId:Dt.collection,assetId:Dt.asset.assetId,revisionId:Dt.asset.revisionId},Dt.asset.name,async()=>{}).catch((xn)=>{z.textContent=`Asset saved; membership unavailable: ${xn instanceof Error?xn.message:xn}. Open the saved asset in Library to link it.`}),_e.disabled=!0,We.textContent="Saved",Ye.textContent="Close"}catch(lt){Oe.textContent=lt instanceof Error?lt.message:String(lt),We.disabled=!1}},W.showModal(),_e.focus()},ue("live-navigation").onchange=(L)=>{let W=L.target.value;o?.navigation(W),c?.navigation(W),ue("live-navigation-help").textContent=W==="explore"?"Focus a viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan · Your camera stays in place between iterations."},window.addEventListener("online",()=>{n="",le()}),document.addEventListener("visibilitychange",()=>{if(!document.hidden)le()}),le(),{activate:q,projects(L){let W=_.value;_.replaceChildren(new Option("All work",""));for(let te of L)_.append(new Option(te.name,te.projectId));if(L.some((te)=>te.projectId===W))_.value=W}}}var Yg=["projects","live","library","materials"];function aR(e,t){let n=new URLSearchParams(e);if(n.has("asset")||n.has("open"))return"library";if(yl(e))return"materials";return t&&Yg.some((i)=>i===t)?t:"library"}function oR(e,t=()=>{}){let n=Yg;function i(c){if(!n.includes(c))return;for(let l of n)ue(`${l}-panel`).hidden=l!==c;for(let l of document.querySelectorAll("#workspace-nav button")){let u=l.dataset.section===c;if(l.classList.toggle("active",u),u)l.setAttribute("aria-current","page");else l.removeAttribute("aria-current")}if(Vi("kiln.section",c),c==="live")r.activate();if(c==="materials")s.refresh().catch(Mn)}for(let c of document.querySelectorAll("#workspace-nav button"))c.onclick=()=>i(c.dataset.section);ue("open-files").onclick=()=>ue("open").click();let r=sR(),s=nR(()=>a.refresh()),a=YM({changed:(c)=>{r.projects(c),s.projects(c),t(c)},openAsset:(c)=>{i("library"),e(c)}});i(aR(location.search,Es("kiln.section"))),a.refresh().catch(Mn),s.refresh().catch(Mn);let o=!1;return window.setInterval(async()=>{if(document.hidden||o||ue("project-editor").open)return;o=!0;try{await a.refresh()}catch{}finally{o=!1}},5000),{library:()=>i("library"),refreshProjects:a.refresh}}var _r=(e)=>`${e.collection}/${e.manifest.assetId}`;function cR(e,t,n){if(!n)return e;if(n==="standalone"){let r=new Set(t.flatMap((s)=>s.inventory.flatMap((a)=>a.asset?[`${a.asset.collectionId}/${a.asset.assetId}`]:[])));return e.filter((s)=>!r.has(_r(s)))}let i=new Set(t.find((r)=>r.projectId===n)?.inventory.flatMap((r)=>r.asset?[`${r.asset.collectionId}/${r.asset.assetId}/${r.asset.revisionId}`]:[])??[]);return e.filter((r)=>i.has(`${_r(r)}/${r.manifest.revisionId}`))}var Ue=(e)=>document.getElementById(e),dt=(e,t,n)=>{let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i},Al=[],Tl=[],Zs=[],Pa=[],ff="",qs,vr,An,Xs=0,lR=0,vl=!1,El=!1,Js=new Set,nb=[],uR=[],Gr=(e)=>`${e.collection}/${e.manifest.assetId}/${e.manifest.revisionId}`,eb=(e)=>{Ue("status").textContent=e},Er=(e)=>eb(e instanceof Error?e.message:String(e)),Oa=(e,t,n=nb)=>{let i=URL.createObjectURL(new Blob([Uint8Array.from(e)],{type:t}));return n.push(i),i};async function tb(e){let t=await fetch(e),n=await t.json();if(!t.ok)throw Error(n.error??"Request failed");return n}async function Qg(e,t){if(e.local){let i=e.local.files[t];if(!i)throw Error("File unavailable");return i}if(e.loose&&t==="asset.glb")return e.loose;let n=await fetch(`/files/${Gr(e)}/${t}`);if(!n.ok)throw Error((await n.json()).error??"File unavailable");return new Uint8Array(await n.arrayBuffer())}function T9(e,t){if(e.local){if(t==="editable.zip")return Oa(Hh([e.local]),"application/zip");return Oa(e.local.files[t],t.endsWith(".js")?"text/javascript":"model/gltf-binary")}if(e.loose)return Oa(e.loose,"model/gltf-binary");return`/files/${Gr(e)}/${t}?download`}function dR(e,t){try{localStorage.setItem(e,t)}catch{}}function A9(e){try{return localStorage.getItem(e)}catch{return null}}function S9(){let e=Ue("collections");e.replaceChildren();for(let t of[{id:"all",label:"All saved assets"},...Al,...Pa.length?[{id:"opened-files",label:"Opened files"}]:[]]){let n=dt("button",t.label,ff===t.id?"active":"");n.onclick=()=>void Ko(t.id).catch(Er),e.append(n)}}async function Ko(e,t=!0){if(t)hR.library();let n=++lR;ff=e,Js.clear(),S9(),eb("");let i=e==="all"?await(async()=>{let r=await tb("/api/library");if(r.errors.length)eb(r.errors.map((s)=>`${s.collectionId}: ${s.message}`).join(" · "));return r.entries.map((s)=>({collection:s.collectionId,manifest:s.manifest}))})():e==="opened-files"?Pa:(await tb(`/api/assets?collection=${encodeURIComponent(e)}`)).assets.map((r)=>({collection:e,manifest:r}));if(n!==lR)return;Zs=i,dR("kiln.collection",e),Ue("collection-title").textContent=e==="all"?"Library":e==="opened-files"?"Opened files":Al.find((r)=>r.id===e)?.label??e,Ue("collection-caption").textContent=e==="opened-files"?"Previewed in your browser. Your original files stay untouched.":"Saved assets across registered storage. Projects link exact revisions; standalone assets belong here too.",hf()}function w9(){let e=new Map;for(let t of cR(Zs,Tl,Ue("library-project").value)){let n=_r(t);e.set(n,[...e.get(n)??[],t])}return[...e.values()].map((t)=>(t.sort((n,i)=>i.manifest.createdAt.localeCompare(n.manifest.createdAt)||i.manifest.revisionId.localeCompare(n.manifest.revisionId)),t.find((n)=>n.manifest.revisionId===A9(`kiln.revision.${n.collection}.${n.manifest.assetId}`))??t[0]))}function hf(){for(let i of uR.splice(0))URL.revokeObjectURL(i);let e=Ue("cards");e.replaceChildren();let t=Ue("search").value.toLowerCase(),n=w9().filter((i)=>`${i.manifest.name} ${i.manifest.tags.join(" ")}`.toLowerCase().includes(t));if(Ue("count").textContent=`${n.length} asset${n.length===1?"":"s"}`,Ue("export-selection").disabled=!Js.size,!n.length){let i=dt("div",void 0,"empty");if(i.append(dt("b",t?"No matching assets":"Your next idea belongs here."),dt("p",t?"Try another name or tag.":"Save an asset with your agent, or open a GLB or editable bundle.")),!t)i.append(dt("code",'kiln save asset.kiln.js --name "My asset"'));e.append(i);return}for(let i of n){let r=i.manifest,s=dt("article",void 0,"card"),a=dt("button",void 0,"card-open");a.setAttribute("aria-label",`View ${r.name}`),a.onclick=()=>void Sl(i).catch(Er);let o=dt("div",void 0,"thumb");if(r.files["preview.png"]){let y=dt("img");y.loading="lazy",y.alt=r.name,y.src=i.local?Oa(i.local.files["preview.png"],"image/png",uR):`/files/${Gr(i)}/preview.png`,y.onerror=()=>{y.remove(),o.textContent="◇"},o.append(y)}else o.textContent="◇";let c=dt("div",void 0,"card-content");c.append(dt("span",r.name,"card-title"));let l=Zs.filter((y)=>_r(y)===_r(i)),u=new Set(l.map((y)=>y.manifest.parentRevision)),d=l.filter((y)=>!u.has(y.manifest.revisionId));c.append(dt("span",`${r.editable?"Editable source":"Source unavailable"} · ${l.length} revision${l.length===1?"":"s"}${d.length>1?` · ${d.length} branches`:""}`,"card-meta"));let f=dt("div",void 0,"tags");for(let y of r.tags)f.append(dt("span",y,"tag"));c.append(f),c.append(dt("small",Al.find((y)=>y.id===i.collection)?.label??i.collection,"card-meta"));let h=Tl.filter((y)=>y.inventory.some((g)=>g.asset&&g.asset.collectionId===i.collection&&g.asset.assetId===r.assetId));if(c.append(dt("small",h.length?h.map((y)=>y.name).join(" · "):"No project membership","card-meta")),a.append(o,c),s.append(a),!i.loose){let y=dt("input");y.type="checkbox",y.className="selection",y.checked=Js.has(Gr(i)),y.setAttribute("aria-label",`Select ${r.name}`),y.onchange=()=>{if(y.checked)Js.add(Gr(i));else Js.delete(Gr(i));Ue("export-selection").disabled=!Js.size},s.append(y)}e.append(s)}}async function Sl(e){let t=++Xs;qs=e,vr=void 0,An?.cancelMeasurement("The Library selection changed. Measure the loaded revision again."),Ue("library-performance").replaceChildren(),dR(`kiln.revision.${e.collection}.${e.manifest.assetId}`,e.manifest.revisionId);for(let u of nb.splice(0))URL.revokeObjectURL(u);let n=Ue("detail");if(!n.open)n.showModal();Ue("asset-name").textContent=e.manifest.name;let i=Ue("asset-membership");if(i.replaceChildren(),!e.local&&!e.loose){let u=dt("div");i.append(u),_l(u,{collectionId:e.collection,assetId:e.manifest.assetId,revisionId:e.manifest.revisionId},e.manifest.name,hR.refreshProjects).catch(Er)}let r=Ue("revisions");r.replaceChildren();for(let u of Zs.filter((d)=>_r(d)===_r(e))){let d=dt("option",`${new Date(u.manifest.createdAt).toLocaleString()} · ${u.manifest.description||u.manifest.revisionId.slice(0,10)}`);d.value=u.manifest.revisionId,d.selected=u.manifest.revisionId===e.manifest.revisionId,r.append(d)}r.onchange=()=>{let u=Zs.find((d)=>_r(d)===_r(e)&&d.manifest.revisionId===r.value);if(u)Sl(u).catch(Er)},Ue("asset-description").textContent=e.manifest.description??e.manifest.brief??(e.manifest.editable?"Source travels with this revision. Download the editable bundle to continue elsewhere.":"This GLB has no saved Kiln source. You can view and use the model.");let s=Ue("asset-attribution");s.replaceChildren();for(let u of Gv(e.manifest)){let d=dt("div");d.append(dt("span",u.label),dt("strong",u.value)),s.append(d)}s.hidden=!s.childElementCount;let a=document.getElementById("asset-material-inputs");if(!a)a=dt("section",void 0,"asset-material-inputs"),a.id="asset-material-inputs",s.after(a);a.replaceChildren();try{let u=Vh({manifest:e.manifest,files:{}});if(u.length){a.append(dt("h3","Exact material build inputs"),dt("p","Open the saved revision to inspect its raw maps, sampling declaration and atlas regions. Declared inputs do not prove every map was used.","subtle"));for(let d of u){let f=dt("a",`${d.name} · ${d.materialId}`);f.href=lf(d),f.target="_blank",f.rel="noopener",a.append(f,dt("p",d.revisionId,"mono"))}}}catch(u){a.append(dt("p",`Material revision links unavailable: ${u instanceof Error?u.message:String(u)}`,"subtle"))}Ue("provenance").textContent=e.loose?"Standalone GLB. No source or build provenance supplied.":JSON.stringify(e.manifest,null,2);let o=Ue("downloads");o.replaceChildren();for(let[u,d]of[["asset.glb","Original GLB"],...e.manifest.editable?[["source.kiln.js","Download source"]]:[],...!e.loose?[["editable.zip",e.manifest.editable?"Download editable bundle":"Download asset bundle"]]:[]]){let f=dt("a",d);f.href=T9(e,u),f.download=`${e.manifest.name.replace(/[^a-z0-9_-]/gi,"-")}${u==="asset.glb"?".glb":u==="source.kiln.js"?".kiln.js":".zip"}`,o.append(f)}if(!e.loose){let u=dt("button","Runtime GLB"),d=dt("span");d.setAttribute("role","status"),u.onclick=async()=>{u.disabled=!0,d.textContent="Preparing runtime download…";try{let f=e.local?await HM(e.local,{profile:"runtime"}):void 0,[h,y]=f?.profile==="runtime"?[f.glb,f.metadata.bytes]:await Promise.all([Qg(e,"runtime.glb"),Qg(e,"runtime.kiln-metadata.json")]);if(t!==Xs)return;let g=dt("a","Runtime GLB");g.href=Oa(h,"model/gltf-binary"),g.download="runtime.glb";let m=dt("a","Runtime metadata");m.href=Oa(y,"application/json"),m.download="runtime.kiln-metadata.json",u.replaceWith(g,m),d.textContent="Keep the companion metadata for traceability.",g.click()}catch(f){if(t!==Xs)return;d.textContent=`Runtime export unavailable: ${f instanceof Error?f.message:f}`,u.disabled=!1}},o.append(u,d),o.append(dt("p","Original GLB retains Kiln review data. Runtime GLB moves duplicate animation-review data into a companion JSON file; geometry and textures are unchanged. Keep the editable bundle for source and build records."))}Ue("refine").disabled=!e.manifest.editable,Ue("asset-stats").replaceChildren(),Ue("stage-status").textContent="Loading saved GLB…",vl=!1,El=!1,Ue("wire").setAttribute("aria-pressed","false"),Ue("play").textContent="Pause";let c=Ue("animation");c.replaceChildren(new Option("Rest pose","")),Ue("play").disabled=!0;let l=Ue("level");l.replaceChildren(),l.hidden=!0,Ue("library-lod").replaceChildren(),Ue("library-lod").hidden=!0;try{An??=cl(Ue("stage"));let u=await Qg(e,"asset.glb");if(t!==Xs)return;let d=await An.load(u,{isCurrent:()=>t===Xs,onCommit:()=>{vr=e}});if(!d||t!==Xs)return;vr=e,An.wire(!1),An.navigation(Ue("library-navigation").value),An.lighting(Ue("lighting").value),ll(l,Ue("library-lod"),An);for(let[f,h]of[...d.levels?d.levels.map((y,g)=>[y.toLocaleString(),`LOD${g} triangles`]):[[d.triangles.toLocaleString(),"triangles"]],[d.meshes,d.levels?"LOD0 meshes":"meshes"],[d.materials,d.levels?"LOD0 materials":"materials"],[`${(u.length/1024).toFixed(0)} KB`,"GLB"]]){let y=dt("div");y.append(dt("strong",String(f)),dt("span",String(h))),Ue("asset-stats").append(y)}for(let f=0;f<d.clips.length;f++)c.append(new Option(d.clips[f],String(f)));Ue("stage-status").textContent=""}catch(u){if(t===Xs)An?.dispose(),An=void 0,Ue("stage-status").textContent=`3D preview unavailable: ${u instanceof Error?u.message:u}. Downloads remain available.`}}async function fR(e){for(let t of e){if(t.bytes.length>ni)throw Error("File exceeds 64 MiB");if(t.name.toLowerCase().endsWith(".zip"))for(let n of Hv(t.bytes)){for(let[i,r]of Object.entries(n.files))if(`sha256:${Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",Uint8Array.from(r)))).map((a)=>a.toString(16).padStart(2,"0")).join("")}`!==n.manifest.files[i]?.sha256)throw Error(`Bundle integrity failure: ${i}`);if(!Pa.some((i)=>i.manifest.revisionId===n.manifest.revisionId&&i.manifest.assetId===n.manifest.assetId))Pa.push({collection:"opened-files",manifest:n.manifest,local:n})}else{let n=`a_${crypto.randomUUID().replaceAll("-","")}`;Pa.push({collection:"opened-files",loose:t.bytes,manifest:{version:"kiln.asset.v1",assetId:n,revisionId:`r_${n}`,name:t.name.replace(/\.glb$/i,""),tags:[],createdAt:new Date().toISOString(),editable:!1,files:{}}})}}await Ko("opened-files")}Ue("open").onchange=async(e)=>{try{let t=Array.from(e.target.files??[]);if(t.some((n)=>n.size>ni))throw Error("File exceeds 64 MiB");await fR(await Promise.all(t.map(async(n)=>({name:n.name,bytes:new Uint8Array(await n.arrayBuffer())}))))}catch(t){Er(t)}};Ue("refresh").onclick=()=>void Ko(ff).catch(Er);Ue("search").oninput=hf;Ue("library-project").onchange=()=>void Ko("all").catch(Er);Ue("close-detail").onclick=()=>Ue("detail").close();Ue("detail").addEventListener("close",()=>{Xs++,vr=void 0,An?.dispose(),An=void 0;for(let e of nb.splice(0))URL.revokeObjectURL(e);hf()});Ue("frame").onclick=()=>An?.reset();Ue("wire").onclick=()=>{vl=!vl,An?.wire(vl),Ue("wire").setAttribute("aria-pressed",String(vl))};Ue("lighting").onchange=(e)=>An?.lighting(e.target.value);Ue("library-navigation").onchange=(e)=>{let t=e.target.value;An?.navigation(t),Ue("library-navigation-help").textContent=t==="explore"?"Focus the viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan"};Ue("animation").onchange=(e)=>{let t=e.target.value;An?.clip(t===""?-1:Number(t)),Ue("play").disabled=t===""};Ue("play").onclick=()=>{El=!El,An?.pause(El),Ue("play").textContent=El?"Play":"Pause"};Ue("refine").onclick=async()=>{if(!qs)return;let e=qs.manifest,t=qs.local?`Import the downloaded editable bundle using kiln import <bundle.zip>. Restore asset ${e.assetId}, revision ${e.revisionId}, using kiln_assets action=restore. Read its source with kiln_source, refine it with kiln_edit, review the result, and save a child revision with kiln_save. Requested change: `:`Use kiln_assets with action=restore, collection=${qs.collection}, assetId=${e.assetId}, revisionId=${e.revisionId}. Read the returned programRef with kiln_source, refine it with kiln_edit, review the result, and save with kiln_save using assetId=${e.assetId}, parentRevision=${e.revisionId}, collection=${qs.collection}. Requested change: `;try{await navigator.clipboard.writeText(t),Ue("refine").textContent="Instructions copied"}catch{Ue("provenance").textContent=t,Ue("provenance").parentElement?.setAttribute("open","")}};Ue("export-selection").onclick=()=>{try{let e=dt("a");if(ff==="opened-files")e.href=Oa(Hh(Zs.filter((t)=>Js.has(Gr(t))).map((t)=>t.local)),"application/zip");else{let t=new URLSearchParams;for(let n of Js)t.append("revision",n);e.href=`/api/bundle?${t}`}e.download="kiln-assets.zip",e.click()}catch(e){Er(e)}};async function M9(){Al=(await tb("/api/collections")).collections;let e=cS(location.search);if(await Ko(Al.find((t)=>t.id===e?.collection)?.id??"all",!1),e){let t=Zs.find((n)=>n.collection===e.collection&&n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The requested saved revision is not available.");await Sl(t)}if(new URLSearchParams(location.search).has("open")){let t=await fetch("/api/standalone");if(!t.ok)throw Error("File unavailable");if(await fR([{name:t.headers.get("Content-Type")?.includes("zip")?"asset.zip":"asset.glb",bytes:new Uint8Array(await t.arrayBuffer())}]),Pa.length===1)await Sl(Pa[0])}}var hR=oR((e)=>{(async()=>{await Ko(e.collectionId);let t=Zs.find((n)=>n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The linked saved revision is not available in this collection.");await Sl(t)})().catch(Er)},(e)=>{Tl=e;let t=Ue("library-project"),n=t.value;t.replaceChildren(new Option("All projects and standalone",""),new Option("Standalone assets","standalone"));for(let i of Tl)t.append(new Option(i.name,i.projectId));if(n==="standalone"||Tl.some((i)=>i.projectId===n))t.value=n;hf()});df(Ue("measure-library"),Ue("library-performance"),()=>An,()=>vr&&qs&&Gr(vr)===Gr(qs)?{collection:vr.collection,assetId:vr.manifest.assetId,revisionId:vr.manifest.revisionId,glbSha256:vr.manifest.files["asset.glb"]?.sha256}:void 0);M9().catch(Er);+*/var Zt=Uint8Array,ii=Uint16Array,jh=Int32Array,yu=new Zt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),_u=new Zt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Lh=new Zt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),_v=function(e,t){var n=new ii(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new jh(n[30]);for(var i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return{b:n,r}},vv=_v(yu,2),{b:Ev,r:Fh}=vv;Ev[28]=258,Fh[258]=28;var Tv=_v(_u,0),{b:fC,r:pv}=Tv,Uh=new ii(32768);for(ht=0;ht<32768;++ht)er=(ht&43690)>>1|(ht&21845)<<1,er=(er&52428)>>2|(er&13107)<<2,er=(er&61680)>>4|(er&3855)<<4,Uh[ht]=((er&65280)>>8|(er&255)<<8)>>1;var er,ht,nr=function(e,t,n){var i=e.length,r=0,s=new ii(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var a=new ii(t);for(r=1;r<t;++r)a[r]=a[r-1]+s[r-1]<<1;var o;if(n){o=new ii(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],d=a[e[r]-1]++<<u;for(var f=d|(1<<u)-1;d<=f;++d)o[Uh[d]>>c]=l}}else{o=new ii(i);for(r=0;r<i;++r)if(e[r])o[r]=Uh[a[e[r]-1]++]>>15-e[r]}return o},es=new Zt(288);for(ht=0;ht<144;++ht)es[ht]=8;var ht;for(ht=144;ht<256;++ht)es[ht]=9;var ht;for(ht=256;ht<280;++ht)es[ht]=7;var ht;for(ht=280;ht<288;++ht)es[ht]=8;var ht,_c=new Zt(32);for(ht=0;ht<32;++ht)_c[ht]=5;var ht,hC=nr(es,9,0),pC=nr(es,9,1),mC=nr(_c,5,0),gC=nr(_c,5,1),Ph=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},Ii=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},Oh=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Hh=function(e){return(e+7)/8|0},vc=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Zt(e.subarray(t,n))};var bC=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],zn=function(e,t,n){var i=Error(t||bC[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,zn);if(!n)throw i;return i},xC=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Zt(0);var a=!n,o=a||t.i!=2,c=t.i;if(a)n=new Zt(r*3);var l=function(ce){var _e=n.length;if(ce>_e){var Re=new Zt(Math.max(_e*2,ce));Re.set(n),n=Re}},u=t.f||0,d=t.p||0,f=t.b||0,{l:h,d:b,m,n:g}=t,p=r*8;do{if(!h){u=Ii(e,d,1);var x=Ii(e,d+1,3);if(d+=3,!x){var _=Hh(d)+4,y=e[_-4]|e[_-3]<<8,v=_+y;if(v>r){if(c)zn(0);break}if(o)l(f+y);n.set(e.subarray(_,v),f),t.b=f+=y,t.p=d=v*8,t.f=u;continue}else if(x==1)h=pC,b=gC,m=9,g=5;else if(x==2){var T=Ii(e,d,31)+257,A=Ii(e,d+10,15)+4,E=T+Ii(e,d+5,31)+1;d+=14;var w=new Zt(E),P=new Zt(19);for(var S=0;S<A;++S)P[Lh[S]]=Ii(e,d+S*3,7);d+=A*3;var I=Ph(P),U=(1<<I)-1,N=nr(P,I,1);for(var S=0;S<E;){var F=N[Ii(e,d,U)];d+=F&15;var _=F>>4;if(_<16)w[S++]=_;else{var D=0,O=0;if(_==16)O=3+Ii(e,d,3),d+=2,D=w[S-1];else if(_==17)O=3+Ii(e,d,7),d+=3;else if(_==18)O=11+Ii(e,d,127),d+=7;while(O--)w[S++]=D}}var K=w.subarray(0,T),B=w.subarray(T);m=Ph(K),g=Ph(B),h=nr(K,m,1),b=nr(B,g,1)}else zn(1);if(d>p){if(c)zn(0);break}}if(o)l(f+131072);var X=(1<<m)-1,q=(1<<g)-1,le=d;for(;;le=d){var D=h[Oh(e,d)&X],de=D>>4;if(d+=D&15,d>p){if(c)zn(0);break}if(!D)zn(2);if(de<256)n[f++]=de;else if(de==256){le=d,h=null;break}else{var Me=de-254;if(de>264){var S=de-257,pe=yu[S];Me=Ii(e,d,(1<<pe)-1)+Ev[S],d+=pe}var J=b[Oh(e,d)&q],L=J>>4;if(!J)zn(3);d+=J&15;var B=fC[L];if(L>3){var pe=_u[L];B+=Oh(e,d)&(1<<pe)-1,d+=pe}if(d>p){if(c)zn(0);break}if(o)l(f+131072);var W=f+Me;if(f<B){var ne=s-B,ie=Math.min(B,W);if(ne+f<0)zn(3);for(;f<ie;++f)n[f]=i[ne+f]}for(;f<W;++f)n[f]=n[f-B]}}if(t.l=h,t.p=le,t.b=f,t.f=u,h)u=1,t.m=m,t.d=b,t.n=g}while(!u);return f!=n.length&&a?vc(n,0,f):n.subarray(0,f)},Cr=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},xc=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},kh=function(e,t){var n=[];for(var i=0;i<e.length;++i)if(e[i])n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return{t:wv,l:0};if(r==1){var a=new Zt(n[0].s+1);return a[n[0].s]=1,{t:a,l:1}}n.sort(function(v,T){return v.f-T.f}),n.push({s:-1,f:25001});var o=n[0],c=n[1],l=0,u=1,d=2;n[0]={s:-1,f:o.f+c.f,l:o,r:c};while(u!=r-1)o=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:o.f+c.f,l:o,r:c};var f=s[0].s;for(var i=1;i<r;++i)if(s[i].s>f)f=s[i].s;var h=new ii(f+1),b=Bh(n[u-1],h,0);if(b>t){var i=0,m=0,g=b-t,p=1<<g;s.sort(function(T,A){return h[A.s]-h[T.s]||T.f-A.f});for(;i<r;++i){var x=s[i].s;if(h[x]>t)m+=p-(1<<b-h[x]),h[x]=t;else break}m>>=g;while(m>0){var _=s[i].s;if(h[_]<t)m-=1<<t-h[_]++-1;else++i}for(;i>=0&&m;--i){var y=s[i].s;if(h[y]==t)--h[y],++m}b=t}return{t:new Zt(h),l:b}},Bh=function(e,t,n){return e.s==-1?Math.max(Bh(e.l,t,n+1),Bh(e.r,t,n+1)):t[e.s]=n},mv=function(e){var t=e.length;while(t&&!e[--t]);var n=new ii(++t),i=0,r=e[0],s=1,a=function(c){n[i++]=c};for(var o=1;o<=t;++o)if(e[o]==r&&o!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)a(32754);if(s>2)a(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){a(r),--s;for(;s>6;s-=6)a(8304);if(s>2)a(s-3<<5|8208),s=0}while(s--)a(r);s=1,r=e[o]}return{c:n.subarray(0,i),n:t}},yc=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},Av=function(e,t,n){var i=n.length,r=Hh(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var s=0;s<i;++s)e[r+s+4]=n[s];return(r+4+i)*8},gv=function(e,t,n,i,r,s,a,o,c,l,u){Cr(t,u++,n),++r[256];var d=kh(r,15),{t:f,l:h}=d,b=kh(s,15),{t:m,l:g}=b,p=mv(f),{c:x,n:_}=p,y=mv(m),{c:v,n:T}=y,A=new ii(19);for(var E=0;E<x.length;++E)++A[x[E]&31];for(var E=0;E<v.length;++E)++A[v[E]&31];var w=kh(A,7),{t:P,l:S}=w,I=19;for(;I>4&&!P[Lh[I-1]];--I);var U=l+5<<3,N=yc(r,es)+yc(s,_c)+a,F=yc(r,f)+yc(s,m)+a+14+3*I+yc(A,P)+2*A[16]+3*A[17]+7*A[18];if(c>=0&&U<=N&&U<=F)return Av(t,u,e.subarray(c,c+l));var D,O,K,B;if(Cr(t,u,1+(F<N)),u+=2,F<N){D=nr(f,h,0),O=f,K=nr(m,g,0),B=m;var X=nr(P,S,0);Cr(t,u,_-257),Cr(t,u+5,T-1),Cr(t,u+10,I-4),u+=14;for(var E=0;E<I;++E)Cr(t,u+3*E,P[Lh[E]]);u+=3*I;var q=[x,v];for(var le=0;le<2;++le){var de=q[le];for(var E=0;E<de.length;++E){var Me=de[E]&31;if(Cr(t,u,X[Me]),u+=P[Me],Me>15)Cr(t,u,de[E]>>5&127),u+=de[E]>>12}}}else D=hC,O=es,K=mC,B=_c;for(var E=0;E<o;++E){var pe=i[E];if(pe>255){var Me=pe>>18&31;if(xc(t,u,D[Me+257]),u+=O[Me+257],Me>7)Cr(t,u,pe>>23&31),u+=yu[Me];var J=pe&31;if(xc(t,u,K[J]),u+=B[J],J>3)xc(t,u,pe>>5&8191),u+=_u[J]}else xc(t,u,D[pe]),u+=O[pe]}return xc(t,u,D[256]),u+O[256]},yC=new jh([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),wv=new Zt(0),_C=function(e,t,n,i,r,s){var a=s.z||e.length,o=new Zt(i+a+5*(1+Math.ceil(a/7000))+r),c=o.subarray(i,o.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var d=yC[t-1],f=d>>13,h=d&8191,b=(1<<n)-1,m=s.p||new ii(32768),g=s.h||new ii(b+1),p=Math.ceil(n/3),x=2*p,_=function(Oe){return(e[Oe]^e[Oe+1]<<p^e[Oe+2]<<x)&b},y=new jh(25000),v=new ii(288),T=new ii(32),A=0,E=0,w=s.i||0,P=0,S=s.w||0,I=0;for(;w+2<a;++w){var U=_(w),N=w&32767,F=g[U];if(m[N]=F,g[U]=N,S<=w){var D=a-w;if((A>7000||P>24576)&&(D>423||!l)){u=gv(e,c,0,y,v,T,E,P,I,w-I,u),P=A=E=0,I=w;for(var O=0;O<286;++O)v[O]=0;for(var O=0;O<30;++O)T[O]=0}var K=2,B=0,X=h,q=N-F&32767;if(D>2&&U==_(w-q)){var le=Math.min(f,D)-1,de=Math.min(32767,w),Me=Math.min(258,D);while(q<=de&&--X&&N!=F){if(e[w+K]==e[w+K-q]){var pe=0;for(;pe<Me&&e[w+pe]==e[w+pe-q];++pe);if(pe>K){if(K=pe,B=q,pe>le)break;var J=Math.min(q,pe-2),L=0;for(var O=0;O<J;++O){var W=w-q+O&32767,ne=m[W],ie=W-ne&32767;if(ie>L)L=ie,F=W}}}N=F,F=m[N],q+=N-F&32767}}if(B){y[P++]=268435456|Fh[K]<<18|pv[B];var ce=Fh[K]&31,_e=pv[B]&31;E+=yu[ce]+_u[_e],++v[257+ce],++T[_e],S=w+K,++A}else y[P++]=e[w],++v[e[w]]}}for(w=Math.max(w,S);w<a;++w)y[P++]=e[w],++v[e[w]];if(u=gv(e,c,l,y,v,T,E,P,I,w-I,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=g,s.p=m,s.i=w,s.w=S}else{for(var w=s.w||0;w<a+l;w+=65535){var Re=w+65535;if(Re>=a)c[u/8|0]=l,Re=a;u=Av(c,u+1,e.subarray(w,Re))}s.i=a}return vc(o,0,i+Hh(u)+r)},vC=function(){var e=new Int32Array(256);for(var t=0;t<256;++t){var n=t,i=9;while(--i)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),EC=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=vC[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var TC=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),a=new Zt(s.length+e.length);a.set(s),a.set(e,s.length),e=a,r.w=s.length}}return _C(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},Sv=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var tr=function(e,t){return e[t]|e[t+1]<<8},Ci=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Dh=function(e,t){return Ci(e,t)+Ci(e,t+4)*4294967296},Sn=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function AC(e,t){return TC(e,t||{},0,0)}function wC(e,t){return xC(e,{i:2},t&&t.out,t&&t.dictionary)}var Mv=function(e,t,n,i){for(var r in e){var s=e[r],a=t+r,o=i;if(Array.isArray(s))o=Sv(i,s[1]),s=s[0];if(s instanceof Zt)n[a]=[s,o];else n[a+="/"]=[new Zt(0),o],Mv(s,a,n,i)}},bv=typeof TextEncoder<"u"&&new TextEncoder,zh=typeof TextDecoder<"u"&&new TextDecoder,SC=0;try{zh.decode(wv,{stream:!0}),SC=1}catch(e){}var MC=function(e){for(var t="",n=0;;){var i=e[n++],r=(i>127)+(i>223)+(i>239);if(n+r>e.length)return{s:t,r:vc(e,n-1)};if(!r)t+=String.fromCharCode(i);else if(r==3)i=((i&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|i>>10,56320|i&1023);else if(r&1)t+=String.fromCharCode((i&31)<<6|e[n++]&63);else t+=String.fromCharCode((i&15)<<12|(e[n++]&63)<<6|e[n++]&63)}};function xv(e,t){if(t){var n=new Zt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(bv)return bv.encode(e);var r=e.length,s=new Zt(e.length+(e.length>>1)),a=0,o=function(u){s[a++]=u};for(var i=0;i<r;++i){if(a+5>s.length){var c=new Zt(a+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)o(l);else if(l<2048)o(192|l>>6),o(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,o(240|l>>18),o(128|l>>12&63),o(128|l>>6&63),o(128|l&63);else o(224|l>>12),o(128|l>>6&63),o(128|l&63)}return vc(s,0,a)}function RC(e,t){if(t){var n="";for(var i=0;i<e.length;i+=16384)n+=String.fromCharCode.apply(null,e.subarray(i,i+16384));return n}else if(zh)return zh.decode(e);else{var r=MC(e),{s,r:n}=r;if(n.length)zn(8);return s}}var IC=function(e,t){return t+30+tr(e,t+26)+tr(e,t+28)},CC=function(e,t,n){var i=tr(e,t+28),r=RC(e.subarray(t+46,t+46+i),!(tr(e,t+8)&2048)),s=t+46+i,a=Ci(e,t+20),o=n&&a==4294967295?NC(e,s):[a,Ci(e,t+24),Ci(e,t+42)],c=o[0],l=o[1],u=o[2];return[tr(e,t+10),c,l,r,s+tr(e,t+30)+tr(e,t+32),u]},NC=function(e,t){for(;tr(e,t)!=1;t+=4+tr(e,t+2));return[Dh(e,t+12),Dh(e,t+4),Dh(e,t+20)]},Vh=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)zn(9);t+=i+4}return t},yv=function(e,t,n,i,r,s,a,o){var c=i.length,l=n.extra,u=o&&o.length,d=Vh(l);if(Sn(e,t,a!=null?33639248:67324752),t+=4,a!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),h=f.getFullYear()-1980;if(h<0||h>119)zn(10);if(Sn(e,t,h<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,s!=-1)Sn(e,t,n.crc),Sn(e,t+4,s<0?-s-2:s),Sn(e,t+8,n.size);if(Sn(e,t+12,c),Sn(e,t+14,d),t+=16,a!=null)Sn(e,t,u),Sn(e,t+6,n.attrs),Sn(e,t+10,a),t+=14;if(e.set(i,t),t+=c,d)for(var b in l){var m=l[b],g=m.length;Sn(e,t,+b),Sn(e,t+2,g),e.set(m,t+4),t+=4+g}if(u)e.set(o,t),t+=u;return t},PC=function(e,t,n,i,r){Sn(e,t,101010256),Sn(e,t+8,n),Sn(e,t+10,n),Sn(e,t+12,i),Sn(e,t+16,r)};function Rv(e,t){if(!t)t={};var n={},i=[];Mv(e,"",n,t);var r=0,s=0;for(var a in n){var o=n[a],c=o[0],l=o[1],u=l.level==0?0:8,d=xv(a),f=d.length,h=l.comment,b=h&&xv(h),m=b&&b.length,g=Vh(l.extra);if(f>65535)zn(11);var p=u?AC(c,l):c,x=p.length,_=EC();_.p(c),i.push(Sv(l,{size:c.length,crc:_.d(),c:p,f:d,m:b,u:f!=a.length||b&&h.length!=m,o:r,compression:u})),r+=30+f+g+x,s+=76+2*(f+g)+(m||0)+x}var y=new Zt(s+22),v=r,T=s-r;for(var A=0;A<i.length;++A){var d=i[A];yv(y,d.o,d,d.f,d.u,d.c.length);var E=30+d.f.length+Vh(d.extra);y.set(d.c,d.o+E),yv(y,r,d,d.f,d.u,d.c.length,d.o,d.m),r+=16+E+(d.m?d.m.length:0)}return PC(y,r,i.length,T,v),y}function Iv(e,t){var n={},i=e.length-22;for(;Ci(e,i)!=101010256;--i)if(!i||e.length-i>65558)zn(13);var r=tr(e,i+8);if(!r)return{};var s=Ci(e,i+16),a=s==4294967295||r==65535;if(a){var o=Ci(e,i-12);if(a=Ci(e,o)==101075792,a)r=Ci(e,o+32),s=Ci(e,o+48)}var c=t&&t.filter;for(var l=0;l<r;++l){var u=CC(e,s,a),d=u[0],f=u[1],h=u[2],b=u[3],m=u[4],g=u[5],p=IC(e,g);if(s=m,!c||c({name:b,size:f,originalSize:h,compression:d}))if(!d)n[b]=vc(e,p,p+f);else if(d==8)n[b]=wC(e.subarray(p,p+f),{out:new Zt(h)});else zn(14,"unknown compression type "+d)}return n}Ja();Cu();Pu();ku();Ja();Cu();ku();Pu();Ec();var tN=(()=>{let e=gt().int().min(0).max(16777215),t=gt().int().min(1).max(ua),n=gt().min(-36000).max(36000),i=gt().min(0).max(1),r={blend:Ct(["normal","multiply","screen","overlay"]),opacity:i};return be({schemaVersion:$e(2),size:gt().int().min(Tu).max(Eu),usage:Ct(ir),name:Le().min(1).max(80).optional(),layers:at(Ri("op",[be({op:$e("solid"),color:e,...r}).strict(),be({op:$e("checker"),colorA:e,colorB:e,squares:t,...r}).strict(),be({op:$e("stripes"),colorA:e,colorB:e,count:t,angleDeg:n,...r}).strict(),be({op:$e("gradient"),from:e,to:e,angleDeg:n,...r}).strict(),be({op:$e("bricks"),brick:e,mortar:e,rows:t,cols:t,mortarWidth:i,stagger:i,...r}).strict(),be({op:$e("noise"),colorA:e,colorB:e,scale:t,octaves:gt().int().min(1).max($h),seed:gt().int().min(-2147483648).max(2147483647),...r}).strict()])).min(1).max(Au)}).strict()})();function Wv(e,t=tN){let n=(X,q)=>gt().int().min(X).max(q),i=n(0,255),r=n(-4096,4096),s=cv([r,r]),a=cv([i,i,i,i]),o=Ct(ir),c=cC(["sha256:",Le().regex(/^[a-f0-9]{64}$/)]),l=Le().min(1).max(80),u=Le().regex(/^[a-z][a-z0-9_-]{0,79}$/),d=Le().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),f={width:n(1,4096),height:n(1,4096)},h=be({x:r,y:r,width:n(1,2048),height:n(1,2048)}).strict(),b=be({x:n(0,4096),y:n(0,4096),...f}).strict(),m=Ri("kind",[h.extend({kind:$e("rectangle")}).strict(),h.extend({kind:$e("ellipse")}).strict(),be({kind:$e("polygon"),points:at(s).min(3).max(Mu)}).strict(),be({kind:$e("line"),from:s,to:s,width:n(1,2048)}).strict()]),g=be({op:$e("paint"),shape:m,rgba:a,opacity:i}).strict(),p=be({op:$e("mask"),shape:m,alpha:i,invert:ca()}).strict(),x=be({op:$e("stamps"),shape:m,rgba:a,opacity:i,count:n(1,Ac),seed:n(0,4294967295),area:h,periodic:ca()}).strict(),_=be({op:$e("legacy-v2"),spec:e,alpha:i,opacity:i}).strict(),y=be({colors:at(n(0,16777215)).min(1).max(Ru),dither:Ct(["none","bayer4"])}).strict(),v={schemaVersion:$e(3),width:n(4,wc),height:n(4,wc),usage:o,name:l.optional(),background:a},T=be({...v,operations:at(Ri("op",[g,p,x,_.extend({spec:t})])).max(Sc),palette:y.optional()}).strict(),A=be({...v,usage:o.optional(),background:a.optional(),operations:at(Ri("op",[g.partial({opacity:!0}),p.partial({alpha:!0,invert:!0}),x.partial({opacity:!0,periodic:!0}),_.partial({alpha:!0,opacity:!0})])).max(Sc),palette:y.partial({dither:!0}).optional()}).strict(),E=be({minFilter:Ct(Xh),magFilter:Ct(qh),wrapS:Ct(Mc),wrapT:Ct(Mc)}).strict(),w=be({resourceId:u,revisionId:c,sha256:c}).strict(),P=be({kind:$e("resource"),resourceId:d,pin:w,expected:be({...f,imageSha256:c,decodedPixelHash:c}).partial().strict().optional()}).strict(),S=be({name:u,content:b,gutter:n(0,32),edgeMode:Ct(["copy-edge","mask-rgb-dilate"]),source:Ri("kind",[be({kind:$e("procedural"),spec:T}).strict(),P]),crop:b.optional(),packed:$e(!0).optional()}).strict(),I={schemaVersion:$e(1),width:n(4,Nr.edge),height:n(4,Nr.edge),usage:o,sampler:E},U=Wa(Zh.map((X)=>$e(X))),N=be({...I,regions:at(S).min(1).max(Nr.regions),pack:be({edge:U,gutter:n(0,32),algorithm:$e("maxrects")}).strict().optional()}).strict(),F=be({...I,width:I.width.optional(),height:I.height.optional(),pack:be({edge:U,gutter:n(0,32).optional(),algorithm:$e("maxrects").optional()}).strict().optional(),sampler:E.optional(),regions:at(S.extend({source:Ri("kind",[be({kind:$e("procedural"),spec:A}).strict(),P])}).partial({content:!0,gutter:!0,edgeMode:!0})).min(1).max(Nr.regions)}).strict(),D=be({materialId:u,revisionId:c,resourceId:d,slot:Ct(["baseColor","normal","metallicRoughness","emissive","occlusion"]),usage:o,colorSpace:Ct(["srgb","linear"]),...f,encodedByteLength:n(1,da.encodedSourceBytes),imageSha256:c,decodedPixelHash:c.optional()}).strict(),O={id:Le().min(1).max(1024),...f,decodedPixelHash:c},K=Ri("kind",[be({...O,kind:$e("procedural"),recipeHash:c,compilerId:$e(Za)}).strict(),be({...O,kind:$e("resource"),descriptor:D}).strict()]),B=be({version:$e("kiln.atlas-manifest.v1"),compilerId:Ct(Ou),width:I.width,height:I.height,usage:o,origin:$e("top-left"),sampler:E,specHash:c,layoutHash:c,decodedPixelHash:c,atlasPixelHash:c,sources:at(K).min(1).max(Nr.sources),regions:at(be({name:u,content:b,allocation:b,crop:b,sourceId:Le().min(1).max(1024)}).strict()).min(1).max(Nr.regions),manifestHash:c}).strict();return{portableSamplerSchema:E,proceduralTextureSpecV3Schema:A,canonicalProceduralTextureSpecV3Schema:T,textureAtlasSpecV1Schema:F,canonicalTextureAtlasSpecV1Schema:N,textureAtlasManifestV1Schema:B,materialMapPinSchema:w,verifiedPinnedMaterialMapDescriptorSchema:D}}var Nn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),qv=["baseColor","normal","metallicRoughness","emissive","occlusion"],Jv={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var eo=Le().regex(/^[a-z][a-z0-9_-]{0,79}$/),ar=Le().regex(/^sha256:[a-f0-9]{64}$/),sr=Le().min(1).max(1000),Xv=Le().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),Zv=be({id:eo,kind:Ct(["external","procedural"]),provider:sr,creator:sr,assetId:sr.optional(),assetUrl:Xv.optional(),accessedAt:Le().datetime().optional(),license:be({spdx:sr,url:Xv,attribution:Le().max(4000)}).strict(),originalFiles:at(be({name:Le().min(1).max(200),sha256:ar,bytes:gt().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),Yv=be({operation:sr,tool:sr,version:sr,parameters:gu(Le().max(100),Wa([Le().max(2000),gt().finite(),ca()])).optional()}).strict(),Pi=gt().int().min(0).max(16777215),Ic=gt().int().min(1).max(256),Qa={blend:Ct(["normal","multiply","screen","overlay"]).default("normal"),opacity:gt().min(0).max(1).default(1)},Pc=be({schemaVersion:$e(2),size:gt().int().min(4).max(1024).default(256),usage:Ct(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Le().min(1).max(80).optional(),layers:at(Ri("op",[be({op:$e("solid"),color:Pi,...Qa}).strict(),be({op:$e("checker"),colorA:Pi,colorB:Pi,squares:Ic.default(8),...Qa}).strict(),be({op:$e("stripes"),colorA:Pi,colorB:Pi,count:Ic.default(8),angleDeg:gt().min(-36000).max(36000).default(0),...Qa}).strict(),be({op:$e("gradient"),from:Pi,to:Pi,angleDeg:gt().min(-36000).max(36000).default(0),...Qa}).strict(),be({op:$e("bricks"),brick:Pi,mortar:Pi,rows:Ic.default(8),cols:Ic.default(4),mortarWidth:gt().min(0).max(1).default(0.06),stagger:gt().min(0).max(1).default(0.5),...Qa}).strict(),be({op:$e("noise"),colorA:Pi,colorB:Pi,scale:Ic.default(8),octaves:gt().int().min(1).max(6).default(3),seed:gt().int().min(-2147483648).max(2147483647).default(0),...Qa}).strict()])).min(1).max(8)}).strict(),tp=be({kind:$e("normal-from-height"),strength:gt().finite().positive().max(64)}).strict(),nN=be({compiler:$e("kiln.procedural-texture.v2"),spec:Pc,derive:tp.optional(),recipeHash:ar,pixelHash:ar,encoder:be({name:$e("sharp"),version:sr}).strict()}).strict(),Qv=be({baseColor:gt().int().min(0).max(16777215).optional(),roughness:gt().min(0).max(1).default(1),metalness:gt().min(0).max(1).default(0),emissive:gt().int().min(0).max(16777215).optional(),emissiveIntensity:gt().min(0).max(64).default(1),alphaMode:Ct(["opaque","mask","blend"]).default("opaque"),alphaCutoff:gt().min(0).max(1).default(0.5),doubleSided:ca().default(!1)}).strict(),Cc=be({schemaVersion:$e(1),materialId:eo,revisionId:ar,name:Le().min(1).max(200),tags:at(Le().min(1).max(80)).max(30),tileable:ca(),physicalSizeMeters:be({width:gt().finite().positive().max(1e5),height:gt().finite().positive().max(1e5)}).strict().optional(),parameters:Qv,sources:at(Zv).min(1).max(20),maps:at(be({slot:Ct(qv),file:Ct(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:ar,bytes:gt().int().positive().max(Nn.maxMapBytes),width:gt().int().positive().max(Nn.maxMapEdge),height:gt().int().positive().max(Nn.maxMapEdge),usage:Ct(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:Ct(["srgb","linear"]),normalConvention:$e("opengl").optional(),channelPacking:$e("r-occlusion-g-roughness-b-metallic").optional(),sourceId:eo,originalFile:Le().min(1).max(200).optional(),transforms:at(Yv).max(30),procedural:nN.optional()}).strict()).min(1).max(5)}).strict(),Qh=be({materialId:eo,name:Le().min(1).max(200),tags:at(Le().min(1).max(80)).max(30).optional(),tileable:ca(),physicalSizeMeters:be({width:gt().finite().positive().max(1e5),height:gt().finite().positive().max(1e5)}).strict().optional(),parameters:Qv.partial().optional(),sources:at(Zv).min(1).max(20),maps:at(be({slot:Ct(qv),sourceId:eo,transforms:at(Yv).max(30),normalConvention:$e("opengl").optional(),channelPacking:$e("r-occlusion-g-roughness-b-metallic").optional(),procedural:Pc,derive:tp.optional()}).strict()).min(1).max(5)}).strict(),ep=be({schemaVersion:$e(1),records:at(be({manifest:Cc,files:gu(Le().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Le().max(Math.ceil(Nn.maxMapBytes/3)*4))}).strict()).max(Nn.maxPayloadRecords)}).strict();function io(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let a=Object.getOwnPropertyDescriptor(e,s);if(!("value"in a)||!a.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");io(a.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Cn(e){io(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function iN(e){if(io(e),new TextEncoder().encode(JSON.stringify(e)).length>Nn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=Cc.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==Jv[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let a=t.sources.find((o)=>o.id===r.sourceId);if(!a)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(Cn(r.procedural.spec)!==Cn(Tc(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(a.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(a.kind!=="external"||!a.originalFiles.some((o)=>o.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>Nn.maxRecordBytes||i>Nn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var to=Wv(Pc),no={when:(e)=>!e.issues.length},eE=(e)=>e instanceof Error?e.message:String(e);function Nc(e,t,n){return(i,r)=>{try{let s=t(i);if(n&&Cn(i)!==Cn(s))r.addIssue({code:"custom",message:`${e} must be stored in canonical form.`})}catch(s){r.addIssue({code:"custom",message:eE(s)})}}}var tE=to.portableSamplerSchema.superRefine(Nc("sampler",Nu,!0),no),rN=to.canonicalProceduralTextureSpecV3Schema.superRefine(Nc("procedural V3 spec",Kh,!0),no),sN=to.canonicalTextureAtlasSpecV1Schema.superRefine(Nc("atlas spec",fa,!0),no),aN=to.textureAtlasManifestV1Schema,oN=be({resourceId:eo,revisionId:ar,sha256:ar}).strict().refine((e)=>e.sha256===e.revisionId,"Material pin hash must match revision"),cN=Ri("kind",[be({kind:$e("procedural"),compilerId:Ct(["kiln.procedural-texture.v2",Za]),spec:Wa([Pc,rN]),recipeHash:ar,pixelHash:ar,encoder:be({name:$e("sharp"),version:sr}).strict(),derive:tp.optional()}).strict(),be({kind:$e("atlas"),compilerId:Ct(Ou),spec:sN,manifest:aN,encoder:be({name:$e("sharp"),version:sr}).strict()}).strict().superRefine((e,t)=>{try{if(Rc(e.manifest,e.spec),e.compilerId!==e.manifest.compilerId)throw Error(`recipe compilerId ${e.compilerId} does not match the manifest's ${e.manifest.compilerId}.`)}catch(n){t.addIssue({code:"custom",message:`stored atlas manifest: ${eE(n)}`})}},no)]),nE=Cc.omit({schemaVersion:!0,maps:!0}).extend({schemaVersion:$e(2),dependencies:at(oN).max(16),maps:at(Cc.shape.maps.element.omit({procedural:!0}).extend({sampler:tE,pixelHash:ar,recipe:cN.optional()}).strict()).min(1).max(5)}).strict(),lN=Ri("schemaVersion",[Cc,nE]),uN=ep.extend({schemaVersion:$e(2),records:at(ep.shape.records.element.extend({manifest:lN}).strict()).max(Nn.maxPayloadRecords)}).strict(),iE=Ri("schemaVersion",[ep,uN]);function rE(e){return e.schemaVersion===1?[]:e.dependencies.map((t)=>({...t}))}var dN=Qh.extend({schemaVersion:$e(2),maps:at(Qh.shape.maps.element.omit({procedural:!0}).extend({sampler:tE,procedural:Wa([Pc,to.proceduralTextureSpecV3Schema.superRefine(Nc("procedural V3 spec",Kh,!1),no)]).optional(),atlas:to.textureAtlasSpecV1Schema.superRefine(Nc("atlas spec",fa,!1),no).optional()}).strict().refine((e)=>e.procedural!==void 0!==(e.atlas!==void 0),"Supply exactly one procedural or atlas recipe")).min(1).max(5)}).strict(),Sj=Wa([Qh,dN]);function ro(e){if(io(e),new TextEncoder().encode(JSON.stringify(e)).length>Nn.maxManifestBytes)throw Error("Material manifest exceeds size limit");if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Invalid material manifest");if(e.schemaVersion===1)return iN(e);let t=nE.parse(e);if(new Set(t.sources.map((a)=>a.id)).size!==t.sources.length||new Set(t.maps.map((a)=>a.slot)).size!==t.maps.length)throw Error("Duplicate material source or slot");let n=0,i=0,r=new Map;for(let a of t.maps){let o=t.sources.find((l)=>l.id===a.sourceId);if(!o||a.file!==`${a.slot}.png`||a.usage!==Jv[a.slot]||a.colorSpace!==(a.slot==="baseColor"||a.slot==="emissive"?"srgb":"linear")||a.slot==="normal"!==(a.normalConvention==="opengl")||a.slot==="metallicRoughness"!==(a.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map source/usage/convention mismatch");let c=a.recipe;if(c){if(o.kind!=="procedural"||a.originalFile)throw Error("Procedural/atlas map source convention mismatch");if(c.kind==="procedural"){let l=c.spec;if(l.schemaVersion===3){if(c.compilerId!==Za||l.width!==a.width||l.height!==a.height)throw Error("V3 compiler/dimensions mismatch")}else if(c.compilerId!=="kiln.procedural-texture.v2"||l.size!==a.width||a.width!==a.height||Cn(l)!==Cn(Tc(l)))throw Error("V2 compiler/canonical recipe dimensions mismatch");if(l.usage!==a.usage||c.pixelHash!==a.pixelHash||c.derive&&a.slot!=="normal")throw Error("Procedural recipe pixel/usage mismatch")}else{if(Rc(c.manifest,c.spec),c.spec.width!==a.width||c.spec.height!==a.height||c.spec.usage!==a.usage||Cn(c.spec.sampler)!==Cn(a.sampler)||c.manifest.decodedPixelHash!==a.pixelHash)throw Error("Atlas recipe map mismatch");for(let l of c.spec.regions)if(l.source.kind==="resource"){let u=l.source.pin;r.set(`${u.resourceId}/${u.revisionId}`,u)}}}else if(o.kind!=="external"||!o.originalFiles.some((l)=>l.name===a.originalFile))throw Error("External material source original file missing");n+=a.bytes,i+=a.width*a.height}let s=t.dependencies.map((a)=>`${a.resourceId}/${a.revisionId}`);if(new Set(s).size!==s.length||s.length!==r.size||s.some((a)=>!r.has(a)))throw Error("Material dependency pin inventory mismatch");if(n>Nn.maxRecordBytes||i>Nn.maxRecordPixels)throw Error("Material record exceeds byte/pixel budget");return structuredClone(t)}var Kn=67108864,np=Le().regex(/^[a-z][a-z0-9_-]{0,79}$/),fN=Le().regex(/^sha256:[a-f0-9]{64}$/),sE=be({version:$e("kiln.asset.v1"),assetId:np,revisionId:np,parentRevision:np.optional(),name:Le().min(1).max(200),tags:at(Le().max(80)).max(30),createdAt:Le().datetime(),description:Le().max(4000).optional(),brief:Le().max(8000).optional(),attribution:be({model:Le().max(200).optional(),harness:Le().max(200).optional(),author:Le().max(200).optional()}).optional(),editable:ca(),files:gu(Le(),be({sha256:fN,bytes:gt().int().nonnegative().max(Kn)})),build:be({engine:Le(),options:gu(Le(),oa()),warnings:at(Le()),integration:oa().optional(),qa:oa().optional(),dependencies:at(oa()).optional(),rebuild:Ct(["engine-required","external-dependencies-required"])}).optional(),preview:be({fidelity:oa().optional(),error:Le().optional(),backdrop:Ct(fv).optional()}).optional()}),Oc="materials.kiln.json",aE=25165824;function kc(e){let t=new Map;for(let n of e.manifest.build?.dependencies??[]){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Invalid saved asset dependency");let i=n;if(i.kind!=="kiln.material.v1"&&i.kind!=="kiln.material.v2"){if(i.delivery==="runtime")throw Error("Unsupported runtime dependency");if(i.delivery!=="embedded")throw Error("Unsupported saved asset dependency");continue}if(i.delivery!=="runtime")throw Error("Invalid saved material dependency");let r=ro(i.manifest);if(i.kind!==`kiln.material.v${r.schemaVersion}`)throw Error("Saved material dependency kind/version mismatch");let s=`${r.materialId}/${r.revisionId}`,a=t.get(s);if(a&&Cn(a)!==Cn(r))throw Error("Conflicting saved material dependency manifests");if(t.set(s,r),t.size>Nn.maxPayloadRecords)throw Error("Saved asset material dependency count exceeds limit")}return[...t.values()]}function oE(e,t=!1){let n=kc(e),i=new Map(n.map((d)=>[`${d.materialId}/${d.revisionId}`,Cn(d)]));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}io(e.materialResources);let r=iE.parse(e.materialResources),s=0,a=0,o=new Map;for(let d of r.records){let f=ro(d.manifest),h=`${d.manifest.materialId}/${d.manifest.revisionId}`;if(o.has(h)||i.has(h)&&i.get(h)!==Cn(f))throw Error("Asset material closure mismatch");if(o.set(h,f),Object.keys(d.files).length!==d.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let b of d.manifest.maps){if(d.files[b.file]?.length!==Math.ceil(b.bytes/3)*4)throw Error("Asset material map size mismatch");s+=b.bytes,a+=b.width*b.height}}if(s>Nn.maxPayloadBytes||a>Nn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits");let c=new Set,l=new Set,u=(d)=>{if(l.has(d))throw Error("Asset material closure contains a cycle");if(c.has(d))return;let f=o.get(d);if(!f)throw Error("Asset material closure incomplete");l.add(d);for(let h of rE(f))u(`${h.resourceId}/${h.revisionId}`);l.delete(d),c.add(d)};for(let d of i.keys())u(d);if(c.size!==o.size)throw Error("Asset material closure has unrelated records")}var hN=new Set(["asset.glb","source.kiln.js","preview.png"]);function Du(e){let t=sE.parse(e.manifest),n=Object.keys(e.files);if(n.length!==Object.keys(t.files).length||!n.includes("asset.glb"))throw Error("Asset file inventory mismatch");let i=0;for(let r of n){if(!hN.has(r)||!t.files[r]||t.files[r].bytes!==e.files[r].length)throw Error("Invalid asset file inventory");i+=e.files[r].length}if(i>Kn||t.editable!==n.includes("source.kiln.js"))throw Error("Invalid asset size or source inventory");if((e.files["source.kiln.js"]?.length??0)>1048576)throw Error("Source exceeds 1 MiB");ip(e.files["asset.glb"]),oE(e)}function ip(e){if(e.length<20||e.length>Kn)throw Error("Invalid GLB size");let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.length||t.getUint32(16,!0)!==1313821514)throw Error("Invalid GLB header");let n=20+t.getUint32(12,!0);if(n>e.length)throw Error("Invalid GLB JSON length");let i=JSON.parse(new TextDecoder().decode(e.subarray(20,n)));for(let r of[...i.buffers??[],...i.images??[]])if(r.uri&&!String(r.uri).startsWith("data:"))throw Error("GLB must embed its resources")}function rp(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){Du(i),oE(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,a]of Object.entries(i.files))t[r+s]=a;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>aE)throw Error("Asset material payload exceeds byte limit");t[r+Oc]=s}}for(let i of Object.values(t))n+=i.length;if(n>Kn)throw Error("Bundle exceeds 64 MiB");return Rv(t,{level:0})}function cE(e){if(e.length>Kn+1048576)throw Error("Bundle exceeds 64 MiB");let t=0,n=0,i=Iv(e,{filter:(a)=>{if(t+=a.originalSize,n++,t>Kn||n>500||a.name.endsWith(`/${Oc}`)&&a.originalSize>aE||!/^[a-z][a-z0-9_-]{0,79}\/[a-z][a-z0-9_-]{0,79}\/(manifest\.json|asset\.glb|source\.kiln\.js|preview\.png|materials\.kiln\.json)$/.test(a.name))throw Error("Unsafe or oversized asset bundle");return!0}}),r=[],s=new Set;for(let[a,o]of Object.entries(i)){if(!a.endsWith("/manifest.json"))continue;if(o.length>1048576)throw Error("Manifest exceeds 1 MiB");let c=sE.parse(JSON.parse(new TextDecoder().decode(o))),l=`${c.assetId}/${c.revisionId}/`;if(a!==`${l}manifest.json`)throw Error("Bundle identity mismatch");let u={manifest:c,files:{}};s.add(a);for(let d of Object.keys(c.files)){if(!i[l+d])throw Error("Bundle file missing");u.files[d]=i[l+d],s.add(l+d)}if(i[l+Oc])u.materialResources=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(i[l+Oc])),s.add(l+Oc);Du(u),r.push(u)}if(!r.length||s.size!==Object.keys(i).length)throw Error("Incomplete asset bundle");return r}function lE(e){let t=e.attribution;if(!t)return[];return[t.model?{label:"Model",value:t.model}:null,t.harness?{label:"Harness",value:t.harness}:null,t.author?{label:"Author",value:t.author}:null].filter((n)=>n!==null)}ji();ji();var DA={type:"change"},ug={type:"start"},FA={type:"end"},$d=new ms,LA=new yi,o8=Math.cos(70*Yc.DEG2RAD),gn=new j,qn=2*Math.PI,Ot={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},lg=0.000001;class dg extends zd{constructor(e,t=null){super(e,t);if(this.state=Ot.NONE,this.target=new j,this.cursor=new j,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:us.ROTATE,MIDDLE:us.DOLLY,RIGHT:us.PAN},this.touches={ONE:ds.ROTATE,TWO:ds.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new j,this._lastQuaternion=new ln,this._lastTargetPosition=new j,this._quat=new ln().setFromUnitVectors(e.up,new j(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new fl,this._sphericalDelta=new fl,this._scale=1,this._panOffset=new j,this._rotateStart=new Ke,this._rotateEnd=new Ke,this._rotateDelta=new Ke,this._panStart=new Ke,this._panEnd=new Ke,this._panDelta=new Ke,this._dollyStart=new Ke,this._dollyEnd=new Ke,this._dollyDelta=new Ke,this._dollyDirection=new j,this._mouse=new Ke,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=l8.bind(this),this._onPointerDown=c8.bind(this),this._onPointerUp=u8.bind(this),this._onContextMenu=b8.bind(this),this._onMouseWheel=h8.bind(this),this._onKeyDown=p8.bind(this),this._onTouchStart=m8.bind(this),this._onTouchMove=g8.bind(this),this._onMouseDown=d8.bind(this),this._onMouseMove=f8.bind(this),this._interceptControlDown=x8.bind(this),this._interceptControlUp=y8.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=Ot.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(DA),this.update(),this.state=Ot.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(gn.copy(t).sub(this.target),gn.applyQuaternion(this._quat),this._spherical.setFromVector3(gn),this.autoRotate&&this.state===Ot.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=qn;else if(n>Math.PI)n-=qn;if(i<-Math.PI)i+=qn;else if(i>Math.PI)i-=qn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(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);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(gn.setFromSpherical(this._spherical),gn.applyQuaternion(this._quatInverse),t.copy(this.target).add(gn),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);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let a=gn.length();s=this._clampDistance(a*this._scale);let o=a-s;this.object.position.addScaledVector(this._dollyDirection,o),this.object.updateMatrixWorld(),r=!!o}else if(this.object.isOrthographicCamera){let a=new j(this._mouse.x,this._mouse.y,0);a.unproject(this.object);let o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=o!==this.object.zoom;let c=new j(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),s=gn.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if($d.origin.copy(this.object.position),$d.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot($d.direction))<o8)this.object.lookAt(this.target);else LA.setFromNormalAndCoplanarPoint(this.object.up,this.target),$d.intersectPlane(LA,this.target)}else if(this.object.isOrthographicCamera){let s=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom)this.object.updateProjectionMatrix(),r=!0}if(this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>lg||8*(1-this._lastQuaternion.dot(this.object.quaternion))>lg||this._lastTargetPosition.distanceToSquared(this.target)>lg)return this.dispatchEvent(DA),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(e){if(e!==null)return qn/60*this.autoRotateSpeed*e;else return qn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){gn.setFromMatrixColumn(t,0),gn.multiplyScalar(-e),this._panOffset.add(gn)}_panUp(e,t){if(this.screenSpacePanning===!0)gn.setFromMatrixColumn(t,1);else gn.setFromMatrixColumn(t,0),gn.crossVectors(this.object.up,gn);gn.multiplyScalar(e),this._panOffset.add(gn)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;gn.copy(i).sub(this.target);let r=gn.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:a}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(qn*this._rotateDelta.x/t.clientHeight),this._rotateUp(qn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){if(this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){if(this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0)this._dollyIn(this._getZoomScale(e.deltaY));else if(e.deltaY>0)this._dollyOut(this._getZoomScale(e.deltaY));this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(qn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);t=!0;break;case this.keys.BOTTOM:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(-qn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);t=!0;break;case this.keys.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(qn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);t=!0;break;case this.keys.RIGHT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(-qn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);t=!0;break}if(t)e.preventDefault(),this.update()}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enablePan)this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enableRotate)this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=0.5*(e.pageX+n.x),r=0.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(qn*this._rotateDelta.x/t.clientHeight),this._rotateUp(qn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,a=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,a)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Ke,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function c8(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function l8(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function u8(e){switch(this._removePointer(e),this._pointers.length){case 0:if(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(FA),this.state=Ot.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function d8(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case us.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=Ot.DOLLY;break;case us.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=Ot.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=Ot.ROTATE}break;case us.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=Ot.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=Ot.PAN}break;default:this.state=Ot.NONE}if(this.state!==Ot.NONE)this.dispatchEvent(ug)}function f8(e){switch(this.state){case Ot.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case Ot.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case Ot.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function h8(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==Ot.NONE)return;e.preventDefault(),this.dispatchEvent(ug),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(FA)}function p8(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function m8(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case ds.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=Ot.TOUCH_ROTATE;break;case ds.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=Ot.TOUCH_PAN;break;default:this.state=Ot.NONE}break;case 2:switch(this.touches.TWO){case ds.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=Ot.TOUCH_DOLLY_PAN;break;case ds.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=Ot.TOUCH_DOLLY_ROTATE;break;default:this.state=Ot.NONE}break;default:this.state=Ot.NONE}if(this.state!==Ot.NONE)this.dispatchEvent(ug)}function g8(e){switch(this._trackPointer(e),this.state){case Ot.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case Ot.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case Ot.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case Ot.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=Ot.NONE}}function b8(e){if(this.enabled===!1)return;e.preventDefault()}function x8(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function y8(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}ji();class fg extends Po{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new bs;e.deleteAttribute("uv");let t=new zr({side:kn}),n=new zr,i=new Uo(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new jt(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new ko(e,n,6),a=new Dt;a.position.set(-10.906,2.009,1.846),a.rotation.set(0,-0.195,0),a.scale.set(2.328,7.905,4.651),a.updateMatrix(),s.setMatrixAt(0,a.matrix),a.position.set(-5.607,-0.754,-0.758),a.rotation.set(0,0.994,0),a.scale.set(1.97,1.534,3.955),a.updateMatrix(),s.setMatrixAt(1,a.matrix),a.position.set(6.167,0.857,7.803),a.rotation.set(0,0.561,0),a.scale.set(3.927,6.285,3.687),a.updateMatrix(),s.setMatrixAt(2,a.matrix),a.position.set(-2.017,0.018,6.124),a.rotation.set(0,0.333,0),a.scale.set(2.002,4.566,2.064),a.updateMatrix(),s.setMatrixAt(3,a.matrix),a.position.set(2.291,-0.756,-2.621),a.rotation.set(0,-0.286,0),a.scale.set(1.546,1.552,1.496),a.updateMatrix(),s.setMatrixAt(4,a.matrix),a.position.set(-2.193,-0.369,-5.547),a.rotation.set(0,0.516,0),a.scale.set(3.875,3.487,2.986),a.updateMatrix(),s.setMatrixAt(5,a.matrix),this.add(s);let o=new jt(e,Ho(50));o.position.set(-16.116,14.37,8.208),o.scale.set(0.1,2.428,2.739),this.add(o);let c=new jt(e,Ho(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new jt(e,Ho(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new jt(e,Ho(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let d=new jt(e,Ho(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,0.1),this.add(d);let f=new jt(e,Ho(100));f.position.set(0,20,0),f.scale.set(1,0.1,1),this.add(f)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function Ho(e){return new Pd({color:0,emissive:16777215,emissiveIntensity:e})}ji();ji();ji();function hg(e,t){if(t===Am)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===No||t===Zc){let n=e.getIndex();if(n===null){let s=[],a=e.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)s.push(o);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===No)for(let s=1;s<=i;s++)r.push(n.getX(0)),r.push(n.getX(s)),r.push(n.getX(s+1));else for(let s=0;s<i;s++)if(s%2===0)r.push(n.getX(s)),r.push(n.getX(s+1)),r.push(n.getX(s+2));else r.push(n.getX(s+2)),r.push(n.getX(s+1)),r.push(n.getX(s));if(r.length/3!==i)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(r),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function UA(e){let t=new Map,n=new Map,i=e.clone();return BA(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,a=t.get(r),o=a.skeleton.bones;s.skeleton=a.skeleton.clone(),s.bindMatrix.copy(a.bindMatrix),s.skeleton.bones=o.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function BA(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)BA(e.children[i],t.children[i],n)}class _g extends jr{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new WA(t)}),this.register(function(t){return new XA(t)}),this.register(function(t){return new iw(t)}),this.register(function(t){return new rw(t)}),this.register(function(t){return new sw(t)}),this.register(function(t){return new JA(t)}),this.register(function(t){return new ZA(t)}),this.register(function(t){return new YA(t)}),this.register(function(t){return new QA(t)}),this.register(function(t){return new KA(t)}),this.register(function(t){return new ew(t)}),this.register(function(t){return new qA(t)}),this.register(function(t){return new nw(t)}),this.register(function(t){return new tw(t)}),this.register(function(t){return new GA(t)}),this.register(function(t){return new bg(t,ut.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new bg(t,ut.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new aw(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=Es.extractUrlBase(e);s=Es.resolveURL(c,this.path)}else s=Es.extractUrlBase(e);this.manager.itemStart(e);let a=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},o=new ul(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},a)}catch(l){a(l)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){if(this.pluginCallbacks.indexOf(e)===-1)this.pluginCallbacks.push(e);return this}unregister(e){if(this.pluginCallbacks.indexOf(e)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1);return this}parse(e,t,n,i){let r,s={},a={},o=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===ow){try{s[ut.KHR_BINARY_GLTF]=new cw(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[ut.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new hw(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");a[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],d=r.extensionsRequired||[];switch(u){case ut.KHR_MATERIALS_UNLIT:s[u]=new $A;break;case ut.KHR_DRACO_MESH_COMPRESSION:s[u]=new lw(r,this.dracoLoader);break;case ut.KHR_TEXTURE_TRANSFORM:s[u]=new uw;break;case ut.KHR_MESH_QUANTIZATION:s[u]=new dw;break;default:if(d.indexOf(u)>=0&&a[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function _8(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function sn(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var ut={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class GA{constructor(e){this.parser=e,this.name=ut.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,o=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new qe(16777215);if(o.color!==void 0)l.setRGB(o.color[0],o.color[1],o.color[2],oi);let u=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new Bo(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Uo(l),c.distance=u;break;case"spot":c=new Fd(l),c.distance=u,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}if(c.position.set(0,0,0),xr(c,o),o.intensity!==void 0)c.intensity=o.intensity;return c.name=t.createUniqueName(o.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;if(a===void 0)return null;return this._loadLight(a).then(function(o){return n._getNodeRef(t.cache,a,o)})}}class $A{constructor(){this.name=ut.KHR_MATERIALS_UNLIT}getMaterialType(){return mr}extendParams(e,t,n){let i=[];e.color=new qe(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],oi),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,ps))}return Promise.all(i)}}class KA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class WA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return sn(this.parser,e,this.name)!==null?ui:null}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ke(r,r)}}return Promise.all(i)}}class XA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_DISPERSION}getMaterialType(e){return sn(this.parser,e,this.name)!==null?ui:null}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class qA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return sn(this.parser,e,this.name)!==null?ui:null}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class JA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_SHEEN}getMaterialType(e){return sn(this.parser,e,this.name)!==null?ui:null}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new qe(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],oi)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,ps));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class ZA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return sn(this.parser,e,this.name)!==null?ui:null}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class YA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_VOLUME}getMaterialType(e){return sn(this.parser,e,this.name)!==null?ui:null}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new qe().setRGB(r[0],r[1],r[2],oi),Promise.all(i)}}class QA{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_IOR}getMaterialType(e){return sn(this.parser,e,this.name)!==null?ui:null}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class ew{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_SPECULAR}getMaterialType(e){return sn(this.parser,e,this.name)!==null?ui:null}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new qe().setRGB(r[0],r[1],r[2],oi),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,ps));return Promise.all(i)}}class tw{constructor(e){this.parser=e,this.name=ut.EXT_MATERIALS_BUMP}getMaterialType(e){return sn(this.parser,e,this.name)!==null?ui:null}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class nw{constructor(e){this.parser=e,this.name=ut.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return sn(this.parser,e,this.name)!==null?ui:null}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class iw{constructor(e){this.parser=e,this.name=ut.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class rw{constructor(e){this.parser=e,this.name=ut.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],a=i.images[s.source],o=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);if(c!==null)o=c}return n.loadTextureImage(e,s.source,o)}}class sw{constructor(e){this.parser=e,this.name=ut.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],a=i.images[s.source],o=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);if(c!==null)o=c}return n.loadTextureImage(e,s.source,o)}}class bg{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(a){let o=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,d=new Uint8Array(a,o,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,d,i.mode,i.filter).then(function(f){return f.buffer});else return s.ready.then(function(){let f=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(f),l,u,d,i.mode,i.filter),f})})}else return null}}class aw{constructor(e){this.name=ut.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==Ti.TRIANGLES&&c.mode!==Ti.TRIANGLE_STRIP&&c.mode!==Ti.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,a=[],o={};for(let c in s)a.push(this.parser.getDependency("accessor",s[c]).then((l)=>(o[c]=l,o[c])));if(a.length<1)return null;return a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],d=c[0].count,f=[];for(let h of u){let b=new Qe,m=new j,g=new ln,p=new j(1,1,1),x=new ko(h.geometry,h.material,d);for(let y=0;y<d;y++){if(o.TRANSLATION)m.fromBufferAttribute(o.TRANSLATION,y);if(o.ROTATION)g.fromBufferAttribute(o.ROTATION,y);if(o.SCALE)p.fromBufferAttribute(o.SCALE,y);x.setMatrixAt(y,b.compose(m,g,p))}let _=null;for(let y in o)if(y==="_COLOR_0"){let v=o[y];x.instanceColor=new ls(v.array,v.itemSize,v.normalized)}else if(y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"){if(_===null){let T=x.geometry;_=new Dn,_.name=T.name;for(let A in T.attributes)_.setAttribute(A,T.attributes[A]);for(let A in T.morphAttributes)_.morphAttributes[A]=T.morphAttributes[A];if(T.index!==null)_.setIndex(T.index);_.morphTargetsRelative=T.morphTargetsRelative;for(let A of T.groups)_.addGroup(A.start,A.count,A.materialIndex);if(T.boundingBox!==null)_.boundingBox=T.boundingBox.clone();if(T.boundingSphere!==null)_.boundingSphere=T.boundingSphere.clone();_.drawRange.start=T.drawRange.start,_.drawRange.count=T.drawRange.count,_.userData=Object.assign({},T.userData),x.geometry=_}let v=o[y];_.setAttribute(y,new ls(v.array,v.itemSize,v.normalized))}Dt.prototype.copy.call(x,h),this.parser.assignFinalMaterial(x),f.push(x)}if(l.isGroup)return l.clear(),l.add(...f),l;return f[0]})}}var ow="glTF",xl=12,zA={JSON:1313821514,BIN:5130562};class cw{constructor(e){this.name=ut.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,xl),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==ow)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-xl,r=new DataView(e,xl),s=0;while(s<i){let a=r.getUint32(s,!0);s+=4;let o=r.getUint32(s,!0);if(s+=4,o===zA.JSON){let c=new Uint8Array(e,xl+s,a);this.content=n.decode(c)}else if(o===zA.BIN){let c=xl+s;this.body=e.slice(c,c+a)}s+=a}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class lw{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ut.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,a={},o={},c={};for(let l in s){let u=xg[l]||l.toLowerCase();a[u]=s[l]}for(let l in e.attributes){let u=xg[l]||l.toLowerCase();if(s[l]!==void 0){let d=n.accessors[e.attributes[l]],f=Go[d.componentType];c[u]=f.name,o[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,d){i.decodeDracoFile(l,function(f){for(let h in f.attributes){let b=f.attributes[h],m=o[h];if(m!==void 0)b.normalized=m}u(f)},a,c,oi,d)})})}}class uw{constructor(){this.name=ut.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class dw{constructor(){this.name=ut.KHR_MESH_QUANTIZATION}}class vg extends Vr{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,l=i-t,u=(n-t)/l,d=u*u,f=d*u,h=e*c,b=h-c,m=-2*f+3*d,g=f-d,p=1-m,x=g-d+u;for(let _=0;_!==a;_++){let y=s[b+_+a],v=s[b+_+o]*l,T=s[h+_+a],A=s[h+_]*l;r[_]=p*y+x*v+m*T+g*A}return r}}var v8=new ln;class fw extends vg{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return v8.fromArray(r).normalize().toArray(r),r}}var Ti={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Go={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},VA={9728:Bi,9729:En,9984:hd,9985:Io,9986:_a,9987:fr},jA={33071:Ro,33648:fd,10497:Mo},pg={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},xg={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Ts={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},E8={CUBICSPLINE:void 0,LINEAR:_d,STEP:Tm},mg={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function T8(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new zr({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:fs});return e.DefaultMaterial}function Ca(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function xr(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function A8(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let d=t[l];if(d.POSITION!==void 0)i=!0;if(d.NORMAL!==void 0)r=!0;if(d.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let a=[],o=[],c=[];for(let l=0,u=t.length;l<u;l++){let d=t[l];if(i){let f=d.POSITION!==void 0?n.getDependency("accessor",d.POSITION):e.attributes.position;a.push(f)}if(r){let f=d.NORMAL!==void 0?n.getDependency("accessor",d.NORMAL):e.attributes.normal;o.push(f)}if(s){let f=d.COLOR_0!==void 0?n.getDependency("accessor",d.COLOR_0):e.attributes.color;c.push(f)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c)]).then(function(l){let u=l[0],d=l[1],f=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=d;if(s)e.morphAttributes.color=f;return e.morphTargetsRelative=!0,e})}function w8(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++)e.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function S8(e){let t,n=e.extensions&&e.extensions[ut.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+gg(n.attributes);else t=e.indices+":"+gg(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+gg(e.targets[i]);return t}function gg(e){let t="",n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function yg(e){switch(e){case Int8Array:return 0.007874015748031496;case Uint8Array:return 0.00392156862745098;case Int16Array:return 0.00003051850947599719;case Uint16Array:return 0.000015259021896696422;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function M8(e){if(e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0)return"image/webp";if(e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var R8=new Qe;class hw{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new _8,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let o=a.match(/Version\/(\d+)/);i=n&&o?parseInt(o[1],10):-1,r=a.indexOf("Firefox")>-1,s=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new Lo(this.options.manager);else this.textureLoader=new Ud(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ul(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let a={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return Ca(r,a,i),xr(a,i),Promise.all(n._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(let o of a.scenes)o.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let a=0,o=s.length;a<o;a++)e[s[a]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,a)=>{let o=this.associations.get(s);if(o!=null)this.associations.set(a,o);for(let[c,l]of s.children.entries())r(l,a.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[ut.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(Es.resolveURL(t.uri,i.path),r,void 0,function(){s(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let s=pg[i.type],a=Go[i.componentType],o=i.normalized===!0,c=new a(i.count*s);return Promise.resolve(new vn(c,s,o))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let a=s[0],o=pg[i.type],c=Go[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*o,d=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,h=i.normalized===!0,b,m;if(f&&f!==u){let g=Math.floor(d/f),p="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+g+":"+i.count,x=t.cache.get(p);if(!x)b=new c(a,g*f,i.count*f/l),x=new tl(b,f/l),t.cache.add(p,x);m=new Oo(x,o,d%f/l,h)}else{if(a===null)b=new c(i.count*o);else b=new c(a,d,i.count*o);m=new vn(b,o,h)}if(i.sparse!==void 0){let g=pg.SCALAR,p=Go[i.sparse.indices.componentType],x=i.sparse.indices.byteOffset||0,_=i.sparse.values.byteOffset||0,y=new p(s[1],x,i.sparse.count*g),v=new c(s[2],_,i.sparse.count*o);if(a!==null)m=new vn(m.array.slice(),m.itemSize,m.normalized);m.normalized=!1;for(let T=0,A=y.length;T<A;T++){let E=y[T];if(m.setX(E,v[T*o]),o>=2)m.setY(E,v[T*o+1]);if(o>=3)m.setZ(E,v[T*o+2]);if(o>=4)m.setW(E,v[T*o+3]);if(o>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=h}return m})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],a=this.textureLoader;if(s.uri){let o=n.manager.getHandler(s.uri);if(o!==null)a=o}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],a=r.images[t],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||a.name||"",l.name===""&&typeof a.uri==="string"&&a.uri.startsWith("data:image/")===!1)l.name=a.uri;let d=(r.samplers||{})[s.sampler]||{};return l.magFilter=VA[d.magFilter]||En,l.minFilter=VA[d.minFilter]||fr,l.wrapS=jA[d.wrapS]||Mo,l.wrapT=jA[d.wrapT]||Mo,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Bi&&l.minFilter!==En,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],a=self.URL||self.webkitURL,o=s.uri||"",c=!1;if(s.bufferView!==void 0)o=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let d=new Blob([u],{type:s.mimeType});return o=a.createObjectURL(d),o});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(o).then(function(u){return new Promise(function(d,f){let h=d;if(t.isImageBitmapLoader===!0)h=function(b){let m=new en(b);m.needsUpdate=!0,d(m)};t.load(Es.resolveURL(u,r.path),h,void 0,f)})}).then(function(u){if(c===!0)a.revokeObjectURL(o);return xr(u,s),u.userData.mimeType=s.mimeType||M8(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[ut.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[ut.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let o=r.associations.get(s);s=r.extensions[ut.KHR_TEXTURE_TRANSFORM].extendTexture(s,a),r.associations.set(s,o)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+n.uuid,o=this.cache.get(a);if(!o)o=new ol,Xn.prototype.copy.call(o,n),o.color.copy(n.color),o.map=n.map,o.sizeAttenuation=!1,this.cache.add(a,o);n=o}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,o=this.cache.get(a);if(!o)o=new al,Xn.prototype.copy.call(o,n),o.color.copy(n.color),o.map=n.map,this.cache.add(a,o);n=o}if(i||r||s){let a="ClonedMaterial:"+n.uuid+":";if(i)a+="derivative-tangents:";if(r)a+="vertex-colors:";if(s)a+="flat-shading:";let o=this.cache.get(a);if(!o){if(o=n.clone(),r)o.vertexColors=!0;if(s)o.flatShading=!0;if(i){if(o.normalScale)o.normalScale.y*=-1;if(o.clearcoatNormalScale)o.clearcoatNormalScale.y*=-1}this.cache.add(a,o),this.associations.set(o,this.associations.get(n))}n=o}e.material=n}getMaterialType(){return zr}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,a={},o=r.extensions||{},c=[];if(o[ut.KHR_MATERIALS_UNLIT]){let u=i[ut.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(a,r,t))}else{let u=r.pbrMetallicRoughness||{};if(a.color=new qe(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){let d=u.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],oi),a.opacity=d[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(a,"map",u.baseColorTexture,ps));if(a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}if(r.doubleSided===!0)a.side=vi;let l=r.alphaMode||mg.OPAQUE;if(l===mg.BLEND)a.transparent=!0,a.depthWrite=!1;else if(a.transparent=!1,l===mg.MASK)a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==mr){if(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Ke(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;a.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==mr){if(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)a.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==mr){let u=r.emissiveFactor;a.emissive=new qe().setRGB(u[0],u[1],u[2],oi)}if(r.emissiveTexture!==void 0&&s!==mr)c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,ps));return Promise.all(c).then(function(){let u=new s(a);if(r.name)u.name=r.name;if(xr(u,r),t.associations.set(u,{materials:e}),r.extensions)Ca(i,u,r);return u})}createUniqueName(e){let t=Tt.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(a){return n[ut.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(o){return HA(o,a,t)})}let s=[];for(let a=0,o=e.length;a<o;a++){let c=e[a],l=S8(c),u=i[l];if(u)s.push(u.promise);else{let d;if(c.extensions&&c.extensions[ut.KHR_DRACO_MESH_COMPRESSION])d=r(c);else d=HA(new Dn,c,t);if(c.mode===Ti.TRIANGLE_STRIP)d=d.then((f)=>hg(f,Zc));else if(c.mode===Ti.TRIANGLE_FAN)d=d.then((f)=>hg(f,No));i[l]={primitive:c,promise:d},s.push(d)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,a=[];for(let o=0,c=s.length;o<c;o++){let l=s[o].material===void 0?T8(this.cache):this.getDependency("material",s[o].material);a.push(l)}return a.push(t.loadGeometries(s)),Promise.all(a).then(async function(o){let c=o.slice(0,o.length-1),l=o[o.length-1],u=[];for(let f=0,h=l.length;f<h;f++){let b=l[f],m=s[f],g,p=c[f];if(m.mode===Ti.TRIANGLES||m.mode===Ti.TRIANGLE_STRIP||m.mode===Ti.TRIANGLE_FAN||m.mode===void 0){let x=r.isSkinnedMesh===!0,_=b.hasAttribute("skinIndex")&&b.hasAttribute("skinWeight");if(x&&_===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(g=x&&_?new Md(b,p):new jt(b,p),g.isSkinnedMesh===!0)g.normalizeSkinWeights()}else if(m.mode===Ti.LINES)g=new Rd(b,p);else if(m.mode===Ti.LINE_STRIP)g=new gs(b,p);else if(m.mode===Ti.LINE_LOOP)g=new Id(b,p);else if(m.mode===Ti.POINTS)g=new Do(b,p);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);if(Object.keys(g.geometry.morphAttributes).length>0)w8(g,r);if(g.name=t.createUniqueName(r.name||"mesh_"+e),xr(g,r),m.extensions)Ca(i,g,m);t.assignFinalMaterial(g),u.push(g)}for(let f=0,h=u.length;f<h;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1){if(r.extensions)Ca(i,u[0],r);return u[0]}let d=new cr;if(r.extensions)Ca(i,d,r);t.associations.set(d,{meshes:e});for(let f=0,h=u.length;f<h;f++)d.add(u[f]);return d})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new fn(Yc.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new Ra(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return xr(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,a=[],o=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){a.push(u);let d=new Qe;if(r!==null)d.fromArray(r.array,c*16);o.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new rl(a,o)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],a=[],o=[],c=[],l=[];for(let u=0,d=i.channels.length;u<d;u++){let f=i.channels[u],h=i.samplers[f.sampler],b=f.target,m=b.node,g=i.parameters!==void 0?i.parameters[h.input]:h.input,p=i.parameters!==void 0?i.parameters[h.output]:h.output;if(b.node===void 0)continue;s.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",g)),o.push(this.getDependency("accessor",p)),c.push(h),l.push(b)}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(l)]).then(function(u){let d=u[0],f=u[1],h=u[2],b=u[3],m=u[4],g=[];for(let x=0,_=d.length;x<_;x++){let y=d[x],v=f[x],T=h[x],A=b[x],E=m[x];if(y===void 0)continue;if(y.updateMatrix)y.updateMatrix();let w=n._createAnimationTracks(y,v,T,A,E);if(w)for(let P=0;P<w.length;P++)g.push(w[P])}let p=new To(r,void 0,g);return xr(p,i),p})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(a){if(!a.isMesh)return;for(let o=0,c=i.weights.length;o<c;o++)a.morphTargetInfluences[o]=i.weights[o]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],a=i.children||[];for(let c=0,l=a.length;c<l;c++)s.push(n.getDependency("node",a[c]));let o=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),o]).then(function(c){let l=c[0],u=c[1],d=c[2];if(d!==null)l.traverse(function(f){if(!f.isSkinnedMesh)return;f.bind(d,R8)});for(let f=0,h=u.length;f<h;f++)l.add(u[f]);if(l.userData.pivot!==void 0&&u.length>0){let f=l.userData.pivot,h=u[0];l.pivot=new j().fromArray(f),l.position.x-=f[0],l.position.y-=f[1],l.position.z-=f[2],h.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",a=[],o=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(o)a.push(o);if(r.camera!==void 0)a.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let l;if(r.isBone===!0)l=new nl;else if(c.length>1)l=new cr;else if(c.length===1)l=c[0];else l=new Dt;if(l!==c[0])for(let u=0,d=c.length;u<d;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(xr(l,r),r.extensions)Ca(n,l,r);if(r.matrix!==void 0){let u=new Qe;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new cr;if(n.name)r.name=i.createUniqueName(n.name);if(xr(r,n),n.extensions)Ca(t,r,n);let s=n.nodes||[],a=[];for(let o=0,c=s.length;o<c;o++)a.push(i.getDependency("node",s[o]));return Promise.all(a).then(function(o){for(let l=0,u=o.length;l<u;l++){let d=o[l];if(d.parent!==null)r.add(UA(d));else r.add(d)}let c=(l)=>{let u=new Map;for(let[d,f]of i.associations)if(d instanceof Xn||d instanceof en)u.set(d,f);return l.traverse((d)=>{let f=i.associations.get(d);if(f!=null)u.set(d,f)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],a=e.name?e.name:e.uuid,o=[];function c(f){if(f.morphTargetInfluences)o.push(f.name?f.name:f.uuid)}if(Ts[r.path]===Ts.weights){if(c(e),e.isGroup)e.children.forEach(c)}else o.push(a);let l;switch(Ts[r.path]){case Ts.weights:l=ys;break;case Ts.rotation:l=_s;break;case Ts.translation:case Ts.scale:l=Ma;break;default:switch(n.itemSize){case 1:l=ys;break;case 2:case 3:default:l=Ma;break}break}let u=i.interpolation!==void 0?E8[i.interpolation]:_d,d=this._getArrayFromAccessor(n);for(let f=0,h=o.length;f<h;f++){let b=new l(o[f]+"."+Ts[r.path],t.array,d,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(b);s.push(b)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=yg(t.constructor),i=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof _s?fw:vg)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function I8(e,t,n){let i=t.attributes,r=new hn;if(i.POSITION!==void 0){let o=n.json.accessors[i.POSITION],{min:c,max:l}=o;if(c!==void 0&&l!==void 0){if(r.set(new j(c[0],c[1],c[2]),new j(l[0],l[1],l[2])),o.normalized){let u=yg(Go[o.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let o=new j,c=new j;for(let l=0,u=s.length;l<u;l++){let d=s[l];if(d.POSITION!==void 0){let f=n.json.accessors[d.POSITION],{min:h,max:b}=f;if(h!==void 0&&b!==void 0){if(c.setX(Math.max(Math.abs(h[0]),Math.abs(b[0]))),c.setY(Math.max(Math.abs(h[1]),Math.abs(b[1]))),c.setZ(Math.max(Math.abs(h[2]),Math.abs(b[2]))),f.normalized){let m=yg(Go[f.componentType]);c.multiplyScalar(m)}o.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(o)}e.boundingBox=r;let a=new li;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=a}function HA(e,t,n){let i=t.attributes,r=[];function s(a,o){return n.getDependency("accessor",a).then(function(c){e.setAttribute(o,c)})}for(let a in i){let o=xg[a]||a.toLowerCase();if(o in e.attributes)continue;r.push(s(i[a],o))}if(t.indices!==void 0&&!e.index){let a=n.getDependency("accessor",t.indices).then(function(o){e.setIndex(o)});r.push(a)}if(ot.workingColorSpace!==oi&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ot.workingColorSpace}" not supported.`);return xr(e,t),I8(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?A8(e,t.targets,n):e})}function yr(e){let t=new Set,n=new Set,i=new Set;e.traverse((r)=>{let s=r;if(!s.isMesh)return;t.add(s.geometry);for(let a of Array.isArray(s.material)?s.material:[s.material]){n.add(a);for(let o of Object.values(a))if(o instanceof en)i.add(o)}});for(let r of[...t,...n,...i])r.dispose()}async function pw(e){ip(e);let t=new ll,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new Lo(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new _g(t);i.register((s)=>({name:"KILN_embedded_images",async beforeRoot(){for(let a of s.json.images??[]){if(a.bufferView===void 0)continue;let o=new Uint8Array(await s.getDependency("bufferView",a.bufferView)),c="";for(let l=0;l<o.length;l+=8192)c+=String.fromCharCode(...o.subarray(l,l+8192));if(!/^image\/(png|jpeg|webp|avif)$/.test(a.mimeType??""))throw Error("Unsupported embedded image type");a.uri=`data:${a.mimeType};base64,${btoa(c)}`,delete a.bufferView}}}));let r=await i.parseAsync(Uint8Array.from(e).buffer,"");if(n){for(let s of r.scenes)yr(s);throw Error("An embedded texture could not be decoded.")}return Object.assign(r,{assertTexturesLoaded(){if(n)throw Error("An embedded texture could not be decoded.")}})}ji();function mw(e,t,n=40,i=[e]){let r=e.getCenter(new j),s=Math.max(e.getSize(new j).length()/2,0.01),a=new j(1,0.65,1.25).normalize(),o=new j().crossVectors(new j(0,1,0),a).normalize(),c=new j().crossVectors(a,o),l=[];for(let x of i.length?i:[e])for(let _ of[x.min.x,x.max.x])for(let y of[x.min.y,x.max.y])for(let v of[x.min.z,x.max.z])l.push(new j(_,y,v));let u=1/0,d=-1/0,f=1/0,h=-1/0;for(let x of l){let _=x.clone().sub(r),y=_.dot(o),v=_.dot(c);u=Math.min(u,y),d=Math.max(d,y),f=Math.min(f,v),h=Math.max(h,v)}r.addScaledVector(o,(u+d)/2),r.addScaledVector(c,(f+h)/2);let b=Math.tan(n*Math.PI/360),m=b*t,g=s;for(let x of l){let _=x.clone().sub(r),y=_.dot(a);g=Math.max(g,y+Math.abs(_.dot(o))*1.12/m,y+Math.abs(_.dot(c))*1.12/b)}let p=r.clone().addScaledVector(a,g);return{center:r,radius:s,distance:g,position:p}}ji();function Eg(e,t){return{position:e.position.clone(),target:t.clone()}}function Tg(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new j).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new j))+r*20,10),e.updateProjectionMatrix()}function gw(e,t,n){let i=e.getWorldDirection(new j);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new j(0,1,0)),s=new j;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function bw(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}async function xw(e,t){let n=t();if(n===void 0)throw Error("Wait for the selected artifact to be loaded before measuring.");let i=JSON.stringify(n),r=await e();if(JSON.stringify(t())!==i)throw Error("The artifact changed during measurement. Measure the loaded revision again.");return{...r,artifact:n}}function yw(e,t,n){if(t())return e;n(e);return}ji();function Kd(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,a)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(a)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((a)=>{let o=e.parser.associations.get(a)?.nodes;if(o===void 0||!i.has(o))return;a.visible=!1,r++});return r}function Wd(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new hn().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new hn,i=new hn,r=new j;return e.traverseVisible((s)=>{let a=s,o=a.geometry;if(!o)return;let c=o.getAttribute("position");if(c&&a.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(a.isMesh)a.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(o.boundingBox===null)o.computeBoundingBox();i.copy(o.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new hn().setFromObject(e,!0):n}function yl(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function _w(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((b)=>!Number.isInteger(b)||!t[b]||n.has(b)))continue;let d=l.parent;while(d&&!i.has(d))d=d.parent;if(d)continue;let f=[l];for(let b of u)f.push(await e.parser.getDependency("node",b));Kd(e,f.slice(1)),i.add(l);let h=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:h,levels:f})}if(r.length===0)return;let s=yl(e.scene)-r.reduce((c,l)=>c+Ag(l,0),0),a=Math.max(...r.map((c)=>c.levels.length)),o=Array.from({length:a},(c,l)=>s+r.reduce((u,d)=>u+Ag(d,l),0));return{chains:r,triangles:o}}var vw=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function Ag(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return yl(vw(e,t))}function Ew(e,t){let n=vw(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function Tw(e,t){for(let n of e.chains)Ew(n,t)}function Aw(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return Ew(i,n),!0}function ww(e,t){if(!e)return;return{triangles:yl(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>Ag(n,r))}))}}function $o(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function wg(e){return e.map((t,n)=>`LOD${n} · ${t.toLocaleString()} triangles`)}function _l(e){let t=new og({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=Xc,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new Po,i=new fn(40,1,0.01,1000),r=new dg(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,a=!1,o=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(O)=>{if(!a||!c.has(O.code))return;O.preventDefault(),s.add(O.code)},u=(O)=>s.delete(O.code),d=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",d);let f=new bl(t),h=new fg,b=f.fromScene(h,0.04);n.environment=b.texture,h.dispose(),f.dispose();let m=new Bo(16773591,2.4);m.position.set(4,8,5),n.add(m),n.add(new Dd(14806490,5065021,1.7));let g,p,x,_=[],y=!0,v=performance.now(),T=0,A=0,E=!1,w,P,S,I=(O)=>{if(!S)return;clearTimeout(S.timeout),S.reject(Error(O)),S=void 0},U=(O)=>{let K=t.getContext(),B=K.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:O-S.started,frameMs:bw(S.samples),...P===void 0?{}:{loadToFirstFrameMs:P},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(K.getParameter(K.VERSION)),vendor:String(K.getParameter(K.VENDOR)),renderer:String(K.getParameter(K.RENDERER)),browser:navigator.userAgent,...B?{unmaskedVendor:String(K.getParameter(B.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(K.getParameter(B.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},N=()=>{if(!g)return;let O=Wd(g),K=[];g.traverseVisible((de)=>{if(de instanceof jt||de instanceof gs||de instanceof Do){let Me=new hn().setFromObject(de,!0);if(!Me.isEmpty())K.push(Me)}});let{center:B,radius:X,distance:q,position:le}=mw(O,i.aspect,i.fov,K);if(r.target.copy(B),i.position.copy(le),i.near=Math.max(X/1000,0.0001),i.far=q+X*100,r.minDistance=X*0.1,r.maxDistance=X*80,o=Math.max(X*0.35,0.01),a)r.minDistance=X*0.00001;i.updateProjectionMatrix(),r.update()},F=new ResizeObserver(()=>{let{clientWidth:O,clientHeight:K}=e;if(!O||!K)return;t.setSize(O,K),i.aspect=O/K,i.updateProjectionMatrix()});F.observe(e);let D=(O)=>{if(E)return;let K=Math.min((O-v)/1000,0.1);if(v=O,e.clientWidth&&e.clientHeight){if(y)x?.update(K);if(a&&s.size){let B=gw(i,s,K*o*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(B),r.target.add(B)}if(r.update(),t.render(n,i),w!==void 0)P=performance.now()-w,w=void 0;if(S){if(S.previous>0&&S.samples.length<1800)S.samples.push(O-S.previous);if(S.previous=O,O-S.started>=S.duration&&S.samples.length){let B=U(O);clearTimeout(S.timeout),S.resolve(B),S=void 0}}}else s.clear(),I("Keep the measured viewport visible for the complete sampling window.");T=requestAnimationFrame(D)};return T=requestAnimationFrame(D),{async load(O,K={}){let B=performance.now(),X=++A;I("The artifact changed during measurement. Measure the new revision again.");let q=await pw(O);Kd(q,[q.scene]);let le=await _w(q);try{q.assertTexturesLoaded()}catch(ne){yr(q.scene);for(let ie of $o(le))yr(ie);throw ne}let de=yw(q,()=>!E&&X===A&&K.isCurrent?.()!==!1,(ne)=>{yr(ne.scene);for(let ie of $o(le))yr(ie)});if(!de)return;let Me=g&&K.preserveView?Eg(i,r.target):void 0;if(g){x?.stopAllAction(),x?.uncacheRoot(g),n.remove(g),yr(g);for(let ne of $o(p))yr(ne)}g=de.scene,p=le,w=B,P=void 0,n.add(g),_=de.animations,x=new Bd(g),y=!0;let{clientWidth:pe,clientHeight:J}=e;if(t.setSize(pe,J),i.aspect=pe&&J?pe/J:i.aspect,N(),Me)Tg(i,r.target,Me,Wd(g)),r.update();let L=0,W=new Set;return g.traverseVisible((ne)=>{let ie=ne;if(!ie.isMesh)return;L++;for(let ce of Array.isArray(ie.material)?ie.material:[ie.material])W.add(ce)}),K.onCommit?.(),{triangles:yl(g),meshes:L,materials:W.size,clips:_.map((ne)=>ne.name),...p?{levels:p.triangles}:{}}},level(O){if(I("The level of detail changed. Measure the displayed combination again."),p)Tw(p,O)},partLevel(O,K){if(I("The level of detail changed. Measure the displayed combination again."),p)Aw(p,O,K)},lod(){return g?ww(p,g):void 0},reset:N,cancelMeasurement:I,measure(O=3000){if(E||!g||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(O)||O<1000||O>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(S)return Promise.reject(Error("A measurement is already running."));return new Promise((K,B)=>{S={started:performance.now(),previous:0,duration:O,samples:[],resolve:K,reject:B,timeout:setTimeout(()=>I("Measurement was interrupted or the browser stopped delivering frames."),O+2000)}})},view(){return Eg(i,r.target)},setView(O){if(!g)return;Tg(i,r.target,O,Wd(g)),r.update()},navigation(O){if(a=O==="explore",s.clear(),r.minDistance=a?0.00001:o/3.5,a)i.near=0.0001,i.updateProjectionMatrix()},wire(O){for(let K of g?[g,...$o(p)]:[])K.traverse((B)=>{let X=B;if(X.isMesh){for(let q of Array.isArray(X.material)?X.material:[X.material])if("wireframe"in q)q.wireframe=O}})},lighting(O){t.toneMappingExposure=O==="bright"?1.65:O==="soft"?0.85:1.15,m.intensity=O==="soft"?0.8:2.4},clip(O){if(x?.stopAllAction(),_[O])x?.clipAction(_[O]).play()},pause(O){y=!O},dispose(){if(I("The viewport closed before measurement finished."),E=!0,A++,cancelAnimationFrame(T),F.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",d),g)yr(g);for(let O of $o(p))yr(O);b.dispose(),t.dispose(),e.replaceChildren()}}}var ue=(e)=>document.getElementById(e);function k(e,t,n){let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i}function Rn(e){let t=ue("dashboard-status");t.textContent=e instanceof Error?e.message:String(e),t.hidden=!t.textContent}async function un(e,t){let n=await fetch(e,t?{method:t.method,headers:{"Content-Type":"application/json"},body:JSON.stringify(t.body)}:void 0),i=await n.json();if(!n.ok)throw Error(i.error??`Request failed (${n.status})`);return i}function Ko(e,t){let n=k("div",void 0,"empty");return n.append(k("b",e),k("p",t)),n}function Hi(e,t){try{localStorage.setItem(e,t)}catch{}}function As(e){try{return localStorage.getItem(e)}catch{return null}}function Tn(e){return e?e.slice(0,15):"Unspecified"}function Wo(e,t){let n=k("details",void 0,"record-details");return n.append(k("summary",e),k("pre",JSON.stringify(t,null,2))),n}function vl(e,t,n,i){let r=n.lod();if(e.hidden=!r,t.hidden=!r,t.replaceChildren(),e.replaceChildren(),e.onchange=null,!r)return;e.append(...wg(r.levels).map((l,u)=>new Option(l,String(u))));let s=new Option("Mixed part levels","mixed");s.disabled=!0,e.append(s);let a=k("p","","lod-total");a.setAttribute("role","status"),t.append(a);let o=new Map;if(r.chains.length>1){let l=k("details",void 0,"lod-parts");l.append(k("summary","Per-part levels")),l.append(k("p","Choose a level for each part. The main selector sets every part to the same index.","subtle"));let u=k("div",void 0,"lod-part-fields"),d=new Set(r.chains.filter((f,h,b)=>b.findIndex((m)=>m.label===f.label)!==h).map((f)=>f.label));for(let[f,h]of r.chains.entries()){let b=d.has(h.label)?`${h.label} (part ${f+1})`:h.label,m=k("label",b,"inline-field"),g=k("select");g.setAttribute("aria-label",`${b} level of detail`),g.append(...wg(h.triangles).map((p,x)=>new Option(p,String(x)))),g.onchange=()=>{n.partLevel(h.id,Number(g.value)),c(),i?.()},o.set(h.id,g),m.append(g),u.append(m)}l.append(u),t.append(l)}function c(){let l=n.lod();if(!l)return;let u=l.levels.findIndex((d,f)=>l.chains.every((h)=>h.level===Math.min(f,h.triangles.length-1)));e.value=u<0?"mixed":String(u),a.textContent=`${l.triangles.toLocaleString()} triangles displayed`;for(let d of l.chains){let f=o.get(d.id);if(f)f.value=String(d.level)}}return e.onchange=()=>{if(e.value==="mixed")return;let l=Number(e.value);n.level(l),c(),i?.(l)},c(),{refresh:c}}var Sw=/^[a-z][a-z0-9_-]{0,79}$/u,C8=/^r_[a-z0-9_-]{1,77}$/u;function Mw(e){let t=new URLSearchParams(e),n=t.get("collection"),i=t.get("asset"),r=t.get("revision");if(!n||!i||!r||!Sw.test(n)||!Sw.test(i)||!C8.test(r))return;return{collection:n,assetId:i,revisionId:r}}Mg();var cb=new TextEncoder,uB=new TextDecoder,Qo=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),ob=(e,t)=>Object.hasOwn(e,t);async function yR(e){let t=await crypto.subtle.digest("SHA-256",Uint8Array.from(e));return`sha256:${Array.from(new Uint8Array(t),(n)=>n.toString(16).padStart(2,"0")).join("")}`}function dB(e){if(e.length>200||!/^[a-z0-9][a-z0-9._-]*\.kiln-metadata\.json$/i.test(e)||/^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(e))throw Error("Runtime metadata filename must be a portable sibling *.kiln-metadata.json filename")}function fB(e){if(e.length>200||!/^[a-z0-9][a-z0-9._-]*\.gltf$/i.test(e)||/^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(e))throw Error("External texture output must be a portable sibling *.gltf filename")}function hB(e,t){if(t+8>e.length)return;let n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(n.getUint32(t+4,!0)!==5130562)return;return e.subarray(t+8,t+8+n.getUint32(t,!0))}function pB(e){let t=new Map;for(let i of[...kc(e),...(e.materialResources?.records??[]).map(({manifest:r})=>r)])t.set(`${i.materialId}/${i.revisionId}`,i);let n=(i,r)=>i<r?-1:i>r?1:0;return[...t.values()].flatMap((i)=>i.maps.map((r)=>({sha256:r.sha256,pin:{resourceId:i.materialId,revisionId:i.revisionId,sha256:i.revisionId},slot:r.slot}))).sort((i,r)=>n(i.pin.resourceId,r.pin.resourceId)||n(i.pin.revisionId,r.pin.revisionId)||n(i.slot,r.slot))}function _R(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=12;while(n<e.length){if(n+8>e.length)throw Error("Invalid GLB chunk header");let s=t.getUint32(n,!0);if(s%4||n+8+s>e.length)throw Error("Invalid GLB chunk length");n+=8+s}let i=20+t.getUint32(12,!0),r=JSON.parse(uB.decode(e.subarray(20,i)));if(!Qo(r)||!Qo(r.asset)||r.asset.version!=="2.0")throw Error("Invalid glTF asset");return{json:r,jsonEnd:i}}function vR(e,t,n){let i=cb.encode(JSON.stringify(n)),r=Math.ceil(i.length/4)*4,s=new Uint8Array(20+r+e.length-t);if(s.length>Kn)throw Error("Runtime export exceeds 64 MiB");s.set(e.subarray(0,20));let a=new DataView(s.buffer);return a.setUint32(8,s.length,!0),a.setUint32(12,r,!0),s.fill(32,20,20+r),s.set(i,20),s.set(e.subarray(t),20+r),s}async function mB(e,t,n={}){let[{deliverRuntimeThreeGlb:i},{MeshoptEncoder:r}]=await Promise.all([Promise.resolve().then(() => (fR(),dR)),Promise.resolve().then(() => (xR(),bR))]);await r.ready;let s=await i(e,r,t,n);if(s.glb.byteLength>Kn)throw Error("Runtime export exceeds 64 MiB");return s}async function ER(e,t={}){let n=t.profile??"editable";if(n!=="editable"&&n!=="runtime")throw Error("Unknown export profile");if(t.target!==void 0&&t.target!=="three")throw Error("Unknown runtime export target");if(t.target!==void 0&&n!=="runtime")throw Error("A runtime export target requires the runtime profile");if(t.compression!==void 0&&t.target!=="three")throw Error("Runtime compression requires the three runtime target");let i=t.textures;if(i!==void 0&&i!=="manifest"&&i!=="external")throw Error("Unknown runtime texture option");if(i!==void 0&&n!=="runtime")throw Error("A texture manifest requires the runtime profile");if(i==="external"&&t.target!=="three")throw Error("External textures require target three");let r=t.gltfFileName??"runtime.gltf";if(i==="external")fB(r);Du(e);let s=e.files["asset.glb"];if(n==="editable")return{profile:n,glb:s};let a=t.metadataFileName??"runtime.kiln-metadata.json";dB(a);for(let[w,P]of Object.entries(e.files))if(await yR(P)!==e.manifest.files[w].sha256)throw Error(`Asset integrity mismatch: ${w}`);let{json:o,jsonEnd:c}=_R(s),l=o.asset;if(ob(l,"extras")&&!Qo(l.extras))throw Error("Cannot add provenance to non-object asset extras");let u=l.extras??{};if(ob(u,"kilnProvenanceV1"))throw Error("Asset extras already contain kilnProvenanceV1; export from the canonical revision");let d=[];if(o.scenes!==void 0&&!Array.isArray(o.scenes))throw Error("Invalid glTF scenes");for(let[w,P]of(o.scenes??[]).entries()){if(!Qo(P)||!Qo(P.extras)||!ob(P.extras,"kilnReviewClipsV1"))continue;let S=P.extras.kilnReviewClipsV1;if(!Qo(S)||S.version!==1&&S.version!==2||!Array.isArray(S.clips))throw Error("Unsupported scenes[].extras.kilnReviewClipsV1");d.push({index:w,kilnReviewClipsV1:S}),delete P.extras.kilnReviewClipsV1}let f={version:"kiln.runtime-metadata.v1",source:{assetId:e.manifest.assetId,revisionId:e.manifest.revisionId,glbSha256:e.manifest.files["asset.glb"].sha256,...e.manifest.files["source.kiln.js"]?{sourceSha256:e.manifest.files["source.kiln.js"].sha256}:{}},scenes:d},h=s,b=o,m=c,g,p;if(t.target==="three"){let w=await mB(vR(s,c,o),{...t.ktx2Encoder?{ktx2Encoder:t.ktx2Encoder}:{},...t.compression?{compression:t.compression}:{}},i==="external"?{gltfBasename:r.slice(0,-5)}:{});f.target="three",f.delivery=w.delivery,h=w.glb,g=w.imageSources,p=w.gltf,{json:b,jsonEnd:m}=_R(h)}if(i!==void 0)f.textures=await Rw(b,hB(h,m),{...g?{sources:g}:{},maps:pB(e)});let x=p?await gB(p,f.textures??[]):void 0,_=cb.encode(JSON.stringify(f));if(_.length>Kn)throw Error("Runtime export exceeds 64 MiB");let y={version:"kiln.provenance.v1",profile:"runtime",...t.target?{target:t.target}:{},metadata:{uri:a,sha256:await yR(_)}},v=b.asset;v.extras={...v.extras??u,kilnProvenanceV1:y};let T=vR(h,m,b);if(!x)return{profile:n,glb:T,metadata:{name:a,bytes:_}};let A=x.json.asset;A.extras={...A.extras??u,kilnProvenanceV1:y};let E=cb.encode(JSON.stringify(x.json));if(E.length>Kn)throw Error("Runtime export exceeds 64 MiB");return{profile:n,layout:"gltf",glb:T,gltf:{name:r,bytes:E},buffers:x.buffers,textures:x.textures,metadata:{name:a,bytes:_}}}async function gB(e,t){let n=structuredClone(e.json),i=new Map(Object.entries(e.resources)),r=Array.isArray(n.images)?n.images:[];if(r.length!==t.length)throw Error("External texture layout mismatch");let s=new Map;for(let[o,c]of r.entries()){let l=t[o],u=typeof c.uri==="string"?c.uri:"",d=i.get(u);if(!d||`sha256:${await El(d)}`!==l.sha256)throw Error("External texture bytes differ from the delivered GLB");i.delete(u);let f=`textures/${l.sha256.slice(7)}.${Iw(l.mimeType)}`;c.uri=f,l.uri=f,s.set(f,{uri:f,sha256:l.sha256,bytes:d})}let a=[...i].map(([o,c])=>({uri:o,bytes:c}));for(let{uri:o}of a)if(!/^[a-z0-9][a-z0-9._-]*\.bin$/i.test(o))throw Error(`Unexpected external glTF resource ${o}`);return{json:n,buffers:a,textures:[...s.values()]}}var Wi=Le().regex(/^[a-z][a-z0-9_-]{0,79}$/).refine((e)=>!/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(e),"Reserved filesystem name"),lb=Le().regex(/^r_[0-9]{10}_[a-f0-9]{64}$/),wR=Le().regex(/^sha256:[a-f0-9]{64}$/),ec=Le().max(4000),SR=Le().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),TR=be({collectionId:Wi,assetId:Wi,revisionId:Wi}).strict(),AR=be({style:ec.default(""),scale:Le().max(1000).default(""),palette:at(be({role:Le().min(1).max(100),color:Le().regex(/^#[a-fA-F0-9]{6}$/)}).strict()).max(64).default([]),materialRoles:at(be({role:Le().min(1).max(100),description:ec.default(""),resourceId:SR.optional()}).strict()).max(128).default([]),conventions:at(Le().max(1000)).max(100).default([]),exceptions:at(Le().max(1000)).max(100).default([])}).strict(),bB=be({resourceId:SR,revisionId:Le().min(1).max(200),sha256:wR,role:Le().max(100).optional()}).strict(),xB=at(bB).max(512),vr={name:Le().trim().min(1).max(200),brief:Le().max(16000).default(""),design:AR.default(()=>AR.parse({})),inventory:at(be({id:Wi,name:Le().trim().min(1).max(200),kind:Ct(["asset","environment"]).default("asset"),brief:ec.default(""),references:at(Wi).max(64).default([]),asset:TR.optional()}).strict()).max(1000).default([]),deliveryProfiles:at(be({id:Wi,target:Ct(["three","godot","unity","unreal","roblox","sbox","usdz","custom"]),description:ec.default(""),performanceIntent:Le().max(1000).default(""),constraints:at(Le().max(1000)).max(100).default([])}).strict()).max(32).default([]),materialDependencies:xB.default([]),references:at(be({id:Wi,title:Le().min(1).max(200),uri:Le().min(1).max(2048),description:ec.default(""),sha256:wR.optional()}).strict()).max(256).default([]),reviews:at(be({id:Wi,inventoryId:Wi,projectRevisionId:lb,asset:TR,reviewer:Le().trim().min(1).max(200),verdict:Ct(["comment","changes-requested","accepted"]),notes:ec}).strict()).max(2000).default([])};function MR(e,t){let n=(a,o)=>{if(new Set(a).size!==a.length)t.addIssue({code:bu.custom,path:[o],message:"Duplicate identity"})};n(e.inventory.map((a)=>a.id),"inventory"),n(e.references.map((a)=>a.id),"references"),n(e.deliveryProfiles.map((a)=>a.id),"deliveryProfiles"),n(e.materialDependencies.map((a)=>a.resourceId),"materialDependencies"),n(e.reviews.map((a)=>a.id),"reviews"),n(e.design.palette.map((a)=>a.role),"design.palette"),n(e.design.materialRoles.map((a)=>a.role),"design.materialRoles");let i=new Set(e.references.map((a)=>a.id)),r=new Set(e.inventory.map((a)=>a.id)),s=new Set(e.materialDependencies.map((a)=>a.resourceId));for(let a of e.inventory)if(n(a.references,`inventory.${a.id}.references`),a.references.some((o)=>!i.has(o)))t.addIssue({code:bu.custom,path:["inventory"],message:"Unknown reference"});if(e.reviews.some((a)=>!r.has(a.inventoryId)))t.addIssue({code:bu.custom,path:["reviews"],message:"Unknown inventory item"});if(e.design.materialRoles.some((a)=>a.resourceId&&!s.has(a.resourceId)))t.addIssue({code:bu.custom,path:["design"],message:"Material role requires a locked resource"})}var RR=be({projectId:Wi.optional(),...vr}).strict().superRefine(MR),QW=be({name:vr.name.optional(),brief:vr.brief.removeDefault().optional(),design:vr.design.removeDefault().optional(),inventory:vr.inventory.removeDefault().optional(),deliveryProfiles:vr.deliveryProfiles.removeDefault().optional(),materialDependencies:vr.materialDependencies.removeDefault().optional(),references:vr.references.removeDefault().optional(),reviews:vr.reviews.removeDefault().optional()}).strict(),eX=be({version:$e("kiln.project.v1"),projectId:Wi,revisionId:lb,parentRevision:lb.optional(),createdAt:Le().datetime(),...vr}).strict().superRefine(MR);function IR(e){let{palette:t,materialRoles:n,conventions:i,exceptions:r}=e.design??{};return{design:{palette:t??[],materialRoles:n??[],conventions:i??[],exceptions:r??[]},inventory:e.inventory??[],deliveryProfiles:e.deliveryProfiles??[],materialDependencies:e.materialDependencies??[],references:e.references??[],reviews:e.reviews??[]}}function CR(e,t){let n=JSON.parse(e);if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Project configuration must be a JSON object.");let i=n,r=i.design??{};if(!r||typeof r!=="object"||Array.isArray(r))throw Error("Design configuration must be a JSON object.");return RR.parse({...i,name:t.name,brief:t.brief,design:{...r,style:t.style,scale:t.scale}})}function NR(e){let t=[],n=As("kiln.project")??"",i,r=()=>{let c=ue("project-list");c.replaceChildren();for(let _ of t){let y=k("button",void 0,_.projectId===n?"active":"");if(y.append(k("strong",_.name),k("small",`${_.inventory.length} inventory items · ${_.materialDependencies.length} resources`)),_.projectId===n)y.setAttribute("aria-current","true");y.onclick=()=>{n=_.projectId,Hi("kiln.project",n),r()},c.append(y)}let l=t.find((_)=>_.projectId===n),u=ue("project-detail");if(u.replaceChildren(),!l){u.append(Ko("A direction for what comes next.","Projects are optional. Group related assets, materials and design decisions here, or build and review standalone assets in Library and Live Review."));return}let d=k("div",void 0,"project-summary"),f=k("div");f.append(k("h2",l.name),k("p",l.brief||"Add a brief to describe what this project should deliver."));let h=k("button","Edit project","secondary");h.onclick=()=>a(l),d.append(f,h),u.append(d);let b=k("p",`${l.projectId} · ${Tn(l.revisionId)} · ${new Date(l.createdAt).toLocaleString()}`,"mono");u.append(b);let m=k("div",void 0,"project-metrics");for(let[_,y]of[[l.inventory.length,"inventory items"],[l.materialDependencies.length,"locked resources"],[l.deliveryProfiles.length,"delivery profiles"]]){let v=k("div");v.append(k("strong",String(_)),k("span",String(y))),m.append(v)}u.append(m);let g=k("div",void 0,"profile-grid");for(let[_,y]of[["Visual direction",l.design.style||"Not specified"],["Scale",l.design.scale||"Not specified"]]){let v=k("div");v.append(k("span",_,"label"),k("p",y)),g.append(v)}u.append(g);let p=k("div",void 0,"palette");for(let _ of l.design.palette){let y=k("div",void 0,"swatch"),v=document.createElementNS("http://www.w3.org/2000/svg","svg");v.setAttribute("viewBox","0 0 24 24"),v.setAttribute("aria-hidden","true");let T=document.createElementNS("http://www.w3.org/2000/svg","rect");T.setAttribute("width","24"),T.setAttribute("height","24"),T.setAttribute("fill",_.color),v.append(T);let A=k("span",_.role);A.append(k("small",_.color)),y.append(v,A),p.append(y)}if(p.childElementCount)u.append(p);for(let[_,y]of[["Conventions",l.design.conventions],["Declared exceptions",l.design.exceptions]]){if(!y.length)continue;u.append(k("h3",_));let v=k("ul",void 0,"subtle");for(let T of y)v.append(k("li",T));u.append(v)}if(u.append(k("h3","Inventory")),!l.inventory.length)u.append(k("p","No inventory yet. Add deliberate asset and environment entries in the project configuration.","subtle"));else{let _=k("div",void 0,"table-wrap"),y=k("table"),v=k("thead"),T=k("tr");for(let E of["Item","Kind","Saved revision","Review"])T.append(k("th",E));v.append(T),y.append(v);let A=k("tbody");for(let E of l.inventory){let w=k("tr"),P=k("td",E.name);P.append(k("small",E.brief));let S=k("td"),I=k("td");if(E.asset){let U=k("button",Tn(E.asset.revisionId),"secondary");U.onclick=()=>e.openAsset(E.asset),S.append(U);let N=[...l.reviews].reverse().find((D)=>D.inventoryId===E.id&&D.asset.revisionId===E.asset.revisionId&&D.asset.assetId===E.asset.assetId&&D.asset.collectionId===E.asset.collectionId);I.append(k("small",N?`${N.verdict} · ${N.reviewer}`:"Unreviewed"));let F=k("button","Record review","secondary");F.onclick=()=>o(l,E),I.append(F)}else S.textContent="Not linked",I.textContent="No saved revision";w.append(P,k("td",E.kind),S,I),A.append(w)}y.append(A),_.append(y),u.append(_)}if(l.design.materialRoles.length){u.append(k("h3","Material roles"));for(let _ of l.design.materialRoles)u.append(k("p",`${_.role}: ${_.description||"No description"}${_.resourceId?` · ${_.resourceId}`:" · No resource assigned"}`,"subtle"))}if(l.deliveryProfiles.length){u.append(k("h3","Delivery intent"));for(let _ of l.deliveryProfiles){if(u.append(k("p",`${_.target} · ${_.description||_.id}`,"subtle")),_.performanceIntent)u.append(k("p",_.performanceIntent,"subtle"));for(let y of _.constraints)u.append(k("p",y,"subtle"))}u.append(k("p","Declared targets are project intent. They do not establish consumer or performance qualification.","subtle"))}if(l.references.length){u.append(k("h3","Reference records"));for(let _ of l.references){let y=k("p",`${_.title}: ${_.uri}`,"subtle");if(_.description)y.append(k("small",` · ${_.description}`));u.append(y)}}u.append(k("h3","Project downloads"));let x=k("div",void 0,"downloads");for(let _ of["editable","runtime"]){let y=k("a",_==="editable"?"Download editable project bundle":"Download runtime project bundle"),v=new URLSearchParams({profile:_,revision:l.revisionId});y.href=`/api/projects/${encodeURIComponent(l.projectId)}/bundle?${v}`,y.download=`${l.projectId}-${_}.zip`,x.append(y)}x.append(k("p","Both downloads bind this exact project revision and its linked saved inventory. Editable includes authored source and material resources for rebuilding. Runtime is delivery-only and cannot restore editable source. Unlinked inventory entries remain plans, not bundled assets.")),u.append(x),u.append(Wo("Exact project configuration and review records",l))},s=async()=>{let c=await un("/api/projects");if(t.length===c.projects.length&&t.every((l,u)=>l.revisionId===c.projects[u]?.revisionId))return;if(t=c.projects,!t.some((l)=>l.projectId===n))n=t[0]?.projectId??"";r(),e.changed(t)};function a(c){i=c,ue("project-editor-title").textContent=c?"Edit project":"New project",ue("project-name").value=c?.name??"",ue("project-brief").value=c?.brief??"",ue("project-style").value=c?.design.style??"",ue("project-scale").value=c?.design.scale??"",ue("project-config").value=JSON.stringify(IR(c??{name:""}),null,2),ue("project-save-status").textContent="",ue("project-editor").showModal(),ue("project-name").focus()}function o(c,l){if(!l.asset)return;let u=k("dialog"),d=k("form"),f=k("div",void 0,"editor-content"),h=k("h2",`Review ${l.name}`);h.id="review-dialog-title",u.setAttribute("aria-labelledby",h.id),f.append(h,k("p","Record an assessment of this exact saved revision. This is a review annotation; structural QA and release qualification remain separate.","subtle"),k("code",`${l.asset.assetId} / ${l.asset.revisionId}`,"mono"));let b=k("input");b.required=!0,b.value=As("kiln.reviewer")??"",b.maxLength=200;let m=k("label","Reviewer","field");m.append(b);let g=k("select");for(let[A,E]of[["comment","Comment"],["changes-requested","Changes requested"],["accepted","Visually accepted"]])g.append(new Option(E,A));let p=k("label","Assessment","field");p.append(g);let x=k("textarea");x.rows=4,x.maxLength=4000;let _=k("label","Notes","field");_.append(x);let y=k("p");y.setAttribute("role","status");let v=k("button","Save review");v.type="submit";let T=k("button","Cancel","secondary");T.type="button",T.onclick=()=>u.close(),f.append(m,p,_,y,v,T),d.append(f),u.append(d),document.body.append(u),u.addEventListener("close",()=>u.remove()),d.onsubmit=async(A)=>{A.preventDefault(),v.disabled=!0,y.textContent="Saving review…";try{await un(`/api/projects/${encodeURIComponent(c.projectId)}`,{method:"PATCH",body:{expectedRevision:c.revisionId,patch:{reviews:[...c.reviews,{id:`review_${crypto.randomUUID().replaceAll("-","")}`,inventoryId:l.id,projectRevisionId:c.revisionId,asset:l.asset,reviewer:b.value.trim(),verdict:g.value,notes:x.value}]}}}),Hi("kiln.reviewer",b.value.trim()),u.close(),await s()}catch(E){y.textContent=E instanceof Error?E.message:String(E)}finally{v.disabled=!1}},u.showModal(),b.focus()}return ue("new-project").onclick=()=>a(),ue("close-project-editor").onclick=()=>ue("project-editor").close(),ue("project-form").onsubmit=async(c)=>{c.preventDefault();let l=ue("save-project");l.disabled=!0,ue("project-save-status").textContent="Saving revision…";try{let u=CR(ue("project-config").value,{name:ue("project-name").value,brief:ue("project-brief").value,style:ue("project-style").value,scale:ue("project-scale").value});n=(await un(i?`/api/projects/${encodeURIComponent(i.projectId)}`:"/api/projects",i?{method:"PATCH",body:{expectedRevision:i.revisionId,patch:u}}:{method:"POST",body:u})).projectId,Hi("kiln.project",n),ue("project-editor").close(),Rn("Project revision saved."),await s()}catch(u){ue("project-save-status").textContent=u instanceof Error?u.message:String(u)}finally{l.disabled=!1}},{refresh:s}}var yB="Raw map pixels · unshaded · not GPU capture evidence",ub=/^[a-z][a-z0-9_-]{0,79}$/,db=/^sha256:[a-f0-9]{64}$/;function Pl(e){let t=new URLSearchParams(e.startsWith("?")?e:e.slice(e.indexOf("?")+1)),n=t.get("material"),i=t.get("materialRevision");if(t.getAll("material").length!==1||t.getAll("materialRevision").length!==1||!n||!i||!ub.test(n)||!db.test(i))return;return{materialId:n,revisionId:i}}function Sf(e){if(!ub.test(e.materialId)||!db.test(e.revisionId))throw Error("Invalid exact material selection");return`/?${new URLSearchParams({material:e.materialId,materialRevision:e.revisionId})}`}function fb(e){if(!ub.test(e.materialId)||!db.test(e.revisionId))throw Error("Invalid exact material selection");return`/api/materials/${encodeURIComponent(e.materialId)}/${encodeURIComponent(e.revisionId)}`}function PR(e){let t=ro(e),n=fb(t),i=t.maps.map((r)=>{let s="recipe"in r?r:void 0,a=s?.recipe?.kind==="atlas"?s.recipe:void 0;return{slot:r.slot,file:r.file,url:`${n}/${encodeURIComponent(r.file)}`,width:r.width,height:r.height,colorSpace:r.colorSpace,imageSha256:r.sha256,..."pixelHash"in r?{pixelHash:r.pixelHash}:{},..."sampler"in r?{sampler:{...r.sampler}}:{},atlas:!!a,...s?.recipe?{compilerId:s.recipe.compilerId}:{},...a?{manifestHash:a.manifest.manifestHash}:{},regions:a?a.manifest.regions.map((o)=>({name:o.name,content:{...o.content},allocation:{...o.allocation},leftPercent:o.content.x/r.width*100,topPercent:o.content.y/r.height*100,widthPercent:o.content.width/r.width*100,heightPercent:o.content.height/r.height*100})):[]}});return{materialId:t.materialId,revisionId:t.revisionId,name:t.name,fidelity:yB,maps:i}}function OR(e,t){if(!e||typeof e!=="object"||Array.isArray(e)||e.artifactGlbSha256!==t)throw Error("Retained evaluation does not identify the displayed artifact");let n=e.materialLibraryDependencies;if(n===void 0)return[];if(!Array.isArray(n)||n.length>16)throw Error("Invalid retained material dependency list");let i=new Map;for(let r of n){let s=ro(r),a=`${s.materialId}/${s.revisionId}`,o=i.get(a);if(o&&Cn(o)!==Cn(s))throw Error("Conflicting retained material identity");i.set(a,s)}return[...i.values()]}function Mf(e){let t=PR(e),n=k("section",void 0,"material-inspection");n.setAttribute("aria-label",`${t.name}: exact material maps`),n.append(k("p",`${t.materialId} · ${t.revisionId}`,"mono"),k("p",t.fidelity,"subtle"));let i=k("div",void 0,"material-inspection-controls"),r=(v,T)=>{let A=k("label",v,"inline-field");return A.append(T),i.append(A),T},s=r("Map",k("select"));for(let v of t.maps)s.append(new Option(`${v.slot}${v.atlas?" · atlas":""}`,v.slot));let a=r("Backdrop",k("select"));for(let v of["checker","light","dark"])a.append(new Option(v[0].toUpperCase()+v.slice(1),v));let o=r("Pixel zoom",k("select"));for(let v of[1,2,4])o.append(new Option(`${v}×`,String(v)));let c=k("div",void 0,"material-pixel-frame"),l=k("div",void 0,"material-pixel-sheet");c.dataset.backdrop="checker",c.tabIndex=0;let u=k("img");u.className="material-pixel-image",u.loading="lazy",u.draggable=!1;let d=k("div",void 0,"material-region-overlay"),f=k("label","Region overlays","inline-field"),h=k("input");h.type="checkbox",h.checked=!1,f.append(h),i.append(f),h.onchange=()=>{d.hidden=!h.checked},l.append(u,d),c.append(l);let b=k("p",void 0,"subtle");b.setAttribute("role","status");let m=k("dl"),g=k("div",void 0,"material-region-list"),p=k("a","Open this saved material revision");p.href=Sf(t),p.target="_blank",p.rel="noopener",n.append(i,c,b,m,g,p);let x=t.maps[0],_=()=>{l.style.width=`${x.width*Number(o.value)}px`,l.style.height=`${x.height*Number(o.value)}px`},y=()=>{x=t.maps.find((T)=>T.slot===s.value)??t.maps[0],f.hidden=!x.atlas,d.hidden=!x.atlas||!h.checked,b.textContent="Loading exact saved map…",u.alt=`${t.name}: ${x.slot}${x.atlas?" atlas sheet":""}, raw unshaded pixels`,u.width=x.width,u.height=x.height,u.src=x.url,_(),m.replaceChildren();let v=(T,A)=>m.append(k("dt",T),k("dd",A));if(v("Image",`${x.width} × ${x.height} · ${x.colorSpace} · nearest pixel display`),v("Sampling declaration",x.sampler?`${x.sampler.minFilter} / ${x.sampler.magFilter} · ${x.sampler.wrapS} / ${x.sampler.wrapT}`:"Not recorded in V1"),v("PNG hash",x.imageSha256),x.pixelHash)v("Decoded RGBA hash",x.pixelHash);if(x.compilerId)v("Compiler",x.compilerId);if(x.manifestHash)v("Atlas manifest hash",x.manifestHash);if(d.replaceChildren(),g.replaceChildren(),x.atlas){g.append(k("h4","Atlas regions · top-left pixel coordinates"));for(let T of x.regions){let A=k("span",void 0,"material-region-box");A.style.left=`${T.leftPercent}%`,A.style.top=`${T.topPercent}%`,A.style.width=`${T.widthPercent}%`,A.style.height=`${T.heightPercent}%`,A.append(k("span",T.name)),A.setAttribute("aria-hidden","true"),d.append(A);let E=k("button",`${T.name}: content ${T.content.x},${T.content.y} ${T.content.width}×${T.content.height}; allocation ${T.allocation.x},${T.allocation.y} ${T.allocation.width}×${T.allocation.height}`,"secondary");E.type="button",E.setAttribute("aria-pressed","false"),E.onclick=()=>{for(let w of d.children)w.classList.remove("selected");for(let w of g.querySelectorAll("button"))w.setAttribute("aria-pressed","false");if(A.classList.add("selected"),E.setAttribute("aria-pressed","true"),!d.hidden)A.scrollIntoView({block:"nearest",inline:"nearest"})},g.append(E)}}};return u.onload=()=>{b.textContent="Raw map loaded. These pixels are not a shaded capture."},u.onerror=()=>{b.textContent=`Exact ${t.materialId} revision map unavailable. No newer revision was substituted.`},s.onchange=y,a.onchange=()=>{c.dataset.backdrop=a.value},o.onchange=_,y(),n}function kR(e){if(!e.presetId.trim())throw Error("Choose a material preset");if(!e.seed.trim())throw Error("Enter an explicit seed");let t=Number(e.seed),n=Number(e.size);if(!Number.isInteger(t)||t<-2147483648||t>2147483647)throw Error("Seed must be a signed 32-bit integer");if(![64,128,256,512].includes(n))throw Error("Choose a supported map size");if(!e.creator.trim()||!e.spdx.trim()||!e.url.trim())throw Error("Creator and license details are required");let i=new URL(e.url.trim());if(i.protocol!=="https:"&&i.protocol!=="http:")throw Error("License URL must be HTTP(S)");return{presetId:e.presetId,seed:t,size:n,creator:e.creator.trim(),license:{spdx:e.spdx.trim(),url:e.url.trim(),attribution:e.attribution}}}function DR(e){let t=[],n=[],i=[],r=ue("materials-project"),s=k("button","Create from preset");ue("materials-refresh").before(s);let a=k("dialog");a.setAttribute("aria-labelledby","material-preset-heading");let o=k("form"),c=k("div",void 0,"detail-top"),l=k("h2","Create a material resource");l.id="material-preset-heading";let u=k("button","Cancel","secondary");u.type="button",u.onclick=()=>a.close(),c.append(l,u);let d=k("div",void 0,"editor-content");d.append(k("p","Offline starting recipes with editable layers and height-derived normals. Choose an explicit seed and provenance for the resource. Map images are not shaded material previews.","subtle"));function f(S,I){let U=k("label",S,"field");return U.append(I),d.append(U),I}let h=f("Preset",k("select")),b=k("p",void 0,"subtle");d.append(b);let m=f("Seed",k("input"));m.type="number",m.step="1",m.required=!0,m.min="-2147483648",m.max="2147483647",m.value="0";let g=f("Map size",k("select"));for(let S of[64,128,256,512])g.append(new Option(`${S} × ${S}`,String(S)));g.value="256";let p=f("Creator",k("input"));p.required=!0,p.maxLength=1000;let x=f("License identifier",k("input"));x.required=!0,x.placeholder="For example, CC0-1.0";let _=f("License URL",k("input"));_.type="url",_.required=!0;let y=f("Attribution text",k("textarea"));y.rows=2;let v=k("p");v.setAttribute("role","status");let T=k("button","Create resource");T.type="submit",d.append(v,T),o.append(c,d),a.append(o),document.body.append(a);let A=()=>{let S=i.find((I)=>I.id===h.value);b.textContent=S?`${S.description} Repeat scale: ${S.physicalSizeMeters.width} × ${S.physicalSizeMeters.height} m.`:""};h.onchange=A,s.onclick=async()=>{s.disabled=!0;try{i=(await un("/api/material-presets")).presets,h.replaceChildren(...i.map((S)=>new Option(S.name,S.id))),A(),v.textContent="",T.disabled=!i.length,a.showModal()}catch(S){Rn(S)}finally{s.disabled=!1}},o.onsubmit=async(S)=>{S.preventDefault(),T.disabled=!0,v.textContent="Creating immutable material resource…";try{let I=kR({presetId:h.value,seed:m.value,size:g.value,creator:p.value,spdx:x.value,url:_.value,attribution:y.value}),U=await un("/api/materials/preset",{method:"POST",body:I});await P(),a.close(),Rn(`${U.material.name} created at ${U.material.revisionId}. Ready for standalone assets. You can also lock this revision to an optional project.`)}catch(I){v.textContent=I instanceof Error?I.message:String(I)}finally{T.disabled=!1}};let E=fb;function w(){let S=n.find((D)=>D.projectId===r.value),I=ue("material-dependencies");if(I.replaceChildren(),S)if(I.append(k("h2",`${S.name}: locked resources`)),!S.materialDependencies.length)I.append(k("p","No materials are locked to this project yet. Select a resource revision below or configure dependencies with your agent.","subtle"));else{let D=k("table"),O=k("thead"),K=k("tr"),B=k("tbody");for(let q of["Resource / role","Exact revision","Local availability"])K.append(k("th",q));O.append(K),D.append(O);for(let q of S.materialDependencies){let le=t.find((pe)=>pe.materialId===q.resourceId&&pe.revisionId===q.revisionId),de=k("tr"),Me=k("td",q.resourceId);Me.append(k("small",q.role??S.design.materialRoles.filter((pe)=>pe.resourceId===q.resourceId).map((pe)=>pe.role).join(", "))),de.append(Me,k("td",q.revisionId,"mono"),k("td",le&&le.revisionId===q.sha256?"Exact local record available":le?"Dependency hash differs":"Not in local catalog")),B.append(de)}D.append(B);let X=k("div",void 0,"table-wrap");X.append(D),I.append(X)}let U=ue("material-list");U.replaceChildren();let N=ue("material-search").value.trim().toLowerCase(),F=t.filter((D)=>`${D.name} ${D.materialId} ${D.tags.join(" ")} ${D.sources.map((O)=>O.provider).join(" ")}`.toLowerCase().includes(N));if(ue("material-count").textContent=`${F.length} material revision${F.length===1?"":"s"}`,!F.length){U.append(Ko(N?"No matching materials":"Your material catalog starts here",N?"Try another material name, tag or provider.":"Materials added through Kiln appear here with their map roles, source records and exact revisions."));return}for(let D of F){let O=k("article",void 0,"material-card"),K=D.maps.find((L)=>L.slot==="baseColor")??D.maps[0];if(K){let L=k("img");L.src=`${E(D)}/${encodeURIComponent(K.file)}`,L.alt=`${D.name}: ${K.slot} map, not a shaded material preview`,L.loading="lazy",L.className="material-map",O.append(L,k("p",`${K.slot} map · unshaded`,"subtle"))}O.append(k("h3",D.name),k("p",D.tags.join(" · "),"subtle"));let B=k("dl"),X=(L,W)=>B.append(k("dt",L),k("dd",W));X("Revision",D.revisionId),X("Physical scale",D.physicalSizeMeters?`${D.physicalSizeMeters.width} × ${D.physicalSizeMeters.height} m`:"Not specified"),X("Tiling",D.tileable?"Declared tileable":"Not declared tileable"),X("Maps",D.maps.map((L)=>`${L.slot} ${L.width}×${L.height} (${L.colorSpace})`).join(" · ")),X("Surface factors",`Roughness ×${D.parameters.roughness} · Metalness ×${D.parameters.metalness}${D.maps.some((L)=>L.slot==="metallicRoughness")?" · multiplied by packed map channels":""}`),O.append(B);for(let L of D.sources){let W=k("p",`${L.provider} · ${L.creator} · ${L.kind}`,"subtle"),ne=k("a",L.license.spdx);if(ne.href=L.license.url,ne.target="_blank",ne.rel="noreferrer",W.append(document.createTextNode(" · "),ne),L.assetUrl){let ie=k("a","Source");ie.href=L.assetUrl,ie.target="_blank",ie.rel="noreferrer",W.append(document.createTextNode(" · "),ie)}if(O.append(W),L.license.attribution)O.append(k("p",L.license.attribution,"subtle"))}let q=k("div",void 0,"material-map-links");for(let L of D.maps){let W=k("a",L.slot);W.href=`${E(D)}/${encodeURIComponent(L.file)}`,W.target="_blank",W.rel="noopener",q.append(W)}O.append(q);let le=k("details",void 0,"material-map-inspection");le.append(k("summary","Inspect maps and atlas regions"));let de=!1;le.ontoggle=()=>{if(le.open&&!de)de=!0,le.append(Mf(D))};let Me=Pl(location.search);if(Me?.materialId===D.materialId&&Me.revisionId===D.revisionId)le.open=!0,O.dataset.selectedMaterial="true";O.append(le);let pe=S?.materialDependencies.find((L)=>L.resourceId===D.materialId),J=k("button",pe?.revisionId===D.revisionId?"Locked to project":pe?"Use this revision":"Add to project","secondary");if(J.disabled=!S||pe?.revisionId===D.revisionId,!S)J.title="Select a project to add a material dependency";J.onclick=async()=>{if(!S)return;J.disabled=!0;try{let L=S.materialDependencies.filter((W)=>W.resourceId!==D.materialId);L.push({resourceId:D.materialId,revisionId:D.revisionId,sha256:D.revisionId,...pe?.role?{role:pe.role}:{}}),await un(`/api/projects/${encodeURIComponent(S.projectId)}`,{method:"PATCH",body:{expectedRevision:S.revisionId,patch:{materialDependencies:L}}}),Rn(`${D.name} is locked to ${S.name} at this exact revision.`),await e()}catch(L){Rn(L),J.disabled=!1}},O.append(J,Wo("Map recipes, transformations and provenance",D)),U.append(O)}}let P=async()=>{t=(await un("/api/materials")).materials,w();let S=Pl(location.search);if(S&&!t.some((I)=>I.materialId===S.materialId&&I.revisionId===S.revisionId))Rn(`Exact material revision unavailable: ${S.materialId} at ${S.revisionId}. No newer revision was selected.`)};return ue("material-search").oninput=w,r.onchange=w,ue("materials-refresh").onclick=()=>void P().catch(Rn),{refresh:P,projects(S){n=S;let I=r.value;r.replaceChildren(new Option("All materials",""));for(let U of n)r.append(new Option(U.name,U.projectId));if(n.some((U)=>U.projectId===I))r.value=I;w()}}}function hb(e,t,n){return n?`${n.triangles.toLocaleString()} triangles displayed · ${t}`:`${e.triangles.toLocaleString()} triangles · ${e.meshes} meshes · ${t}`}var LR=(e,t)=>e.startedAt.localeCompare(t.startedAt)||e.operationId.localeCompare(t.operationId);function Ol(e,t){let n=new Map(e.operations.map((c)=>[c.operationId,c])),i=t.map((c)=>{let l=n.get(c.operationId);return l&&l.revision>c.revision?l:c}).sort(LR),r=(c)=>i.find((l)=>l.operationId===c?.operationId)??c,s=e.following?i.at(-1):r(e.selected),a=(c)=>!!c&&!!s&&c.projectId===s.projectId&&c.workId===s.workId&&LR(c,s)<=0&&(c.sessionId===s.sessionId||e.following&&e.crossRunContinuity===!0&&!!s.workId),o=s?.artifact?s:s?i.filter((c)=>c.artifact&&a(c)).at(-1)??(a(e.displayed)?e.displayed:void 0):void 0;return{...e,operations:i,selected:s,displayed:o,pinned:r(e.pinned)}}function pb(e,t){return Ol({...e,following:!1,selected:e.operations.find((n)=>n.operationId===t)??e.selected},e.operations)}function Zs(e,t){return e?.artifact&&t?.artifact&&e.operationId===t.operationId&&e.revision===t.revision&&e.artifact.sha256===t.artifact.sha256?t:void 0}function FR(e,t,n,i){if(e.status!=="complete"||!e.artifact)throw Error("Save requires a completed operation with an artifact.");if(!Zs(e,Zs(i,n)))throw Error("The visible artifact changed or has not loaded. Close this dialog and review it before saving.");let r=t.trim();if(!r||r.length>200)throw Error("Choose an asset name of 1–200 characters.");return{path:`/api/live/${encodeURIComponent(e.operationId)}/save`,body:{expectedRevision:e.revision,name:r,collection:"project"}}}function Rf(e,t,n,i){let r;e.onclick=async()=>{let s=n();if(!s){t.replaceChildren(k("p","Load an artifact before measuring.","subtle"));return}e.disabled=!0,t.replaceChildren(k("p","Measuring frame pacing for 3 seconds. Keep this viewport visible and the camera steady.","subtle"));try{let a=await xw(()=>s.measure(3000),i),o=k("div",void 0,"evidence-card");o.append(k("h3","Exploratory browser measurement"),k("p","Other workloads are not controlled. This sample is not an isolated performance baseline or budget acceptance."),k("strong",`p50 ${a.frameMs.p50.toFixed(1)} ms · p95 ${a.frameMs.p95.toFixed(1)} ms`),k("p",`${a.frameMs.samples} frame intervals · ${(a.windowMs/1000).toFixed(2)} s · ${a.drawCalls} draws · ${a.triangles.toLocaleString()} rendered triangles`),k("p",`${a.geometryObjects} geometry objects · ${a.textureObjects} texture objects. These counts are not GPU memory bytes.`),k("p",`GLB parse to first frame submission: ${a.loadToFirstFrameMs?.toFixed(1)??"unavailable"} ms. Download time excluded.`),k("p",`${a.viewport.cssWidth}×${a.viewport.cssHeight} CSS pixels · DPR ${a.viewport.devicePixelRatio.toFixed(2)}. Frame pacing includes browser scheduling and vertical sync, not GPU execution timing.`));let c=Wo("Exact measurement receipt and limitations",a);if(r)URL.revokeObjectURL(r);r=URL.createObjectURL(new Blob([JSON.stringify(a,null,2)],{type:"application/json"}));let l=k("a","Download measurement receipt");l.href=r,l.download="kiln-viewer-performance.json",o.append(c,l),t.replaceChildren(o)}catch(a){t.replaceChildren(k("p",a instanceof Error?a.message:String(a),"subtle"))}finally{e.disabled=!1}}}function mb(e,t,n,i){let r=e.inventory.find((a)=>a.id===t);if(!r&&!n)throw Error("Inventory item not found");let s=e.inventory.map((a)=>{if(a.id!==t)return a;let{asset:o,...c}=a;return n?{...c,asset:n}:c});if(!r&&n)s.push({id:t,name:i,kind:"asset",brief:"",references:[],asset:n});return{inventory:s}}async function kl(e,t,n,i){e.replaceChildren(k("h3","Project membership"));let{projects:r}=await un("/api/projects");if(!e.isConnected)return;let s=k("div");e.append(s);let a=k("p");a.setAttribute("role","status");let o=()=>kl(e,t,n,i);for(let m of r)for(let g of m.inventory){if(!g.asset||g.asset.collectionId!==t.collectionId||g.asset.assetId!==t.assetId)continue;let p=k("div",void 0,"membership-row");p.append(k("span",`${m.name} / ${g.name} · ${Tn(g.asset.revisionId)}${g.asset.revisionId===t.revisionId?" · this revision":" · another revision"}`));let x=k("button","Remove membership","secondary");x.onclick=async()=>{x.disabled=!0;try{await un(`/api/projects/${encodeURIComponent(m.projectId)}`,{method:"PATCH",body:{expectedRevision:m.revisionId,patch:mb(m,g.id,null,n)}}),await i(),await o()}catch(_){a.textContent=`${_ instanceof Error?_.message:_} Reopen membership to load the current project.`,x.disabled=!1}},p.append(x),s.append(p)}if(!s.childElementCount)s.append(k("p","This asset is standalone. Project membership is optional.","subtle"));if(!r.length){s.append(k("p","Create a named project in Projects to organize related assets."));return}let c=k("form"),l=k("select"),u=k("select"),d=k("label","Project","field"),f=k("label","Inventory item","field");d.append(l),f.append(u);for(let m of r)l.append(new Option(m.name,m.projectId));let h=()=>{let m=r.find((p)=>p.projectId===l.value);u.replaceChildren(new Option("Add as a new inventory item",""));for(let p of m.inventory)u.append(new Option(`${p.name}${p.asset?" (replace linked revision)":""}`,p.id));let g=m.inventory.find((p)=>p.asset?.collectionId===t.collectionId&&p.asset.assetId===t.assetId);if(g)u.value=g.id};l.onchange=h,h();let b=k("button","Link this exact revision");b.type="submit",c.append(d,f,k("p","Linking preserves the saved asset and its original build provenance. Replacing a link advances only this project.","subtle"),b,a),c.onsubmit=async(m)=>{m.preventDefault(),b.disabled=!0;let g=r.find((x)=>x.projectId===l.value),p=u.value||`asset_${crypto.randomUUID().replaceAll("-","")}`;try{await un(`/api/projects/${encodeURIComponent(g.projectId)}`,{method:"PATCH",body:{expectedRevision:g.revisionId,patch:mb(g,p,t,n)}}),await i(),await o()}catch(x){a.textContent=`${x instanceof Error?x.message:x} Reopen membership to load the current project.`,b.disabled=!1}},s.append(c)}function UR(){let e={following:!0,crossRunContinuity:!0,operations:[]},t=[],n="",i=0,r=!1,s,a=0,o,c,l,u,d,f,h,b=0,m=0,g=!1,p=!1,x,_=ue("live-project"),y=ue("live-source"),v=(L)=>y.value?`${L}${L.includes("?")?"&":"?"}source=${encodeURIComponent(y.value)}`:L,T=ue("live-run"),A=ue("live-work"),E=()=>`kiln.live.selection.${y.value}.${_.value}.${A.value}.${T.value}`,w=()=>`kiln.live.pin.${y.value}`,P=()=>t.filter((L)=>(!T.value||L.sessionId===T.value)&&(!A.value||(A.value==="ungrouped"?!L.workId:L.workId===A.value))),S=(L,W)=>{let ne=ue("live-connection");ne.textContent=L?"Connected":"Reconnecting",ne.className=`pill ${L?"connected":"warning"}`,ue("connection-status").textContent=W};function I(){let L=A.value,W=[...new Set(t.flatMap((ce)=>ce.workId?[ce.workId]:[]))];if(A.replaceChildren(new Option("All authoring items",""),new Option("Ungrouped history","ungrouped"),...W.map((ce)=>new Option(ce,ce))),L==="ungrouped"||W.includes(L))A.value=L;let ne=T.value,ie=[...new Set(t.map((ce)=>ce.sessionId))];T.replaceChildren(new Option("All runs",""));for(let ce of ie){let _e=t.find((Re)=>Re.sessionId===ce);T.append(new Option(`${_e.transport} · ${Tn(ce)}`,ce))}if(ie.includes(ne))T.value=ne}function U(){let L=ue("live-timeline"),W=L.scrollTop,ne=L.contains(document.activeElement)?document.activeElement.dataset.operation:void 0;if(L.replaceChildren(),!e.operations.length){L.append(Ko("Nothing observed yet","Actual Kiln operations will appear here. There is no agent running state to infer."));return}for(let ie of[...e.operations].reverse()){let ce=k("button",void 0,`timeline-item ${ie.status}${e.selected?.operationId===ie.operationId?" selected":""}${ie.pinned?" pinned":""}`);ce.dataset.operation=ie.operationId;let _e=k("span",void 0,"timeline-meta");if(_e.append(k("span",ie.transport.toUpperCase()),k("time",new Date(ie.startedAt).toLocaleTimeString())),ce.append(_e,k("strong",ie.tool.replace(/^kiln_/,"")),k("small",`${ie.status} · ${ie.artifact?"artifact available":"no artifact"}`),k("small",ie.workId?`Item ${ie.workId}`:`Ungrouped · run ${Tn(ie.sessionId)}`)),ce.setAttribute("aria-label",`${ie.tool}, ${ie.status}, ${new Date(ie.startedAt).toLocaleString()}`),e.selected?.operationId===ie.operationId)ce.setAttribute("aria-current","true");if(ce.onclick=()=>{e=pb(e,ie.operationId),Hi(E(),ie.operationId),q()},L.append(ce),ne===ie.operationId)ce.focus({preventScroll:!0})}L.scrollTop=W}function N(L){let W=k("div",void 0,"evidence-card");W.append(k("h3","Capture fidelity"));let ne=L.viewFidelity,ie=ne&&typeof ne==="object"?ne:void 0;if(W.append(k("strong",ie?String(ie.delivered??"Reported"):"No capture receipt yet")),W.append(k("p",ie?.materialFaithful===!0?"Material-faithful capture reported.":ie?"Geometry evidence only. Do not use this capture to judge materials.":"The interactive viewport uses local browser lighting; it is not a recorded capture.")),ie?.degradeReason)W.append(k("p",String(ie.degradeReason)));if(ie?.rendererId)W.append(k("p",`Renderer: ${String(ie.rendererId)}`,"mono"));if(ie?.inputGlbSha256)W.append(k("p",`Capture input: ${String(ie.inputGlbSha256)}`,"mono"));if(ie)W.append(k("p",ie.exactArtifact===!0?"Receipt identifies the exact evaluated artifact.":"Capture does not claim exact artifact equivalence."));return W}function F(){let L=ue("live-evidence"),W=ue("live-downloads");L.replaceChildren(),W.replaceChildren();let ne=e.displayed;if(!ne?.artifact){x=void 0;return}let ie=k("div",void 0,"evidence-card");ie.append(k("h3","Selected observed artifact"),k("strong",`${(ne.artifact.bytes/1024).toFixed(0)} KB GLB`),k("p",ne.artifact.sha256,"mono"),k("p",`Source: ${ne.programRef??"See authored source download"}`,"mono")),L.append(ie,N(ne));let ce=`${y.value}/${ne.operationId}/${ne.artifact.sha256}`;if(x?.key!==ce){let _e=k("div",void 0,"evidence-card live-material-inspection"),Re=k("button","Inspect exact material inputs","secondary");_e.append(k("h3","Materials and atlas sheets"),k("p","Declared inputs for this displayed artifact. Raw sheets are unshaded; capture fidelity is reported separately."),Re),x={key:ce,card:_e},Re.onclick=async()=>{Re.disabled=!0;let Oe=k("p","Reading the displayed artifact evaluation…");Oe.setAttribute("role","status"),_e.append(Oe);try{let We=await un(v(`/api/live/${encodeURIComponent(ne.operationId)}/evaluation.json`));if(x?.key!==ce)return;let Ye=OR(We,ne.artifact.sha256);Oe.textContent=Ye.length?"Exact declared revisions. Map images require the matching record in this local material library.":"No saved material resource declarations in this artifact. Embedded textures can still be viewed in the viewport.";for(let Wt of Ye){let lt=k("details");lt.append(k("summary",`${Wt.name} · ${Wt.revisionId}`));let Lt=!1;lt.ontoggle=()=>{if(lt.open&&!Lt)Lt=!0,lt.append(Mf(Wt))},_e.append(lt)}}catch(We){if(x?.key!==ce)return;Oe.textContent=`Material inspection unavailable for this exact artifact: ${We instanceof Error?We.message:String(We)}`,Re.disabled=!1}}}if(L.append(x.card),ne.captures.length)for(let _e of ne.captures){let Re=k("div",void 0,"evidence-card");Re.append(k("h3",_e.name));let Oe=ne.viewFidelity&&typeof ne.viewFidelity==="object"?ne.viewFidelity:void 0;Re.append(k("p",Oe?.materialFaithful===!0?`Recorded capture · ${String(Oe.delivered??"material-faithful")}`:`Recorded capture · ${String(Oe?.delivered??"fidelity unreported")}. Materials are not verified.`,Oe?.materialFaithful===!0?"subtle":"warning"));let We=k("a"),Ye=k("img");Ye.src=_e.url,Ye.alt=`Recorded ${_e.name} for ${ne.tool}`,Ye.loading="lazy",We.href=_e.url,We.target="_blank",We.rel="noopener",We.append(Ye),Re.append(We,k("p",_e.sha256,"mono")),L.append(Re)}else{let _e=k("div",void 0,"evidence-card");_e.append(k("h3","Recorded captures"),k("p",ne.status==="evaluated"||ne.status==="running"?"Artifact is ready. Capture work may still be in progress.":"No capture image was retained for this operation.")),L.append(_e)}for(let[_e,Re,Oe]of[[ne.artifact.url,"Observed GLB","asset.glb"],[v(`/api/live/${encodeURIComponent(ne.operationId)}/source.kiln.js`),"Authored source","source.kiln.js"]]){let We=k("a",Re);We.href=_e,We.download=Oe,W.append(We)}W.append(k("p","These are the observed artifact and source. Use the saved Library revision for an editable bundle with resources or a separate runtime export. A live observation is not a saved release."))}function D(){let L=Zs(e.displayed,l);ue("pin-build").disabled=!L,Me.disabled=L?.status!=="complete"}function O(){if(d&&l)ue("live-stage-label").textContent=hb(d,Tn(l.operationId),o?.lod())}function K(){if(f&&u)ue("compare-stage-label").textContent=`Pinned · ${hb(f,Tn(u.operationId),c?.lod())}`}async function B(L){if(ue("live-panel").hidden)return;let W=++b;if(!Zs(L,l))o?.cancelMeasurement("The review selection changed. Measure the loaded revision again.");if(!L?.artifact){ue("live-performance").replaceChildren(),o?.dispose(),o=void 0,l=void 0,d=void 0,ue("live-level-field").hidden=!0,ue("live-lod").replaceChildren(),ue("live-lod").hidden=!0,ue("live-stage-status").textContent="No completed artifact available for this run.",ue("live-stage-label").textContent="Current",D();return}if(l?.artifact?.sha256===L.artifact.sha256){l=L,ue("live-stage-status").textContent="",O(),D();return}ue("live-stage-status").textContent=`Loading ${Tn(L.operationId)}…${l?` Previous artifact ${Tn(l.operationId)} remains visible; Save and Pin are unavailable until the selection loads.`:""}`;try{let ne=await fetch(L.artifact.url);if(!ne.ok)throw Error("This retained artifact is no longer available");let ie=new Uint8Array(await ne.arrayBuffer());if(W!==b)return;o??=_l(ue("live-stage"));let ce=await o.load(ie,{isCurrent:()=>W===b,onCommit:()=>{l=L},preserveView:l?.projectId===L.projectId&&(l?.sessionId===L.sessionId||e.following)});if(!ce||W!==b)return;ue("live-performance").replaceChildren(),l=L,d=ce,D();let _e=ue("live-level");if(ue("live-level-field").hidden=!ce.levels,vl(_e,ue("live-lod"),o,(Re)=>{if(Re!==void 0)c?.level(Re),h?.refresh(),K();O()}),o.wire(g),o.navigation(ue("live-navigation").value),ue("live-stage-status").textContent="",O(),c)c.setView(o.view())}catch(ne){if(W!==b)return;ue("live-stage-status").textContent=`${ne instanceof Error?ne.message:ne}.${l?` Previous artifact ${Tn(l.operationId)} remains visible. Save and Pin are unavailable for the unloaded selection.`:""}`,D()}}async function X(L){if(ue("live-panel").hidden)return;let W=++m;if(ue("compare-viewport").hidden=!L?.artifact,ue("review-viewports").classList.toggle("comparing",!!L?.artifact),!L?.artifact){c?.dispose(),c=void 0,u=void 0,f=void 0,h=void 0,ue("compare-lod").replaceChildren(),ue("compare-level-field").hidden=!0;return}if(u?.artifact?.sha256===L.artifact.sha256){u=L,K(),ue("compare-stage-status").textContent="";return}if(!u)ue("compare-stage-label").textContent="Comparison";ue("compare-stage-status").textContent=`Loading pinned ${Tn(L.operationId)}…`;try{let ne=await fetch(L.artifact.url);if(!ne.ok)throw Error("Pinned artifact unavailable");let ie=new Uint8Array(await ne.arrayBuffer());if(W!==m)return;c??=_l(ue("compare-stage"));let ce=await c.load(ie,{preserveView:!0,isCurrent:()=>W===m,onCommit:()=>{u=L}});if(!ce||W!==m)return;if(u=L,f=ce,o)c.setView(o.view());let _e=Number(ue("live-level").value||0);c.level(Number.isFinite(_e)?_e:0),ue("compare-level-field").hidden=!ce.levels,h=vl(ue("compare-level"),ue("compare-lod"),c,K),K(),c.wire(g),c.navigation(ue("live-navigation").value),ue("compare-stage-status").textContent=""}catch(ne){if(W===m)ue("compare-stage-status").textContent=`${ne instanceof Error?ne.message:String(ne)}.${u?` Previous comparison ${Tn(u.operationId)} remains visible.`:""}`}}function q(){U();let L=e.selected,W=e.displayed,ne=ue("follow-latest");ne.textContent=e.following?"Following latest":"Follow latest",ne.setAttribute("aria-pressed",String(e.following));let ie=ue("live-current-summary");if(ie.replaceChildren(),L){ie.append(k("h2",L.tool.replace(/^kiln_/,"")),k("p",`${L.status} · ${L.transport} · Run ${Tn(L.sessionId)} · ${new Date(L.updatedAt).toLocaleString()}`));let Re=k("div",void 0,"tags");if(L.projectId)Re.append(k("span",L.projectId,"tag"));for(let Oe of L.phases)Re.append(k("span",Oe.phase,"tag"));ie.append(Re)}else ie.append(k("h2","No build selected"),k("p","Run Kiln tools from your agent or CLI. Completed evaluations appear here automatically."));let ce=L&&"observationIssues"in L&&Array.isArray(L.observationIssues)?L.observationIssues.map(String):[],_e=[L?.error,...ce,L&&W&&L.operationId!==W.operationId?`Current ${L.status} operation has no retained artifact. Showing the last successful artifact ${Tn(W.operationId)} from run ${Tn(W.sessionId)}.`:"",L&&!e.operations.some((Re)=>Re.operationId===L.operationId)?"This selection is outside the current retained history. Its loaded view remains until you choose another build.":""].filter(Boolean);ue("live-failure").textContent=_e.join(" "),ue("live-failure").hidden=!_e.length,D(),ue("clear-pin").hidden=!e.pinned,ue("live-count").textContent=`${e.operations.length} retained operation${e.operations.length===1?"":"s"}`,ue("live-record").textContent=JSON.stringify({selected:L,displayedArtifactOperation:W?.operationId,pinnedOperation:e.pinned?.operationId},null,2),F(),B(W),X(e.pinned)}async function le(){if(r)return;r=!0;let L=i;try{let W=new URLSearchParams;if(_.value)W.set("project",_.value);if(n)W.set("cursor",n);let ne=await un(v(`/api/live?${W}`));if(L!==i)return;if(a=0,S(!0,"Connected · checks every 2 seconds"),n=ne.cursor,ue("live-history-note").textContent=`Up to ${ne.retention.maxOperations} operations`,ue("live-history-issues").textContent=ne.observationIssues?.join(" ")??"",ue("live-history-issues").hidden=!ne.observationIssues?.length,!ne.unchanged){if(t=ne.operations,I(),e=Ol(e,P()),!p){p=!0;let ie=As(E());if(ie&&e.operations.some((_e)=>_e.operationId===ie))e=pb(e,ie);let ce=As(w());e.pinned=t.find((_e)=>_e.operationId===ce&&_e.pinned)??[...t].reverse().find((_e)=>_e.pinned&&_e.artifact)}q()}}catch(W){a++,S(!1,`Connection lost. Retrying; retained views remain available. ${W instanceof Error?W.message:W}`)}finally{if(r=!1,s)clearTimeout(s);s=setTimeout(()=>void le(),document.hidden?1e4:Math.min(30000,2000*2**Math.min(a,4)))}}_.onchange=()=>{i++,n="",t=[],p=!1,T.replaceChildren(new Option("All runs","")),A.value="",e={following:!0,crossRunContinuity:!0,operations:[]},q(),le()},y.onchange=()=>{_.value="",e.pinned=void 0,_.dispatchEvent(new Event("change"))},un("/api/live-sources").then(({sources:L})=>{y.replaceChildren(...L.map((W)=>new Option(W.label,W.id)))}).catch(Rn),T.onchange=()=>{e=Ol({...e,selected:void 0,displayed:void 0,following:!0,crossRunContinuity:!T.value},P()),q()},A.onchange=()=>T.dispatchEvent(new Event("change")),ue("follow-latest").onclick=()=>{e=Ol({...e,following:!e.following},P()),Hi(E(),e.following?"":e.selected?.operationId??""),q()},ue("live-refresh").onclick=()=>{n="",le(),q()},ue("pin-build").onclick=async()=>{let L=Zs(e.displayed,l);if(!L?.artifact)return;let W=ue("pin-build");W.disabled=!0;try{await un(v(`/api/live/${encodeURIComponent(L.operationId)}/pin`),{method:"POST",body:{pinned:!0}}),e.pinned={...L,pinned:!0},Hi(w(),L.operationId),n="",q(),le()}catch(ne){Rn(ne),D()}},ue("clear-pin").onclick=async()=>{if(!e.pinned)return;try{await un(v(`/api/live/${encodeURIComponent(e.pinned.operationId)}/pin`),{method:"POST",body:{pinned:!1}}),e.pinned=void 0,Hi(w(),""),n="",q(),le()}catch(L){Rn(L)}},ue("live-frame").onclick=()=>{if(o?.reset(),o)c?.setView(o.view())},ue("live-wire").onclick=()=>{g=!g,o?.wire(g),c?.wire(g),ue("live-wire").setAttribute("aria-pressed",String(g))};let de=k("button","Match comparison camera","secondary");de.onclick=()=>{if(o)c?.setView(o.view())},ue("live-frame").parentElement?.append(de);let Me=k("button","Save exact artifact");Me.disabled=!0,ue("live-frame").parentElement?.prepend(Me);let pe=k("button","Measure 3 s","secondary"),J=k("div");return J.id="live-performance",ue("live-evidence").after(J),ue("live-frame").parentElement?.append(pe),Rf(pe,J,()=>o,()=>Zs(e.displayed,l)?{operationId:l.operationId,revision:l.revision,glbSha256:l.artifact?.sha256}:void 0),Me.onclick=()=>{let L=Zs(e.displayed,l);if(L?.status!=="complete")return;let W=k("dialog"),ne=k("form"),ie=k("div",void 0,"editor-content"),ce=k("h2","Save reviewed artifact");ce.id="save-review-title",W.setAttribute("aria-labelledby",ce.id),ie.append(ce,k("p","Save the exact source, GLB and recorded capture to Library. Then optionally link the saved revision to one or more named projects. Kiln will not evaluate the source again.","subtle"),k("p",`${L.operationId} · revision ${L.revision}`,"mono"),k("p",L.artifact.sha256,"mono"));let _e=k("input");_e.required=!0,_e.maxLength=200,_e.value="";let Re=k("label","Asset name","field");Re.append(_e);let Oe=k("p");Oe.setAttribute("role","status");let We=k("button","Save exact artifact");We.type="submit";let Ye=k("button","Cancel","secondary");Ye.type="button",Ye.onclick=()=>W.close(),ie.append(Re,Oe,We,Ye),ne.append(ie),W.append(ne),document.body.append(W),W.addEventListener("close",()=>W.remove()),ne.onsubmit=async(Wt)=>{Wt.preventDefault(),We.disabled=!0,Oe.textContent="Saving retained bytes…";try{let lt=FR(L,_e.value,l,e.displayed),Lt=await un(v(lt.path),{method:"POST",body:lt.body});Oe.replaceChildren(k("span",`Saved ${Lt.asset.assetId} / ${Lt.asset.revisionId}. `));let Qt=k("a","Open saved revision"),nn=new URLSearchParams({collection:Lt.collection,asset:Lt.asset.assetId,revision:Lt.asset.revisionId});Qt.href=`/?${nn}`,Oe.append(Qt);let z=k("div");ie.append(z),kl(z,{collectionId:Lt.collection,assetId:Lt.asset.assetId,revisionId:Lt.asset.revisionId},Lt.asset.name,async()=>{}).catch((yn)=>{z.textContent=`Asset saved; membership unavailable: ${yn instanceof Error?yn.message:yn}. Open the saved asset in Library to link it.`}),_e.disabled=!0,We.textContent="Saved",Ye.textContent="Close"}catch(lt){Oe.textContent=lt instanceof Error?lt.message:String(lt),We.disabled=!1}},W.showModal(),_e.focus()},ue("live-navigation").onchange=(L)=>{let W=L.target.value;o?.navigation(W),c?.navigation(W),ue("live-navigation-help").textContent=W==="explore"?"Focus a viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan · Your camera stays in place between iterations."},window.addEventListener("online",()=>{n="",le()}),document.addEventListener("visibilitychange",()=>{if(!document.hidden)le()}),le(),{activate:q,projects(L){let W=_.value;_.replaceChildren(new Option("All work",""));for(let ne of L)_.append(new Option(ne.name,ne.projectId));if(L.some((ne)=>ne.projectId===W))_.value=W}}}var gb=["projects","live","library","materials"];function BR(e,t){let n=new URLSearchParams(e);if(n.has("asset")||n.has("open"))return"library";if(Pl(e))return"materials";return t&&gb.some((i)=>i===t)?t:"library"}function zR(e,t=()=>{}){let n=gb;function i(c){if(!n.includes(c))return;for(let l of n)ue(`${l}-panel`).hidden=l!==c;for(let l of document.querySelectorAll("#workspace-nav button")){let u=l.dataset.section===c;if(l.classList.toggle("active",u),u)l.setAttribute("aria-current","page");else l.removeAttribute("aria-current")}if(Hi("kiln.section",c),c==="live")r.activate();if(c==="materials")s.refresh().catch(Rn)}for(let c of document.querySelectorAll("#workspace-nav button"))c.onclick=()=>i(c.dataset.section);ue("open-files").onclick=()=>ue("open").click();let r=UR(),s=DR(()=>a.refresh()),a=NR({changed:(c)=>{r.projects(c),s.projects(c),t(c)},openAsset:(c)=>{i("library"),e(c)}});i(BR(location.search,As("kiln.section"))),a.refresh().catch(Rn),s.refresh().catch(Rn);let o=!1;return window.setInterval(async()=>{if(document.hidden||o||ue("project-editor").open)return;o=!0;try{await a.refresh()}catch{}finally{o=!1}},5000),{library:()=>i("library"),refreshProjects:a.refresh}}var Er=(e)=>`${e.collection}/${e.manifest.assetId}`;function VR(e,t,n){if(!n)return e;if(n==="standalone"){let r=new Set(t.flatMap((s)=>s.inventory.flatMap((a)=>a.asset?[`${a.asset.collectionId}/${a.asset.assetId}`]:[])));return e.filter((s)=>!r.has(Er(s)))}let i=new Set(t.find((r)=>r.projectId===n)?.inventory.flatMap((r)=>r.asset?[`${r.asset.collectionId}/${r.asset.assetId}/${r.asset.revisionId}`]:[])??[]);return e.filter((r)=>i.has(`${Er(r)}/${r.manifest.revisionId}`))}var Ue=(e)=>document.getElementById(e),dt=(e,t,n)=>{let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i},Ul=[],Fl=[],ta=[],Ua=[],If="",Qs,Tr,An,Ys=0,jR=0,Dl=!1,Ll=!1,ea=new Set,_b=[],HR=[],Kr=(e)=>`${e.collection}/${e.manifest.assetId}/${e.manifest.revisionId}`,xb=(e)=>{Ue("status").textContent=e},Ar=(e)=>xb(e instanceof Error?e.message:String(e)),Ba=(e,t,n=_b)=>{let i=URL.createObjectURL(new Blob([Uint8Array.from(e)],{type:t}));return n.push(i),i};async function yb(e){let t=await fetch(e),n=await t.json();if(!t.ok)throw Error(n.error??"Request failed");return n}async function bb(e,t){if(e.local){let i=e.local.files[t];if(!i)throw Error("File unavailable");return i}if(e.loose&&t==="asset.glb")return e.loose;let n=await fetch(`/files/${Kr(e)}/${t}`);if(!n.ok)throw Error((await n.json()).error??"File unavailable");return new Uint8Array(await n.arrayBuffer())}function _B(e,t){if(e.local){if(t==="editable.zip")return Ba(rp([e.local]),"application/zip");return Ba(e.local.files[t],t.endsWith(".js")?"text/javascript":"model/gltf-binary")}if(e.loose)return Ba(e.loose,"model/gltf-binary");return`/files/${Kr(e)}/${t}?download`}function GR(e,t){try{localStorage.setItem(e,t)}catch{}}function vB(e){try{return localStorage.getItem(e)}catch{return null}}function EB(){let e=Ue("collections");e.replaceChildren();for(let t of[{id:"all",label:"All saved assets"},...Ul,...Ua.length?[{id:"opened-files",label:"Opened files"}]:[]]){let n=dt("button",t.label,If===t.id?"active":"");n.onclick=()=>void tc(t.id).catch(Ar),e.append(n)}}async function tc(e,t=!0){if(t)KR.library();let n=++jR;If=e,ea.clear(),EB(),xb("");let i=e==="all"?await(async()=>{let r=await yb("/api/library");if(r.errors.length)xb(r.errors.map((s)=>`${s.collectionId}: ${s.message}`).join(" · "));return r.entries.map((s)=>({collection:s.collectionId,manifest:s.manifest}))})():e==="opened-files"?Ua:(await yb(`/api/assets?collection=${encodeURIComponent(e)}`)).assets.map((r)=>({collection:e,manifest:r}));if(n!==jR)return;ta=i,GR("kiln.collection",e),Ue("collection-title").textContent=e==="all"?"Library":e==="opened-files"?"Opened files":Ul.find((r)=>r.id===e)?.label??e,Ue("collection-caption").textContent=e==="opened-files"?"Previewed in your browser. Your original files stay untouched.":"Saved assets across registered storage. Projects link exact revisions; standalone assets belong here too.",Cf()}function TB(){let e=new Map;for(let t of VR(ta,Fl,Ue("library-project").value)){let n=Er(t);e.set(n,[...e.get(n)??[],t])}return[...e.values()].map((t)=>(t.sort((n,i)=>i.manifest.createdAt.localeCompare(n.manifest.createdAt)||i.manifest.revisionId.localeCompare(n.manifest.revisionId)),t.find((n)=>n.manifest.revisionId===vB(`kiln.revision.${n.collection}.${n.manifest.assetId}`))??t[0]))}function Cf(){for(let i of HR.splice(0))URL.revokeObjectURL(i);let e=Ue("cards");e.replaceChildren();let t=Ue("search").value.toLowerCase(),n=TB().filter((i)=>`${i.manifest.name} ${i.manifest.tags.join(" ")}`.toLowerCase().includes(t));if(Ue("count").textContent=`${n.length} asset${n.length===1?"":"s"}`,Ue("export-selection").disabled=!ea.size,!n.length){let i=dt("div",void 0,"empty");if(i.append(dt("b",t?"No matching assets":"Your next idea belongs here."),dt("p",t?"Try another name or tag.":"Save an asset with your agent, or open a GLB or editable bundle.")),!t)i.append(dt("code",'kiln save asset.kiln.js --name "My asset"'));e.append(i);return}for(let i of n){let r=i.manifest,s=dt("article",void 0,"card"),a=dt("button",void 0,"card-open");a.setAttribute("aria-label",`View ${r.name}`),a.onclick=()=>void Bl(i).catch(Ar);let o=dt("div",void 0,"thumb");if(r.files["preview.png"]){let b=dt("img");b.loading="lazy",b.alt=r.name,b.src=i.local?Ba(i.local.files["preview.png"],"image/png",HR):`/files/${Kr(i)}/preview.png`,b.onerror=()=>{b.remove(),o.textContent="◇"},o.append(b)}else o.textContent="◇";let c=dt("div",void 0,"card-content");c.append(dt("span",r.name,"card-title"));let l=ta.filter((b)=>Er(b)===Er(i)),u=new Set(l.map((b)=>b.manifest.parentRevision)),d=l.filter((b)=>!u.has(b.manifest.revisionId));c.append(dt("span",`${r.editable?"Editable source":"Source unavailable"} · ${l.length} revision${l.length===1?"":"s"}${d.length>1?` · ${d.length} branches`:""}`,"card-meta"));let f=dt("div",void 0,"tags");for(let b of r.tags)f.append(dt("span",b,"tag"));c.append(f),c.append(dt("small",Ul.find((b)=>b.id===i.collection)?.label??i.collection,"card-meta"));let h=Fl.filter((b)=>b.inventory.some((m)=>m.asset&&m.asset.collectionId===i.collection&&m.asset.assetId===r.assetId));if(c.append(dt("small",h.length?h.map((b)=>b.name).join(" · "):"No project membership","card-meta")),a.append(o,c),s.append(a),!i.loose){let b=dt("input");b.type="checkbox",b.className="selection",b.checked=ea.has(Kr(i)),b.setAttribute("aria-label",`Select ${r.name}`),b.onchange=()=>{if(b.checked)ea.add(Kr(i));else ea.delete(Kr(i));Ue("export-selection").disabled=!ea.size},s.append(b)}e.append(s)}}async function Bl(e){let t=++Ys;Qs=e,Tr=void 0,An?.cancelMeasurement("The Library selection changed. Measure the loaded revision again."),Ue("library-performance").replaceChildren(),GR(`kiln.revision.${e.collection}.${e.manifest.assetId}`,e.manifest.revisionId);for(let u of _b.splice(0))URL.revokeObjectURL(u);let n=Ue("detail");if(!n.open)n.showModal();Ue("asset-name").textContent=e.manifest.name;let i=Ue("asset-membership");if(i.replaceChildren(),!e.local&&!e.loose){let u=dt("div");i.append(u),kl(u,{collectionId:e.collection,assetId:e.manifest.assetId,revisionId:e.manifest.revisionId},e.manifest.name,KR.refreshProjects).catch(Ar)}let r=Ue("revisions");r.replaceChildren();for(let u of ta.filter((d)=>Er(d)===Er(e))){let d=dt("option",`${new Date(u.manifest.createdAt).toLocaleString()} · ${u.manifest.description||u.manifest.revisionId.slice(0,10)}`);d.value=u.manifest.revisionId,d.selected=u.manifest.revisionId===e.manifest.revisionId,r.append(d)}r.onchange=()=>{let u=ta.find((d)=>Er(d)===Er(e)&&d.manifest.revisionId===r.value);if(u)Bl(u).catch(Ar)},Ue("asset-description").textContent=e.manifest.description??e.manifest.brief??(e.manifest.editable?"Source travels with this revision. Download the editable bundle to continue elsewhere.":"This GLB has no saved Kiln source. You can view and use the model.");let s=Ue("asset-attribution");s.replaceChildren();for(let u of lE(e.manifest)){let d=dt("div");d.append(dt("span",u.label),dt("strong",u.value)),s.append(d)}s.hidden=!s.childElementCount;let a=document.getElementById("asset-material-inputs");if(!a)a=dt("section",void 0,"asset-material-inputs"),a.id="asset-material-inputs",s.after(a);a.replaceChildren();try{let u=kc({manifest:e.manifest,files:{}});if(u.length){a.append(dt("h3","Exact material build inputs"),dt("p","Open the saved revision to inspect its raw maps, sampling declaration and atlas regions. Declared inputs do not prove every map was used.","subtle"));for(let d of u){let f=dt("a",`${d.name} · ${d.materialId}`);f.href=Sf(d),f.target="_blank",f.rel="noopener",a.append(f,dt("p",d.revisionId,"mono"))}}}catch(u){a.append(dt("p",`Material revision links unavailable: ${u instanceof Error?u.message:String(u)}`,"subtle"))}Ue("provenance").textContent=e.loose?"Standalone GLB. No source or build provenance supplied.":JSON.stringify(e.manifest,null,2);let o=Ue("downloads");o.replaceChildren();for(let[u,d]of[["asset.glb","Original GLB"],...e.manifest.editable?[["source.kiln.js","Download source"]]:[],...!e.loose?[["editable.zip",e.manifest.editable?"Download editable bundle":"Download asset bundle"]]:[]]){let f=dt("a",d);f.href=_B(e,u),f.download=`${e.manifest.name.replace(/[^a-z0-9_-]/gi,"-")}${u==="asset.glb"?".glb":u==="source.kiln.js"?".kiln.js":".zip"}`,o.append(f)}if(!e.loose){let u=dt("button","Runtime GLB"),d=dt("span");d.setAttribute("role","status"),u.onclick=async()=>{u.disabled=!0,d.textContent="Preparing runtime download…";try{let f=e.local?await ER(e.local,{profile:"runtime"}):void 0,[h,b]=f?.profile==="runtime"?[f.glb,f.metadata.bytes]:await Promise.all([bb(e,"runtime.glb"),bb(e,"runtime.kiln-metadata.json")]);if(t!==Ys)return;let m=dt("a","Runtime GLB");m.href=Ba(h,"model/gltf-binary"),m.download="runtime.glb";let g=dt("a","Runtime metadata");g.href=Ba(b,"application/json"),g.download="runtime.kiln-metadata.json",u.replaceWith(m,g),d.textContent="Keep the companion metadata for traceability.",m.click()}catch(f){if(t!==Ys)return;d.textContent=`Runtime export unavailable: ${f instanceof Error?f.message:f}`,u.disabled=!1}},o.append(u,d),o.append(dt("p","Original GLB retains Kiln review data. Runtime GLB moves duplicate animation-review data into a companion JSON file; geometry and textures are unchanged. Keep the editable bundle for source and build records."))}Ue("refine").disabled=!e.manifest.editable,Ue("asset-stats").replaceChildren(),Ue("stage-status").textContent="Loading saved GLB…",Dl=!1,Ll=!1,Ue("wire").setAttribute("aria-pressed","false"),Ue("play").textContent="Pause";let c=Ue("animation");c.replaceChildren(new Option("Rest pose","")),Ue("play").disabled=!0;let l=Ue("level");l.replaceChildren(),l.hidden=!0,Ue("library-lod").replaceChildren(),Ue("library-lod").hidden=!0;try{An??=_l(Ue("stage"));let u=await bb(e,"asset.glb");if(t!==Ys)return;let d=await An.load(u,{isCurrent:()=>t===Ys,onCommit:()=>{Tr=e}});if(!d||t!==Ys)return;Tr=e,An.wire(!1),An.navigation(Ue("library-navigation").value),An.lighting(Ue("lighting").value),vl(l,Ue("library-lod"),An);for(let[f,h]of[...d.levels?d.levels.map((b,m)=>[b.toLocaleString(),`LOD${m} triangles`]):[[d.triangles.toLocaleString(),"triangles"]],[d.meshes,d.levels?"LOD0 meshes":"meshes"],[d.materials,d.levels?"LOD0 materials":"materials"],[`${(u.length/1024).toFixed(0)} KB`,"GLB"]]){let b=dt("div");b.append(dt("strong",String(f)),dt("span",String(h))),Ue("asset-stats").append(b)}for(let f=0;f<d.clips.length;f++)c.append(new Option(d.clips[f],String(f)));Ue("stage-status").textContent=""}catch(u){if(t===Ys)An?.dispose(),An=void 0,Ue("stage-status").textContent=`3D preview unavailable: ${u instanceof Error?u.message:u}. Downloads remain available.`}}async function $R(e){for(let t of e){if(t.bytes.length>Kn)throw Error("File exceeds 64 MiB");if(t.name.toLowerCase().endsWith(".zip"))for(let n of cE(t.bytes)){for(let[i,r]of Object.entries(n.files))if(`sha256:${Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",Uint8Array.from(r)))).map((a)=>a.toString(16).padStart(2,"0")).join("")}`!==n.manifest.files[i]?.sha256)throw Error(`Bundle integrity failure: ${i}`);if(!Ua.some((i)=>i.manifest.revisionId===n.manifest.revisionId&&i.manifest.assetId===n.manifest.assetId))Ua.push({collection:"opened-files",manifest:n.manifest,local:n})}else{let n=`a_${crypto.randomUUID().replaceAll("-","")}`;Ua.push({collection:"opened-files",loose:t.bytes,manifest:{version:"kiln.asset.v1",assetId:n,revisionId:`r_${n}`,name:t.name.replace(/\.glb$/i,""),tags:[],createdAt:new Date().toISOString(),editable:!1,files:{}}})}}await tc("opened-files")}Ue("open").onchange=async(e)=>{try{let t=Array.from(e.target.files??[]);if(t.some((n)=>n.size>Kn))throw Error("File exceeds 64 MiB");await $R(await Promise.all(t.map(async(n)=>({name:n.name,bytes:new Uint8Array(await n.arrayBuffer())}))))}catch(t){Ar(t)}};Ue("refresh").onclick=()=>void tc(If).catch(Ar);Ue("search").oninput=Cf;Ue("library-project").onchange=()=>void tc("all").catch(Ar);Ue("close-detail").onclick=()=>Ue("detail").close();Ue("detail").addEventListener("close",()=>{Ys++,Tr=void 0,An?.dispose(),An=void 0;for(let e of _b.splice(0))URL.revokeObjectURL(e);Cf()});Ue("frame").onclick=()=>An?.reset();Ue("wire").onclick=()=>{Dl=!Dl,An?.wire(Dl),Ue("wire").setAttribute("aria-pressed",String(Dl))};Ue("lighting").onchange=(e)=>An?.lighting(e.target.value);Ue("library-navigation").onchange=(e)=>{let t=e.target.value;An?.navigation(t),Ue("library-navigation-help").textContent=t==="explore"?"Focus the viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan"};Ue("animation").onchange=(e)=>{let t=e.target.value;An?.clip(t===""?-1:Number(t)),Ue("play").disabled=t===""};Ue("play").onclick=()=>{Ll=!Ll,An?.pause(Ll),Ue("play").textContent=Ll?"Play":"Pause"};Ue("refine").onclick=async()=>{if(!Qs)return;let e=Qs.manifest,t=Qs.local?`Import the downloaded editable bundle using kiln import <bundle.zip>. Restore asset ${e.assetId}, revision ${e.revisionId}, using kiln_assets action=restore. Read its source with kiln_source, refine it with kiln_edit, review the result, and save a child revision with kiln_save. Requested change: `:`Use kiln_assets with action=restore, collection=${Qs.collection}, assetId=${e.assetId}, revisionId=${e.revisionId}. Read the returned programRef with kiln_source, refine it with kiln_edit, review the result, and save with kiln_save using assetId=${e.assetId}, parentRevision=${e.revisionId}, collection=${Qs.collection}. Requested change: `;try{await navigator.clipboard.writeText(t),Ue("refine").textContent="Instructions copied"}catch{Ue("provenance").textContent=t,Ue("provenance").parentElement?.setAttribute("open","")}};Ue("export-selection").onclick=()=>{try{let e=dt("a");if(If==="opened-files")e.href=Ba(rp(ta.filter((t)=>ea.has(Kr(t))).map((t)=>t.local)),"application/zip");else{let t=new URLSearchParams;for(let n of ea)t.append("revision",n);e.href=`/api/bundle?${t}`}e.download="kiln-assets.zip",e.click()}catch(e){Ar(e)}};async function AB(){Ul=(await yb("/api/collections")).collections;let e=Mw(location.search);if(await tc(Ul.find((t)=>t.id===e?.collection)?.id??"all",!1),e){let t=ta.find((n)=>n.collection===e.collection&&n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The requested saved revision is not available.");await Bl(t)}if(new URLSearchParams(location.search).has("open")){let t=await fetch("/api/standalone");if(!t.ok)throw Error("File unavailable");if(await $R([{name:t.headers.get("Content-Type")?.includes("zip")?"asset.zip":"asset.glb",bytes:new Uint8Array(await t.arrayBuffer())}]),Ua.length===1)await Bl(Ua[0])}}var KR=zR((e)=>{(async()=>{await tc(e.collectionId);let t=ta.find((n)=>n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The linked saved revision is not available in this collection.");await Bl(t)})().catch(Ar)},(e)=>{Fl=e;let t=Ue("library-project"),n=t.value;t.replaceChildren(new Option("All projects and standalone",""),new Option("Standalone assets","standalone"));for(let i of Fl)t.append(new Option(i.name,i.projectId));if(n==="standalone"||Fl.some((i)=>i.projectId===n))t.value=n;Cf()});Rf(Ue("measure-library"),Ue("library-performance"),()=>An,()=>Tr&&Qs&&Kr(Tr)===Kr(Qs)?{collection:Tr.collection,assetId:Tr.manifest.assetId,revisionId:Tr.manifest.revisionId,glbSha256:Tr.manifest.files["asset.glb"]?.sha256}:void 0);AB().catch(Ar);diff --git a/dist/viewer/chat.html b/dist/viewer/chat.htmlindex c4df88ee..6739f2ba 100644--- a/dist/viewer/chat.html+++ b/dist/viewer/chat.html@@ -122,13 +122,13 @@</div><p id="status" role="status">Loading asset from Kiln…</p><script type="module">- var lp="186",cr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},lr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},up=0,Yl=1,hp=2;var go=1,dp=2,Ms=3,ur=0,sn=1,kn=2,di=0,_o=1,Jl=2,Kl=3,Ql=4,fp=5;var ws=100,pp=101,mp=102,gp=103,_p=104,xp=200,yp=201,vp=202,bp=203,Sp=204,Mp=205,wp=206,Ep=207,Ap=208,Tp=209,Rp=210,Cp=211,Pp=212,Ip=213,Lp=214,Np=0,Dp=1,Op=2,eu=3,Up=4,Fp=5,zp=6,kp=7,Bp=0,Vp=1,Gp=2,Jn=0,tu=1,nu=2,iu=3,xo=4,ru=5,su=6,ou=7;var Es=301,Or=302,Ya=303,Ja=304,yo=306,As=1000,Ts=1001,Ka=1002,Kn=1003,Qa=1004;var Ur=1005;var qt=1006,Rs=1007;var fi=1008;var Qn=1009,Hp=1010,$p=1011,vo=1012,au=1013,hr=1014,Gi=1015,pi=1016,cu=1017,lu=1018,Cs=1020,Wp=35902,Zp=35899,Xp=1021,jp=1022,mi=1023,Fr=1026,zr=1027,qp=1028,uu=1029,kr=1030,hu=1031;var du=1033,ec=33776,tc=33777,nc=33778,ic=33779,fu=35840,pu=35841,mu=35842,gu=35843,_u=36196,xu=37492,yu=37496,vu=37488,bu=37489,rc=37490,Su=37491,Mu=37808,wu=37809,Eu=37810,Au=37811,Tu=37812,Ru=37813,Cu=37814,Pu=37815,Iu=37816,Lu=37817,Nu=37818,Du=37819,Ou=37820,Uu=37821,Fu=36492,zu=36494,ku=36495,Bu=36283,Vu=36284,sc=36285,Gu=36286;var Hu=2300,oc=2301;var $u=0,bo=1,Ps=2;var Wu=0,Yp=1,Br="",dr="srgb",Mn="srgb-linear",Zu="linear",yt="srgb";var Jp=512,Kp=513,Qp=514,ac=515,em=516,tm=517,cc=518,nm=519;var Xu="300 es",ju=2000;function Lb(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Nb(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function vs(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function im(){let e=vs("canvas");return e.style.display="block",e}var Af={},bs=null;function mo(...e){let t="THREE."+e.shift();if(bs)bs("log",t,...e);else console.log(t,...e)}function rm(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Le(...e){e=rm(e);let t="THREE."+e.shift();if(bs)bs("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function ke(...e){e=rm(e);let t="THREE."+e.shift();if(bs)bs("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function Nr(...e){let t=e.join(" ");if(t in Af)return;Af[t]=!0,Le(...e)}function sm(e,t,n){return new Promise(function(i,r){function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}var om={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ei{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}var nn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Tf=1234567,fo=Math.PI/180,Dr=180/Math.PI;function Yn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(nn[e&255]+nn[e>>8&255]+nn[e>>16&255]+nn[e>>24&255]+"-"+nn[t&255]+nn[t>>8&255]+"-"+nn[t>>16&15|64]+nn[t>>24&255]+"-"+nn[n&63|128]+nn[n>>8&255]+"-"+nn[n>>16&255]+nn[n>>24&255]+nn[i&255]+nn[i>>8&255]+nn[i>>16&255]+nn[i>>24&255]).toLowerCase()}function qe(e,t,n){return Math.max(t,Math.min(n,e))}function qu(e,t){return(e%t+t)%t}function Db(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function Ob(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function po(e,t,n){return(1-n)*e+n*t}function Ub(e,t,n,i){return po(e,t,1-Math.exp(-n*i))}function Fb(e,t=1){return t-Math.abs(qu(e,t*2)-t)}function zb(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*(3-2*e)}function kb(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10)}function Bb(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Vb(e,t){return e+Math.random()*(t-e)}function Gb(e){return e*(0.5-Math.random())}function Hb(e){if(e!==void 0)Tf=e;let t=Tf+=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 $b(e){return e*fo}function Wb(e){return e*Dr}function Zb(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function Xb(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function jb(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function qb(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),d=s((t-i)/2),h=o((t-i)/2),f=s((i-t)/2),m=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*d,c*h,a*l);break;case"YZY":e.set(c*h,a*u,c*d,a*l);break;case"ZXZ":e.set(c*d,c*h,a*u,a*l);break;case"XZX":e.set(a*u,c*m,c*f,a*l);break;case"YXY":e.set(c*f,a*u,c*m,a*l);break;case"ZYZ":e.set(c*m,c*f,a*u,a*l);break;default:Le("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function qn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function dt(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var So={DEG2RAD:fo,RAD2DEG:Dr,generateUUID:Yn,clamp:qe,euclideanModulo:qu,mapLinear:Db,inverseLerp:Ob,lerp:po,damp:Ub,pingpong:Fb,smoothstep:zb,smootherstep:kb,randInt:Bb,randFloat:Vb,randFloatSpread:Gb,seededRandom:Hb,degToRad:$b,radToDeg:Wb,isPowerOfTwo:Zb,ceilPowerOfTwo:Xb,floorPowerOfTwo:jb,setQuaternionFromProperEuler:qb,normalize:dt,denormalize:qn};class Ue{static{Ue.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(qe(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Xt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],d=r[s+0],h=r[s+1],f=r[s+2],m=r[s+3];if(u!==m||a!==d||c!==h||l!==f){let _=a*d+c*h+l*f+u*m;if(_<0)d=-d,h=-h,f=-f,m=-m,_=-_;let p=1-o;if(_<0.9995){let g=Math.acos(_),S=Math.sin(g);p=Math.sin(p*g)/S,o=Math.sin(o*g)/S,a=a*p+d*o,c=c*p+h*o,l=l*p+f*o,u=u*p+m*o}else{a=a*p+d*o,c=c*p+h*o,l=l*p+f*o,u=u*p+m*o;let g=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=g,c*=g,l*=g,u*=g}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],d=r[s+1],h=r[s+2],f=r[s+3];return e[t]=o*f+l*u+a*h-c*d,e[t+1]=a*f+l*d+c*u-o*h,e[t+2]=c*f+l*h+o*d-a*u,e[t+3]=l*f-o*u-a*d-c*h,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),d=a(n/2),h=a(i/2),f=a(r/2);switch(s){case"XYZ":this._x=d*l*u+c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u-d*h*f;break;case"YXZ":this._x=d*l*u+c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u+d*h*f;break;case"ZXY":this._x=d*l*u-c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u-d*h*f;break;case"ZYX":this._x=d*l*u-c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u+d*h*f;break;case"YZX":this._x=d*l*u+c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u-d*h*f;break;case"XZY":this._x=d*l*u-c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u+d*h*f;break;default:Le("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let h=0.5/Math.sqrt(d+1);this._w=0.25/h,this._x=(l-a)*h,this._y=(r-c)*h,this._z=(s-i)*h}else if(n>o&&n>u){let h=2*Math.sqrt(1+n-o-u);this._w=(l-a)/h,this._x=0.25*h,this._y=(i+s)/h,this._z=(r+c)/h}else if(o>u){let h=2*Math.sqrt(1+o-n-u);this._w=(r-c)/h,this._x=(i+s)/h,this._y=0.25*h,this._z=(a+l)/h}else{let h=2*Math.sqrt(1+u-n-o);this._w=(s-i)/h,this._x=(r+c)/h,this._y=(a+l)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(qe(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:o,_y:a,_z:c,_w:l}=t;return this._x=n*l+s*o+i*c-r*a,this._y=i*l+s*a+r*o-n*c,this._z=r*l+s*c+n*a-i*o,this._w=s*l-n*o-i*a-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,o=this.dot(e);if(o<0)n=-n,i=-i,r=-r,s=-s,o=-o;let a=1-t;if(o<0.9995){let c=Math.acos(o),l=Math.sin(c);a=Math.sin(a*c)/l,t=Math.sin(t*c)/l,this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this._onChangeCallback()}else this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class U{static{U.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Rf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Rf.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:o,w:a}=e,c=2*(s*i-o*n),l=2*(o*t-r*i),u=2*(r*n-s*t);return this.x=t+a*c+s*u-o*l,this.y=n+a*l+o*c-r*u,this.z=i+a*u+r*l-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:o,z:a}=t;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return El.copy(this).projectOnVector(e),this.sub(El)}reflect(e){return this.sub(El.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(qe(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var El=new U,Rf=new Xt;class Ve{static{Ve.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],d=n[2],h=n[5],f=n[8],m=i[0],_=i[3],p=i[6],g=i[1],S=i[4],T=i[7],y=i[2],w=i[5],A=i[8];return r[0]=s*m+o*g+a*y,r[3]=s*_+o*S+a*w,r[6]=s*p+o*T+a*A,r[1]=c*m+l*g+u*y,r[4]=c*_+l*S+u*w,r[7]=c*p+l*T+u*A,r[2]=d*m+h*g+f*y,r[5]=d*_+h*S+f*w,r[8]=d*p+h*T+f*A,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,d=o*a-l*r,h=c*r-s*a,f=t*u+n*d+i*h;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/f;return e[0]=u*m,e[1]=(i*c-l*n)*m,e[2]=(o*n-i*s)*m,e[3]=d*m,e[4]=(l*t-i*a)*m,e[5]=(i*r-o*t)*m,e[6]=h*m,e[7]=(n*a-c*t)*m,e[8]=(s*t-n*r)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return Nr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Al.makeScale(e,t)),this}rotate(e){return Nr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Al.makeRotation(-e)),this}translate(e,t){return Nr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Al.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}var Al=new Ve,Cf=new Ve().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Pf=new Ve().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function Yb(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,o){if(this.enabled===!1||s===o||!s||!o)return r;if(this.spaces[s].transfer==="srgb")r.r=Vi(r.r),r.g=Vi(r.g),r.b=Vi(r.b);if(this.spaces[s].primaries!==this.spaces[o].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ);if(this.spaces[o].transfer==="srgb")r.r=ys(r.r),r.g=ys(r.g),r.b=ys(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Nr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Nr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(r,s)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:Cf,fromXYZ:Pf,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Cf,fromXYZ:Pf,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var je=Yb();function Vi(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function ys(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var ss;class Yu{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(ss===void 0)ss=vs("canvas");ss.width=e.width,ss.height=e.height;let i=ss.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=ss}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=vs("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Vi(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Vi(t[n]/255)*255);else t[n]=Vi(t[n]);return{data:t,width:e.width,height:e.height}}else return Le("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var Jb=0;class Mo{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Jb++}),this.uuid=Yn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)if(i[s].isDataTexture)r.push(Tl(i[s].image));else r.push(Tl(i[s]))}else r=Tl(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Tl(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return Yu.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Le("Texture: Unable to serialize Texture."),{}}var Kb=0,Rl=new U;class Nt extends ei{constructor(e=Nt.DEFAULT_IMAGE,t=Nt.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Nt.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:Kb++}),this.uuid=Yn(),this.name="",this.source=new Mo(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new Ue(0,0),this.repeat=new Ue(1,1),this.center=new Ue(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ve,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Rl).x}get height(){return this.source.getSize(Rl).y}get depth(){return this.source.getSize(Rl).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Le(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Le(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}Nt.DEFAULT_IMAGE=null;Nt.DEFAULT_MAPPING=300;Nt.DEFAULT_ANISOTROPY=1;class ft{static{ft.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],d=a[1],h=a[5],f=a[9],m=a[2],_=a[6],p=a[10];if(Math.abs(l-d)<0.01&&Math.abs(u-m)<0.01&&Math.abs(f-_)<0.01){if(Math.abs(l+d)<0.1&&Math.abs(u+m)<0.1&&Math.abs(f+_)<0.1&&Math.abs(c+h+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let S=(c+1)/2,T=(h+1)/2,y=(p+1)/2,w=(l+d)/4,A=(u+m)/4,R=(f+_)/4;if(S>T&&S>y)if(S<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(S),i=w/n,r=A/n;else if(T>y)if(T<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(T),n=w/i,r=R/i;else if(y<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(y),n=A/r,i=R/r;return this.set(n,i,r,t),this}let g=Math.sqrt((_-f)*(_-f)+(u-m)*(u-m)+(d-l)*(d-l));if(Math.abs(g)<0.001)g=1;return this.x=(_-f)/g,this.y=(u-m)/g,this.z=(d-l)/g,this.w=Math.acos((c+h+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this.w=qe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this.w=qe(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Ju extends ei{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ft(0,0,e,t),this.scissorTest=!1,this.viewport=new ft(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Nt(i),s=n.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new Mo(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class wn extends Ju{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class lc extends Nt{constructor(e=null,t=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Ku extends Nt{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class $e{static{$e.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,d,h,f,m,_){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c,l,u,d,h,f,m,_)}set(e,t,n,i,r,s,o,a,c,l,u,d,h,f,m,_){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=d,p[3]=h,p[7]=f,p[11]=m,p[15]=_,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 $e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/os.setFromMatrixColumn(e,0).length(),r=1/os.setFromMatrixColumn(e,1).length(),s=1/os.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let d=s*l,h=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=h+f*c,t[5]=d-m*c,t[9]=-o*a,t[2]=m-d*c,t[6]=f+h*c,t[10]=s*a}else if(e.order==="YXZ"){let d=a*l,h=a*u,f=c*l,m=c*u;t[0]=d+m*o,t[4]=f*o-h,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=h*o-f,t[6]=m+d*o,t[10]=s*a}else if(e.order==="ZXY"){let d=a*l,h=a*u,f=c*l,m=c*u;t[0]=d-m*o,t[4]=-s*u,t[8]=f+h*o,t[1]=h+f*o,t[5]=s*l,t[9]=m-d*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let d=s*l,h=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=f*c-h,t[8]=d*c+m,t[1]=a*u,t[5]=m*c+d,t[9]=h*c-f,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let d=s*a,h=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=m-d*u,t[8]=f*u+h,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=h*u+f,t[10]=d-m*u}else if(e.order==="XZY"){let d=s*a,h=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=d*u+m,t[5]=s*l,t[9]=h*u-f,t[2]=f*u-h,t[6]=o*l,t[10]=m*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Qb,e,eS)}lookAt(e,t,n){let i=this.elements;if(bn.subVectors(e,t),bn.lengthSq()===0)bn.z=1;if(bn.normalize(),tr.crossVectors(n,bn),tr.lengthSq()===0){if(Math.abs(n.z)===1)bn.x+=0.0001;else bn.z+=0.0001;bn.normalize(),tr.crossVectors(n,bn)}return tr.normalize(),Sa.crossVectors(bn,tr),i[0]=tr.x,i[4]=Sa.x,i[8]=bn.x,i[1]=tr.y,i[5]=Sa.y,i[9]=bn.y,i[2]=tr.z,i[6]=Sa.z,i[10]=bn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],d=n[9],h=n[13],f=n[2],m=n[6],_=n[10],p=n[14],g=n[3],S=n[7],T=n[11],y=n[15],w=i[0],A=i[4],R=i[8],x=i[12],M=i[1],z=i[5],C=i[9],L=i[13],K=i[2],I=i[6],G=i[10],X=i[14],P=i[3],j=i[7],k=i[11],q=i[15];return r[0]=s*w+o*M+a*K+c*P,r[4]=s*A+o*z+a*I+c*j,r[8]=s*R+o*C+a*G+c*k,r[12]=s*x+o*L+a*X+c*q,r[1]=l*w+u*M+d*K+h*P,r[5]=l*A+u*z+d*I+h*j,r[9]=l*R+u*C+d*G+h*k,r[13]=l*x+u*L+d*X+h*q,r[2]=f*w+m*M+_*K+p*P,r[6]=f*A+m*z+_*I+p*j,r[10]=f*R+m*C+_*G+p*k,r[14]=f*x+m*L+_*X+p*q,r[3]=g*w+S*M+T*K+y*P,r[7]=g*A+S*z+T*I+y*j,r[11]=g*R+S*C+T*G+y*k,r[15]=g*x+S*L+T*X+y*q,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],d=e[10],h=e[14],f=e[3],m=e[7],_=e[11],p=e[15],g=a*h-c*d,S=o*h-c*u,T=o*d-a*u,y=s*h-c*l,w=s*d-a*l,A=s*u-o*l;return t*(m*g-_*S+p*T)-n*(f*g-_*y+p*w)+i*(f*S-m*y+p*A)-r*(f*T-m*w+_*A)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],d=e[10],h=e[11],f=e[12],m=e[13],_=e[14],p=e[15],g=t*o-n*s,S=t*a-i*s,T=t*c-r*s,y=n*a-i*o,w=n*c-r*o,A=i*c-r*a,R=l*m-u*f,x=l*_-d*f,M=l*p-h*f,z=u*_-d*m,C=u*p-h*m,L=d*p-h*_,K=g*L-S*C+T*z+y*M-w*x+A*R;if(K===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let I=1/K;return e[0]=(o*L-a*C+c*z)*I,e[1]=(i*C-n*L-r*z)*I,e[2]=(m*A-_*w+p*y)*I,e[3]=(d*w-u*A-h*y)*I,e[4]=(a*M-s*L-c*x)*I,e[5]=(t*L-i*M+r*x)*I,e[6]=(_*T-f*A-p*S)*I,e[7]=(l*A-d*T+h*S)*I,e[8]=(s*C-o*M+c*R)*I,e[9]=(n*M-t*C-r*R)*I,e[10]=(f*w-m*T+p*g)*I,e[11]=(u*T-l*w-h*g)*I,e[12]=(o*x-s*z-a*R)*I,e[13]=(t*z-n*x+i*R)*I,e[14]=(m*S-f*y-_*g)*I,e[15]=(l*y-u*S+d*g)*I,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,d=r*c,h=r*l,f=r*u,m=s*l,_=s*u,p=o*u,g=a*c,S=a*l,T=a*u,{x:y,y:w,z:A}=n;return i[0]=(1-(m+p))*y,i[1]=(h+T)*y,i[2]=(f-S)*y,i[3]=0,i[4]=(h-T)*w,i[5]=(1-(d+p))*w,i[6]=(_+g)*w,i[7]=0,i[8]=(f+S)*A,i[9]=(_-g)*A,i[10]=(1-(d+m))*A,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=os.set(i[0],i[1],i[2]).length(),o=os.set(i[4],i[5],i[6]).length(),a=os.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Zn.copy(this);let c=1/s,l=1/o,u=1/a;return Zn.elements[0]*=c,Zn.elements[1]*=c,Zn.elements[2]*=c,Zn.elements[4]*=l,Zn.elements[5]*=l,Zn.elements[6]*=l,Zn.elements[8]*=u,Zn.elements[9]*=u,Zn.elements[10]*=u,t.setFromRotationMatrix(Zn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),d=(t+e)/(t-e),h=(n+i)/(n-i),f,m;if(a)f=r/(s-r),m=s*r/(s-r);else if(o===2000)f=-(s+r)/(s-r),m=-2*s*r/(s-r);else if(o===2001)f=-s/(s-r),m=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),d=-(t+e)/(t-e),h=-(n+i)/(n-i),f,m;if(a)f=1/(s-r),m=s/(s-r);else if(o===2000)f=-2/(s-r),m=-(s+r)/(s-r);else if(o===2001)f=-1/(s-r),m=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=h,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var os=new U,Zn=new $e,Qb=new U(0,0,0),eS=new U(1,1,1),tr=new U,Sa=new U,bn=new U,If=new $e,Lf=new Xt;class hi{constructor(e=0,t=0,n=0,i=hi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],d=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin(qe(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,h),this._z=Math.atan2(-s,r);else this._x=Math.atan2(d,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-qe(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(o,h),this._z=Math.atan2(a,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(qe(d,-1,1)),Math.abs(d)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-qe(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(d,h),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(qe(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(o,h);break;case"XZY":if(this._z=Math.asin(-qe(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(d,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,h),this._y=0;break;default:Le("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return If.makeRotationFromQuaternion(e),this.setFromRotationMatrix(If,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Lf.setFromEuler(this),this.setFromQuaternion(Lf,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}hi.DEFAULT_ORDER="XYZ";class uc{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}var tS=0,Nf=new U,as=new Xt,Oi=new $e,Ma=new U,ro=new U,nS=new U,iS=new Xt,Df=new U(1,0,0),Of=new U(0,1,0),Uf=new U(0,0,1),Ff={type:"added"},rS={type:"removed"},cs={type:"childadded",child:null},Cl={type:"childremoved",child:null};class gt extends ei{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:tS++}),this.uuid=Yn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=gt.DEFAULT_UP.clone();let e=new U,t=new hi,n=new Xt,i=new U(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new $e},normalMatrix:{value:new Ve}}),this.matrix=new $e,this.matrixWorld=new $e,this.matrixAutoUpdate=gt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new uc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return as.setFromAxisAngle(e,t),this.quaternion.multiply(as),this}rotateOnWorldAxis(e,t){return as.setFromAxisAngle(e,t),this.quaternion.premultiply(as),this}rotateX(e){return this.rotateOnAxis(Df,e)}rotateY(e){return this.rotateOnAxis(Of,e)}rotateZ(e){return this.rotateOnAxis(Uf,e)}translateOnAxis(e,t){return Nf.copy(e).applyQuaternion(this.quaternion),this.position.add(Nf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Df,e)}translateY(e){return this.translateOnAxis(Of,e)}translateZ(e){return this.translateOnAxis(Uf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Oi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)Ma.copy(e);else Ma.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),ro.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Oi.lookAt(ro,Ma,this.up);else Oi.lookAt(Ma,ro,this.up);if(this.quaternion.setFromRotationMatrix(Oi),i)Oi.extractRotation(i.matrixWorld),as.setFromRotationMatrix(Oi),this.quaternion.premultiply(as.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return ke("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Ff),cs.child=e,this.dispatchEvent(cs),cs.child=null;else ke("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(rS),Cl.child=e,this.dispatchEvent(Cl),Cl.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),Oi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Oi.multiply(e.parent.matrixWorld);return e.applyMatrix4(Oi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ff),cs.child=e,this.dispatchEvent(cs),cs.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ro,e,nS),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ro,iS,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),d=s(e.skeletons),h=s(e.animations),f=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(d.length>0)n.skeletons=d;if(h.length>0)n.animations=h;if(f.length>0)n.nodes=f}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}gt.DEFAULT_UP=new U(0,1,0);gt.DEFAULT_MATRIX_AUTO_UPDATE=!0;gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class li extends gt{constructor(){super();this.isGroup=!0,this.type="Group"}}var sS={type:"move"};class wo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new li,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new li,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new li,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,o=this._targetRay,a=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let m of e.hand.values()){let _=t.getJointPose(m,n),p=this._getHandJoint(c,m);if(_!==null)p.matrix.fromArray(_.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=_.radius;p.visible=_!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=l.position.distanceTo(u.position),h=0.02,f=0.005;if(c.inputState.pinching&&d>h+f)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&d<=h-f)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(sS)}}}if(o!==null)o.visible=i!==null;if(a!==null)a.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new li;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var am={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},nr={h:0,s:0,l:0},wa={h:0,s:0,l:0};function Pl(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class ze{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,je.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=je.workingColorSpace){return this.r=e,this.g=t,this.b=n,je.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=je.workingColorSpace){if(e=qu(e,1),t=qe(t,0,1),n=qe(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=Pl(s,r,e+0.3333333333333333),this.g=Pl(s,r,e),this.b=Pl(s,r,e-0.3333333333333333)}return je.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Le("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Le("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else Le("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=am[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Le("Color: Unknown color "+e);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Vi(e.r),this.g=Vi(e.g),this.b=Vi(e.b),this}copyLinearToSRGB(e){return this.r=ys(e.r),this.g=ys(e.g),this.b=ys(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return je.workingToColorSpace(rn.copy(this),e),Math.round(qe(rn.r*255,0,255))*65536+Math.round(qe(rn.g*255,0,255))*256+Math.round(qe(rn.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=je.workingColorSpace){je.workingToColorSpace(rn.copy(this),t);let{r:n,g:i,b:r}=rn,s=Math.max(n,i,r),o=Math.min(n,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=0.5?u/(s+o):u/(2-s-o),s){case n:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-n)/u+2;break;case r:a=(n-i)/u+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,t=je.workingColorSpace){return je.workingToColorSpace(rn.copy(this),t),e.r=rn.r,e.g=rn.g,e.b=rn.b,e}getStyle(e="srgb"){je.workingToColorSpace(rn.copy(this),e);let{r:t,g:n,b:i}=rn;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(nr),this.setHSL(nr.h+e,nr.s+t,nr.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(nr),e.getHSL(wa);let n=po(nr.h,wa.h,t),i=po(nr.s,wa.s,t),r=po(nr.l,wa.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}var rn=new ze;ze.NAMES=am;class Is extends gt{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new hi,this.environmentIntensity=1,this.environmentRotation=new hi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null)this.overrideMaterial=e.overrideMaterial.clone();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}}var Xn=new U,Ui=new U,Il=new U,Fi=new U,ls=new U,us=new U,zf=new U,Ll=new U,Nl=new U,Dl=new U,Ol=new ft,Ul=new ft,Fl=new ft;class zn{constructor(e=new U,t=new U,n=new U){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Xn.subVectors(e,t),i.cross(Xn);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Xn.subVectors(i,t),Ui.subVectors(n,t),Il.subVectors(e,t);let s=Xn.dot(Xn),o=Xn.dot(Ui),a=Xn.dot(Il),c=Ui.dot(Ui),l=Ui.dot(Il),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let d=1/u,h=(c*a-o*l)*d,f=(s*l-o*a)*d;return r.set(1-h-f,f,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,Fi)===null)return!1;return Fi.x>=0&&Fi.y>=0&&Fi.x+Fi.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,Fi)===null){if(a.x=0,a.y=0,"z"in a)a.z=0;if("w"in a)a.w=0;return null}return a.setScalar(0),a.addScaledVector(r,Fi.x),a.addScaledVector(s,Fi.y),a.addScaledVector(o,Fi.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Ol.setScalar(0),Ul.setScalar(0),Fl.setScalar(0),Ol.fromBufferAttribute(e,t),Ul.fromBufferAttribute(e,n),Fl.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Ol,r.x),s.addScaledVector(Ul,r.y),s.addScaledVector(Fl,r.z),s}static isFrontFacing(e,t,n,i){return Xn.subVectors(n,t),Ui.subVectors(e,t),Xn.cross(Ui).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Xn.subVectors(this.c,this.b),Ui.subVectors(this.a,this.b),Xn.cross(Ui).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return zn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return zn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return zn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return zn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return zn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,o;ls.subVectors(i,n),us.subVectors(r,n),Ll.subVectors(e,n);let a=ls.dot(Ll),c=us.dot(Ll);if(a<=0&&c<=0)return t.copy(n);Nl.subVectors(e,i);let l=ls.dot(Nl),u=us.dot(Nl);if(l>=0&&u<=l)return t.copy(i);let d=a*u-l*c;if(d<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(ls,s);Dl.subVectors(e,r);let h=ls.dot(Dl),f=us.dot(Dl);if(f>=0&&h<=f)return t.copy(r);let m=h*c-a*f;if(m<=0&&c>=0&&f<=0)return o=c/(c-f),t.copy(n).addScaledVector(us,o);let _=l*f-h*u;if(_<=0&&u-l>=0&&h-f>=0)return zf.subVectors(r,i),o=(u-l)/(u-l+(h-f)),t.copy(i).addScaledVector(zf,o);let p=1/(_+m+d);return s=m*p,o=d*p,t.copy(n).addScaledVector(ls,s).addScaledVector(us,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Gt{constructor(e=new U(1/0,1/0,1/0),t=new U(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(jn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(jn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=jn.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++){if(e.isMesh===!0)e.getVertexPosition(s,jn);else jn.fromBufferAttribute(r,s);jn.applyMatrix4(e.matrixWorld),this.expandByPoint(jn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();Ea.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Ea.copy(n.boundingBox)}Ea.applyMatrix4(e.matrixWorld),this.union(Ea)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,jn),jn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(so),Aa.subVectors(this.max,so),hs.subVectors(e.a,so),ds.subVectors(e.b,so),fs.subVectors(e.c,so),ir.subVectors(ds,hs),rr.subVectors(fs,ds),Cr.subVectors(hs,fs);let t=[0,-ir.z,ir.y,0,-rr.z,rr.y,0,-Cr.z,Cr.y,ir.z,0,-ir.x,rr.z,0,-rr.x,Cr.z,0,-Cr.x,-ir.y,ir.x,0,-rr.y,rr.x,0,-Cr.y,Cr.x,0];if(!zl(t,hs,ds,fs,Aa))return!1;if(t=[1,0,0,0,1,0,0,0,1],!zl(t,hs,ds,fs,Aa))return!1;return Ta.crossVectors(ir,rr),t=[Ta.x,Ta.y,Ta.z],zl(t,hs,ds,fs,Aa)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,jn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(jn).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return zi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),zi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),zi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),zi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),zi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),zi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),zi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),zi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(zi),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}var zi=[new U,new U,new U,new U,new U,new U,new U,new U],jn=new U,Ea=new Gt,hs=new U,ds=new U,fs=new U,ir=new U,rr=new U,Cr=new U,so=new U,Aa=new U,Ta=new U,Pr=new U;function zl(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){Pr.fromArray(e,s);let a=r.x*Math.abs(Pr.x)+r.y*Math.abs(Pr.y)+r.z*Math.abs(Pr.z),c=t.dot(Pr),l=n.dot(Pr),u=i.dot(Pr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var zt=new U,Ra=new Ue,oS=0;class jt extends ei{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:oS++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Ra.fromBufferAttribute(this,t),Ra.applyMatrix3(e),this.setXY(t,Ra.x,Ra.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix3(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix4(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyNormalMatrix(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.transformDirection(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=qn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=dt(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=qn(t,this.array);return t}setX(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=qn(t,this.array);return t}setY(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=qn(t,this.array);return t}setZ(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=qn(t,this.array);return t}setW(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=dt(t,this.array),n=dt(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array),r=dt(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class hc extends jt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class dc extends jt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class xn extends jt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var aS=new Gt,oo=new U,kl=new U;class En{constructor(e=new U,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;if(t!==void 0)n.copy(t);else aS.setFromPoints(e).getCenter(n);let i=0;for(let r=0,s=e.length;r<s;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return e.set(this.center,this.center),e.expandByScalar(this.radius),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;oo.subVectors(e,this.center);let t=oo.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(oo,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else kl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(oo.copy(e.center).add(kl)),this.expandByPoint(oo.copy(e.center).sub(kl));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}var cS=0,Un=new $e,Bl=new gt,ps=new U,Sn=new Gt,ao=new Gt,Zt=new U;class on extends ei{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:cS++}),this.uuid=Yn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){if(Array.isArray(e))this.index=new((Lb(e))?dc:hc)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new Ve().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return Un.makeRotationFromQuaternion(e),this.applyMatrix4(Un),this}rotateX(e){return Un.makeRotationX(e),this.applyMatrix4(Un),this}rotateY(e){return Un.makeRotationY(e),this.applyMatrix4(Un),this}rotateZ(e){return Un.makeRotationZ(e),this.applyMatrix4(Un),this}translate(e,t,n){return Un.makeTranslation(e,t,n),this.applyMatrix4(Un),this}scale(e,t,n){return Un.makeScale(e,t,n),this.applyMatrix4(Un),this}lookAt(e){return Bl.lookAt(e),Bl.updateMatrix(),this.applyMatrix4(Bl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ps).negate(),this.translate(ps.x,ps.y,ps.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new xn(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)Le("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Gt;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(Sn.setFromBufferAttribute(r),this.morphTargetsRelative)Zt.addVectors(this.boundingBox.min,Sn.min),this.boundingBox.expandByPoint(Zt),Zt.addVectors(this.boundingBox.max,Sn.max),this.boundingBox.expandByPoint(Zt);else this.boundingBox.expandByPoint(Sn.min),this.boundingBox.expandByPoint(Sn.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))ke('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new En;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,1/0);return}if(e){let n=this.boundingSphere.center;if(Sn.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(ao.setFromBufferAttribute(o),this.morphTargetsRelative)Zt.addVectors(Sn.min,ao.min),Sn.expandByPoint(Zt),Zt.addVectors(Sn.max,ao.max),Sn.expandByPoint(Zt);else Sn.expandByPoint(ao.min),Sn.expandByPoint(ao.max)}Sn.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)Zt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Zt));if(t)for(let r=0,s=t.length;r<s;r++){let o=t[r],a=this.morphTargetsRelative;for(let c=0,l=o.count;c<l;c++){if(Zt.fromBufferAttribute(o,c),a)ps.fromBufferAttribute(e,c),Zt.add(ps);i=Math.max(i,n.distanceToSquared(Zt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))ke('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){ke("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new jt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let R=0;R<n.count;R++)o[R]=new U,a[R]=new U;let c=new U,l=new U,u=new U,d=new Ue,h=new Ue,f=new Ue,m=new U,_=new U;function p(R,x,M){c.fromBufferAttribute(n,R),l.fromBufferAttribute(n,x),u.fromBufferAttribute(n,M),d.fromBufferAttribute(r,R),h.fromBufferAttribute(r,x),f.fromBufferAttribute(r,M),l.sub(c),u.sub(c),h.sub(d),f.sub(d);let z=1/(h.x*f.y-f.x*h.y);if(!isFinite(z))return;m.copy(l).multiplyScalar(f.y).addScaledVector(u,-h.y).multiplyScalar(z),_.copy(u).multiplyScalar(h.x).addScaledVector(l,-f.x).multiplyScalar(z),o[R].add(m),o[x].add(m),o[M].add(m),a[R].add(_),a[x].add(_),a[M].add(_)}let g=this.groups;if(g.length===0)g=[{start:0,count:e.count}];for(let R=0,x=g.length;R<x;++R){let M=g[R],{start:z,count:C}=M;for(let L=z,K=z+C;L<K;L+=3)p(e.getX(L+0),e.getX(L+1),e.getX(L+2))}let S=new U,T=new U,y=new U,w=new U;function A(R){y.fromBufferAttribute(i,R),w.copy(y);let x=o[R];S.copy(x),S.sub(y.multiplyScalar(y.dot(x))).normalize(),T.crossVectors(w,x);let z=T.dot(a[R])<0?-1:1;s.setXYZW(R,S.x,S.y,S.z,z)}for(let R=0,x=g.length;R<x;++R){let M=g[R],{start:z,count:C}=M;for(let L=z,K=z+C;L<K;L+=3)A(e.getX(L+0)),A(e.getX(L+1)),A(e.getX(L+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new jt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,h=n.count;d<h;d++)n.setXYZ(d,0,0,0);let i=new U,r=new U,s=new U,o=new U,a=new U,c=new U,l=new U,u=new U;if(e)for(let d=0,h=e.count;d<h;d+=3){let f=e.getX(d+0),m=e.getX(d+1),_=e.getX(d+2);i.fromBufferAttribute(t,f),r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,_),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,f),a.fromBufferAttribute(n,m),c.fromBufferAttribute(n,_),o.add(l),a.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(_,c.x,c.y,c.z)}else for(let d=0,h=t.count;d<h;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),s.fromBufferAttribute(t,d+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(d+0,l.x,l.y,l.z),n.setXYZ(d+1,l.x,l.y,l.z),n.setXYZ(d+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Zt.fromBufferAttribute(e,t),Zt.normalize(),e.setXYZ(t,Zt.x,Zt.y,Zt.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,d=new c.constructor(a.length*l),h=0,f=0;for(let m=0,_=a.length;m<_;m++){if(o.isInterleavedBufferAttribute)h=a[m]*o.data.stride+o.offset;else h=a[m]*l;for(let p=0;p<l;p++)d[f++]=c[h++]}return new jt(d,l,u)}if(this.index===null)return Le("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new on,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let d=c[l],h=e(d,n);a.push(h)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,d=c.length;u<d;u++){let h=c[u];l.push(h.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let d=0,h=u.length;d<h;d++)l.push(u[d].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Eo{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=Yn()}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Yn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Yn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}var hn=new U;class Ls{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)hn.fromBufferAttribute(this,t),hn.applyMatrix4(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)hn.fromBufferAttribute(this,t),hn.applyNormalMatrix(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)hn.fromBufferAttribute(this,t),hn.transformDirection(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=qn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=dt(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=qn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=qn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=qn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=qn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=dt(t,this.array),n=dt(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array),r=dt(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){mo("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new jt(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new Ls(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){mo("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var Vl=new U,lS=new U,uS=new Ve;class Fn{constructor(e=new U(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=Vl.subVectors(n,t).cross(lS.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let i=e.delta(Vl),r=this.normal.dot(i);if(r===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let s=-(e.start.dot(this.normal)+this.constant)/r;if(n===!0&&(s<0||s>1))return null;return t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||uS.getNormalMatrix(e),i=this.coplanarPoint(Vl).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}var hS=0;class yn extends ei{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:hS++}),this.uuid=Yn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ze(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Le(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Le(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new ze().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new Fn().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Ue().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Ue().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}}var ki=new U,Gl=new U,Ca=new U,Pa=new U;class fr{constructor(e=new U,t=new U(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ki)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=ki.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return ki.copy(this.origin).addScaledVector(this.direction,t),ki.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){Gl.copy(e).add(t).multiplyScalar(0.5),Ca.copy(t).sub(e).normalize(),Pa.copy(this.origin).sub(Gl);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(Ca),o=Pa.dot(this.direction),a=-Pa.dot(Ca),c=Pa.lengthSq(),l=Math.abs(1-s*s),u,d,h,f;if(l>0)if(u=s*a-o,d=s*o-a,f=r*l,u>=0)if(d>=-f)if(d<=f){let m=1/l;u*=m,d*=m,h=u*(u+s*d+2*o)+d*(s*u+d+2*a)+c}else d=r,u=Math.max(0,-(s*d+o)),h=-u*u+d*(d+2*a)+c;else d=-r,u=Math.max(0,-(s*d+o)),h=-u*u+d*(d+2*a)+c;else if(d<=-f)u=Math.max(0,-(-s*r+o)),d=u>0?-r:Math.min(Math.max(-r,-a),r),h=-u*u+d*(d+2*a)+c;else if(d<=f)u=0,d=Math.min(Math.max(-r,-a),r),h=d*(d+2*a)+c;else u=Math.max(0,-(s*r+o)),d=u>0?r:Math.min(Math.max(-r,-a),r),h=-u*u+d*(d+2*a)+c;else d=s>0?-r:r,u=Math.max(0,-(s*d+o)),h=-u*u+d*(d+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(Gl).addScaledVector(Ca,d);return h}intersectSphere(e,t){if(e.radius<0)return null;ki.subVectors(e.center,this.origin);let n=ki.dot(this.direction),i=ki.dot(ki)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;if(c>=0)n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c;else n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c;if(l>=0)r=(e.min.y-d.y)*l,s=(e.max.y-d.y)*l;else r=(e.max.y-d.y)*l,s=(e.min.y-d.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-d.z)*u,a=(e.max.z-d.z)*u;else o=(e.max.z-d.z)*u,a=(e.min.z-d.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,ki)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,d=e.y-s.y,h=e.z-s.z,f=t.x-s.x,m=t.y-s.y,_=t.z-s.z,p=n.x-s.x,g=n.y-s.y,S=n.z-s.z,T=Math.abs(a),y=Math.abs(c),w=Math.abs(l),A,R,x,M,z,C,L,K,I,G,X,P;if(T>=y&&T>=w)if(x=a,C=u,I=f,P=p,a>=0)A=c,R=l,M=d,z=h,L=m,K=_,G=g,X=S;else A=l,R=c,M=h,z=d,L=_,K=m,G=S,X=g;else if(y>=w)if(x=c,C=d,I=m,P=g,c>=0)A=l,R=a,M=h,z=u,L=_,K=f,G=S,X=p;else A=a,R=l,M=u,z=h,L=f,K=_,G=p,X=S;else if(x=l,C=h,I=_,P=S,l>=0)A=a,R=c,M=u,z=d,L=f,K=m,G=p,X=g;else A=c,R=a,M=d,z=u,L=m,K=f,G=g,X=p;if(x===0)return null;let j=A/x,k=R/x,q=1/x,Q=M-j*C,Me=z-k*C,ue=L-j*I,Be=K-k*I,we=G-j*P,Z=X-k*P,re=we*Be-Z*ue,se=Q*Z-Me*we,xe=ue*Me-Be*Q;if(i){if(re<0||se<0||xe<0)return null}else if((re<0||se<0||xe<0)&&(re>0||se>0||xe>0))return null;let Ee=re+se+xe;if(Ee===0)return null;let Ae=q*(re*C+se*I+xe*P);if(Ee>0?Ae<0:Ae>0)return null;return this.at(Ae/Ee,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class gi extends yn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ze(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 hi,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}var kf=new $e,Ir=new fr,Ia=new En,Bf=new U,La=new U,Na=new U,Da=new U,Hl=new U,Oa=new U,Vf=new U,Ua=new U;class Mt extends gt{constructor(e=new on,t=new gi){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let o=this.morphTargetInfluences;if(r&&o){Oa.set(0,0,0);for(let a=0,c=r.length;a<c;a++){let l=o[a],u=r[a];if(l===0)continue;if(Hl.fromBufferAttribute(u,e),s)Oa.addScaledVector(Hl,l);else Oa.addScaledVector(Hl.sub(t),l)}t.add(Oa)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(Ia.copy(n.boundingSphere),Ia.applyMatrix4(r),Ir.copy(e.ray).recast(e.near),Ia.containsPoint(Ir.origin)===!1){if(Ir.intersectSphere(Ia,Bf)===null)return;if(Ir.origin.distanceToSquared(Bf)>(e.far-e.near)**2)return}if(kf.copy(r).invert(),Ir.copy(e.ray).applyMatrix4(kf),n.boundingBox!==null){if(Ir.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,Ir)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:d,drawRange:h}=r;if(o!==null)if(Array.isArray(s))for(let f=0,m=d.length;f<m;f++){let _=d[f],p=s[_.materialIndex],g=Math.max(_.start,h.start),S=Math.min(o.count,Math.min(_.start+_.count,h.start+h.count));for(let T=g,y=S;T<y;T+=3){let w=o.getX(T),A=o.getX(T+1),R=o.getX(T+2);if(i=Fa(this,p,e,n,c,l,u,w,A,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,h.start),m=Math.min(o.count,h.start+h.count);for(let _=f,p=m;_<p;_+=3){let g=o.getX(_),S=o.getX(_+1),T=o.getX(_+2);if(i=Fa(this,s,e,n,c,l,u,g,S,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let f=0,m=d.length;f<m;f++){let _=d[f],p=s[_.materialIndex],g=Math.max(_.start,h.start),S=Math.min(a.count,Math.min(_.start+_.count,h.start+h.count));for(let T=g,y=S;T<y;T+=3){let w=T,A=T+1,R=T+2;if(i=Fa(this,p,e,n,c,l,u,w,A,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,h.start),m=Math.min(a.count,h.start+h.count);for(let _=f,p=m;_<p;_+=3){let g=_,S=_+1,T=_+2;if(i=Fa(this,s,e,n,c,l,u,g,S,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}}}function dS(e,t,n,i,r,s,o,a){let c;if(t.side===1)c=i.intersectTriangle(o,s,r,!0,a);else c=i.intersectTriangle(r,s,o,t.side===0,a);if(c===null)return null;Ua.copy(a),Ua.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Ua);if(l<n.near||l>n.far)return null;return{distance:l,point:Ua.clone(),object:e}}function Fa(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,La),e.getVertexPosition(c,Na),e.getVertexPosition(l,Da);let u=dS(e,t,n,i,La,Na,Da,Vf);if(u){let d=new U;if(zn.getBarycoord(Vf,La,Na,Da,d),r)u.uv=zn.getInterpolatedAttribute(r,a,c,l,d,new Ue);if(s)u.uv1=zn.getInterpolatedAttribute(s,a,c,l,d,new Ue);if(o){if(u.normal=zn.getInterpolatedAttribute(o,a,c,l,d,new U),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a,b:c,c:l,normal:new U,materialIndex:0};zn.getNormal(La,Na,Da,h.normal),u.face=h,u.barycoord=d}return u}var co=new ft,Gf=new ft,Hf=new ft,fS=new ft,$f=new $e,za=new U,$l=new En,Wf=new $e,Wl=new fr;class fc extends Mt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new $e,this.bindMatrixInverse=new $e,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Gt;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,za),this.boundingBox.expandByPoint(za)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new En;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,za),this.boundingSphere.expandByPoint(za)}copy(e,t){if(super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if($l.copy(this.boundingSphere),$l.applyMatrix4(i),e.ray.intersectsSphere($l)===!1)return;if(Wf.copy(i).invert(),Wl.copy(e.ray).applyMatrix4(Wf),this.boundingBox!==null){if(Wl.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,Wl)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new ft,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Le("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(Gf.fromBufferAttribute(i.attributes.skinIndex,e),Hf.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)co.copy(t),t.set(0,0,0,0);else co.set(...t,1),t.set(0,0,0);co.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=Hf.getComponent(r);if(s!==0){let o=Gf.getComponent(r);$f.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(fS.copy(co).applyMatrix4($f),s)}}if(t.isVector4)t.w=co.w;return t.applyMatrix4(this.bindMatrixInverse)}}class Ao extends gt{constructor(){super();this.isBone=!0,this.type="Bone"}}class To extends Nt{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,d){super(null,s,o,a,c,l,i,r,u,d);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var Zf=new $e,pS=new $e;class Ro{constructor(e=[],t=[]){this.uuid=Yn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Le("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new $e)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new $e;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let o=e[r]?e[r].matrixWorld:pS;Zf.multiplyMatrices(o,t[r]),Zf.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Ro(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new To(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)Le("Skeleton: No bone found with UUID:",r),s=new Ao;this.bones.push(s),this.boneInverses.push(new $e().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let o=n[i];e.boneInverses.push(o.toArray())}return e}}class ar extends jt{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}var ms=new $e,Xf=new $e,ka=[],jf=new Gt,mS=new $e,lo=new Mt,uo=new En;class Ns extends Mt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new ar(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,mS)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Gt;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ms),jf.copy(e.boundingBox).applyMatrix4(ms),this.boundingBox.union(jf)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new En;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ms),uo.copy(e.boundingSphere).applyMatrix4(ms),this.boundingSphere.union(uo)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[s+o]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(lo.geometry=this.geometry,lo.material=this.material,lo.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(uo.copy(this.boundingSphere),uo.applyMatrix4(n),e.ray.intersectsSphere(uo)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,ms),Xf.multiplyMatrices(n,ms),lo.matrixWorld=Xf,lo.raycast(e,ka);for(let s=0,o=ka.length;s<o;s++){let a=ka[s];a.instanceId=r,a.object=this,t.push(a)}ka.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new ar(new Float32Array(this.instanceMatrix.count*3).fill(1),3);return t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;if(this.morphTexture===null)this.morphTexture=new To(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let o=this.geometry.morphTargetsRelative?1:1-s,a=i*e;return r[a]=o,r.set(n,a+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}}var Lr=new En,gS=new Ue(0.5,0.5),Ba=new U;class Co{constructor(e=new Fn,t=new Fn,n=new Fn,i=new Fn,r=new Fn,s=new Fn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],d=r[6],h=r[7],f=r[8],m=r[9],_=r[10],p=r[11],g=r[12],S=r[13],T=r[14],y=r[15];if(i[0].setComponents(c-s,h-l,p-f,y-g).normalize(),i[1].setComponents(c+s,h+l,p+f,y+g).normalize(),i[2].setComponents(c+o,h+u,p+m,y+S).normalize(),i[3].setComponents(c-o,h-u,p-m,y-S).normalize(),n)i[4].setComponents(a,d,_,T).normalize(),i[5].setComponents(c-a,h-d,p-_,y-T).normalize();else if(i[4].setComponents(c-a,h-d,p-_,y-T).normalize(),t===2000)i[5].setComponents(c+a,h+d,p+_,y+T).normalize();else if(t===2001)i[5].setComponents(a,d,_,T).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();Lr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();Lr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Lr)}intersectsSprite(e){Lr.center.set(0,0,0);let t=gS.distanceTo(e.center);return Lr.radius=0.7071067811865476+t,Lr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Lr)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(Ba.x=i.normal.x>0?e.max.x:e.min.x,Ba.y=i.normal.y>0?e.max.y:e.min.y,Ba.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ba)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Po extends yn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ze(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var ja=new U,qa=new U,qf=new $e,ho=new fr,Va=new En,Zl=new U,Yf=new U;class pr extends gt{constructor(e=new on,t=new Po){super();this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)ja.fromBufferAttribute(t,i-1),qa.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=ja.distanceTo(qa);e.setAttribute("lineDistance",new xn(n,1))}else Le("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Va.copy(n.boundingSphere),Va.applyMatrix4(i),Va.radius+=r,e.ray.intersectsSphere(Va)===!1)return;qf.copy(i).invert(),ho.copy(e.ray).applyMatrix4(qf);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,d=n.attributes.position;if(l!==null){let h=Math.max(0,s.start),f=Math.min(l.count,s.start+s.count);for(let m=h,_=f-1;m<_;m+=c){let p=l.getX(m),g=l.getX(m+1),S=Ga(this,e,ho,a,p,g,m);if(S)t.push(S)}if(this.isLineLoop){let m=l.getX(f-1),_=l.getX(h),p=Ga(this,e,ho,a,m,_,f-1);if(p)t.push(p)}}else{let h=Math.max(0,s.start),f=Math.min(d.count,s.start+s.count);for(let m=h,_=f-1;m<_;m+=c){let p=Ga(this,e,ho,a,m,m+1,m);if(p)t.push(p)}if(this.isLineLoop){let m=Ga(this,e,ho,a,f-1,h,f-1);if(m)t.push(m)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Ga(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(ja.fromBufferAttribute(a,r),qa.fromBufferAttribute(a,s),n.distanceSqToSegment(ja,qa,Zl,Yf)>i)return;Zl.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(Zl);if(l<t.near||l>t.far)return;return{distance:l,point:Yf.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var Jf=new U,Kf=new U;class pc extends pr{constructor(e,t){super(e,t);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)Jf.fromBufferAttribute(t,i),Kf.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Jf.distanceTo(Kf);e.setAttribute("lineDistance",new xn(n,1))}else Le("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class mc extends pr{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class Io extends yn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ze(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var Qf=new $e,ql=new fr,Ha=new En,$a=new U;class Ds extends gt{constructor(e=new on,t=new Io){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Ha.copy(n.boundingSphere),Ha.applyMatrix4(i),Ha.radius+=r,e.ray.intersectsSphere(Ha)===!1)return;Qf.copy(i).invert(),ql.copy(e.ray).applyMatrix4(Qf);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let d=Math.max(0,s.start),h=Math.min(c.count,s.start+s.count);for(let f=d,m=h;f<m;f++){let _=c.getX(f);$a.fromBufferAttribute(u,_),ep($a,_,a,i,e,t,this)}}else{let d=Math.max(0,s.start),h=Math.min(u.count,s.start+s.count);for(let f=d,m=h;f<m;f++)$a.fromBufferAttribute(u,f),ep($a,f,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function ep(e,t,n,i,r,s,o){let a=ql.distanceSqToPoint(e);if(a<n){let c=new U;ql.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class gc extends Nt{constructor(e=[],t=301,n,i,r,s,o,a,c,l){super(e,t,n,i,r,s,o,a,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Vr extends Nt{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:u};super(d,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Mo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class Qu extends Vr{constructor(e,t=1014,n=301,i,r,s=1003,o=1003,a,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,o,a,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class _c extends Nt{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class mr extends on{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],d=0,h=0;f("z","y","x",-1,-1,n,t,e,s,r,0),f("z","y","x",1,-1,n,t,-e,s,r,1),f("x","z","y",1,1,e,n,t,i,s,2),f("x","z","y",1,-1,e,n,-t,i,s,3),f("x","y","z",1,-1,e,t,n,i,r,4),f("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new xn(c,3)),this.setAttribute("normal",new xn(l,3)),this.setAttribute("uv",new xn(u,2));function f(m,_,p,g,S,T,y,w,A,R,x){let M=T/A,z=y/R,C=T/2,L=y/2,K=w/2,I=A+1,G=R+1,X=0,P=0,j=new U;for(let k=0;k<G;k++){let q=k*z-L;for(let Q=0;Q<I;Q++){let Me=Q*M-C;j[m]=Me*g,j[_]=q*S,j[p]=K,c.push(j.x,j.y,j.z),j[m]=0,j[_]=0,j[p]=w>0?1:-1,l.push(j.x,j.y,j.z),u.push(Q/A),u.push(1-k/R),X+=1}}for(let k=0;k<R;k++)for(let q=0;q<A;q++){let Q=d+q+I*k,Me=d+q+I*(k+1),ue=d+(q+1)+I*(k+1),Be=d+(q+1)+I*k;a.push(Q,Me,Be),a.push(Me,ue,Be),P+=6}o.addGroup(h,P,x),h+=P,d+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Lo extends on{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,d=t/a,h=[],f=[],m=[],_=[];for(let p=0;p<l;p++){let g=p*d-s;for(let S=0;S<c;S++){let T=S*u-r;f.push(T,-g,0),m.push(0,0,1),_.push(S/o),_.push(1-p/a)}}for(let p=0;p<a;p++)for(let g=0;g<o;g++){let S=g+c*p,T=g+c*(p+1),y=g+1+c*(p+1),w=g+1+c*p;h.push(S,T,w),h.push(T,y,w)}this.setIndex(h),this.setAttribute("position",new xn(f,3)),this.setAttribute("normal",new xn(m,3)),this.setAttribute("uv",new xn(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Lo(e.width,e.height,e.widthSegments,e.heightSegments)}}function Gr(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(tp(r))if(r.isRenderTargetTexture)Le("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(tp(r[0])){let s=[];for(let o=0,a=r.length;o<a;o++)s[o]=r[o].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function an(e){let t={};for(let n=0;n<e.length;n++){let i=Gr(e[n]);for(let r in i)t[r]=i[r]}return t}function tp(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function _S(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function eh(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return je.workingColorSpace}var cm={clone:Gr,merge:an},xS=`void main() {+ var hp="186",cr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},lr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},dp=0,Kl=1,fp=2;var _o=1,pp=2,Ms=3,ur=0,rn=1,kn=2,di=0,xo=1,Ql=2,eu=3,tu=4,mp=5;var ws=100,gp=101,_p=102,xp=103,yp=104,vp=200,bp=201,Sp=202,Mp=203,wp=204,Ep=205,Ap=206,Tp=207,Rp=208,Cp=209,Pp=210,Ip=211,Lp=212,Np=213,Dp=214,Op=0,Up=1,Fp=2,nu=3,zp=4,kp=5,Bp=6,Vp=7,Gp=0,Hp=1,$p=2,Jn=0,iu=1,ru=2,su=3,yo=4,ou=5,au=6,cu=7;var Es=301,Or=302,Ka=303,Qa=304,vo=306,As=1000,Ts=1001,ec=1002,Kn=1003,tc=1004;var Ur=1005;var qt=1006,Rs=1007;var fi=1008;var Qn=1009,Wp=1010,Zp=1011,bo=1012,lu=1013,hr=1014,Gi=1015,pi=1016,uu=1017,hu=1018,Cs=1020,Xp=35902,jp=35899,qp=1021,Yp=1022,mi=1023,Fr=1026,zr=1027,Jp=1028,du=1029,kr=1030,fu=1031;var pu=1033,nc=33776,ic=33777,rc=33778,sc=33779,mu=35840,gu=35841,_u=35842,xu=35843,yu=36196,vu=37492,bu=37496,Su=37488,Mu=37489,oc=37490,wu=37491,Eu=37808,Au=37809,Tu=37810,Ru=37811,Cu=37812,Pu=37813,Iu=37814,Lu=37815,Nu=37816,Du=37817,Ou=37818,Uu=37819,Fu=37820,zu=37821,ku=36492,Bu=36494,Vu=36495,Gu=36283,Hu=36284,ac=36285,$u=36286;var Wu=2300,cc=2301;var Zu=0,So=1,Ps=2;var Xu=0,Kp=1,Br="",dr="srgb",Sn="srgb-linear",ju="linear",yt="srgb";var Qp=512,em=513,tm=514,lc=515,nm=516,im=517,uc=518,rm=519;var qu="300 es",Yu=2000;function Ob(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Ub(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function vs(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function sm(){let e=vs("canvas");return e.style.display="block",e}var Rf={},bs=null;function go(...e){let t="THREE."+e.shift();if(bs)bs("log",t,...e);else console.log(t,...e)}function om(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Le(...e){e=om(e);let t="THREE."+e.shift();if(bs)bs("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function ke(...e){e=om(e);let t="THREE."+e.shift();if(bs)bs("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function Nr(...e){let t=e.join(" ");if(t in Rf)return;Rf[t]=!0,Le(...e)}function am(e,t,n){return new Promise(function(i,r){function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}var cm={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ei{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}var tn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Cf=1234567,po=Math.PI/180,Dr=180/Math.PI;function Yn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(tn[e&255]+tn[e>>8&255]+tn[e>>16&255]+tn[e>>24&255]+"-"+tn[t&255]+tn[t>>8&255]+"-"+tn[t>>16&15|64]+tn[t>>24&255]+"-"+tn[n&63|128]+tn[n>>8&255]+"-"+tn[n>>16&255]+tn[n>>24&255]+tn[i&255]+tn[i>>8&255]+tn[i>>16&255]+tn[i>>24&255]).toLowerCase()}function qe(e,t,n){return Math.max(t,Math.min(n,e))}function Ju(e,t){return(e%t+t)%t}function Fb(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function zb(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function mo(e,t,n){return(1-n)*e+n*t}function kb(e,t,n,i){return mo(e,t,1-Math.exp(-n*i))}function Bb(e,t=1){return t-Math.abs(Ju(e,t*2)-t)}function Vb(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*(3-2*e)}function Gb(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10)}function Hb(e,t){return e+Math.floor(Math.random()*(t-e+1))}function $b(e,t){return e+Math.random()*(t-e)}function Wb(e){return e*(0.5-Math.random())}function Zb(e){if(e!==void 0)Cf=e;let t=Cf+=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 Xb(e){return e*po}function jb(e){return e*Dr}function qb(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function Yb(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Jb(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Kb(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),d=s((t-i)/2),h=o((t-i)/2),f=s((i-t)/2),m=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*d,c*h,a*l);break;case"YZY":e.set(c*h,a*u,c*d,a*l);break;case"ZXZ":e.set(c*d,c*h,a*u,a*l);break;case"XZX":e.set(a*u,c*m,c*f,a*l);break;case"YXY":e.set(c*f,a*u,c*m,a*l);break;case"ZYZ":e.set(c*m,c*f,a*u,a*l);break;default:Le("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function qn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function dt(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var Mo={DEG2RAD:po,RAD2DEG:Dr,generateUUID:Yn,clamp:qe,euclideanModulo:Ju,mapLinear:Fb,inverseLerp:zb,lerp:mo,damp:kb,pingpong:Bb,smoothstep:Vb,smootherstep:Gb,randInt:Hb,randFloat:$b,randFloatSpread:Wb,seededRandom:Zb,degToRad:Xb,radToDeg:jb,isPowerOfTwo:qb,ceilPowerOfTwo:Yb,floorPowerOfTwo:Jb,setQuaternionFromProperEuler:Kb,normalize:dt,denormalize:qn};class Ue{static{Ue.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(qe(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Xt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],d=r[s+0],h=r[s+1],f=r[s+2],m=r[s+3];if(u!==m||a!==d||c!==h||l!==f){let _=a*d+c*h+l*f+u*m;if(_<0)d=-d,h=-h,f=-f,m=-m,_=-_;let p=1-o;if(_<0.9995){let g=Math.acos(_),S=Math.sin(g);p=Math.sin(p*g)/S,o=Math.sin(o*g)/S,a=a*p+d*o,c=c*p+h*o,l=l*p+f*o,u=u*p+m*o}else{a=a*p+d*o,c=c*p+h*o,l=l*p+f*o,u=u*p+m*o;let g=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=g,c*=g,l*=g,u*=g}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],d=r[s+1],h=r[s+2],f=r[s+3];return e[t]=o*f+l*u+a*h-c*d,e[t+1]=a*f+l*d+c*u-o*h,e[t+2]=c*f+l*h+o*d-a*u,e[t+3]=l*f-o*u-a*d-c*h,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),d=a(n/2),h=a(i/2),f=a(r/2);switch(s){case"XYZ":this._x=d*l*u+c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u-d*h*f;break;case"YXZ":this._x=d*l*u+c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u+d*h*f;break;case"ZXY":this._x=d*l*u-c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u-d*h*f;break;case"ZYX":this._x=d*l*u-c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u+d*h*f;break;case"YZX":this._x=d*l*u+c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u-d*h*f;break;case"XZY":this._x=d*l*u-c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u+d*h*f;break;default:Le("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let h=0.5/Math.sqrt(d+1);this._w=0.25/h,this._x=(l-a)*h,this._y=(r-c)*h,this._z=(s-i)*h}else if(n>o&&n>u){let h=2*Math.sqrt(1+n-o-u);this._w=(l-a)/h,this._x=0.25*h,this._y=(i+s)/h,this._z=(r+c)/h}else if(o>u){let h=2*Math.sqrt(1+o-n-u);this._w=(r-c)/h,this._x=(i+s)/h,this._y=0.25*h,this._z=(a+l)/h}else{let h=2*Math.sqrt(1+u-n-o);this._w=(s-i)/h,this._x=(r+c)/h,this._y=(a+l)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(qe(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:o,_y:a,_z:c,_w:l}=t;return this._x=n*l+s*o+i*c-r*a,this._y=i*l+s*a+r*o-n*c,this._z=r*l+s*c+n*a-i*o,this._w=s*l-n*o-i*a-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,o=this.dot(e);if(o<0)n=-n,i=-i,r=-r,s=-s,o=-o;let a=1-t;if(o<0.9995){let c=Math.acos(o),l=Math.sin(c);a=Math.sin(a*c)/l,t=Math.sin(t*c)/l,this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this._onChangeCallback()}else this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class U{static{U.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Pf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Pf.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:o,w:a}=e,c=2*(s*i-o*n),l=2*(o*t-r*i),u=2*(r*n-s*t);return this.x=t+a*c+s*u-o*l,this.y=n+a*l+o*c-r*u,this.z=i+a*u+r*l-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:o,z:a}=t;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Tl.copy(this).projectOnVector(e),this.sub(Tl)}reflect(e){return this.sub(Tl.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(qe(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var Tl=new U,Pf=new Xt;class Ve{static{Ve.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],d=n[2],h=n[5],f=n[8],m=i[0],_=i[3],p=i[6],g=i[1],S=i[4],T=i[7],y=i[2],w=i[5],A=i[8];return r[0]=s*m+o*g+a*y,r[3]=s*_+o*S+a*w,r[6]=s*p+o*T+a*A,r[1]=c*m+l*g+u*y,r[4]=c*_+l*S+u*w,r[7]=c*p+l*T+u*A,r[2]=d*m+h*g+f*y,r[5]=d*_+h*S+f*w,r[8]=d*p+h*T+f*A,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,d=o*a-l*r,h=c*r-s*a,f=t*u+n*d+i*h;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/f;return e[0]=u*m,e[1]=(i*c-l*n)*m,e[2]=(o*n-i*s)*m,e[3]=d*m,e[4]=(l*t-i*a)*m,e[5]=(i*r-o*t)*m,e[6]=h*m,e[7]=(n*a-c*t)*m,e[8]=(s*t-n*r)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return Nr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Rl.makeScale(e,t)),this}rotate(e){return Nr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Rl.makeRotation(-e)),this}translate(e,t){return Nr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Rl.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}var Rl=new Ve,If=new Ve().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Lf=new Ve().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function Qb(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,o){if(this.enabled===!1||s===o||!s||!o)return r;if(this.spaces[s].transfer==="srgb")r.r=Vi(r.r),r.g=Vi(r.g),r.b=Vi(r.b);if(this.spaces[s].primaries!==this.spaces[o].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ);if(this.spaces[o].transfer==="srgb")r.r=ys(r.r),r.g=ys(r.g),r.b=ys(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Nr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Nr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(r,s)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:If,fromXYZ:Lf,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:If,fromXYZ:Lf,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var je=Qb();function Vi(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function ys(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var ss;class Ku{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(ss===void 0)ss=vs("canvas");ss.width=e.width,ss.height=e.height;let i=ss.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=ss}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=vs("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Vi(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Vi(t[n]/255)*255);else t[n]=Vi(t[n]);return{data:t,width:e.width,height:e.height}}else return Le("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var eS=0;class wo{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:eS++}),this.uuid=Yn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)if(i[s].isDataTexture)r.push(Cl(i[s].image));else r.push(Cl(i[s]))}else r=Cl(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Cl(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return Ku.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Le("Texture: Unable to serialize Texture."),{}}var tS=0,Pl=new U;class Nt extends ei{constructor(e=Nt.DEFAULT_IMAGE,t=Nt.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Nt.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:tS++}),this.uuid=Yn(),this.name="",this.source=new wo(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new Ue(0,0),this.repeat=new Ue(1,1),this.center=new Ue(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ve,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Pl).x}get height(){return this.source.getSize(Pl).y}get depth(){return this.source.getSize(Pl).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Le(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Le(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}Nt.DEFAULT_IMAGE=null;Nt.DEFAULT_MAPPING=300;Nt.DEFAULT_ANISOTROPY=1;class ft{static{ft.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],d=a[1],h=a[5],f=a[9],m=a[2],_=a[6],p=a[10];if(Math.abs(l-d)<0.01&&Math.abs(u-m)<0.01&&Math.abs(f-_)<0.01){if(Math.abs(l+d)<0.1&&Math.abs(u+m)<0.1&&Math.abs(f+_)<0.1&&Math.abs(c+h+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let S=(c+1)/2,T=(h+1)/2,y=(p+1)/2,w=(l+d)/4,A=(u+m)/4,R=(f+_)/4;if(S>T&&S>y)if(S<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(S),i=w/n,r=A/n;else if(T>y)if(T<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(T),n=w/i,r=R/i;else if(y<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(y),n=A/r,i=R/r;return this.set(n,i,r,t),this}let g=Math.sqrt((_-f)*(_-f)+(u-m)*(u-m)+(d-l)*(d-l));if(Math.abs(g)<0.001)g=1;return this.x=(_-f)/g,this.y=(u-m)/g,this.z=(d-l)/g,this.w=Math.acos((c+h+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this.w=qe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this.w=qe(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Qu extends ei{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ft(0,0,e,t),this.scissorTest=!1,this.viewport=new ft(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Nt(i),s=n.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new wo(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Mn extends Qu{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class hc extends Nt{constructor(e=null,t=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class eh extends Nt{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class $e{static{$e.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,d,h,f,m,_){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c,l,u,d,h,f,m,_)}set(e,t,n,i,r,s,o,a,c,l,u,d,h,f,m,_){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=d,p[3]=h,p[7]=f,p[11]=m,p[15]=_,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 $e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/os.setFromMatrixColumn(e,0).length(),r=1/os.setFromMatrixColumn(e,1).length(),s=1/os.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let d=s*l,h=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=h+f*c,t[5]=d-m*c,t[9]=-o*a,t[2]=m-d*c,t[6]=f+h*c,t[10]=s*a}else if(e.order==="YXZ"){let d=a*l,h=a*u,f=c*l,m=c*u;t[0]=d+m*o,t[4]=f*o-h,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=h*o-f,t[6]=m+d*o,t[10]=s*a}else if(e.order==="ZXY"){let d=a*l,h=a*u,f=c*l,m=c*u;t[0]=d-m*o,t[4]=-s*u,t[8]=f+h*o,t[1]=h+f*o,t[5]=s*l,t[9]=m-d*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let d=s*l,h=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=f*c-h,t[8]=d*c+m,t[1]=a*u,t[5]=m*c+d,t[9]=h*c-f,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let d=s*a,h=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=m-d*u,t[8]=f*u+h,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=h*u+f,t[10]=d-m*u}else if(e.order==="XZY"){let d=s*a,h=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=d*u+m,t[5]=s*l,t[9]=h*u-f,t[2]=f*u-h,t[6]=o*l,t[10]=m*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(nS,e,iS)}lookAt(e,t,n){let i=this.elements;if(vn.subVectors(e,t),vn.lengthSq()===0)vn.z=1;if(vn.normalize(),tr.crossVectors(n,vn),tr.lengthSq()===0){if(Math.abs(n.z)===1)vn.x+=0.0001;else vn.z+=0.0001;vn.normalize(),tr.crossVectors(n,vn)}return tr.normalize(),wa.crossVectors(vn,tr),i[0]=tr.x,i[4]=wa.x,i[8]=vn.x,i[1]=tr.y,i[5]=wa.y,i[9]=vn.y,i[2]=tr.z,i[6]=wa.z,i[10]=vn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],d=n[9],h=n[13],f=n[2],m=n[6],_=n[10],p=n[14],g=n[3],S=n[7],T=n[11],y=n[15],w=i[0],A=i[4],R=i[8],x=i[12],M=i[1],z=i[5],C=i[9],L=i[13],K=i[2],I=i[6],G=i[10],X=i[14],P=i[3],j=i[7],k=i[11],q=i[15];return r[0]=s*w+o*M+a*K+c*P,r[4]=s*A+o*z+a*I+c*j,r[8]=s*R+o*C+a*G+c*k,r[12]=s*x+o*L+a*X+c*q,r[1]=l*w+u*M+d*K+h*P,r[5]=l*A+u*z+d*I+h*j,r[9]=l*R+u*C+d*G+h*k,r[13]=l*x+u*L+d*X+h*q,r[2]=f*w+m*M+_*K+p*P,r[6]=f*A+m*z+_*I+p*j,r[10]=f*R+m*C+_*G+p*k,r[14]=f*x+m*L+_*X+p*q,r[3]=g*w+S*M+T*K+y*P,r[7]=g*A+S*z+T*I+y*j,r[11]=g*R+S*C+T*G+y*k,r[15]=g*x+S*L+T*X+y*q,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],d=e[10],h=e[14],f=e[3],m=e[7],_=e[11],p=e[15],g=a*h-c*d,S=o*h-c*u,T=o*d-a*u,y=s*h-c*l,w=s*d-a*l,A=s*u-o*l;return t*(m*g-_*S+p*T)-n*(f*g-_*y+p*w)+i*(f*S-m*y+p*A)-r*(f*T-m*w+_*A)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],d=e[10],h=e[11],f=e[12],m=e[13],_=e[14],p=e[15],g=t*o-n*s,S=t*a-i*s,T=t*c-r*s,y=n*a-i*o,w=n*c-r*o,A=i*c-r*a,R=l*m-u*f,x=l*_-d*f,M=l*p-h*f,z=u*_-d*m,C=u*p-h*m,L=d*p-h*_,K=g*L-S*C+T*z+y*M-w*x+A*R;if(K===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let I=1/K;return e[0]=(o*L-a*C+c*z)*I,e[1]=(i*C-n*L-r*z)*I,e[2]=(m*A-_*w+p*y)*I,e[3]=(d*w-u*A-h*y)*I,e[4]=(a*M-s*L-c*x)*I,e[5]=(t*L-i*M+r*x)*I,e[6]=(_*T-f*A-p*S)*I,e[7]=(l*A-d*T+h*S)*I,e[8]=(s*C-o*M+c*R)*I,e[9]=(n*M-t*C-r*R)*I,e[10]=(f*w-m*T+p*g)*I,e[11]=(u*T-l*w-h*g)*I,e[12]=(o*x-s*z-a*R)*I,e[13]=(t*z-n*x+i*R)*I,e[14]=(m*S-f*y-_*g)*I,e[15]=(l*y-u*S+d*g)*I,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,d=r*c,h=r*l,f=r*u,m=s*l,_=s*u,p=o*u,g=a*c,S=a*l,T=a*u,{x:y,y:w,z:A}=n;return i[0]=(1-(m+p))*y,i[1]=(h+T)*y,i[2]=(f-S)*y,i[3]=0,i[4]=(h-T)*w,i[5]=(1-(d+p))*w,i[6]=(_+g)*w,i[7]=0,i[8]=(f+S)*A,i[9]=(_-g)*A,i[10]=(1-(d+m))*A,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=os.set(i[0],i[1],i[2]).length(),o=os.set(i[4],i[5],i[6]).length(),a=os.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Zn.copy(this);let c=1/s,l=1/o,u=1/a;return Zn.elements[0]*=c,Zn.elements[1]*=c,Zn.elements[2]*=c,Zn.elements[4]*=l,Zn.elements[5]*=l,Zn.elements[6]*=l,Zn.elements[8]*=u,Zn.elements[9]*=u,Zn.elements[10]*=u,t.setFromRotationMatrix(Zn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),d=(t+e)/(t-e),h=(n+i)/(n-i),f,m;if(a)f=r/(s-r),m=s*r/(s-r);else if(o===2000)f=-(s+r)/(s-r),m=-2*s*r/(s-r);else if(o===2001)f=-s/(s-r),m=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),d=-(t+e)/(t-e),h=-(n+i)/(n-i),f,m;if(a)f=1/(s-r),m=s/(s-r);else if(o===2000)f=-2/(s-r),m=-(s+r)/(s-r);else if(o===2001)f=-1/(s-r),m=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=h,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var os=new U,Zn=new $e,nS=new U(0,0,0),iS=new U(1,1,1),tr=new U,wa=new U,vn=new U,Nf=new $e,Df=new Xt;class hi{constructor(e=0,t=0,n=0,i=hi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],d=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin(qe(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,h),this._z=Math.atan2(-s,r);else this._x=Math.atan2(d,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-qe(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(o,h),this._z=Math.atan2(a,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(qe(d,-1,1)),Math.abs(d)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-qe(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(d,h),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(qe(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(o,h);break;case"XZY":if(this._z=Math.asin(-qe(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(d,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,h),this._y=0;break;default:Le("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return Nf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Nf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Df.setFromEuler(this),this.setFromQuaternion(Df,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}hi.DEFAULT_ORDER="XYZ";class dc{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}var rS=0,Of=new U,as=new Xt,Oi=new $e,Ea=new U,so=new U,sS=new U,oS=new Xt,Uf=new U(1,0,0),Ff=new U(0,1,0),zf=new U(0,0,1),kf={type:"added"},aS={type:"removed"},cs={type:"childadded",child:null},Il={type:"childremoved",child:null};class gt extends ei{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:rS++}),this.uuid=Yn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=gt.DEFAULT_UP.clone();let e=new U,t=new hi,n=new Xt,i=new U(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new $e},normalMatrix:{value:new Ve}}),this.matrix=new $e,this.matrixWorld=new $e,this.matrixAutoUpdate=gt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new dc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return as.setFromAxisAngle(e,t),this.quaternion.multiply(as),this}rotateOnWorldAxis(e,t){return as.setFromAxisAngle(e,t),this.quaternion.premultiply(as),this}rotateX(e){return this.rotateOnAxis(Uf,e)}rotateY(e){return this.rotateOnAxis(Ff,e)}rotateZ(e){return this.rotateOnAxis(zf,e)}translateOnAxis(e,t){return Of.copy(e).applyQuaternion(this.quaternion),this.position.add(Of.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Uf,e)}translateY(e){return this.translateOnAxis(Ff,e)}translateZ(e){return this.translateOnAxis(zf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Oi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)Ea.copy(e);else Ea.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),so.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Oi.lookAt(so,Ea,this.up);else Oi.lookAt(Ea,so,this.up);if(this.quaternion.setFromRotationMatrix(Oi),i)Oi.extractRotation(i.matrixWorld),as.setFromRotationMatrix(Oi),this.quaternion.premultiply(as.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return ke("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(kf),cs.child=e,this.dispatchEvent(cs),cs.child=null;else ke("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(aS),Il.child=e,this.dispatchEvent(Il),Il.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),Oi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Oi.multiply(e.parent.matrixWorld);return e.applyMatrix4(Oi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(kf),cs.child=e,this.dispatchEvent(cs),cs.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(so,e,sS),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(so,oS,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),d=s(e.skeletons),h=s(e.animations),f=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(d.length>0)n.skeletons=d;if(h.length>0)n.animations=h;if(f.length>0)n.nodes=f}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}gt.DEFAULT_UP=new U(0,1,0);gt.DEFAULT_MATRIX_AUTO_UPDATE=!0;gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class li extends gt{constructor(){super();this.isGroup=!0,this.type="Group"}}var cS={type:"move"};class Eo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new li,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new li,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new li,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,o=this._targetRay,a=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let m of e.hand.values()){let _=t.getJointPose(m,n),p=this._getHandJoint(c,m);if(_!==null)p.matrix.fromArray(_.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=_.radius;p.visible=_!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=l.position.distanceTo(u.position),h=0.02,f=0.005;if(c.inputState.pinching&&d>h+f)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&d<=h-f)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(cS)}}}if(o!==null)o.visible=i!==null;if(a!==null)a.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new li;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var lm={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},nr={h:0,s:0,l:0},Aa={h:0,s:0,l:0};function Ll(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class ze{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,je.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=je.workingColorSpace){return this.r=e,this.g=t,this.b=n,je.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=je.workingColorSpace){if(e=Ju(e,1),t=qe(t,0,1),n=qe(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=Ll(s,r,e+0.3333333333333333),this.g=Ll(s,r,e),this.b=Ll(s,r,e-0.3333333333333333)}return je.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Le("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Le("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else Le("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=lm[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Le("Color: Unknown color "+e);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Vi(e.r),this.g=Vi(e.g),this.b=Vi(e.b),this}copyLinearToSRGB(e){return this.r=ys(e.r),this.g=ys(e.g),this.b=ys(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return je.workingToColorSpace(nn.copy(this),e),Math.round(qe(nn.r*255,0,255))*65536+Math.round(qe(nn.g*255,0,255))*256+Math.round(qe(nn.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=je.workingColorSpace){je.workingToColorSpace(nn.copy(this),t);let{r:n,g:i,b:r}=nn,s=Math.max(n,i,r),o=Math.min(n,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=0.5?u/(s+o):u/(2-s-o),s){case n:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-n)/u+2;break;case r:a=(n-i)/u+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,t=je.workingColorSpace){return je.workingToColorSpace(nn.copy(this),t),e.r=nn.r,e.g=nn.g,e.b=nn.b,e}getStyle(e="srgb"){je.workingToColorSpace(nn.copy(this),e);let{r:t,g:n,b:i}=nn;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(nr),this.setHSL(nr.h+e,nr.s+t,nr.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(nr),e.getHSL(Aa);let n=mo(nr.h,Aa.h,t),i=mo(nr.s,Aa.s,t),r=mo(nr.l,Aa.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}var nn=new ze;ze.NAMES=lm;class Is extends gt{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new hi,this.environmentIntensity=1,this.environmentRotation=new hi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null)this.overrideMaterial=e.overrideMaterial.clone();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}}var Xn=new U,Ui=new U,Nl=new U,Fi=new U,ls=new U,us=new U,Bf=new U,Dl=new U,Ol=new U,Ul=new U,Fl=new ft,zl=new ft,kl=new ft;class zn{constructor(e=new U,t=new U,n=new U){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Xn.subVectors(e,t),i.cross(Xn);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Xn.subVectors(i,t),Ui.subVectors(n,t),Nl.subVectors(e,t);let s=Xn.dot(Xn),o=Xn.dot(Ui),a=Xn.dot(Nl),c=Ui.dot(Ui),l=Ui.dot(Nl),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let d=1/u,h=(c*a-o*l)*d,f=(s*l-o*a)*d;return r.set(1-h-f,f,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,Fi)===null)return!1;return Fi.x>=0&&Fi.y>=0&&Fi.x+Fi.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,Fi)===null){if(a.x=0,a.y=0,"z"in a)a.z=0;if("w"in a)a.w=0;return null}return a.setScalar(0),a.addScaledVector(r,Fi.x),a.addScaledVector(s,Fi.y),a.addScaledVector(o,Fi.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Fl.setScalar(0),zl.setScalar(0),kl.setScalar(0),Fl.fromBufferAttribute(e,t),zl.fromBufferAttribute(e,n),kl.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Fl,r.x),s.addScaledVector(zl,r.y),s.addScaledVector(kl,r.z),s}static isFrontFacing(e,t,n,i){return Xn.subVectors(n,t),Ui.subVectors(e,t),Xn.cross(Ui).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Xn.subVectors(this.c,this.b),Ui.subVectors(this.a,this.b),Xn.cross(Ui).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return zn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return zn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return zn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return zn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return zn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,o;ls.subVectors(i,n),us.subVectors(r,n),Dl.subVectors(e,n);let a=ls.dot(Dl),c=us.dot(Dl);if(a<=0&&c<=0)return t.copy(n);Ol.subVectors(e,i);let l=ls.dot(Ol),u=us.dot(Ol);if(l>=0&&u<=l)return t.copy(i);let d=a*u-l*c;if(d<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(ls,s);Ul.subVectors(e,r);let h=ls.dot(Ul),f=us.dot(Ul);if(f>=0&&h<=f)return t.copy(r);let m=h*c-a*f;if(m<=0&&c>=0&&f<=0)return o=c/(c-f),t.copy(n).addScaledVector(us,o);let _=l*f-h*u;if(_<=0&&u-l>=0&&h-f>=0)return Bf.subVectors(r,i),o=(u-l)/(u-l+(h-f)),t.copy(i).addScaledVector(Bf,o);let p=1/(_+m+d);return s=m*p,o=d*p,t.copy(n).addScaledVector(ls,s).addScaledVector(us,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Gt{constructor(e=new U(1/0,1/0,1/0),t=new U(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(jn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(jn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=jn.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++){if(e.isMesh===!0)e.getVertexPosition(s,jn);else jn.fromBufferAttribute(r,s);jn.applyMatrix4(e.matrixWorld),this.expandByPoint(jn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();Ta.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Ta.copy(n.boundingBox)}Ta.applyMatrix4(e.matrixWorld),this.union(Ta)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,jn),jn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(oo),Ra.subVectors(this.max,oo),hs.subVectors(e.a,oo),ds.subVectors(e.b,oo),fs.subVectors(e.c,oo),ir.subVectors(ds,hs),rr.subVectors(fs,ds),Cr.subVectors(hs,fs);let t=[0,-ir.z,ir.y,0,-rr.z,rr.y,0,-Cr.z,Cr.y,ir.z,0,-ir.x,rr.z,0,-rr.x,Cr.z,0,-Cr.x,-ir.y,ir.x,0,-rr.y,rr.x,0,-Cr.y,Cr.x,0];if(!Bl(t,hs,ds,fs,Ra))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Bl(t,hs,ds,fs,Ra))return!1;return Ca.crossVectors(ir,rr),t=[Ca.x,Ca.y,Ca.z],Bl(t,hs,ds,fs,Ra)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,jn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(jn).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return zi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),zi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),zi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),zi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),zi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),zi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),zi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),zi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(zi),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}var zi=[new U,new U,new U,new U,new U,new U,new U,new U],jn=new U,Ta=new Gt,hs=new U,ds=new U,fs=new U,ir=new U,rr=new U,Cr=new U,oo=new U,Ra=new U,Ca=new U,Pr=new U;function Bl(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){Pr.fromArray(e,s);let a=r.x*Math.abs(Pr.x)+r.y*Math.abs(Pr.y)+r.z*Math.abs(Pr.z),c=t.dot(Pr),l=n.dot(Pr),u=i.dot(Pr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var zt=new U,Pa=new Ue,lS=0;class jt extends ei{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:lS++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Pa.fromBufferAttribute(this,t),Pa.applyMatrix3(e),this.setXY(t,Pa.x,Pa.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix3(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix4(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyNormalMatrix(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.transformDirection(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=qn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=dt(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=qn(t,this.array);return t}setX(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=qn(t,this.array);return t}setY(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=qn(t,this.array);return t}setZ(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=qn(t,this.array);return t}setW(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=dt(t,this.array),n=dt(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array),r=dt(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class fc extends jt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class pc extends jt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class _n extends jt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var uS=new Gt,ao=new U,Vl=new U;class wn{constructor(e=new U,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;if(t!==void 0)n.copy(t);else uS.setFromPoints(e).getCenter(n);let i=0;for(let r=0,s=e.length;r<s;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return e.set(this.center,this.center),e.expandByScalar(this.radius),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ao.subVectors(e,this.center);let t=ao.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(ao,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else Vl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ao.copy(e.center).add(Vl)),this.expandByPoint(ao.copy(e.center).sub(Vl));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}var hS=0,Un=new $e,Gl=new gt,ps=new U,bn=new Gt,co=new Gt,Zt=new U;class sn extends ei{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:hS++}),this.uuid=Yn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){if(Array.isArray(e))this.index=new((Ob(e))?pc:fc)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new Ve().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return Un.makeRotationFromQuaternion(e),this.applyMatrix4(Un),this}rotateX(e){return Un.makeRotationX(e),this.applyMatrix4(Un),this}rotateY(e){return Un.makeRotationY(e),this.applyMatrix4(Un),this}rotateZ(e){return Un.makeRotationZ(e),this.applyMatrix4(Un),this}translate(e,t,n){return Un.makeTranslation(e,t,n),this.applyMatrix4(Un),this}scale(e,t,n){return Un.makeScale(e,t,n),this.applyMatrix4(Un),this}lookAt(e){return Gl.lookAt(e),Gl.updateMatrix(),this.applyMatrix4(Gl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ps).negate(),this.translate(ps.x,ps.y,ps.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new _n(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)Le("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Gt;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(bn.setFromBufferAttribute(r),this.morphTargetsRelative)Zt.addVectors(this.boundingBox.min,bn.min),this.boundingBox.expandByPoint(Zt),Zt.addVectors(this.boundingBox.max,bn.max),this.boundingBox.expandByPoint(Zt);else this.boundingBox.expandByPoint(bn.min),this.boundingBox.expandByPoint(bn.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))ke('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new wn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,1/0);return}if(e){let n=this.boundingSphere.center;if(bn.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(co.setFromBufferAttribute(o),this.morphTargetsRelative)Zt.addVectors(bn.min,co.min),bn.expandByPoint(Zt),Zt.addVectors(bn.max,co.max),bn.expandByPoint(Zt);else bn.expandByPoint(co.min),bn.expandByPoint(co.max)}bn.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)Zt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Zt));if(t)for(let r=0,s=t.length;r<s;r++){let o=t[r],a=this.morphTargetsRelative;for(let c=0,l=o.count;c<l;c++){if(Zt.fromBufferAttribute(o,c),a)ps.fromBufferAttribute(e,c),Zt.add(ps);i=Math.max(i,n.distanceToSquared(Zt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))ke('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){ke("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new jt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let R=0;R<n.count;R++)o[R]=new U,a[R]=new U;let c=new U,l=new U,u=new U,d=new Ue,h=new Ue,f=new Ue,m=new U,_=new U;function p(R,x,M){c.fromBufferAttribute(n,R),l.fromBufferAttribute(n,x),u.fromBufferAttribute(n,M),d.fromBufferAttribute(r,R),h.fromBufferAttribute(r,x),f.fromBufferAttribute(r,M),l.sub(c),u.sub(c),h.sub(d),f.sub(d);let z=1/(h.x*f.y-f.x*h.y);if(!isFinite(z))return;m.copy(l).multiplyScalar(f.y).addScaledVector(u,-h.y).multiplyScalar(z),_.copy(u).multiplyScalar(h.x).addScaledVector(l,-f.x).multiplyScalar(z),o[R].add(m),o[x].add(m),o[M].add(m),a[R].add(_),a[x].add(_),a[M].add(_)}let g=this.groups;if(g.length===0)g=[{start:0,count:e.count}];for(let R=0,x=g.length;R<x;++R){let M=g[R],{start:z,count:C}=M;for(let L=z,K=z+C;L<K;L+=3)p(e.getX(L+0),e.getX(L+1),e.getX(L+2))}let S=new U,T=new U,y=new U,w=new U;function A(R){y.fromBufferAttribute(i,R),w.copy(y);let x=o[R];S.copy(x),S.sub(y.multiplyScalar(y.dot(x))).normalize(),T.crossVectors(w,x);let z=T.dot(a[R])<0?-1:1;s.setXYZW(R,S.x,S.y,S.z,z)}for(let R=0,x=g.length;R<x;++R){let M=g[R],{start:z,count:C}=M;for(let L=z,K=z+C;L<K;L+=3)A(e.getX(L+0)),A(e.getX(L+1)),A(e.getX(L+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new jt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,h=n.count;d<h;d++)n.setXYZ(d,0,0,0);let i=new U,r=new U,s=new U,o=new U,a=new U,c=new U,l=new U,u=new U;if(e)for(let d=0,h=e.count;d<h;d+=3){let f=e.getX(d+0),m=e.getX(d+1),_=e.getX(d+2);i.fromBufferAttribute(t,f),r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,_),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,f),a.fromBufferAttribute(n,m),c.fromBufferAttribute(n,_),o.add(l),a.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(_,c.x,c.y,c.z)}else for(let d=0,h=t.count;d<h;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),s.fromBufferAttribute(t,d+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(d+0,l.x,l.y,l.z),n.setXYZ(d+1,l.x,l.y,l.z),n.setXYZ(d+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Zt.fromBufferAttribute(e,t),Zt.normalize(),e.setXYZ(t,Zt.x,Zt.y,Zt.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,d=new c.constructor(a.length*l),h=0,f=0;for(let m=0,_=a.length;m<_;m++){if(o.isInterleavedBufferAttribute)h=a[m]*o.data.stride+o.offset;else h=a[m]*l;for(let p=0;p<l;p++)d[f++]=c[h++]}return new jt(d,l,u)}if(this.index===null)return Le("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new sn,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let d=c[l],h=e(d,n);a.push(h)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,d=c.length;u<d;u++){let h=c[u];l.push(h.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let d=0,h=u.length;d<h;d++)l.push(u[d].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ao{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=Yn()}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Yn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Yn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}var un=new U;class Ls{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)un.fromBufferAttribute(this,t),un.applyMatrix4(e),this.setXYZ(t,un.x,un.y,un.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)un.fromBufferAttribute(this,t),un.applyNormalMatrix(e),this.setXYZ(t,un.x,un.y,un.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)un.fromBufferAttribute(this,t),un.transformDirection(e),this.setXYZ(t,un.x,un.y,un.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=qn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=dt(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=qn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=qn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=qn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=qn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=dt(t,this.array),n=dt(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array),r=dt(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){go("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new jt(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new Ls(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){go("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var Hl=new U,dS=new U,fS=new Ve;class Fn{constructor(e=new U(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=Hl.subVectors(n,t).cross(dS.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let i=e.delta(Hl),r=this.normal.dot(i);if(r===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let s=-(e.start.dot(this.normal)+this.constant)/r;if(n===!0&&(s<0||s>1))return null;return t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||fS.getNormalMatrix(e),i=this.coplanarPoint(Hl).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}var pS=0;class xn extends ei{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:pS++}),this.uuid=Yn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ze(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Le(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Le(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new ze().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new Fn().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Ue().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Ue().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}}var ki=new U,$l=new U,Ia=new U,La=new U;class fr{constructor(e=new U,t=new U(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ki)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=ki.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return ki.copy(this.origin).addScaledVector(this.direction,t),ki.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){$l.copy(e).add(t).multiplyScalar(0.5),Ia.copy(t).sub(e).normalize(),La.copy(this.origin).sub($l);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(Ia),o=La.dot(this.direction),a=-La.dot(Ia),c=La.lengthSq(),l=Math.abs(1-s*s),u,d,h,f;if(l>0)if(u=s*a-o,d=s*o-a,f=r*l,u>=0)if(d>=-f)if(d<=f){let m=1/l;u*=m,d*=m,h=u*(u+s*d+2*o)+d*(s*u+d+2*a)+c}else d=r,u=Math.max(0,-(s*d+o)),h=-u*u+d*(d+2*a)+c;else d=-r,u=Math.max(0,-(s*d+o)),h=-u*u+d*(d+2*a)+c;else if(d<=-f)u=Math.max(0,-(-s*r+o)),d=u>0?-r:Math.min(Math.max(-r,-a),r),h=-u*u+d*(d+2*a)+c;else if(d<=f)u=0,d=Math.min(Math.max(-r,-a),r),h=d*(d+2*a)+c;else u=Math.max(0,-(s*r+o)),d=u>0?r:Math.min(Math.max(-r,-a),r),h=-u*u+d*(d+2*a)+c;else d=s>0?-r:r,u=Math.max(0,-(s*d+o)),h=-u*u+d*(d+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy($l).addScaledVector(Ia,d);return h}intersectSphere(e,t){if(e.radius<0)return null;ki.subVectors(e.center,this.origin);let n=ki.dot(this.direction),i=ki.dot(ki)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;if(c>=0)n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c;else n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c;if(l>=0)r=(e.min.y-d.y)*l,s=(e.max.y-d.y)*l;else r=(e.max.y-d.y)*l,s=(e.min.y-d.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-d.z)*u,a=(e.max.z-d.z)*u;else o=(e.max.z-d.z)*u,a=(e.min.z-d.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,ki)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,d=e.y-s.y,h=e.z-s.z,f=t.x-s.x,m=t.y-s.y,_=t.z-s.z,p=n.x-s.x,g=n.y-s.y,S=n.z-s.z,T=Math.abs(a),y=Math.abs(c),w=Math.abs(l),A,R,x,M,z,C,L,K,I,G,X,P;if(T>=y&&T>=w)if(x=a,C=u,I=f,P=p,a>=0)A=c,R=l,M=d,z=h,L=m,K=_,G=g,X=S;else A=l,R=c,M=h,z=d,L=_,K=m,G=S,X=g;else if(y>=w)if(x=c,C=d,I=m,P=g,c>=0)A=l,R=a,M=h,z=u,L=_,K=f,G=S,X=p;else A=a,R=l,M=u,z=h,L=f,K=_,G=p,X=S;else if(x=l,C=h,I=_,P=S,l>=0)A=a,R=c,M=u,z=d,L=f,K=m,G=p,X=g;else A=c,R=a,M=d,z=u,L=m,K=f,G=g,X=p;if(x===0)return null;let j=A/x,k=R/x,q=1/x,Q=M-j*C,Me=z-k*C,ue=L-j*I,Be=K-k*I,we=G-j*P,Z=X-k*P,re=we*Be-Z*ue,se=Q*Z-Me*we,xe=ue*Me-Be*Q;if(i){if(re<0||se<0||xe<0)return null}else if((re<0||se<0||xe<0)&&(re>0||se>0||xe>0))return null;let Ee=re+se+xe;if(Ee===0)return null;let Ae=q*(re*C+se*I+xe*P);if(Ee>0?Ae<0:Ae>0)return null;return this.at(Ae/Ee,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class gi extends xn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ze(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 hi,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}var Vf=new $e,Ir=new fr,Na=new wn,Gf=new U,Da=new U,Oa=new U,Ua=new U,Wl=new U,Fa=new U,Hf=new U,za=new U;class Mt extends gt{constructor(e=new sn,t=new gi){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let o=this.morphTargetInfluences;if(r&&o){Fa.set(0,0,0);for(let a=0,c=r.length;a<c;a++){let l=o[a],u=r[a];if(l===0)continue;if(Wl.fromBufferAttribute(u,e),s)Fa.addScaledVector(Wl,l);else Fa.addScaledVector(Wl.sub(t),l)}t.add(Fa)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(Na.copy(n.boundingSphere),Na.applyMatrix4(r),Ir.copy(e.ray).recast(e.near),Na.containsPoint(Ir.origin)===!1){if(Ir.intersectSphere(Na,Gf)===null)return;if(Ir.origin.distanceToSquared(Gf)>(e.far-e.near)**2)return}if(Vf.copy(r).invert(),Ir.copy(e.ray).applyMatrix4(Vf),n.boundingBox!==null){if(Ir.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,Ir)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:d,drawRange:h}=r;if(o!==null)if(Array.isArray(s))for(let f=0,m=d.length;f<m;f++){let _=d[f],p=s[_.materialIndex],g=Math.max(_.start,h.start),S=Math.min(o.count,Math.min(_.start+_.count,h.start+h.count));for(let T=g,y=S;T<y;T+=3){let w=o.getX(T),A=o.getX(T+1),R=o.getX(T+2);if(i=ka(this,p,e,n,c,l,u,w,A,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,h.start),m=Math.min(o.count,h.start+h.count);for(let _=f,p=m;_<p;_+=3){let g=o.getX(_),S=o.getX(_+1),T=o.getX(_+2);if(i=ka(this,s,e,n,c,l,u,g,S,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let f=0,m=d.length;f<m;f++){let _=d[f],p=s[_.materialIndex],g=Math.max(_.start,h.start),S=Math.min(a.count,Math.min(_.start+_.count,h.start+h.count));for(let T=g,y=S;T<y;T+=3){let w=T,A=T+1,R=T+2;if(i=ka(this,p,e,n,c,l,u,w,A,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,h.start),m=Math.min(a.count,h.start+h.count);for(let _=f,p=m;_<p;_+=3){let g=_,S=_+1,T=_+2;if(i=ka(this,s,e,n,c,l,u,g,S,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}}}function mS(e,t,n,i,r,s,o,a){let c;if(t.side===1)c=i.intersectTriangle(o,s,r,!0,a);else c=i.intersectTriangle(r,s,o,t.side===0,a);if(c===null)return null;za.copy(a),za.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(za);if(l<n.near||l>n.far)return null;return{distance:l,point:za.clone(),object:e}}function ka(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,Da),e.getVertexPosition(c,Oa),e.getVertexPosition(l,Ua);let u=mS(e,t,n,i,Da,Oa,Ua,Hf);if(u){let d=new U;if(zn.getBarycoord(Hf,Da,Oa,Ua,d),r)u.uv=zn.getInterpolatedAttribute(r,a,c,l,d,new Ue);if(s)u.uv1=zn.getInterpolatedAttribute(s,a,c,l,d,new Ue);if(o){if(u.normal=zn.getInterpolatedAttribute(o,a,c,l,d,new U),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a,b:c,c:l,normal:new U,materialIndex:0};zn.getNormal(Da,Oa,Ua,h.normal),u.face=h,u.barycoord=d}return u}var lo=new ft,$f=new ft,Wf=new ft,gS=new ft,Zf=new $e,Ba=new U,Zl=new wn,Xf=new $e,Xl=new fr;class mc extends Mt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new $e,this.bindMatrixInverse=new $e,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Gt;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ba),this.boundingBox.expandByPoint(Ba)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new wn;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ba),this.boundingSphere.expandByPoint(Ba)}copy(e,t){if(super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Zl.copy(this.boundingSphere),Zl.applyMatrix4(i),e.ray.intersectsSphere(Zl)===!1)return;if(Xf.copy(i).invert(),Xl.copy(e.ray).applyMatrix4(Xf),this.boundingBox!==null){if(Xl.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,Xl)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new ft,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Le("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if($f.fromBufferAttribute(i.attributes.skinIndex,e),Wf.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)lo.copy(t),t.set(0,0,0,0);else lo.set(...t,1),t.set(0,0,0);lo.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=Wf.getComponent(r);if(s!==0){let o=$f.getComponent(r);Zf.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(gS.copy(lo).applyMatrix4(Zf),s)}}if(t.isVector4)t.w=lo.w;return t.applyMatrix4(this.bindMatrixInverse)}}class To extends gt{constructor(){super();this.isBone=!0,this.type="Bone"}}class Ro extends Nt{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,d){super(null,s,o,a,c,l,i,r,u,d);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var jf=new $e,_S=new $e;class Co{constructor(e=[],t=[]){this.uuid=Yn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Le("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new $e)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new $e;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let o=e[r]?e[r].matrixWorld:_S;jf.multiplyMatrices(o,t[r]),jf.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Co(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Ro(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)Le("Skeleton: No bone found with UUID:",r),s=new To;this.bones.push(s),this.boneInverses.push(new $e().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let o=n[i];e.boneInverses.push(o.toArray())}return e}}class ar extends jt{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}var ms=new $e,qf=new $e,Va=[],Yf=new Gt,xS=new $e,uo=new Mt,ho=new wn;class Ns extends Mt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new ar(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,xS)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Gt;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ms),Yf.copy(e.boundingBox).applyMatrix4(ms),this.boundingBox.union(Yf)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new wn;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ms),ho.copy(e.boundingSphere).applyMatrix4(ms),this.boundingSphere.union(ho)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[s+o]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(uo.geometry=this.geometry,uo.material=this.material,uo.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(ho.copy(this.boundingSphere),ho.applyMatrix4(n),e.ray.intersectsSphere(ho)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,ms),qf.multiplyMatrices(n,ms),uo.matrixWorld=qf,uo.raycast(e,Va);for(let s=0,o=Va.length;s<o;s++){let a=Va[s];a.instanceId=r,a.object=this,t.push(a)}Va.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new ar(new Float32Array(this.instanceMatrix.count*3).fill(1),3);return t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;if(this.morphTexture===null)this.morphTexture=new Ro(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let o=this.geometry.morphTargetsRelative?1:1-s,a=i*e;return r[a]=o,r.set(n,a+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}}var Lr=new wn,yS=new Ue(0.5,0.5),Ga=new U;class Po{constructor(e=new Fn,t=new Fn,n=new Fn,i=new Fn,r=new Fn,s=new Fn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],d=r[6],h=r[7],f=r[8],m=r[9],_=r[10],p=r[11],g=r[12],S=r[13],T=r[14],y=r[15];if(i[0].setComponents(c-s,h-l,p-f,y-g).normalize(),i[1].setComponents(c+s,h+l,p+f,y+g).normalize(),i[2].setComponents(c+o,h+u,p+m,y+S).normalize(),i[3].setComponents(c-o,h-u,p-m,y-S).normalize(),n)i[4].setComponents(a,d,_,T).normalize(),i[5].setComponents(c-a,h-d,p-_,y-T).normalize();else if(i[4].setComponents(c-a,h-d,p-_,y-T).normalize(),t===2000)i[5].setComponents(c+a,h+d,p+_,y+T).normalize();else if(t===2001)i[5].setComponents(a,d,_,T).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();Lr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();Lr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Lr)}intersectsSprite(e){Lr.center.set(0,0,0);let t=yS.distanceTo(e.center);return Lr.radius=0.7071067811865476+t,Lr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Lr)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(Ga.x=i.normal.x>0?e.max.x:e.min.x,Ga.y=i.normal.y>0?e.max.y:e.min.y,Ga.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ga)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Io extends xn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ze(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var Ya=new U,Ja=new U,Jf=new $e,fo=new fr,Ha=new wn,jl=new U,Kf=new U;class pr extends gt{constructor(e=new sn,t=new Io){super();this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)Ya.fromBufferAttribute(t,i-1),Ja.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Ya.distanceTo(Ja);e.setAttribute("lineDistance",new _n(n,1))}else Le("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Ha.copy(n.boundingSphere),Ha.applyMatrix4(i),Ha.radius+=r,e.ray.intersectsSphere(Ha)===!1)return;Jf.copy(i).invert(),fo.copy(e.ray).applyMatrix4(Jf);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,d=n.attributes.position;if(l!==null){let h=Math.max(0,s.start),f=Math.min(l.count,s.start+s.count);for(let m=h,_=f-1;m<_;m+=c){let p=l.getX(m),g=l.getX(m+1),S=$a(this,e,fo,a,p,g,m);if(S)t.push(S)}if(this.isLineLoop){let m=l.getX(f-1),_=l.getX(h),p=$a(this,e,fo,a,m,_,f-1);if(p)t.push(p)}}else{let h=Math.max(0,s.start),f=Math.min(d.count,s.start+s.count);for(let m=h,_=f-1;m<_;m+=c){let p=$a(this,e,fo,a,m,m+1,m);if(p)t.push(p)}if(this.isLineLoop){let m=$a(this,e,fo,a,f-1,h,f-1);if(m)t.push(m)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function $a(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(Ya.fromBufferAttribute(a,r),Ja.fromBufferAttribute(a,s),n.distanceSqToSegment(Ya,Ja,jl,Kf)>i)return;jl.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(jl);if(l<t.near||l>t.far)return;return{distance:l,point:Kf.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var Qf=new U,ep=new U;class gc extends pr{constructor(e,t){super(e,t);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)Qf.fromBufferAttribute(t,i),ep.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Qf.distanceTo(ep);e.setAttribute("lineDistance",new _n(n,1))}else Le("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class _c extends pr{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class Lo extends xn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ze(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var tp=new $e,Jl=new fr,Wa=new wn,Za=new U;class Ds extends gt{constructor(e=new sn,t=new Lo){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Wa.copy(n.boundingSphere),Wa.applyMatrix4(i),Wa.radius+=r,e.ray.intersectsSphere(Wa)===!1)return;tp.copy(i).invert(),Jl.copy(e.ray).applyMatrix4(tp);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let d=Math.max(0,s.start),h=Math.min(c.count,s.start+s.count);for(let f=d,m=h;f<m;f++){let _=c.getX(f);Za.fromBufferAttribute(u,_),np(Za,_,a,i,e,t,this)}}else{let d=Math.max(0,s.start),h=Math.min(u.count,s.start+s.count);for(let f=d,m=h;f<m;f++)Za.fromBufferAttribute(u,f),np(Za,f,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function np(e,t,n,i,r,s,o){let a=Jl.distanceSqToPoint(e);if(a<n){let c=new U;Jl.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class xc extends Nt{constructor(e=[],t=301,n,i,r,s,o,a,c,l){super(e,t,n,i,r,s,o,a,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Vr extends Nt{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:u};super(d,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new wo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class th extends Vr{constructor(e,t=1014,n=301,i,r,s=1003,o=1003,a,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,o,a,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class yc extends Nt{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class mr extends sn{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],d=0,h=0;f("z","y","x",-1,-1,n,t,e,s,r,0),f("z","y","x",1,-1,n,t,-e,s,r,1),f("x","z","y",1,1,e,n,t,i,s,2),f("x","z","y",1,-1,e,n,-t,i,s,3),f("x","y","z",1,-1,e,t,n,i,r,4),f("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new _n(c,3)),this.setAttribute("normal",new _n(l,3)),this.setAttribute("uv",new _n(u,2));function f(m,_,p,g,S,T,y,w,A,R,x){let M=T/A,z=y/R,C=T/2,L=y/2,K=w/2,I=A+1,G=R+1,X=0,P=0,j=new U;for(let k=0;k<G;k++){let q=k*z-L;for(let Q=0;Q<I;Q++){let Me=Q*M-C;j[m]=Me*g,j[_]=q*S,j[p]=K,c.push(j.x,j.y,j.z),j[m]=0,j[_]=0,j[p]=w>0?1:-1,l.push(j.x,j.y,j.z),u.push(Q/A),u.push(1-k/R),X+=1}}for(let k=0;k<R;k++)for(let q=0;q<A;q++){let Q=d+q+I*k,Me=d+q+I*(k+1),ue=d+(q+1)+I*(k+1),Be=d+(q+1)+I*k;a.push(Q,Me,Be),a.push(Me,ue,Be),P+=6}o.addGroup(h,P,x),h+=P,d+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class No extends sn{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,d=t/a,h=[],f=[],m=[],_=[];for(let p=0;p<l;p++){let g=p*d-s;for(let S=0;S<c;S++){let T=S*u-r;f.push(T,-g,0),m.push(0,0,1),_.push(S/o),_.push(1-p/a)}}for(let p=0;p<a;p++)for(let g=0;g<o;g++){let S=g+c*p,T=g+c*(p+1),y=g+1+c*(p+1),w=g+1+c*p;h.push(S,T,w),h.push(T,y,w)}this.setIndex(h),this.setAttribute("position",new _n(f,3)),this.setAttribute("normal",new _n(m,3)),this.setAttribute("uv",new _n(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new No(e.width,e.height,e.widthSegments,e.heightSegments)}}function Gr(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(ip(r))if(r.isRenderTargetTexture)Le("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(ip(r[0])){let s=[];for(let o=0,a=r.length;o<a;o++)s[o]=r[o].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function on(e){let t={};for(let n=0;n<e.length;n++){let i=Gr(e[n]);for(let r in i)t[r]=i[r]}return t}function ip(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function vS(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function nh(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return je.workingColorSpace}var um={clone:Gr,merge:on},bS=`void main() {gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );-}`,yS=`void main() {+}`,SS=`void main() {gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );-}`;class Bn extends yn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=xS,this.fragmentShader=yS,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0)this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Gr(e.uniforms),this.uniformsGroups=_S(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new ze().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ue().fromArray(i.value);break;case"v3":this.uniforms[n].value=new U().fromArray(i.value);break;case"v4":this.uniforms[n].value=new ft().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Ve().fromArray(i.value);break;case"m4":this.uniforms[n].value=new $e().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class th extends Bn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Hi extends yn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ze(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ue(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class An extends Hi{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ue(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return qe(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ze(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ze(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ze(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class xc extends yn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ze(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ue(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hi,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class nh extends yn{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class ih extends yn{constructor(e){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function or(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function Xa(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function vS(e){function t(r,s){return e[r]-e[s]}let n=e.length,i=Array(n);for(let r=0;r!==n;++r)i[r]=r;return i.sort(t),i}function np(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,o=0;o!==i;++s){let a=n[s]*t;for(let c=0;c!==t;++c)r[o++]=e[a+c]}return r}function bS(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let o=s[i];if(o===void 0)return;if(Array.isArray(o))do{if(o=s[i],o!==void 0)t.push(s.time),n.push(...o);s=e[r++]}while(s!==void 0);else if(o.toArray!==void 0)do{if(o=s[i],o!==void 0)t.push(s.time),o.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(o=s[i],o!==void 0)t.push(s.time),n.push(o);s=e[r++]}while(s!==void 0)}class $i{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let o=t[1];if(e<o)n=2,r=o;for(let a=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let o=n+s>>>1;if(e<t[o])s=o;else n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class rh extends $i{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,h=this._weightNext,f=(n-t)/(i-t),m=f*f,_=m*f,p=-d*_+2*d*m-d*f,g=(1+d)*_+(-1.5-2*d)*m+(-0.5+d)*f+1,S=(-1-h)*_+(1.5+h)*m+0.5*f,T=h*_-h*m;for(let y=0;y!==o;++y)r[y]=p*s[l+y]+g*s[c+y]+S*s[a+y]+T*s[u+y];return r}}class yc extends $i{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let d=0;d!==o;++d)r[d]=s[c+d]*u+s[a+d]*l;return r}}class sh extends $i{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class oh extends $i{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let f=(n-t)/(i-t),m=1-f;for(let _=0;_!==o;++_)r[_]=s[c+_]*m+s[a+_]*f;return r}let d=o*2,h=e-1;for(let f=0;f!==o;++f){let m=s[c+f],_=s[a+f],p=h*d+f*2,g=u[p],S=u[p+1],T=e*d+f*2,y=l[T],w=l[T+1],A=MS(n,t,g,y,i);r[f]=lm(A,m,S,w,_)}return r}}function lm(e,t,n,i,r){let s=1-e;return s*s*s*t+3*s*s*e*n+3*s*e*e*i+e*e*e*r}function SS(e,t,n,i,r){let s=1-e;return 3*s*s*(n-t)+6*s*e*(i-n)+3*e*e*(r-i)}function MS(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=lm(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=SS(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-a/c))}return s}class Tn{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=or(t,this.TimeBufferType),this.values=or(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:or(e.times,Array),values:or(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Xa(e.settings))n.settings={inTangents:or(e.settings.inTangents,Array),outTangents:or(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new sh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new yc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new rh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new oh(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return Le("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(Xa(this.settings))ip(this.settings.inTangents,e),ip(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)ke("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)ke("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){ke("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){ke("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(Nb(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){ke("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,d=u-n,h=u+n;for(let f=0;f!==n;++f){let m=t[u+f];if(m!==t[d+f]||m!==t[h+f]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,d=s*n;for(let h=0;h!==n;++h)t[d+h]=t[u+h]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,Xa(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function ip(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}Tn.prototype.ValueTypeName="";Tn.prototype.TimeBufferType=Float32Array;Tn.prototype.ValueBufferType=Float32Array;Tn.prototype.DefaultInterpolation=2301;class gr extends Tn{constructor(e,t,n){super(e,t,n)}}gr.prototype.ValueTypeName="bool";gr.prototype.ValueBufferType=Array;gr.prototype.DefaultInterpolation=2300;gr.prototype.InterpolantFactoryMethodLinear=void 0;gr.prototype.InterpolantFactoryMethodSmooth=void 0;class vc extends Tn{constructor(e,t,n,i){super(e,t,n,i)}}vc.prototype.ValueTypeName="color";class _r extends Tn{constructor(e,t,n,i){super(e,t,n,i)}}_r.prototype.ValueTypeName="number";class ah extends $i{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(n-t)/(i-t),c=e*o;for(let l=c+o;c!==l;c+=4)Xt.slerpFlat(r,0,s,c-o,s,c,a);return r}}class xr extends Tn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new ah(this.times,this.values,this.getValueSize(),e)}}xr.prototype.ValueTypeName="quaternion";xr.prototype.InterpolantFactoryMethodSmooth=void 0;class yr extends Tn{constructor(e,t,n){super(e,t,n)}}yr.prototype.ValueTypeName="string";yr.prototype.ValueBufferType=Array;yr.prototype.DefaultInterpolation=2300;yr.prototype.InterpolantFactoryMethodLinear=void 0;yr.prototype.InterpolantFactoryMethodSmooth=void 0;class Hr extends Tn{constructor(e,t,n,i){super(e,t,n,i)}}Hr.prototype.ValueTypeName="vector";class Ss{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Yn(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,o=n.length;s!==o;++s)t.push(ES(n[s]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=n.length;r!==s;++r)t.push(Tn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let o=0;o<r;o++){let a=[],c=[];a.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);let l=vS(a);if(a=np(a,1,l),c=np(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new _r(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],d=i[u];if(!d)i[u]=d=[];d.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function wS(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return _r;case"vector":case"vector2":case"vector3":case"vector4":return Hr;case"color":return vc;case"quaternion":return xr;case"bool":case"boolean":return gr;case"string":return yr}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function ES(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=wS(e.type);if(e.times===void 0){let i=[],r=[];bS(e.keys,i,r,"value"),e.times=i,e.values=r}let n;if(t.parse!==void 0)n=t.parse(e);else n=new t(e.name,e.times,e.values,e.interpolation);if(Xa(e.settings))n.settings={inTangents:or(e.settings.inTangents,Float32Array),outTangents:or(e.settings.outTangents,Float32Array)};return n}var ui={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(rp(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(rp(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function rp(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class No{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,d=c.length;u<d;u+=2){let h=c[u],f=c[u+1];if(h.global)h.lastIndex=0;if(h.test(l))return f}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var um=new No;class Wi{constructor(e){if(this.manager=e!==void 0?e:um,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Wi.DEFAULT_MATERIAL_NAME="__DEFAULT";var Bi={};class hm extends Error{constructor(e,t){super(e);this.response=t}}class Do extends Wi{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=ui.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Bi[e]!==void 0){Bi[e].push({onLoad:t,onProgress:n,onError:i});return}Bi[e]=[],Bi[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Le("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Bi[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),h=d?parseInt(d):0,f=h!==0,m=0,_=new ReadableStream({start(p){g();function g(){u.read().then(({done:S,value:T})=>{if(S)p.close();else{m+=T.byteLength;let y=new ProgressEvent("progress",{lengthComputable:f,loaded:m,total:h});for(let w=0,A=l.length;w<A;w++){let R=l[w];if(R.onProgress)R.onProgress(y)}p.enqueue(T),g()}},(S)=>{p.error(S)})}}});return new Response(_)}else throw new hm(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,h=new TextDecoder(d);return c.arrayBuffer().then((f)=>h.decode(f))}}}).then((c)=>{ui.add(`file:${e}`,c);let l=Bi[e];delete Bi[e];for(let u=0,d=l.length;u<d;u++){let h=l[u];if(h.onLoad)h.onLoad(c)}}).catch((c)=>{let l=Bi[e];if(l===void 0)throw this.manager.itemError(e),c;delete Bi[e];for(let u=0,d=l.length;u<d;u++){let h=l[u];if(h.onError)h.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var gs=new WeakMap;class ch extends Wi{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ui.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);else{let u=gs.get(s);if(u===void 0)u=[],gs.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=vs("img");function a(){if(l(),t)t(this);let u=gs.get(this)||[];for(let d=0;d<u.length;d++){let h=u[d];if(h.onLoad)h.onLoad(this)}gs.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);ui.remove(`image:${e}`);let d=gs.get(this)||[];for(let h=0;h<d.length;h++){let f=d[h];if(f.onError)f.onError(u)}gs.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1)}if(o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)o.crossOrigin=this.crossOrigin}return ui.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class Os extends Wi{constructor(e){super(e)}load(e,t,n,i){let r=new Nt,s=new ch(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class Us extends gt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new ze(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class bc extends Us{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ze(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var Xl=new $e,sp=new U,op=new U;class Oo{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ue(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new $e,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Co,this._frameExtents=new Ue(1,1),this._viewportCount=1,this._viewports=[new ft(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;sp.setFromMatrixPosition(e.matrixWorld),t.position.copy(sp),op.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(op),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){Xl.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(Xl,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,o=i?i.w/r.y:1,a=i?i.x/r.x:0,c=i?i.y/r.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,0.5,0.5,0,0,0,1);t.multiply(Xl)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}var Wa=new U,Za=new Xt,ci=new U;class Sc extends gt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new $e,this.projectionMatrix=new $e,this.projectionMatrixInverse=new $e,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(Wa,Za,ci),ci.x===1&&ci.y===1&&ci.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Wa,Za,ci.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Wa,Za,ci),ci.x===1&&ci.y===1&&ci.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Wa,Za,ci.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var sr=new U,ap=new Ue,cp=new Ue;class Vt extends Sc{constructor(e=50,t=1,n=0.1,i=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=0.5*this.getFilmHeight()/e;this.fov=Dr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(fo*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return Dr*2*Math.atan(Math.tan(fo*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){sr.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(sr.x,sr.y).multiplyScalar(-e/sr.z),sr.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(sr.x,sr.y).multiplyScalar(-e/sr.z)}getViewSize(e,t){return this.getViewBounds(e,ap,cp),t.subVectors(cp,ap)}setViewOffset(e,t,n,i,r,s){if(this.aspect=e/t,this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(fo*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:a,fullHeight:c}=s;r+=s.offsetX*i/a,t-=s.offsetY*n/c,i*=s.width/a,n*=s.height/c}let o=this.filmOffset;if(o!==0)r+=e*o/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null)t.object.view=Object.assign({},this.view);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class dm extends Oo{constructor(){super(new Vt(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=Dr*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;if(n!==t.fov||i!==t.aspect||r!==t.far)t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix();super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}}class Mc extends Us{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new dm}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);if(t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture)t.object.map=this.map.toJSON(e).uuid;return t.object.shadow=this.shadow.toJSON(),t}}class fm extends Oo{constructor(){super(new Vt(90,1,0.5,500));this.isPointLightShadow=!0}}class Fs extends Us{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new fm}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class $r extends Sc{constructor(e=-1,t=1,n=1,i=-1,r=0.1,s=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){if(this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,s=n+e,o=i+t,a=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,o-=l*this.view.offsetY,a=o-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null)t.object.view=Object.assign({},this.view);return t}}class pm extends Oo{constructor(){super(new $r(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class zs extends Us{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.shadow=new pm}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class vr{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}var jl=new WeakMap;class wc extends Wi{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Le("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Le("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ui.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(jl.has(s)===!0){if(i)i(jl.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let a=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(ui.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);jl.set(a,c),ui.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});ui.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var _s=-90,xs=1;class lh extends gt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Vt(_s,xs,e,t);i.layers=this.layers,this.add(i);let r=new Vt(_s,xs,e,t);r.layers=this.layers,this.add(r);let s=new Vt(_s,xs,e,t);s.layers=this.layers,this.add(s);let o=new Vt(_s,xs,e,t);o.layers=this.layers,this.add(o);let a=new Vt(_s,xs,e,t);a.layers=this.layers,this.add(a);let c=new Vt(_s,xs,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),f=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let _=!1;if(e.isWebGLRenderer===!0)_=e.state.buffers.depth.getReversed();else _=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,i),_&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,d,h),e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class uh extends Vt{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class hh{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let o=0;o!==i;++o)n[r+o]=n[o];s=t}else{s+=t;let o=t/s;this._mixBufferRegion(n,r,0,o,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let a=t*this._origIndex;this._mixBufferRegion(n,i,a,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let a=t,c=t+t;a!==c;++a)if(n[a]!==n[a+t]){o.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){Xt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Xt.multiplyQuaternionsFlat(e,s,e,t,e,n),Xt.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var dh="\\[\\]\\.:\\/",AS=new RegExp("["+dh+"]","g"),fh="[^"+dh+"]",TS="[^"+dh.replace("\\.","")+"]",RS=/((?:WC+[\/:])*)/.source.replace("WC",fh),CS=/(WCOD+)?/.source.replace("WCOD",TS),PS=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",fh),IS=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",fh),LS=new RegExp("^"+RS+CS+PS+IS+"$"),NS=["material","materials","bones","map"];class mm{constructor(e,t,n){let i=n||ot.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ot{constructor(e,t,n){this.path=t,this.parsedPath=n||ot.parseTrackName(t),this.node=ot.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new ot(e,t,n);else return new ot.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(AS,"")}static parseTrackName(e){let t=LS.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);if(NS.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=ot.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Le("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ke("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){ke("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ke("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){ke("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){ke("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;ke("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ot.Composite=mm;ot.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ot.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ot.prototype.GetterByBindingType=[ot.prototype._getValue_direct,ot.prototype._getValue_array,ot.prototype._getValue_arrayElement,ot.prototype._getValue_toArray];ot.prototype.SetterByBindingTypeAndVersioning=[[ot.prototype._setValue_direct,ot.prototype._setValue_direct_setNeedsUpdate,ot.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_array,ot.prototype._setValue_array_setNeedsUpdate,ot.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_arrayElement,ot.prototype._setValue_arrayElement_setNeedsUpdate,ot.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_fromArray,ot.prototype._setValue_fromArray_setNeedsUpdate,ot.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class ph{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,s=r.length,o=Array(s),a={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);o[c]=l,l.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,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(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,r=e._clip.duration,s=r/i,o=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;if(e!==null)this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,s=this.timeScale,o=this._timeScaleInterpolant;if(o===null)o=i._lendControlInterpolant(),this._timeScaleInterpolant=o;let a=o.parameterPositions,c=o.sampleValues;return a[0]=r,a[1]=r+n,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;if(e!==null)this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}let r=this._startTime;if(r!==null){let a=(e-r)*n;if(a<0||n===0)t=0;else this._startTime=null,t=n*a}t*=this._updateTimeScale(e);let s=this._updateTime(t),o=this._updateWeight(e);if(o>0){let a=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulateAdditive(o);break;case 2500:default:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(this.stopFading(),i===0)this.enabled=!1}}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(t===0)this.paused=!0;else{if(this._restoreTimeScale!==null)t=this._restoreTimeScale;this.timeScale=t}this.stopWarping()}}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,s=n===2202;if(e===0){if(r===-1)return i;return s&&(r&1)===1?t-i:i}if(n===2200){if(r===-1)this._loopCount=0,this._setEndings(!0,!0,!1);e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1)if(e>=0)r=0,this._setEndings(!0,this.repetitions===0,s);else this._setEndings(this.repetitions===0,!0,s);if(i>=t||i<0){let o=Math.floor(i/t);i-=t*o,r+=Math.abs(o);let a=this.repetitions-r;if(a<=0){if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1})}else{if(a===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=r,this.time=i;if(s&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;if(n)i.endingStart=2401,i.endingEnd=2401;else{if(e)i.endingStart=this.zeroSlopeAtStart?2401:2400;else i.endingStart=2402;if(t)i.endingEnd=this.zeroSlopeAtEnd?2401:2400;else i.endingEnd=2402}}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,s=this._weightInterpolant;if(s===null)s=i._lendControlInterpolant(),this._weightInterpolant=s;let o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=t,o[1]=r+e,a[1]=n,this}}var DS=new Float32Array(1);class Ec extends ei{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let d=i[u],h=d.name,f=l[h];if(f!==void 0)++f.referenceCount,s[u]=f;else{if(f=s[u],f!==void 0){if(f._cacheIndex===null)++f.referenceCount,this._addInactiveBinding(f,a,h);continue}let m=t&&t._propertyBindings[u].binding.parsedPath;f=new hh(ot.create(n,h,m),d.ValueTypeName,d.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,a,h),s[u]=f}o[u].resultBuffer=f.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,d=(e._localRoot||this._root).uuid;if(delete u[d],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new yc(new Float32Array(2),new Float32Array(2),1,DS),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,s=typeof e==="string"?Ss.findByName(i,e):e,o=s!==null?s.uuid:e,a=this._actionsByClip[o],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(a!==void 0){let u=a.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=a.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new ph(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?Ss.findByName(n,e):e,s=r?r.uuid:e,o=this._actionsByClip[s];if(o!==void 0)return o.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let o=this._bindings,a=this._nActiveBindings;for(let c=0;c!==a;++c)o[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let o=0,a=s.length;o!==a;++o){let c=s[o];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let o=n[s].actionByRoot,a=o[t];if(a!==void 0)this._deactivateAction(a),this._removeInactiveAction(a)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}}class Uo{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=qe(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(qe(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class mh{static{mh.prototype.isMatrix2=!0}constructor(e,t,n,i){if(this.elements=[1,0,0,1],e!==void 0)this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}class Ac extends ei{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}}function gh(e,t,n,i){let r=OS(i);switch(n){case 1021:return e*t;case 1028:return e*t/r.components*r.byteLength;case 1029:return e*t/r.components*r.byteLength;case 1030:return e*t*2/r.components*r.byteLength;case 1031:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case 1023:return e*t*4/r.components*r.byteLength;case 1033:return e*t*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function OS(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Le("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Fm(){let e=null,t=!1,n=null,i=null;function r(s,o){i=e.requestAnimationFrame(r),n(s,o)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(r),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(s){n=s},setContext:function(s){e=s}}}function US(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,d=l.byteLength,h=e.createBuffer();e.bindBuffer(c,h),e.bufferData(c,l,u),a.onUploadCallback();let f;if(l instanceof Float32Array)f=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)f=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)f=e.HALF_FLOAT;else f=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=e.SHORT;else if(l instanceof Uint32Array)f=e.UNSIGNED_INT;else if(l instanceof Int32Array)f=e.INT;else if(l instanceof Int8Array)f=e.BYTE;else if(l instanceof Uint8Array)f=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:d}}function i(a,c,l){let{array:u,updateRanges:d}=c;if(e.bindBuffer(l,a),d.length===0)e.bufferSubData(l,0,u);else{d.sort((f,m)=>f.start-m.start);let h=0;for(let f=1;f<d.length;f++){let m=d[h],_=d[f];if(_.start<=m.start+m.count+1)m.count=Math.max(m.count,_.start+_.count-m.start);else++h,d[h]=_}d.length=h+1;for(let f=0,m=d.length;f<m;f++){let _=d[f];e.bufferSubData(l,_.start*u.BYTES_PER_ELEMENT,u,_.start,_.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var FS=`#ifdef USE_ALPHAHASH+}`;class Bn extends xn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=bS,this.fragmentShader=SS,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0)this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Gr(e.uniforms),this.uniformsGroups=vS(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new ze().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ue().fromArray(i.value);break;case"v3":this.uniforms[n].value=new U().fromArray(i.value);break;case"v4":this.uniforms[n].value=new ft().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Ve().fromArray(i.value);break;case"m4":this.uniforms[n].value=new $e().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class ih extends Bn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Hi extends xn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ze(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ue(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class En extends Hi{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ue(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return qe(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ze(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ze(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ze(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class vc extends xn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ze(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ue(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hi,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class rh extends xn{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class sh extends xn{constructor(e){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function or(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function qa(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function MS(e){function t(r,s){return e[r]-e[s]}let n=e.length,i=Array(n);for(let r=0;r!==n;++r)i[r]=r;return i.sort(t),i}function rp(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,o=0;o!==i;++s){let a=n[s]*t;for(let c=0;c!==t;++c)r[o++]=e[a+c]}return r}function wS(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let o=s[i];if(o===void 0)return;if(Array.isArray(o))do{if(o=s[i],o!==void 0)t.push(s.time),n.push(...o);s=e[r++]}while(s!==void 0);else if(o.toArray!==void 0)do{if(o=s[i],o!==void 0)t.push(s.time),o.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(o=s[i],o!==void 0)t.push(s.time),n.push(o);s=e[r++]}while(s!==void 0)}class $i{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let o=t[1];if(e<o)n=2,r=o;for(let a=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let o=n+s>>>1;if(e<t[o])s=o;else n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class oh extends $i{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,h=this._weightNext,f=(n-t)/(i-t),m=f*f,_=m*f,p=-d*_+2*d*m-d*f,g=(1+d)*_+(-1.5-2*d)*m+(-0.5+d)*f+1,S=(-1-h)*_+(1.5+h)*m+0.5*f,T=h*_-h*m;for(let y=0;y!==o;++y)r[y]=p*s[l+y]+g*s[c+y]+S*s[a+y]+T*s[u+y];return r}}class bc extends $i{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let d=0;d!==o;++d)r[d]=s[c+d]*u+s[a+d]*l;return r}}class ah extends $i{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class ch extends $i{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let f=(n-t)/(i-t),m=1-f;for(let _=0;_!==o;++_)r[_]=s[c+_]*m+s[a+_]*f;return r}let d=o*2,h=e-1;for(let f=0;f!==o;++f){let m=s[c+f],_=s[a+f],p=h*d+f*2,g=u[p],S=u[p+1],T=e*d+f*2,y=l[T],w=l[T+1],A=AS(n,t,g,y,i);r[f]=hm(A,m,S,w,_)}return r}}function hm(e,t,n,i,r){let s=1-e;return s*s*s*t+3*s*s*e*n+3*s*e*e*i+e*e*e*r}function ES(e,t,n,i,r){let s=1-e;return 3*s*s*(n-t)+6*s*e*(i-n)+3*e*e*(r-i)}function AS(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=hm(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=ES(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-a/c))}return s}class An{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=or(t,this.TimeBufferType),this.values=or(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:or(e.times,Array),values:or(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(qa(e.settings))n.settings={inTangents:or(e.settings.inTangents,Array),outTangents:or(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new ah(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new bc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new oh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new ch(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return Le("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(qa(this.settings))sp(this.settings.inTangents,e),sp(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)ke("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)ke("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){ke("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){ke("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(Ub(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){ke("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,d=u-n,h=u+n;for(let f=0;f!==n;++f){let m=t[u+f];if(m!==t[d+f]||m!==t[h+f]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,d=s*n;for(let h=0;h!==n;++h)t[d+h]=t[u+h]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,qa(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function sp(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}An.prototype.ValueTypeName="";An.prototype.TimeBufferType=Float32Array;An.prototype.ValueBufferType=Float32Array;An.prototype.DefaultInterpolation=2301;class gr extends An{constructor(e,t,n){super(e,t,n)}}gr.prototype.ValueTypeName="bool";gr.prototype.ValueBufferType=Array;gr.prototype.DefaultInterpolation=2300;gr.prototype.InterpolantFactoryMethodLinear=void 0;gr.prototype.InterpolantFactoryMethodSmooth=void 0;class Sc extends An{constructor(e,t,n,i){super(e,t,n,i)}}Sc.prototype.ValueTypeName="color";class _r extends An{constructor(e,t,n,i){super(e,t,n,i)}}_r.prototype.ValueTypeName="number";class lh extends $i{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(n-t)/(i-t),c=e*o;for(let l=c+o;c!==l;c+=4)Xt.slerpFlat(r,0,s,c-o,s,c,a);return r}}class xr extends An{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new lh(this.times,this.values,this.getValueSize(),e)}}xr.prototype.ValueTypeName="quaternion";xr.prototype.InterpolantFactoryMethodSmooth=void 0;class yr extends An{constructor(e,t,n){super(e,t,n)}}yr.prototype.ValueTypeName="string";yr.prototype.ValueBufferType=Array;yr.prototype.DefaultInterpolation=2300;yr.prototype.InterpolantFactoryMethodLinear=void 0;yr.prototype.InterpolantFactoryMethodSmooth=void 0;class Hr extends An{constructor(e,t,n,i){super(e,t,n,i)}}Hr.prototype.ValueTypeName="vector";class Ss{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Yn(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,o=n.length;s!==o;++s)t.push(RS(n[s]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=n.length;r!==s;++r)t.push(An.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let o=0;o<r;o++){let a=[],c=[];a.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);let l=MS(a);if(a=rp(a,1,l),c=rp(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new _r(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],d=i[u];if(!d)i[u]=d=[];d.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function TS(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return _r;case"vector":case"vector2":case"vector3":case"vector4":return Hr;case"color":return Sc;case"quaternion":return xr;case"bool":case"boolean":return gr;case"string":return yr}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function RS(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=TS(e.type);if(e.times===void 0){let i=[],r=[];wS(e.keys,i,r,"value"),e.times=i,e.values=r}let n;if(t.parse!==void 0)n=t.parse(e);else n=new t(e.name,e.times,e.values,e.interpolation);if(qa(e.settings))n.settings={inTangents:or(e.settings.inTangents,Float32Array),outTangents:or(e.settings.outTangents,Float32Array)};return n}var ui={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(op(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(op(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function op(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class Do{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,d=c.length;u<d;u+=2){let h=c[u],f=c[u+1];if(h.global)h.lastIndex=0;if(h.test(l))return f}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var dm=new Do;class Wi{constructor(e){if(this.manager=e!==void 0?e:dm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Wi.DEFAULT_MATERIAL_NAME="__DEFAULT";var Bi={};class fm extends Error{constructor(e,t){super(e);this.response=t}}class Oo extends Wi{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=ui.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Bi[e]!==void 0){Bi[e].push({onLoad:t,onProgress:n,onError:i});return}Bi[e]=[],Bi[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Le("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Bi[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),h=d?parseInt(d):0,f=h!==0,m=0,_=new ReadableStream({start(p){g();function g(){u.read().then(({done:S,value:T})=>{if(S)p.close();else{m+=T.byteLength;let y=new ProgressEvent("progress",{lengthComputable:f,loaded:m,total:h});for(let w=0,A=l.length;w<A;w++){let R=l[w];if(R.onProgress)R.onProgress(y)}p.enqueue(T),g()}},(S)=>{p.error(S)})}}});return new Response(_)}else throw new fm(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,h=new TextDecoder(d);return c.arrayBuffer().then((f)=>h.decode(f))}}}).then((c)=>{ui.add(`file:${e}`,c);let l=Bi[e];delete Bi[e];for(let u=0,d=l.length;u<d;u++){let h=l[u];if(h.onLoad)h.onLoad(c)}}).catch((c)=>{let l=Bi[e];if(l===void 0)throw this.manager.itemError(e),c;delete Bi[e];for(let u=0,d=l.length;u<d;u++){let h=l[u];if(h.onError)h.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var gs=new WeakMap;class uh extends Wi{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ui.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);else{let u=gs.get(s);if(u===void 0)u=[],gs.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=vs("img");function a(){if(l(),t)t(this);let u=gs.get(this)||[];for(let d=0;d<u.length;d++){let h=u[d];if(h.onLoad)h.onLoad(this)}gs.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);ui.remove(`image:${e}`);let d=gs.get(this)||[];for(let h=0;h<d.length;h++){let f=d[h];if(f.onError)f.onError(u)}gs.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1)}if(o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)o.crossOrigin=this.crossOrigin}return ui.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class Os extends Wi{constructor(e){super(e)}load(e,t,n,i){let r=new Nt,s=new uh(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class Us extends gt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new ze(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class Mc extends Us{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ze(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var ql=new $e,ap=new U,cp=new U;class Uo{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ue(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new $e,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Po,this._frameExtents=new Ue(1,1),this._viewportCount=1,this._viewports=[new ft(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;ap.setFromMatrixPosition(e.matrixWorld),t.position.copy(ap),cp.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(cp),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){ql.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(ql,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,o=i?i.w/r.y:1,a=i?i.x/r.x:0,c=i?i.y/r.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,0.5,0.5,0,0,0,1);t.multiply(ql)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}var Xa=new U,ja=new Xt,ci=new U;class wc extends gt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new $e,this.projectionMatrix=new $e,this.projectionMatrixInverse=new $e,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(Xa,ja,ci),ci.x===1&&ci.y===1&&ci.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Xa,ja,ci.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Xa,ja,ci),ci.x===1&&ci.y===1&&ci.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Xa,ja,ci.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var sr=new U,lp=new Ue,up=new Ue;class Vt extends wc{constructor(e=50,t=1,n=0.1,i=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=0.5*this.getFilmHeight()/e;this.fov=Dr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(po*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return Dr*2*Math.atan(Math.tan(po*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){sr.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(sr.x,sr.y).multiplyScalar(-e/sr.z),sr.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(sr.x,sr.y).multiplyScalar(-e/sr.z)}getViewSize(e,t){return this.getViewBounds(e,lp,up),t.subVectors(up,lp)}setViewOffset(e,t,n,i,r,s){if(this.aspect=e/t,this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(po*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:a,fullHeight:c}=s;r+=s.offsetX*i/a,t-=s.offsetY*n/c,i*=s.width/a,n*=s.height/c}let o=this.filmOffset;if(o!==0)r+=e*o/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null)t.object.view=Object.assign({},this.view);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class pm extends Uo{constructor(){super(new Vt(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=Dr*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;if(n!==t.fov||i!==t.aspect||r!==t.far)t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix();super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}}class Ec extends Us{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new pm}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);if(t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture)t.object.map=this.map.toJSON(e).uuid;return t.object.shadow=this.shadow.toJSON(),t}}class mm extends Uo{constructor(){super(new Vt(90,1,0.5,500));this.isPointLightShadow=!0}}class Fs extends Us{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new mm}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class $r extends wc{constructor(e=-1,t=1,n=1,i=-1,r=0.1,s=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){if(this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,s=n+e,o=i+t,a=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,o-=l*this.view.offsetY,a=o-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null)t.object.view=Object.assign({},this.view);return t}}class gm extends Uo{constructor(){super(new $r(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class zs extends Us{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.shadow=new gm}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class vr{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}var Yl=new WeakMap;class Ac extends Wi{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Le("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Le("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ui.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(Yl.has(s)===!0){if(i)i(Yl.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let a=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(ui.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);Yl.set(a,c),ui.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});ui.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var _s=-90,xs=1;class hh extends gt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Vt(_s,xs,e,t);i.layers=this.layers,this.add(i);let r=new Vt(_s,xs,e,t);r.layers=this.layers,this.add(r);let s=new Vt(_s,xs,e,t);s.layers=this.layers,this.add(s);let o=new Vt(_s,xs,e,t);o.layers=this.layers,this.add(o);let a=new Vt(_s,xs,e,t);a.layers=this.layers,this.add(a);let c=new Vt(_s,xs,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),f=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let _=!1;if(e.isWebGLRenderer===!0)_=e.state.buffers.depth.getReversed();else _=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,i),_&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,d,h),e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class dh extends Vt{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class fh{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let o=0;o!==i;++o)n[r+o]=n[o];s=t}else{s+=t;let o=t/s;this._mixBufferRegion(n,r,0,o,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let a=t*this._origIndex;this._mixBufferRegion(n,i,a,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let a=t,c=t+t;a!==c;++a)if(n[a]!==n[a+t]){o.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){Xt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Xt.multiplyQuaternionsFlat(e,s,e,t,e,n),Xt.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var ph="\\[\\]\\.:\\/",CS=new RegExp("["+ph+"]","g"),mh="[^"+ph+"]",PS="[^"+ph.replace("\\.","")+"]",IS=/((?:WC+[\/:])*)/.source.replace("WC",mh),LS=/(WCOD+)?/.source.replace("WCOD",PS),NS=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",mh),DS=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",mh),OS=new RegExp("^"+IS+LS+NS+DS+"$"),US=["material","materials","bones","map"];class _m{constructor(e,t,n){let i=n||ot.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ot{constructor(e,t,n){this.path=t,this.parsedPath=n||ot.parseTrackName(t),this.node=ot.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new ot(e,t,n);else return new ot.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(CS,"")}static parseTrackName(e){let t=OS.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);if(US.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=ot.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Le("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ke("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){ke("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ke("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){ke("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){ke("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;ke("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ot.Composite=_m;ot.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ot.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ot.prototype.GetterByBindingType=[ot.prototype._getValue_direct,ot.prototype._getValue_array,ot.prototype._getValue_arrayElement,ot.prototype._getValue_toArray];ot.prototype.SetterByBindingTypeAndVersioning=[[ot.prototype._setValue_direct,ot.prototype._setValue_direct_setNeedsUpdate,ot.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_array,ot.prototype._setValue_array_setNeedsUpdate,ot.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_arrayElement,ot.prototype._setValue_arrayElement_setNeedsUpdate,ot.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_fromArray,ot.prototype._setValue_fromArray_setNeedsUpdate,ot.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class gh{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,s=r.length,o=Array(s),a={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);o[c]=l,l.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,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(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,r=e._clip.duration,s=r/i,o=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;if(e!==null)this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,s=this.timeScale,o=this._timeScaleInterpolant;if(o===null)o=i._lendControlInterpolant(),this._timeScaleInterpolant=o;let a=o.parameterPositions,c=o.sampleValues;return a[0]=r,a[1]=r+n,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;if(e!==null)this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}let r=this._startTime;if(r!==null){let a=(e-r)*n;if(a<0||n===0)t=0;else this._startTime=null,t=n*a}t*=this._updateTimeScale(e);let s=this._updateTime(t),o=this._updateWeight(e);if(o>0){let a=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulateAdditive(o);break;case 2500:default:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(this.stopFading(),i===0)this.enabled=!1}}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(t===0)this.paused=!0;else{if(this._restoreTimeScale!==null)t=this._restoreTimeScale;this.timeScale=t}this.stopWarping()}}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,s=n===2202;if(e===0){if(r===-1)return i;return s&&(r&1)===1?t-i:i}if(n===2200){if(r===-1)this._loopCount=0,this._setEndings(!0,!0,!1);e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1)if(e>=0)r=0,this._setEndings(!0,this.repetitions===0,s);else this._setEndings(this.repetitions===0,!0,s);if(i>=t||i<0){let o=Math.floor(i/t);i-=t*o,r+=Math.abs(o);let a=this.repetitions-r;if(a<=0){if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1})}else{if(a===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=r,this.time=i;if(s&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;if(n)i.endingStart=2401,i.endingEnd=2401;else{if(e)i.endingStart=this.zeroSlopeAtStart?2401:2400;else i.endingStart=2402;if(t)i.endingEnd=this.zeroSlopeAtEnd?2401:2400;else i.endingEnd=2402}}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,s=this._weightInterpolant;if(s===null)s=i._lendControlInterpolant(),this._weightInterpolant=s;let o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=t,o[1]=r+e,a[1]=n,this}}var FS=new Float32Array(1);class Tc extends ei{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let d=i[u],h=d.name,f=l[h];if(f!==void 0)++f.referenceCount,s[u]=f;else{if(f=s[u],f!==void 0){if(f._cacheIndex===null)++f.referenceCount,this._addInactiveBinding(f,a,h);continue}let m=t&&t._propertyBindings[u].binding.parsedPath;f=new fh(ot.create(n,h,m),d.ValueTypeName,d.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,a,h),s[u]=f}o[u].resultBuffer=f.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,d=(e._localRoot||this._root).uuid;if(delete u[d],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new bc(new Float32Array(2),new Float32Array(2),1,FS),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,s=typeof e==="string"?Ss.findByName(i,e):e,o=s!==null?s.uuid:e,a=this._actionsByClip[o],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(a!==void 0){let u=a.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=a.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new gh(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?Ss.findByName(n,e):e,s=r?r.uuid:e,o=this._actionsByClip[s];if(o!==void 0)return o.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let o=this._bindings,a=this._nActiveBindings;for(let c=0;c!==a;++c)o[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let o=0,a=s.length;o!==a;++o){let c=s[o];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let o=n[s].actionByRoot,a=o[t];if(a!==void 0)this._deactivateAction(a),this._removeInactiveAction(a)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}}class Fo{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=qe(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(qe(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class _h{static{_h.prototype.isMatrix2=!0}constructor(e,t,n,i){if(this.elements=[1,0,0,1],e!==void 0)this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}class Rc extends ei{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}}function xh(e,t,n,i){let r=zS(i);switch(n){case 1021:return e*t;case 1028:return e*t/r.components*r.byteLength;case 1029:return e*t/r.components*r.byteLength;case 1030:return e*t*2/r.components*r.byteLength;case 1031:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case 1023:return e*t*4/r.components*r.byteLength;case 1033:return e*t*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function zS(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Le("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function km(){let e=null,t=!1,n=null,i=null;function r(s,o){i=e.requestAnimationFrame(r),n(s,o)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(r),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(s){n=s},setContext:function(s){e=s}}}function kS(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,d=l.byteLength,h=e.createBuffer();e.bindBuffer(c,h),e.bufferData(c,l,u),a.onUploadCallback();let f;if(l instanceof Float32Array)f=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)f=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)f=e.HALF_FLOAT;else f=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=e.SHORT;else if(l instanceof Uint32Array)f=e.UNSIGNED_INT;else if(l instanceof Int32Array)f=e.INT;else if(l instanceof Int8Array)f=e.BYTE;else if(l instanceof Uint8Array)f=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:d}}function i(a,c,l){let{array:u,updateRanges:d}=c;if(e.bindBuffer(l,a),d.length===0)e.bufferSubData(l,0,u);else{d.sort((f,m)=>f.start-m.start);let h=0;for(let f=1;f<d.length;f++){let m=d[h],_=d[f];if(_.start<=m.start+m.count+1)m.count=Math.max(m.count,_.start+_.count-m.start);else++h,d[h]=_}d.length=h+1;for(let f=0,m=d.length;f<m;f++){let _=d[f];e.bufferSubData(l,_.start*u.BYTES_PER_ELEMENT,u,_.start,_.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var BS=`#ifdef USE_ALPHAHASHif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;-#endif`,zS=`#ifdef USE_ALPHAHASH+#endif`,VS=`#ifdef USE_ALPHAHASHconst float ALPHA_HASH_SCALE = 0.05;float hash2D( vec2 value ) {return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );@@ -163,20 +163,20 @@: cases.z;return clamp( threshold , 1.0e-6, 1.0 );}-#endif`,kS=`#ifdef USE_ALPHAMAP+#endif`,GS=`#ifdef USE_ALPHAMAPdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;-#endif`,BS=`#ifdef USE_ALPHAMAP+#endif`,HS=`#ifdef USE_ALPHAMAPuniform sampler2D alphaMap;-#endif`,VS=`#ifdef USE_ALPHATEST+#endif`,$S=`#ifdef USE_ALPHATEST#ifdef ALPHA_TO_COVERAGEdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );if ( diffuseColor.a == 0.0 ) discard;#elseif ( diffuseColor.a < alphaTest ) discard;#endif-#endif`,GS=`#ifdef USE_ALPHATEST+#endif`,WS=`#ifdef USE_ALPHATESTuniform float alphaTest;-#endif`,HS=`#ifdef USE_AOMAP+#endif`,ZS=`#ifdef USE_AOMAPfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;reflectedLight.indirectDiffuse *= ambientOcclusion;#if defined( USE_CLEARCOAT )@@ -189,10 +189,10 @@float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );#endif-#endif`,$S=`#ifdef USE_AOMAP+#endif`,XS=`#ifdef USE_AOMAPuniform sampler2D aoMap;uniform float aoMapIntensity;-#endif`,WS=`#ifdef USE_BATCHING+#endif`,jS=`#ifdef USE_BATCHING#if ! defined( GL_ANGLE_multi_draw )#define gl_DrawID _gl_DrawIDuniform int _gl_DrawID;@@ -226,15 +226,15 @@int y = j / size;return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );}-#endif`,ZS=`#ifdef USE_BATCHING+#endif`,qS=`#ifdef USE_BATCHINGmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );-#endif`,XS=`vec3 transformed = vec3( position );+#endif`,YS=`vec3 transformed = vec3( position );#ifdef USE_ALPHAHASHvPosition = vec3( position );-#endif`,jS=`vec3 objectNormal = vec3( normal );+#endif`,JS=`vec3 objectNormal = vec3( normal );#ifdef USE_TANGENTvec3 objectTangent = vec3( tangent.xyz );-#endif`,qS=`float G_BlinnPhong_Implicit( ) {+#endif`,KS=`float G_BlinnPhong_Implicit( ) {return 0.25;}float D_BlinnPhong( const in float shininess, const in float dotNH ) {@@ -248,7 +248,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vefloat G = G_BlinnPhong_Implicit( );float D = D_BlinnPhong( shininess, dotNH );return F * ( G * D );-} // validated`,YS=`#ifdef USE_IRIDESCENCE+} // validated`,QS=`#ifdef USE_IRIDESCENCEconst mat3 XYZ_TO_REC709 = mat3(3.2404542, -0.9692660, 0.0556434,-1.5371385, 1.8760108, -0.2040259,@@ -311,7 +311,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve}return max( I, vec3( 0.0 ) );}-#endif`,JS=`#ifdef USE_BUMPMAP+#endif`,eM=`#ifdef USE_BUMPMAPuniform sampler2D bumpMap;uniform float bumpScale;vec2 dHdxy_fwd() {@@ -332,7 +332,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vevec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );return normalize( abs( fDet ) * surf_norm - vGrad );}-#endif`,KS=`#if NUM_CLIPPING_PLANES > 0+#endif`,tM=`#if NUM_CLIPPING_PLANES > 0vec4 plane;#ifdef ALPHA_TO_COVERAGEfloat distanceToPlane, distanceGradient;@@ -378,20 +378,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in veif ( clipped ) discard;#endif#endif-#endif`,QS=`#if NUM_CLIPPING_PLANES > 0+#endif`,nM=`#if NUM_CLIPPING_PLANES > 0varying vec3 vClipPosition;uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];-#endif`,eM=`#if NUM_CLIPPING_PLANES > 0+#endif`,iM=`#if NUM_CLIPPING_PLANES > 0varying vec3 vClipPosition;-#endif`,tM=`#if NUM_CLIPPING_PLANES > 0+#endif`,rM=`#if NUM_CLIPPING_PLANES > 0vClipPosition = - mvPosition.xyz;-#endif`,nM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )+#endif`,sM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )diffuseColor *= vColor;-#endif`,iM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )+#endif`,oM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )varying vec4 vColor;-#endif`,rM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )+#endif`,aM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )varying vec4 vColor;-#endif`,sM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )+#endif`,cM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )vColor = vec4( 1.0 );#endif#ifdef USE_COLOR_ALPHA@@ -404,7 +404,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve#endif#ifdef USE_BATCHING_COLORvColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );-#endif`,oM=`#define PI 3.141592653589793+#endif`,lM=`#define PI 3.141592653589793#define PI2 6.283185307179586#define PI_HALF 1.5707963267948966#define RECIPROCAL_PI 0.3183098861837907@@ -475,7 +475,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {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`,aM=`#ifdef ENVMAP_TYPE_CUBE_UV+} // validated`,uM=`#ifdef ENVMAP_TYPE_CUBE_UV#define cubeUV_minMipLevel 4.0#define cubeUV_minTileSize 16.0float getFace( vec3 direction ) {@@ -568,7 +568,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {return vec4( mix( color0, color1, mipF ), 1.0 );}}-#endif`,cM=`vec3 transformedNormal = objectNormal;+#endif`,hM=`vec3 transformedNormal = objectNormal;#ifdef USE_TANGENTvec3 transformedTangent = objectTangent;#endif@@ -594,21 +594,21 @@ transformedNormal = normalMatrix * transformedNormal;#endif#ifdef USE_TANGENTtransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;-#endif`,lM=`#ifdef USE_DISPLACEMENTMAP+#endif`,dM=`#ifdef USE_DISPLACEMENTMAPuniform sampler2D displacementMap;uniform float displacementScale;uniform float displacementBias;-#endif`,uM=`#ifdef USE_DISPLACEMENTMAP+#endif`,fM=`#ifdef USE_DISPLACEMENTMAPtransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );-#endif`,hM=`#ifdef USE_EMISSIVEMAP+#endif`,pM=`#ifdef USE_EMISSIVEMAPvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );#ifdef DECODE_VIDEO_TEXTURE_EMISSIVEemissiveColor = sRGBTransferEOTF( emissiveColor );#endiftotalEmissiveRadiance *= emissiveColor.rgb;-#endif`,dM=`#ifdef USE_EMISSIVEMAP+#endif`,mM=`#ifdef USE_EMISSIVEMAPuniform sampler2D emissiveMap;-#endif`,fM="gl_FragColor = linearToOutputTexel( gl_FragColor );",pM=`vec4 LinearTransferOETF( in vec4 value ) {+#endif`,gM="gl_FragColor = linearToOutputTexel( gl_FragColor );",_M=`vec4 LinearTransferOETF( in vec4 value ) {return value;}vec4 sRGBTransferEOTF( in vec4 value ) {@@ -616,7 +616,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {}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 );-}`,mM=`#ifdef USE_ENVMAP+}`,xM=`#ifdef USE_ENVMAP#ifdef ENV_WORLDPOSvec3 cameraToFrag;if ( isOrthographic ) {@@ -643,7 +643,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {outgoingLight += envColor.xyz * specularStrength * reflectivity;#endif#endif-#endif`,gM=`#ifdef USE_ENVMAP+#endif`,yM=`#ifdef USE_ENVMAPuniform float envMapIntensity;uniform mat3 envMapRotation;#ifdef ENVMAP_TYPE_CUBE@@ -651,7 +651,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {#elseuniform sampler2D envMap;#endif-#endif`,_M=`#ifdef USE_ENVMAP+#endif`,vM=`#ifdef USE_ENVMAPuniform float reflectivity;#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )#define ENV_WORLDPOS@@ -662,7 +662,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {#elsevarying vec3 vReflect;#endif-#endif`,xM=`#ifdef USE_ENVMAP+#endif`,bM=`#ifdef USE_ENVMAP#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )#define ENV_WORLDPOS#endif@@ -673,7 +673,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {varying vec3 vReflect;uniform float refractionRatio;#endif-#endif`,yM=`#ifdef USE_ENVMAP+#endif`,SM=`#ifdef USE_ENVMAP#ifdef ENV_WORLDPOSvWorldPosition = worldPosition.xyz;#else@@ -690,18 +690,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {vReflect = refract( cameraToVertex, worldNormal, refractionRatio );#endif#endif-#endif`,vM=`#ifdef USE_FOG+#endif`,MM=`#ifdef USE_FOGvFogDepth = - mvPosition.z;-#endif`,bM=`#ifdef USE_FOG+#endif`,wM=`#ifdef USE_FOGvarying float vFogDepth;-#endif`,SM=`#ifdef USE_FOG+#endif`,EM=`#ifdef USE_FOG#ifdef FOG_EXP2float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );#elsefloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );#endifgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );-#endif`,MM=`#ifdef USE_FOG+#endif`,AM=`#ifdef USE_FOGuniform vec3 fogColor;varying float vFogDepth;#ifdef FOG_EXP2@@ -710,7 +710,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {uniform float fogNear;uniform float fogFar;#endif-#endif`,wM=`#ifdef USE_GRADIENTMAP+#endif`,TM=`#ifdef USE_GRADIENTMAPuniform sampler2D gradientMap;#endifvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {@@ -722,12 +722,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {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-}`,EM=`#ifdef USE_LIGHTMAP+}`,RM=`#ifdef USE_LIGHTMAPuniform sampler2D lightMap;uniform float lightMapIntensity;-#endif`,AM=`LambertMaterial material;+#endif`,CM=`LambertMaterial material;material.diffuseColor = diffuseColor.rgb;-material.specularStrength = specularStrength;`,TM=`varying vec3 vViewPosition;+material.specularStrength = specularStrength;`,PM=`varying vec3 vViewPosition;struct LambertMaterial {vec3 diffuseColor;float specularStrength;@@ -741,7 +741,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometrreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );}#define RE_Direct RE_Direct_Lambert-#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,RM=`uniform bool receiveShadow;+#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,IM=`uniform bool receiveShadow;uniform vec3 ambientLightColor;#if defined( USE_LIGHT_PROBES )uniform vec3 lightProbe[ 9 ];@@ -870,7 +870,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosireturn irradiance;}#endif-#include <lightprobes_pars_fragment>`,CM=`#ifdef USE_ENVMAP+#include <lightprobes_pars_fragment>`,LM=`#ifdef USE_ENVMAPvec3 getIBLIrradiance( const in vec3 normal ) {#ifdef ENVMAP_TYPE_CUBE_UVvec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );@@ -927,8 +927,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi}#endif#endif-#endif`,PM=`ToonMaterial material;-material.diffuseColor = diffuseColor.rgb;`,IM=`varying vec3 vViewPosition;+#endif`,NM=`ToonMaterial material;+material.diffuseColor = diffuseColor.rgb;`,DM=`varying vec3 vViewPosition;struct ToonMaterial {vec3 diffuseColor;};@@ -940,11 +940,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPoreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );}#define RE_Direct RE_Direct_Toon-#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,LM=`BlinnPhongMaterial material;+#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,OM=`BlinnPhongMaterial material;material.diffuseColor = diffuseColor.rgb;material.specularColor = specular;material.specularShininess = shininess;-material.specularStrength = specularStrength;`,NM=`varying vec3 vViewPosition;+material.specularStrength = specularStrength;`,UM=`varying vec3 vViewPosition;struct BlinnPhongMaterial {vec3 diffuseColor;vec3 specularColor;@@ -961,7 +961,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geomreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );}#define RE_Direct RE_Direct_BlinnPhong-#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,DM=`PhysicalMaterial material;+#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,FM=`PhysicalMaterial material;material.diffuseColor = diffuseColor.rgb;material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );material.metalness = metalnessFactor;@@ -1054,7 +1054,7 @@ material.roughness = min( material.roughness, 1.0 );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`,OM=`uniform sampler2D dfgLUT;+#endif`,zM=`uniform sampler2D dfgLUT;struct PhysicalMaterial {vec3 diffuseColor;vec3 diffuseContribution;@@ -1421,7 +1421,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia#define RE_IndirectSpecular RE_IndirectSpecular_Physicalfloat 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 );-}`,UM=`+}`,kM=`vec3 geometryPosition = - vViewPosition;vec3 geometryNormal = normal;vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );@@ -1569,7 +1569,7 @@ IncidentLight directLight;#if defined( RE_IndirectSpecular )vec3 radiance = vec3( 0.0 );vec3 clearcoatRadiance = vec3( 0.0 );-#endif`,FM=`#if defined( RE_IndirectDiffuse )+#endif`,BM=`#if defined( RE_IndirectDiffuse )#ifdef USE_LIGHTMAPvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;@@ -1599,7 +1599,7 @@ IncidentLight directLight;#ifdef USE_CLEARCOATclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );#endif-#endif`,zM=`#if defined( RE_IndirectDiffuse )+#endif`,VM=`#if defined( RE_IndirectDiffuse )#if defined( LAMBERT ) || defined( PHONG )irradiance += iblIrradiance;#endif@@ -1607,7 +1607,7 @@ IncidentLight directLight;#endif#if defined( RE_IndirectSpecular )RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );-#endif`,kM=`#ifdef USE_LIGHT_PROBES_GRID+#endif`,GM=`#ifdef USE_LIGHT_PROBES_GRIDuniform highp sampler3D probesSH;uniform vec3 probesMin;uniform vec3 probesMax;@@ -1652,27 +1652,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {result += c8 * 0.429043 * ( x * x - y * y );return max( result, vec3( 0.0 ) );}-#endif`,BM=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )+#endif`,HM=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;-#endif`,VM=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )+#endif`,$M=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )uniform float logDepthBufFC;varying float vFragDepth;varying float vIsPerspective;-#endif`,GM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER+#endif`,WM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFERvarying float vFragDepth;varying float vIsPerspective;-#endif`,HM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER+#endif`,ZM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFERvFragDepth = 1.0 + gl_Position.w;vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );-#endif`,$M=`#ifdef USE_MAP+#endif`,XM=`#ifdef USE_MAPvec4 sampledDiffuseColor = texture2D( map, vMapUv );#ifdef DECODE_VIDEO_TEXTUREsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );#endifdiffuseColor *= sampledDiffuseColor;-#endif`,WM=`#ifdef USE_MAP+#endif`,jM=`#ifdef USE_MAPuniform sampler2D map;-#endif`,ZM=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )+#endif`,qM=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )#if defined( USE_POINTS_UV )vec2 uv = vUv;#else@@ -1684,7 +1684,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {#endif#ifdef USE_ALPHAMAPdiffuseColor.a *= texture2D( alphaMap, uv ).g;-#endif`,XM=`#if defined( USE_POINTS_UV )+#endif`,YM=`#if defined( USE_POINTS_UV )varying vec2 vUv;#else#if defined( USE_MAP ) || defined( USE_ALPHAMAP )@@ -1696,19 +1696,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {#endif#ifdef USE_ALPHAMAPuniform sampler2D alphaMap;-#endif`,jM=`float metalnessFactor = metalness;+#endif`,JM=`float metalnessFactor = metalness;#ifdef USE_METALNESSMAPvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );metalnessFactor *= texelMetalness.b;-#endif`,qM=`#ifdef USE_METALNESSMAP+#endif`,KM=`#ifdef USE_METALNESSMAPuniform sampler2D metalnessMap;-#endif`,YM=`#ifdef USE_INSTANCING_MORPH+#endif`,QM=`#ifdef USE_INSTANCING_MORPHfloat 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`,JM=`#if defined( USE_MORPHCOLORS )+#endif`,ew=`#if defined( USE_MORPHCOLORS )vColor *= morphTargetBaseInfluence;for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {#if defined( USE_COLOR_ALPHA )@@ -1717,12 +1717,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];#endif}-#endif`,KM=`#ifdef USE_MORPHNORMALS+#endif`,tw=`#ifdef USE_MORPHNORMALSobjectNormal *= morphTargetBaseInfluence;for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];}-#endif`,QM=`#ifdef USE_MORPHTARGETS+#endif`,nw=`#ifdef USE_MORPHTARGETS#ifndef USE_INSTANCING_MORPHuniform float morphTargetBaseInfluence;uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];@@ -1736,12 +1736,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {ivec3 morphUV = ivec3( x, y, morphTargetIndex );return texelFetch( morphTargetsTexture, morphUV, 0 );}-#endif`,ew=`#ifdef USE_MORPHTARGETS+#endif`,iw=`#ifdef USE_MORPHTARGETStransformed *= morphTargetBaseInfluence;for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];}-#endif`,tw=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;+#endif`,rw=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;#ifdef FLAT_SHADEDvec3 fdx = dFdx( vViewPosition );vec3 fdy = dFdy( vViewPosition );@@ -1782,7 +1782,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {tbn2[1] *= faceDirection;#endif#endif-vec3 nonPerturbedNormal = normal;`,nw=`#ifdef USE_NORMALMAP_OBJECTSPACE+vec3 nonPerturbedNormal = normal;`,sw=`#ifdef USE_NORMALMAP_OBJECTSPACEnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;#ifdef FLIP_SIDEDnormal = - normal;@@ -1800,19 +1800,19 @@ vec3 nonPerturbedNormal = normal;`,nw=`#ifdef USE_NORMALMAP_OBJECTSPACEnormal = normalize( tbn * mapN );#elif defined( USE_BUMPMAP )normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );-#endif`,iw=`#ifndef FLAT_SHADED+#endif`,ow=`#ifndef FLAT_SHADEDvarying vec3 vNormal;#ifdef USE_TANGENTvarying vec3 vTangent;varying vec3 vBitangent;#endif-#endif`,rw=`#ifndef FLAT_SHADED+#endif`,aw=`#ifndef FLAT_SHADEDvarying vec3 vNormal;#ifdef USE_TANGENTvarying vec3 vTangent;varying vec3 vBitangent;#endif-#endif`,sw=`#ifndef FLAT_SHADED+#endif`,cw=`#ifndef FLAT_SHADEDvNormal = normalize( transformedNormal );#ifdef USE_TANGENTvTangent = normalize( transformedTangent );@@ -1821,7 +1821,7 @@ vec3 nonPerturbedNormal = normal;`,nw=`#ifdef USE_NORMALMAP_OBJECTSPACEvBitangent = - vBitangent;#endif#endif-#endif`,ow=`#ifdef USE_NORMALMAP+#endif`,lw=`#ifdef USE_NORMALMAPuniform sampler2D normalMap;uniform vec2 normalScale;#endif@@ -1843,13 +1843,13 @@ vec3 nonPerturbedNormal = normal;`,nw=`#ifdef USE_NORMALMAP_OBJECTSPACEfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );return mat3( T * scale, B * scale, N );}-#endif`,aw=`#ifdef USE_CLEARCOAT+#endif`,uw=`#ifdef USE_CLEARCOATvec3 clearcoatNormal = nonPerturbedNormal;-#endif`,cw=`#ifdef USE_CLEARCOAT_NORMALMAP+#endif`,hw=`#ifdef USE_CLEARCOAT_NORMALMAPvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;clearcoatMapN.xy *= clearcoatNormalScale;clearcoatNormal = normalize( tbn2 * clearcoatMapN );-#endif`,lw=`#ifdef USE_CLEARCOATMAP+#endif`,dw=`#ifdef USE_CLEARCOATMAPuniform sampler2D clearcoatMap;#endif#ifdef USE_CLEARCOAT_NORMALMAP@@ -1858,18 +1858,18 @@ vec3 nonPerturbedNormal = normal;`,nw=`#ifdef USE_NORMALMAP_OBJECTSPACE#endif#ifdef USE_CLEARCOAT_ROUGHNESSMAPuniform sampler2D clearcoatRoughnessMap;-#endif`,uw=`#ifdef USE_IRIDESCENCEMAP+#endif`,fw=`#ifdef USE_IRIDESCENCEMAPuniform sampler2D iridescenceMap;#endif#ifdef USE_IRIDESCENCE_THICKNESSMAPuniform sampler2D iridescenceThicknessMap;-#endif`,hw=`#ifdef OPAQUE+#endif`,pw=`#ifdef OPAQUEdiffuseColor.a = 1.0;#endif#ifdef USE_TRANSMISSIONdiffuseColor.a *= material.transmissionAlpha;#endif-gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,dw=`vec3 packNormalToRGB( const in vec3 normal ) {+gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,mw=`vec3 packNormalToRGB( const in vec3 normal ) {return normalize( normal ) * 0.5 + 0.5;}vec3 unpackRGBToNormal( const in vec3 rgb ) {@@ -1948,9 +1948,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const#elsereturn ( near * far ) / ( ( far - near ) * depth - far );#endif-}`,fw=`#ifdef PREMULTIPLIED_ALPHA+}`,gw=`#ifdef PREMULTIPLIED_ALPHAgl_FragColor.rgb *= gl_FragColor.a;-#endif`,pw=`vec4 mvPosition = vec4( transformed, 1.0 );+#endif`,_w=`vec4 mvPosition = vec4( transformed, 1.0 );#ifdef USE_BATCHINGmvPosition = batchingMatrix * mvPosition;#endif@@ -1958,22 +1958,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, constmvPosition = instanceMatrix * mvPosition;#endifmvPosition = modelViewMatrix * mvPosition;-gl_Position = projectionMatrix * mvPosition;`,mw=`#ifdef DITHERING+gl_Position = projectionMatrix * mvPosition;`,xw=`#ifdef DITHERINGgl_FragColor.rgb = dithering( gl_FragColor.rgb );-#endif`,gw=`#ifdef DITHERING+#endif`,yw=`#ifdef DITHERINGvec3 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`,_w=`float roughnessFactor = roughness;+#endif`,vw=`float roughnessFactor = roughness;#ifdef USE_ROUGHNESSMAPvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );roughnessFactor *= texelRoughness.g;-#endif`,xw=`#ifdef USE_ROUGHNESSMAP+#endif`,bw=`#ifdef USE_ROUGHNESSMAPuniform sampler2D roughnessMap;-#endif`,yw=`#if NUM_SPOT_LIGHT_COORDS > 0+#endif`,Sw=`#if NUM_SPOT_LIGHT_COORDS > 0varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];#endif#if NUM_SPOT_LIGHT_MAPS > 0@@ -2224,7 +2224,7 @@ gl_Position = projectionMatrix * mvPosition;`,mw=`#ifdef DITHERING}#endif#endif-#endif`,vw=`#if NUM_SPOT_LIGHT_COORDS > 0+#endif`,Mw=`#if NUM_SPOT_LIGHT_COORDS > 0uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];#endif@@ -2269,7 +2269,7 @@ gl_Position = projectionMatrix * mvPosition;`,mw=`#ifdef DITHERING};uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];#endif-#endif`,bw=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )+#endif`,ww=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )#ifdef HAS_NORMALvec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );#else@@ -2309,7 +2309,7 @@ gl_Position = projectionMatrix * mvPosition;`,mw=`#ifdef DITHERINGvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;}#pragma unroll_loop_end-#endif`,Sw=`float getShadowMask() {+#endif`,Ew=`float getShadowMask() {float shadow = 1.0;#ifdef USE_SHADOWMAP#if NUM_SUN_LIGHT_SHADOWS > 0@@ -2350,12 +2350,12 @@ gl_Position = projectionMatrix * mvPosition;`,mw=`#ifdef DITHERING#endif#endifreturn shadow;-}`,Mw=`#ifdef USE_SKINNING+}`,Aw=`#ifdef USE_SKINNINGmat4 boneMatX = getBoneMatrix( skinIndex.x );mat4 boneMatY = getBoneMatrix( skinIndex.y );mat4 boneMatZ = getBoneMatrix( skinIndex.z );mat4 boneMatW = getBoneMatrix( skinIndex.w );-#endif`,ww=`#ifdef USE_SKINNING+#endif`,Tw=`#ifdef USE_SKINNINGuniform mat4 bindMatrix;uniform mat4 bindMatrixInverse;uniform highp sampler2D boneTexture;@@ -2370,7 +2370,7 @@ gl_Position = projectionMatrix * mvPosition;`,mw=`#ifdef DITHERINGvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );return mat4( v1, v2, v3, v4 );}-#endif`,Ew=`#ifdef USE_SKINNING+#endif`,Rw=`#ifdef USE_SKINNINGvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );vec4 skinned = vec4( 0.0 );skinned += boneMatX * skinVertex * skinWeight.x;@@ -2378,7 +2378,7 @@ gl_Position = projectionMatrix * mvPosition;`,mw=`#ifdef DITHERINGskinned += boneMatZ * skinVertex * skinWeight.z;skinned += boneMatW * skinVertex * skinWeight.w;transformed = ( bindMatrixInverse * skinned ).xyz;-#endif`,Aw=`#ifdef USE_SKINNING+#endif`,Cw=`#ifdef USE_SKINNINGmat4 skinMatrix = mat4( 0.0 );skinMatrix += skinWeight.x * boneMatX;skinMatrix += skinWeight.y * boneMatY;@@ -2389,17 +2389,17 @@ gl_Position = projectionMatrix * mvPosition;`,mw=`#ifdef DITHERING#ifdef USE_TANGENTobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;#endif-#endif`,Tw=`float specularStrength;+#endif`,Pw=`float specularStrength;#ifdef USE_SPECULARMAPvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );specularStrength = texelSpecular.r;#elsespecularStrength = 1.0;-#endif`,Rw=`#ifdef USE_SPECULARMAP+#endif`,Iw=`#ifdef USE_SPECULARMAPuniform sampler2D specularMap;-#endif`,Cw=`#if defined( TONE_MAPPING )+#endif`,Lw=`#if defined( TONE_MAPPING )gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );-#endif`,Pw=`#ifndef saturate+#endif`,Nw=`#ifndef saturate#define saturate( a ) clamp( a, 0.0, 1.0 )#endifuniform float toneMappingExposure;@@ -2496,7 +2496,7 @@ vec3 NeutralToneMapping( vec3 color ) {float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );return mix( color, vec3( newPeak ), g );}-vec3 CustomToneMapping( vec3 color ) { return color; }`,Iw=`#ifdef USE_TRANSMISSION+vec3 CustomToneMapping( vec3 color ) { return color; }`,Dw=`#ifdef USE_TRANSMISSIONmaterial.transmission = transmission;material.transmissionAlpha = 1.0;material.thickness = thickness;@@ -2517,7 +2517,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Iw=`#ifdef USE_TRANSMISSmaterial.attenuationColor, material.attenuationDistance );material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );-#endif`,Lw=`#ifdef USE_TRANSMISSION+#endif`,Ow=`#ifdef USE_TRANSMISSIONuniform float transmission;uniform float thickness;uniform float attenuationDistance;@@ -2643,7 +2643,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Iw=`#ifdef USE_TRANSMISSfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );}-#endif`,Nw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )+#endif`,Uw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )varying vec2 vUv;#endif#ifdef USE_MAP@@ -2713,7 +2713,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Iw=`#ifdef USE_TRANSMISS#ifdef USE_THICKNESSMAPuniform mat3 thicknessMapTransform;varying vec2 vThicknessMapUv;-#endif`,Dw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )+#endif`,Fw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )varying vec2 vUv;#endif#ifdef USE_MAP@@ -2807,7 +2807,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Iw=`#ifdef USE_TRANSMISS#ifdef USE_THICKNESSMAPuniform mat3 thicknessMapTransform;varying vec2 vThicknessMapUv;-#endif`,Ow=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )+#endif`,zw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )vUv = vec3( uv, 1 ).xy;#endif#ifdef USE_MAP@@ -2878,7 +2878,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Iw=`#ifdef USE_TRANSMISS#endif#ifdef USE_THICKNESSMAPvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;-#endif`;var Uw=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0+#endif`;var kw=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0vec4 worldPosition = vec4( transformed, 1.0 );#ifdef USE_BATCHINGworldPosition = batchingMatrix * worldPosition;@@ -2887,12 +2887,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Iw=`#ifdef USE_TRANSMISSworldPosition = instanceMatrix * worldPosition;#endifworldPosition = modelMatrix * worldPosition;-#endif`,Fw=`varying vec2 vUv;+#endif`,Bw=`varying vec2 vUv;uniform mat3 uvTransform;void main() {vUv = ( uvTransform * vec3( uv, 1 ) ).xy;gl_Position = vec4( position.xy, 1.0, 1.0 );-}`,zw=`uniform sampler2D t2D;+}`,Vw=`uniform sampler2D t2D;uniform float backgroundIntensity;varying vec2 vUv;void main() {@@ -2904,14 +2904,14 @@ void main() {gl_FragColor = texColor;#include <tonemapping_fragment>#include <colorspace_fragment>-}`,kw=`varying vec3 vWorldDirection;+}`,Gw=`varying vec3 vWorldDirection;#include <common>void main() {vWorldDirection = transformDirection( position, modelMatrix );#include <begin_vertex>#include <project_vertex>gl_Position.z = gl_Position.w;-}`,Bw=`#ifdef ENVMAP_TYPE_CUBE+}`,Hw=`#ifdef ENVMAP_TYPE_CUBEuniform samplerCube envMap;#elif defined( ENVMAP_TYPE_CUBE_UV )uniform sampler2D envMap;@@ -2933,14 +2933,14 @@ void main() {gl_FragColor = texColor;#include <tonemapping_fragment>#include <colorspace_fragment>-}`,Vw=`varying vec3 vWorldDirection;+}`,$w=`varying vec3 vWorldDirection;#include <common>void main() {vWorldDirection = transformDirection( position, modelMatrix );#include <begin_vertex>#include <project_vertex>gl_Position.z = gl_Position.w;-}`,Gw=`uniform samplerCube tCube;+}`,Ww=`uniform samplerCube tCube;uniform float tFlip;uniform float opacity;varying vec3 vWorldDirection;@@ -2950,7 +2950,7 @@ void main() {gl_FragColor.a *= opacity;#include <tonemapping_fragment>#include <colorspace_fragment>-}`,Hw=`#include <common>+}`,Zw=`#include <common>#include <batching_pars_vertex>#include <uv_pars_vertex>#include <displacementmap_pars_vertex>@@ -2977,7 +2977,7 @@ void main() {#include <logdepthbuf_vertex>#include <clipping_planes_vertex>vHighPrecisionZW = gl_Position.zw;-}`,$w=`#if DEPTH_PACKING == 3200+}`,Xw=`#if DEPTH_PACKING == 3200uniform float opacity;#endif#include <common>@@ -3015,7 +3015,7 @@ void main() {#elif DEPTH_PACKING == 3203gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );#endif-}`,Ww=`#define DISTANCE+}`,jw=`#define DISTANCEvarying vec3 vWorldPosition;#include <common>#include <batching_pars_vertex>@@ -3042,7 +3042,7 @@ void main() {#include <worldpos_vertex>#include <clipping_planes_vertex>vWorldPosition = worldPosition.xyz;-}`,Zw=`#define DISTANCE+}`,qw=`#define DISTANCEuniform vec3 referencePosition;uniform float nearDistance;uniform float farDistance;@@ -3065,13 +3065,13 @@ void main() {dist = ( dist - nearDistance ) / ( farDistance - nearDistance );dist = saturate( dist );gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );-}`,Xw=`varying vec3 vWorldDirection;+}`,Yw=`varying vec3 vWorldDirection;#include <common>void main() {vWorldDirection = transformDirection( position, modelMatrix );#include <begin_vertex>#include <project_vertex>-}`,jw=`uniform sampler2D tEquirect;+}`,Jw=`uniform sampler2D tEquirect;varying vec3 vWorldDirection;#include <common>void main() {@@ -3080,7 +3080,7 @@ void main() {gl_FragColor = texture2D( tEquirect, sampleUV );#include <tonemapping_fragment>#include <colorspace_fragment>-}`,qw=`uniform float scale;+}`,Kw=`uniform float scale;attribute float lineDistance;varying float vLineDistance;#include <common>@@ -3102,7 +3102,7 @@ void main() {#include <logdepthbuf_vertex>#include <clipping_planes_vertex>#include <fog_vertex>-}`,Yw=`uniform vec3 diffuse;+}`,Qw=`uniform vec3 diffuse;uniform float opacity;uniform float dashSize;uniform float totalSize;@@ -3130,7 +3130,7 @@ void main() {#include <colorspace_fragment>#include <fog_fragment>#include <premultiplied_alpha_fragment>-}`,Jw=`#include <common>+}`,eE=`#include <common>#include <batching_pars_vertex>#include <uv_pars_vertex>#include <envmap_pars_vertex>@@ -3162,7 +3162,7 @@ void main() {#include <worldpos_vertex>#include <envmap_vertex>#include <fog_vertex>-}`,Kw=`uniform vec3 diffuse;+}`,tE=`uniform vec3 diffuse;uniform float opacity;#ifndef FLAT_SHADEDvarying vec3 vNormal;@@ -3210,7 +3210,7 @@ void main() {#include <fog_fragment>#include <premultiplied_alpha_fragment>#include <dithering_fragment>-}`,Qw=`#define LAMBERT+}`,nE=`#define LAMBERTvarying vec3 vViewPosition;#include <common>#include <batching_pars_vertex>@@ -3249,7 +3249,7 @@ void main() {#include <envmap_vertex>#include <shadowmap_vertex>#include <fog_vertex>-}`,eE=`#define LAMBERT+}`,iE=`#define LAMBERTuniform vec3 diffuse;uniform vec3 emissive;uniform float opacity;@@ -3307,7 +3307,7 @@ void main() {#include <fog_fragment>#include <premultiplied_alpha_fragment>#include <dithering_fragment>-}`,tE=`#define MATCAP+}`,rE=`#define MATCAPvarying vec3 vViewPosition;#include <common>#include <batching_pars_vertex>@@ -3341,7 +3341,7 @@ void main() {#include <clipping_planes_vertex>#include <fog_vertex>vViewPosition = - mvPosition.xyz;-}`,nE=`#define MATCAP+}`,sE=`#define MATCAPuniform vec3 diffuse;uniform float opacity;uniform sampler2D matcap;@@ -3387,7 +3387,7 @@ void main() {#include <fog_fragment>#include <premultiplied_alpha_fragment>#include <dithering_fragment>-}`,iE=`#define NORMAL+}`,oE=`#define NORMAL#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )varying vec3 vViewPosition;#endif@@ -3420,7 +3420,7 @@ void main() {#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )vViewPosition = - mvPosition.xyz;#endif-}`,rE=`#define NORMAL+}`,aE=`#define NORMALuniform float opacity;#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )varying vec3 vViewPosition;@@ -3441,7 +3441,7 @@ void main() {#ifdef OPAQUEgl_FragColor.a = 1.0;#endif-}`,sE=`#define PHONG+}`,cE=`#define PHONGvarying vec3 vViewPosition;#include <common>#include <batching_pars_vertex>@@ -3480,7 +3480,7 @@ void main() {#include <envmap_vertex>#include <shadowmap_vertex>#include <fog_vertex>-}`,oE=`#define PHONG+}`,lE=`#define PHONGuniform vec3 diffuse;uniform vec3 emissive;uniform vec3 specular;@@ -3540,7 +3540,7 @@ void main() {#include <fog_fragment>#include <premultiplied_alpha_fragment>#include <dithering_fragment>-}`,aE=`#define STANDARD+}`,uE=`#define STANDARDvarying vec3 vViewPosition;#ifdef USE_TRANSMISSIONvarying vec3 vWorldPosition;@@ -3583,7 +3583,7 @@ void main() {#ifdef USE_TRANSMISSIONvWorldPosition = worldPosition.xyz;#endif-}`,cE=`#define STANDARD+}`,hE=`#define STANDARD#ifdef PHYSICAL#define IOR#define USE_SPECULAR@@ -3711,7 +3711,7 @@ void main() {#include <fog_fragment>#include <premultiplied_alpha_fragment>#include <dithering_fragment>-}`,lE=`#define TOON+}`,dE=`#define TOONvarying vec3 vViewPosition;#include <common>#include <batching_pars_vertex>@@ -3748,7 +3748,7 @@ void main() {#include <worldpos_vertex>#include <shadowmap_vertex>#include <fog_vertex>-}`,uE=`#define TOON+}`,fE=`#define TOONuniform vec3 diffuse;uniform vec3 emissive;uniform float opacity;@@ -3800,7 +3800,7 @@ void main() {#include <fog_fragment>#include <premultiplied_alpha_fragment>#include <dithering_fragment>-}`,hE=`uniform float size;+}`,pE=`uniform float size;uniform float scale;#include <common>#include <color_pars_vertex>@@ -3831,7 +3831,7 @@ void main() {#include <clipping_planes_vertex>#include <worldpos_vertex>#include <fog_vertex>-}`,dE=`uniform vec3 diffuse;+}`,mE=`uniform vec3 diffuse;uniform float opacity;#include <common>#include <color_pars_fragment>@@ -3856,7 +3856,7 @@ void main() {#include <colorspace_fragment>#include <fog_fragment>#include <premultiplied_alpha_fragment>-}`,fE=`#include <common>+}`,gE=`#include <common>#include <batching_pars_vertex>#include <fog_pars_vertex>#include <morphtarget_pars_vertex>@@ -3879,7 +3879,7 @@ void main() {#include <worldpos_vertex>#include <shadowmap_vertex>#include <fog_vertex>-}`,pE=`uniform vec3 color;+}`,_E=`uniform vec3 color;uniform float opacity;#include <common>#include <fog_pars_fragment>@@ -3895,7 +3895,7 @@ void main() {#include <colorspace_fragment>#include <fog_fragment>#include <premultiplied_alpha_fragment>-}`,mE=`uniform float rotation;+}`,xE=`uniform float rotation;uniform vec2 center;#include <common>#include <uv_pars_vertex>@@ -3919,7 +3919,7 @@ void main() {#include <logdepthbuf_vertex>#include <clipping_planes_vertex>#include <fog_vertex>-}`,gE=`uniform vec3 diffuse;+}`,yE=`uniform vec3 diffuse;uniform float opacity;#include <common>#include <uv_pars_fragment>@@ -3944,7 +3944,7 @@ void main() {#include <tonemapping_fragment>#include <colorspace_fragment>#include <fog_fragment>-}`,Ze={alphahash_fragment:FS,alphahash_pars_fragment:zS,alphamap_fragment:kS,alphamap_pars_fragment:BS,alphatest_fragment:VS,alphatest_pars_fragment:GS,aomap_fragment:HS,aomap_pars_fragment:$S,batching_pars_vertex:WS,batching_vertex:ZS,begin_vertex:XS,beginnormal_vertex:jS,bsdfs:qS,iridescence_fragment:YS,bumpmap_pars_fragment:JS,clipping_planes_fragment:KS,clipping_planes_pars_fragment:QS,clipping_planes_pars_vertex:eM,clipping_planes_vertex:tM,color_fragment:nM,color_pars_fragment:iM,color_pars_vertex:rM,color_vertex:sM,common:oM,cube_uv_reflection_fragment:aM,defaultnormal_vertex:cM,displacementmap_pars_vertex:lM,displacementmap_vertex:uM,emissivemap_fragment:hM,emissivemap_pars_fragment:dM,colorspace_fragment:fM,colorspace_pars_fragment:pM,envmap_fragment:mM,envmap_common_pars_fragment:gM,envmap_pars_fragment:_M,envmap_pars_vertex:xM,envmap_physical_pars_fragment:CM,envmap_vertex:yM,fog_vertex:vM,fog_pars_vertex:bM,fog_fragment:SM,fog_pars_fragment:MM,gradientmap_pars_fragment:wM,lightmap_pars_fragment:EM,lights_lambert_fragment:AM,lights_lambert_pars_fragment:TM,lights_pars_begin:RM,lights_toon_fragment:PM,lights_toon_pars_fragment:IM,lights_phong_fragment:LM,lights_phong_pars_fragment:NM,lights_physical_fragment:DM,lights_physical_pars_fragment:OM,lights_fragment_begin:UM,lights_fragment_maps:FM,lights_fragment_end:zM,lightprobes_pars_fragment:kM,logdepthbuf_fragment:BM,logdepthbuf_pars_fragment:VM,logdepthbuf_pars_vertex:GM,logdepthbuf_vertex:HM,map_fragment:$M,map_pars_fragment:WM,map_particle_fragment:ZM,map_particle_pars_fragment:XM,metalnessmap_fragment:jM,metalnessmap_pars_fragment:qM,morphinstance_vertex:YM,morphcolor_vertex:JM,morphnormal_vertex:KM,morphtarget_pars_vertex:QM,morphtarget_vertex:ew,normal_fragment_begin:tw,normal_fragment_maps:nw,normal_pars_fragment:iw,normal_pars_vertex:rw,normal_vertex:sw,normalmap_pars_fragment:ow,clearcoat_normal_fragment_begin:aw,clearcoat_normal_fragment_maps:cw,clearcoat_pars_fragment:lw,iridescence_pars_fragment:uw,opaque_fragment:hw,packing:dw,premultiplied_alpha_fragment:fw,project_vertex:pw,dithering_fragment:mw,dithering_pars_fragment:gw,roughnessmap_fragment:_w,roughnessmap_pars_fragment:xw,shadowmap_pars_fragment:yw,shadowmap_pars_vertex:vw,shadowmap_vertex:bw,shadowmask_pars_fragment:Sw,skinbase_vertex:Mw,skinning_pars_vertex:ww,skinning_vertex:Ew,skinnormal_vertex:Aw,specularmap_fragment:Tw,specularmap_pars_fragment:Rw,tonemapping_fragment:Cw,tonemapping_pars_fragment:Pw,transmission_fragment:Iw,transmission_pars_fragment:Lw,uv_pars_fragment:Nw,uv_pars_vertex:Dw,uv_vertex:Ow,worldpos_vertex:Uw,background_vert:Fw,background_frag:zw,backgroundCube_vert:kw,backgroundCube_frag:Bw,cube_vert:Vw,cube_frag:Gw,depth_vert:Hw,depth_frag:$w,distance_vert:Ww,distance_frag:Zw,equirect_vert:Xw,equirect_frag:jw,linedashed_vert:qw,linedashed_frag:Yw,meshbasic_vert:Jw,meshbasic_frag:Kw,meshlambert_vert:Qw,meshlambert_frag:eE,meshmatcap_vert:tE,meshmatcap_frag:nE,meshnormal_vert:iE,meshnormal_frag:rE,meshphong_vert:sE,meshphong_frag:oE,meshphysical_vert:aE,meshphysical_frag:cE,meshtoon_vert:lE,meshtoon_frag:uE,points_vert:hE,points_frag:dE,shadow_vert:fE,shadow_frag:pE,sprite_vert:mE,sprite_frag:gE},fe={common:{diffuse:{value:new ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ve}},envmap:{envMap:{value:null},envMapRotation:{value:new Ve},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ve}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ve}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ve},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ve},normalScale:{value:new Ue(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ve},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ve}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ve}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ve}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new ze(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new U},probesMax:{value:new U},probesResolution:{value:new U}},points:{diffuse:{value:new ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0},uvTransform:{value:new Ve}},sprite:{diffuse:{value:new ze(16777215)},opacity:{value:1},center:{value:new Ue(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}}},xi={basic:{uniforms:an([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:Ze.meshbasic_vert,fragmentShader:Ze.meshbasic_frag},lambert:{uniforms:an([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ze(0)},envMapIntensity:{value:1}}]),vertexShader:Ze.meshlambert_vert,fragmentShader:Ze.meshlambert_frag},phong:{uniforms:an([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ze(0)},specular:{value:new ze(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ze.meshphong_vert,fragmentShader:Ze.meshphong_frag},standard:{uniforms:an([fe.common,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.roughnessmap,fe.metalnessmap,fe.fog,fe.lights,{emissive:{value:new ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag},toon:{uniforms:an([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new ze(0)}}]),vertexShader:Ze.meshtoon_vert,fragmentShader:Ze.meshtoon_frag},matcap:{uniforms:an([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:Ze.meshmatcap_vert,fragmentShader:Ze.meshmatcap_frag},points:{uniforms:an([fe.points,fe.fog]),vertexShader:Ze.points_vert,fragmentShader:Ze.points_frag},dashed:{uniforms:an([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ze.linedashed_vert,fragmentShader:Ze.linedashed_frag},depth:{uniforms:an([fe.common,fe.displacementmap]),vertexShader:Ze.depth_vert,fragmentShader:Ze.depth_frag},normal:{uniforms:an([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:Ze.meshnormal_vert,fragmentShader:Ze.meshnormal_frag},sprite:{uniforms:an([fe.sprite,fe.fog]),vertexShader:Ze.sprite_vert,fragmentShader:Ze.sprite_frag},background:{uniforms:{uvTransform:{value:new Ve},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ze.background_vert,fragmentShader:Ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ve}},vertexShader:Ze.backgroundCube_vert,fragmentShader:Ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ze.cube_vert,fragmentShader:Ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ze.equirect_vert,fragmentShader:Ze.equirect_frag},distance:{uniforms:an([fe.common,fe.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ze.distance_vert,fragmentShader:Ze.distance_frag},shadow:{uniforms:an([fe.lights,fe.fog,{color:{value:new ze(0)},opacity:{value:1}}]),vertexShader:Ze.shadow_vert,fragmentShader:Ze.shadow_frag}};xi.physical={uniforms:an([xi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ve},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ve},clearcoatNormalScale:{value:new Ue(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ve},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ve},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ve},sheen:{value:0},sheenColor:{value:new ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ve},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ve},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ve},transmissionSamplerSize:{value:new Ue},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ve},attenuationDistance:{value:0},attenuationColor:{value:new ze(0)},specularColor:{value:new ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ve},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ve},anisotropyVector:{value:new Ue},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ve}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag};var Tc={r:0,b:0,g:0},_E=new $e,zm=new Ve;zm.set(-1,0,0,0,1,0,0,0,1);function xE(e,t,n,i,r,s){let o=new ze(0),a=r===!0?0:1,c,l,u=null,d=0,h=null;function f(S){let T=S.isScene===!0?S.background:null;if(T&&T.isTexture){let y=S.backgroundBlurriness>0;T=t.get(T,y)}return T}function m(S){let T=!1,y=f(S);if(y===null)p(o,a);else if(y&&y.isColor)p(y,1),T=!0;let w=e.xr.getEnvironmentBlendMode();if(w==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(w==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||T)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function _(S,T){let y=f(T);if(y&&(y.isCubeTexture||y.mapping===yo)){if(l===void 0)l=new Mt(new mr(1,1,1),new Bn({name:"BackgroundCubeMaterial",uniforms:Gr(xi.backgroundCube.uniforms),vertexShader:xi.backgroundCube.vertexShader,fragmentShader:xi.backgroundCube.fragmentShader,side:sn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(w,A,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=y,l.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(_E.makeRotationFromEuler(T.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(zm);if(l.material.toneMapped=je.getTransfer(y.colorSpace)!==yt,u!==y||d!==y.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=y,d=y.version,h=e.toneMapping;l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null)}else if(y&&y.isTexture){if(c===void 0)c=new Mt(new Lo(2,2),new Bn({name:"BackgroundMaterial",uniforms:Gr(xi.background.uniforms),vertexShader:xi.background.vertexShader,fragmentShader:xi.background.fragmentShader,side:ur,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=y,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=je.getTransfer(y.colorSpace)!==yt,y.matrixAutoUpdate===!0)y.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(y.matrix),u!==y||d!==y.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=y,d=y.version,h=e.toneMapping;c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null)}}function p(S,T){S.getRGB(Tc,eh(e)),n.buffers.color.setClear(Tc.r,Tc.g,Tc.b,T,s)}function g(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(S,T=1){o.set(S),a=T,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(S){a=S,p(o,a)},render:m,addToRenderList:_,dispose:g}}function yE(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(C,L,K,I,G){let X=!1,P=d(C,I,K,L);if(s!==P)s=P,l(s.object);if(X=f(C,I,K,G),X)m(C,I,K,G);if(G!==null)t.update(G,e.ELEMENT_ARRAY_BUFFER);if(X||o){if(o=!1,y(C,L,K,I),G!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(G).buffer)}}function c(){return e.createVertexArray()}function l(C){return e.bindVertexArray(C)}function u(C){return e.deleteVertexArray(C)}function d(C,L,K,I){let G=I.wireframe===!0,X=i[L.id];if(X===void 0)X={},i[L.id]=X;let P=C.isInstancedMesh===!0?C.id:0,j=X[P];if(j===void 0)j={},X[P]=j;let k=j[K.id];if(k===void 0)k={},j[K.id]=k;let q=k[G];if(q===void 0)q=h(c()),k[G]=q;return q}function h(C){let L=[],K=[],I=[];for(let G=0;G<n;G++)L[G]=0,K[G]=0,I[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:K,attributeDivisors:I,object:C,attributes:{},index:null}}function f(C,L,K,I){let G=s.attributes,X=L.attributes,P=0,j=K.getAttributes();for(let k in j)if(j[k].location>=0){let Q=G[k],Me=X[k];if(Me===void 0){if(k==="instanceMatrix"&&C.instanceMatrix)Me=C.instanceMatrix;if(k==="instanceColor"&&C.instanceColor)Me=C.instanceColor}if(Q===void 0)return!0;if(Q.attribute!==Me)return!0;if(Me&&Q.data!==Me.data)return!0;P++}if(s.attributesNum!==P)return!0;if(s.index!==I)return!0;return!1}function m(C,L,K,I){let G={},X=L.attributes,P=0,j=K.getAttributes();for(let k in j)if(j[k].location>=0){let Q=X[k];if(Q===void 0){if(k==="instanceMatrix"&&C.instanceMatrix)Q=C.instanceMatrix;if(k==="instanceColor"&&C.instanceColor)Q=C.instanceColor}let Me={};if(Me.attribute=Q,Q&&Q.data)Me.data=Q.data;G[k]=Me,P++}s.attributes=G,s.attributesNum=P,s.index=I}function _(){let C=s.newAttributes;for(let L=0,K=C.length;L<K;L++)C[L]=0}function p(C){g(C,0)}function g(C,L){let K=s.newAttributes,I=s.enabledAttributes,G=s.attributeDivisors;if(K[C]=1,I[C]===0)e.enableVertexAttribArray(C),I[C]=1;if(G[C]!==L)e.vertexAttribDivisor(C,L),G[C]=L}function S(){let C=s.newAttributes,L=s.enabledAttributes;for(let K=0,I=L.length;K<I;K++)if(L[K]!==C[K])e.disableVertexAttribArray(K),L[K]=0}function T(C,L,K,I,G,X,P){if(P===!0)e.vertexAttribIPointer(C,L,K,G,X);else e.vertexAttribPointer(C,L,K,I,G,X)}function y(C,L,K,I){_();let G=I.attributes,X=K.getAttributes(),P=L.defaultAttributeValues;for(let j in X){let k=X[j];if(k.location>=0){let q=G[j];if(q===void 0){if(j==="instanceMatrix"&&C.instanceMatrix)q=C.instanceMatrix;if(j==="instanceColor"&&C.instanceColor)q=C.instanceColor}if(q!==void 0){let Q=q.normalized,Me=q.itemSize,ue=t.get(q);if(ue===void 0)continue;let{buffer:Be,type:we,bytesPerElement:Z}=ue,re=we===e.INT||we===e.UNSIGNED_INT||q.gpuType===au;if(q.isInterleavedBufferAttribute){let se=q.data,xe=se.stride,Ee=q.offset;if(se.isInstancedInterleavedBuffer){for(let Ae=0;Ae<k.locationSize;Ae++)g(k.location+Ae,se.meshPerAttribute);if(C.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=se.meshPerAttribute*se.count}else for(let Ae=0;Ae<k.locationSize;Ae++)p(k.location+Ae);e.bindBuffer(e.ARRAY_BUFFER,Be);for(let Ae=0;Ae<k.locationSize;Ae++)T(k.location+Ae,Me/k.locationSize,we,Q,xe*Z,(Ee+Me/k.locationSize*Ae)*Z,re)}else{if(q.isInstancedBufferAttribute){for(let se=0;se<k.locationSize;se++)g(k.location+se,q.meshPerAttribute);if(C.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=q.meshPerAttribute*q.count}else for(let se=0;se<k.locationSize;se++)p(k.location+se);e.bindBuffer(e.ARRAY_BUFFER,Be);for(let se=0;se<k.locationSize;se++)T(k.location+se,Me/k.locationSize,we,Q,Me*Z,Me/k.locationSize*se*Z,re)}}else if(P!==void 0){let Q=P[j];if(Q!==void 0)switch(Q.length){case 2:e.vertexAttrib2fv(k.location,Q);break;case 3:e.vertexAttrib3fv(k.location,Q);break;case 4:e.vertexAttrib4fv(k.location,Q);break;default:e.vertexAttrib1fv(k.location,Q)}}}}S()}function w(){M();for(let C in i){let L=i[C];for(let K in L){let I=L[K];for(let G in I){let X=I[G];for(let P in X)u(X[P].object),delete X[P];delete I[G]}}delete i[C]}}function A(C){if(i[C.id]===void 0)return;let L=i[C.id];for(let K in L){let I=L[K];for(let G in I){let X=I[G];for(let P in X)u(X[P].object),delete X[P];delete I[G]}}delete i[C.id]}function R(C){for(let L in i){let K=i[L];for(let I in K){let G=K[I];if(G[C.id]===void 0)continue;let X=G[C.id];for(let P in X)u(X[P].object),delete X[P];delete G[C.id]}}}function x(C){for(let L in i){let K=i[L],I=C.isInstancedMesh===!0?C.id:0,G=K[I];if(G===void 0)continue;for(let X in G){let P=G[X];for(let j in P)u(P[j].object),delete P[j];delete G[X]}if(delete K[I],Object.keys(K).length===0)delete i[L]}}function M(){if(z(),o=!0,s===r)return;s=r,l(s.object)}function z(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:M,resetDefaultState:z,dispose:w,releaseStatesOfGeometry:A,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:_,enableAttribute:p,disableUnusedAttributes:S}}function vE(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let h=0;for(let f=0;f<u;f++)h+=l[f];n.update(h,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function bE(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let R=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(R){if(R!==mi&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(R){let x=R===pi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(R!==Qn&&R!==Gi&&!x&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(R){if(R==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";R="mediump"}if(R==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Le("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let d=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Le("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),g=e.getParameter(e.MAX_VERTEX_ATTRIBS),S=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),T=e.getParameter(e.MAX_VARYING_VECTORS),y=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),w=e.getParameter(e.MAX_SAMPLES),A=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:p,maxAttributes:g,maxVertexUniforms:S,maxVaryings:T,maxFragmentUniforms:y,maxSamples:w,samples:A}}function SE(e){let t=this,n=null,i=0,r=!1,s=!1,o=new Fn,a=new Ve,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let f=d.length!==0||h||i!==0||r;return r=h,i=d.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,h){n=u(d,h,0)},this.setState=function(d,h,f){let{clippingPlanes:m,clipIntersection:_,clipShadows:p}=d,g=e.get(d);if(!r||m===null||m.length===0||s&&!p)if(s)u(null);else l();else{let S=s?0:i,T=S*4,y=g.clippingState||null;c.value=y,y=u(m,h,T,f);for(let w=0;w!==T;++w)y[w]=n[w];g.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=S}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(d,h,f,m){let _=d!==null?d.length:0,p=null;if(_!==0){if(p=c.value,m!==!0||p===null){let g=f+_*4,S=h.matrixWorldInverse;if(a.getNormalMatrix(S),p===null||p.length<g)p=new Float32Array(g);for(let T=0,y=f;T!==_;++T,y+=4)o.copy(d[T]).applyMatrix4(S,a),o.normal.toArray(p,y),p[y+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,p}}var Bs=4,ME=6,wE=20,EE=256,Fo=new $r,gm=new ze,_h=null,xh=0,yh=0,vh=!1,AE=new U,Wr=new U;class Vo{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=0.1,i=100,r={}){let{size:s=256,position:o=AE}=r;_h=this._renderer.getRenderTarget(),xh=this._renderer.getActiveCubeFace(),yh=this._renderer.getActiveMipmapLevel(),vh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let a=this._allocateTargets();if(a.depthBuffer=!0,this._sceneToCubeUV(e,n,i,a,o),t>0)this._blur(a,0,0,t);return this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=ym(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=xm(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(_h,xh,yh),this._renderer.xr.enabled=vh,e.scissorTest=!1,ks(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===Es||e.mapping===Or)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);_h=this._renderer.getRenderTarget(),xh=this._renderer.getActiveCubeFace(),yh=this._renderer.getActiveMipmapLevel(),vh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:qt,minFilter:qt,generateMipmaps:!1,type:pi,format:mi,colorSpace:Mn,depthBuffer:!1},i=_m(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=_m(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=TE(r)),this._blurMaterial=CE(r,e,t),this._ggxMaterial=RE(r,e,t)}return i}_compileMaterial(e){let t=new Mt(new on,e);this._renderer.compile(t,Fo)}_sceneToCubeUV(e,t,n,i,r){let a=new Vt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:d,toneMapping:h}=u;if(u.getClearColor(gm),u.toneMapping=Jn,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new Mt(new mr,new gi({name:"PMREM.Background",side:sn,depthWrite:!1,depthTest:!1}));let m=this._backgroundBox,_=m.material,p=!1,g=e.background;if(g){if(g.isColor)_.color.copy(g),e.background=null,p=!0}else _.color.copy(gm),p=!0;for(let S=0;S<6;S++){let T=S%3;if(T===0)a.up.set(0,c[S],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[S],r.y,r.z);else if(T===1)a.up.set(0,0,c[S]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[S],r.z);else a.up.set(0,c[S],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[S]);let y=this._cubeSize;if(ks(i,T*y,S>2?y:0,y,y),u.setRenderTarget(i),p)u.render(m,a);u.render(e,a)}u.toneMapping=h,u.autoClear=d,e.background=g}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Es||e.mapping===Or;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=ym();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=xm();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let o=r.uniforms;o.envMap.value=e;let a=this._cubeSize;ks(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,Fo)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),d=c*1.25,h=u*d,{_lodMax:f}=this,m=this._sizeLods[n],_=3*m*(n>f-Bs?n-f+Bs:0),p=4*(this._cubeSize-m);a.envMap.value=e.texture,a.roughness.value=h,a.mipInt.value=f-t,ks(r,_,p,3*m,2*m),i.setRenderTarget(r),i.render(o,Fo),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=f-n,ks(e,_,p,3*m,2*m),i.setRenderTarget(e),i.render(o,Fo)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,o=this._blurMaterial,a=this._lodMeshes[i];a.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-Bs?i-this._lodMax+Bs:0),d=4*(this._cubeSize-l);ks(t,u,d,3*l,2*l),s.setRenderTarget(t),s.render(a,Fo)}}function TE(e){let t=[],n=[],i=e,r=e-Bs+1+ME;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],d=6,h=6,f=3,m=new Float32Array(f*h*d),_=new Float32Array(f*h*d);for(let g=0;g<d;g++){let S=g%3*2/3-1,T=g>2?0:-1,y=[S,T,0,S+0.6666666666666666,T,0,S+0.6666666666666666,T+1,0,S,T,0,S+0.6666666666666666,T+1,0,S,T+1,0];m.set(y,f*h*g);for(let w=0;w<h;w++){let A=u[w*2]*2-1,R=u[w*2+1]*2-1;if(g===0)Wr.set(1,R,A);else if(g===1)Wr.set(-A,1,-R);else if(g===2)Wr.set(-A,R,1);else if(g===3)Wr.set(-1,R,-A);else if(g===4)Wr.set(-A,-1,R);else Wr.set(A,R,-1);Wr.toArray(_,(g*h+w)*f)}}let p=new on;if(p.setAttribute("position",new jt(m,f)),p.setAttribute("outputDirection",new jt(_,f)),n.push(new Mt(p,null)),i>Bs)i--}return{lodMeshes:n,sizeLods:t}}function _m(e,t,n){let i=new wn(e,t,n);return i.texture.mapping=yo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function ks(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function RE(e,t,n){return new Bn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:EE,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Cc(),fragmentShader:`+}`,Ze={alphahash_fragment:BS,alphahash_pars_fragment:VS,alphamap_fragment:GS,alphamap_pars_fragment:HS,alphatest_fragment:$S,alphatest_pars_fragment:WS,aomap_fragment:ZS,aomap_pars_fragment:XS,batching_pars_vertex:jS,batching_vertex:qS,begin_vertex:YS,beginnormal_vertex:JS,bsdfs:KS,iridescence_fragment:QS,bumpmap_pars_fragment:eM,clipping_planes_fragment:tM,clipping_planes_pars_fragment:nM,clipping_planes_pars_vertex:iM,clipping_planes_vertex:rM,color_fragment:sM,color_pars_fragment:oM,color_pars_vertex:aM,color_vertex:cM,common:lM,cube_uv_reflection_fragment:uM,defaultnormal_vertex:hM,displacementmap_pars_vertex:dM,displacementmap_vertex:fM,emissivemap_fragment:pM,emissivemap_pars_fragment:mM,colorspace_fragment:gM,colorspace_pars_fragment:_M,envmap_fragment:xM,envmap_common_pars_fragment:yM,envmap_pars_fragment:vM,envmap_pars_vertex:bM,envmap_physical_pars_fragment:LM,envmap_vertex:SM,fog_vertex:MM,fog_pars_vertex:wM,fog_fragment:EM,fog_pars_fragment:AM,gradientmap_pars_fragment:TM,lightmap_pars_fragment:RM,lights_lambert_fragment:CM,lights_lambert_pars_fragment:PM,lights_pars_begin:IM,lights_toon_fragment:NM,lights_toon_pars_fragment:DM,lights_phong_fragment:OM,lights_phong_pars_fragment:UM,lights_physical_fragment:FM,lights_physical_pars_fragment:zM,lights_fragment_begin:kM,lights_fragment_maps:BM,lights_fragment_end:VM,lightprobes_pars_fragment:GM,logdepthbuf_fragment:HM,logdepthbuf_pars_fragment:$M,logdepthbuf_pars_vertex:WM,logdepthbuf_vertex:ZM,map_fragment:XM,map_pars_fragment:jM,map_particle_fragment:qM,map_particle_pars_fragment:YM,metalnessmap_fragment:JM,metalnessmap_pars_fragment:KM,morphinstance_vertex:QM,morphcolor_vertex:ew,morphnormal_vertex:tw,morphtarget_pars_vertex:nw,morphtarget_vertex:iw,normal_fragment_begin:rw,normal_fragment_maps:sw,normal_pars_fragment:ow,normal_pars_vertex:aw,normal_vertex:cw,normalmap_pars_fragment:lw,clearcoat_normal_fragment_begin:uw,clearcoat_normal_fragment_maps:hw,clearcoat_pars_fragment:dw,iridescence_pars_fragment:fw,opaque_fragment:pw,packing:mw,premultiplied_alpha_fragment:gw,project_vertex:_w,dithering_fragment:xw,dithering_pars_fragment:yw,roughnessmap_fragment:vw,roughnessmap_pars_fragment:bw,shadowmap_pars_fragment:Sw,shadowmap_pars_vertex:Mw,shadowmap_vertex:ww,shadowmask_pars_fragment:Ew,skinbase_vertex:Aw,skinning_pars_vertex:Tw,skinning_vertex:Rw,skinnormal_vertex:Cw,specularmap_fragment:Pw,specularmap_pars_fragment:Iw,tonemapping_fragment:Lw,tonemapping_pars_fragment:Nw,transmission_fragment:Dw,transmission_pars_fragment:Ow,uv_pars_fragment:Uw,uv_pars_vertex:Fw,uv_vertex:zw,worldpos_vertex:kw,background_vert:Bw,background_frag:Vw,backgroundCube_vert:Gw,backgroundCube_frag:Hw,cube_vert:$w,cube_frag:Ww,depth_vert:Zw,depth_frag:Xw,distance_vert:jw,distance_frag:qw,equirect_vert:Yw,equirect_frag:Jw,linedashed_vert:Kw,linedashed_frag:Qw,meshbasic_vert:eE,meshbasic_frag:tE,meshlambert_vert:nE,meshlambert_frag:iE,meshmatcap_vert:rE,meshmatcap_frag:sE,meshnormal_vert:oE,meshnormal_frag:aE,meshphong_vert:cE,meshphong_frag:lE,meshphysical_vert:uE,meshphysical_frag:hE,meshtoon_vert:dE,meshtoon_frag:fE,points_vert:pE,points_frag:mE,shadow_vert:gE,shadow_frag:_E,sprite_vert:xE,sprite_frag:yE},fe={common:{diffuse:{value:new ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ve}},envmap:{envMap:{value:null},envMapRotation:{value:new Ve},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ve}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ve}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ve},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ve},normalScale:{value:new Ue(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ve},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ve}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ve}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ve}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new ze(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new U},probesMax:{value:new U},probesResolution:{value:new U}},points:{diffuse:{value:new ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0},uvTransform:{value:new Ve}},sprite:{diffuse:{value:new ze(16777215)},opacity:{value:1},center:{value:new Ue(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}}},xi={basic:{uniforms:on([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:Ze.meshbasic_vert,fragmentShader:Ze.meshbasic_frag},lambert:{uniforms:on([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ze(0)},envMapIntensity:{value:1}}]),vertexShader:Ze.meshlambert_vert,fragmentShader:Ze.meshlambert_frag},phong:{uniforms:on([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ze(0)},specular:{value:new ze(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ze.meshphong_vert,fragmentShader:Ze.meshphong_frag},standard:{uniforms:on([fe.common,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.roughnessmap,fe.metalnessmap,fe.fog,fe.lights,{emissive:{value:new ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag},toon:{uniforms:on([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new ze(0)}}]),vertexShader:Ze.meshtoon_vert,fragmentShader:Ze.meshtoon_frag},matcap:{uniforms:on([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:Ze.meshmatcap_vert,fragmentShader:Ze.meshmatcap_frag},points:{uniforms:on([fe.points,fe.fog]),vertexShader:Ze.points_vert,fragmentShader:Ze.points_frag},dashed:{uniforms:on([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ze.linedashed_vert,fragmentShader:Ze.linedashed_frag},depth:{uniforms:on([fe.common,fe.displacementmap]),vertexShader:Ze.depth_vert,fragmentShader:Ze.depth_frag},normal:{uniforms:on([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:Ze.meshnormal_vert,fragmentShader:Ze.meshnormal_frag},sprite:{uniforms:on([fe.sprite,fe.fog]),vertexShader:Ze.sprite_vert,fragmentShader:Ze.sprite_frag},background:{uniforms:{uvTransform:{value:new Ve},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ze.background_vert,fragmentShader:Ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ve}},vertexShader:Ze.backgroundCube_vert,fragmentShader:Ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ze.cube_vert,fragmentShader:Ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ze.equirect_vert,fragmentShader:Ze.equirect_frag},distance:{uniforms:on([fe.common,fe.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ze.distance_vert,fragmentShader:Ze.distance_frag},shadow:{uniforms:on([fe.lights,fe.fog,{color:{value:new ze(0)},opacity:{value:1}}]),vertexShader:Ze.shadow_vert,fragmentShader:Ze.shadow_frag}};xi.physical={uniforms:on([xi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ve},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ve},clearcoatNormalScale:{value:new Ue(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ve},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ve},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ve},sheen:{value:0},sheenColor:{value:new ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ve},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ve},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ve},transmissionSamplerSize:{value:new Ue},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ve},attenuationDistance:{value:0},attenuationColor:{value:new ze(0)},specularColor:{value:new ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ve},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ve},anisotropyVector:{value:new Ue},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ve}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag};var Cc={r:0,b:0,g:0},vE=new $e,Bm=new Ve;Bm.set(-1,0,0,0,1,0,0,0,1);function bE(e,t,n,i,r,s){let o=new ze(0),a=r===!0?0:1,c,l,u=null,d=0,h=null;function f(S){let T=S.isScene===!0?S.background:null;if(T&&T.isTexture){let y=S.backgroundBlurriness>0;T=t.get(T,y)}return T}function m(S){let T=!1,y=f(S);if(y===null)p(o,a);else if(y&&y.isColor)p(y,1),T=!0;let w=e.xr.getEnvironmentBlendMode();if(w==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(w==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||T)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function _(S,T){let y=f(T);if(y&&(y.isCubeTexture||y.mapping===vo)){if(l===void 0)l=new Mt(new mr(1,1,1),new Bn({name:"BackgroundCubeMaterial",uniforms:Gr(xi.backgroundCube.uniforms),vertexShader:xi.backgroundCube.vertexShader,fragmentShader:xi.backgroundCube.fragmentShader,side:rn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(w,A,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=y,l.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(vE.makeRotationFromEuler(T.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(Bm);if(l.material.toneMapped=je.getTransfer(y.colorSpace)!==yt,u!==y||d!==y.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=y,d=y.version,h=e.toneMapping;l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null)}else if(y&&y.isTexture){if(c===void 0)c=new Mt(new No(2,2),new Bn({name:"BackgroundMaterial",uniforms:Gr(xi.background.uniforms),vertexShader:xi.background.vertexShader,fragmentShader:xi.background.fragmentShader,side:ur,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=y,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=je.getTransfer(y.colorSpace)!==yt,y.matrixAutoUpdate===!0)y.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(y.matrix),u!==y||d!==y.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=y,d=y.version,h=e.toneMapping;c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null)}}function p(S,T){S.getRGB(Cc,nh(e)),n.buffers.color.setClear(Cc.r,Cc.g,Cc.b,T,s)}function g(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(S,T=1){o.set(S),a=T,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(S){a=S,p(o,a)},render:m,addToRenderList:_,dispose:g}}function SE(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(C,L,K,I,G){let X=!1,P=d(C,I,K,L);if(s!==P)s=P,l(s.object);if(X=f(C,I,K,G),X)m(C,I,K,G);if(G!==null)t.update(G,e.ELEMENT_ARRAY_BUFFER);if(X||o){if(o=!1,y(C,L,K,I),G!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(G).buffer)}}function c(){return e.createVertexArray()}function l(C){return e.bindVertexArray(C)}function u(C){return e.deleteVertexArray(C)}function d(C,L,K,I){let G=I.wireframe===!0,X=i[L.id];if(X===void 0)X={},i[L.id]=X;let P=C.isInstancedMesh===!0?C.id:0,j=X[P];if(j===void 0)j={},X[P]=j;let k=j[K.id];if(k===void 0)k={},j[K.id]=k;let q=k[G];if(q===void 0)q=h(c()),k[G]=q;return q}function h(C){let L=[],K=[],I=[];for(let G=0;G<n;G++)L[G]=0,K[G]=0,I[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:K,attributeDivisors:I,object:C,attributes:{},index:null}}function f(C,L,K,I){let G=s.attributes,X=L.attributes,P=0,j=K.getAttributes();for(let k in j)if(j[k].location>=0){let Q=G[k],Me=X[k];if(Me===void 0){if(k==="instanceMatrix"&&C.instanceMatrix)Me=C.instanceMatrix;if(k==="instanceColor"&&C.instanceColor)Me=C.instanceColor}if(Q===void 0)return!0;if(Q.attribute!==Me)return!0;if(Me&&Q.data!==Me.data)return!0;P++}if(s.attributesNum!==P)return!0;if(s.index!==I)return!0;return!1}function m(C,L,K,I){let G={},X=L.attributes,P=0,j=K.getAttributes();for(let k in j)if(j[k].location>=0){let Q=X[k];if(Q===void 0){if(k==="instanceMatrix"&&C.instanceMatrix)Q=C.instanceMatrix;if(k==="instanceColor"&&C.instanceColor)Q=C.instanceColor}let Me={};if(Me.attribute=Q,Q&&Q.data)Me.data=Q.data;G[k]=Me,P++}s.attributes=G,s.attributesNum=P,s.index=I}function _(){let C=s.newAttributes;for(let L=0,K=C.length;L<K;L++)C[L]=0}function p(C){g(C,0)}function g(C,L){let K=s.newAttributes,I=s.enabledAttributes,G=s.attributeDivisors;if(K[C]=1,I[C]===0)e.enableVertexAttribArray(C),I[C]=1;if(G[C]!==L)e.vertexAttribDivisor(C,L),G[C]=L}function S(){let C=s.newAttributes,L=s.enabledAttributes;for(let K=0,I=L.length;K<I;K++)if(L[K]!==C[K])e.disableVertexAttribArray(K),L[K]=0}function T(C,L,K,I,G,X,P){if(P===!0)e.vertexAttribIPointer(C,L,K,G,X);else e.vertexAttribPointer(C,L,K,I,G,X)}function y(C,L,K,I){_();let G=I.attributes,X=K.getAttributes(),P=L.defaultAttributeValues;for(let j in X){let k=X[j];if(k.location>=0){let q=G[j];if(q===void 0){if(j==="instanceMatrix"&&C.instanceMatrix)q=C.instanceMatrix;if(j==="instanceColor"&&C.instanceColor)q=C.instanceColor}if(q!==void 0){let Q=q.normalized,Me=q.itemSize,ue=t.get(q);if(ue===void 0)continue;let{buffer:Be,type:we,bytesPerElement:Z}=ue,re=we===e.INT||we===e.UNSIGNED_INT||q.gpuType===lu;if(q.isInterleavedBufferAttribute){let se=q.data,xe=se.stride,Ee=q.offset;if(se.isInstancedInterleavedBuffer){for(let Ae=0;Ae<k.locationSize;Ae++)g(k.location+Ae,se.meshPerAttribute);if(C.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=se.meshPerAttribute*se.count}else for(let Ae=0;Ae<k.locationSize;Ae++)p(k.location+Ae);e.bindBuffer(e.ARRAY_BUFFER,Be);for(let Ae=0;Ae<k.locationSize;Ae++)T(k.location+Ae,Me/k.locationSize,we,Q,xe*Z,(Ee+Me/k.locationSize*Ae)*Z,re)}else{if(q.isInstancedBufferAttribute){for(let se=0;se<k.locationSize;se++)g(k.location+se,q.meshPerAttribute);if(C.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=q.meshPerAttribute*q.count}else for(let se=0;se<k.locationSize;se++)p(k.location+se);e.bindBuffer(e.ARRAY_BUFFER,Be);for(let se=0;se<k.locationSize;se++)T(k.location+se,Me/k.locationSize,we,Q,Me*Z,Me/k.locationSize*se*Z,re)}}else if(P!==void 0){let Q=P[j];if(Q!==void 0)switch(Q.length){case 2:e.vertexAttrib2fv(k.location,Q);break;case 3:e.vertexAttrib3fv(k.location,Q);break;case 4:e.vertexAttrib4fv(k.location,Q);break;default:e.vertexAttrib1fv(k.location,Q)}}}}S()}function w(){M();for(let C in i){let L=i[C];for(let K in L){let I=L[K];for(let G in I){let X=I[G];for(let P in X)u(X[P].object),delete X[P];delete I[G]}}delete i[C]}}function A(C){if(i[C.id]===void 0)return;let L=i[C.id];for(let K in L){let I=L[K];for(let G in I){let X=I[G];for(let P in X)u(X[P].object),delete X[P];delete I[G]}}delete i[C.id]}function R(C){for(let L in i){let K=i[L];for(let I in K){let G=K[I];if(G[C.id]===void 0)continue;let X=G[C.id];for(let P in X)u(X[P].object),delete X[P];delete G[C.id]}}}function x(C){for(let L in i){let K=i[L],I=C.isInstancedMesh===!0?C.id:0,G=K[I];if(G===void 0)continue;for(let X in G){let P=G[X];for(let j in P)u(P[j].object),delete P[j];delete G[X]}if(delete K[I],Object.keys(K).length===0)delete i[L]}}function M(){if(z(),o=!0,s===r)return;s=r,l(s.object)}function z(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:M,resetDefaultState:z,dispose:w,releaseStatesOfGeometry:A,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:_,enableAttribute:p,disableUnusedAttributes:S}}function ME(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let h=0;for(let f=0;f<u;f++)h+=l[f];n.update(h,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function wE(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let R=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(R){if(R!==mi&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(R){let x=R===pi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(R!==Qn&&R!==Gi&&!x&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(R){if(R==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";R="mediump"}if(R==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Le("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let d=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Le("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),g=e.getParameter(e.MAX_VERTEX_ATTRIBS),S=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),T=e.getParameter(e.MAX_VARYING_VECTORS),y=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),w=e.getParameter(e.MAX_SAMPLES),A=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:p,maxAttributes:g,maxVertexUniforms:S,maxVaryings:T,maxFragmentUniforms:y,maxSamples:w,samples:A}}function EE(e){let t=this,n=null,i=0,r=!1,s=!1,o=new Fn,a=new Ve,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let f=d.length!==0||h||i!==0||r;return r=h,i=d.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,h){n=u(d,h,0)},this.setState=function(d,h,f){let{clippingPlanes:m,clipIntersection:_,clipShadows:p}=d,g=e.get(d);if(!r||m===null||m.length===0||s&&!p)if(s)u(null);else l();else{let S=s?0:i,T=S*4,y=g.clippingState||null;c.value=y,y=u(m,h,T,f);for(let w=0;w!==T;++w)y[w]=n[w];g.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=S}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(d,h,f,m){let _=d!==null?d.length:0,p=null;if(_!==0){if(p=c.value,m!==!0||p===null){let g=f+_*4,S=h.matrixWorldInverse;if(a.getNormalMatrix(S),p===null||p.length<g)p=new Float32Array(g);for(let T=0,y=f;T!==_;++T,y+=4)o.copy(d[T]).applyMatrix4(S,a),o.normal.toArray(p,y),p[y+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,p}}var Bs=4,AE=6,TE=20,RE=256,zo=new $r,xm=new ze,yh=null,vh=0,bh=0,Sh=!1,CE=new U,Wr=new U;class Go{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=0.1,i=100,r={}){let{size:s=256,position:o=CE}=r;yh=this._renderer.getRenderTarget(),vh=this._renderer.getActiveCubeFace(),bh=this._renderer.getActiveMipmapLevel(),Sh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let a=this._allocateTargets();if(a.depthBuffer=!0,this._sceneToCubeUV(e,n,i,a,o),t>0)this._blur(a,0,0,t);return this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=bm(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=vm(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(yh,vh,bh),this._renderer.xr.enabled=Sh,e.scissorTest=!1,ks(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===Es||e.mapping===Or)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);yh=this._renderer.getRenderTarget(),vh=this._renderer.getActiveCubeFace(),bh=this._renderer.getActiveMipmapLevel(),Sh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:qt,minFilter:qt,generateMipmaps:!1,type:pi,format:mi,colorSpace:Sn,depthBuffer:!1},i=ym(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=ym(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=PE(r)),this._blurMaterial=LE(r,e,t),this._ggxMaterial=IE(r,e,t)}return i}_compileMaterial(e){let t=new Mt(new sn,e);this._renderer.compile(t,zo)}_sceneToCubeUV(e,t,n,i,r){let a=new Vt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:d,toneMapping:h}=u;if(u.getClearColor(xm),u.toneMapping=Jn,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new Mt(new mr,new gi({name:"PMREM.Background",side:rn,depthWrite:!1,depthTest:!1}));let m=this._backgroundBox,_=m.material,p=!1,g=e.background;if(g){if(g.isColor)_.color.copy(g),e.background=null,p=!0}else _.color.copy(xm),p=!0;for(let S=0;S<6;S++){let T=S%3;if(T===0)a.up.set(0,c[S],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[S],r.y,r.z);else if(T===1)a.up.set(0,0,c[S]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[S],r.z);else a.up.set(0,c[S],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[S]);let y=this._cubeSize;if(ks(i,T*y,S>2?y:0,y,y),u.setRenderTarget(i),p)u.render(m,a);u.render(e,a)}u.toneMapping=h,u.autoClear=d,e.background=g}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Es||e.mapping===Or;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=bm();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=vm();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let o=r.uniforms;o.envMap.value=e;let a=this._cubeSize;ks(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,zo)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),d=c*1.25,h=u*d,{_lodMax:f}=this,m=this._sizeLods[n],_=3*m*(n>f-Bs?n-f+Bs:0),p=4*(this._cubeSize-m);a.envMap.value=e.texture,a.roughness.value=h,a.mipInt.value=f-t,ks(r,_,p,3*m,2*m),i.setRenderTarget(r),i.render(o,zo),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=f-n,ks(e,_,p,3*m,2*m),i.setRenderTarget(e),i.render(o,zo)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,o=this._blurMaterial,a=this._lodMeshes[i];a.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-Bs?i-this._lodMax+Bs:0),d=4*(this._cubeSize-l);ks(t,u,d,3*l,2*l),s.setRenderTarget(t),s.render(a,zo)}}function PE(e){let t=[],n=[],i=e,r=e-Bs+1+AE;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],d=6,h=6,f=3,m=new Float32Array(f*h*d),_=new Float32Array(f*h*d);for(let g=0;g<d;g++){let S=g%3*2/3-1,T=g>2?0:-1,y=[S,T,0,S+0.6666666666666666,T,0,S+0.6666666666666666,T+1,0,S,T,0,S+0.6666666666666666,T+1,0,S,T+1,0];m.set(y,f*h*g);for(let w=0;w<h;w++){let A=u[w*2]*2-1,R=u[w*2+1]*2-1;if(g===0)Wr.set(1,R,A);else if(g===1)Wr.set(-A,1,-R);else if(g===2)Wr.set(-A,R,1);else if(g===3)Wr.set(-1,R,-A);else if(g===4)Wr.set(-A,-1,R);else Wr.set(A,R,-1);Wr.toArray(_,(g*h+w)*f)}}let p=new sn;if(p.setAttribute("position",new jt(m,f)),p.setAttribute("outputDirection",new jt(_,f)),n.push(new Mt(p,null)),i>Bs)i--}return{lodMeshes:n,sizeLods:t}}function ym(e,t,n){let i=new Mn(e,t,n);return i.texture.mapping=vo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function ks(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function IE(e,t,n){return new Bn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:RE,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Ic(),fragmentShader:`precision highp float;precision highp int;@@ -4048,7 +4048,7 @@ void main() {gl_FragColor = vec4(prefilteredColor, 1.0);}- `,blending:di,depthTest:!1,depthWrite:!1})}function CE(e,t,n){return new Bn({name:"SphericalGaussianBlur",defines:{SAMPLES:wE,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:Cc(),fragmentShader:`+ `,blending:di,depthTest:!1,depthWrite:!1})}function LE(e,t,n){return new Bn({name:"SphericalGaussianBlur",defines:{SAMPLES:TE,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:Ic(),fragmentShader:`precision highp float;precision highp int;@@ -4108,7 +4108,7 @@ void main() {gl_FragColor = vec4( accumColor / accumWeight, 1.0 );}- `,blending:di,depthTest:!1,depthWrite:!1})}function xm(){return new Bn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Cc(),fragmentShader:`+ `,blending:di,depthTest:!1,depthWrite:!1})}function vm(){return new Bn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ic(),fragmentShader:`precision mediump float;precision mediump int;@@ -4127,7 +4127,7 @@ void main() {gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );}- `,blending:di,depthTest:!1,depthWrite:!1})}function ym(){return new Bn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Cc(),fragmentShader:`+ `,blending:di,depthTest:!1,depthWrite:!1})}function bm(){return new Bn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ic(),fragmentShader:`precision mediump float;precision mediump int;@@ -4143,7 +4143,7 @@ void main() {gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );}- `,blending:di,depthTest:!1,depthWrite:!1})}function Cc(){return`+ `,blending:di,depthTest:!1,depthWrite:!1})}function Ic(){return`precision mediump float;precision mediump int;@@ -4158,7 +4158,7 @@ void main() {gl_Position = vec4( position, 1.0 );}- `}class Eh extends wn{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new gc(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`+ `}class Th extends Mn{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new xc(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`varying vec3 vWorldDirection;@@ -4193,7 +4193,7 @@ void main() {gl_FragColor = texture2D( tEquirect, sampleUV );}- `},i=new mr(5,5,5),r=new Bn({name:"CubemapFromEquirect",uniforms:Gr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:sn,blending:di});r.uniforms.tEquirect.value=t;let s=new Mt(i,r),o=t.minFilter;if(t.minFilter===fi)t.minFilter=qt;return new lh(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}}function PE(e){let t=new WeakMap,n=new WeakMap,i=null;function r(h,f=!1){if(h===null||h===void 0)return null;if(f)return o(h);return s(h)}function s(h){if(h&&h.isTexture){let f=h.mapping;if(f===Ya||f===Ja)if(t.has(h)){let m=t.get(h).texture;return a(m,h.mapping)}else{let m=h.image;if(m&&m.height>0){let _=new Eh(m.height);return _.fromEquirectangularTexture(e,h),t.set(h,_),h.addEventListener("dispose",l),a(_.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let f=h.mapping,m=f===Ya||f===Ja,_=f===Es||f===Or;if(m||_){let p=n.get(h),g=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==g){if(i===null)i=new Vo(e);return p=m?i.fromEquirectangular(h,p):i.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),p.texture}else if(p!==void 0)return p.texture;else{let S=h.image;if(m&&S&&S.height>0||_&&S&&c(S)){if(i===null)i=new Vo(e);return p=m?i.fromEquirectangular(h):i.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),h.addEventListener("dispose",u),p.texture}else return null}}}return h}function a(h,f){if(f===Ya)h.mapping=Es;else if(f===Ja)h.mapping=Or;return h}function c(h){let f=0,m=6;for(let _=0;_<m;_++)if(h[_]!==void 0)f++;return f===m}function l(h){let f=h.target;f.removeEventListener("dispose",l);let m=t.get(f);if(m!==void 0)t.delete(f),m.dispose()}function u(h){let f=h.target;f.removeEventListener("dispose",u);let m=n.get(f);if(m!==void 0)n.delete(f),m.dispose()}function d(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:d}}function IE(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let r=e.getExtension(i);return t[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let r=n(i);if(r===null)Nr("WebGLRenderer: "+i+" extension not supported.");return r}}}function LE(e,t,n,i){let r={},s=new WeakMap;function o(d){let h=d.target;if(h.index!==null)t.remove(h.index);for(let m in h.attributes)t.remove(h.attributes[m]);h.removeEventListener("dispose",o),delete r[h.id];let f=s.get(h);if(f)t.remove(f),s.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function a(d,h){if(r[h.id]===!0)return h;return h.addEventListener("dispose",o),r[h.id]=!0,n.memory.geometries++,h}function c(d){let h=d.attributes;for(let f in h)t.update(h[f],e.ARRAY_BUFFER)}function l(d){let h=[],f=d.index,m=d.attributes.position,_=0;if(m===void 0)return;if(f!==null){let S=f.array;_=f.version;for(let T=0,y=S.length;T<y;T+=3){let w=S[T+0],A=S[T+1],R=S[T+2];h.push(w,A,A,R,R,w)}}else{let S=m.array;_=m.version;for(let T=0,y=S.length/3-1;T<y;T+=3){let w=T+0,A=T+1,R=T+2;h.push(w,A,A,R,R,w)}}let p=new(m.count>=65535?dc:hc)(h,1);p.version=_;let g=s.get(d);if(g)t.remove(g);s.set(d,p)}function u(d){let h=s.get(d);if(h){let f=d.index;if(f!==null){if(h.version<f.version)l(d)}}else l(d);return s.get(d)}return{get:a,update:c,getWireframeAttribute:u}}function NE(e,t,n){let i;function r(d){i=d}let s,o;function a(d){s=d.type,o=d.bytesPerElement}function c(d,h){e.drawElements(i,h,s,d*o),n.update(h,i,1)}function l(d,h,f){if(f===0)return;e.drawElementsInstanced(i,h,s,d*o,f),n.update(h,i,f)}function u(d,h,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,s,d,0,f);let _=0;for(let p=0;p<f;p++)_+=h[p];n.update(_,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function DE(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:ke("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function OE(e,t,n){let i=new WeakMap,r=new ft;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,d=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==d){let M=function(){R.dispose(),i.delete(a),a.removeEventListener("dispose",M)};if(h!==void 0)h.texture.dispose();let f=a.morphAttributes.position!==void 0,m=a.morphAttributes.normal!==void 0,_=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],S=a.morphAttributes.color||[],T=0;if(f===!0)T=1;if(m===!0)T=2;if(_===!0)T=3;let y=a.attributes.position.count*T,w=1;if(y>t.maxTextureSize)w=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize;let A=new Float32Array(y*w*4*d),R=new lc(A,y,w,d);R.type=Gi,R.needsUpdate=!0;let x=T*4;for(let z=0;z<d;z++){let C=p[z],L=g[z],K=S[z],I=y*w*4*z;for(let G=0;G<C.count;G++){let X=G*x;if(f===!0)r.fromBufferAttribute(C,G),A[I+X+0]=r.x,A[I+X+1]=r.y,A[I+X+2]=r.z,A[I+X+3]=0;if(m===!0)r.fromBufferAttribute(L,G),A[I+X+4]=r.x,A[I+X+5]=r.y,A[I+X+6]=r.z,A[I+X+7]=0;if(_===!0)r.fromBufferAttribute(K,G),A[I+X+8]=r.x,A[I+X+9]=r.y,A[I+X+10]=r.z,A[I+X+11]=K.itemSize===4?r.w:1}}h={count:d,texture:R,size:new Ue(y,w)},i.set(a,h),a.addEventListener("dispose",M)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",o.morphTexture,n);else{let f=0;for(let _=0;_<l.length;_++)f+=l[_];let m=a.morphTargetsRelative?1:1-f;c.getUniforms().setValue(e,"morphTargetBaseInfluence",m),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}return{update:s}}function UE(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,d=l.geometry,h=t.get(l,d);if(s.get(h)!==u)t.update(h),s.set(h,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let f=l.skeleton;if(s.get(f)!==u)f.update(),s.set(f,u)}return h}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var FE={[tu]:"LINEAR_TONE_MAPPING",[nu]:"REINHARD_TONE_MAPPING",[iu]:"CINEON_TONE_MAPPING",[xo]:"ACES_FILMIC_TONE_MAPPING",[su]:"AGX_TONE_MAPPING",[ou]:"NEUTRAL_TONE_MAPPING",[ru]:"CUSTOM_TONE_MAPPING"};function zE(e,t,n,i,r,s){let o=new wn(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=new on;l.setAttribute("position",new xn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new xn([0,2,0,0,2,0],2));let u=new th({uniforms:{tDiffuse:{value:null}},vertexShader:`+ `},i=new mr(5,5,5),r=new Bn({name:"CubemapFromEquirect",uniforms:Gr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:rn,blending:di});r.uniforms.tEquirect.value=t;let s=new Mt(i,r),o=t.minFilter;if(t.minFilter===fi)t.minFilter=qt;return new hh(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}}function NE(e){let t=new WeakMap,n=new WeakMap,i=null;function r(h,f=!1){if(h===null||h===void 0)return null;if(f)return o(h);return s(h)}function s(h){if(h&&h.isTexture){let f=h.mapping;if(f===Ka||f===Qa)if(t.has(h)){let m=t.get(h).texture;return a(m,h.mapping)}else{let m=h.image;if(m&&m.height>0){let _=new Th(m.height);return _.fromEquirectangularTexture(e,h),t.set(h,_),h.addEventListener("dispose",l),a(_.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let f=h.mapping,m=f===Ka||f===Qa,_=f===Es||f===Or;if(m||_){let p=n.get(h),g=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==g){if(i===null)i=new Go(e);return p=m?i.fromEquirectangular(h,p):i.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),p.texture}else if(p!==void 0)return p.texture;else{let S=h.image;if(m&&S&&S.height>0||_&&S&&c(S)){if(i===null)i=new Go(e);return p=m?i.fromEquirectangular(h):i.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),h.addEventListener("dispose",u),p.texture}else return null}}}return h}function a(h,f){if(f===Ka)h.mapping=Es;else if(f===Qa)h.mapping=Or;return h}function c(h){let f=0,m=6;for(let _=0;_<m;_++)if(h[_]!==void 0)f++;return f===m}function l(h){let f=h.target;f.removeEventListener("dispose",l);let m=t.get(f);if(m!==void 0)t.delete(f),m.dispose()}function u(h){let f=h.target;f.removeEventListener("dispose",u);let m=n.get(f);if(m!==void 0)n.delete(f),m.dispose()}function d(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:d}}function DE(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let r=e.getExtension(i);return t[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let r=n(i);if(r===null)Nr("WebGLRenderer: "+i+" extension not supported.");return r}}}function OE(e,t,n,i){let r={},s=new WeakMap;function o(d){let h=d.target;if(h.index!==null)t.remove(h.index);for(let m in h.attributes)t.remove(h.attributes[m]);h.removeEventListener("dispose",o),delete r[h.id];let f=s.get(h);if(f)t.remove(f),s.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function a(d,h){if(r[h.id]===!0)return h;return h.addEventListener("dispose",o),r[h.id]=!0,n.memory.geometries++,h}function c(d){let h=d.attributes;for(let f in h)t.update(h[f],e.ARRAY_BUFFER)}function l(d){let h=[],f=d.index,m=d.attributes.position,_=0;if(m===void 0)return;if(f!==null){let S=f.array;_=f.version;for(let T=0,y=S.length;T<y;T+=3){let w=S[T+0],A=S[T+1],R=S[T+2];h.push(w,A,A,R,R,w)}}else{let S=m.array;_=m.version;for(let T=0,y=S.length/3-1;T<y;T+=3){let w=T+0,A=T+1,R=T+2;h.push(w,A,A,R,R,w)}}let p=new(m.count>=65535?pc:fc)(h,1);p.version=_;let g=s.get(d);if(g)t.remove(g);s.set(d,p)}function u(d){let h=s.get(d);if(h){let f=d.index;if(f!==null){if(h.version<f.version)l(d)}}else l(d);return s.get(d)}return{get:a,update:c,getWireframeAttribute:u}}function UE(e,t,n){let i;function r(d){i=d}let s,o;function a(d){s=d.type,o=d.bytesPerElement}function c(d,h){e.drawElements(i,h,s,d*o),n.update(h,i,1)}function l(d,h,f){if(f===0)return;e.drawElementsInstanced(i,h,s,d*o,f),n.update(h,i,f)}function u(d,h,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,s,d,0,f);let _=0;for(let p=0;p<f;p++)_+=h[p];n.update(_,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function FE(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:ke("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function zE(e,t,n){let i=new WeakMap,r=new ft;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,d=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==d){let M=function(){R.dispose(),i.delete(a),a.removeEventListener("dispose",M)};if(h!==void 0)h.texture.dispose();let f=a.morphAttributes.position!==void 0,m=a.morphAttributes.normal!==void 0,_=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],S=a.morphAttributes.color||[],T=0;if(f===!0)T=1;if(m===!0)T=2;if(_===!0)T=3;let y=a.attributes.position.count*T,w=1;if(y>t.maxTextureSize)w=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize;let A=new Float32Array(y*w*4*d),R=new hc(A,y,w,d);R.type=Gi,R.needsUpdate=!0;let x=T*4;for(let z=0;z<d;z++){let C=p[z],L=g[z],K=S[z],I=y*w*4*z;for(let G=0;G<C.count;G++){let X=G*x;if(f===!0)r.fromBufferAttribute(C,G),A[I+X+0]=r.x,A[I+X+1]=r.y,A[I+X+2]=r.z,A[I+X+3]=0;if(m===!0)r.fromBufferAttribute(L,G),A[I+X+4]=r.x,A[I+X+5]=r.y,A[I+X+6]=r.z,A[I+X+7]=0;if(_===!0)r.fromBufferAttribute(K,G),A[I+X+8]=r.x,A[I+X+9]=r.y,A[I+X+10]=r.z,A[I+X+11]=K.itemSize===4?r.w:1}}h={count:d,texture:R,size:new Ue(y,w)},i.set(a,h),a.addEventListener("dispose",M)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",o.morphTexture,n);else{let f=0;for(let _=0;_<l.length;_++)f+=l[_];let m=a.morphTargetsRelative?1:1-f;c.getUniforms().setValue(e,"morphTargetBaseInfluence",m),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}return{update:s}}function kE(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,d=l.geometry,h=t.get(l,d);if(s.get(h)!==u)t.update(h),s.set(h,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let f=l.skeleton;if(s.get(f)!==u)f.update(),s.set(f,u)}return h}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var BE={[iu]:"LINEAR_TONE_MAPPING",[ru]:"REINHARD_TONE_MAPPING",[su]:"CINEON_TONE_MAPPING",[yo]:"ACES_FILMIC_TONE_MAPPING",[au]:"AGX_TONE_MAPPING",[cu]:"NEUTRAL_TONE_MAPPING",[ou]:"CUSTOM_TONE_MAPPING"};function VE(e,t,n,i,r,s){let o=new Mn(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=new sn;l.setAttribute("position",new _n([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new _n([0,2,0,0,2,0],2));let u=new ih({uniforms:{tDiffuse:{value:null}},vertexShader:`precision highp float;uniform mat4 modelViewMatrix;@@ -4239,17 +4239,17 @@ void main() {#ifdef SRGB_TRANSFERgl_FragColor = sRGBTransferOETF( gl_FragColor );#endif- }`,depthTest:!1,depthWrite:!1}),d=new Mt(l,u),h=new $r(-1,1,1,-1,0,1),f=null,m=null,_=!1,p,g=null,S=[],T=!1;this.setSize=function(y,w){if(o.setSize(y,w),a!==null)a.setSize(y,w);if(c!==null)c.setSize(y,w);for(let A=0;A<S.length;A++){let R=S[A];if(R.setSize)R.setSize(y,w)}},this.setEffects=function(y){S=y,T=S.length>0&&S[0].isRenderPass===!0;let{width:w,height:A}=o;if(S.length>0&&a===null)a=new wn(w,A,{type:pi,depthBuffer:!1,stencilBuffer:!1}),c=new wn(w,A,{type:pi,depthBuffer:!1,stencilBuffer:!1});for(let R=0;R<S.length;R++){let x=S[R];if(x.setSize)x.setSize(w,A)}},this.begin=function(y,w){if(_)return!1;if(y.toneMapping===Jn&&S.length===0)return!1;if(g=w,w!==null){let{width:A,height:R}=w;if(o.width!==A||o.height!==R)this.setSize(A,R)}if(T===!1)y.setRenderTarget(o);return p=y.toneMapping,y.toneMapping=Jn,!0},this.hasRenderPass=function(){return T},this.end=function(y,w){y.toneMapping=p,_=!0;let A=o,R=a;for(let x=0;x<S.length;x++){let M=S[x];if(M.enabled===!1)continue;if(M.render(y,R,A,w),M.needsSwap!==!1)A=R,R=R===a?c:a}if(f!==y.outputColorSpace||m!==y.toneMapping){if(f=y.outputColorSpace,m=y.toneMapping,u.defines={},je.getTransfer(f)===yt)u.defines.SRGB_TRANSFER="";let x=FE[m];if(x)u.defines[x]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=A.texture,y.setRenderTarget(g),y.render(d,h),g=null,_=!1},this.isCompositing=function(){return _},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var km=new Nt,Mh=new Vr(1,1),Bm=new lc,Vm=new Ku,Gm=new gc,vm=[],bm=[],Sm=new Float32Array(16),Mm=new Float32Array(9),wm=new Float32Array(4);function Vs(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=vm[r];if(s===void 0)s=new Float32Array(r),vm[r]=s;if(t!==0){i.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=n,e[o].toArray(s,a)}return s}function Ht(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function $t(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Pc(e,t){let n=bm[t];if(n===void 0)n=new Int32Array(t),bm[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function kE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function BE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ht(n,t))return;e.uniform2fv(this.addr,t),$t(n,t)}}function VE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if(Ht(n,t))return;e.uniform3fv(this.addr,t),$t(n,t)}}function GE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(Ht(n,t))return;e.uniform4fv(this.addr,t),$t(n,t)}}function HE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;wm.set(i),e.uniformMatrix2fv(this.addr,!1,wm),$t(n,i)}}function $E(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;Mm.set(i),e.uniformMatrix3fv(this.addr,!1,Mm),$t(n,i)}}function WE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;Sm.set(i),e.uniformMatrix4fv(this.addr,!1,Sm),$t(n,i)}}function ZE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function XE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ht(n,t))return;e.uniform2iv(this.addr,t),$t(n,t)}}function jE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(Ht(n,t))return;e.uniform3iv(this.addr,t),$t(n,t)}}function qE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(Ht(n,t))return;e.uniform4iv(this.addr,t),$t(n,t)}}function YE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function JE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ht(n,t))return;e.uniform2uiv(this.addr,t),$t(n,t)}}function KE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(Ht(n,t))return;e.uniform3uiv(this.addr,t),$t(n,t)}}function QE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(Ht(n,t))return;e.uniform4uiv(this.addr,t),$t(n,t)}}function eA(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;let s;if(this.type===e.SAMPLER_2D_SHADOW)Mh.compareFunction=n.isReversedDepthBuffer()?cc:ac,s=Mh;else s=km;n.setTexture2D(t||s,r)}function tA(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture3D(t||Vm,r)}function nA(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTextureCube(t||Gm,r)}function iA(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture2DArray(t||Bm,r)}function rA(e){switch(e){case 5126:return kE;case 35664:return BE;case 35665:return VE;case 35666:return GE;case 35674:return HE;case 35675:return $E;case 35676:return WE;case 5124:case 35670:return ZE;case 35667:case 35671:return XE;case 35668:case 35672:return jE;case 35669:case 35673:return qE;case 5125:return YE;case 36294:return JE;case 36295:return KE;case 36296:return QE;case 35678:case 36198:case 36298:case 36306:case 35682:return eA;case 35679:case 36299:case 36307:return tA;case 35680:case 36300:case 36308:case 36293:return nA;case 36289:case 36303:case 36311:case 36292:return iA}}function sA(e,t){e.uniform1fv(this.addr,t)}function oA(e,t){let n=Vs(t,this.size,2);e.uniform2fv(this.addr,n)}function aA(e,t){let n=Vs(t,this.size,3);e.uniform3fv(this.addr,n)}function cA(e,t){let n=Vs(t,this.size,4);e.uniform4fv(this.addr,n)}function lA(e,t){let n=Vs(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function uA(e,t){let n=Vs(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function hA(e,t){let n=Vs(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function dA(e,t){e.uniform1iv(this.addr,t)}function fA(e,t){e.uniform2iv(this.addr,t)}function pA(e,t){e.uniform3iv(this.addr,t)}function mA(e,t){e.uniform4iv(this.addr,t)}function gA(e,t){e.uniform1uiv(this.addr,t)}function _A(e,t){e.uniform2uiv(this.addr,t)}function xA(e,t){e.uniform3uiv(this.addr,t)}function yA(e,t){e.uniform4uiv(this.addr,t)}function vA(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=Mh;else o=km;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function bA(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||Vm,s[o])}function SA(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||Gm,s[o])}function MA(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||Bm,s[o])}function wA(e){switch(e){case 5126:return sA;case 35664:return oA;case 35665:return aA;case 35666:return cA;case 35674:return lA;case 35675:return uA;case 35676:return hA;case 5124:case 35670:return dA;case 35667:case 35671:return fA;case 35668:case 35672:return pA;case 35669:case 35673:return mA;case 5125:return gA;case 36294:return _A;case 36295:return xA;case 36296:return yA;case 35678:case 36198:case 36298:case 36306:case 35682:return vA;case 35679:case 36299:case 36307:return bA;case 35680:case 36300:case 36308:case 36293:return SA;case 36289:case 36303:case 36311:case 36292:return MA}}class Hm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=rA(t.type)}}class $m{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=wA(t.type)}}class Wm{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let o=i[r];o.setValue(e,t[o.id],n)}}}var bh=/(\w+)(\])?(\[|\.)?/g;function Em(e,t){e.seq.push(t),e.map[t.id]=t}function EA(e,t,n){let i=e.name,r=i.length;bh.lastIndex=0;while(!0){let s=bh.exec(i),o=bh.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){Em(n,l===void 0?new Hm(a,e,t):new $m(a,e,t));break}else{let d=n.map[a];if(d===void 0)d=new Wm(a),Em(n,d);n=d}}}class Bo{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let o=e.getActiveUniform(t,s),a=e.getUniformLocation(t,o.name);EA(o,a,this)}let i=[],r=[];for(let s of this.seq)if(s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(s);else r.push(s);if(i.length>0)this.seq=i.concat(r)}setValue(e,t,n,i){let r=this.map[t];if(r!==void 0)r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){let o=t[r],a=n[o.id];if(a.needsUpdate!==!1)o.setValue(e,a.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let s=e[i];if(s.id in t)n.push(s)}return n}}function Am(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var AA=37297,TA=0;function RA(e,t){let n=e.split(`+ }`,depthTest:!1,depthWrite:!1}),d=new Mt(l,u),h=new $r(-1,1,1,-1,0,1),f=null,m=null,_=!1,p,g=null,S=[],T=!1;this.setSize=function(y,w){if(o.setSize(y,w),a!==null)a.setSize(y,w);if(c!==null)c.setSize(y,w);for(let A=0;A<S.length;A++){let R=S[A];if(R.setSize)R.setSize(y,w)}},this.setEffects=function(y){S=y,T=S.length>0&&S[0].isRenderPass===!0;let{width:w,height:A}=o;if(S.length>0&&a===null)a=new Mn(w,A,{type:pi,depthBuffer:!1,stencilBuffer:!1}),c=new Mn(w,A,{type:pi,depthBuffer:!1,stencilBuffer:!1});for(let R=0;R<S.length;R++){let x=S[R];if(x.setSize)x.setSize(w,A)}},this.begin=function(y,w){if(_)return!1;if(y.toneMapping===Jn&&S.length===0)return!1;if(g=w,w!==null){let{width:A,height:R}=w;if(o.width!==A||o.height!==R)this.setSize(A,R)}if(T===!1)y.setRenderTarget(o);return p=y.toneMapping,y.toneMapping=Jn,!0},this.hasRenderPass=function(){return T},this.end=function(y,w){y.toneMapping=p,_=!0;let A=o,R=a;for(let x=0;x<S.length;x++){let M=S[x];if(M.enabled===!1)continue;if(M.render(y,R,A,w),M.needsSwap!==!1)A=R,R=R===a?c:a}if(f!==y.outputColorSpace||m!==y.toneMapping){if(f=y.outputColorSpace,m=y.toneMapping,u.defines={},je.getTransfer(f)===yt)u.defines.SRGB_TRANSFER="";let x=BE[m];if(x)u.defines[x]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=A.texture,y.setRenderTarget(g),y.render(d,h),g=null,_=!1},this.isCompositing=function(){return _},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var Vm=new Nt,Eh=new Vr(1,1),Gm=new hc,Hm=new eh,$m=new xc,Sm=[],Mm=[],wm=new Float32Array(16),Em=new Float32Array(9),Am=new Float32Array(4);function Vs(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=Sm[r];if(s===void 0)s=new Float32Array(r),Sm[r]=s;if(t!==0){i.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=n,e[o].toArray(s,a)}return s}function Ht(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function $t(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Lc(e,t){let n=Mm[t];if(n===void 0)n=new Int32Array(t),Mm[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function GE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function HE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ht(n,t))return;e.uniform2fv(this.addr,t),$t(n,t)}}function $E(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if(Ht(n,t))return;e.uniform3fv(this.addr,t),$t(n,t)}}function WE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(Ht(n,t))return;e.uniform4fv(this.addr,t),$t(n,t)}}function ZE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;Am.set(i),e.uniformMatrix2fv(this.addr,!1,Am),$t(n,i)}}function XE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;Em.set(i),e.uniformMatrix3fv(this.addr,!1,Em),$t(n,i)}}function jE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;wm.set(i),e.uniformMatrix4fv(this.addr,!1,wm),$t(n,i)}}function qE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function YE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ht(n,t))return;e.uniform2iv(this.addr,t),$t(n,t)}}function JE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(Ht(n,t))return;e.uniform3iv(this.addr,t),$t(n,t)}}function KE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(Ht(n,t))return;e.uniform4iv(this.addr,t),$t(n,t)}}function QE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function eA(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ht(n,t))return;e.uniform2uiv(this.addr,t),$t(n,t)}}function tA(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(Ht(n,t))return;e.uniform3uiv(this.addr,t),$t(n,t)}}function nA(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(Ht(n,t))return;e.uniform4uiv(this.addr,t),$t(n,t)}}function iA(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;let s;if(this.type===e.SAMPLER_2D_SHADOW)Eh.compareFunction=n.isReversedDepthBuffer()?uc:lc,s=Eh;else s=Vm;n.setTexture2D(t||s,r)}function rA(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture3D(t||Hm,r)}function sA(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTextureCube(t||$m,r)}function oA(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture2DArray(t||Gm,r)}function aA(e){switch(e){case 5126:return GE;case 35664:return HE;case 35665:return $E;case 35666:return WE;case 35674:return ZE;case 35675:return XE;case 35676:return jE;case 5124:case 35670:return qE;case 35667:case 35671:return YE;case 35668:case 35672:return JE;case 35669:case 35673:return KE;case 5125:return QE;case 36294:return eA;case 36295:return tA;case 36296:return nA;case 35678:case 36198:case 36298:case 36306:case 35682:return iA;case 35679:case 36299:case 36307:return rA;case 35680:case 36300:case 36308:case 36293:return sA;case 36289:case 36303:case 36311:case 36292:return oA}}function cA(e,t){e.uniform1fv(this.addr,t)}function lA(e,t){let n=Vs(t,this.size,2);e.uniform2fv(this.addr,n)}function uA(e,t){let n=Vs(t,this.size,3);e.uniform3fv(this.addr,n)}function hA(e,t){let n=Vs(t,this.size,4);e.uniform4fv(this.addr,n)}function dA(e,t){let n=Vs(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function fA(e,t){let n=Vs(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function pA(e,t){let n=Vs(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function mA(e,t){e.uniform1iv(this.addr,t)}function gA(e,t){e.uniform2iv(this.addr,t)}function _A(e,t){e.uniform3iv(this.addr,t)}function xA(e,t){e.uniform4iv(this.addr,t)}function yA(e,t){e.uniform1uiv(this.addr,t)}function vA(e,t){e.uniform2uiv(this.addr,t)}function bA(e,t){e.uniform3uiv(this.addr,t)}function SA(e,t){e.uniform4uiv(this.addr,t)}function MA(e,t,n){let i=this.cache,r=t.length,s=Lc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=Eh;else o=Vm;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function wA(e,t,n){let i=this.cache,r=t.length,s=Lc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||Hm,s[o])}function EA(e,t,n){let i=this.cache,r=t.length,s=Lc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||$m,s[o])}function AA(e,t,n){let i=this.cache,r=t.length,s=Lc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||Gm,s[o])}function TA(e){switch(e){case 5126:return cA;case 35664:return lA;case 35665:return uA;case 35666:return hA;case 35674:return dA;case 35675:return fA;case 35676:return pA;case 5124:case 35670:return mA;case 35667:case 35671:return gA;case 35668:case 35672:return _A;case 35669:case 35673:return xA;case 5125:return yA;case 36294:return vA;case 36295:return bA;case 36296:return SA;case 35678:case 36198:case 36298:case 36306:case 35682:return MA;case 35679:case 36299:case 36307:return wA;case 35680:case 36300:case 36308:case 36293:return EA;case 36289:case 36303:case 36311:case 36292:return AA}}class Wm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=aA(t.type)}}class Zm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=TA(t.type)}}class Xm{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let o=i[r];o.setValue(e,t[o.id],n)}}}var Mh=/(\w+)(\])?(\[|\.)?/g;function Tm(e,t){e.seq.push(t),e.map[t.id]=t}function RA(e,t,n){let i=e.name,r=i.length;Mh.lastIndex=0;while(!0){let s=Mh.exec(i),o=Mh.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){Tm(n,l===void 0?new Wm(a,e,t):new Zm(a,e,t));break}else{let d=n.map[a];if(d===void 0)d=new Xm(a),Tm(n,d);n=d}}}class Vo{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let o=e.getActiveUniform(t,s),a=e.getUniformLocation(t,o.name);RA(o,a,this)}let i=[],r=[];for(let s of this.seq)if(s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(s);else r.push(s);if(i.length>0)this.seq=i.concat(r)}setValue(e,t,n,i){let r=this.map[t];if(r!==void 0)r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){let o=t[r],a=n[o.id];if(a.needsUpdate!==!1)o.setValue(e,a.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let s=e[i];if(s.id in t)n.push(s)}return n}}function Rm(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var CA=37297,PA=0;function IA(e,t){let n=e.split(``),i=[],r=Math.max(t-6,0),s=Math.min(t+6,n.length);for(let o=r;o<s;o++){let a=o+1;i.push(`${a===t?">":" "} ${a}: ${n[o]}`)}return i.join(`-`)}var Tm=new Ve;function CA(e){je._getMatrix(Tm,je.workingColorSpace,e);let t=`mat3( ${Tm.elements.map((n)=>n.toFixed(4))} )`;switch(je.getTransfer(e)){case Zu:return[t,"LinearTransferOETF"];case yt:return[t,"sRGBTransferOETF"];default:return Le("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Rm(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let o=/ERROR: 0:(\d+)/.exec(s);if(o){let a=parseInt(o[1]);return n.toUpperCase()+`+`)}var Cm=new Ve;function LA(e){je._getMatrix(Cm,je.workingColorSpace,e);let t=`mat3( ${Cm.elements.map((n)=>n.toFixed(4))} )`;switch(je.getTransfer(e)){case ju:return[t,"LinearTransferOETF"];case yt:return[t,"sRGBTransferOETF"];default:return Le("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Pm(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let o=/ERROR: 0:(\d+)/.exec(s);if(o){let a=parseInt(o[1]);return n.toUpperCase()+``+s+`-`+RA(e.getShaderSource(t),a)}else return s}function PA(e,t){let n=CA(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`-`)}var IA={[tu]:"Linear",[nu]:"Reinhard",[iu]:"Cineon",[xo]:"ACESFilmic",[su]:"AgX",[ou]:"Neutral",[ru]:"Custom"};function LA(e,t){let n=IA[t];if(n===void 0)return Le("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var Rc=new U;function NA(){je.getLuminanceCoefficients(Rc);let e=Rc.x.toFixed(4),t=Rc.y.toFixed(4),n=Rc.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`-`)}function DA(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ko).join(`-`)}function OA(e){let t=[];for(let n in e){let i=e[n];if(i===!1)continue;t.push("#define "+n+" "+i)}return t.join(`-`)}function UA(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),o=s.name,a=1;if(s.type===e.FLOAT_MAT2)a=2;if(s.type===e.FLOAT_MAT3)a=3;if(s.type===e.FLOAT_MAT4)a=4;n[o]={type:s.type,location:e.getAttribLocation(t,o),locationSize:a}}return n}function ko(e){return e!==""}function Cm(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Pm(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var FA=/^[ \t]*#include +<([\w\d./]+)>/gm;function wh(e){return e.replace(FA,kA)}var zA=new Map;function kA(e,t){let n=Ze[t];if(n===void 0){let i=zA.get(t);if(i!==void 0)n=Ze[i],Le('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return wh(n)}var BA=/#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 Im(e){return e.replace(BA,VA)}function VA(e,t,n,i){let r="";for(let s=parseInt(t);s<parseInt(n);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Lm(e){let t=`precision ${e.precision} float;+`+IA(e.getShaderSource(t),a)}else return s}function NA(e,t){let n=LA(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`+`)}var DA={[iu]:"Linear",[ru]:"Reinhard",[su]:"Cineon",[yo]:"ACESFilmic",[au]:"AgX",[cu]:"Neutral",[ou]:"Custom"};function OA(e,t){let n=DA[t];if(n===void 0)return Le("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var Pc=new U;function UA(){je.getLuminanceCoefficients(Pc);let e=Pc.x.toFixed(4),t=Pc.y.toFixed(4),n=Pc.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`+`)}function FA(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Bo).join(`+`)}function zA(e){let t=[];for(let n in e){let i=e[n];if(i===!1)continue;t.push("#define "+n+" "+i)}return t.join(`+`)}function kA(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),o=s.name,a=1;if(s.type===e.FLOAT_MAT2)a=2;if(s.type===e.FLOAT_MAT3)a=3;if(s.type===e.FLOAT_MAT4)a=4;n[o]={type:s.type,location:e.getAttribLocation(t,o),locationSize:a}}return n}function Bo(e){return e!==""}function Im(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Lm(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var BA=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ah(e){return e.replace(BA,GA)}var VA=new Map;function GA(e,t){let n=Ze[t];if(n===void 0){let i=VA.get(t);if(i!==void 0)n=Ze[i],Le('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Ah(n)}var HA=/#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 Nm(e){return e.replace(HA,$A)}function $A(e,t,n,i){let r="";for(let s=parseInt(t);s<parseInt(n);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Dm(e){let t=`precision ${e.precision} float;precision ${e.precision} int;precision ${e.precision} sampler2D;precision ${e.precision} samplerCube;@@ -4269,30 +4269,30 @@ void main() {`;if(e.precision==="highp")t+=`#define HIGH_PRECISION`;else if(e.precision==="mediump")t+=`#define MEDIUM_PRECISION`;else if(e.precision==="lowp")t+=`-#define LOW_PRECISION`;return t}var GA={[go]:"SHADOWMAP_TYPE_PCF",[Ms]:"SHADOWMAP_TYPE_VSM"};function HA(e){return GA[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var $A={[Es]:"ENVMAP_TYPE_CUBE",[Or]:"ENVMAP_TYPE_CUBE",[yo]:"ENVMAP_TYPE_CUBE_UV"};function WA(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return $A[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var ZA={[Or]:"ENVMAP_MODE_REFRACTION"};function XA(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return ZA[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var jA={[Bp]:"ENVMAP_BLENDING_MULTIPLY",[Vp]:"ENVMAP_BLENDING_MIX",[Gp]:"ENVMAP_BLENDING_ADD"};function qA(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return jA[e.combine]||"ENVMAP_BLENDING_NONE"}function YA(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function JA(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=HA(n),l=WA(n),u=XA(n),d=qA(n),h=YA(n),f=DA(n),m=OA(s),_=r.createProgram(),p,g,S=n.glslVersion?"#version "+n.glslVersion+`-`:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ko).join(`+#define LOW_PRECISION`;return t}var WA={[_o]:"SHADOWMAP_TYPE_PCF",[Ms]:"SHADOWMAP_TYPE_VSM"};function ZA(e){return WA[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var XA={[Es]:"ENVMAP_TYPE_CUBE",[Or]:"ENVMAP_TYPE_CUBE",[vo]:"ENVMAP_TYPE_CUBE_UV"};function jA(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return XA[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var qA={[Or]:"ENVMAP_MODE_REFRACTION"};function YA(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return qA[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var JA={[Gp]:"ENVMAP_BLENDING_MULTIPLY",[Hp]:"ENVMAP_BLENDING_MIX",[$p]:"ENVMAP_BLENDING_ADD"};function KA(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return JA[e.combine]||"ENVMAP_BLENDING_NONE"}function QA(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function eT(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=ZA(n),l=jA(n),u=YA(n),d=KA(n),h=QA(n),f=FA(n),m=zA(s),_=r.createProgram(),p,g,S=n.glslVersion?"#version "+n.glslVersion+`+`:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(Bo).join(``),p.length>0)p+=`-`;if(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ko).join(`+`;if(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(Bo).join(``),g.length>0)g+=`-`}else p=[Lm(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&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 "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`-`].filter(ko).join(`-`),g=[Lm(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",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?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Jn?"#define TONE_MAPPING":"",n.toneMapping!==Jn?Ze.tonemapping_pars_fragment:"",n.toneMapping!==Jn?LA("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ze.colorspace_pars_fragment,PA("linearToOutputTexel",n.outputColorSpace),NA(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`-`].filter(ko).join(`-`);if(o=wh(o),o=Cm(o,n),o=Pm(o,n),a=wh(a),a=Cm(a,n),a=Pm(a,n),o=Im(o),a=Im(a),n.isRawShaderMaterial!==!0)S=`#version 300 es+`}else p=[Dm(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&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 "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`+`].filter(Bo).join(`+`),g=[Dm(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",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?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Jn?"#define TONE_MAPPING":"",n.toneMapping!==Jn?Ze.tonemapping_pars_fragment:"",n.toneMapping!==Jn?OA("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ze.colorspace_pars_fragment,NA("linearToOutputTexel",n.outputColorSpace),UA(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`+`].filter(Bo).join(`+`);if(o=Ah(o),o=Im(o,n),o=Lm(o,n),a=Ah(a),a=Im(a,n),a=Lm(a,n),o=Nm(o),a=Nm(a),n.isRawShaderMaterial!==!0)S=`#version 300 es`,p=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(``)+`-`+p,g=["#define varying in",n.glslVersion===Xu?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Xu?"":"#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(`+`+p,g=["#define varying in",n.glslVersion===qu?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===qu?"":"#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(``)+`-`+g;let T=S+p+o,y=S+g+a,w=Am(r,r.VERTEX_SHADER,T),A=Am(r,r.FRAGMENT_SHADER,y);if(r.attachShader(_,w),r.attachShader(_,A),n.index0AttributeName!==void 0)r.bindAttribLocation(_,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(_,0,"position");r.linkProgram(_);function R(C){if(e.debug.checkShaderErrors){let L=r.getProgramInfoLog(_)||"",K=r.getShaderInfoLog(w)||"",I=r.getShaderInfoLog(A)||"",G=L.trim(),X=K.trim(),P=I.trim(),j=!0,k=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(j=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,_,w,A);else{let q=Rm(r,w,"vertex"),Q=Rm(r,A,"fragment");ke("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`+`+g;let T=S+p+o,y=S+g+a,w=Rm(r,r.VERTEX_SHADER,T),A=Rm(r,r.FRAGMENT_SHADER,y);if(r.attachShader(_,w),r.attachShader(_,A),n.index0AttributeName!==void 0)r.bindAttribLocation(_,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(_,0,"position");r.linkProgram(_);function R(C){if(e.debug.checkShaderErrors){let L=r.getProgramInfoLog(_)||"",K=r.getShaderInfoLog(w)||"",I=r.getShaderInfoLog(A)||"",G=L.trim(),X=K.trim(),P=I.trim(),j=!0,k=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(j=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,_,w,A);else{let q=Pm(r,w,"vertex"),Q=Pm(r,A,"fragment");ke("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`Material Name: `+C.name+`Material Type: `+C.type+`Program Info Log: `+G+``+q+`-`+Q)}else if(G!=="")Le("WebGLProgram: Program Info Log:",G);else if(X===""||P==="")k=!1;if(k)C.diagnostics={runnable:j,programLog:G,vertexShader:{log:X,prefix:p},fragmentShader:{log:P,prefix:g}}}r.deleteShader(w),r.deleteShader(A),x=new Bo(r,_),M=UA(r,_)}let x;this.getUniforms=function(){if(x===void 0)R(this);return x};let M;this.getAttributes=function(){if(M===void 0)R(this);return M};let z=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(z===!1)z=r.getProgramParameter(_,AA);return z},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=TA++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=w,this.fragmentShader=A,this}var KA=0;class Zm{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new Xm(e),t.set(e,n);return n}}class Xm{constructor(e){this.id=KA++,this.code=e,this.usedTimes=0}}function QA(e){return e===kr||e===rc||e===sc}function eT(e,t,n,i,r,s){let o=new uc,a=new Zm,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:d,precision:h}=i,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",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 m(x){if(c.add(x),x===0)return"uv";return`uv${x}`}function _(x,M,z,C,L,K){let I=C.fog,G=L.geometry,X=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,P=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,j=t.get(x.envMap||X,P),k=!!j&&j.mapping===yo?j.image.height:null,q=f[x.type];if(x.precision!==null){if(h=i.getMaxPrecision(x.precision),h!==x.precision)Le("WebGLProgram.getParameters:",x.precision,"not supported, using",h,"instead.")}let Q=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Me=Q!==void 0?Q.length:0,ue=0;if(G.morphAttributes.position!==void 0)ue=1;if(G.morphAttributes.normal!==void 0)ue=2;if(G.morphAttributes.color!==void 0)ue=3;let Be,we,Z,re;if(q){let bt=xi[q];Be=bt.vertexShader,we=bt.fragmentShader}else{Be=x.vertexShader,we=x.fragmentShader;let bt=a.getVertexShaderStage(x),lt=a.getFragmentShaderStage(x);a.update(x,bt,lt),Z=bt.id,re=lt.id}let se=e.getRenderTarget(),xe=e.state.buffers.depth.getReversed(),Ee=L.isInstancedMesh===!0,Ae=L.isBatchedMesh===!0,Et=!!x.map,Ge=!!x.matcap,Ye=!!j,ht=!!x.aoMap,nt=!!x.lightMap,Jt=!!x.bumpMap&&x.wireframe===!1,At=!!x.normalMap,gn=!!x.displacementMap,kt=!!x.emissiveMap,Bt=!!x.metalnessMap,D=!!x.roughnessMap,_n=x.anisotropy>0,ct=x.clearcoat>0,Pt=x.dispersion>0,E=x.retroreflectivity>0,v=x.iridescence>0,N=x.sheen>0,H=x.transmission>0,ie=_n&&!!x.anisotropyMap,ae=ct&&!!x.clearcoatMap,he=ct&&!!x.clearcoatNormalMap,Y=ct&&!!x.clearcoatRoughnessMap,te=v&&!!x.iridescenceMap,_e=v&&!!x.iridescenceThicknessMap,Ie=N&&!!x.sheenColorMap,de=N&&!!x.sheenRoughnessMap,oe=!!x.specularMap,De=!!x.specularColorMap,Fe=!!x.specularIntensityMap,st=H&&!!x.transmissionMap,F=H&&!!x.thicknessMap,ce=!!x.gradientMap,ee=!!x.alphaMap,le=x.alphaTest>0,ye=!!x.alphaHash,ne=!!x.extensions,pe=Jn;if(x.toneMapped){if(se===null||se.isXRRenderTarget===!0)pe=e.toneMapping}let He={shaderID:q,shaderType:x.type,shaderName:x.name,vertexShader:Be,fragmentShader:we,defines:x.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:h,batching:Ae,batchingColor:Ae&&L._colorsTexture!==null,instancing:Ee,instancingColor:Ee&&L.instanceColor!==null,instancingMorph:Ee&&L.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:je.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Et,matcap:Ge,envMap:Ye,envMapMode:Ye&&j.mapping,envMapCubeUVHeight:k,aoMap:ht,lightMap:nt,bumpMap:Jt,normalMap:At,displacementMap:gn,emissiveMap:kt,normalMapObjectSpace:At&&x.normalMapType===Yp,normalMapTangentSpace:At&&x.normalMapType===Wu,packedNormalMap:At&&x.normalMapType===Wu&&QA(x.normalMap.format),metalnessMap:Bt,roughnessMap:D,anisotropy:_n,anisotropyMap:ie,clearcoat:ct,clearcoatMap:ae,clearcoatNormalMap:he,clearcoatRoughnessMap:Y,dispersion:Pt,retroreflection:E,iridescence:v,iridescenceMap:te,iridescenceThicknessMap:_e,sheen:N,sheenColorMap:Ie,sheenRoughnessMap:de,specularMap:oe,specularColorMap:De,specularIntensityMap:Fe,transmission:H,transmissionMap:st,thicknessMap:F,gradientMap:ce,opaque:x.transparent===!1&&x.blending===_o&&x.alphaToCoverage===!1,alphaMap:ee,alphaTest:le,alphaHash:ye,combine:x.combine,mapUv:Et&&m(x.map.channel),aoMapUv:ht&&m(x.aoMap.channel),lightMapUv:nt&&m(x.lightMap.channel),bumpMapUv:Jt&&m(x.bumpMap.channel),normalMapUv:At&&m(x.normalMap.channel),displacementMapUv:gn&&m(x.displacementMap.channel),emissiveMapUv:kt&&m(x.emissiveMap.channel),metalnessMapUv:Bt&&m(x.metalnessMap.channel),roughnessMapUv:D&&m(x.roughnessMap.channel),anisotropyMapUv:ie&&m(x.anisotropyMap.channel),clearcoatMapUv:ae&&m(x.clearcoatMap.channel),clearcoatNormalMapUv:he&&m(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Y&&m(x.clearcoatRoughnessMap.channel),iridescenceMapUv:te&&m(x.iridescenceMap.channel),iridescenceThicknessMapUv:_e&&m(x.iridescenceThicknessMap.channel),sheenColorMapUv:Ie&&m(x.sheenColorMap.channel),sheenRoughnessMapUv:de&&m(x.sheenRoughnessMap.channel),specularMapUv:oe&&m(x.specularMap.channel),specularColorMapUv:De&&m(x.specularColorMap.channel),specularIntensityMapUv:Fe&&m(x.specularIntensityMap.channel),transmissionMapUv:st&&m(x.transmissionMap.channel),thicknessMapUv:F&&m(x.thicknessMap.channel),alphaMapUv:ee&&m(x.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(At||_n),vertexNormals:!!G.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!G.attributes.uv&&(Et||ee),fog:!!I,useFog:x.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||G.attributes.normal===void 0&&At===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:L.isSkinnedMesh===!0,hasPositionAttribute:G.attributes.position!==void 0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:ue,numSunLights:M.sun.length,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numSunLightShadows:M.sunShadowMap.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numLightProbeGrids:K.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:e.shadowMap.enabled&&z.length>0,shadowMapType:e.shadowMap.type,toneMapping:pe,decodeVideoTexture:Et&&x.map.isVideoTexture===!0&&je.getTransfer(x.map.colorSpace)===yt,decodeVideoTextureEmissive:kt&&x.emissiveMap.isVideoTexture===!0&&je.getTransfer(x.emissiveMap.colorSpace)===yt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===kn,flipSided:x.side===sn,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ne&&x.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&x.extensions.multiDraw===!0||Ae)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return He.vertexUv1s=c.has(1),He.vertexUv2s=c.has(2),He.vertexUv3s=c.has(3),c.clear(),He}function p(x){let M=[];if(x.shaderID)M.push(x.shaderID);else M.push(x.customVertexShaderID),M.push(x.customFragmentShaderID);if(x.defines!==void 0)for(let z in x.defines)M.push(z),M.push(x.defines[z]);if(x.isRawShaderMaterial===!1)g(M,x),S(M,x),M.push(e.outputColorSpace);return M.push(x.customProgramCacheKey),M.join()}function g(x,M){x.push(M.precision),x.push(M.outputColorSpace),x.push(M.envMapMode),x.push(M.envMapCubeUVHeight),x.push(M.mapUv),x.push(M.alphaMapUv),x.push(M.lightMapUv),x.push(M.aoMapUv),x.push(M.bumpMapUv),x.push(M.normalMapUv),x.push(M.displacementMapUv),x.push(M.emissiveMapUv),x.push(M.metalnessMapUv),x.push(M.roughnessMapUv),x.push(M.anisotropyMapUv),x.push(M.clearcoatMapUv),x.push(M.clearcoatNormalMapUv),x.push(M.clearcoatRoughnessMapUv),x.push(M.iridescenceMapUv),x.push(M.iridescenceThicknessMapUv),x.push(M.sheenColorMapUv),x.push(M.sheenRoughnessMapUv),x.push(M.specularMapUv),x.push(M.specularColorMapUv),x.push(M.specularIntensityMapUv),x.push(M.transmissionMapUv),x.push(M.thicknessMapUv),x.push(M.combine),x.push(M.fogExp2),x.push(M.sizeAttenuation),x.push(M.morphTargetsCount),x.push(M.morphAttributeCount),x.push(M.numSunLights),x.push(M.numDirLights),x.push(M.numPointLights),x.push(M.numSpotLights),x.push(M.numSpotLightMaps),x.push(M.numHemiLights),x.push(M.numRectAreaLights),x.push(M.numSunLightShadows),x.push(M.numDirLightShadows),x.push(M.numPointLightShadows),x.push(M.numSpotLightShadows),x.push(M.numSpotLightShadowsWithMaps),x.push(M.numLightProbes),x.push(M.shadowMapType),x.push(M.toneMapping),x.push(M.numClippingPlanes),x.push(M.numClipIntersection),x.push(M.depthPacking)}function S(x,M){if(o.disableAll(),M.instancing)o.enable(0);if(M.instancingColor)o.enable(1);if(M.instancingMorph)o.enable(2);if(M.matcap)o.enable(3);if(M.envMap)o.enable(4);if(M.normalMapObjectSpace)o.enable(5);if(M.normalMapTangentSpace)o.enable(6);if(M.clearcoat)o.enable(7);if(M.iridescence)o.enable(8);if(M.alphaTest)o.enable(9);if(M.vertexColors)o.enable(10);if(M.vertexAlphas)o.enable(11);if(M.vertexUv1s)o.enable(12);if(M.vertexUv2s)o.enable(13);if(M.vertexUv3s)o.enable(14);if(M.vertexTangents)o.enable(15);if(M.anisotropy)o.enable(16);if(M.alphaHash)o.enable(17);if(M.batching)o.enable(18);if(M.dispersion)o.enable(19);if(M.retroreflection)o.enable(24);if(M.batchingColor)o.enable(20);if(M.gradientMap)o.enable(21);if(M.packedNormalMap)o.enable(22);if(M.vertexNormals)o.enable(23);if(x.push(o.mask),o.disableAll(),M.fog)o.enable(0);if(M.useFog)o.enable(1);if(M.flatShading)o.enable(2);if(M.logarithmicDepthBuffer)o.enable(3);if(M.reversedDepthBuffer)o.enable(4);if(M.skinning)o.enable(5);if(M.morphTargets)o.enable(6);if(M.morphNormals)o.enable(7);if(M.morphColors)o.enable(8);if(M.premultipliedAlpha)o.enable(9);if(M.shadowMapEnabled)o.enable(10);if(M.doubleSided)o.enable(11);if(M.flipSided)o.enable(12);if(M.useDepthPacking)o.enable(13);if(M.dithering)o.enable(14);if(M.transmission)o.enable(15);if(M.sheen)o.enable(16);if(M.opaque)o.enable(17);if(M.pointsUvs)o.enable(18);if(M.decodeVideoTexture)o.enable(19);if(M.decodeVideoTextureEmissive)o.enable(20);if(M.alphaToCoverage)o.enable(21);if(M.numLightProbeGrids>0)o.enable(22);if(M.hasPositionAttribute)o.enable(23);x.push(o.mask)}function T(x){let M=f[x.type],z;if(M){let C=xi[M];z=cm.clone(C.uniforms)}else z=x.uniforms;return z}function y(x,M){let z=u.get(M);if(z!==void 0)++z.usedTimes;else z=new JA(e,M,x,r),l.push(z),u.set(M,z);return z}function w(x){if(--x.usedTimes===0){let M=l.indexOf(x);l[M]=l[l.length-1],l.pop(),u.delete(x.cacheKey),x.destroy()}}function A(x){a.remove(x)}function R(){a.dispose()}return{getParameters:_,getProgramCacheKey:p,getUniforms:T,acquireProgram:y,releaseProgram:w,releaseShaderCache:A,programs:l,dispose:R}}function tT(){let e=new WeakMap;function t(o){return e.has(o)}function n(o){let a=e.get(o);if(a===void 0)a={},e.set(o,a);return a}function i(o){e.delete(o)}function r(o,a,c){e.get(o)[a]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function nT(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function Nm(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function Dm(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(h){let f=0;if(h.isInstancedMesh)f+=2;if(h.isSkinnedMesh)f+=1;return f}function a(h,f,m,_,p,g){let S=e[t];if(S===void 0)S={id:h.id,object:h,geometry:f,material:m,materialVariant:o(h),groupOrder:_,renderOrder:h.renderOrder,z:p,group:g},e[t]=S;else S.id=h.id,S.object=h,S.geometry=f,S.material=m,S.materialVariant=o(h),S.groupOrder=_,S.renderOrder=h.renderOrder,S.z=p,S.group=g;return t++,S}function c(h,f,m,_,p,g,S){if(S.reversedDepth===!0)p=-p;let T=a(h,f,m,_,p,g);if(m.transmission>0)i.push(T);else if(m.transparent===!0)r.push(T);else n.push(T)}function l(h,f,m,_,p,g){let S=a(h,f,m,_,p,g);if(m.transmission>0)i.unshift(S);else if(m.transparent===!0)r.unshift(S);else n.unshift(S)}function u(h,f){if(n.length>1)n.sort(h||nT);if(i.length>1)i.sort(f||Nm);if(r.length>1)r.sort(f||Nm)}function d(){for(let h=t,f=e.length;h<f;h++){let m=e[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:d,sort:u}}function iT(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new Dm,e.set(i,[o]);else if(r>=s.length)o=new Dm,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function rT(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new U,color:new ze};break;case"SpotLight":n={position:new U,direction:new U,color:new ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new U,color:new ze,distance:0,decay:0};break;case"HemisphereLight":n={direction:new U,skyColor:new ze,groundColor:new ze};break;case"RectAreaLight":n={color:new ze,position:new U,halfWidth:new U,halfHeight:new U};break}return e[t.id]=n,n}}}function sT(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var oT=0;function aT(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function cT(e){let t=new rT,n=sT(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],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 l=0;l<9;l++)i.probe.push(new U);let r=new U,s=new $e,o=new $e;function a(l){let u=0,d=0,h=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let f=0,m=0,_=0,p=0,g=0,S=0,T=0,y=0,w=0,A=0,R=0,x=0,M=0,z=0;l.sort(aT);for(let L=0,K=l.length;L<K;L++){let I=l[L],{color:G,intensity:X,distance:P}=I,j=null;if(I.shadow&&I.shadow.map)if(I.shadow.map.texture.format===kr)j=I.shadow.map.texture;else j=I.shadow.map.depthTexture||I.shadow.map.texture;if(I.isAmbientLight)u+=G.r*X,d+=G.g*X,h+=G.b*X;else if(I.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(I.sh.coefficients[k],X);z++}else if(I.isSunLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let q=I.shadow,Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize.copy(q.mapSize).multiply(q.getFrameExtents()),i.sunShadow[m]=Q,i.sunShadowMap[m]=j;let Me=q.getViewportCount();for(let ue=0;ue<Me;ue++)i.sunShadowMatrix[_+ue]=q.getMatrix(ue),i.sunShadowCascade[_+ue]=q._cascadeData[ue];_+=Me,m++}i.sun[f]=k,f++}else if(I.isDirectionalLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let q=I.shadow,Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,i.directionalShadow[p]=Q,i.directionalShadowMap[p]=j,i.directionalShadowMatrix[p]=I.shadow.matrix,w++}i.directional[p]=k,p++}else if(I.isSpotLight){let k=t.get(I);k.position.setFromMatrixPosition(I.matrixWorld),k.color.copy(G).multiplyScalar(X),k.distance=P,k.coneCos=Math.cos(I.angle),k.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),k.decay=I.decay,i.spot[S]=k;let q=I.shadow;if(I.map){if(i.spotLightMap[x]=I.map,x++,q.updateMatrices(I),I.castShadow)M++}if(i.spotLightMatrix[S]=q.matrix,I.castShadow){let Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,i.spotShadow[S]=Q,i.spotShadowMap[S]=j,R++}S++}else if(I.isRectAreaLight){let k=t.get(I);k.color.copy(G).multiplyScalar(X),k.halfWidth.set(I.width*0.5,0,0),k.halfHeight.set(0,I.height*0.5,0),i.rectArea[T]=k,T++}else if(I.isPointLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),k.distance=I.distance,k.decay=I.decay,I.castShadow){let q=I.shadow,Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,Q.shadowCameraNear=q.camera.near,Q.shadowCameraFar=q.camera.far,i.pointShadow[g]=Q,i.pointShadowMap[g]=j,i.pointShadowMatrix[g]=I.shadow.matrix,A++}i.point[g]=k,g++}else if(I.isHemisphereLight){let k=t.get(I);k.skyColor.copy(I.color).multiplyScalar(X),k.groundColor.copy(I.groundColor).multiplyScalar(X),i.hemi[y]=k,y++}}if(T>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=fe.LTC_FLOAT_1,i.rectAreaLTC2=fe.LTC_FLOAT_2;else i.rectAreaLTC1=fe.LTC_HALF_1,i.rectAreaLTC2=fe.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;let C=i.hash;if(C.sunLength!==f||C.directionalLength!==p||C.pointLength!==g||C.spotLength!==S||C.rectAreaLength!==T||C.hemiLength!==y||C.numSunShadows!==m||C.numDirectionalShadows!==w||C.numPointShadows!==A||C.numSpotShadows!==R||C.numSpotMaps!==x||C.numLightProbes!==z)i.sun.length=f,i.directional.length=p,i.spot.length=S,i.rectArea.length=T,i.point.length=g,i.hemi.length=y,i.sunShadow.length=m,i.sunShadowMap.length=m,i.sunShadowMatrix.length=_,i.sunShadowCascade.length=_,i.directionalShadow.length=w,i.directionalShadowMap.length=w,i.directionalShadowMatrix.length=w,i.pointShadow.length=A,i.pointShadowMap.length=A,i.pointShadowMatrix.length=A,i.spotShadow.length=R,i.spotShadowMap.length=R,i.spotLightMatrix.length=R+x-M,i.spotLightMap.length=x,i.numSpotLightShadowsWithMaps=M,i.numLightProbes=z,C.sunLength=f,C.directionalLength=p,C.pointLength=g,C.spotLength=S,C.rectAreaLength=T,C.hemiLength=y,C.numSunShadows=m,C.numDirectionalShadows=w,C.numPointShadows=A,C.numSpotShadows=R,C.numSpotMaps=x,C.numLightProbes=z,i.version=oT++}function c(l,u){let d=0,h=0,f=0,m=0,_=0,p=0,g=u.matrixWorldInverse;for(let S=0,T=l.length;S<T;S++){let y=l[S];if(y.isSunLight){let w=i.sun[d];w.direction.setFromMatrixPosition(y.matrixWorld),w.direction.transformDirection(g),d++}else if(y.isDirectionalLight){let w=i.directional[h];w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),h++}else if(y.isSpotLight){let w=i.spot[m];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),m++}else if(y.isRectAreaLight){let w=i.rectArea[_];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),o.identity(),s.copy(y.matrixWorld),s.premultiply(g),o.extractRotation(s),w.halfWidth.set(y.width*0.5,0,0),w.halfHeight.set(0,y.height*0.5,0),w.halfWidth.applyMatrix4(o),w.halfHeight.applyMatrix4(o),_++}else if(y.isPointLight){let w=i.point[f];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),f++}else if(y.isHemisphereLight){let w=i.hemi[p];w.direction.setFromMatrixPosition(y.matrixWorld),w.direction.transformDirection(g),p++}}}return{setup:a,setupView:c,state:i}}function Om(e){let t=new cT(e),n=[],i=[],r=[];function s(h){d.camera=h,n.length=0,i.length=0,r.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function c(h){r.push(h)}function l(){t.setup(n)}function u(h){t.setupView(n,h)}let d={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:d,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function lT(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new Om(e),t.set(r,[a]);else if(s>=o.length)a=new Om(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var uT=`void main() {+`+Q)}else if(G!=="")Le("WebGLProgram: Program Info Log:",G);else if(X===""||P==="")k=!1;if(k)C.diagnostics={runnable:j,programLog:G,vertexShader:{log:X,prefix:p},fragmentShader:{log:P,prefix:g}}}r.deleteShader(w),r.deleteShader(A),x=new Vo(r,_),M=kA(r,_)}let x;this.getUniforms=function(){if(x===void 0)R(this);return x};let M;this.getAttributes=function(){if(M===void 0)R(this);return M};let z=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(z===!1)z=r.getProgramParameter(_,CA);return z},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=PA++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=w,this.fragmentShader=A,this}var tT=0;class jm{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new qm(e),t.set(e,n);return n}}class qm{constructor(e){this.id=tT++,this.code=e,this.usedTimes=0}}function nT(e){return e===kr||e===oc||e===ac}function iT(e,t,n,i,r,s){let o=new dc,a=new jm,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:d,precision:h}=i,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",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 m(x){if(c.add(x),x===0)return"uv";return`uv${x}`}function _(x,M,z,C,L,K){let I=C.fog,G=L.geometry,X=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,P=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,j=t.get(x.envMap||X,P),k=!!j&&j.mapping===vo?j.image.height:null,q=f[x.type];if(x.precision!==null){if(h=i.getMaxPrecision(x.precision),h!==x.precision)Le("WebGLProgram.getParameters:",x.precision,"not supported, using",h,"instead.")}let Q=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Me=Q!==void 0?Q.length:0,ue=0;if(G.morphAttributes.position!==void 0)ue=1;if(G.morphAttributes.normal!==void 0)ue=2;if(G.morphAttributes.color!==void 0)ue=3;let Be,we,Z,re;if(q){let bt=xi[q];Be=bt.vertexShader,we=bt.fragmentShader}else{Be=x.vertexShader,we=x.fragmentShader;let bt=a.getVertexShaderStage(x),lt=a.getFragmentShaderStage(x);a.update(x,bt,lt),Z=bt.id,re=lt.id}let se=e.getRenderTarget(),xe=e.state.buffers.depth.getReversed(),Ee=L.isInstancedMesh===!0,Ae=L.isBatchedMesh===!0,Et=!!x.map,Ge=!!x.matcap,Ye=!!j,ht=!!x.aoMap,tt=!!x.lightMap,Jt=!!x.bumpMap&&x.wireframe===!1,At=!!x.normalMap,mn=!!x.displacementMap,kt=!!x.emissiveMap,Bt=!!x.metalnessMap,D=!!x.roughnessMap,gn=x.anisotropy>0,ct=x.clearcoat>0,Pt=x.dispersion>0,E=x.retroreflectivity>0,v=x.iridescence>0,N=x.sheen>0,H=x.transmission>0,ie=gn&&!!x.anisotropyMap,ae=ct&&!!x.clearcoatMap,he=ct&&!!x.clearcoatNormalMap,Y=ct&&!!x.clearcoatRoughnessMap,te=v&&!!x.iridescenceMap,_e=v&&!!x.iridescenceThicknessMap,Ie=N&&!!x.sheenColorMap,de=N&&!!x.sheenRoughnessMap,oe=!!x.specularMap,De=!!x.specularColorMap,Fe=!!x.specularIntensityMap,st=H&&!!x.transmissionMap,F=H&&!!x.thicknessMap,ce=!!x.gradientMap,ee=!!x.alphaMap,le=x.alphaTest>0,ye=!!x.alphaHash,ne=!!x.extensions,pe=Jn;if(x.toneMapped){if(se===null||se.isXRRenderTarget===!0)pe=e.toneMapping}let He={shaderID:q,shaderType:x.type,shaderName:x.name,vertexShader:Be,fragmentShader:we,defines:x.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:h,batching:Ae,batchingColor:Ae&&L._colorsTexture!==null,instancing:Ee,instancingColor:Ee&&L.instanceColor!==null,instancingMorph:Ee&&L.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:je.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Et,matcap:Ge,envMap:Ye,envMapMode:Ye&&j.mapping,envMapCubeUVHeight:k,aoMap:ht,lightMap:tt,bumpMap:Jt,normalMap:At,displacementMap:mn,emissiveMap:kt,normalMapObjectSpace:At&&x.normalMapType===Kp,normalMapTangentSpace:At&&x.normalMapType===Xu,packedNormalMap:At&&x.normalMapType===Xu&&nT(x.normalMap.format),metalnessMap:Bt,roughnessMap:D,anisotropy:gn,anisotropyMap:ie,clearcoat:ct,clearcoatMap:ae,clearcoatNormalMap:he,clearcoatRoughnessMap:Y,dispersion:Pt,retroreflection:E,iridescence:v,iridescenceMap:te,iridescenceThicknessMap:_e,sheen:N,sheenColorMap:Ie,sheenRoughnessMap:de,specularMap:oe,specularColorMap:De,specularIntensityMap:Fe,transmission:H,transmissionMap:st,thicknessMap:F,gradientMap:ce,opaque:x.transparent===!1&&x.blending===xo&&x.alphaToCoverage===!1,alphaMap:ee,alphaTest:le,alphaHash:ye,combine:x.combine,mapUv:Et&&m(x.map.channel),aoMapUv:ht&&m(x.aoMap.channel),lightMapUv:tt&&m(x.lightMap.channel),bumpMapUv:Jt&&m(x.bumpMap.channel),normalMapUv:At&&m(x.normalMap.channel),displacementMapUv:mn&&m(x.displacementMap.channel),emissiveMapUv:kt&&m(x.emissiveMap.channel),metalnessMapUv:Bt&&m(x.metalnessMap.channel),roughnessMapUv:D&&m(x.roughnessMap.channel),anisotropyMapUv:ie&&m(x.anisotropyMap.channel),clearcoatMapUv:ae&&m(x.clearcoatMap.channel),clearcoatNormalMapUv:he&&m(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Y&&m(x.clearcoatRoughnessMap.channel),iridescenceMapUv:te&&m(x.iridescenceMap.channel),iridescenceThicknessMapUv:_e&&m(x.iridescenceThicknessMap.channel),sheenColorMapUv:Ie&&m(x.sheenColorMap.channel),sheenRoughnessMapUv:de&&m(x.sheenRoughnessMap.channel),specularMapUv:oe&&m(x.specularMap.channel),specularColorMapUv:De&&m(x.specularColorMap.channel),specularIntensityMapUv:Fe&&m(x.specularIntensityMap.channel),transmissionMapUv:st&&m(x.transmissionMap.channel),thicknessMapUv:F&&m(x.thicknessMap.channel),alphaMapUv:ee&&m(x.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(At||gn),vertexNormals:!!G.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!G.attributes.uv&&(Et||ee),fog:!!I,useFog:x.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||G.attributes.normal===void 0&&At===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:L.isSkinnedMesh===!0,hasPositionAttribute:G.attributes.position!==void 0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:ue,numSunLights:M.sun.length,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numSunLightShadows:M.sunShadowMap.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numLightProbeGrids:K.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:e.shadowMap.enabled&&z.length>0,shadowMapType:e.shadowMap.type,toneMapping:pe,decodeVideoTexture:Et&&x.map.isVideoTexture===!0&&je.getTransfer(x.map.colorSpace)===yt,decodeVideoTextureEmissive:kt&&x.emissiveMap.isVideoTexture===!0&&je.getTransfer(x.emissiveMap.colorSpace)===yt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===kn,flipSided:x.side===rn,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ne&&x.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&x.extensions.multiDraw===!0||Ae)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return He.vertexUv1s=c.has(1),He.vertexUv2s=c.has(2),He.vertexUv3s=c.has(3),c.clear(),He}function p(x){let M=[];if(x.shaderID)M.push(x.shaderID);else M.push(x.customVertexShaderID),M.push(x.customFragmentShaderID);if(x.defines!==void 0)for(let z in x.defines)M.push(z),M.push(x.defines[z]);if(x.isRawShaderMaterial===!1)g(M,x),S(M,x),M.push(e.outputColorSpace);return M.push(x.customProgramCacheKey),M.join()}function g(x,M){x.push(M.precision),x.push(M.outputColorSpace),x.push(M.envMapMode),x.push(M.envMapCubeUVHeight),x.push(M.mapUv),x.push(M.alphaMapUv),x.push(M.lightMapUv),x.push(M.aoMapUv),x.push(M.bumpMapUv),x.push(M.normalMapUv),x.push(M.displacementMapUv),x.push(M.emissiveMapUv),x.push(M.metalnessMapUv),x.push(M.roughnessMapUv),x.push(M.anisotropyMapUv),x.push(M.clearcoatMapUv),x.push(M.clearcoatNormalMapUv),x.push(M.clearcoatRoughnessMapUv),x.push(M.iridescenceMapUv),x.push(M.iridescenceThicknessMapUv),x.push(M.sheenColorMapUv),x.push(M.sheenRoughnessMapUv),x.push(M.specularMapUv),x.push(M.specularColorMapUv),x.push(M.specularIntensityMapUv),x.push(M.transmissionMapUv),x.push(M.thicknessMapUv),x.push(M.combine),x.push(M.fogExp2),x.push(M.sizeAttenuation),x.push(M.morphTargetsCount),x.push(M.morphAttributeCount),x.push(M.numSunLights),x.push(M.numDirLights),x.push(M.numPointLights),x.push(M.numSpotLights),x.push(M.numSpotLightMaps),x.push(M.numHemiLights),x.push(M.numRectAreaLights),x.push(M.numSunLightShadows),x.push(M.numDirLightShadows),x.push(M.numPointLightShadows),x.push(M.numSpotLightShadows),x.push(M.numSpotLightShadowsWithMaps),x.push(M.numLightProbes),x.push(M.shadowMapType),x.push(M.toneMapping),x.push(M.numClippingPlanes),x.push(M.numClipIntersection),x.push(M.depthPacking)}function S(x,M){if(o.disableAll(),M.instancing)o.enable(0);if(M.instancingColor)o.enable(1);if(M.instancingMorph)o.enable(2);if(M.matcap)o.enable(3);if(M.envMap)o.enable(4);if(M.normalMapObjectSpace)o.enable(5);if(M.normalMapTangentSpace)o.enable(6);if(M.clearcoat)o.enable(7);if(M.iridescence)o.enable(8);if(M.alphaTest)o.enable(9);if(M.vertexColors)o.enable(10);if(M.vertexAlphas)o.enable(11);if(M.vertexUv1s)o.enable(12);if(M.vertexUv2s)o.enable(13);if(M.vertexUv3s)o.enable(14);if(M.vertexTangents)o.enable(15);if(M.anisotropy)o.enable(16);if(M.alphaHash)o.enable(17);if(M.batching)o.enable(18);if(M.dispersion)o.enable(19);if(M.retroreflection)o.enable(24);if(M.batchingColor)o.enable(20);if(M.gradientMap)o.enable(21);if(M.packedNormalMap)o.enable(22);if(M.vertexNormals)o.enable(23);if(x.push(o.mask),o.disableAll(),M.fog)o.enable(0);if(M.useFog)o.enable(1);if(M.flatShading)o.enable(2);if(M.logarithmicDepthBuffer)o.enable(3);if(M.reversedDepthBuffer)o.enable(4);if(M.skinning)o.enable(5);if(M.morphTargets)o.enable(6);if(M.morphNormals)o.enable(7);if(M.morphColors)o.enable(8);if(M.premultipliedAlpha)o.enable(9);if(M.shadowMapEnabled)o.enable(10);if(M.doubleSided)o.enable(11);if(M.flipSided)o.enable(12);if(M.useDepthPacking)o.enable(13);if(M.dithering)o.enable(14);if(M.transmission)o.enable(15);if(M.sheen)o.enable(16);if(M.opaque)o.enable(17);if(M.pointsUvs)o.enable(18);if(M.decodeVideoTexture)o.enable(19);if(M.decodeVideoTextureEmissive)o.enable(20);if(M.alphaToCoverage)o.enable(21);if(M.numLightProbeGrids>0)o.enable(22);if(M.hasPositionAttribute)o.enable(23);x.push(o.mask)}function T(x){let M=f[x.type],z;if(M){let C=xi[M];z=um.clone(C.uniforms)}else z=x.uniforms;return z}function y(x,M){let z=u.get(M);if(z!==void 0)++z.usedTimes;else z=new eT(e,M,x,r),l.push(z),u.set(M,z);return z}function w(x){if(--x.usedTimes===0){let M=l.indexOf(x);l[M]=l[l.length-1],l.pop(),u.delete(x.cacheKey),x.destroy()}}function A(x){a.remove(x)}function R(){a.dispose()}return{getParameters:_,getProgramCacheKey:p,getUniforms:T,acquireProgram:y,releaseProgram:w,releaseShaderCache:A,programs:l,dispose:R}}function rT(){let e=new WeakMap;function t(o){return e.has(o)}function n(o){let a=e.get(o);if(a===void 0)a={},e.set(o,a);return a}function i(o){e.delete(o)}function r(o,a,c){e.get(o)[a]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function sT(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function Om(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function Um(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(h){let f=0;if(h.isInstancedMesh)f+=2;if(h.isSkinnedMesh)f+=1;return f}function a(h,f,m,_,p,g){let S=e[t];if(S===void 0)S={id:h.id,object:h,geometry:f,material:m,materialVariant:o(h),groupOrder:_,renderOrder:h.renderOrder,z:p,group:g},e[t]=S;else S.id=h.id,S.object=h,S.geometry=f,S.material=m,S.materialVariant=o(h),S.groupOrder=_,S.renderOrder=h.renderOrder,S.z=p,S.group=g;return t++,S}function c(h,f,m,_,p,g,S){if(S.reversedDepth===!0)p=-p;let T=a(h,f,m,_,p,g);if(m.transmission>0)i.push(T);else if(m.transparent===!0)r.push(T);else n.push(T)}function l(h,f,m,_,p,g){let S=a(h,f,m,_,p,g);if(m.transmission>0)i.unshift(S);else if(m.transparent===!0)r.unshift(S);else n.unshift(S)}function u(h,f){if(n.length>1)n.sort(h||sT);if(i.length>1)i.sort(f||Om);if(r.length>1)r.sort(f||Om)}function d(){for(let h=t,f=e.length;h<f;h++){let m=e[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:d,sort:u}}function oT(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new Um,e.set(i,[o]);else if(r>=s.length)o=new Um,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function aT(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new U,color:new ze};break;case"SpotLight":n={position:new U,direction:new U,color:new ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new U,color:new ze,distance:0,decay:0};break;case"HemisphereLight":n={direction:new U,skyColor:new ze,groundColor:new ze};break;case"RectAreaLight":n={color:new ze,position:new U,halfWidth:new U,halfHeight:new U};break}return e[t.id]=n,n}}}function cT(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var lT=0;function uT(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function hT(e){let t=new aT,n=cT(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],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 l=0;l<9;l++)i.probe.push(new U);let r=new U,s=new $e,o=new $e;function a(l){let u=0,d=0,h=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let f=0,m=0,_=0,p=0,g=0,S=0,T=0,y=0,w=0,A=0,R=0,x=0,M=0,z=0;l.sort(uT);for(let L=0,K=l.length;L<K;L++){let I=l[L],{color:G,intensity:X,distance:P}=I,j=null;if(I.shadow&&I.shadow.map)if(I.shadow.map.texture.format===kr)j=I.shadow.map.texture;else j=I.shadow.map.depthTexture||I.shadow.map.texture;if(I.isAmbientLight)u+=G.r*X,d+=G.g*X,h+=G.b*X;else if(I.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(I.sh.coefficients[k],X);z++}else if(I.isSunLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let q=I.shadow,Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize.copy(q.mapSize).multiply(q.getFrameExtents()),i.sunShadow[m]=Q,i.sunShadowMap[m]=j;let Me=q.getViewportCount();for(let ue=0;ue<Me;ue++)i.sunShadowMatrix[_+ue]=q.getMatrix(ue),i.sunShadowCascade[_+ue]=q._cascadeData[ue];_+=Me,m++}i.sun[f]=k,f++}else if(I.isDirectionalLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let q=I.shadow,Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,i.directionalShadow[p]=Q,i.directionalShadowMap[p]=j,i.directionalShadowMatrix[p]=I.shadow.matrix,w++}i.directional[p]=k,p++}else if(I.isSpotLight){let k=t.get(I);k.position.setFromMatrixPosition(I.matrixWorld),k.color.copy(G).multiplyScalar(X),k.distance=P,k.coneCos=Math.cos(I.angle),k.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),k.decay=I.decay,i.spot[S]=k;let q=I.shadow;if(I.map){if(i.spotLightMap[x]=I.map,x++,q.updateMatrices(I),I.castShadow)M++}if(i.spotLightMatrix[S]=q.matrix,I.castShadow){let Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,i.spotShadow[S]=Q,i.spotShadowMap[S]=j,R++}S++}else if(I.isRectAreaLight){let k=t.get(I);k.color.copy(G).multiplyScalar(X),k.halfWidth.set(I.width*0.5,0,0),k.halfHeight.set(0,I.height*0.5,0),i.rectArea[T]=k,T++}else if(I.isPointLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),k.distance=I.distance,k.decay=I.decay,I.castShadow){let q=I.shadow,Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,Q.shadowCameraNear=q.camera.near,Q.shadowCameraFar=q.camera.far,i.pointShadow[g]=Q,i.pointShadowMap[g]=j,i.pointShadowMatrix[g]=I.shadow.matrix,A++}i.point[g]=k,g++}else if(I.isHemisphereLight){let k=t.get(I);k.skyColor.copy(I.color).multiplyScalar(X),k.groundColor.copy(I.groundColor).multiplyScalar(X),i.hemi[y]=k,y++}}if(T>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=fe.LTC_FLOAT_1,i.rectAreaLTC2=fe.LTC_FLOAT_2;else i.rectAreaLTC1=fe.LTC_HALF_1,i.rectAreaLTC2=fe.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;let C=i.hash;if(C.sunLength!==f||C.directionalLength!==p||C.pointLength!==g||C.spotLength!==S||C.rectAreaLength!==T||C.hemiLength!==y||C.numSunShadows!==m||C.numDirectionalShadows!==w||C.numPointShadows!==A||C.numSpotShadows!==R||C.numSpotMaps!==x||C.numLightProbes!==z)i.sun.length=f,i.directional.length=p,i.spot.length=S,i.rectArea.length=T,i.point.length=g,i.hemi.length=y,i.sunShadow.length=m,i.sunShadowMap.length=m,i.sunShadowMatrix.length=_,i.sunShadowCascade.length=_,i.directionalShadow.length=w,i.directionalShadowMap.length=w,i.directionalShadowMatrix.length=w,i.pointShadow.length=A,i.pointShadowMap.length=A,i.pointShadowMatrix.length=A,i.spotShadow.length=R,i.spotShadowMap.length=R,i.spotLightMatrix.length=R+x-M,i.spotLightMap.length=x,i.numSpotLightShadowsWithMaps=M,i.numLightProbes=z,C.sunLength=f,C.directionalLength=p,C.pointLength=g,C.spotLength=S,C.rectAreaLength=T,C.hemiLength=y,C.numSunShadows=m,C.numDirectionalShadows=w,C.numPointShadows=A,C.numSpotShadows=R,C.numSpotMaps=x,C.numLightProbes=z,i.version=lT++}function c(l,u){let d=0,h=0,f=0,m=0,_=0,p=0,g=u.matrixWorldInverse;for(let S=0,T=l.length;S<T;S++){let y=l[S];if(y.isSunLight){let w=i.sun[d];w.direction.setFromMatrixPosition(y.matrixWorld),w.direction.transformDirection(g),d++}else if(y.isDirectionalLight){let w=i.directional[h];w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),h++}else if(y.isSpotLight){let w=i.spot[m];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),m++}else if(y.isRectAreaLight){let w=i.rectArea[_];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),o.identity(),s.copy(y.matrixWorld),s.premultiply(g),o.extractRotation(s),w.halfWidth.set(y.width*0.5,0,0),w.halfHeight.set(0,y.height*0.5,0),w.halfWidth.applyMatrix4(o),w.halfHeight.applyMatrix4(o),_++}else if(y.isPointLight){let w=i.point[f];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),f++}else if(y.isHemisphereLight){let w=i.hemi[p];w.direction.setFromMatrixPosition(y.matrixWorld),w.direction.transformDirection(g),p++}}}return{setup:a,setupView:c,state:i}}function Fm(e){let t=new hT(e),n=[],i=[],r=[];function s(h){d.camera=h,n.length=0,i.length=0,r.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function c(h){r.push(h)}function l(){t.setup(n)}function u(h){t.setupView(n,h)}let d={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:d,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function dT(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new Fm(e),t.set(r,[a]);else if(s>=o.length)a=new Fm(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var fT=`void main() {gl_Position = vec4( position, 1.0 );-}`,hT=`uniform sampler2D shadow_pass;+}`,pT=`uniform sampler2D shadow_pass;uniform vec2 resolution;uniform float radius;void main() {@@ -4317,12 +4317,12 @@ void main() {squared_mean = squared_mean / samples;float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );-}`,dT=[new U(1,0,0),new U(-1,0,0),new U(0,1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1)],fT=[new U(0,-1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1),new U(0,-1,0),new U(0,-1,0)],Um=new $e,zo=new U,Sh=new U;function pT(e,t,n){let i=new Co,r=new Ue,s=new Ue,o=new ft,a=new nh,c=new ih,l={},u=n.maxTextureSize,d={[ur]:sn,[sn]:ur,[kn]:kn},h=new Bn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ue},radius:{value:4}},vertexShader:uT,fragmentShader:hT}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let m=new on;m.setAttribute("position",new jt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let _=new Mt(m,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=go;let g=this.type;this.render=function(A,R,x){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(A.length===0)return;if(this.type===dp)Le("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=go;let M=e.getRenderTarget(),z=e.getActiveCubeFace(),C=e.getActiveMipmapLevel(),L=e.state;if(L.setBlending(di),L.buffers.depth.getReversed()===!0)L.buffers.color.setClear(0,0,0,0);else L.buffers.color.setClear(1,1,1,1);L.buffers.depth.setTest(!0),L.setScissorTest(!1);let K=g!==this.type;if(K)R.traverse(function(I){if(I.material)if(Array.isArray(I.material))I.material.forEach((G)=>G.needsUpdate=!0);else I.material.needsUpdate=!0});for(let I=0,G=A.length;I<G;I++){let X=A[I],P=X.shadow;if(P===void 0){Le("WebGLShadowMap:",X,"has no shadow.");continue}if(P.autoUpdate===!1&&P.needsUpdate===!1)continue;r.copy(P.mapSize);let j=P.getFrameExtents();if(r.multiply(j),s.copy(P.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/j.x),r.x=s.x*j.x,P.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/j.y),r.y=s.y*j.y,P.mapSize.y=s.y}let k=e.state.buffers.depth.getReversed();if(P.camera._reversedDepth=k,P.map===null||K===!0){if(P.map!==null){if(P.map.depthTexture!==null)P.map.depthTexture.dispose(),P.map.depthTexture=null;P.map.dispose()}if(this.type===Ms){if(X.isPointLight){Le("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}P.map=new wn(r.x,r.y,{format:kr,type:pi,minFilter:qt,magFilter:qt,generateMipmaps:!1}),P.map.texture.name=X.name+".shadowMap",P.map.depthTexture=new Vr(r.x,r.y,Gi),P.map.depthTexture.name=X.name+".shadowMapDepth",P.map.depthTexture.format=Fr,P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=Kn,P.map.depthTexture.magFilter=Kn}else{if(X.isPointLight)P.map=new Eh(r.x),P.map.depthTexture=new Qu(r.x,hr);else P.map=new wn(r.x,r.y),P.map.depthTexture=new Vr(r.x,r.y,hr);if(P.map.depthTexture.name=X.name+".shadowMap",P.map.depthTexture.format=Fr,this.type===go)P.map.depthTexture.compareFunction=k?cc:ac,P.map.depthTexture.minFilter=qt,P.map.depthTexture.magFilter=qt;else P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=Kn,P.map.depthTexture.magFilter=Kn}P.camera.updateProjectionMatrix()}if(P.map.isWebGLCubeRenderTarget!==!0&&(P.map.width!==r.x||P.map.height!==r.y))P.map.setSize(r.x,r.y);let q=P.map.isWebGLCubeRenderTarget?6:P.getViewportCount();if(X.isPointLight!==!0)P.updateMatrices(X,x);for(let Q=0;Q<q;Q++){let Me=P.getCamera(Q);if(X.isPointLight){let{camera:ue,matrix:Be}=P,we=X.distance||ue.far;if(we!==ue.far)ue.far=we,ue.updateProjectionMatrix();zo.setFromMatrixPosition(X.matrixWorld),ue.position.copy(zo),Sh.copy(ue.position),Sh.add(dT[Q]),ue.up.copy(fT[Q]),ue.lookAt(Sh),ue.updateMatrixWorld(),Be.makeTranslation(-zo.x,-zo.y,-zo.z),Um.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),P._frustum.setFromProjectionMatrix(Um,ue.coordinateSystem,ue.reversedDepth)}if(P.map.isWebGLCubeRenderTarget)e.setRenderTarget(P.map,Q),e.clear();else{if(Q===0)e.setRenderTarget(P.map),e.clear();let ue=P.getViewport(Q);o.set(s.x*ue.x,s.y*ue.y,s.x*ue.z,s.y*ue.w),L.viewport(o)}i=P.getFrustum(Q),y(R,x,Me,X,this.type)}if(P.isPointLightShadow!==!0&&this.type===Ms)S(P,x);P.needsUpdate=!1}g=this.type,p.needsUpdate=!1,e.setRenderTarget(M,z,C)};function S(A,R){let x=t.update(_);if(h.defines.VSM_SAMPLES!==A.blurSamples)h.defines.VSM_SAMPLES=A.blurSamples,f.defines.VSM_SAMPLES=A.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0;if(A.mapPass===null)A.mapPass=new wn(r.x,r.y,{format:kr,type:pi});else if(A.mapPass.width!==A.map.width||A.mapPass.height!==A.map.height)A.mapPass.setSize(A.map.width,A.map.height);h.uniforms.shadow_pass.value=A.map.depthTexture,h.uniforms.resolution.value.set(A.map.width,A.map.height),h.uniforms.radius.value=A.radius,e.setRenderTarget(A.mapPass),e.clear(),e.renderBufferDirect(R,null,x,h,_,null),f.uniforms.shadow_pass.value=A.mapPass.texture,f.uniforms.resolution.value.set(A.map.width,A.map.height),f.uniforms.radius.value=A.radius,e.setRenderTarget(A.map),e.clear(),e.renderBufferDirect(R,null,x,f,_,null)}function T(A,R,x,M){let z=null,C=x.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(C!==void 0)z=C;else if(z=x.isPointLight===!0?c:a,e.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){let L=z.uuid,K=R.uuid,I=l[L];if(I===void 0)I={},l[L]=I;let G=I[K];if(G===void 0)G=z.clone(),I[K]=G,R.addEventListener("dispose",w);z=G}if(z.visible=R.visible,z.wireframe=R.wireframe,M===Ms)z.side=R.shadowSide!==null?R.shadowSide:R.side;else z.side=R.shadowSide!==null?R.shadowSide:d[R.side];if(z.alphaMap=R.alphaMap,z.alphaTest=R.alphaToCoverage===!0?0.5:R.alphaTest,z.map=R.map,z.clipShadows=R.clipShadows,z.clippingPlanes=R.clippingPlanes,z.clipIntersection=R.clipIntersection,z.displacementMap=R.displacementMap,z.displacementScale=R.displacementScale,z.displacementBias=R.displacementBias,z.wireframeLinewidth=R.wireframeLinewidth,z.linewidth=R.linewidth,x.isPointLight===!0&&z.isMeshDistanceMaterial===!0){let L=e.properties.get(z);L.light=x}return z}function y(A,R,x,M,z){if(A.visible===!1)return;if(A.layers.test(R.layers)&&(A.isMesh||A.isLine||A.isPoints)){if((A.castShadow||A.receiveShadow&&z===Ms)&&(!A.frustumCulled||A.intersectsFrustum(i))){A.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,A.matrixWorld);let K=t.update(A),I=A.material;if(Array.isArray(I)){let G=K.groups;for(let X=0,P=G.length;X<P;X++){let j=G[X],k=I[j.materialIndex];if(k&&k.visible){let q=T(A,k,M,z);A.onBeforeShadow(e,A,R,x,K,q,j),e.renderBufferDirect(x,null,K,q,A,j),A.onAfterShadow(e,A,R,x,K,q,j)}}}else if(I.visible){let G=T(A,I,M,z);A.onBeforeShadow(e,A,R,x,K,G,null),e.renderBufferDirect(x,null,K,G,A,null),A.onAfterShadow(e,A,R,x,K,G,null)}}}let L=A.children;for(let K=0,I=L.length;K<I;K++)y(L[K],R,x,M,z)}function w(A){A.target.removeEventListener("dispose",w);for(let x in l){let M=l[x],z=A.target.uuid;if(z in M)M[z].dispose(),delete M[z]}}}function mT(e,t){function n(){let F=!1,ce=new ft,ee=null,le=new ft(0,0,0,0);return{setMask:function(ye){if(ee!==ye&&!F)e.colorMask(ye,ye,ye,ye),ee=ye},setLocked:function(ye){F=ye},setClear:function(ye,ne,pe,He,bt){if(bt===!0)ye*=He,ne*=He,pe*=He;if(ce.set(ye,ne,pe,He),le.equals(ce)===!1)e.clearColor(ye,ne,pe,He),le.copy(ce)},reset:function(){F=!1,ee=null,le.set(-1,0,0,0)}}}function i(){let F=!1,ce=!1,ee=null,le=null,ye=null;return{setReversed:function(ne){if(ce!==ne){let pe=t.get("EXT_clip_control");if(ne)pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.ZERO_TO_ONE_EXT);else pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.NEGATIVE_ONE_TO_ONE_EXT);ce=ne;let He=ye;ye=null,this.setClear(He)}},getReversed:function(){return ce},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else xe(e.DEPTH_TEST)},setMask:function(ne){if(ee!==ne&&!F)e.depthMask(ne),ee=ne},setFunc:function(ne){if(ce)ne=om[ne];if(le!==ne){switch(ne){case Np:e.depthFunc(e.NEVER);break;case Dp:e.depthFunc(e.ALWAYS);break;case Op:e.depthFunc(e.LESS);break;case eu:e.depthFunc(e.LEQUAL);break;case Up:e.depthFunc(e.EQUAL);break;case Fp:e.depthFunc(e.GEQUAL);break;case zp:e.depthFunc(e.GREATER);break;case kp:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}le=ne}},setLocked:function(ne){F=ne},setClear:function(ne){if(ye!==ne){if(ye=ne,ce)ne=1-ne;e.clearDepth(ne)}},reset:function(){F=!1,ee=null,le=null,ye=null,ce=!1}}}function r(){let F=!1,ce=null,ee=null,le=null,ye=null,ne=null,pe=null,He=null,bt=null;return{setTest:function(lt){if(!F)if(lt)se(e.STENCIL_TEST);else xe(e.STENCIL_TEST)},setMask:function(lt){if(ce!==lt&&!F)e.stencilMask(lt),ce=lt},setFunc:function(lt,oi,Di){if(ee!==lt||le!==oi||ye!==Di)e.stencilFunc(lt,oi,Di),ee=lt,le=oi,ye=Di},setOp:function(lt,oi,Di){if(ne!==lt||pe!==oi||He!==Di)e.stencilOp(lt,oi,Di),ne=lt,pe=oi,He=Di},setLocked:function(lt){F=lt},setClear:function(lt){if(bt!==lt)e.clearStencil(lt),bt=lt},reset:function(){F=!1,ce=null,ee=null,le=null,ye=null,ne=null,pe=null,He=null,bt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},d={},h={},f=new WeakMap,m=[],_=null,p=!1,g=null,S=null,T=null,y=null,w=null,A=null,R=null,x=new ze(0,0,0),M=0,z=!1,C=null,L=null,K=null,I=null,G=null,X=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),P=!1,j=0,k=e.getParameter(e.VERSION);if(k.indexOf("WebGL")!==-1)j=parseFloat(/^WebGL (\d)/.exec(k)[1]),P=j>=1;else if(k.indexOf("OpenGL ES")!==-1)j=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),P=j>=2;let q=null,Q={},Me=e.getParameter(e.SCISSOR_BOX),ue=e.getParameter(e.VIEWPORT),Be=new ft().fromArray(Me),we=new ft().fromArray(ue);function Z(F,ce,ee,le){let ye=new Uint8Array(4),ne=e.createTexture();e.bindTexture(F,ne),e.texParameteri(F,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(F,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let pe=0;pe<ee;pe++)if(F===e.TEXTURE_3D||F===e.TEXTURE_2D_ARRAY)e.texImage3D(ce,0,e.RGBA,1,1,le,0,e.RGBA,e.UNSIGNED_BYTE,ye);else e.texImage2D(ce+pe,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,ye);return ne}let re={};re[e.TEXTURE_2D]=Z(e.TEXTURE_2D,e.TEXTURE_2D,1),re[e.TEXTURE_CUBE_MAP]=Z(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[e.TEXTURE_2D_ARRAY]=Z(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),re[e.TEXTURE_3D]=Z(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),se(e.DEPTH_TEST),o.setFunc(eu),Jt(!1),At(Yl),se(e.CULL_FACE),ht(di);function se(F){if(u[F]!==!0)e.enable(F),u[F]=!0}function xe(F){if(u[F]!==!1)e.disable(F),u[F]=!1}function Ee(F,ce){if(h[F]!==ce){if(e.bindFramebuffer(F,ce),h[F]=ce,F===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=ce;if(F===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=ce;return!0}return!1}function Ae(F,ce){let ee=m,le=!1;if(F){if(ee=f.get(ce),ee===void 0)ee=[],f.set(ce,ee);let ye=F.textures;if(ee.length!==ye.length||ee[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,pe=ye.length;ne<pe;ne++)ee[ne]=e.COLOR_ATTACHMENT0+ne;ee.length=ye.length,le=!0}}else if(ee[0]!==e.BACK)ee[0]=e.BACK,le=!0;if(le)e.drawBuffers(ee)}function Et(F){if(_!==F)return e.useProgram(F),_=F,!0;return!1}let Ge={[ws]:e.FUNC_ADD,[pp]:e.FUNC_SUBTRACT,[mp]:e.FUNC_REVERSE_SUBTRACT};Ge[gp]=e.MIN,Ge[_p]=e.MAX;let Ye={[xp]:e.ZERO,[yp]:e.ONE,[vp]:e.SRC_COLOR,[Sp]:e.SRC_ALPHA,[Rp]:e.SRC_ALPHA_SATURATE,[Ap]:e.DST_COLOR,[wp]:e.DST_ALPHA,[bp]:e.ONE_MINUS_SRC_COLOR,[Mp]:e.ONE_MINUS_SRC_ALPHA,[Tp]:e.ONE_MINUS_DST_COLOR,[Ep]:e.ONE_MINUS_DST_ALPHA,[Cp]:e.CONSTANT_COLOR,[Pp]:e.ONE_MINUS_CONSTANT_COLOR,[Ip]:e.CONSTANT_ALPHA,[Lp]:e.ONE_MINUS_CONSTANT_ALPHA};function ht(F,ce,ee,le,ye,ne,pe,He,bt,lt){if(F===di){if(p===!0)xe(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(F!==fp){if(F!==g||lt!==z){if(S!==ws||w!==ws)e.blendEquation(e.FUNC_ADD),S=ws,w=ws;if(lt)switch(F){case _o:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Jl:e.blendFunc(e.ONE,e.ONE);break;case Kl:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case Ql:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:ke("WebGLState: Invalid blending: ",F);break}else switch(F){case _o:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Jl:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case Kl:ke("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Ql:ke("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ke("WebGLState: Invalid blending: ",F);break}T=null,y=null,A=null,R=null,x.set(0,0,0),M=0,g=F,z=lt}return}if(ye=ye||ce,ne=ne||ee,pe=pe||le,ce!==S||ye!==w)e.blendEquationSeparate(Ge[ce],Ge[ye]),S=ce,w=ye;if(ee!==T||le!==y||ne!==A||pe!==R)e.blendFuncSeparate(Ye[ee],Ye[le],Ye[ne],Ye[pe]),T=ee,y=le,A=ne,R=pe;if(He.equals(x)===!1||bt!==M)e.blendColor(He.r,He.g,He.b,bt),x.copy(He),M=bt;g=F,z=!1}function nt(F,ce){F.side===kn?xe(e.CULL_FACE):se(e.CULL_FACE);let ee=F.side===sn;if(ce)ee=!ee;Jt(ee),F.blending===_o&&F.transparent===!1?ht(di):ht(F.blending,F.blendEquation,F.blendSrc,F.blendDst,F.blendEquationAlpha,F.blendSrcAlpha,F.blendDstAlpha,F.blendColor,F.blendAlpha,F.premultipliedAlpha),o.setFunc(F.depthFunc),o.setTest(F.depthTest),o.setMask(F.depthWrite),s.setMask(F.colorWrite);let le=F.stencilWrite;if(a.setTest(le),le)a.setMask(F.stencilWriteMask),a.setFunc(F.stencilFunc,F.stencilRef,F.stencilFuncMask),a.setOp(F.stencilFail,F.stencilZFail,F.stencilZPass);kt(F.polygonOffset,F.polygonOffsetFactor,F.polygonOffsetUnits),F.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):xe(e.SAMPLE_ALPHA_TO_COVERAGE)}function Jt(F){if(C!==F){if(F)e.frontFace(e.CW);else e.frontFace(e.CCW);C=F}}function At(F){if(F!==up){if(se(e.CULL_FACE),F!==L)if(F===Yl)e.cullFace(e.BACK);else if(F===hp)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else xe(e.CULL_FACE);L=F}function gn(F){if(F!==K){if(P)e.lineWidth(F);K=F}}function kt(F,ce,ee){if(F){if(se(e.POLYGON_OFFSET_FILL),I!==ce||G!==ee){if(I=ce,G=ee,o.getReversed())ce=-ce;e.polygonOffset(ce,ee)}}else xe(e.POLYGON_OFFSET_FILL)}function Bt(F){if(F)se(e.SCISSOR_TEST);else xe(e.SCISSOR_TEST)}function D(F){if(F===void 0)F=e.TEXTURE0+X-1;if(q!==F)e.activeTexture(F),q=F}function _n(F,ce,ee){if(ee===void 0)if(q===null)ee=e.TEXTURE0+X-1;else ee=q;let le=Q[ee];if(le===void 0)le={type:void 0,texture:void 0},Q[ee]=le;if(le.type!==F||le.texture!==ce){if(q!==ee)e.activeTexture(ee),q=ee;e.bindTexture(F,ce||re[F]),le.type=F,le.texture=ce}}function ct(){let F=Q[q];if(F!==void 0&&F.type!==void 0)e.bindTexture(F.type,null),F.type=void 0,F.texture=void 0}function Pt(){try{e.compressedTexImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function E(){try{e.compressedTexImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function v(){try{e.texSubImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function N(){try{e.texSubImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function H(){try{e.compressedTexSubImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function ae(){try{e.texStorage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function he(){try{e.texStorage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function Y(){try{e.texImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function te(){try{e.texImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function _e(F){if(d[F]!==void 0)return d[F];else return e.getParameter(F)}function Ie(F,ce){if(d[F]!==ce)e.pixelStorei(F,ce),d[F]=ce}function de(F){if(Be.equals(F)===!1)e.scissor(F.x,F.y,F.z,F.w),Be.copy(F)}function oe(F){if(we.equals(F)===!1)e.viewport(F.x,F.y,F.z,F.w),we.copy(F)}function De(F,ce){let ee=l.get(ce);if(ee===void 0)ee=new WeakMap,l.set(ce,ee);let le=ee.get(F);if(le===void 0)le=e.getUniformBlockIndex(ce,F.name),ee.set(F,le)}function Fe(F,ce){let le=l.get(ce).get(F);if(c.get(ce)!==le)e.uniformBlockBinding(ce,le,F.__bindingPointIndex),c.set(ce,le)}function st(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},d={},q=null,Q={},h={},f=new WeakMap,m=[],_=null,p=!1,g=null,S=null,T=null,y=null,w=null,A=null,R=null,x=new ze(0,0,0),M=0,z=!1,C=null,L=null,K=null,I=null,G=null,Be.set(0,0,e.canvas.width,e.canvas.height),we.set(0,0,e.canvas.width,e.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:se,disable:xe,bindFramebuffer:Ee,drawBuffers:Ae,useProgram:Et,setBlending:ht,setMaterial:nt,setFlipSided:Jt,setCullFace:At,setLineWidth:gn,setPolygonOffset:kt,setScissorTest:Bt,activeTexture:D,bindTexture:_n,unbindTexture:ct,compressedTexImage2D:Pt,compressedTexImage3D:E,texImage2D:Y,texImage3D:te,pixelStorei:Ie,getParameter:_e,updateUBOMapping:De,uniformBlockBinding:Fe,texStorage2D:ae,texStorage3D:he,texSubImage2D:v,texSubImage3D:N,compressedTexSubImage2D:H,compressedTexSubImage3D:ie,scissor:de,viewport:oe,reset:st}}function gT(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ue,u=new WeakMap,d=new Set,h,f=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(E){}function _(E,v){return m?new OffscreenCanvas(E,v):vs("canvas")}function p(E,v,N){let H=1,ie=Pt(E);if(ie.width>N||ie.height>N)H=N/Math.max(ie.width,ie.height);if(H<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){let ae=Math.floor(H*ie.width),he=Math.floor(H*ie.height);if(h===void 0)h=_(ae,he);let Y=v?_(ae,he):h;return Y.width=ae,Y.height=he,Y.getContext("2d").drawImage(E,0,0,ae,he),Le("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+he+")."),Y}else{if("data"in E)Le("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return E}return E}function g(E){return E.generateMipmaps}function S(E){e.generateMipmap(E)}function T(E){if(E.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(E.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function y(E,v,N,H,ie,ae=!1){if(E!==null){if(e[E]!==void 0)return e[E];Le("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let he;if(H){if(he=t.get("EXT_texture_norm16"),!he)Le("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let Y=v;if(v===e.RED){if(N===e.FLOAT)Y=e.R32F;if(N===e.HALF_FLOAT)Y=e.R16F;if(N===e.UNSIGNED_BYTE)Y=e.R8;if(N===e.UNSIGNED_SHORT&&he)Y=he.R16_EXT;if(N===e.SHORT&&he)Y=he.R16_SNORM_EXT}if(v===e.RED_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.R8UI;if(N===e.UNSIGNED_SHORT)Y=e.R16UI;if(N===e.UNSIGNED_INT)Y=e.R32UI;if(N===e.BYTE)Y=e.R8I;if(N===e.SHORT)Y=e.R16I;if(N===e.INT)Y=e.R32I}if(v===e.RG){if(N===e.FLOAT)Y=e.RG32F;if(N===e.HALF_FLOAT)Y=e.RG16F;if(N===e.UNSIGNED_BYTE)Y=e.RG8;if(N===e.UNSIGNED_SHORT&&he)Y=he.RG16_EXT;if(N===e.SHORT&&he)Y=he.RG16_SNORM_EXT}if(v===e.RG_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RG8UI;if(N===e.UNSIGNED_SHORT)Y=e.RG16UI;if(N===e.UNSIGNED_INT)Y=e.RG32UI;if(N===e.BYTE)Y=e.RG8I;if(N===e.SHORT)Y=e.RG16I;if(N===e.INT)Y=e.RG32I}if(v===e.RGB_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RGB8UI;if(N===e.UNSIGNED_SHORT)Y=e.RGB16UI;if(N===e.UNSIGNED_INT)Y=e.RGB32UI;if(N===e.BYTE)Y=e.RGB8I;if(N===e.SHORT)Y=e.RGB16I;if(N===e.INT)Y=e.RGB32I}if(v===e.RGBA_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RGBA8UI;if(N===e.UNSIGNED_SHORT)Y=e.RGBA16UI;if(N===e.UNSIGNED_INT)Y=e.RGBA32UI;if(N===e.BYTE)Y=e.RGBA8I;if(N===e.SHORT)Y=e.RGBA16I;if(N===e.INT)Y=e.RGBA32I}if(v===e.RGB){if(N===e.UNSIGNED_SHORT&&he)Y=he.RGB16_EXT;if(N===e.SHORT&&he)Y=he.RGB16_SNORM_EXT;if(N===e.UNSIGNED_INT_5_9_9_9_REV)Y=e.RGB9_E5;if(N===e.UNSIGNED_INT_10F_11F_11F_REV)Y=e.R11F_G11F_B10F}if(v===e.RGBA){let te=ae?Zu:je.getTransfer(ie);if(N===e.FLOAT)Y=e.RGBA32F;if(N===e.HALF_FLOAT)Y=e.RGBA16F;if(N===e.UNSIGNED_BYTE)Y=te===yt?e.SRGB8_ALPHA8:e.RGBA8;if(N===e.UNSIGNED_SHORT&&he)Y=he.RGBA16_EXT;if(N===e.SHORT&&he)Y=he.RGBA16_SNORM_EXT;if(N===e.UNSIGNED_SHORT_4_4_4_4)Y=e.RGBA4;if(N===e.UNSIGNED_SHORT_5_5_5_1)Y=e.RGB5_A1}if(Y===e.R16F||Y===e.R32F||Y===e.RG16F||Y===e.RG32F||Y===e.RGBA16F||Y===e.RGBA32F)t.get("EXT_color_buffer_float");return Y}function w(E,v){let N;if(E){if(v===null||v===hr||v===Cs)N=e.DEPTH24_STENCIL8;else if(v===Gi)N=e.DEPTH32F_STENCIL8;else if(v===vo)N=e.DEPTH24_STENCIL8,Le("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(v===null||v===hr||v===Cs)N=e.DEPTH_COMPONENT24;else if(v===Gi)N=e.DEPTH_COMPONENT32F;else if(v===vo)N=e.DEPTH_COMPONENT16;return N}function A(E,v){if(g(E)===!0||E.isFramebufferTexture&&E.minFilter!==Kn&&E.minFilter!==qt)return Math.log2(Math.max(v.width,v.height))+1;else if(E.mipmaps!==void 0&&E.mipmaps.length>0)return E.mipmaps.length;else if(E.isCompressedTexture&&Array.isArray(E.image))return v.mipmaps.length;else return 1}function R(E){let v=E.target;if(v.removeEventListener("dispose",R),M(v),v.isVideoTexture)u.delete(v);if(v.isHTMLTexture)d.delete(v)}function x(E){let v=E.target;v.removeEventListener("dispose",x),C(v)}function M(E){let v=i.get(E);if(v.__webglInit===void 0)return;let N=E.source,H=f.get(N);if(H){let ie=H[v.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)z(E);if(Object.keys(H).length===0)f.delete(N)}i.remove(E)}function z(E){let v=i.get(E);e.deleteTexture(v.__webglTexture);let N=E.source,H=f.get(N);delete H[v.__cacheKey],o.memory.textures--}function C(E){let v=i.get(E);if(E.depthTexture)E.depthTexture.dispose(),i.remove(E.depthTexture);if(E.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(v.__webglFramebuffer[H]))for(let ie=0;ie<v.__webglFramebuffer[H].length;ie++)e.deleteFramebuffer(v.__webglFramebuffer[H][ie]);else e.deleteFramebuffer(v.__webglFramebuffer[H]);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer[H])}else{if(Array.isArray(v.__webglFramebuffer))for(let H=0;H<v.__webglFramebuffer.length;H++)e.deleteFramebuffer(v.__webglFramebuffer[H]);else e.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer);if(v.__webglMultisampledFramebuffer)e.deleteFramebuffer(v.__webglMultisampledFramebuffer);if(v.__webglColorRenderbuffer){for(let H=0;H<v.__webglColorRenderbuffer.length;H++)if(v.__webglColorRenderbuffer[H])e.deleteRenderbuffer(v.__webglColorRenderbuffer[H])}if(v.__webglDepthRenderbuffer)e.deleteRenderbuffer(v.__webglDepthRenderbuffer)}let N=E.textures;for(let H=0,ie=N.length;H<ie;H++){let ae=i.get(N[H]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(N[H])}i.remove(E)}let L=0;function K(){L=0}function I(){return L}function G(E){L=E}function X(){let E=L;if(E>=r.maxTextures)Le("WebGLTextures: Trying to use "+(E+1)+" texture units while this GPU supports only "+r.maxTextures);return L+=1,E}function P(E){let v=[];return v.push(E.wrapS),v.push(E.wrapT),v.push(E.wrapR||0),v.push(E.magFilter),v.push(E.minFilter),v.push(E.anisotropy),v.push(E.internalFormat),v.push(E.format),v.push(E.type),v.push(E.generateMipmaps),v.push(E.premultiplyAlpha),v.push(E.flipY),v.push(E.unpackAlignment),v.push(E.colorSpace),v.join()}function j(E,v){let N=i.get(E);if(E.isVideoTexture)_n(E);if(E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&N.__version!==E.version){let H=E.image;if(H===null)Le("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Le("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(N,E,v);return}}else if(E.isExternalTexture)N.__webglTexture=E.sourceTexture?E.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,N.__webglTexture,e.TEXTURE0+v)}function k(E,v){let N=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){xe(N,E,v);return}else if(E.isExternalTexture)N.__webglTexture=E.sourceTexture?E.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,N.__webglTexture,e.TEXTURE0+v)}function q(E,v){let N=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){xe(N,E,v);return}n.bindTexture(e.TEXTURE_3D,N.__webglTexture,e.TEXTURE0+v)}function Q(E,v){let N=i.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&N.__version!==E.version){Ee(N,E,v);return}n.bindTexture(e.TEXTURE_CUBE_MAP,N.__webglTexture,e.TEXTURE0+v)}let Me={[As]:e.REPEAT,[Ts]:e.CLAMP_TO_EDGE,[Ka]:e.MIRRORED_REPEAT},ue={[Kn]:e.NEAREST,[Qa]:e.NEAREST_MIPMAP_NEAREST,[Ur]:e.NEAREST_MIPMAP_LINEAR,[qt]:e.LINEAR,[Rs]:e.LINEAR_MIPMAP_NEAREST,[fi]:e.LINEAR_MIPMAP_LINEAR},Be={[Jp]:e.NEVER,[nm]:e.ALWAYS,[Kp]:e.LESS,[ac]:e.LEQUAL,[Qp]:e.EQUAL,[cc]:e.GEQUAL,[em]:e.GREATER,[tm]:e.NOTEQUAL};function we(E,v){if(v.type===Gi&&t.has("OES_texture_float_linear")===!1&&(v.magFilter===qt||v.magFilter===Rs||v.magFilter===Ur||v.magFilter===fi||v.minFilter===qt||v.minFilter===Rs||v.minFilter===Ur||v.minFilter===fi))Le("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(E,e.TEXTURE_WRAP_S,Me[v.wrapS]),e.texParameteri(E,e.TEXTURE_WRAP_T,Me[v.wrapT]),E===e.TEXTURE_3D||E===e.TEXTURE_2D_ARRAY)e.texParameteri(E,e.TEXTURE_WRAP_R,Me[v.wrapR]);if(e.texParameteri(E,e.TEXTURE_MAG_FILTER,ue[v.magFilter]),e.texParameteri(E,e.TEXTURE_MIN_FILTER,ue[v.minFilter]),v.compareFunction)e.texParameteri(E,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(E,e.TEXTURE_COMPARE_FUNC,Be[v.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Kn)return;if(v.minFilter!==Ur&&v.minFilter!==fi)return;if(v.type===Gi&&t.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){let N=t.get("EXT_texture_filter_anisotropic");e.texParameterf(E,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function Z(E,v){let N=!1;if(E.__webglInit===void 0)E.__webglInit=!0,v.addEventListener("dispose",R);let H=v.source,ie=f.get(H);if(ie===void 0)ie={},f.set(H,ie);let ae=P(v);if(ae!==E.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,N=!0;ie[ae].usedTimes++;let he=ie[E.__cacheKey];if(he!==void 0){if(ie[E.__cacheKey].usedTimes--,he.usedTimes===0)z(v)}E.__cacheKey=ae,E.__webglTexture=ie[ae].texture}return N}function re(E,v,N){return Math.floor(Math.floor(E/N)/v)}function se(E,v,N,H){let ae=E.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,v.width,v.height,N,H,v.data);else{ae.sort((Ie,de)=>Ie.start-de.start);let he=0;for(let Ie=1;Ie<ae.length;Ie++){let de=ae[he],oe=ae[Ie],De=de.start+de.count,Fe=re(oe.start,v.width,4),st=re(de.start,v.width,4);if(oe.start<=De+1&&Fe===st&&re(oe.start+oe.count-1,v.width,4)===Fe)de.count=Math.max(de.count,oe.start+oe.count-de.start);else++he,ae[he]=oe}ae.length=he+1;let Y=n.getParameter(e.UNPACK_ROW_LENGTH),te=n.getParameter(e.UNPACK_SKIP_PIXELS),_e=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,v.width);for(let Ie=0,de=ae.length;Ie<de;Ie++){let oe=ae[Ie],De=Math.floor(oe.start/4),Fe=Math.ceil(oe.count/4),st=De%v.width,F=Math.floor(De/v.width),ce=Fe,ee=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,st),n.pixelStorei(e.UNPACK_SKIP_ROWS,F),n.texSubImage2D(e.TEXTURE_2D,0,st,F,ce,1,N,H,v.data)}E.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,Y),n.pixelStorei(e.UNPACK_SKIP_PIXELS,te),n.pixelStorei(e.UNPACK_SKIP_ROWS,_e)}}function xe(E,v,N){let H=e.TEXTURE_2D;if(v.isDataArrayTexture||v.isCompressedArrayTexture)H=e.TEXTURE_2D_ARRAY;if(v.isData3DTexture)H=e.TEXTURE_3D;let ie=Z(E,v),ae=v.source;n.bindTexture(H,E.__webglTexture,e.TEXTURE0+N);let he=i.get(ae);if(ae.version!==he.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+N),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){let ee=je.getPrimaries(je.workingColorSpace),le=v.colorSpace===Br?null:je.getPrimaries(v.colorSpace),ye=v.colorSpace===Br||ee===le?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,ye)}n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment);let te=p(v.image,!1,r.maxTextureSize);te=ct(v,te);let _e=s.convert(v.format,v.colorSpace),Ie=s.convert(v.type),de=y(v.internalFormat,_e,Ie,v.normalized,v.colorSpace,v.isVideoTexture);we(H,v);let oe,De=v.mipmaps,Fe=v.isVideoTexture!==!0,st=he.__version===void 0||ie===!0,F=ae.dataReady,ce=A(v,te);if(v.isDepthTexture){if(de=w(v.format===zr,v.type),st)if(Fe)n.texStorage2D(e.TEXTURE_2D,1,de,te.width,te.height);else n.texImage2D(e.TEXTURE_2D,0,de,te.width,te.height,0,_e,Ie,null)}else if(v.isDataTexture)if(De.length>0){if(Fe&&st)n.texStorage2D(e.TEXTURE_2D,ce,de,De[0].width,De[0].height);for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],Fe){if(F)n.texSubImage2D(e.TEXTURE_2D,ee,0,0,oe.width,oe.height,_e,Ie,oe.data)}else n.texImage2D(e.TEXTURE_2D,ee,de,oe.width,oe.height,0,_e,Ie,oe.data);v.generateMipmaps=!1}else if(Fe){if(st)n.texStorage2D(e.TEXTURE_2D,ce,de,te.width,te.height);if(F)se(v,te,_e,Ie)}else n.texImage2D(e.TEXTURE_2D,0,de,te.width,te.height,0,_e,Ie,te.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){if(Fe&&st)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,de,De[0].width,De[0].height,te.depth);for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],v.format!==mi)if(_e!==null)if(Fe){if(F)if(v.layerUpdates.size>0){let ye=gh(oe.width,oe.height,v.format,v.type);for(let ne of v.layerUpdates){let pe=oe.data.subarray(ne*ye/oe.data.BYTES_PER_ELEMENT,(ne+1)*ye/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ee,0,0,ne,oe.width,oe.height,1,_e,pe)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ee,0,0,0,oe.width,oe.height,te.depth,_e,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ee,de,oe.width,oe.height,te.depth,0,oe.data,0,0);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Fe){if(F)n.texSubImage3D(e.TEXTURE_2D_ARRAY,ee,0,0,0,oe.width,oe.height,te.depth,_e,Ie,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,ee,de,oe.width,oe.height,te.depth,0,_e,Ie,oe.data);if(v.layerUpdates.size>0)v.clearLayerUpdates()}else{if(Fe&&st)n.texStorage2D(e.TEXTURE_2D,ce,de,De[0].width,De[0].height);for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],v.format!==mi)if(_e!==null)if(Fe){if(F)n.compressedTexSubImage2D(e.TEXTURE_2D,ee,0,0,oe.width,oe.height,_e,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,ee,de,oe.width,oe.height,0,oe.data);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Fe){if(F)n.texSubImage2D(e.TEXTURE_2D,ee,0,0,oe.width,oe.height,_e,Ie,oe.data)}else n.texImage2D(e.TEXTURE_2D,ee,de,oe.width,oe.height,0,_e,Ie,oe.data)}else if(v.isDataArrayTexture)if(Fe){if(st)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,de,te.width,te.height,te.depth);if(F)if(v.layerUpdates.size>0){let ee=gh(te.width,te.height,v.format,v.type);for(let le of v.layerUpdates){let ye=te.data.subarray(le*ee/te.data.BYTES_PER_ELEMENT,(le+1)*ee/te.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,le,te.width,te.height,1,_e,Ie,ye)}v.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,te.width,te.height,te.depth,_e,Ie,te.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,de,te.width,te.height,te.depth,0,_e,Ie,te.data);else if(v.isData3DTexture)if(Fe){if(st)n.texStorage3D(e.TEXTURE_3D,ce,de,te.width,te.height,te.depth);if(F)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,te.width,te.height,te.depth,_e,Ie,te.data)}else n.texImage3D(e.TEXTURE_3D,0,de,te.width,te.height,te.depth,0,_e,Ie,te.data);else if(v.isFramebufferTexture){if(st)if(Fe)n.texStorage2D(e.TEXTURE_2D,ce,de,te.width,te.height);else{let ee=te.width,le=te.height;for(let ye=0;ye<ce;ye++)n.texImage2D(e.TEXTURE_2D,ye,de,ee,le,0,_e,Ie,null),ee>>=1,le>>=1}}else if(v.isHTMLTexture){if("texElementImage2D"in e){let ee=e.canvas;if(!ee.hasAttribute("layoutsubtree"))ee.setAttribute("layoutsubtree","true");if(te.parentNode!==ee){ee.appendChild(te),d.add(v),ee.onpaint=(le)=>{let ye=le.changedElements;for(let ne of d)if(ye.includes(ne.image))ne.needsUpdate=!0},ee.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,te);else{let{RGBA:ye,RGBA:ne,UNSIGNED_BYTE:pe}=e;e.texElementImage2D(e.TEXTURE_2D,0,ye,ne,pe,te)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(De.length>0){if(Fe&&st){let ee=Pt(De[0]);n.texStorage2D(e.TEXTURE_2D,ce,de,ee.width,ee.height)}for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],Fe){if(F)n.texSubImage2D(e.TEXTURE_2D,ee,0,0,_e,Ie,oe)}else n.texImage2D(e.TEXTURE_2D,ee,de,_e,Ie,oe);v.generateMipmaps=!1}else if(Fe){if(st){let ee=Pt(te);n.texStorage2D(e.TEXTURE_2D,ce,de,ee.width,ee.height)}if(F)n.texSubImage2D(e.TEXTURE_2D,0,0,0,_e,Ie,te)}else n.texImage2D(e.TEXTURE_2D,0,de,_e,Ie,te);if(g(v))S(H);if(he.__version=ae.version,v.onUpdate)v.onUpdate(v)}E.__version=v.version}function Ee(E,v,N){if(v.image.length!==6)return;let H=Z(E,v),ie=v.source;n.bindTexture(e.TEXTURE_CUBE_MAP,E.__webglTexture,e.TEXTURE0+N);let ae=i.get(ie);if(ie.version!==ae.__version||H===!0){n.activeTexture(e.TEXTURE0+N);let he=je.getPrimaries(je.workingColorSpace),Y=v.colorSpace===Br?null:je.getPrimaries(v.colorSpace),te=v.colorSpace===Br||he===Y?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,te);let _e=v.isCompressedTexture||v.image[0].isCompressedTexture,Ie=v.image[0]&&v.image[0].isDataTexture,de=[];for(let ne=0;ne<6;ne++){if(!_e&&!Ie)de[ne]=p(v.image[ne],!0,r.maxCubemapSize);else de[ne]=Ie?v.image[ne].image:v.image[ne];de[ne]=ct(v,de[ne])}let oe=de[0],De=s.convert(v.format,v.colorSpace),Fe=s.convert(v.type),st=y(v.internalFormat,De,Fe,v.normalized,v.colorSpace),F=v.isVideoTexture!==!0,ce=ae.__version===void 0||H===!0,ee=ie.dataReady,le=A(v,oe);we(e.TEXTURE_CUBE_MAP,v);let ye;if(_e){if(F&&ce)n.texStorage2D(e.TEXTURE_CUBE_MAP,le,st,oe.width,oe.height);for(let ne=0;ne<6;ne++){ye=de[ne].mipmaps;for(let pe=0;pe<ye.length;pe++){let He=ye[pe];if(v.format!==mi)if(De!==null)if(F){if(ee)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,He.width,He.height,De,He.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,st,He.width,He.height,0,He.data);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,He.width,He.height,De,Fe,He.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,st,He.width,He.height,0,De,Fe,He.data)}}}else{if(ye=v.mipmaps,F&&ce){if(ye.length>0)le++;let ne=Pt(de[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,le,st,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Ie){if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,de[ne].width,de[ne].height,De,Fe,de[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,st,de[ne].width,de[ne].height,0,De,Fe,de[ne].data);for(let pe=0;pe<ye.length;pe++){let bt=ye[pe].image[ne].image;if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,bt.width,bt.height,De,Fe,bt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,st,bt.width,bt.height,0,De,Fe,bt.data)}}else{if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,De,Fe,de[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,st,De,Fe,de[ne]);for(let pe=0;pe<ye.length;pe++){let He=ye[pe];if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,De,Fe,He.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,st,De,Fe,He.image[ne])}}}if(g(v))S(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,v.onUpdate)v.onUpdate(v)}E.__version=v.version}function Ae(E,v,N,H,ie,ae){let he=s.convert(N.format,N.colorSpace),Y=s.convert(N.type),te=y(N.internalFormat,he,Y,N.normalized,N.colorSpace),_e=i.get(v),Ie=i.get(N);if(Ie.__renderTarget=v,!_e.__hasExternalTextures){let de=Math.max(1,v.width>>ae),oe=Math.max(1,v.height>>ae);if(ie===e.TEXTURE_3D||ie===e.TEXTURE_2D_ARRAY)n.texImage3D(ie,ae,te,de,oe,v.depth,0,he,Y,null);else n.texImage2D(ie,ae,te,de,oe,0,he,Y,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,E),D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,H,ie,Ie.__webglTexture,0,Bt(v));else if(ie===e.TEXTURE_2D||ie>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,H,ie,Ie.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function Et(E,v,N){if(e.bindRenderbuffer(e.RENDERBUFFER,E),v.depthBuffer){let H=v.depthTexture,ie=H&&H.isDepthTexture?H.type:null,ae=w(v.stencilBuffer,ie),he=v.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(D(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Bt(v),ae,v.width,v.height);else if(N)e.renderbufferStorageMultisample(e.RENDERBUFFER,Bt(v),ae,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,v.width,v.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,E)}else{let H=v.textures;for(let ie=0;ie<H.length;ie++){let ae=H[ie],he=s.convert(ae.format,ae.colorSpace),Y=s.convert(ae.type),te=y(ae.internalFormat,he,Y,ae.normalized,ae.colorSpace);if(D(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Bt(v),te,v.width,v.height);else if(N)e.renderbufferStorageMultisample(e.RENDERBUFFER,Bt(v),te,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,te,v.width,v.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Ge(E,v,N){let H=v.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,E),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ie=i.get(v.depthTexture);if(ie.__renderTarget=v,!ie.__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0;if(H){if(ie.__webglInit===void 0)ie.__webglInit=!0,v.depthTexture.addEventListener("dispose",R);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),we(e.TEXTURE_CUBE_MAP,v.depthTexture);let _e=s.convert(v.depthTexture.format),Ie=s.convert(v.depthTexture.type),de;if(v.depthTexture.format===Fr)de=e.DEPTH_COMPONENT24;else if(v.depthTexture.format===zr)de=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,de,v.width,v.height,0,_e,Ie,null)}}else j(v.depthTexture,0);let ae=ie.__webglTexture,he=Bt(v),Y=H?e.TEXTURE_CUBE_MAP_POSITIVE_X+N:e.TEXTURE_2D,te=v.depthTexture.format===zr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(v.depthTexture.format===Fr)if(D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else if(v.depthTexture.format===zr)if(D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ye(E){let v=i.get(E),N=E.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==E.depthTexture){let H=E.depthTexture;if(v.__depthDisposeCallback)v.__depthDisposeCallback();if(H){let ie=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,H.removeEventListener("dispose",ie)};H.addEventListener("dispose",ie),v.__depthDisposeCallback=ie}v.__boundDepthTexture=H}if(E.depthTexture&&!v.__autoAllocateDepthBuffer)if(N)for(let H=0;H<6;H++)Ge(v.__webglFramebuffer[H],E,H);else{let H=E.texture.mipmaps;if(H&&H.length>0)Ge(v.__webglFramebuffer[0],E,0);else Ge(v.__webglFramebuffer,E,0)}else if(N){v.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[H]),v.__webglDepthbuffer[H]===void 0)v.__webglDepthbuffer[H]=e.createRenderbuffer(),Et(v.__webglDepthbuffer[H],E,!1);else{let ie=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer[H];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let H=E.texture.mipmaps;if(H&&H.length>0)n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer);if(v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=e.createRenderbuffer(),Et(v.__webglDepthbuffer,E,!1);else{let ie=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function ht(E,v,N){let H=i.get(E);if(v!==void 0)Ae(H.__webglFramebuffer,E,E.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(N!==void 0)Ye(E)}function nt(E){let v=E.texture,N=i.get(E),H=i.get(v);E.addEventListener("dispose",x);let ie=E.textures,ae=E.isWebGLCubeRenderTarget===!0,he=ie.length>1;if(!he){if(H.__webglTexture===void 0)H.__webglTexture=e.createTexture();H.__version=v.version,o.memory.textures++}if(ae){N.__webglFramebuffer=[];for(let Y=0;Y<6;Y++)if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer[Y]=[];for(let te=0;te<v.mipmaps.length;te++)N.__webglFramebuffer[Y][te]=e.createFramebuffer()}else N.__webglFramebuffer[Y]=e.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer=[];for(let Y=0;Y<v.mipmaps.length;Y++)N.__webglFramebuffer[Y]=e.createFramebuffer()}else N.__webglFramebuffer=e.createFramebuffer();if(he)for(let Y=0,te=ie.length;Y<te;Y++){let _e=i.get(ie[Y]);if(_e.__webglTexture===void 0)_e.__webglTexture=e.createTexture(),o.memory.textures++}if(E.samples>0&&D(E)===!1){N.__webglMultisampledFramebuffer=e.createFramebuffer(),N.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let Y=0;Y<ie.length;Y++){let te=ie[Y];N.__webglColorRenderbuffer[Y]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,N.__webglColorRenderbuffer[Y]);let _e=s.convert(te.format,te.colorSpace),Ie=s.convert(te.type),de=y(te.internalFormat,_e,Ie,te.normalized,te.colorSpace,E.isXRRenderTarget===!0),oe=Bt(E);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,de,E.width,E.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Y,e.RENDERBUFFER,N.__webglColorRenderbuffer[Y])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),E.depthBuffer)N.__webglDepthRenderbuffer=e.createRenderbuffer(),Et(N.__webglDepthRenderbuffer,E,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,H.__webglTexture),we(e.TEXTURE_CUBE_MAP,v);for(let Y=0;Y<6;Y++)if(v.mipmaps&&v.mipmaps.length>0)for(let te=0;te<v.mipmaps.length;te++)Ae(N.__webglFramebuffer[Y][te],E,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,te);else Ae(N.__webglFramebuffer[Y],E,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0);if(g(v))S(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(he){for(let Y=0,te=ie.length;Y<te;Y++){let _e=ie[Y],Ie=i.get(_e),de=e.TEXTURE_2D;if(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)de=E.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(de,Ie.__webglTexture),we(de,_e),Ae(N.__webglFramebuffer,E,_e,e.COLOR_ATTACHMENT0+Y,de,0),g(_e))S(de)}n.unbindTexture()}else{let Y=e.TEXTURE_2D;if(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)Y=E.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Y,H.__webglTexture),we(Y,v),v.mipmaps&&v.mipmaps.length>0)for(let te=0;te<v.mipmaps.length;te++)Ae(N.__webglFramebuffer[te],E,v,e.COLOR_ATTACHMENT0,Y,te);else Ae(N.__webglFramebuffer,E,v,e.COLOR_ATTACHMENT0,Y,0);if(g(v))S(Y);n.unbindTexture()}if(E.depthBuffer)Ye(E)}function Jt(E){let v=E.textures;for(let N=0,H=v.length;N<H;N++){let ie=v[N];if(g(ie)){let ae=T(E),he=i.get(ie).__webglTexture;n.bindTexture(ae,he),S(ae),n.unbindTexture()}}}let At=[],gn=[];function kt(E){if(E.samples>0){if(D(E)===!1){let{textures:v,width:N,height:H}=E,ie=e.COLOR_BUFFER_BIT,ae=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,he=i.get(E),Y=v.length>1;if(Y)for(let _e=0;_e<v.length;_e++)n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,he.__webglMultisampledFramebuffer);let te=E.texture.mipmaps;if(te&&te.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer);for(let _e=0;_e<v.length;_e++){if(E.resolveDepthBuffer){if(E.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(E.stencilBuffer&&E.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(Y){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Ie=i.get(v[_e]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ie,0)}if(e.blitFramebuffer(0,0,N,H,0,0,N,H,ie,e.NEAREST),c===!0){if(At.length=0,gn.length=0,At.push(e.COLOR_ATTACHMENT0+_e),E.depthBuffer&&E.storeMultisampledDepthBuffer===!1)At.push(ae),gn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,gn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,At)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),Y)for(let _e=0;_e<v.length;_e++){n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Ie=i.get(v[_e]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,Ie,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.storeMultisampledDepthBuffer===!1&&c){let v=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[v])}}}function Bt(E){return Math.min(r.maxSamples,E.samples)}function D(E){let v=i.get(E);return E.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function _n(E){let v=o.render.frame;if(u.get(E)!==v)u.set(E,v),E.update()}function ct(E,v){let{colorSpace:N,format:H,type:ie}=E;if(E.isCompressedTexture===!0||E.isVideoTexture===!0)return v;if(N!==Mn&&N!==Br)if(je.getTransfer(N)===yt){if(H!==mi||ie!==Qn)Le("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else ke("WebGLTextures: Unsupported texture color space:",N);return v}function Pt(E){if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement)l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height;else if(typeof VideoFrame<"u"&&E instanceof VideoFrame)l.width=E.displayWidth,l.height=E.displayHeight;else l.width=E.width,l.height=E.height;return l}this.allocateTextureUnit=X,this.resetTextureUnits=K,this.getTextureUnits=I,this.setTextureUnits=G,this.setTexture2D=j,this.setTexture2DArray=k,this.setTexture3D=q,this.setTextureCube=Q,this.rebindTextures=ht,this.setupRenderTarget=nt,this.updateRenderTargetMipmap=Jt,this.updateMultisampleRenderTarget=kt,this.setupDepthRenderbuffer=Ye,this.setupFrameBufferTexture=Ae,this.useMultisampledRTT=D,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function _T(e,t){function n(i,r=Br){let s,o=je.getTransfer(r);if(i===Qn)return e.UNSIGNED_BYTE;if(i===cu)return e.UNSIGNED_SHORT_4_4_4_4;if(i===lu)return e.UNSIGNED_SHORT_5_5_5_1;if(i===Wp)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===Zp)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===Hp)return e.BYTE;if(i===$p)return e.SHORT;if(i===vo)return e.UNSIGNED_SHORT;if(i===au)return e.INT;if(i===hr)return e.UNSIGNED_INT;if(i===Gi)return e.FLOAT;if(i===pi)return e.HALF_FLOAT;if(i===Xp)return e.ALPHA;if(i===jp)return e.RGB;if(i===mi)return e.RGBA;if(i===Fr)return e.DEPTH_COMPONENT;if(i===zr)return e.DEPTH_STENCIL;if(i===qp)return e.RED;if(i===uu)return e.RED_INTEGER;if(i===kr)return e.RG;if(i===hu)return e.RG_INTEGER;if(i===du)return e.RGBA_INTEGER;if(i===ec||i===tc||i===nc||i===ic)if(o===yt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===ec)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===tc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===nc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===ic)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===ec)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===tc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===nc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===ic)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===fu||i===pu||i===mu||i===gu)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===fu)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===pu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===mu)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===gu)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===_u||i===xu||i===yu||i===vu||i===bu||i===rc||i===Su)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===_u||i===xu)return o===yt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===yu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===vu)return s.COMPRESSED_R11_EAC;if(i===bu)return s.COMPRESSED_SIGNED_R11_EAC;if(i===rc)return s.COMPRESSED_RG11_EAC;if(i===Su)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Mu||i===wu||i===Eu||i===Au||i===Tu||i===Ru||i===Cu||i===Pu||i===Iu||i===Lu||i===Nu||i===Du||i===Ou||i===Uu)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Mu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===wu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Eu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Au)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Tu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Ru)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Cu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Pu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Iu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Lu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Nu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Du)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Ou)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Uu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Fu||i===zu||i===ku)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Fu)return o===yt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===zu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ku)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Bu||i===Vu||i===sc||i===Gu)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===Bu)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Vu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===sc)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Gu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Cs)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var xT=`+}`,mT=[new U(1,0,0),new U(-1,0,0),new U(0,1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1)],gT=[new U(0,-1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1),new U(0,-1,0),new U(0,-1,0)],zm=new $e,ko=new U,wh=new U;function _T(e,t,n){let i=new Po,r=new Ue,s=new Ue,o=new ft,a=new rh,c=new sh,l={},u=n.maxTextureSize,d={[ur]:rn,[rn]:ur,[kn]:kn},h=new Bn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ue},radius:{value:4}},vertexShader:fT,fragmentShader:pT}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let m=new sn;m.setAttribute("position",new jt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let _=new Mt(m,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=_o;let g=this.type;this.render=function(A,R,x){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(A.length===0)return;if(this.type===pp)Le("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=_o;let M=e.getRenderTarget(),z=e.getActiveCubeFace(),C=e.getActiveMipmapLevel(),L=e.state;if(L.setBlending(di),L.buffers.depth.getReversed()===!0)L.buffers.color.setClear(0,0,0,0);else L.buffers.color.setClear(1,1,1,1);L.buffers.depth.setTest(!0),L.setScissorTest(!1);let K=g!==this.type;if(K)R.traverse(function(I){if(I.material)if(Array.isArray(I.material))I.material.forEach((G)=>G.needsUpdate=!0);else I.material.needsUpdate=!0});for(let I=0,G=A.length;I<G;I++){let X=A[I],P=X.shadow;if(P===void 0){Le("WebGLShadowMap:",X,"has no shadow.");continue}if(P.autoUpdate===!1&&P.needsUpdate===!1)continue;r.copy(P.mapSize);let j=P.getFrameExtents();if(r.multiply(j),s.copy(P.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/j.x),r.x=s.x*j.x,P.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/j.y),r.y=s.y*j.y,P.mapSize.y=s.y}let k=e.state.buffers.depth.getReversed();if(P.camera._reversedDepth=k,P.map===null||K===!0){if(P.map!==null){if(P.map.depthTexture!==null)P.map.depthTexture.dispose(),P.map.depthTexture=null;P.map.dispose()}if(this.type===Ms){if(X.isPointLight){Le("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}P.map=new Mn(r.x,r.y,{format:kr,type:pi,minFilter:qt,magFilter:qt,generateMipmaps:!1}),P.map.texture.name=X.name+".shadowMap",P.map.depthTexture=new Vr(r.x,r.y,Gi),P.map.depthTexture.name=X.name+".shadowMapDepth",P.map.depthTexture.format=Fr,P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=Kn,P.map.depthTexture.magFilter=Kn}else{if(X.isPointLight)P.map=new Th(r.x),P.map.depthTexture=new th(r.x,hr);else P.map=new Mn(r.x,r.y),P.map.depthTexture=new Vr(r.x,r.y,hr);if(P.map.depthTexture.name=X.name+".shadowMap",P.map.depthTexture.format=Fr,this.type===_o)P.map.depthTexture.compareFunction=k?uc:lc,P.map.depthTexture.minFilter=qt,P.map.depthTexture.magFilter=qt;else P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=Kn,P.map.depthTexture.magFilter=Kn}P.camera.updateProjectionMatrix()}if(P.map.isWebGLCubeRenderTarget!==!0&&(P.map.width!==r.x||P.map.height!==r.y))P.map.setSize(r.x,r.y);let q=P.map.isWebGLCubeRenderTarget?6:P.getViewportCount();if(X.isPointLight!==!0)P.updateMatrices(X,x);for(let Q=0;Q<q;Q++){let Me=P.getCamera(Q);if(X.isPointLight){let{camera:ue,matrix:Be}=P,we=X.distance||ue.far;if(we!==ue.far)ue.far=we,ue.updateProjectionMatrix();ko.setFromMatrixPosition(X.matrixWorld),ue.position.copy(ko),wh.copy(ue.position),wh.add(mT[Q]),ue.up.copy(gT[Q]),ue.lookAt(wh),ue.updateMatrixWorld(),Be.makeTranslation(-ko.x,-ko.y,-ko.z),zm.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),P._frustum.setFromProjectionMatrix(zm,ue.coordinateSystem,ue.reversedDepth)}if(P.map.isWebGLCubeRenderTarget)e.setRenderTarget(P.map,Q),e.clear();else{if(Q===0)e.setRenderTarget(P.map),e.clear();let ue=P.getViewport(Q);o.set(s.x*ue.x,s.y*ue.y,s.x*ue.z,s.y*ue.w),L.viewport(o)}i=P.getFrustum(Q),y(R,x,Me,X,this.type)}if(P.isPointLightShadow!==!0&&this.type===Ms)S(P,x);P.needsUpdate=!1}g=this.type,p.needsUpdate=!1,e.setRenderTarget(M,z,C)};function S(A,R){let x=t.update(_);if(h.defines.VSM_SAMPLES!==A.blurSamples)h.defines.VSM_SAMPLES=A.blurSamples,f.defines.VSM_SAMPLES=A.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0;if(A.mapPass===null)A.mapPass=new Mn(r.x,r.y,{format:kr,type:pi});else if(A.mapPass.width!==A.map.width||A.mapPass.height!==A.map.height)A.mapPass.setSize(A.map.width,A.map.height);h.uniforms.shadow_pass.value=A.map.depthTexture,h.uniforms.resolution.value.set(A.map.width,A.map.height),h.uniforms.radius.value=A.radius,e.setRenderTarget(A.mapPass),e.clear(),e.renderBufferDirect(R,null,x,h,_,null),f.uniforms.shadow_pass.value=A.mapPass.texture,f.uniforms.resolution.value.set(A.map.width,A.map.height),f.uniforms.radius.value=A.radius,e.setRenderTarget(A.map),e.clear(),e.renderBufferDirect(R,null,x,f,_,null)}function T(A,R,x,M){let z=null,C=x.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(C!==void 0)z=C;else if(z=x.isPointLight===!0?c:a,e.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){let L=z.uuid,K=R.uuid,I=l[L];if(I===void 0)I={},l[L]=I;let G=I[K];if(G===void 0)G=z.clone(),I[K]=G,R.addEventListener("dispose",w);z=G}if(z.visible=R.visible,z.wireframe=R.wireframe,M===Ms)z.side=R.shadowSide!==null?R.shadowSide:R.side;else z.side=R.shadowSide!==null?R.shadowSide:d[R.side];if(z.alphaMap=R.alphaMap,z.alphaTest=R.alphaToCoverage===!0?0.5:R.alphaTest,z.map=R.map,z.clipShadows=R.clipShadows,z.clippingPlanes=R.clippingPlanes,z.clipIntersection=R.clipIntersection,z.displacementMap=R.displacementMap,z.displacementScale=R.displacementScale,z.displacementBias=R.displacementBias,z.wireframeLinewidth=R.wireframeLinewidth,z.linewidth=R.linewidth,x.isPointLight===!0&&z.isMeshDistanceMaterial===!0){let L=e.properties.get(z);L.light=x}return z}function y(A,R,x,M,z){if(A.visible===!1)return;if(A.layers.test(R.layers)&&(A.isMesh||A.isLine||A.isPoints)){if((A.castShadow||A.receiveShadow&&z===Ms)&&(!A.frustumCulled||A.intersectsFrustum(i))){A.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,A.matrixWorld);let K=t.update(A),I=A.material;if(Array.isArray(I)){let G=K.groups;for(let X=0,P=G.length;X<P;X++){let j=G[X],k=I[j.materialIndex];if(k&&k.visible){let q=T(A,k,M,z);A.onBeforeShadow(e,A,R,x,K,q,j),e.renderBufferDirect(x,null,K,q,A,j),A.onAfterShadow(e,A,R,x,K,q,j)}}}else if(I.visible){let G=T(A,I,M,z);A.onBeforeShadow(e,A,R,x,K,G,null),e.renderBufferDirect(x,null,K,G,A,null),A.onAfterShadow(e,A,R,x,K,G,null)}}}let L=A.children;for(let K=0,I=L.length;K<I;K++)y(L[K],R,x,M,z)}function w(A){A.target.removeEventListener("dispose",w);for(let x in l){let M=l[x],z=A.target.uuid;if(z in M)M[z].dispose(),delete M[z]}}}function xT(e,t){function n(){let F=!1,ce=new ft,ee=null,le=new ft(0,0,0,0);return{setMask:function(ye){if(ee!==ye&&!F)e.colorMask(ye,ye,ye,ye),ee=ye},setLocked:function(ye){F=ye},setClear:function(ye,ne,pe,He,bt){if(bt===!0)ye*=He,ne*=He,pe*=He;if(ce.set(ye,ne,pe,He),le.equals(ce)===!1)e.clearColor(ye,ne,pe,He),le.copy(ce)},reset:function(){F=!1,ee=null,le.set(-1,0,0,0)}}}function i(){let F=!1,ce=!1,ee=null,le=null,ye=null;return{setReversed:function(ne){if(ce!==ne){let pe=t.get("EXT_clip_control");if(ne)pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.ZERO_TO_ONE_EXT);else pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.NEGATIVE_ONE_TO_ONE_EXT);ce=ne;let He=ye;ye=null,this.setClear(He)}},getReversed:function(){return ce},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else xe(e.DEPTH_TEST)},setMask:function(ne){if(ee!==ne&&!F)e.depthMask(ne),ee=ne},setFunc:function(ne){if(ce)ne=cm[ne];if(le!==ne){switch(ne){case Op:e.depthFunc(e.NEVER);break;case Up:e.depthFunc(e.ALWAYS);break;case Fp:e.depthFunc(e.LESS);break;case nu:e.depthFunc(e.LEQUAL);break;case zp:e.depthFunc(e.EQUAL);break;case kp:e.depthFunc(e.GEQUAL);break;case Bp:e.depthFunc(e.GREATER);break;case Vp:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}le=ne}},setLocked:function(ne){F=ne},setClear:function(ne){if(ye!==ne){if(ye=ne,ce)ne=1-ne;e.clearDepth(ne)}},reset:function(){F=!1,ee=null,le=null,ye=null,ce=!1}}}function r(){let F=!1,ce=null,ee=null,le=null,ye=null,ne=null,pe=null,He=null,bt=null;return{setTest:function(lt){if(!F)if(lt)se(e.STENCIL_TEST);else xe(e.STENCIL_TEST)},setMask:function(lt){if(ce!==lt&&!F)e.stencilMask(lt),ce=lt},setFunc:function(lt,oi,Di){if(ee!==lt||le!==oi||ye!==Di)e.stencilFunc(lt,oi,Di),ee=lt,le=oi,ye=Di},setOp:function(lt,oi,Di){if(ne!==lt||pe!==oi||He!==Di)e.stencilOp(lt,oi,Di),ne=lt,pe=oi,He=Di},setLocked:function(lt){F=lt},setClear:function(lt){if(bt!==lt)e.clearStencil(lt),bt=lt},reset:function(){F=!1,ce=null,ee=null,le=null,ye=null,ne=null,pe=null,He=null,bt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},d={},h={},f=new WeakMap,m=[],_=null,p=!1,g=null,S=null,T=null,y=null,w=null,A=null,R=null,x=new ze(0,0,0),M=0,z=!1,C=null,L=null,K=null,I=null,G=null,X=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),P=!1,j=0,k=e.getParameter(e.VERSION);if(k.indexOf("WebGL")!==-1)j=parseFloat(/^WebGL (\d)/.exec(k)[1]),P=j>=1;else if(k.indexOf("OpenGL ES")!==-1)j=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),P=j>=2;let q=null,Q={},Me=e.getParameter(e.SCISSOR_BOX),ue=e.getParameter(e.VIEWPORT),Be=new ft().fromArray(Me),we=new ft().fromArray(ue);function Z(F,ce,ee,le){let ye=new Uint8Array(4),ne=e.createTexture();e.bindTexture(F,ne),e.texParameteri(F,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(F,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let pe=0;pe<ee;pe++)if(F===e.TEXTURE_3D||F===e.TEXTURE_2D_ARRAY)e.texImage3D(ce,0,e.RGBA,1,1,le,0,e.RGBA,e.UNSIGNED_BYTE,ye);else e.texImage2D(ce+pe,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,ye);return ne}let re={};re[e.TEXTURE_2D]=Z(e.TEXTURE_2D,e.TEXTURE_2D,1),re[e.TEXTURE_CUBE_MAP]=Z(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[e.TEXTURE_2D_ARRAY]=Z(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),re[e.TEXTURE_3D]=Z(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),se(e.DEPTH_TEST),o.setFunc(nu),Jt(!1),At(Kl),se(e.CULL_FACE),ht(di);function se(F){if(u[F]!==!0)e.enable(F),u[F]=!0}function xe(F){if(u[F]!==!1)e.disable(F),u[F]=!1}function Ee(F,ce){if(h[F]!==ce){if(e.bindFramebuffer(F,ce),h[F]=ce,F===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=ce;if(F===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=ce;return!0}return!1}function Ae(F,ce){let ee=m,le=!1;if(F){if(ee=f.get(ce),ee===void 0)ee=[],f.set(ce,ee);let ye=F.textures;if(ee.length!==ye.length||ee[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,pe=ye.length;ne<pe;ne++)ee[ne]=e.COLOR_ATTACHMENT0+ne;ee.length=ye.length,le=!0}}else if(ee[0]!==e.BACK)ee[0]=e.BACK,le=!0;if(le)e.drawBuffers(ee)}function Et(F){if(_!==F)return e.useProgram(F),_=F,!0;return!1}let Ge={[ws]:e.FUNC_ADD,[gp]:e.FUNC_SUBTRACT,[_p]:e.FUNC_REVERSE_SUBTRACT};Ge[xp]=e.MIN,Ge[yp]=e.MAX;let Ye={[vp]:e.ZERO,[bp]:e.ONE,[Sp]:e.SRC_COLOR,[wp]:e.SRC_ALPHA,[Pp]:e.SRC_ALPHA_SATURATE,[Rp]:e.DST_COLOR,[Ap]:e.DST_ALPHA,[Mp]:e.ONE_MINUS_SRC_COLOR,[Ep]:e.ONE_MINUS_SRC_ALPHA,[Cp]:e.ONE_MINUS_DST_COLOR,[Tp]:e.ONE_MINUS_DST_ALPHA,[Ip]:e.CONSTANT_COLOR,[Lp]:e.ONE_MINUS_CONSTANT_COLOR,[Np]:e.CONSTANT_ALPHA,[Dp]:e.ONE_MINUS_CONSTANT_ALPHA};function ht(F,ce,ee,le,ye,ne,pe,He,bt,lt){if(F===di){if(p===!0)xe(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(F!==mp){if(F!==g||lt!==z){if(S!==ws||w!==ws)e.blendEquation(e.FUNC_ADD),S=ws,w=ws;if(lt)switch(F){case xo:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Ql:e.blendFunc(e.ONE,e.ONE);break;case eu:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case tu:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:ke("WebGLState: Invalid blending: ",F);break}else switch(F){case xo:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Ql:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case eu:ke("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case tu:ke("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ke("WebGLState: Invalid blending: ",F);break}T=null,y=null,A=null,R=null,x.set(0,0,0),M=0,g=F,z=lt}return}if(ye=ye||ce,ne=ne||ee,pe=pe||le,ce!==S||ye!==w)e.blendEquationSeparate(Ge[ce],Ge[ye]),S=ce,w=ye;if(ee!==T||le!==y||ne!==A||pe!==R)e.blendFuncSeparate(Ye[ee],Ye[le],Ye[ne],Ye[pe]),T=ee,y=le,A=ne,R=pe;if(He.equals(x)===!1||bt!==M)e.blendColor(He.r,He.g,He.b,bt),x.copy(He),M=bt;g=F,z=!1}function tt(F,ce){F.side===kn?xe(e.CULL_FACE):se(e.CULL_FACE);let ee=F.side===rn;if(ce)ee=!ee;Jt(ee),F.blending===xo&&F.transparent===!1?ht(di):ht(F.blending,F.blendEquation,F.blendSrc,F.blendDst,F.blendEquationAlpha,F.blendSrcAlpha,F.blendDstAlpha,F.blendColor,F.blendAlpha,F.premultipliedAlpha),o.setFunc(F.depthFunc),o.setTest(F.depthTest),o.setMask(F.depthWrite),s.setMask(F.colorWrite);let le=F.stencilWrite;if(a.setTest(le),le)a.setMask(F.stencilWriteMask),a.setFunc(F.stencilFunc,F.stencilRef,F.stencilFuncMask),a.setOp(F.stencilFail,F.stencilZFail,F.stencilZPass);kt(F.polygonOffset,F.polygonOffsetFactor,F.polygonOffsetUnits),F.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):xe(e.SAMPLE_ALPHA_TO_COVERAGE)}function Jt(F){if(C!==F){if(F)e.frontFace(e.CW);else e.frontFace(e.CCW);C=F}}function At(F){if(F!==dp){if(se(e.CULL_FACE),F!==L)if(F===Kl)e.cullFace(e.BACK);else if(F===fp)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else xe(e.CULL_FACE);L=F}function mn(F){if(F!==K){if(P)e.lineWidth(F);K=F}}function kt(F,ce,ee){if(F){if(se(e.POLYGON_OFFSET_FILL),I!==ce||G!==ee){if(I=ce,G=ee,o.getReversed())ce=-ce;e.polygonOffset(ce,ee)}}else xe(e.POLYGON_OFFSET_FILL)}function Bt(F){if(F)se(e.SCISSOR_TEST);else xe(e.SCISSOR_TEST)}function D(F){if(F===void 0)F=e.TEXTURE0+X-1;if(q!==F)e.activeTexture(F),q=F}function gn(F,ce,ee){if(ee===void 0)if(q===null)ee=e.TEXTURE0+X-1;else ee=q;let le=Q[ee];if(le===void 0)le={type:void 0,texture:void 0},Q[ee]=le;if(le.type!==F||le.texture!==ce){if(q!==ee)e.activeTexture(ee),q=ee;e.bindTexture(F,ce||re[F]),le.type=F,le.texture=ce}}function ct(){let F=Q[q];if(F!==void 0&&F.type!==void 0)e.bindTexture(F.type,null),F.type=void 0,F.texture=void 0}function Pt(){try{e.compressedTexImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function E(){try{e.compressedTexImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function v(){try{e.texSubImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function N(){try{e.texSubImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function H(){try{e.compressedTexSubImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function ae(){try{e.texStorage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function he(){try{e.texStorage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function Y(){try{e.texImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function te(){try{e.texImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function _e(F){if(d[F]!==void 0)return d[F];else return e.getParameter(F)}function Ie(F,ce){if(d[F]!==ce)e.pixelStorei(F,ce),d[F]=ce}function de(F){if(Be.equals(F)===!1)e.scissor(F.x,F.y,F.z,F.w),Be.copy(F)}function oe(F){if(we.equals(F)===!1)e.viewport(F.x,F.y,F.z,F.w),we.copy(F)}function De(F,ce){let ee=l.get(ce);if(ee===void 0)ee=new WeakMap,l.set(ce,ee);let le=ee.get(F);if(le===void 0)le=e.getUniformBlockIndex(ce,F.name),ee.set(F,le)}function Fe(F,ce){let le=l.get(ce).get(F);if(c.get(ce)!==le)e.uniformBlockBinding(ce,le,F.__bindingPointIndex),c.set(ce,le)}function st(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},d={},q=null,Q={},h={},f=new WeakMap,m=[],_=null,p=!1,g=null,S=null,T=null,y=null,w=null,A=null,R=null,x=new ze(0,0,0),M=0,z=!1,C=null,L=null,K=null,I=null,G=null,Be.set(0,0,e.canvas.width,e.canvas.height),we.set(0,0,e.canvas.width,e.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:se,disable:xe,bindFramebuffer:Ee,drawBuffers:Ae,useProgram:Et,setBlending:ht,setMaterial:tt,setFlipSided:Jt,setCullFace:At,setLineWidth:mn,setPolygonOffset:kt,setScissorTest:Bt,activeTexture:D,bindTexture:gn,unbindTexture:ct,compressedTexImage2D:Pt,compressedTexImage3D:E,texImage2D:Y,texImage3D:te,pixelStorei:Ie,getParameter:_e,updateUBOMapping:De,uniformBlockBinding:Fe,texStorage2D:ae,texStorage3D:he,texSubImage2D:v,texSubImage3D:N,compressedTexSubImage2D:H,compressedTexSubImage3D:ie,scissor:de,viewport:oe,reset:st}}function yT(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ue,u=new WeakMap,d=new Set,h,f=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(E){}function _(E,v){return m?new OffscreenCanvas(E,v):vs("canvas")}function p(E,v,N){let H=1,ie=Pt(E);if(ie.width>N||ie.height>N)H=N/Math.max(ie.width,ie.height);if(H<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){let ae=Math.floor(H*ie.width),he=Math.floor(H*ie.height);if(h===void 0)h=_(ae,he);let Y=v?_(ae,he):h;return Y.width=ae,Y.height=he,Y.getContext("2d").drawImage(E,0,0,ae,he),Le("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+he+")."),Y}else{if("data"in E)Le("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return E}return E}function g(E){return E.generateMipmaps}function S(E){e.generateMipmap(E)}function T(E){if(E.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(E.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function y(E,v,N,H,ie,ae=!1){if(E!==null){if(e[E]!==void 0)return e[E];Le("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let he;if(H){if(he=t.get("EXT_texture_norm16"),!he)Le("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let Y=v;if(v===e.RED){if(N===e.FLOAT)Y=e.R32F;if(N===e.HALF_FLOAT)Y=e.R16F;if(N===e.UNSIGNED_BYTE)Y=e.R8;if(N===e.UNSIGNED_SHORT&&he)Y=he.R16_EXT;if(N===e.SHORT&&he)Y=he.R16_SNORM_EXT}if(v===e.RED_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.R8UI;if(N===e.UNSIGNED_SHORT)Y=e.R16UI;if(N===e.UNSIGNED_INT)Y=e.R32UI;if(N===e.BYTE)Y=e.R8I;if(N===e.SHORT)Y=e.R16I;if(N===e.INT)Y=e.R32I}if(v===e.RG){if(N===e.FLOAT)Y=e.RG32F;if(N===e.HALF_FLOAT)Y=e.RG16F;if(N===e.UNSIGNED_BYTE)Y=e.RG8;if(N===e.UNSIGNED_SHORT&&he)Y=he.RG16_EXT;if(N===e.SHORT&&he)Y=he.RG16_SNORM_EXT}if(v===e.RG_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RG8UI;if(N===e.UNSIGNED_SHORT)Y=e.RG16UI;if(N===e.UNSIGNED_INT)Y=e.RG32UI;if(N===e.BYTE)Y=e.RG8I;if(N===e.SHORT)Y=e.RG16I;if(N===e.INT)Y=e.RG32I}if(v===e.RGB_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RGB8UI;if(N===e.UNSIGNED_SHORT)Y=e.RGB16UI;if(N===e.UNSIGNED_INT)Y=e.RGB32UI;if(N===e.BYTE)Y=e.RGB8I;if(N===e.SHORT)Y=e.RGB16I;if(N===e.INT)Y=e.RGB32I}if(v===e.RGBA_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RGBA8UI;if(N===e.UNSIGNED_SHORT)Y=e.RGBA16UI;if(N===e.UNSIGNED_INT)Y=e.RGBA32UI;if(N===e.BYTE)Y=e.RGBA8I;if(N===e.SHORT)Y=e.RGBA16I;if(N===e.INT)Y=e.RGBA32I}if(v===e.RGB){if(N===e.UNSIGNED_SHORT&&he)Y=he.RGB16_EXT;if(N===e.SHORT&&he)Y=he.RGB16_SNORM_EXT;if(N===e.UNSIGNED_INT_5_9_9_9_REV)Y=e.RGB9_E5;if(N===e.UNSIGNED_INT_10F_11F_11F_REV)Y=e.R11F_G11F_B10F}if(v===e.RGBA){let te=ae?ju:je.getTransfer(ie);if(N===e.FLOAT)Y=e.RGBA32F;if(N===e.HALF_FLOAT)Y=e.RGBA16F;if(N===e.UNSIGNED_BYTE)Y=te===yt?e.SRGB8_ALPHA8:e.RGBA8;if(N===e.UNSIGNED_SHORT&&he)Y=he.RGBA16_EXT;if(N===e.SHORT&&he)Y=he.RGBA16_SNORM_EXT;if(N===e.UNSIGNED_SHORT_4_4_4_4)Y=e.RGBA4;if(N===e.UNSIGNED_SHORT_5_5_5_1)Y=e.RGB5_A1}if(Y===e.R16F||Y===e.R32F||Y===e.RG16F||Y===e.RG32F||Y===e.RGBA16F||Y===e.RGBA32F)t.get("EXT_color_buffer_float");return Y}function w(E,v){let N;if(E){if(v===null||v===hr||v===Cs)N=e.DEPTH24_STENCIL8;else if(v===Gi)N=e.DEPTH32F_STENCIL8;else if(v===bo)N=e.DEPTH24_STENCIL8,Le("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(v===null||v===hr||v===Cs)N=e.DEPTH_COMPONENT24;else if(v===Gi)N=e.DEPTH_COMPONENT32F;else if(v===bo)N=e.DEPTH_COMPONENT16;return N}function A(E,v){if(g(E)===!0||E.isFramebufferTexture&&E.minFilter!==Kn&&E.minFilter!==qt)return Math.log2(Math.max(v.width,v.height))+1;else if(E.mipmaps!==void 0&&E.mipmaps.length>0)return E.mipmaps.length;else if(E.isCompressedTexture&&Array.isArray(E.image))return v.mipmaps.length;else return 1}function R(E){let v=E.target;if(v.removeEventListener("dispose",R),M(v),v.isVideoTexture)u.delete(v);if(v.isHTMLTexture)d.delete(v)}function x(E){let v=E.target;v.removeEventListener("dispose",x),C(v)}function M(E){let v=i.get(E);if(v.__webglInit===void 0)return;let N=E.source,H=f.get(N);if(H){let ie=H[v.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)z(E);if(Object.keys(H).length===0)f.delete(N)}i.remove(E)}function z(E){let v=i.get(E);e.deleteTexture(v.__webglTexture);let N=E.source,H=f.get(N);delete H[v.__cacheKey],o.memory.textures--}function C(E){let v=i.get(E);if(E.depthTexture)E.depthTexture.dispose(),i.remove(E.depthTexture);if(E.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(v.__webglFramebuffer[H]))for(let ie=0;ie<v.__webglFramebuffer[H].length;ie++)e.deleteFramebuffer(v.__webglFramebuffer[H][ie]);else e.deleteFramebuffer(v.__webglFramebuffer[H]);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer[H])}else{if(Array.isArray(v.__webglFramebuffer))for(let H=0;H<v.__webglFramebuffer.length;H++)e.deleteFramebuffer(v.__webglFramebuffer[H]);else e.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer);if(v.__webglMultisampledFramebuffer)e.deleteFramebuffer(v.__webglMultisampledFramebuffer);if(v.__webglColorRenderbuffer){for(let H=0;H<v.__webglColorRenderbuffer.length;H++)if(v.__webglColorRenderbuffer[H])e.deleteRenderbuffer(v.__webglColorRenderbuffer[H])}if(v.__webglDepthRenderbuffer)e.deleteRenderbuffer(v.__webglDepthRenderbuffer)}let N=E.textures;for(let H=0,ie=N.length;H<ie;H++){let ae=i.get(N[H]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(N[H])}i.remove(E)}let L=0;function K(){L=0}function I(){return L}function G(E){L=E}function X(){let E=L;if(E>=r.maxTextures)Le("WebGLTextures: Trying to use "+(E+1)+" texture units while this GPU supports only "+r.maxTextures);return L+=1,E}function P(E){let v=[];return v.push(E.wrapS),v.push(E.wrapT),v.push(E.wrapR||0),v.push(E.magFilter),v.push(E.minFilter),v.push(E.anisotropy),v.push(E.internalFormat),v.push(E.format),v.push(E.type),v.push(E.generateMipmaps),v.push(E.premultiplyAlpha),v.push(E.flipY),v.push(E.unpackAlignment),v.push(E.colorSpace),v.join()}function j(E,v){let N=i.get(E);if(E.isVideoTexture)gn(E);if(E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&N.__version!==E.version){let H=E.image;if(H===null)Le("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Le("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(N,E,v);return}}else if(E.isExternalTexture)N.__webglTexture=E.sourceTexture?E.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,N.__webglTexture,e.TEXTURE0+v)}function k(E,v){let N=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){xe(N,E,v);return}else if(E.isExternalTexture)N.__webglTexture=E.sourceTexture?E.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,N.__webglTexture,e.TEXTURE0+v)}function q(E,v){let N=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){xe(N,E,v);return}n.bindTexture(e.TEXTURE_3D,N.__webglTexture,e.TEXTURE0+v)}function Q(E,v){let N=i.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&N.__version!==E.version){Ee(N,E,v);return}n.bindTexture(e.TEXTURE_CUBE_MAP,N.__webglTexture,e.TEXTURE0+v)}let Me={[As]:e.REPEAT,[Ts]:e.CLAMP_TO_EDGE,[ec]:e.MIRRORED_REPEAT},ue={[Kn]:e.NEAREST,[tc]:e.NEAREST_MIPMAP_NEAREST,[Ur]:e.NEAREST_MIPMAP_LINEAR,[qt]:e.LINEAR,[Rs]:e.LINEAR_MIPMAP_NEAREST,[fi]:e.LINEAR_MIPMAP_LINEAR},Be={[Qp]:e.NEVER,[rm]:e.ALWAYS,[em]:e.LESS,[lc]:e.LEQUAL,[tm]:e.EQUAL,[uc]:e.GEQUAL,[nm]:e.GREATER,[im]:e.NOTEQUAL};function we(E,v){if(v.type===Gi&&t.has("OES_texture_float_linear")===!1&&(v.magFilter===qt||v.magFilter===Rs||v.magFilter===Ur||v.magFilter===fi||v.minFilter===qt||v.minFilter===Rs||v.minFilter===Ur||v.minFilter===fi))Le("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(E,e.TEXTURE_WRAP_S,Me[v.wrapS]),e.texParameteri(E,e.TEXTURE_WRAP_T,Me[v.wrapT]),E===e.TEXTURE_3D||E===e.TEXTURE_2D_ARRAY)e.texParameteri(E,e.TEXTURE_WRAP_R,Me[v.wrapR]);if(e.texParameteri(E,e.TEXTURE_MAG_FILTER,ue[v.magFilter]),e.texParameteri(E,e.TEXTURE_MIN_FILTER,ue[v.minFilter]),v.compareFunction)e.texParameteri(E,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(E,e.TEXTURE_COMPARE_FUNC,Be[v.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Kn)return;if(v.minFilter!==Ur&&v.minFilter!==fi)return;if(v.type===Gi&&t.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){let N=t.get("EXT_texture_filter_anisotropic");e.texParameterf(E,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function Z(E,v){let N=!1;if(E.__webglInit===void 0)E.__webglInit=!0,v.addEventListener("dispose",R);let H=v.source,ie=f.get(H);if(ie===void 0)ie={},f.set(H,ie);let ae=P(v);if(ae!==E.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,N=!0;ie[ae].usedTimes++;let he=ie[E.__cacheKey];if(he!==void 0){if(ie[E.__cacheKey].usedTimes--,he.usedTimes===0)z(v)}E.__cacheKey=ae,E.__webglTexture=ie[ae].texture}return N}function re(E,v,N){return Math.floor(Math.floor(E/N)/v)}function se(E,v,N,H){let ae=E.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,v.width,v.height,N,H,v.data);else{ae.sort((Ie,de)=>Ie.start-de.start);let he=0;for(let Ie=1;Ie<ae.length;Ie++){let de=ae[he],oe=ae[Ie],De=de.start+de.count,Fe=re(oe.start,v.width,4),st=re(de.start,v.width,4);if(oe.start<=De+1&&Fe===st&&re(oe.start+oe.count-1,v.width,4)===Fe)de.count=Math.max(de.count,oe.start+oe.count-de.start);else++he,ae[he]=oe}ae.length=he+1;let Y=n.getParameter(e.UNPACK_ROW_LENGTH),te=n.getParameter(e.UNPACK_SKIP_PIXELS),_e=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,v.width);for(let Ie=0,de=ae.length;Ie<de;Ie++){let oe=ae[Ie],De=Math.floor(oe.start/4),Fe=Math.ceil(oe.count/4),st=De%v.width,F=Math.floor(De/v.width),ce=Fe,ee=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,st),n.pixelStorei(e.UNPACK_SKIP_ROWS,F),n.texSubImage2D(e.TEXTURE_2D,0,st,F,ce,1,N,H,v.data)}E.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,Y),n.pixelStorei(e.UNPACK_SKIP_PIXELS,te),n.pixelStorei(e.UNPACK_SKIP_ROWS,_e)}}function xe(E,v,N){let H=e.TEXTURE_2D;if(v.isDataArrayTexture||v.isCompressedArrayTexture)H=e.TEXTURE_2D_ARRAY;if(v.isData3DTexture)H=e.TEXTURE_3D;let ie=Z(E,v),ae=v.source;n.bindTexture(H,E.__webglTexture,e.TEXTURE0+N);let he=i.get(ae);if(ae.version!==he.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+N),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){let ee=je.getPrimaries(je.workingColorSpace),le=v.colorSpace===Br?null:je.getPrimaries(v.colorSpace),ye=v.colorSpace===Br||ee===le?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,ye)}n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment);let te=p(v.image,!1,r.maxTextureSize);te=ct(v,te);let _e=s.convert(v.format,v.colorSpace),Ie=s.convert(v.type),de=y(v.internalFormat,_e,Ie,v.normalized,v.colorSpace,v.isVideoTexture);we(H,v);let oe,De=v.mipmaps,Fe=v.isVideoTexture!==!0,st=he.__version===void 0||ie===!0,F=ae.dataReady,ce=A(v,te);if(v.isDepthTexture){if(de=w(v.format===zr,v.type),st)if(Fe)n.texStorage2D(e.TEXTURE_2D,1,de,te.width,te.height);else n.texImage2D(e.TEXTURE_2D,0,de,te.width,te.height,0,_e,Ie,null)}else if(v.isDataTexture)if(De.length>0){if(Fe&&st)n.texStorage2D(e.TEXTURE_2D,ce,de,De[0].width,De[0].height);for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],Fe){if(F)n.texSubImage2D(e.TEXTURE_2D,ee,0,0,oe.width,oe.height,_e,Ie,oe.data)}else n.texImage2D(e.TEXTURE_2D,ee,de,oe.width,oe.height,0,_e,Ie,oe.data);v.generateMipmaps=!1}else if(Fe){if(st)n.texStorage2D(e.TEXTURE_2D,ce,de,te.width,te.height);if(F)se(v,te,_e,Ie)}else n.texImage2D(e.TEXTURE_2D,0,de,te.width,te.height,0,_e,Ie,te.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){if(Fe&&st)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,de,De[0].width,De[0].height,te.depth);for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],v.format!==mi)if(_e!==null)if(Fe){if(F)if(v.layerUpdates.size>0){let ye=xh(oe.width,oe.height,v.format,v.type);for(let ne of v.layerUpdates){let pe=oe.data.subarray(ne*ye/oe.data.BYTES_PER_ELEMENT,(ne+1)*ye/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ee,0,0,ne,oe.width,oe.height,1,_e,pe)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ee,0,0,0,oe.width,oe.height,te.depth,_e,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ee,de,oe.width,oe.height,te.depth,0,oe.data,0,0);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Fe){if(F)n.texSubImage3D(e.TEXTURE_2D_ARRAY,ee,0,0,0,oe.width,oe.height,te.depth,_e,Ie,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,ee,de,oe.width,oe.height,te.depth,0,_e,Ie,oe.data);if(v.layerUpdates.size>0)v.clearLayerUpdates()}else{if(Fe&&st)n.texStorage2D(e.TEXTURE_2D,ce,de,De[0].width,De[0].height);for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],v.format!==mi)if(_e!==null)if(Fe){if(F)n.compressedTexSubImage2D(e.TEXTURE_2D,ee,0,0,oe.width,oe.height,_e,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,ee,de,oe.width,oe.height,0,oe.data);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Fe){if(F)n.texSubImage2D(e.TEXTURE_2D,ee,0,0,oe.width,oe.height,_e,Ie,oe.data)}else n.texImage2D(e.TEXTURE_2D,ee,de,oe.width,oe.height,0,_e,Ie,oe.data)}else if(v.isDataArrayTexture)if(Fe){if(st)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,de,te.width,te.height,te.depth);if(F)if(v.layerUpdates.size>0){let ee=xh(te.width,te.height,v.format,v.type);for(let le of v.layerUpdates){let ye=te.data.subarray(le*ee/te.data.BYTES_PER_ELEMENT,(le+1)*ee/te.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,le,te.width,te.height,1,_e,Ie,ye)}v.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,te.width,te.height,te.depth,_e,Ie,te.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,de,te.width,te.height,te.depth,0,_e,Ie,te.data);else if(v.isData3DTexture)if(Fe){if(st)n.texStorage3D(e.TEXTURE_3D,ce,de,te.width,te.height,te.depth);if(F)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,te.width,te.height,te.depth,_e,Ie,te.data)}else n.texImage3D(e.TEXTURE_3D,0,de,te.width,te.height,te.depth,0,_e,Ie,te.data);else if(v.isFramebufferTexture){if(st)if(Fe)n.texStorage2D(e.TEXTURE_2D,ce,de,te.width,te.height);else{let ee=te.width,le=te.height;for(let ye=0;ye<ce;ye++)n.texImage2D(e.TEXTURE_2D,ye,de,ee,le,0,_e,Ie,null),ee>>=1,le>>=1}}else if(v.isHTMLTexture){if("texElementImage2D"in e){let ee=e.canvas;if(!ee.hasAttribute("layoutsubtree"))ee.setAttribute("layoutsubtree","true");if(te.parentNode!==ee){ee.appendChild(te),d.add(v),ee.onpaint=(le)=>{let ye=le.changedElements;for(let ne of d)if(ye.includes(ne.image))ne.needsUpdate=!0},ee.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,te);else{let{RGBA:ye,RGBA:ne,UNSIGNED_BYTE:pe}=e;e.texElementImage2D(e.TEXTURE_2D,0,ye,ne,pe,te)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(De.length>0){if(Fe&&st){let ee=Pt(De[0]);n.texStorage2D(e.TEXTURE_2D,ce,de,ee.width,ee.height)}for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],Fe){if(F)n.texSubImage2D(e.TEXTURE_2D,ee,0,0,_e,Ie,oe)}else n.texImage2D(e.TEXTURE_2D,ee,de,_e,Ie,oe);v.generateMipmaps=!1}else if(Fe){if(st){let ee=Pt(te);n.texStorage2D(e.TEXTURE_2D,ce,de,ee.width,ee.height)}if(F)n.texSubImage2D(e.TEXTURE_2D,0,0,0,_e,Ie,te)}else n.texImage2D(e.TEXTURE_2D,0,de,_e,Ie,te);if(g(v))S(H);if(he.__version=ae.version,v.onUpdate)v.onUpdate(v)}E.__version=v.version}function Ee(E,v,N){if(v.image.length!==6)return;let H=Z(E,v),ie=v.source;n.bindTexture(e.TEXTURE_CUBE_MAP,E.__webglTexture,e.TEXTURE0+N);let ae=i.get(ie);if(ie.version!==ae.__version||H===!0){n.activeTexture(e.TEXTURE0+N);let he=je.getPrimaries(je.workingColorSpace),Y=v.colorSpace===Br?null:je.getPrimaries(v.colorSpace),te=v.colorSpace===Br||he===Y?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,te);let _e=v.isCompressedTexture||v.image[0].isCompressedTexture,Ie=v.image[0]&&v.image[0].isDataTexture,de=[];for(let ne=0;ne<6;ne++){if(!_e&&!Ie)de[ne]=p(v.image[ne],!0,r.maxCubemapSize);else de[ne]=Ie?v.image[ne].image:v.image[ne];de[ne]=ct(v,de[ne])}let oe=de[0],De=s.convert(v.format,v.colorSpace),Fe=s.convert(v.type),st=y(v.internalFormat,De,Fe,v.normalized,v.colorSpace),F=v.isVideoTexture!==!0,ce=ae.__version===void 0||H===!0,ee=ie.dataReady,le=A(v,oe);we(e.TEXTURE_CUBE_MAP,v);let ye;if(_e){if(F&&ce)n.texStorage2D(e.TEXTURE_CUBE_MAP,le,st,oe.width,oe.height);for(let ne=0;ne<6;ne++){ye=de[ne].mipmaps;for(let pe=0;pe<ye.length;pe++){let He=ye[pe];if(v.format!==mi)if(De!==null)if(F){if(ee)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,He.width,He.height,De,He.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,st,He.width,He.height,0,He.data);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,He.width,He.height,De,Fe,He.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,st,He.width,He.height,0,De,Fe,He.data)}}}else{if(ye=v.mipmaps,F&&ce){if(ye.length>0)le++;let ne=Pt(de[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,le,st,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Ie){if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,de[ne].width,de[ne].height,De,Fe,de[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,st,de[ne].width,de[ne].height,0,De,Fe,de[ne].data);for(let pe=0;pe<ye.length;pe++){let bt=ye[pe].image[ne].image;if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,bt.width,bt.height,De,Fe,bt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,st,bt.width,bt.height,0,De,Fe,bt.data)}}else{if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,De,Fe,de[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,st,De,Fe,de[ne]);for(let pe=0;pe<ye.length;pe++){let He=ye[pe];if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,De,Fe,He.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,st,De,Fe,He.image[ne])}}}if(g(v))S(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,v.onUpdate)v.onUpdate(v)}E.__version=v.version}function Ae(E,v,N,H,ie,ae){let he=s.convert(N.format,N.colorSpace),Y=s.convert(N.type),te=y(N.internalFormat,he,Y,N.normalized,N.colorSpace),_e=i.get(v),Ie=i.get(N);if(Ie.__renderTarget=v,!_e.__hasExternalTextures){let de=Math.max(1,v.width>>ae),oe=Math.max(1,v.height>>ae);if(ie===e.TEXTURE_3D||ie===e.TEXTURE_2D_ARRAY)n.texImage3D(ie,ae,te,de,oe,v.depth,0,he,Y,null);else n.texImage2D(ie,ae,te,de,oe,0,he,Y,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,E),D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,H,ie,Ie.__webglTexture,0,Bt(v));else if(ie===e.TEXTURE_2D||ie>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,H,ie,Ie.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function Et(E,v,N){if(e.bindRenderbuffer(e.RENDERBUFFER,E),v.depthBuffer){let H=v.depthTexture,ie=H&&H.isDepthTexture?H.type:null,ae=w(v.stencilBuffer,ie),he=v.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(D(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Bt(v),ae,v.width,v.height);else if(N)e.renderbufferStorageMultisample(e.RENDERBUFFER,Bt(v),ae,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,v.width,v.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,E)}else{let H=v.textures;for(let ie=0;ie<H.length;ie++){let ae=H[ie],he=s.convert(ae.format,ae.colorSpace),Y=s.convert(ae.type),te=y(ae.internalFormat,he,Y,ae.normalized,ae.colorSpace);if(D(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Bt(v),te,v.width,v.height);else if(N)e.renderbufferStorageMultisample(e.RENDERBUFFER,Bt(v),te,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,te,v.width,v.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Ge(E,v,N){let H=v.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,E),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ie=i.get(v.depthTexture);if(ie.__renderTarget=v,!ie.__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0;if(H){if(ie.__webglInit===void 0)ie.__webglInit=!0,v.depthTexture.addEventListener("dispose",R);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),we(e.TEXTURE_CUBE_MAP,v.depthTexture);let _e=s.convert(v.depthTexture.format),Ie=s.convert(v.depthTexture.type),de;if(v.depthTexture.format===Fr)de=e.DEPTH_COMPONENT24;else if(v.depthTexture.format===zr)de=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,de,v.width,v.height,0,_e,Ie,null)}}else j(v.depthTexture,0);let ae=ie.__webglTexture,he=Bt(v),Y=H?e.TEXTURE_CUBE_MAP_POSITIVE_X+N:e.TEXTURE_2D,te=v.depthTexture.format===zr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(v.depthTexture.format===Fr)if(D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else if(v.depthTexture.format===zr)if(D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ye(E){let v=i.get(E),N=E.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==E.depthTexture){let H=E.depthTexture;if(v.__depthDisposeCallback)v.__depthDisposeCallback();if(H){let ie=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,H.removeEventListener("dispose",ie)};H.addEventListener("dispose",ie),v.__depthDisposeCallback=ie}v.__boundDepthTexture=H}if(E.depthTexture&&!v.__autoAllocateDepthBuffer)if(N)for(let H=0;H<6;H++)Ge(v.__webglFramebuffer[H],E,H);else{let H=E.texture.mipmaps;if(H&&H.length>0)Ge(v.__webglFramebuffer[0],E,0);else Ge(v.__webglFramebuffer,E,0)}else if(N){v.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[H]),v.__webglDepthbuffer[H]===void 0)v.__webglDepthbuffer[H]=e.createRenderbuffer(),Et(v.__webglDepthbuffer[H],E,!1);else{let ie=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer[H];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let H=E.texture.mipmaps;if(H&&H.length>0)n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer);if(v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=e.createRenderbuffer(),Et(v.__webglDepthbuffer,E,!1);else{let ie=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function ht(E,v,N){let H=i.get(E);if(v!==void 0)Ae(H.__webglFramebuffer,E,E.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(N!==void 0)Ye(E)}function tt(E){let v=E.texture,N=i.get(E),H=i.get(v);E.addEventListener("dispose",x);let ie=E.textures,ae=E.isWebGLCubeRenderTarget===!0,he=ie.length>1;if(!he){if(H.__webglTexture===void 0)H.__webglTexture=e.createTexture();H.__version=v.version,o.memory.textures++}if(ae){N.__webglFramebuffer=[];for(let Y=0;Y<6;Y++)if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer[Y]=[];for(let te=0;te<v.mipmaps.length;te++)N.__webglFramebuffer[Y][te]=e.createFramebuffer()}else N.__webglFramebuffer[Y]=e.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer=[];for(let Y=0;Y<v.mipmaps.length;Y++)N.__webglFramebuffer[Y]=e.createFramebuffer()}else N.__webglFramebuffer=e.createFramebuffer();if(he)for(let Y=0,te=ie.length;Y<te;Y++){let _e=i.get(ie[Y]);if(_e.__webglTexture===void 0)_e.__webglTexture=e.createTexture(),o.memory.textures++}if(E.samples>0&&D(E)===!1){N.__webglMultisampledFramebuffer=e.createFramebuffer(),N.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let Y=0;Y<ie.length;Y++){let te=ie[Y];N.__webglColorRenderbuffer[Y]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,N.__webglColorRenderbuffer[Y]);let _e=s.convert(te.format,te.colorSpace),Ie=s.convert(te.type),de=y(te.internalFormat,_e,Ie,te.normalized,te.colorSpace,E.isXRRenderTarget===!0),oe=Bt(E);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,de,E.width,E.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Y,e.RENDERBUFFER,N.__webglColorRenderbuffer[Y])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),E.depthBuffer)N.__webglDepthRenderbuffer=e.createRenderbuffer(),Et(N.__webglDepthRenderbuffer,E,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,H.__webglTexture),we(e.TEXTURE_CUBE_MAP,v);for(let Y=0;Y<6;Y++)if(v.mipmaps&&v.mipmaps.length>0)for(let te=0;te<v.mipmaps.length;te++)Ae(N.__webglFramebuffer[Y][te],E,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,te);else Ae(N.__webglFramebuffer[Y],E,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0);if(g(v))S(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(he){for(let Y=0,te=ie.length;Y<te;Y++){let _e=ie[Y],Ie=i.get(_e),de=e.TEXTURE_2D;if(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)de=E.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(de,Ie.__webglTexture),we(de,_e),Ae(N.__webglFramebuffer,E,_e,e.COLOR_ATTACHMENT0+Y,de,0),g(_e))S(de)}n.unbindTexture()}else{let Y=e.TEXTURE_2D;if(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)Y=E.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Y,H.__webglTexture),we(Y,v),v.mipmaps&&v.mipmaps.length>0)for(let te=0;te<v.mipmaps.length;te++)Ae(N.__webglFramebuffer[te],E,v,e.COLOR_ATTACHMENT0,Y,te);else Ae(N.__webglFramebuffer,E,v,e.COLOR_ATTACHMENT0,Y,0);if(g(v))S(Y);n.unbindTexture()}if(E.depthBuffer)Ye(E)}function Jt(E){let v=E.textures;for(let N=0,H=v.length;N<H;N++){let ie=v[N];if(g(ie)){let ae=T(E),he=i.get(ie).__webglTexture;n.bindTexture(ae,he),S(ae),n.unbindTexture()}}}let At=[],mn=[];function kt(E){if(E.samples>0){if(D(E)===!1){let{textures:v,width:N,height:H}=E,ie=e.COLOR_BUFFER_BIT,ae=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,he=i.get(E),Y=v.length>1;if(Y)for(let _e=0;_e<v.length;_e++)n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,he.__webglMultisampledFramebuffer);let te=E.texture.mipmaps;if(te&&te.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer);for(let _e=0;_e<v.length;_e++){if(E.resolveDepthBuffer){if(E.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(E.stencilBuffer&&E.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(Y){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Ie=i.get(v[_e]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ie,0)}if(e.blitFramebuffer(0,0,N,H,0,0,N,H,ie,e.NEAREST),c===!0){if(At.length=0,mn.length=0,At.push(e.COLOR_ATTACHMENT0+_e),E.depthBuffer&&E.storeMultisampledDepthBuffer===!1)At.push(ae),mn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,mn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,At)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),Y)for(let _e=0;_e<v.length;_e++){n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Ie=i.get(v[_e]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,Ie,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.storeMultisampledDepthBuffer===!1&&c){let v=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[v])}}}function Bt(E){return Math.min(r.maxSamples,E.samples)}function D(E){let v=i.get(E);return E.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function gn(E){let v=o.render.frame;if(u.get(E)!==v)u.set(E,v),E.update()}function ct(E,v){let{colorSpace:N,format:H,type:ie}=E;if(E.isCompressedTexture===!0||E.isVideoTexture===!0)return v;if(N!==Sn&&N!==Br)if(je.getTransfer(N)===yt){if(H!==mi||ie!==Qn)Le("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else ke("WebGLTextures: Unsupported texture color space:",N);return v}function Pt(E){if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement)l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height;else if(typeof VideoFrame<"u"&&E instanceof VideoFrame)l.width=E.displayWidth,l.height=E.displayHeight;else l.width=E.width,l.height=E.height;return l}this.allocateTextureUnit=X,this.resetTextureUnits=K,this.getTextureUnits=I,this.setTextureUnits=G,this.setTexture2D=j,this.setTexture2DArray=k,this.setTexture3D=q,this.setTextureCube=Q,this.rebindTextures=ht,this.setupRenderTarget=tt,this.updateRenderTargetMipmap=Jt,this.updateMultisampleRenderTarget=kt,this.setupDepthRenderbuffer=Ye,this.setupFrameBufferTexture=Ae,this.useMultisampledRTT=D,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function vT(e,t){function n(i,r=Br){let s,o=je.getTransfer(r);if(i===Qn)return e.UNSIGNED_BYTE;if(i===uu)return e.UNSIGNED_SHORT_4_4_4_4;if(i===hu)return e.UNSIGNED_SHORT_5_5_5_1;if(i===Xp)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===jp)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===Wp)return e.BYTE;if(i===Zp)return e.SHORT;if(i===bo)return e.UNSIGNED_SHORT;if(i===lu)return e.INT;if(i===hr)return e.UNSIGNED_INT;if(i===Gi)return e.FLOAT;if(i===pi)return e.HALF_FLOAT;if(i===qp)return e.ALPHA;if(i===Yp)return e.RGB;if(i===mi)return e.RGBA;if(i===Fr)return e.DEPTH_COMPONENT;if(i===zr)return e.DEPTH_STENCIL;if(i===Jp)return e.RED;if(i===du)return e.RED_INTEGER;if(i===kr)return e.RG;if(i===fu)return e.RG_INTEGER;if(i===pu)return e.RGBA_INTEGER;if(i===nc||i===ic||i===rc||i===sc)if(o===yt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===nc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===ic)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===rc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===sc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===nc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===ic)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===rc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===sc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===mu||i===gu||i===_u||i===xu)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===mu)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===gu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===_u)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===xu)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===yu||i===vu||i===bu||i===Su||i===Mu||i===oc||i===wu)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===yu||i===vu)return o===yt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===bu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Su)return s.COMPRESSED_R11_EAC;if(i===Mu)return s.COMPRESSED_SIGNED_R11_EAC;if(i===oc)return s.COMPRESSED_RG11_EAC;if(i===wu)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Eu||i===Au||i===Tu||i===Ru||i===Cu||i===Pu||i===Iu||i===Lu||i===Nu||i===Du||i===Ou||i===Uu||i===Fu||i===zu)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Eu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Au)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Tu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Ru)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Cu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Pu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Iu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Lu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Nu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Du)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Ou)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Uu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Fu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===zu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===ku||i===Bu||i===Vu)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===ku)return o===yt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Bu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Vu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Gu||i===Hu||i===ac||i===$u)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===Gu)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Hu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===ac)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===$u)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Cs)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var bT=`void main() {gl_Position = vec4( position, 1.0 );-}`,yT=`+}`,ST=`uniform sampler2DArray depthColor;uniform float depthWidth;uniform float depthHeight;@@ -4341,11 +4341,11 @@ void main() {}-}`;class jm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new _c(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new Bn({vertexShader:xT,fragmentShader:yT,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Mt(new Lo(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class qm extends ei{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,d=null,h=null,f=null,m=typeof XRWebGLBinding<"u",_=new jm,p={},g=t.getContextAttributes(),S=null,T=null,y=[],w=[],A=new Ue,R=null,x=null,M=new Vt;M.viewport=new ft;let z=new Vt;z.viewport=new ft;let C=[M,z],L=new uh,K=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=y[Z];if(re===void 0)re=new wo,y[Z]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=y[Z];if(re===void 0)re=new wo,y[Z]=re;return re.getGripSpace()},this.getHand=function(Z){let re=y[Z];if(re===void 0)re=new wo,y[Z]=re;return re.getHandSpace()};function G(Z){let re=w.indexOf(Z.inputSource);if(re===-1)return;let se=y[re];if(se!==void 0)se.update(Z.inputSource,Z.frame,c||s),se.dispatchEvent({type:Z.type,data:Z.inputSource})}function X(){i.removeEventListener("select",G),i.removeEventListener("selectstart",G),i.removeEventListener("selectend",G),i.removeEventListener("squeeze",G),i.removeEventListener("squeezestart",G),i.removeEventListener("squeezeend",G),i.removeEventListener("end",X),i.removeEventListener("inputsourceschange",P);for(let Z=0;Z<y.length;Z++){let re=w[Z];if(re===null)continue;w[Z]=null,y[Z].disconnect(re)}K=null,I=null,_.reset();for(let Z in p)delete p[Z];if(e.setRenderTarget(S),h=null,d=null,u=null,i=null,T=null,we.stop(),n.isPresenting=!1,e.setPixelRatio(R),e.setSize(A.width,A.height,!1),x!==null){let Z=x.camera;Z.fov=x.fov,Z.zoom=x.zoom,Z.updateProjectionMatrix(),x=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){if(r=Z,n.isPresenting===!0)Le("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){if(o=Z,n.isPresenting===!0)Le("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return d!==null?d:h},this.getBinding=function(){if(u===null&&m)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(Z){if(i=Z,i!==null){if(S=e.getRenderTarget(),i.addEventListener("select",G),i.addEventListener("selectstart",G),i.addEventListener("selectend",G),i.addEventListener("squeeze",G),i.addEventListener("squeezestart",G),i.addEventListener("squeezeend",G),i.addEventListener("end",X),i.addEventListener("inputsourceschange",P),g.xrCompatible!==!0)await t.makeXRCompatible();if(R=e.getPixelRatio(),e.getSize(A),!(m&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:r};h=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),T=new wn(h.framebufferWidth,h.framebufferHeight,{format:mi,type:Qn,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let se=null,xe=null,Ee=null;if(g.depth)Ee=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=g.stencil?zr:Fr,xe=g.stencil?Cs:hr;let Ae={colorFormat:t.RGBA8,depthFormat:Ee,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Ae),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),T=new wn(d.textureWidth,d.textureHeight,{format:mi,type:Qn,depthTexture:new Vr(d.textureWidth,d.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),we.setContext(i),we.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function P(Z){for(let re=0;re<Z.removed.length;re++){let se=Z.removed[re],xe=w.indexOf(se);if(xe>=0)w[xe]=null,y[xe].disconnect(se)}for(let re=0;re<Z.added.length;re++){let se=Z.added[re],xe=w.indexOf(se);if(xe===-1){for(let Ae=0;Ae<y.length;Ae++)if(Ae>=w.length){w.push(se),xe=Ae;break}else if(w[Ae]===null){w[Ae]=se,xe=Ae;break}if(xe===-1)break}let Ee=y[xe];if(Ee)Ee.connect(se)}}let j=new U,k=new U;function q(Z,re,se){j.setFromMatrixPosition(re.matrixWorld),k.setFromMatrixPosition(se.matrixWorld);let xe=j.distanceTo(k),Ee=re.projectionMatrix.elements,Ae=se.projectionMatrix.elements,Et=Ee[14]/(Ee[10]-1),Ge=Ee[14]/(Ee[10]+1),Ye=(Ee[9]+1)/Ee[5],ht=(Ee[9]-1)/Ee[5],nt=(Ee[8]-1)/Ee[0],Jt=(Ae[8]+1)/Ae[0],At=Et*nt,gn=Et*Jt,kt=xe/(-nt+Jt),Bt=kt*-nt;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(Bt),Z.translateZ(kt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Ee[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let D=Et+kt,_n=Ge+kt,ct=At-Bt,Pt=gn+(xe-Bt),E=Ye*Ge/_n*D,v=ht*Ge/_n*D;Z.projectionMatrix.makePerspective(ct,Pt,E,v,D,_n),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}}function Q(Z,re){if(re===null)Z.matrixWorld.copy(Z.matrix);else Z.matrixWorld.multiplyMatrices(re.matrixWorld,Z.matrix);Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(i===null)return;let{near:re,far:se}=Z;if(_.texture!==null){if(_.depthNear>0)re=_.depthNear;if(_.depthFar>0)se=_.depthFar}if(L.near=z.near=M.near=re,L.far=z.far=M.far=se,K!==L.near||I!==L.far)i.updateRenderState({depthNear:L.near,depthFar:L.far}),K=L.near,I=L.far;L.layers.mask=Z.layers.mask|6,M.layers.mask=L.layers.mask&-5,z.layers.mask=L.layers.mask&-3;let xe=Z.parent,Ee=L.cameras;Q(L,xe);for(let Ae=0;Ae<Ee.length;Ae++)Q(Ee[Ae],xe);if(Ee.length===2)q(L,M,z);else L.projectionMatrix.copy(M.projectionMatrix);if(x===null&&Z.isPerspectiveCamera)x={camera:Z,fov:Z.fov,zoom:Z.zoom};Me(Z,L,xe)};function Me(Z,re,se){if(se===null)Z.matrix.copy(re.matrixWorld);else Z.matrix.copy(se.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(re.matrixWorld);if(Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse),Z.isPerspectiveCamera)Z.fov=Dr*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1}this.getCamera=function(){return L},this.getFoveation=function(){if(d===null&&h===null)return;return a},this.setFoveation=function(Z){if(a=Z,d!==null)d.fixedFoveation=Z;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Z},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(L)},this.getCameraTexture=function(Z){return p[Z]};let ue=null;function Be(Z,re){if(l=re.getViewerPose(c||s),f=re,l!==null){let se=l.views;if(h!==null)e.setRenderTargetFramebuffer(T,h.framebuffer),e.setRenderTarget(T);let xe=!1;if(se.length!==L.cameras.length)L.cameras.length=0,xe=!0;for(let Ge=0;Ge<se.length;Ge++){let Ye=se[Ge],ht=null;if(h!==null)ht=h.getViewport(Ye);else{let Jt=u.getViewSubImage(d,Ye);if(ht=Jt.viewport,Ge===0)e.setRenderTargetTextures(T,Jt.colorTexture,Jt.depthStencilTexture),e.setRenderTarget(T)}let nt=C[Ge];if(nt===void 0)nt=new Vt,nt.layers.enable(Ge),nt.viewport=new ft,C[Ge]=nt;if(nt.matrix.fromArray(Ye.transform.matrix),nt.matrix.decompose(nt.position,nt.quaternion,nt.scale),nt.projectionMatrix.fromArray(Ye.projectionMatrix),nt.projectionMatrixInverse.copy(nt.projectionMatrix).invert(),nt.viewport.set(ht.x,ht.y,ht.width,ht.height),Ge===0)L.matrix.copy(nt.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale);if(xe===!0)L.cameras.push(nt)}let Ee=i.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&m){u=n.getBinding();let Ge=u.getDepthInformation(se[0]);if(Ge&&Ge.isValid&&Ge.texture)_.init(Ge,i.renderState)}if(Ee&&Ee.includes("camera-access")&&m){e.state.unbindTexture(),u=n.getBinding();for(let Ge=0;Ge<se.length;Ge++){let Ye=se[Ge].camera;if(Ye){let ht=p[Ye];if(!ht)ht=new _c,p[Ye]=ht;let nt=u.getCameraImage(Ye);ht.sourceTexture=nt}}}}for(let se=0;se<y.length;se++){let xe=w[se],Ee=y[se];if(xe!==null&&Ee!==void 0)Ee.update(xe,re,c||s)}if(ue)ue(Z,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});f=null}let we=new Fm;we.setAnimationLoop(Be),this.setAnimationLoop=function(Z){ue=Z},this.dispose=function(){}}}var vT=new $e,Ym=new Ve;Ym.set(-1,0,0,0,1,0,0,0,1);function bT(e,t){function n(p,g){if(p.matrixAutoUpdate===!0)p.updateMatrix();g.value.copy(p.matrix)}function i(p,g){if(g.color.getRGB(p.fogColor.value,eh(e)),g.isFog)p.fogNear.value=g.near,p.fogFar.value=g.far;else if(g.isFogExp2)p.fogDensity.value=g.density}function r(p,g,S,T,y){if(g.isNodeMaterial)g.uniformsNeedUpdate=!1;else if(g.isMeshBasicMaterial)s(p,g);else if(g.isMeshLambertMaterial){if(s(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshToonMaterial)s(p,g),d(p,g);else if(g.isMeshPhongMaterial){if(s(p,g),u(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshStandardMaterial){if(s(p,g),h(p,g),g.isMeshPhysicalMaterial)f(p,g,y)}else if(g.isMeshMatcapMaterial)s(p,g),m(p,g);else if(g.isMeshDepthMaterial)s(p,g);else if(g.isMeshDistanceMaterial)s(p,g),_(p,g);else if(g.isMeshNormalMaterial)s(p,g);else if(g.isLineBasicMaterial){if(o(p,g),g.isLineDashedMaterial)a(p,g)}else if(g.isPointsMaterial)c(p,g,S,T);else if(g.isSpriteMaterial)l(p,g);else if(g.isShadowMaterial)p.color.value.copy(g.color),p.opacity.value=g.opacity;else if(g.isShaderMaterial)g.uniformsNeedUpdate=!1}function s(p,g){if(p.opacity.value=g.opacity,g.color)p.diffuse.value.copy(g.color);if(g.emissive)p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity);if(g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.bumpMap){if(p.bumpMap.value=g.bumpMap,n(g.bumpMap,p.bumpMapTransform),p.bumpScale.value=g.bumpScale,g.side===sn)p.bumpScale.value*=-1}if(g.normalMap){if(p.normalMap.value=g.normalMap,n(g.normalMap,p.normalMapTransform),p.normalScale.value.copy(g.normalScale),g.side===sn)p.normalScale.value.negate()}if(g.displacementMap)p.displacementMap.value=g.displacementMap,n(g.displacementMap,p.displacementMapTransform),p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias;if(g.emissiveMap)p.emissiveMap.value=g.emissiveMap,n(g.emissiveMap,p.emissiveMapTransform);if(g.specularMap)p.specularMap.value=g.specularMap,n(g.specularMap,p.specularMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest;let S=t.get(g),{envMap:T,envMapRotation:y}=S;if(T){if(p.envMap.value=T,p.envMapRotation.value.setFromMatrix4(vT.makeRotationFromEuler(y)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(Ym);p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio}if(g.lightMap)p.lightMap.value=g.lightMap,p.lightMapIntensity.value=g.lightMapIntensity,n(g.lightMap,p.lightMapTransform);if(g.aoMap)p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity,n(g.aoMap,p.aoMapTransform)}function o(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,g.map)p.map.value=g.map,n(g.map,p.mapTransform)}function a(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function c(p,g,S,T){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*S,p.scale.value=T*0.5,g.map)p.map.value=g.map,n(g.map,p.uvTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function l(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,0.0001)}function d(p,g){if(g.gradientMap)p.gradientMap.value=g.gradientMap}function h(p,g){if(p.metalness.value=g.metalness,g.metalnessMap)p.metalnessMap.value=g.metalnessMap,n(g.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=g.roughness,g.roughnessMap)p.roughnessMap.value=g.roughnessMap,n(g.roughnessMap,p.roughnessMapTransform);if(g.envMap)p.envMapIntensity.value=g.envMapIntensity}function f(p,g,S){if(p.ior.value=g.ior,g.sheen>0){if(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap)p.sheenColorMap.value=g.sheenColorMap,n(g.sheenColorMap,p.sheenColorMapTransform);if(g.sheenRoughnessMap)p.sheenRoughnessMap.value=g.sheenRoughnessMap,n(g.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(g.clearcoat>0){if(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap)p.clearcoatMap.value=g.clearcoatMap,n(g.clearcoatMap,p.clearcoatMapTransform);if(g.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,n(g.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(g.clearcoatNormalMap){if(p.clearcoatNormalMap.value=g.clearcoatNormalMap,n(g.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===sn)p.clearcoatNormalScale.value.negate()}}if(g.dispersion>0)p.dispersion.value=g.dispersion;if(g.retroreflectivity>0)p.retroreflectivity.value=g.retroreflectivity;if(g.iridescence>0){if(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap)p.iridescenceMap.value=g.iridescenceMap,n(g.iridescenceMap,p.iridescenceMapTransform);if(g.iridescenceThicknessMap)p.iridescenceThicknessMap.value=g.iridescenceThicknessMap,n(g.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(g.transmission>0){if(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=S.texture,p.transmissionSamplerSize.value.set(S.width,S.height),g.transmissionMap)p.transmissionMap.value=g.transmissionMap,n(g.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=g.thickness,g.thicknessMap)p.thicknessMap.value=g.thicknessMap,n(g.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)}if(g.anisotropy>0){if(p.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap)p.anisotropyMap.value=g.anisotropyMap,n(g.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularColorMap)p.specularColorMap.value=g.specularColorMap,n(g.specularColorMap,p.specularColorMapTransform);if(g.specularIntensityMap)p.specularIntensityMap.value=g.specularIntensityMap,n(g.specularIntensityMap,p.specularIntensityMapTransform)}function m(p,g){if(g.matcap)p.matcap.value=g.matcap}function _(p,g){let S=t.get(g).light;p.referencePosition.value.setFromMatrixPosition(S.matrixWorld),p.nearDistance.value=S.shadow.camera.near,p.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function ST(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,w){let A=w.program;i.uniformBlockBinding(y,A)}function l(y,w){let A=r[y.id];if(A===void 0)p(y),A=u(y),r[y.id]=A,y.addEventListener("dispose",S);let R=w.program;i.updateUBOMapping(y,R);let x=t.render.frame;if(s[y.id]!==x)h(y),s[y.id]=x}function u(y){let w=d();y.__bindingPointIndex=w;let A=e.createBuffer(),{__size:R,usage:x}=y;return e.bindBuffer(e.UNIFORM_BUFFER,A),e.bufferData(e.UNIFORM_BUFFER,R,x),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,w,A),A}function d(){for(let y=0;y<a;y++)if(o.indexOf(y)===-1)return o.push(y),y;return ke("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(y){let w=r[y.id],{uniforms:A,__cache:R}=y;e.bindBuffer(e.UNIFORM_BUFFER,w);for(let x=0,M=A.length;x<M;x++){let z=A[x];if(Array.isArray(z))for(let C=0,L=z.length;C<L;C++)f(z[C],x,C,R);else f(z,x,0,R)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function f(y,w,A,R){if(_(y,w,A,R)===!0){let{__offset:x,value:M}=y;if(Array.isArray(M)){let z=0;for(let C=0;C<M.length;C++){let L=M[C],K=g(L);if(m(L,y.__data,z),typeof L!=="number"&&typeof L!=="boolean"&&!L.isMatrix3&&!ArrayBuffer.isView(L))z+=K.storage/Float32Array.BYTES_PER_ELEMENT}}else m(M,y.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,x,y.__data)}}function m(y,w,A){if(typeof y==="number"||typeof y==="boolean")w[0]=y;else if(y.isMatrix3)w[0]=y.elements[0],w[1]=y.elements[1],w[2]=y.elements[2],w[3]=0,w[4]=y.elements[3],w[5]=y.elements[4],w[6]=y.elements[5],w[7]=0,w[8]=y.elements[6],w[9]=y.elements[7],w[10]=y.elements[8],w[11]=0;else if(ArrayBuffer.isView(y))w.set(new y.constructor(y.buffer,y.byteOffset,w.length));else y.toArray(w,A)}function _(y,w,A,R){let x=y.value,M=w+"_"+A;if(R[M]===void 0){if(typeof x==="number"||typeof x==="boolean")R[M]=x;else if(ArrayBuffer.isView(x))R[M]=x.slice();else R[M]=x.clone();return!0}else{let z=R[M];if(typeof x==="number"||typeof x==="boolean"){if(z!==x)return R[M]=x,!0}else if(ArrayBuffer.isView(x))return!0;else if(z.equals(x)===!1)return z.copy(x),!0}return!1}function p(y){let w=y.uniforms,A=0,R=16;for(let M=0,z=w.length;M<z;M++){let C=Array.isArray(w[M])?w[M]:[w[M]];for(let L=0,K=C.length;L<K;L++){let I=C[L],G=Array.isArray(I.value)?I.value:[I.value];for(let X=0,P=G.length;X<P;X++){let j=G[X],k=g(j),q=A%R,Q=q%k.boundary,Me=q+Q;if(A+=Q,Me!==0&&R-Me<k.storage)A+=R-Me;I.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=A,A+=k.storage}}}let x=A%R;if(x>0)A+=R-x;return y.__size=A,y.__cache={},this}function g(y){let w={boundary:0,storage:0};if(typeof y==="number"||typeof y==="boolean")w.boundary=4,w.storage=4;else if(y.isVector2)w.boundary=8,w.storage=8;else if(y.isVector3||y.isColor)w.boundary=16,w.storage=12;else if(y.isVector4)w.boundary=16,w.storage=16;else if(y.isMatrix3)w.boundary=48,w.storage=48;else if(y.isMatrix4)w.boundary=64,w.storage=64;else if(y.isTexture)Le("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(y))w.boundary=16,w.storage=y.byteLength;else Le("WebGLRenderer: Unsupported uniform value type.",y);return w}function S(y){let w=y.target;w.removeEventListener("dispose",S);let A=o.indexOf(w.__bindingPointIndex);o.splice(A,1),e.deleteBuffer(r[w.id]),delete r[w.id],delete s[w.id]}function T(){for(let y in r)e.deleteBuffer(r[y]);o=[],r={},s={}}return{bind:c,update:l,dispose:T}}var MT=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),_i=null;function wT(){if(_i===null)_i=new To(MT,16,16,kr,pi),_i.name="DFG_LUT",_i.minFilter=qt,_i.magFilter=qt,_i.wrapS=Ts,_i.wrapT=Ts,_i.generateMipmaps=!1,_i.needsUpdate=!0;return _i}class Ah{constructor(e={}){let{canvas:t=im(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:h=Qn}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=s;let m=h,_=new Set([du,hu,uu]),p=new Set([Qn,hr,vo,Cs,cu,lu]),g=new Uint32Array(4),S=new Int32Array(4),T=new U,y=null,w=null,A=[],R=[],x=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,z=!1,C=null,L=null,K=null,I=null;this._outputColorSpace=dr;let G=0,X=0,P=null,j=-1,k=null,q=new ft,Q=new ft,Me=null,ue=new ze(0),Be=0,{width:we,height:Z}=t,re=1,se=null,xe=null,Ee=new ft(0,0,we,Z),Ae=new ft(0,0,we,Z),Et=!1,Ge=new Co,Ye=!1,ht=!1,nt=new $e,Jt=new U,At=new ft,gn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},kt=!1;function Bt(){return P===null?re:1}let D=n;function _n(b,O){return t.getContext(b,O)}let ct,Pt,E,v,N,H,ie,ae,he,Y,te,_e,Ie,de,oe,De,Fe,st,F,ce,ee,le,ye;try{let b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${lp}`);if(t.addEventListener("webglcontextlost",He,!1),t.addEventListener("webglcontextrestored",bt,!1),t.addEventListener("webglcontextcreationerror",lt,!1),D===null){if(D=_n("webgl2",b),D===null)if(_n("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(b){throw t.removeEventListener("webglcontextlost",He,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",lt,!1),ke("WebGLRenderer: "+b.message),b}function ne(){if(ct=new IE(D),ct.init(),ee=new _T(D,ct),Pt=new bE(D,ct,e,ee),E=new mT(D,ct),Pt.reversedDepthBuffer&&d)E.buffers.depth.setReversed(!0);L=D.createFramebuffer(),K=D.createFramebuffer(),I=D.createFramebuffer(),v=new DE(D),N=new tT,H=new gT(D,ct,E,N,Pt,ee,v),ie=new PE(M),ae=new US(D),le=new yE(D,ae),he=new LE(D,ae,v,le),Y=new UE(D,he,ae,le,v),st=new OE(D,Pt,H),oe=new SE(N),te=new eT(M,ie,ct,Pt,le,oe),_e=new bT(M,N),Ie=new iT,de=new lT(ct),Fe=new xE(M,ie,E,Y,f,a),De=new pT(M,Y,Pt),ye=new ST(D,v,Pt,E),F=new vE(D,ct,v),ce=new NE(D,ct,v),v.programs=te.programs,M.capabilities=Pt,M.extensions=ct,M.properties=N,M.renderLists=Ie,M.shadowMap=De,M.state=E,M.info=v}if(m!==Qn)x=new zE(m,t.width,t.height,o,i,r);let pe=new qm(M,D);this.xr=pe,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){let b=ct.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=ct.get("WEBGL_lose_context");if(b)b.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(b){if(b===void 0)return;re=b,this.setSize(we,Z,!1)},this.getSize=function(b){return b.set(we,Z)},this.setSize=function(b,O,W=!0){if(pe.isPresenting){Le("WebGLRenderer: Can't change size while VR device is presenting.");return}if(we=b,Z=O,t.width=Math.floor(b*re),t.height=Math.floor(O*re),W===!0)t.style.width=b+"px",t.style.height=O+"px";if(x!==null)x.setSize(t.width,t.height);this.setViewport(0,0,b,O)},this.getDrawingBufferSize=function(b){return b.set(we*re,Z*re).floor()},this.setDrawingBufferSize=function(b,O,W){we=b,Z=O,re=W,t.width=Math.floor(b*W),t.height=Math.floor(O*W),this.setViewport(0,0,b,O)},this.setEffects=function(b){if(m===Qn){ke("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let O=0;O<b.length;O++)if(b[O].isOutputPass===!0){Le("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}x.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(q)},this.getViewport=function(b){return b.copy(Ee)},this.setViewport=function(b,O,W,B){if(b.isVector4)Ee.set(b.x,b.y,b.z,b.w);else Ee.set(b,O,W,B);E.viewport(q.copy(Ee).multiplyScalar(re).round())},this.getScissor=function(b){return b.copy(Ae)},this.setScissor=function(b,O,W,B){if(b.isVector4)Ae.set(b.x,b.y,b.z,b.w);else Ae.set(b,O,W,B);E.scissor(Q.copy(Ae).multiplyScalar(re).round())},this.getScissorTest=function(){return Et},this.setScissorTest=function(b){E.setScissorTest(Et=b)},this.setOpaqueSort=function(b){se=b},this.setTransparentSort=function(b){xe=b},this.getClearColor=function(b){return b.copy(Fe.getClearColor())},this.setClearColor=function(){Fe.setClearColor(...arguments)},this.getClearAlpha=function(){return Fe.getClearAlpha()},this.setClearAlpha=function(){Fe.setClearAlpha(...arguments)},this.clear=function(b=!0,O=!0,W=!0){let B=0;if(b){let V=!1;if(P!==null){let ge=P.texture.format;V=_.has(ge)}if(V){let ge=P.texture.type,Se=p.has(ge),me=Fe.getClearColor(),Te=Fe.getClearAlpha(),{r:Pe,g:We,b:Ke}=me;if(Se)g[0]=Pe,g[1]=We,g[2]=Ke,g[3]=Te,D.clearBufferuiv(D.COLOR,0,g);else S[0]=Pe,S[1]=We,S[2]=Ke,S[3]=Te,D.clearBufferiv(D.COLOR,0,S)}else B|=D.COLOR_BUFFER_BIT}if(O)B|=D.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)B|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(B!==0)D.clear(B)},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.setNodesHandler=function(b){b.setRenderer(this),C=b},this.dispose=function(){t.removeEventListener("webglcontextlost",He,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",lt,!1),Fe.dispose(),Ie.dispose(),de.dispose(),N.dispose(),ie.dispose(),Y.dispose(),le.dispose(),ye.dispose(),te.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",_f),pe.removeEventListener("sessionend",xf),Rr.stop()};function He(b){b.preventDefault(),mo("WebGLRenderer: Context Lost."),z=!0}function bt(){mo("WebGLRenderer: Context Restored."),z=!1;let b=v.autoReset,O=De.enabled,W=De.autoUpdate,B=De.needsUpdate,V=De.type;ne(),v.autoReset=b,De.enabled=O,De.autoUpdate=W,De.needsUpdate=B,De.type=V}function lt(b){ke("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function oi(b){let O=b.target;O.removeEventListener("dispose",oi),Di(O)}function Di(b){Ab(b),N.remove(b)}function Ab(b){let O=N.get(b).programs;if(O!==void 0){if(O.forEach(function(W){te.releaseProgram(W)}),b.isShaderMaterial)te.releaseShaderCache(b)}}this.renderBufferDirect=function(b,O,W,B,V,ge){if(O===null)O=gn;let Se=V.isMesh&&V.matrixWorld.determinantAffine()<0,me=Cb(b,O,W,B,V);E.setMaterial(B,Se);let Te=W.index,Pe=1;if(B.wireframe===!0){if(Te=he.getWireframeAttribute(W),Te===void 0)return;Pe=2}let We=W.drawRange,Ke=W.attributes.position,Re=We.start*Pe,ut=(We.start+We.count)*Pe;if(ge!==null)Re=Math.max(Re,ge.start*Pe),ut=Math.min(ut,(ge.start+ge.count)*Pe);if(Te!==null)Re=Math.max(Re,0),ut=Math.min(ut,Te.count);else if(Ke!==void 0&&Ke!==null)Re=Math.max(Re,0),ut=Math.min(ut,Ke.count);let Ft=ut-Re;if(Ft<0||Ft===1/0)return;le.setup(V,B,me,W,Te);let Tt,xt=F;if(Te!==null)Tt=ae.get(Te),xt=ce,xt.setIndex(Tt);if(V.isMesh)if(B.wireframe===!0)E.setLineWidth(B.wireframeLinewidth*Bt()),xt.setMode(D.LINES);else xt.setMode(D.TRIANGLES);else if(V.isLine){let tn=B.linewidth;if(tn===void 0)tn=1;if(E.setLineWidth(tn*Bt()),V.isLineSegments)xt.setMode(D.LINES);else if(V.isLineLoop)xt.setMode(D.LINE_LOOP);else xt.setMode(D.LINE_STRIP)}else if(V.isPoints)xt.setMode(D.POINTS);else if(V.isSprite)xt.setMode(D.TRIANGLES);if(V.isBatchedMesh)if(!ct.get("WEBGL_multi_draw")){let{_multiDrawStarts:tn,_multiDrawCounts:ve,_multiDrawCount:un}=V,it=Te?ae.get(Te).bytesPerElement:1,On=N.get(B).currentProgram.getUniforms();for(let ai=0;ai<un;ai++)On.setValue(D,"_gl_DrawID",ai),xt.render(tn[ai]/it,ve[ai])}else xt.renderMultiDraw(V._multiDrawStarts,V._multiDrawCounts,V._multiDrawCount);else if(V.isInstancedMesh)xt.renderInstances(Re,Ft,V.count);else if(W.isInstancedBufferGeometry){let tn=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,ve=Math.min(W.instanceCount,tn);xt.renderInstances(Re,Ft,ve)}else xt.render(Re,Ft)};function gf(b,O,W,B){if(C!==null&&b.isNodeMaterial)C.setObject(B,b);if(Ye===!0)oe.setState(b,W,!1);if(b.transparent===!0&&b.side===kn&&b.forceSinglePass===!1)b.side=sn,b.needsUpdate=!0,ba(b,O,B),b.side=ur,b.needsUpdate=!0,ba(b,O,B),b.side=kn;else ba(b,O,B)}this.compile=function(b,O,W=null){if(W===null)W=b;if(C!==null)C.renderStart(b,O,W);if(w=de.get(W),w.init(O),R.push(w),W.traverseVisible(function(V){if(V.isLight&&V.layers.test(O.layers)){if(w.pushLight(V),V.castShadow)w.pushShadow(V)}}),b!==W)b.traverseVisible(function(V){if(V.isLight&&V.layers.test(O.layers)){if(w.pushLight(V),V.castShadow)w.pushShadow(V)}});if(w.setupLights(),C!==null)C.updateLights(w.state.lightsArray);if(ht=this.localClippingEnabled,Ye=oe.init(this.clippingPlanes,ht),Ye===!0)oe.setGlobalState(this.clippingPlanes,O);if(C!==null)De.render(w.state.shadowsArray,W,O);let B=new Set;if(b.traverse(function(V){if(!(V.isMesh||V.isPoints||V.isLine||V.isSprite))return;let ge=V.material;if(ge)if(Array.isArray(ge))for(let Se=0;Se<ge.length;Se++){let me=ge[Se];gf(me,W,O,V),B.add(me)}else gf(ge,W,O,V),B.add(ge)}),w=R.pop(),C!==null)C.renderEnd();return B},this.compileAsync=function(b,O,W=null){let B=this.compile(b,O,W);return new Promise((V)=>{function ge(){if(B.forEach(function(Se){let Te=N.get(Se).currentProgram;if(Te===void 0||Te.isReady())B.delete(Se)}),B.size===0){V(b);return}setTimeout(ge,10)}if(ct.get("KHR_parallel_shader_compile")!==null)ge();else setTimeout(ge,10)})};let Ml=null;function Tb(b){if(Ml)Ml(b)}function _f(){Rr.stop()}function xf(){Rr.start()}let Rr=new Fm;if(Rr.setAnimationLoop(Tb),typeof self<"u")Rr.setContext(self);this.setAnimationLoop=function(b){Ml=b,pe.setAnimationLoop(b),b===null?Rr.stop():Rr.start()},pe.addEventListener("sessionstart",_f),pe.addEventListener("sessionend",xf),this.render=function(b,O){if(O!==void 0&&O.isCamera!==!0){ke("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(z===!0)return;if(C!==null)C.renderStart(b,O);let W=pe.enabled===!0&&pe.isPresenting===!0,B=x!==null&&(P===null||W)&&x.begin(M,P);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(O.parent===null&&O.matrixWorldAutoUpdate===!0)O.updateMatrixWorld();if(pe.enabled===!0&&pe.isPresenting===!0&&(x===null||x.isCompositing()===!1)){if(pe.cameraAutoUpdate===!0)pe.updateCamera(O);O=pe.getCamera()}if(b.isScene===!0)b.onBeforeRender(M,b,O,P);if(w=de.get(b,R.length),w.init(O),w.state.textureUnits=H.getTextureUnits(),R.push(w),nt.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),Ge.setFromProjectionMatrix(nt,ju,O.reversedDepth),ht=this.localClippingEnabled,Ye=oe.init(this.clippingPlanes,ht),y=Ie.get(b,A.length),y.init(),A.push(y),pe.enabled===!0&&pe.isPresenting===!0){let Se=M.xr.getDepthSensingMesh();if(Se!==null)wl(Se,O,-1/0,M.sortObjects)}if(wl(b,O,0,M.sortObjects),y.finish(),C!==null)C.updateLights(w.state.lightsArray);if(M.sortObjects===!0)y.sort(se,xe);if(kt=pe.enabled===!1||pe.isPresenting===!1||pe.hasDepthSensing()===!1,kt)Fe.addToRenderList(y,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ye===!0)oe.beginShadows();let V=w.state.shadowsArray;if(De.render(V,b,O),Ye===!0)oe.endShadows();if((B&&x.hasRenderPass())===!1){let Se=y.opaque,me=y.transmissive;if(w.setupLights(),O.isArrayCamera){let Te=O.cameras;if(me.length>0)for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe];vf(Se,me,b,Ke)}if(kt)Fe.render(b);for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe];yf(y,b,Ke,Ke.viewport)}}else{if(me.length>0)vf(Se,me,b,O);if(kt)Fe.render(b);yf(y,b,O)}}if(P!==null&&X===0)H.updateMultisampleRenderTarget(P),H.updateRenderTargetMipmap(P);if(B)x.end(M);if(b.isScene===!0)b.onAfterRender(M,b,O);if(le.resetDefaultState(),j=-1,k=null,R.pop(),R.length>0){if(w=R[R.length-1],H.setTextureUnits(w.state.textureUnits),Ye===!0)oe.setGlobalState(M.clippingPlanes,w.state.camera)}else w=null;if(A.pop(),A.length>0)y=A[A.length-1];else y=null;if(C!==null)C.renderEnd()};function wl(b,O,W,B){if(b.visible===!1)return;if(b.layers.test(O.layers)){if(b.isGroup)W=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(O)}else if(b.isLightProbeGrid)w.pushLightProbeGrid(b);else if(b.isLight){if(w.pushLight(b),b.castShadow)w.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(Ge)){if(B)At.setFromMatrixPosition(b.matrixWorld).applyMatrix4(nt);let Se=Y.update(b),me=b.material;if(me.visible)y.push(b,Se,me,W,At.z,null,O)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(Ge)){let Se=Y.update(b),me=b.material;if(B){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();At.copy(b.boundingSphere.center)}else{if(Se.boundingSphere===null)Se.computeBoundingSphere();At.copy(Se.boundingSphere.center)}At.applyMatrix4(b.matrixWorld).applyMatrix4(nt)}if(Array.isArray(me)){let Te=Se.groups;for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe],Re=me[Ke.materialIndex];if(Re&&Re.visible)y.push(b,Se,Re,W,At.z,Ke,O)}}else if(me.visible)y.push(b,Se,me,W,At.z,null,O)}}}let ge=b.children;for(let Se=0,me=ge.length;Se<me;Se++)wl(ge[Se],O,W,B)}function yf(b,O,W,B){let{opaque:V,transmissive:ge,transparent:Se}=b;if(w.setupLightsView(W),Ye===!0)oe.setGlobalState(M.clippingPlanes,W);if(B)E.viewport(q.copy(B));if(V.length>0)va(V,O,W);if(ge.length>0)va(ge,O,W);if(Se.length>0)va(Se,O,W);E.buffers.depth.setTest(!0),E.buffers.depth.setMask(!0),E.buffers.color.setMask(!0),E.setPolygonOffset(!1)}function vf(b,O,W,B){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[B.id]===void 0){let Re=ct.has("EXT_color_buffer_half_float")||ct.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[B.id]=new wn(1,1,{generateMipmaps:!0,type:Re?pi:Qn,minFilter:fi,samples:Math.max(4,Pt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:je.workingColorSpace})}let ge=w.state.transmissionRenderTarget[B.id],Se=B.viewport||q;ge.setSize(Se.z*M.transmissionResolutionScale,Se.w*M.transmissionResolutionScale);let me=M.getRenderTarget(),Te=M.getActiveCubeFace(),Pe=M.getActiveMipmapLevel();if(M.setRenderTarget(ge),M.getClearColor(ue),Be=M.getClearAlpha(),Be<1)M.setClearColor(16777215,0.5);if(M.clear(),kt)Fe.render(W);let We=M.toneMapping;M.toneMapping=Jn;let Ke=B.viewport;if(B.viewport!==void 0)B.viewport=void 0;if(w.setupLightsView(B),Ye===!0)oe.setGlobalState(M.clippingPlanes,B);if(va(b,W,B),H.updateMultisampleRenderTarget(ge),H.updateRenderTargetMipmap(ge),ct.has("WEBGL_multisampled_render_to_texture")===!1){let Re=!1;for(let ut=0,Ft=O.length;ut<Ft;ut++){let Tt=O[ut],{object:xt,geometry:tn,material:ve,group:un}=Tt;if(ve.side===kn&&xt.layers.test(B.layers)){let it=ve.side;ve.side=sn,ve.needsUpdate=!0,bf(xt,W,B,tn,ve,un),ve.side=it,ve.needsUpdate=!0,Re=!0}}if(Re===!0)H.updateMultisampleRenderTarget(ge),H.updateRenderTargetMipmap(ge)}if(M.setRenderTarget(me,Te,Pe),M.setClearColor(ue,Be),Ke!==void 0)B.viewport=Ke;M.toneMapping=We}function va(b,O,W){let B=O.isScene===!0?O.overrideMaterial:null;for(let V=0,ge=b.length;V<ge;V++){let Se=b[V],{object:me,geometry:Te,group:Pe}=Se,We=Se.material;if(We.allowOverride===!0&&B!==null)We=B;if(me.layers.test(W.layers))bf(me,O,W,Te,We,Pe)}}function bf(b,O,W,B,V,ge){if(C!==null&&V.isNodeMaterial)C.setObject(b,V);if(b.onBeforeRender(M,O,W,B,V,ge),b.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),V.onBeforeRender(M,O,W,B,b,ge),V.transparent===!0&&V.side===kn&&V.forceSinglePass===!1)V.side=sn,V.needsUpdate=!0,M.renderBufferDirect(W,O,B,V,b,ge),V.side=ur,V.needsUpdate=!0,M.renderBufferDirect(W,O,B,V,b,ge),V.side=kn;else M.renderBufferDirect(W,O,B,V,b,ge);b.onAfterRender(M,O,W,B,V,ge)}function ba(b,O,W){if(O.isScene!==!0)O=gn;let B=N.get(b),V=w.state.lights,ge=w.state.shadowsArray,Se=V.state.version,me=te.getParameters(b,V.state,ge,O,W,w.state.lightProbeGridArray),Te=te.getProgramCacheKey(me),Pe=B.programs;B.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?O.environment:null,B.fog=O.fog;let We=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(B.envMap=ie.get(b.envMap||B.environment,We),B.envMapRotation=B.environment!==null&&b.envMap===null?O.environmentRotation:b.envMapRotation,Pe===void 0)b.addEventListener("dispose",oi),Pe=new Map,B.programs=Pe;let Ke=Pe.get(Te);if(Ke!==void 0){if(B.currentProgram===Ke&&B.lightsStateVersion===Se)return Mf(b,me),Ke}else{if(me.uniforms=te.getUniforms(b),C!==null&&b.isNodeMaterial)C.build(b,W,me);b.onBeforeCompile(me,M),Ke=te.acquireProgram(me,Te),Pe.set(Te,Ke),B.uniforms=me.uniforms}let Re=B.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Re.clippingPlanes=oe.uniform;if(Mf(b,me),B.needsLights=Ib(b),B.lightsStateVersion=Se,B.needsLights)Re.ambientLightColor.value=V.state.ambient,Re.lightProbe.value=V.state.probe,Re.sunLights.value=V.state.sun,Re.sunLightShadows.value=V.state.sunShadow,Re.directionalLights.value=V.state.directional,Re.directionalLightShadows.value=V.state.directionalShadow,Re.spotLights.value=V.state.spot,Re.spotLightShadows.value=V.state.spotShadow,Re.rectAreaLights.value=V.state.rectArea,Re.ltc_1.value=V.state.rectAreaLTC1,Re.ltc_2.value=V.state.rectAreaLTC2,Re.pointLights.value=V.state.point,Re.pointLightShadows.value=V.state.pointShadow,Re.hemisphereLights.value=V.state.hemi,Re.sunShadowMatrix.value=V.state.sunShadowMatrix,Re.sunShadowCascade.value=V.state.sunShadowCascade,Re.directionalShadowMatrix.value=V.state.directionalShadowMatrix,Re.spotLightMatrix.value=V.state.spotLightMatrix,Re.spotLightMap.value=V.state.spotLightMap,Re.pointShadowMatrix.value=V.state.pointShadowMatrix;return B.lightProbeGrid=w.state.lightProbeGridArray.length>0,B.currentProgram=Ke,B.uniformsList=null,Ke}function Sf(b){if(b.uniformsList===null){let O=b.currentProgram.getUniforms();b.uniformsList=Bo.seqWithValue(O.seq,b.uniforms)}return b.uniformsList}function Mf(b,O){let W=N.get(b);W.outputColorSpace=O.outputColorSpace,W.batching=O.batching,W.batchingColor=O.batchingColor,W.instancing=O.instancing,W.instancingColor=O.instancingColor,W.instancingMorph=O.instancingMorph,W.skinning=O.skinning,W.morphTargets=O.morphTargets,W.morphNormals=O.morphNormals,W.morphColors=O.morphColors,W.morphTargetsCount=O.morphTargetsCount,W.numClippingPlanes=O.numClippingPlanes,W.numIntersection=O.numClipIntersection,W.vertexAlphas=O.vertexAlphas,W.vertexTangents=O.vertexTangents,W.toneMapping=O.toneMapping}function Rb(b,O){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;T.setFromMatrixPosition(O.matrixWorld);for(let W=0,B=b.length;W<B;W++){let V=b[W];if(V.texture!==null&&V.boundingBox.containsPoint(T))return V}return null}function Cb(b,O,W,B,V){if(O.isScene!==!0)O=gn;H.resetTextureUnits();let ge=O.fog,Se=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?O.environment:null,me=P===null?M.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:je.workingColorSpace,Te=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Pe=ie.get(B.envMap||Se,Te),We=B.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,Ke=!!W.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Re=!!W.morphAttributes.position,ut=!!W.morphAttributes.normal,Ft=!!W.morphAttributes.color,Tt=Jn;if(B.toneMapped){if(P===null||P.isXRRenderTarget===!0)Tt=M.toneMapping}let xt=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,tn=xt!==void 0?xt.length:0,ve=N.get(B),un=w.state.lights;if(Ye===!0){if(ht===!0||b!==k){let St=b===k&&B.id===j;oe.setState(B,b,St)}}let it=!1;if(B.version===ve.__version){if(ve.needsLights&&ve.lightsStateVersion!==un.state.version)it=!0;else if(ve.outputColorSpace!==me)it=!0;else if(V.isBatchedMesh&&ve.batching===!1)it=!0;else if(!V.isBatchedMesh&&ve.batching===!0)it=!0;else if(V.isBatchedMesh&&ve.batchingColor===!0&&V._colorsTexture===null)it=!0;else if(V.isBatchedMesh&&ve.batchingColor===!1&&V._colorsTexture!==null)it=!0;else if(V.isInstancedMesh&&ve.instancing===!1)it=!0;else if(!V.isInstancedMesh&&ve.instancing===!0)it=!0;else if(V.isSkinnedMesh&&ve.skinning===!1)it=!0;else if(!V.isSkinnedMesh&&ve.skinning===!0)it=!0;else if(V.isInstancedMesh&&ve.instancingColor===!0&&V.instanceColor===null)it=!0;else if(V.isInstancedMesh&&ve.instancingColor===!1&&V.instanceColor!==null)it=!0;else if(V.isInstancedMesh&&ve.instancingMorph===!0&&V.morphTexture===null)it=!0;else if(V.isInstancedMesh&&ve.instancingMorph===!1&&V.morphTexture!==null)it=!0;else if(ve.envMap!==Pe)it=!0;else if(B.fog===!0&&ve.fog!==ge)it=!0;else if(ve.numClippingPlanes!==void 0&&(ve.numClippingPlanes!==oe.numPlanes||ve.numIntersection!==oe.numIntersection))it=!0;else if(ve.vertexAlphas!==We)it=!0;else if(ve.vertexTangents!==Ke)it=!0;else if(ve.morphTargets!==Re)it=!0;else if(ve.morphNormals!==ut)it=!0;else if(ve.morphColors!==Ft)it=!0;else if(ve.toneMapping!==Tt)it=!0;else if(ve.morphTargetsCount!==tn)it=!0;else if(!!ve.lightProbeGrid!==w.state.lightProbeGridArray.length>0)it=!0}else it=!0,ve.__version=B.version;let On=ve.currentProgram;if(it===!0){if(On=ba(B,O,V),C&&B.isNodeMaterial)C.onUpdateProgram(B,On,ve)}let ai=!1,Ki=!1,is=!1,mt=On.getUniforms(),Ot=ve.uniforms;if(E.useProgram(On.program))ai=!0,Ki=!0,is=!0;if(B.id!==j)j=B.id,Ki=!0;if(ve.needsLights){let St=Rb(w.state.lightProbeGridArray,V);if(ve.lightProbeGrid!==St)ve.lightProbeGrid=St,Ki=!0}if(ai||k!==b){if(E.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();mt.setValue(D,"projectionMatrix",b.projectionMatrix),mt.setValue(D,"viewMatrix",b.matrixWorldInverse);let er=mt.map.cameraPosition;if(er!==void 0)er.setValue(D,Jt.setFromMatrixPosition(b.matrixWorld));if(Pt.logarithmicDepthBuffer)mt.setValue(D,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)mt.setValue(D,"isOrthographic",b.isOrthographicCamera===!0);if(k!==b)k=b,Ki=!0,is=!0}if(ve.needsLights){if(un.state.sunShadowMap.length>0)mt.setValue(D,"sunShadowMap",un.state.sunShadowMap,H);if(un.state.directionalShadowMap.length>0)mt.setValue(D,"directionalShadowMap",un.state.directionalShadowMap,H);if(un.state.spotShadowMap.length>0)mt.setValue(D,"spotShadowMap",un.state.spotShadowMap,H);if(un.state.pointShadowMap.length>0)mt.setValue(D,"pointShadowMap",un.state.pointShadowMap,H)}if(V.isSkinnedMesh){mt.setOptional(D,V,"bindMatrix"),mt.setOptional(D,V,"bindMatrixInverse");let St=V.skeleton;if(St){if(St.boneTexture===null)St.computeBoneTexture();mt.setValue(D,"boneTexture",St.boneTexture,H)}}if(V.isBatchedMesh){if(mt.setOptional(D,V,"batchingTexture"),mt.setValue(D,"batchingTexture",V._matricesTexture,H),mt.setOptional(D,V,"batchingIdTexture"),mt.setValue(D,"batchingIdTexture",V._indirectTexture,H),mt.setOptional(D,V,"batchingColorTexture"),V._colorsTexture!==null)mt.setValue(D,"batchingColorTexture",V._colorsTexture,H)}let Qi=W.morphAttributes;if(Qi.position!==void 0||Qi.normal!==void 0||Qi.color!==void 0)st.update(V,W,On);if(Ki||ve.receiveShadow!==V.receiveShadow)ve.receiveShadow=V.receiveShadow,mt.setValue(D,"receiveShadow",V.receiveShadow);if((B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&O.environment!==null)Ot.envMapIntensity.value=O.environmentIntensity;if(Ot.dfgLUT!==void 0)Ot.dfgLUT.value=wT();if(Ki){if(mt.setValue(D,"toneMappingExposure",M.toneMappingExposure),ve.needsLights)Pb(Ot,is);if(ge&&B.fog===!0)_e.refreshFogUniforms(Ot,ge);if(_e.refreshMaterialUniforms(Ot,B,re,Z,w.state.transmissionRenderTarget[b.id]),ve.needsLights&&ve.lightProbeGrid){let St=ve.lightProbeGrid;Ot.probesSH.value=St.texture,Ot.probesMin.value.copy(St.boundingBox.min),Ot.probesMax.value.copy(St.boundingBox.max),Ot.probesResolution.value.copy(St.resolution)}Bo.upload(D,Sf(ve),Ot,H)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0)Bo.upload(D,Sf(ve),Ot,H),B.uniformsNeedUpdate=!1;if(B.isSpriteMaterial)mt.setValue(D,"center",V.center);if(mt.setValue(D,"modelViewMatrix",V.modelViewMatrix),mt.setValue(D,"normalMatrix",V.normalMatrix),mt.setValue(D,"modelMatrix",V.matrixWorld),B.uniformsGroups!==void 0){let St=B.uniformsGroups;for(let er=0,rs=St.length;er<rs;er++){let Ef=St[er];ye.update(Ef,On),ye.bind(Ef,On)}}return On}function Pb(b,O){b.ambientLightColor.needsUpdate=O,b.lightProbe.needsUpdate=O,b.sunLights.needsUpdate=O,b.sunLightShadows.needsUpdate=O,b.directionalLights.needsUpdate=O,b.directionalLightShadows.needsUpdate=O,b.pointLights.needsUpdate=O,b.pointLightShadows.needsUpdate=O,b.spotLights.needsUpdate=O,b.spotLightShadows.needsUpdate=O,b.rectAreaLights.needsUpdate=O,b.hemisphereLights.needsUpdate=O}function Ib(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(b,O,W){let B=N.get(b);if(B.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1)B.__useRenderToTexture=!1;N.get(b.texture).__webglTexture=O,N.get(b.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:W,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,O){let W=N.get(b);W.__webglFramebuffer=O,W.__useDefaultFramebuffer=O===void 0},this.setRenderTarget=function(b,O=0,W=0){P=b,G=O,X=W;let B=null,V=!1,ge=!1;if(b){let me=N.get(b);if(me.__useDefaultFramebuffer!==void 0){E.bindFramebuffer(D.FRAMEBUFFER,me.__webglFramebuffer),q.copy(b.viewport),Q.copy(b.scissor),Me=b.scissorTest,E.viewport(q),E.scissor(Q),E.setScissorTest(Me),j=-1;return}else if(me.__webglFramebuffer===void 0)H.setupRenderTarget(b);else if(me.__hasExternalTextures)H.rebindTextures(b,N.get(b.texture).__webglTexture,N.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let We=b.depthTexture;if(me.__boundDepthTexture!==We){if(We!==null&&N.has(We)&&(b.width!==We.image.width||b.height!==We.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");H.setupDepthRenderbuffer(b)}}let Te=b.texture;if(Te.isData3DTexture||Te.isDataArrayTexture||Te.isCompressedArrayTexture)ge=!0;let Pe=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Pe[O]))B=Pe[O][W];else B=Pe[O];V=!0}else if(b.samples>0&&H.useMultisampledRTT(b)===!1)B=N.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Pe))B=Pe[W];else B=Pe;q.copy(b.viewport),Q.copy(b.scissor),Me=b.scissorTest}else q.copy(Ee).multiplyScalar(re).floor(),Q.copy(Ae).multiplyScalar(re).floor(),Me=Et;if(W!==0)B=L;if(E.bindFramebuffer(D.FRAMEBUFFER,B))E.drawBuffers(b,B);if(E.viewport(q),E.scissor(Q),E.setScissorTest(Me),V){let me=N.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+O,me.__webglTexture,W)}else if(ge){let me=O;for(let Te=0;Te<b.textures.length;Te++){let Pe=N.get(b.textures[Te]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+Te,Pe.__webglTexture,W,me)}}else if(b!==null&&W!==0){let me=N.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,me.__webglTexture,W)}j=-1};function wf(b){let O=N.get(b);if(O.__readFormat!==b.format||O.__readType!==b.type)O.__readFormat=b.format,O.__readType=b.type,O.__formatReadable=Pt.textureFormatReadable(b.format),O.__typeReadable=Pt.textureTypeReadable(b.type);return O}if(this.readRenderTargetPixels=function(b,O,W,B,V,ge,Se,me=0){if(!(b&&b.isWebGLRenderTarget)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Te=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Se!==void 0)Te=Te[Se];if(Te){E.bindFramebuffer(D.FRAMEBUFFER,Te);try{let Pe=b.textures[me],{format:We,type:Ke}=Pe;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+me);let Re=wf(Pe);if(Re.__formatReadable===!1){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Re.__typeReadable===!1){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(O>=0&&O<=b.width-B&&(W>=0&&W<=b.height-V))D.readPixels(O,W,B,V,ee.convert(We),ee.convert(Ke),ge)}finally{let Pe=P!==null?N.get(P).__webglFramebuffer:null;E.bindFramebuffer(D.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(b,O,W,B,V,ge,Se,me=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Te=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Se!==void 0)Te=Te[Se];if(Te)if(O>=0&&O<=b.width-B&&(W>=0&&W<=b.height-V)){E.bindFramebuffer(D.FRAMEBUFFER,Te);let Pe=b.textures[me],{format:We,type:Ke}=Pe;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+me);let Re=wf(Pe);if(Re.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Re.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let ut=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,ut),D.bufferData(D.PIXEL_PACK_BUFFER,ge.byteLength,D.STREAM_READ),D.readPixels(O,W,B,V,ee.convert(We),ee.convert(Ke),0),D.bindBuffer(D.PIXEL_PACK_BUFFER,null);let Ft=P!==null?N.get(P).__webglFramebuffer:null;E.bindFramebuffer(D.FRAMEBUFFER,Ft);let Tt=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await sm(D,Tt,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,ut),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,ge),D.bindBuffer(D.PIXEL_PACK_BUFFER,null),D.deleteBuffer(ut),D.deleteSync(Tt),ge}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,O=null,W=0){let B=Math.pow(2,-W),V=Math.floor(b.image.width*B),ge=Math.floor(b.image.height*B),Se=O!==null?O.x:0,me=O!==null?O.y:0;H.setTexture2D(b,0),D.copyTexSubImage2D(D.TEXTURE_2D,W,0,0,Se,me,V,ge),E.unbindTexture()},this.copyTextureToTexture=function(b,O,W=null,B=null,V=0,ge=0){let Se,me,Te,Pe,We,Ke,Re,ut,Ft,Tt=b.isCompressedTexture?b.mipmaps[ge]:b.image;if(W!==null)Se=W.max.x-W.min.x,me=W.max.y-W.min.y,Te=W.isBox3?W.max.z-W.min.z:1,Pe=W.min.x,We=W.min.y,Ke=W.isBox3?W.min.z:0;else{let Ot=Math.pow(2,-V);if(Se=Math.floor(Tt.width*Ot),me=Math.floor(Tt.height*Ot),b.isDataArrayTexture)Te=Tt.depth;else if(b.isData3DTexture)Te=Math.floor(Tt.depth*Ot);else Te=1;Pe=0,We=0,Ke=0}if(B!==null)Re=B.x,ut=B.y,Ft=B.z;else Re=0,ut=0,Ft=0;let xt=ee.convert(O.format),tn=ee.convert(O.type),ve;if(O.isData3DTexture)H.setTexture3D(O,0),ve=D.TEXTURE_3D;else if(O.isDataArrayTexture||O.isCompressedArrayTexture)H.setTexture2DArray(O,0),ve=D.TEXTURE_2D_ARRAY;else H.setTexture2D(O,0),ve=D.TEXTURE_2D;E.activeTexture(D.TEXTURE0),E.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,O.flipY),E.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),E.pixelStorei(D.UNPACK_ALIGNMENT,O.unpackAlignment);let un=E.getParameter(D.UNPACK_ROW_LENGTH),it=E.getParameter(D.UNPACK_IMAGE_HEIGHT),On=E.getParameter(D.UNPACK_SKIP_PIXELS),ai=E.getParameter(D.UNPACK_SKIP_ROWS),Ki=E.getParameter(D.UNPACK_SKIP_IMAGES);E.pixelStorei(D.UNPACK_ROW_LENGTH,Tt.width),E.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Tt.height),E.pixelStorei(D.UNPACK_SKIP_PIXELS,Pe),E.pixelStorei(D.UNPACK_SKIP_ROWS,We),E.pixelStorei(D.UNPACK_SKIP_IMAGES,Ke);let is=b.isDataArrayTexture||b.isData3DTexture,mt=O.isDataArrayTexture||O.isData3DTexture;if(b.isDepthTexture){let Ot=N.get(b),Qi=N.get(O),St=N.get(Ot.__renderTarget),er=N.get(Qi.__renderTarget);E.bindFramebuffer(D.READ_FRAMEBUFFER,St.__webglFramebuffer),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,er.__webglFramebuffer);for(let rs=0;rs<Te;rs++){if(is)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,N.get(b).__webglTexture,V,Ke+rs),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,N.get(O).__webglTexture,ge,Ft+rs);D.blitFramebuffer(Pe,We,Se,me,Re,ut,Se,me,D.DEPTH_BUFFER_BIT,D.NEAREST)}E.bindFramebuffer(D.READ_FRAMEBUFFER,null),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(V!==0||b.isRenderTargetTexture||N.has(b)){let Ot=N.get(b),Qi=N.get(O);E.bindFramebuffer(D.READ_FRAMEBUFFER,K),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,I);for(let St=0;St<Te;St++){if(is)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Ot.__webglTexture,V,Ke+St);else D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Ot.__webglTexture,V);if(mt)D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Qi.__webglTexture,ge,Ft+St);else D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Qi.__webglTexture,ge);if(V!==0)D.blitFramebuffer(Pe,We,Se,me,Re,ut,Se,me,D.COLOR_BUFFER_BIT,D.NEAREST);else if(mt)D.copyTexSubImage3D(ve,ge,Re,ut,Ft+St,Pe,We,Se,me);else D.copyTexSubImage2D(ve,ge,Re,ut,Pe,We,Se,me)}E.bindFramebuffer(D.READ_FRAMEBUFFER,null),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(mt)if(b.isDataTexture||b.isData3DTexture)D.texSubImage3D(ve,ge,Re,ut,Ft,Se,me,Te,xt,tn,Tt.data);else if(O.isCompressedArrayTexture)D.compressedTexSubImage3D(ve,ge,Re,ut,Ft,Se,me,Te,xt,Tt.data);else D.texSubImage3D(ve,ge,Re,ut,Ft,Se,me,Te,xt,tn,Tt);else if(b.isDataTexture)D.texSubImage2D(D.TEXTURE_2D,ge,Re,ut,Se,me,xt,tn,Tt.data);else if(b.isCompressedTexture)D.compressedTexSubImage2D(D.TEXTURE_2D,ge,Re,ut,Tt.width,Tt.height,xt,Tt.data);else D.texSubImage2D(D.TEXTURE_2D,ge,Re,ut,Se,me,xt,tn,Tt);if(E.pixelStorei(D.UNPACK_ROW_LENGTH,un),E.pixelStorei(D.UNPACK_IMAGE_HEIGHT,it),E.pixelStorei(D.UNPACK_SKIP_PIXELS,On),E.pixelStorei(D.UNPACK_SKIP_ROWS,ai),E.pixelStorei(D.UNPACK_SKIP_IMAGES,Ki),ge===0&&O.generateMipmaps)D.generateMipmap(ve);E.unbindTexture()},this.initRenderTarget=function(b){if(N.get(b).__webglFramebuffer===void 0)H.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)H.setTextureCube(b,0);else if(b.isData3DTexture)H.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)H.setTexture2DArray(b,0);else H.setTexture2D(b,0);E.unbindTexture()},this.resetState=function(){G=0,X=0,P=null,E.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ju}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=je._getDrawingBufferColorSpace(e),t.unpackColorSpace=je._getUnpackColorSpace()}}var Km={type:"change"},Rh={type:"start"},eg={type:"end"},Ic=new fr,Qm=new Fn,ET=Math.cos(70*So.DEG2RAD),Wt=new U,vn=2*Math.PI,pt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Th=0.000001;class Ch extends Ac{constructor(e,t=null){super(e,t);if(this.state=pt.NONE,this.target=new U,this.cursor=new U,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:cr.ROTATE,MIDDLE:cr.DOLLY,RIGHT:cr.PAN},this.touches={ONE:lr.ROTATE,TWO:lr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new U,this._lastQuaternion=new Xt,this._lastTargetPosition=new U,this._quat=new Xt().setFromUnitVectors(e.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Uo,this._sphericalDelta=new Uo,this._scale=1,this._panOffset=new U,this._rotateStart=new Ue,this._rotateEnd=new Ue,this._rotateDelta=new Ue,this._panStart=new Ue,this._panEnd=new Ue,this._panDelta=new Ue,this._dollyStart=new Ue,this._dollyEnd=new Ue,this._dollyDelta=new Ue,this._dollyDirection=new U,this._mouse=new Ue,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=TT.bind(this),this._onPointerDown=AT.bind(this),this._onPointerUp=RT.bind(this),this._onContextMenu=OT.bind(this),this._onMouseWheel=IT.bind(this),this._onKeyDown=LT.bind(this),this._onTouchStart=NT.bind(this),this._onTouchMove=DT.bind(this),this._onMouseDown=CT.bind(this),this._onMouseMove=PT.bind(this),this._interceptControlDown=UT.bind(this),this._interceptControlUp=FT.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=pt.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Km),this.update(),this.state=pt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Wt.copy(t).sub(this.target),Wt.applyQuaternion(this._quat),this._spherical.setFromVector3(Wt),this.autoRotate&&this.state===pt.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=vn;else if(n>Math.PI)n-=vn;if(i<-Math.PI)i+=vn;else if(i>Math.PI)i-=vn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(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);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(Wt.setFromSpherical(this._spherical),Wt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Wt),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);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let o=Wt.length();s=this._clampDistance(o*this._scale);let a=o-s;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),r=!!a}else if(this.object.isOrthographicCamera){let o=new U(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=a!==this.object.zoom;let c=new U(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Wt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if(Ic.origin.copy(this.object.position),Ic.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ic.direction))<ET)this.object.lookAt(this.target);else Qm.setFromNormalAndCoplanarPoint(this.object.up,this.target),Ic.intersectPlane(Qm,this.target)}else if(this.object.isOrthographicCamera){let s=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom)this.object.updateProjectionMatrix(),r=!0}if(this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Th||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Th||this._lastTargetPosition.distanceToSquared(this.target)>Th)return this.dispatchEvent(Km),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(e){if(e!==null)return vn/60*this.autoRotateSpeed*e;else return vn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Wt.setFromMatrixColumn(t,0),Wt.multiplyScalar(-e),this._panOffset.add(Wt)}_panUp(e,t){if(this.screenSpacePanning===!0)Wt.setFromMatrixColumn(t,1);else Wt.setFromMatrixColumn(t,0),Wt.crossVectors(this.object.up,Wt);Wt.multiplyScalar(e),this._panOffset.add(Wt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Wt.copy(i).sub(this.target);let r=Wt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:o}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(vn*this._rotateDelta.x/t.clientHeight),this._rotateUp(vn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){if(this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){if(this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0)this._dollyIn(this._getZoomScale(e.deltaY));else if(e.deltaY>0)this._dollyOut(this._getZoomScale(e.deltaY));this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(vn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);t=!0;break;case this.keys.BOTTOM:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(-vn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);t=!0;break;case this.keys.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(vn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);t=!0;break;case this.keys.RIGHT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(-vn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);t=!0;break}if(t)e.preventDefault(),this.update()}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enablePan)this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enableRotate)this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=0.5*(e.pageX+n.x),r=0.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(vn*this._rotateDelta.x/t.clientHeight),this._rotateUp(vn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Ue,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function AT(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function TT(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function RT(e){switch(this._removePointer(e),this._pointers.length){case 0:if(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(eg),this.state=pt.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function CT(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case cr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=pt.DOLLY;break;case cr.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=pt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=pt.ROTATE}break;case cr.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=pt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=pt.PAN}break;default:this.state=pt.NONE}if(this.state!==pt.NONE)this.dispatchEvent(Rh)}function PT(e){switch(this.state){case pt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case pt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case pt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function IT(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==pt.NONE)return;e.preventDefault(),this.dispatchEvent(Rh),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(eg)}function LT(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function NT(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case lr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=pt.TOUCH_ROTATE;break;case lr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=pt.TOUCH_PAN;break;default:this.state=pt.NONE}break;case 2:switch(this.touches.TWO){case lr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=pt.TOUCH_DOLLY_PAN;break;case lr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=pt.TOUCH_DOLLY_ROTATE;break;default:this.state=pt.NONE}break;default:this.state=pt.NONE}if(this.state!==pt.NONE)this.dispatchEvent(Rh)}function DT(e){switch(this._trackPointer(e),this.state){case pt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case pt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case pt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case pt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=pt.NONE}}function OT(e){if(this.enabled===!1)return;e.preventDefault()}function UT(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function FT(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class Ph extends Is{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new mr;e.deleteAttribute("uv");let t=new Hi({side:sn}),n=new Hi,i=new Fs(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new Mt(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new Ns(e,n,6),o=new gt;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new Mt(e,Gs(50));a.position.set(-16.116,14.37,8.208),a.scale.set(0.1,2.428,2.739),this.add(a);let c=new Mt(e,Gs(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new Mt(e,Gs(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new Mt(e,Gs(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let d=new Mt(e,Gs(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,0.1),this.add(d);let h=new Mt(e,Gs(100));h.position.set(0,20,0),h.scale.set(1,0.1,1),this.add(h)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function Gs(e){return new xc({color:0,emissive:16777215,emissiveIntensity:e})}function Ih(e,t){if(t===$u)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Ps||t===bo){let n=e.getIndex();if(n===null){let s=[],o=e.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)s.push(a);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===Ps)for(let s=1;s<=i;s++)r.push(n.getX(0)),r.push(n.getX(s)),r.push(n.getX(s+1));else for(let s=0;s<i;s++)if(s%2===0)r.push(n.getX(s)),r.push(n.getX(s+1)),r.push(n.getX(s+2));else r.push(n.getX(s+2)),r.push(n.getX(s+1)),r.push(n.getX(s));if(r.length/3!==i)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(r),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function tg(e){let t=new Map,n=new Map,i=e.clone();return ng(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,o=t.get(r),a=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=a.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function ng(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)ng(e.children[i],t.children[i],n)}class zh extends Wi{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new ug(t)}),this.register(function(t){return new hg(t)}),this.register(function(t){return new vg(t)}),this.register(function(t){return new bg(t)}),this.register(function(t){return new Sg(t)}),this.register(function(t){return new fg(t)}),this.register(function(t){return new pg(t)}),this.register(function(t){return new mg(t)}),this.register(function(t){return new gg(t)}),this.register(function(t){return new lg(t)}),this.register(function(t){return new _g(t)}),this.register(function(t){return new dg(t)}),this.register(function(t){return new yg(t)}),this.register(function(t){return new xg(t)}),this.register(function(t){return new ag(t)}),this.register(function(t){return new Oh(t,Je.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Oh(t,Je.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Mg(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=vr.extractUrlBase(e);s=vr.resolveURL(c,this.path)}else s=vr.extractUrlBase(e);this.manager.itemStart(e);let o=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},a=new Do(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},o)}catch(l){o(l)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){if(this.pluginCallbacks.indexOf(e)===-1)this.pluginCallbacks.push(e);return this}unregister(e){if(this.pluginCallbacks.indexOf(e)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1);return this}parse(e,t,n,i){let r,s={},o={},a=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===wg){try{s[Je.KHR_BINARY_GLTF]=new Eg(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Je.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new Pg(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],d=r.extensionsRequired||[];switch(u){case Je.KHR_MATERIALS_UNLIT:s[u]=new cg;break;case Je.KHR_DRACO_MESH_COMPRESSION:s[u]=new Ag(r,this.dracoLoader);break;case Je.KHR_TEXTURE_TRANSFORM:s[u]=new Tg;break;case Je.KHR_MESH_QUANTIZATION:s[u]=new Rg;break;default:if(d.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function zT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function Ut(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Je={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ag{constructor(e){this.parser=e,this.name=Je.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new ze(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],Mn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new zs(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Fs(l),c.distance=u;break;case"spot":c=new Mc(l),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}if(c.position.set(0,0,0),yi(c,a),a.intensity!==void 0)c.intensity=a.intensity;return c.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;if(o===void 0)return null;return this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class cg{constructor(){this.name=Je.KHR_MATERIALS_UNLIT}getMaterialType(){return gi}extendParams(e,t,n){let i=[];e.color=new ze(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],Mn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,dr))}return Promise.all(i)}}class lg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class ug{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ue(r,r)}}return Promise.all(i)}}class hg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class dg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class fg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SHEEN}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new ze(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],Mn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,dr));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class pg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class mg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_VOLUME}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new ze().setRGB(r[0],r[1],r[2],Mn),Promise.all(i)}}class gg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IOR}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class _g{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new ze().setRGB(r[0],r[1],r[2],Mn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,dr));return Promise.all(i)}}class xg{constructor(e){this.parser=e,this.name=Je.EXT_MATERIALS_BUMP}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class yg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?An:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class vg{constructor(e){this.parser=e,this.name=Je.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class bg{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Sg{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Oh{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,d=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,d,i.mode,i.filter).then(function(h){return h.buffer});else return s.ready.then(function(){let h=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(h),l,u,d,i.mode,i.filter),h})})}else return null}}class Mg{constructor(e){this.name=Je.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==Vn.TRIANGLES&&c.mode!==Vn.TRIANGLE_STRIP&&c.mode!==Vn.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],d=c[0].count,h=[];for(let f of u){let m=new $e,_=new U,p=new Xt,g=new U(1,1,1),S=new Ns(f.geometry,f.material,d);for(let y=0;y<d;y++){if(a.TRANSLATION)_.fromBufferAttribute(a.TRANSLATION,y);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,y);if(a.SCALE)g.fromBufferAttribute(a.SCALE,y);S.setMatrixAt(y,m.compose(_,p,g))}let T=null;for(let y in a)if(y==="_COLOR_0"){let w=a[y];S.instanceColor=new ar(w.array,w.itemSize,w.normalized)}else if(y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"){if(T===null){let A=S.geometry;T=new on,T.name=A.name;for(let R in A.attributes)T.setAttribute(R,A.attributes[R]);for(let R in A.morphAttributes)T.morphAttributes[R]=A.morphAttributes[R];if(A.index!==null)T.setIndex(A.index);T.morphTargetsRelative=A.morphTargetsRelative;for(let R of A.groups)T.addGroup(R.start,R.count,R.materialIndex);if(A.boundingBox!==null)T.boundingBox=A.boundingBox.clone();if(A.boundingSphere!==null)T.boundingSphere=A.boundingSphere.clone();T.drawRange.start=A.drawRange.start,T.drawRange.count=A.drawRange.count,T.userData=Object.assign({},A.userData),S.geometry=T}let w=a[y];T.setAttribute(y,new ar(w.array,w.itemSize,w.normalized))}gt.prototype.copy.call(S,f),this.parser.assignFinalMaterial(S),h.push(S)}if(l.isGroup)return l.clear(),l.add(...h),l;return h[0]})}}var wg="glTF",Go=12,ig={JSON:1313821514,BIN:5130562};class Eg{constructor(e){this.name=Je.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Go),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==wg)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-Go,r=new DataView(e,Go),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===ig.JSON){let c=new Uint8Array(e,Go+s,o);this.content=n.decode(c)}else if(a===ig.BIN){let c=Go+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Ag{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Je.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=Uh[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=Uh[l]||l.toLowerCase();if(s[l]!==void 0){let d=n.accessors[e.attributes[l]],h=Hs[d.componentType];c[u]=h.name,a[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,d){i.decodeDracoFile(l,function(h){for(let f in h.attributes){let m=h.attributes[f],_=a[f];if(_!==void 0)m.normalized=_}u(h)},o,c,Mn,d)})})}}class Tg{constructor(){this.name=Je.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class Rg{constructor(){this.name=Je.KHR_MESH_QUANTIZATION}}class kh extends $i{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,d=u*u,h=d*u,f=e*c,m=f-c,_=-2*h+3*d,p=h-d,g=1-_,S=p-d+u;for(let T=0;T!==o;T++){let y=s[m+T+o],w=s[m+T+a]*l,A=s[f+T+o],R=s[f+T]*l;r[T]=g*y+S*w+_*A+p*R}return r}}var kT=new Xt;class Cg extends kh{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return kT.fromArray(r).normalize().toArray(r),r}}var Vn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Hs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},rg={9728:Kn,9729:qt,9984:Qa,9985:Rs,9986:Ur,9987:fi},sg={33071:Ts,33648:Ka,10497:As},Lh={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Uh={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},br={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},BT={CUBICSPLINE:void 0,LINEAR:oc,STEP:Hu},Nh={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function VT(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new Hi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ur});return e.DefaultMaterial}function Zr(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function yi(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function GT(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let d=t[l];if(d.POSITION!==void 0)i=!0;if(d.NORMAL!==void 0)r=!0;if(d.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let d=t[l];if(i){let h=d.POSITION!==void 0?n.getDependency("accessor",d.POSITION):e.attributes.position;o.push(h)}if(r){let h=d.NORMAL!==void 0?n.getDependency("accessor",d.NORMAL):e.attributes.normal;a.push(h)}if(s){let h=d.COLOR_0!==void 0?n.getDependency("accessor",d.COLOR_0):e.attributes.color;c.push(h)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],d=l[1],h=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=d;if(s)e.morphAttributes.color=h;return e.morphTargetsRelative=!0,e})}function HT(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++)e.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function $T(e){let t,n=e.extensions&&e.extensions[Je.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Dh(n.attributes);else t=e.indices+":"+Dh(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Dh(e.targets[i]);return t}function Dh(e){let t="",n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function Fh(e){switch(e){case Int8Array:return 0.007874015748031496;case Uint8Array:return 0.00392156862745098;case Int16Array:return 0.00003051850947599719;case Uint16Array:return 0.000015259021896696422;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function WT(e){if(e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0)return"image/webp";if(e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var ZT=new $e;class Pg{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new zT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;let a=o.match(/Version\/(\d+)/);i=n&&a?parseInt(a[1],10):-1,r=o.indexOf("Firefox")>-1,s=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new Os(this.options.manager);else this.textureLoader=new wc(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Do(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let o={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return Zr(r,o,i),yi(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Je.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(vr.resolveURL(t.uri,i.path),r,void 0,function(){s(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let s=Lh[i.type],o=Hs[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new jt(c,s,a))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let o=s[0],a=Lh[i.type],c=Hs[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,d=i.byteOffset||0,h=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0,m,_;if(h&&h!==u){let p=Math.floor(d/h),g="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,S=t.cache.get(g);if(!S)m=new c(o,p*h,i.count*h/l),S=new Eo(m,h/l),t.cache.add(g,S);_=new Ls(S,a,d%h/l,f)}else{if(o===null)m=new c(i.count*a);else m=new c(o,d,i.count*a);_=new jt(m,a,f)}if(i.sparse!==void 0){let p=Lh.SCALAR,g=Hs[i.sparse.indices.componentType],S=i.sparse.indices.byteOffset||0,T=i.sparse.values.byteOffset||0,y=new g(s[1],S,i.sparse.count*p),w=new c(s[2],T,i.sparse.count*a);if(o!==null)_=new jt(_.array.slice(),_.itemSize,_.normalized);_.normalized=!1;for(let A=0,R=y.length;A<R;A++){let x=y[A];if(_.setX(x,w[A*a]),a>=2)_.setY(x,w[A*a+1]);if(a>=3)_.setZ(x,w[A*a+2]);if(a>=4)_.setW(x,w[A*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}_.normalized=f}return _})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let d=(r.samplers||{})[s.sampler]||{};return l.magFilter=rg[d.magFilter]||qt,l.minFilter=rg[d.minFilter]||fi,l.wrapS=sg[d.wrapS]||As,l.wrapT=sg[d.wrapT]||As,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Kn&&l.minFilter!==qt,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let d=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(d),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(d,h){let f=d;if(t.isImageBitmapLoader===!0)f=function(m){let _=new Nt(m);_.needsUpdate=!0,d(_)};t.load(vr.resolveURL(u,r.path),f,void 0,h)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return yi(u,s),u.userData.mimeType=s.mimeType||WT(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[Je.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Je.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Je.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new Io,yn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(o,a);n=a}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new Po,yn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return Hi}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Je.KHR_MATERIALS_UNLIT]){let u=i[Je.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new ze(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let d=u.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],Mn),o.opacity=d[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,dr));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=kn;let l=r.alphaMode||Nh.OPAQUE;if(l===Nh.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===Nh.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==gi){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ue(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==gi){if(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)o.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==gi){let u=r.emissiveFactor;o.emissive=new ze().setRGB(u[0],u[1],u[2],Mn)}if(r.emissiveTexture!==void 0&&s!==gi)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,dr));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(yi(u,r),t.associations.set(u,{materials:e}),r.extensions)Zr(i,u,r);return u})}createUniqueName(e){let t=ot.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Je.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return og(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=$T(c),u=i[l];if(u)s.push(u.promise);else{let d;if(c.extensions&&c.extensions[Je.KHR_DRACO_MESH_COMPRESSION])d=r(c);else d=og(new on,c,t);if(c.mode===Vn.TRIANGLE_STRIP)d=d.then((h)=>Ih(h,bo));else if(c.mode===Vn.TRIANGLE_FAN)d=d.then((h)=>Ih(h,Ps));i[l]={primitive:c,promise:d},s.push(d)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?VT(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let h=0,f=l.length;h<f;h++){let m=l[h],_=s[h],p,g=c[h];if(_.mode===Vn.TRIANGLES||_.mode===Vn.TRIANGLE_STRIP||_.mode===Vn.TRIANGLE_FAN||_.mode===void 0){let S=r.isSkinnedMesh===!0,T=m.hasAttribute("skinIndex")&&m.hasAttribute("skinWeight");if(S&&T===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=S&&T?new fc(m,g):new Mt(m,g),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(_.mode===Vn.LINES)p=new pc(m,g);else if(_.mode===Vn.LINE_STRIP)p=new pr(m,g);else if(_.mode===Vn.LINE_LOOP)p=new mc(m,g);else if(_.mode===Vn.POINTS)p=new Ds(m,g);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);if(Object.keys(p.geometry.morphAttributes).length>0)HT(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),yi(p,r),_.extensions)Zr(i,p,_);t.assignFinalMaterial(p),u.push(p)}for(let h=0,f=u.length;h<f;h++)t.associations.set(u[h],{meshes:e,primitives:h});if(u.length===1){if(r.extensions)Zr(i,u[0],r);return u[0]}let d=new li;if(r.extensions)Zr(i,d,r);t.associations.set(d,{meshes:e});for(let h=0,f=u.length;h<f;h++)d.add(u[h]);return d})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Vt(So.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new $r(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return yi(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let d=new $e;if(r!==null)d.fromArray(r.array,c*16);a.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Ro(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,d=i.channels.length;u<d;u++){let h=i.channels[u],f=i.samplers[h.sampler],m=h.target,_=m.node,p=i.parameters!==void 0?i.parameters[f.input]:f.input,g=i.parameters!==void 0?i.parameters[f.output]:f.output;if(m.node===void 0)continue;s.push(this.getDependency("node",_)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",g)),c.push(f),l.push(m)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let d=u[0],h=u[1],f=u[2],m=u[3],_=u[4],p=[];for(let S=0,T=d.length;S<T;S++){let y=d[S],w=h[S],A=f[S],R=m[S],x=_[S];if(y===void 0)continue;if(y.updateMatrix)y.updateMatrix();let M=n._createAnimationTracks(y,w,A,R,x);if(M)for(let z=0;z<M.length;z++)p.push(M[z])}let g=new Ss(r,void 0,p);return yi(g,i),g})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],d=c[2];if(d!==null)l.traverse(function(h){if(!h.isSkinnedMesh)return;h.bind(d,ZT)});for(let h=0,f=u.length;h<f;h++)l.add(u[h]);if(l.userData.pivot!==void 0&&u.length>0){let h=l.userData.pivot,f=u[0];l.pivot=new U().fromArray(h),l.position.x-=h[0],l.position.y-=h[1],l.position.z-=h[2],f.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new Ao;else if(c.length>1)l=new li;else if(c.length===1)l=c[0];else l=new gt;if(l!==c[0])for(let u=0,d=c.length;u<d;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(yi(l,r),r.extensions)Zr(n,l,r);if(r.matrix!==void 0){let u=new $e;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new li;if(n.name)r.name=i.createUniqueName(n.name);if(yi(r,n),n.extensions)Zr(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let d=a[l];if(d.parent!==null)r.add(tg(d));else r.add(d)}let c=(l)=>{let u=new Map;for(let[d,h]of i.associations)if(d instanceof yn||d instanceof Nt)u.set(d,h);return l.traverse((d)=>{let h=i.associations.get(d);if(h!=null)u.set(d,h)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(h){if(h.morphTargetInfluences)a.push(h.name?h.name:h.uuid)}if(br[r.path]===br.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(br[r.path]){case br.weights:l=_r;break;case br.rotation:l=xr;break;case br.translation:case br.scale:l=Hr;break;default:switch(n.itemSize){case 1:l=_r;break;case 2:case 3:default:l=Hr;break}break}let u=i.interpolation!==void 0?BT[i.interpolation]:oc,d=this._getArrayFromAccessor(n);for(let h=0,f=a.length;h<f;h++){let m=new l(a[h]+"."+br[r.path],t.array,d,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(m);s.push(m)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=Fh(t.constructor),i=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof xr?Cg:kh)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function XT(e,t,n){let i=t.attributes,r=new Gt;if(i.POSITION!==void 0){let a=n.json.accessors[i.POSITION],{min:c,max:l}=a;if(c!==void 0&&l!==void 0){if(r.set(new U(c[0],c[1],c[2]),new U(l[0],l[1],l[2])),a.normalized){let u=Fh(Hs[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new U,c=new U;for(let l=0,u=s.length;l<u;l++){let d=s[l];if(d.POSITION!==void 0){let h=n.json.accessors[d.POSITION],{min:f,max:m}=h;if(f!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),h.normalized){let _=Fh(Hs[h.componentType]);c.multiplyScalar(_)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new En;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function og(e,t,n){let i=t.attributes,r=[];function s(o,a){return n.getDependency("accessor",o).then(function(c){e.setAttribute(a,c)})}for(let o in i){let a=Uh[o]||o.toLowerCase();if(a in e.attributes)continue;r.push(s(i[o],a))}if(t.indices!==void 0&&!e.index){let o=n.getDependency("accessor",t.indices).then(function(a){e.setIndex(a)});r.push(o)}if(je.workingColorSpace!==Mn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${je.workingColorSpace}" not supported.`);return yi(e,t),XT(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?GT(e,t.targets,n):e})}function $o(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function Vh(e,t="|"){return e.map((n)=>$h(n)).join(t)}function Wo(e,t){if(typeof t==="bigint")return t.toString();return t}class Ig{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function Zo(e){return new Ig(e)}function Lg(e){return e===null||e===void 0}function Mr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Ng(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function Gn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Xo(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Zi(e){return Xo(e._zod.def)??e._zod.def.shape}function Dg(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Gn(this,t,i),i},enumerable:!0,configurable:!0})}function Og(e,t,n){if(t in e)Gn(e,t,n);else e[t]=n}function Xr(e,t,n,i){let r=Zi(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)Dg(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else Og(e,s,i?i(o.value,s):o.value)}}function jT(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)Dg(e,n,()=>t[n]);else Og(e,n,i.value)}}function Rn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function Ug(e){return JSON.stringify(e)}function Fg(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Gh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function $s(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var zg=Zo(()=>{if(dn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function jr(e){if($s(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if($s(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Hh(e){if(jr(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var kg=new Set(["string","number","symbol"]),Bg=new Set(["string","number","bigint","boolean","symbol","undefined"]);function ji(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vi(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function Ce(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function $h(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Vg(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Lc=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Wh={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function qT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return Xr(s,e,Nc(e,t)),vi(e,Rn(n,{shape:s,checks:[]}))}function Nc(e,t){let n=Zi(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function YT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Nc(e,t)),o={};return Xr(o,e,Reflect.ownKeys(Zi(e)).filter((a)=>!s.has(a))),vi(e,Rn(n,{shape:o,checks:[]}))}function JT(e,t){if(!jr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Zi(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return vi(e,Rn(e._zod.def,{shape:Gg(e,t)}))}function Gg(e,t){let n={};return Xr(n,e,Reflect.ownKeys(Zi(e))),jT(n,t),n}function KT(e,t){if(!jr(t))throw Error("Invalid input to safeExtend: expected a plain object");return vi(e,Rn(e._zod.def,{shape:Gg(e,t)}))}function QT(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Xr(n,e,Reflect.ownKeys(Zi(e))),Xr(n,t,Reflect.ownKeys(Zi(t)));let i=Rn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return vi(e,i)}function Hg(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let a=n?new Set(Nc(t,n)):void 0,c={};return Xr(c,t,Reflect.ownKeys(Zi(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),vi(t,Rn(t._zod.def,{shape:c,checks:[]}))}function e1(e,t,n){let i=n?new Set(Nc(t,n)):void 0,r={};return Xr(r,t,Reflect.ownKeys(Zi(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),vi(t,Rn(t._zod.def,{shape:r}))}function Hn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function $g(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function bi(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Ho(e){return typeof e==="string"?e:e?.message}function Zh(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function Si(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:Ho(e.inst?._zod.def?.error?.(e))??Ho(s?.(e))??Ho(t?.error?.(e))??Ho(n.customError?.(e))??Ho(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=e.input;return a}var t1=/[\uD800-\uDBFF]/;function Dc(e){let t=e.length;if(!t1.test(e))return t;let n=t;for(let i=0;i<t-1;i++)if((e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320)n--,i++;return n}function Oc(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Wg(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function qr(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function Zg(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else n1(e,n,i.value)}}function Xi(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function Uc(e,t,n){return Xi(e,t,n,!1)}function Xg(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Xi(this,n,i(this))},set(r){Xi(this,n,r)}})}return t}function n1(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Xi(this,t,n.bind(this))},set(i){Xi(this,t,i)}})}function i1(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Bh,Sr=!1,r1={configurable:!0,get(){Sr=!0;return}};function at(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&Bh!==e._zod){Bh=void 0;return}Bh=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,r1);let r=Sr;Sr=!1;try{let s=n(this);if(Sr)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Sr=Sr||r,s}catch(s){throw delete this[t],Sr=Sr||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function s1(e,t,n,i){let r=i1(e,t);if(!r)return;Object.defineProperty(r,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:s})}})}var o1="~constantCatch";function jg(e){let t=()=>e;return t[o1]=!0,t}var qg;var Xh={value:void 0,enumerable:!1},Yg="captureStackTrace"in Error?Error:null;function a1(e){let t=Yg;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Yg=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function J(e,t,n,i){let r={};function s(h){this.def=h,this.constr=d,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(h,f){if(!h._zod){Xh.value=new s(f);try{Object.defineProperty(h,"_zod",Xh)}finally{Xh.value=void 0}}else if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,f),a){let _=Object.getPrototypeOf(h),p=h._zod.constr.prototype,g=_;while(g&&g!==p)g=Object.getPrototypeOf(g);let S=g??_;if(!a.has(S))a.add(S),Zg(S,o)}let m=d.prototype;for(let _ in m){if(!Object.prototype.hasOwnProperty.call(m,_))continue;if(!(_ in h))h[_]=m[_].bind(h)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(h){let f=i?.Parent?a1(u):this;c(f,h);let m=f._zod.deferred;if(m){for(let p of m)p();f._zod.deferred=void 0}let _=globalThis.__zod_globalConfig?.postProcessor;if(_)_(f);return f}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:(h)=>{if(i?.Parent&&h instanceof i.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(d,"name",{value:e}),d}class Mi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class jo extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(qg=globalThis).__zod_globalConfig??(qg.__zod_globalConfig={});var dn=globalThis.__zod_globalConfig;function Cn(e){if(e)Object.assign(dn,e);return dn}function c1(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Wo,2)),e.message}function l1(e){this._zod.message=e}var u1={get:c1,set:l1,enumerable:!0,configurable:!0},qh={value:void 0,enumerable:!1},Jg=new WeakSet([Object.prototype,Error.prototype]),Kg=(e,t)=>{e.name="$ZodError",qh.value=t,Object.defineProperty(e,"issues",qh),qh.value=void 0,Object.defineProperty(e,"message",u1);let n=Object.getPrototypeOf(e);if(!Jg.has(n))Jg.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}})},Qg=J("$ZodError",Kg),NN=J("$ZodError",Kg,void 0,{Parent:Error});function h1(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function e_(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)h1(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function t_(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],d=l===a.length-1;if(u==="_errors"){if(d)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=c[u];if(d)h._errors.push(t(o));c=h,l++}}}};return i(e),n}function Fc(e,t){return{callee:t?.callee??e,Err:t?.Err}}var zc=(e)=>{let t=(n,i,r,s)=>{let o=r?{...r,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new Mi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Si(l,o,Cn())));throw Gh(c,s?.callee??t),c}return a.value};return t};var kc=(e)=>{let t=async(n,i,r,s)=>{let o=r?{...r,async:!0}:{async:!0},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Si(l,o,Cn())));throw Gh(c,s?.callee??t),c}return a.value};return t};var Bc=(e)=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new Mi;return s.issues.length?n_(e,s.issues,r):{success:!0,data:s.value}};function n_(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>Si(r,n,Cn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Vc=(e)=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?n_(e,s.issues,r):{success:!0,data:s.value}};var d1=Symbol.for("zod.compile.invalid"),f1=Symbol.for("zod.compile.fallback"),Yh=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==d1)return!0;if(i.definite===!0&&n===void 0)return!1}return p1(e,t,n)};function p1(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[f1]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Mi;return s.issues.length===0}var Jh=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)r=await r;return r.issues.length===0},i_=(e)=>{let t=zc(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,Fc(n,o))};return n};var r_=(e)=>{let t=zc(e),n=(i,r,s,o)=>t(i,r,s,Fc(n,o));return n};var s_=(e)=>{let t=kc(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,Fc(n,o))};return n};var o_=(e)=>{let t=kc(e),n=async(i,r,s,o)=>await t(i,r,s,Fc(n,o));return n};var a_=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Bc(e)(t,n,r)};var c_=(e)=>(t,n,i)=>Bc(e)(t,n,i);var l_=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Vc(e)(t,n,r)};var u_=(e)=>async(t,n,i)=>Vc(e)(t,n,i);var h_=/^[cC][0-9a-z]{6,}$/,d_=/^[0-9a-z]+$/,f_=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,p_=/^[0-9a-vA-V]{20}$/,m_=/^[A-Za-z0-9]{27}$/,g_=/^[a-zA-Z0-9_-]{21}$/;function __(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var x_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var y_=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Qh=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var v_=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var m1="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function b_(){return new RegExp(m1,"u")}var S_=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,M_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var w_=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,E_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,A_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,T_=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var R_=/^https?$/,C_=/^\+[1-9]\d{6,14}$/;var P_="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function g1(e){return new RegExp(`^${e}$`)}var I_=g1(P_);function Kh(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function L_(e){return new RegExp(`^${Kh(e)}$`)}function N_(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Kh({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Kh({precision:e.precision})}`:n;return new RegExp(`^${P_}T(?:${i})$`)}var D_=/^[\s\S]{0,}$/,O_=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Gc=/^-?\d+$/,Ws=/^-?\d+(?:\.\d+)?$/,U_=/^(?:true|false)$/i;var F_=/^[^A-Z]*$/,z_=/^[^a-z]*$/;var Kt=J("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var ed=(e)=>{let t=e.value;return!Lg(t)&&t.length!==void 0},Hc={number:"number",bigint:"bigint",object:"date"},td=J("$ZodCheckLessThan",(e,t)=>{Kt.init(e,t);let n=Hc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:Hc[typeof i.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),nd=J("$ZodCheckGreaterThan",(e,t)=>{Kt.init(e,t);let n=Hc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:Hc[typeof i.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),k_=J("$ZodCheckMultipleOf",(e,t)=>{Kt.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Ng(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),B_=J("$ZodCheckNumberFormat",(e,t)=>{Kt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Lc[t.format];e._zod.check=(o)=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(a<r)o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(a>s)o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var V_=J("$ZodCheckMaxLength",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=ed),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Dc(r):s)<=t.maximum)return;let a=Oc(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),G_=J("$ZodCheckMinLength",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=ed),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Dc(r):s)>=t.minimum)return;let a=Oc(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),H_=J("$ZodCheckLengthEquals",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=ed),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?Dc(r):s;if(o===t.length)return;let a=Oc(r),c=o>t.length;i.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),Yo=J("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Kt.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),$_=J("$ZodCheckRegex",(e,t)=>{Yo.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),W_=J("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=F_),Yo.init(e,t)}),Z_=J("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=z_),Yo.init(e,t)}),X_=J("$ZodCheckIncludes",(e,t)=>{Kt.init(e,t);let n=ji(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),j_=J("$ZodCheckStartsWith",(e,t)=>{Kt.init(e,t);let n=new RegExp(`^${ji(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),q_=J("$ZodCheckEndsWith",(e,t)=>{Kt.init(e,t);let n=new RegExp(`.*${ji(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var Y_=J("$ZodCheckOverwrite",(e,t)=>{Kt.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class id{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`+}`;class Ym{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new yc(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new Bn({vertexShader:bT,fragmentShader:ST,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Mt(new No(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Jm extends ei{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,d=null,h=null,f=null,m=typeof XRWebGLBinding<"u",_=new Ym,p={},g=t.getContextAttributes(),S=null,T=null,y=[],w=[],A=new Ue,R=null,x=null,M=new Vt;M.viewport=new ft;let z=new Vt;z.viewport=new ft;let C=[M,z],L=new dh,K=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=y[Z];if(re===void 0)re=new Eo,y[Z]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=y[Z];if(re===void 0)re=new Eo,y[Z]=re;return re.getGripSpace()},this.getHand=function(Z){let re=y[Z];if(re===void 0)re=new Eo,y[Z]=re;return re.getHandSpace()};function G(Z){let re=w.indexOf(Z.inputSource);if(re===-1)return;let se=y[re];if(se!==void 0)se.update(Z.inputSource,Z.frame,c||s),se.dispatchEvent({type:Z.type,data:Z.inputSource})}function X(){i.removeEventListener("select",G),i.removeEventListener("selectstart",G),i.removeEventListener("selectend",G),i.removeEventListener("squeeze",G),i.removeEventListener("squeezestart",G),i.removeEventListener("squeezeend",G),i.removeEventListener("end",X),i.removeEventListener("inputsourceschange",P);for(let Z=0;Z<y.length;Z++){let re=w[Z];if(re===null)continue;w[Z]=null,y[Z].disconnect(re)}K=null,I=null,_.reset();for(let Z in p)delete p[Z];if(e.setRenderTarget(S),h=null,d=null,u=null,i=null,T=null,we.stop(),n.isPresenting=!1,e.setPixelRatio(R),e.setSize(A.width,A.height,!1),x!==null){let Z=x.camera;Z.fov=x.fov,Z.zoom=x.zoom,Z.updateProjectionMatrix(),x=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){if(r=Z,n.isPresenting===!0)Le("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){if(o=Z,n.isPresenting===!0)Le("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return d!==null?d:h},this.getBinding=function(){if(u===null&&m)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(Z){if(i=Z,i!==null){if(S=e.getRenderTarget(),i.addEventListener("select",G),i.addEventListener("selectstart",G),i.addEventListener("selectend",G),i.addEventListener("squeeze",G),i.addEventListener("squeezestart",G),i.addEventListener("squeezeend",G),i.addEventListener("end",X),i.addEventListener("inputsourceschange",P),g.xrCompatible!==!0)await t.makeXRCompatible();if(R=e.getPixelRatio(),e.getSize(A),!(m&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:r};h=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),T=new Mn(h.framebufferWidth,h.framebufferHeight,{format:mi,type:Qn,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let se=null,xe=null,Ee=null;if(g.depth)Ee=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=g.stencil?zr:Fr,xe=g.stencil?Cs:hr;let Ae={colorFormat:t.RGBA8,depthFormat:Ee,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Ae),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),T=new Mn(d.textureWidth,d.textureHeight,{format:mi,type:Qn,depthTexture:new Vr(d.textureWidth,d.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),we.setContext(i),we.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function P(Z){for(let re=0;re<Z.removed.length;re++){let se=Z.removed[re],xe=w.indexOf(se);if(xe>=0)w[xe]=null,y[xe].disconnect(se)}for(let re=0;re<Z.added.length;re++){let se=Z.added[re],xe=w.indexOf(se);if(xe===-1){for(let Ae=0;Ae<y.length;Ae++)if(Ae>=w.length){w.push(se),xe=Ae;break}else if(w[Ae]===null){w[Ae]=se,xe=Ae;break}if(xe===-1)break}let Ee=y[xe];if(Ee)Ee.connect(se)}}let j=new U,k=new U;function q(Z,re,se){j.setFromMatrixPosition(re.matrixWorld),k.setFromMatrixPosition(se.matrixWorld);let xe=j.distanceTo(k),Ee=re.projectionMatrix.elements,Ae=se.projectionMatrix.elements,Et=Ee[14]/(Ee[10]-1),Ge=Ee[14]/(Ee[10]+1),Ye=(Ee[9]+1)/Ee[5],ht=(Ee[9]-1)/Ee[5],tt=(Ee[8]-1)/Ee[0],Jt=(Ae[8]+1)/Ae[0],At=Et*tt,mn=Et*Jt,kt=xe/(-tt+Jt),Bt=kt*-tt;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(Bt),Z.translateZ(kt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Ee[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let D=Et+kt,gn=Ge+kt,ct=At-Bt,Pt=mn+(xe-Bt),E=Ye*Ge/gn*D,v=ht*Ge/gn*D;Z.projectionMatrix.makePerspective(ct,Pt,E,v,D,gn),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}}function Q(Z,re){if(re===null)Z.matrixWorld.copy(Z.matrix);else Z.matrixWorld.multiplyMatrices(re.matrixWorld,Z.matrix);Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(i===null)return;let{near:re,far:se}=Z;if(_.texture!==null){if(_.depthNear>0)re=_.depthNear;if(_.depthFar>0)se=_.depthFar}if(L.near=z.near=M.near=re,L.far=z.far=M.far=se,K!==L.near||I!==L.far)i.updateRenderState({depthNear:L.near,depthFar:L.far}),K=L.near,I=L.far;L.layers.mask=Z.layers.mask|6,M.layers.mask=L.layers.mask&-5,z.layers.mask=L.layers.mask&-3;let xe=Z.parent,Ee=L.cameras;Q(L,xe);for(let Ae=0;Ae<Ee.length;Ae++)Q(Ee[Ae],xe);if(Ee.length===2)q(L,M,z);else L.projectionMatrix.copy(M.projectionMatrix);if(x===null&&Z.isPerspectiveCamera)x={camera:Z,fov:Z.fov,zoom:Z.zoom};Me(Z,L,xe)};function Me(Z,re,se){if(se===null)Z.matrix.copy(re.matrixWorld);else Z.matrix.copy(se.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(re.matrixWorld);if(Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse),Z.isPerspectiveCamera)Z.fov=Dr*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1}this.getCamera=function(){return L},this.getFoveation=function(){if(d===null&&h===null)return;return a},this.setFoveation=function(Z){if(a=Z,d!==null)d.fixedFoveation=Z;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Z},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(L)},this.getCameraTexture=function(Z){return p[Z]};let ue=null;function Be(Z,re){if(l=re.getViewerPose(c||s),f=re,l!==null){let se=l.views;if(h!==null)e.setRenderTargetFramebuffer(T,h.framebuffer),e.setRenderTarget(T);let xe=!1;if(se.length!==L.cameras.length)L.cameras.length=0,xe=!0;for(let Ge=0;Ge<se.length;Ge++){let Ye=se[Ge],ht=null;if(h!==null)ht=h.getViewport(Ye);else{let Jt=u.getViewSubImage(d,Ye);if(ht=Jt.viewport,Ge===0)e.setRenderTargetTextures(T,Jt.colorTexture,Jt.depthStencilTexture),e.setRenderTarget(T)}let tt=C[Ge];if(tt===void 0)tt=new Vt,tt.layers.enable(Ge),tt.viewport=new ft,C[Ge]=tt;if(tt.matrix.fromArray(Ye.transform.matrix),tt.matrix.decompose(tt.position,tt.quaternion,tt.scale),tt.projectionMatrix.fromArray(Ye.projectionMatrix),tt.projectionMatrixInverse.copy(tt.projectionMatrix).invert(),tt.viewport.set(ht.x,ht.y,ht.width,ht.height),Ge===0)L.matrix.copy(tt.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale);if(xe===!0)L.cameras.push(tt)}let Ee=i.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&m){u=n.getBinding();let Ge=u.getDepthInformation(se[0]);if(Ge&&Ge.isValid&&Ge.texture)_.init(Ge,i.renderState)}if(Ee&&Ee.includes("camera-access")&&m){e.state.unbindTexture(),u=n.getBinding();for(let Ge=0;Ge<se.length;Ge++){let Ye=se[Ge].camera;if(Ye){let ht=p[Ye];if(!ht)ht=new yc,p[Ye]=ht;let tt=u.getCameraImage(Ye);ht.sourceTexture=tt}}}}for(let se=0;se<y.length;se++){let xe=w[se],Ee=y[se];if(xe!==null&&Ee!==void 0)Ee.update(xe,re,c||s)}if(ue)ue(Z,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});f=null}let we=new km;we.setAnimationLoop(Be),this.setAnimationLoop=function(Z){ue=Z},this.dispose=function(){}}}var MT=new $e,Km=new Ve;Km.set(-1,0,0,0,1,0,0,0,1);function wT(e,t){function n(p,g){if(p.matrixAutoUpdate===!0)p.updateMatrix();g.value.copy(p.matrix)}function i(p,g){if(g.color.getRGB(p.fogColor.value,nh(e)),g.isFog)p.fogNear.value=g.near,p.fogFar.value=g.far;else if(g.isFogExp2)p.fogDensity.value=g.density}function r(p,g,S,T,y){if(g.isNodeMaterial)g.uniformsNeedUpdate=!1;else if(g.isMeshBasicMaterial)s(p,g);else if(g.isMeshLambertMaterial){if(s(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshToonMaterial)s(p,g),d(p,g);else if(g.isMeshPhongMaterial){if(s(p,g),u(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshStandardMaterial){if(s(p,g),h(p,g),g.isMeshPhysicalMaterial)f(p,g,y)}else if(g.isMeshMatcapMaterial)s(p,g),m(p,g);else if(g.isMeshDepthMaterial)s(p,g);else if(g.isMeshDistanceMaterial)s(p,g),_(p,g);else if(g.isMeshNormalMaterial)s(p,g);else if(g.isLineBasicMaterial){if(o(p,g),g.isLineDashedMaterial)a(p,g)}else if(g.isPointsMaterial)c(p,g,S,T);else if(g.isSpriteMaterial)l(p,g);else if(g.isShadowMaterial)p.color.value.copy(g.color),p.opacity.value=g.opacity;else if(g.isShaderMaterial)g.uniformsNeedUpdate=!1}function s(p,g){if(p.opacity.value=g.opacity,g.color)p.diffuse.value.copy(g.color);if(g.emissive)p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity);if(g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.bumpMap){if(p.bumpMap.value=g.bumpMap,n(g.bumpMap,p.bumpMapTransform),p.bumpScale.value=g.bumpScale,g.side===rn)p.bumpScale.value*=-1}if(g.normalMap){if(p.normalMap.value=g.normalMap,n(g.normalMap,p.normalMapTransform),p.normalScale.value.copy(g.normalScale),g.side===rn)p.normalScale.value.negate()}if(g.displacementMap)p.displacementMap.value=g.displacementMap,n(g.displacementMap,p.displacementMapTransform),p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias;if(g.emissiveMap)p.emissiveMap.value=g.emissiveMap,n(g.emissiveMap,p.emissiveMapTransform);if(g.specularMap)p.specularMap.value=g.specularMap,n(g.specularMap,p.specularMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest;let S=t.get(g),{envMap:T,envMapRotation:y}=S;if(T){if(p.envMap.value=T,p.envMapRotation.value.setFromMatrix4(MT.makeRotationFromEuler(y)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(Km);p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio}if(g.lightMap)p.lightMap.value=g.lightMap,p.lightMapIntensity.value=g.lightMapIntensity,n(g.lightMap,p.lightMapTransform);if(g.aoMap)p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity,n(g.aoMap,p.aoMapTransform)}function o(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,g.map)p.map.value=g.map,n(g.map,p.mapTransform)}function a(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function c(p,g,S,T){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*S,p.scale.value=T*0.5,g.map)p.map.value=g.map,n(g.map,p.uvTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function l(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,0.0001)}function d(p,g){if(g.gradientMap)p.gradientMap.value=g.gradientMap}function h(p,g){if(p.metalness.value=g.metalness,g.metalnessMap)p.metalnessMap.value=g.metalnessMap,n(g.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=g.roughness,g.roughnessMap)p.roughnessMap.value=g.roughnessMap,n(g.roughnessMap,p.roughnessMapTransform);if(g.envMap)p.envMapIntensity.value=g.envMapIntensity}function f(p,g,S){if(p.ior.value=g.ior,g.sheen>0){if(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap)p.sheenColorMap.value=g.sheenColorMap,n(g.sheenColorMap,p.sheenColorMapTransform);if(g.sheenRoughnessMap)p.sheenRoughnessMap.value=g.sheenRoughnessMap,n(g.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(g.clearcoat>0){if(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap)p.clearcoatMap.value=g.clearcoatMap,n(g.clearcoatMap,p.clearcoatMapTransform);if(g.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,n(g.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(g.clearcoatNormalMap){if(p.clearcoatNormalMap.value=g.clearcoatNormalMap,n(g.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===rn)p.clearcoatNormalScale.value.negate()}}if(g.dispersion>0)p.dispersion.value=g.dispersion;if(g.retroreflectivity>0)p.retroreflectivity.value=g.retroreflectivity;if(g.iridescence>0){if(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap)p.iridescenceMap.value=g.iridescenceMap,n(g.iridescenceMap,p.iridescenceMapTransform);if(g.iridescenceThicknessMap)p.iridescenceThicknessMap.value=g.iridescenceThicknessMap,n(g.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(g.transmission>0){if(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=S.texture,p.transmissionSamplerSize.value.set(S.width,S.height),g.transmissionMap)p.transmissionMap.value=g.transmissionMap,n(g.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=g.thickness,g.thicknessMap)p.thicknessMap.value=g.thicknessMap,n(g.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)}if(g.anisotropy>0){if(p.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap)p.anisotropyMap.value=g.anisotropyMap,n(g.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularColorMap)p.specularColorMap.value=g.specularColorMap,n(g.specularColorMap,p.specularColorMapTransform);if(g.specularIntensityMap)p.specularIntensityMap.value=g.specularIntensityMap,n(g.specularIntensityMap,p.specularIntensityMapTransform)}function m(p,g){if(g.matcap)p.matcap.value=g.matcap}function _(p,g){let S=t.get(g).light;p.referencePosition.value.setFromMatrixPosition(S.matrixWorld),p.nearDistance.value=S.shadow.camera.near,p.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function ET(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,w){let A=w.program;i.uniformBlockBinding(y,A)}function l(y,w){let A=r[y.id];if(A===void 0)p(y),A=u(y),r[y.id]=A,y.addEventListener("dispose",S);let R=w.program;i.updateUBOMapping(y,R);let x=t.render.frame;if(s[y.id]!==x)h(y),s[y.id]=x}function u(y){let w=d();y.__bindingPointIndex=w;let A=e.createBuffer(),{__size:R,usage:x}=y;return e.bindBuffer(e.UNIFORM_BUFFER,A),e.bufferData(e.UNIFORM_BUFFER,R,x),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,w,A),A}function d(){for(let y=0;y<a;y++)if(o.indexOf(y)===-1)return o.push(y),y;return ke("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(y){let w=r[y.id],{uniforms:A,__cache:R}=y;e.bindBuffer(e.UNIFORM_BUFFER,w);for(let x=0,M=A.length;x<M;x++){let z=A[x];if(Array.isArray(z))for(let C=0,L=z.length;C<L;C++)f(z[C],x,C,R);else f(z,x,0,R)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function f(y,w,A,R){if(_(y,w,A,R)===!0){let{__offset:x,value:M}=y;if(Array.isArray(M)){let z=0;for(let C=0;C<M.length;C++){let L=M[C],K=g(L);if(m(L,y.__data,z),typeof L!=="number"&&typeof L!=="boolean"&&!L.isMatrix3&&!ArrayBuffer.isView(L))z+=K.storage/Float32Array.BYTES_PER_ELEMENT}}else m(M,y.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,x,y.__data)}}function m(y,w,A){if(typeof y==="number"||typeof y==="boolean")w[0]=y;else if(y.isMatrix3)w[0]=y.elements[0],w[1]=y.elements[1],w[2]=y.elements[2],w[3]=0,w[4]=y.elements[3],w[5]=y.elements[4],w[6]=y.elements[5],w[7]=0,w[8]=y.elements[6],w[9]=y.elements[7],w[10]=y.elements[8],w[11]=0;else if(ArrayBuffer.isView(y))w.set(new y.constructor(y.buffer,y.byteOffset,w.length));else y.toArray(w,A)}function _(y,w,A,R){let x=y.value,M=w+"_"+A;if(R[M]===void 0){if(typeof x==="number"||typeof x==="boolean")R[M]=x;else if(ArrayBuffer.isView(x))R[M]=x.slice();else R[M]=x.clone();return!0}else{let z=R[M];if(typeof x==="number"||typeof x==="boolean"){if(z!==x)return R[M]=x,!0}else if(ArrayBuffer.isView(x))return!0;else if(z.equals(x)===!1)return z.copy(x),!0}return!1}function p(y){let w=y.uniforms,A=0,R=16;for(let M=0,z=w.length;M<z;M++){let C=Array.isArray(w[M])?w[M]:[w[M]];for(let L=0,K=C.length;L<K;L++){let I=C[L],G=Array.isArray(I.value)?I.value:[I.value];for(let X=0,P=G.length;X<P;X++){let j=G[X],k=g(j),q=A%R,Q=q%k.boundary,Me=q+Q;if(A+=Q,Me!==0&&R-Me<k.storage)A+=R-Me;I.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=A,A+=k.storage}}}let x=A%R;if(x>0)A+=R-x;return y.__size=A,y.__cache={},this}function g(y){let w={boundary:0,storage:0};if(typeof y==="number"||typeof y==="boolean")w.boundary=4,w.storage=4;else if(y.isVector2)w.boundary=8,w.storage=8;else if(y.isVector3||y.isColor)w.boundary=16,w.storage=12;else if(y.isVector4)w.boundary=16,w.storage=16;else if(y.isMatrix3)w.boundary=48,w.storage=48;else if(y.isMatrix4)w.boundary=64,w.storage=64;else if(y.isTexture)Le("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(y))w.boundary=16,w.storage=y.byteLength;else Le("WebGLRenderer: Unsupported uniform value type.",y);return w}function S(y){let w=y.target;w.removeEventListener("dispose",S);let A=o.indexOf(w.__bindingPointIndex);o.splice(A,1),e.deleteBuffer(r[w.id]),delete r[w.id],delete s[w.id]}function T(){for(let y in r)e.deleteBuffer(r[y]);o=[],r={},s={}}return{bind:c,update:l,dispose:T}}var AT=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),_i=null;function TT(){if(_i===null)_i=new Ro(AT,16,16,kr,pi),_i.name="DFG_LUT",_i.minFilter=qt,_i.magFilter=qt,_i.wrapS=Ts,_i.wrapT=Ts,_i.generateMipmaps=!1,_i.needsUpdate=!0;return _i}class Rh{constructor(e={}){let{canvas:t=sm(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:h=Qn}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=s;let m=h,_=new Set([pu,fu,du]),p=new Set([Qn,hr,bo,Cs,uu,hu]),g=new Uint32Array(4),S=new Int32Array(4),T=new U,y=null,w=null,A=[],R=[],x=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,z=!1,C=null,L=null,K=null,I=null;this._outputColorSpace=dr;let G=0,X=0,P=null,j=-1,k=null,q=new ft,Q=new ft,Me=null,ue=new ze(0),Be=0,{width:we,height:Z}=t,re=1,se=null,xe=null,Ee=new ft(0,0,we,Z),Ae=new ft(0,0,we,Z),Et=!1,Ge=new Po,Ye=!1,ht=!1,tt=new $e,Jt=new U,At=new ft,mn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},kt=!1;function Bt(){return P===null?re:1}let D=n;function gn(b,O){return t.getContext(b,O)}let ct,Pt,E,v,N,H,ie,ae,he,Y,te,_e,Ie,de,oe,De,Fe,st,F,ce,ee,le,ye;try{let b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${hp}`);if(t.addEventListener("webglcontextlost",He,!1),t.addEventListener("webglcontextrestored",bt,!1),t.addEventListener("webglcontextcreationerror",lt,!1),D===null){if(D=gn("webgl2",b),D===null)if(gn("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(b){throw t.removeEventListener("webglcontextlost",He,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",lt,!1),ke("WebGLRenderer: "+b.message),b}function ne(){if(ct=new DE(D),ct.init(),ee=new vT(D,ct),Pt=new wE(D,ct,e,ee),E=new xT(D,ct),Pt.reversedDepthBuffer&&d)E.buffers.depth.setReversed(!0);L=D.createFramebuffer(),K=D.createFramebuffer(),I=D.createFramebuffer(),v=new FE(D),N=new rT,H=new yT(D,ct,E,N,Pt,ee,v),ie=new NE(M),ae=new kS(D),le=new SE(D,ae),he=new OE(D,ae,v,le),Y=new kE(D,he,ae,le,v),st=new zE(D,Pt,H),oe=new EE(N),te=new iT(M,ie,ct,Pt,le,oe),_e=new wT(M,N),Ie=new oT,de=new dT(ct),Fe=new bE(M,ie,E,Y,f,a),De=new _T(M,Y,Pt),ye=new ET(D,v,Pt,E),F=new ME(D,ct,v),ce=new UE(D,ct,v),v.programs=te.programs,M.capabilities=Pt,M.extensions=ct,M.properties=N,M.renderLists=Ie,M.shadowMap=De,M.state=E,M.info=v}if(m!==Qn)x=new VE(m,t.width,t.height,o,i,r);let pe=new Jm(M,D);this.xr=pe,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){let b=ct.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=ct.get("WEBGL_lose_context");if(b)b.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(b){if(b===void 0)return;re=b,this.setSize(we,Z,!1)},this.getSize=function(b){return b.set(we,Z)},this.setSize=function(b,O,W=!0){if(pe.isPresenting){Le("WebGLRenderer: Can't change size while VR device is presenting.");return}if(we=b,Z=O,t.width=Math.floor(b*re),t.height=Math.floor(O*re),W===!0)t.style.width=b+"px",t.style.height=O+"px";if(x!==null)x.setSize(t.width,t.height);this.setViewport(0,0,b,O)},this.getDrawingBufferSize=function(b){return b.set(we*re,Z*re).floor()},this.setDrawingBufferSize=function(b,O,W){we=b,Z=O,re=W,t.width=Math.floor(b*W),t.height=Math.floor(O*W),this.setViewport(0,0,b,O)},this.setEffects=function(b){if(m===Qn){ke("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let O=0;O<b.length;O++)if(b[O].isOutputPass===!0){Le("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}x.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(q)},this.getViewport=function(b){return b.copy(Ee)},this.setViewport=function(b,O,W,B){if(b.isVector4)Ee.set(b.x,b.y,b.z,b.w);else Ee.set(b,O,W,B);E.viewport(q.copy(Ee).multiplyScalar(re).round())},this.getScissor=function(b){return b.copy(Ae)},this.setScissor=function(b,O,W,B){if(b.isVector4)Ae.set(b.x,b.y,b.z,b.w);else Ae.set(b,O,W,B);E.scissor(Q.copy(Ae).multiplyScalar(re).round())},this.getScissorTest=function(){return Et},this.setScissorTest=function(b){E.setScissorTest(Et=b)},this.setOpaqueSort=function(b){se=b},this.setTransparentSort=function(b){xe=b},this.getClearColor=function(b){return b.copy(Fe.getClearColor())},this.setClearColor=function(){Fe.setClearColor(...arguments)},this.getClearAlpha=function(){return Fe.getClearAlpha()},this.setClearAlpha=function(){Fe.setClearAlpha(...arguments)},this.clear=function(b=!0,O=!0,W=!0){let B=0;if(b){let V=!1;if(P!==null){let ge=P.texture.format;V=_.has(ge)}if(V){let ge=P.texture.type,Se=p.has(ge),me=Fe.getClearColor(),Te=Fe.getClearAlpha(),{r:Pe,g:We,b:Ke}=me;if(Se)g[0]=Pe,g[1]=We,g[2]=Ke,g[3]=Te,D.clearBufferuiv(D.COLOR,0,g);else S[0]=Pe,S[1]=We,S[2]=Ke,S[3]=Te,D.clearBufferiv(D.COLOR,0,S)}else B|=D.COLOR_BUFFER_BIT}if(O)B|=D.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)B|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(B!==0)D.clear(B)},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.setNodesHandler=function(b){b.setRenderer(this),C=b},this.dispose=function(){t.removeEventListener("webglcontextlost",He,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",lt,!1),Fe.dispose(),Ie.dispose(),de.dispose(),N.dispose(),ie.dispose(),Y.dispose(),le.dispose(),ye.dispose(),te.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",yf),pe.removeEventListener("sessionend",vf),Rr.stop()};function He(b){b.preventDefault(),go("WebGLRenderer: Context Lost."),z=!0}function bt(){go("WebGLRenderer: Context Restored."),z=!1;let b=v.autoReset,O=De.enabled,W=De.autoUpdate,B=De.needsUpdate,V=De.type;ne(),v.autoReset=b,De.enabled=O,De.autoUpdate=W,De.needsUpdate=B,De.type=V}function lt(b){ke("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function oi(b){let O=b.target;O.removeEventListener("dispose",oi),Di(O)}function Di(b){Cb(b),N.remove(b)}function Cb(b){let O=N.get(b).programs;if(O!==void 0){if(O.forEach(function(W){te.releaseProgram(W)}),b.isShaderMaterial)te.releaseShaderCache(b)}}this.renderBufferDirect=function(b,O,W,B,V,ge){if(O===null)O=mn;let Se=V.isMesh&&V.matrixWorld.determinantAffine()<0,me=Lb(b,O,W,B,V);E.setMaterial(B,Se);let Te=W.index,Pe=1;if(B.wireframe===!0){if(Te=he.getWireframeAttribute(W),Te===void 0)return;Pe=2}let We=W.drawRange,Ke=W.attributes.position,Re=We.start*Pe,ut=(We.start+We.count)*Pe;if(ge!==null)Re=Math.max(Re,ge.start*Pe),ut=Math.min(ut,(ge.start+ge.count)*Pe);if(Te!==null)Re=Math.max(Re,0),ut=Math.min(ut,Te.count);else if(Ke!==void 0&&Ke!==null)Re=Math.max(Re,0),ut=Math.min(ut,Ke.count);let Ft=ut-Re;if(Ft<0||Ft===1/0)return;le.setup(V,B,me,W,Te);let Tt,xt=F;if(Te!==null)Tt=ae.get(Te),xt=ce,xt.setIndex(Tt);if(V.isMesh)if(B.wireframe===!0)E.setLineWidth(B.wireframeLinewidth*Bt()),xt.setMode(D.LINES);else xt.setMode(D.TRIANGLES);else if(V.isLine){let en=B.linewidth;if(en===void 0)en=1;if(E.setLineWidth(en*Bt()),V.isLineSegments)xt.setMode(D.LINES);else if(V.isLineLoop)xt.setMode(D.LINE_LOOP);else xt.setMode(D.LINE_STRIP)}else if(V.isPoints)xt.setMode(D.POINTS);else if(V.isSprite)xt.setMode(D.TRIANGLES);if(V.isBatchedMesh)if(!ct.get("WEBGL_multi_draw")){let{_multiDrawStarts:en,_multiDrawCounts:ve,_multiDrawCount:ln}=V,it=Te?ae.get(Te).bytesPerElement:1,On=N.get(B).currentProgram.getUniforms();for(let ai=0;ai<ln;ai++)On.setValue(D,"_gl_DrawID",ai),xt.render(en[ai]/it,ve[ai])}else xt.renderMultiDraw(V._multiDrawStarts,V._multiDrawCounts,V._multiDrawCount);else if(V.isInstancedMesh)xt.renderInstances(Re,Ft,V.count);else if(W.isInstancedBufferGeometry){let en=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,ve=Math.min(W.instanceCount,en);xt.renderInstances(Re,Ft,ve)}else xt.render(Re,Ft)};function xf(b,O,W,B){if(C!==null&&b.isNodeMaterial)C.setObject(B,b);if(Ye===!0)oe.setState(b,W,!1);if(b.transparent===!0&&b.side===kn&&b.forceSinglePass===!1)b.side=rn,b.needsUpdate=!0,Ma(b,O,B),b.side=ur,b.needsUpdate=!0,Ma(b,O,B),b.side=kn;else Ma(b,O,B)}this.compile=function(b,O,W=null){if(W===null)W=b;if(C!==null)C.renderStart(b,O,W);if(w=de.get(W),w.init(O),R.push(w),W.traverseVisible(function(V){if(V.isLight&&V.layers.test(O.layers)){if(w.pushLight(V),V.castShadow)w.pushShadow(V)}}),b!==W)b.traverseVisible(function(V){if(V.isLight&&V.layers.test(O.layers)){if(w.pushLight(V),V.castShadow)w.pushShadow(V)}});if(w.setupLights(),C!==null)C.updateLights(w.state.lightsArray);if(ht=this.localClippingEnabled,Ye=oe.init(this.clippingPlanes,ht),Ye===!0)oe.setGlobalState(this.clippingPlanes,O);if(C!==null)De.render(w.state.shadowsArray,W,O);let B=new Set;if(b.traverse(function(V){if(!(V.isMesh||V.isPoints||V.isLine||V.isSprite))return;let ge=V.material;if(ge)if(Array.isArray(ge))for(let Se=0;Se<ge.length;Se++){let me=ge[Se];xf(me,W,O,V),B.add(me)}else xf(ge,W,O,V),B.add(ge)}),w=R.pop(),C!==null)C.renderEnd();return B},this.compileAsync=function(b,O,W=null){let B=this.compile(b,O,W);return new Promise((V)=>{function ge(){if(B.forEach(function(Se){let Te=N.get(Se).currentProgram;if(Te===void 0||Te.isReady())B.delete(Se)}),B.size===0){V(b);return}setTimeout(ge,10)}if(ct.get("KHR_parallel_shader_compile")!==null)ge();else setTimeout(ge,10)})};let El=null;function Pb(b){if(El)El(b)}function yf(){Rr.stop()}function vf(){Rr.start()}let Rr=new km;if(Rr.setAnimationLoop(Pb),typeof self<"u")Rr.setContext(self);this.setAnimationLoop=function(b){El=b,pe.setAnimationLoop(b),b===null?Rr.stop():Rr.start()},pe.addEventListener("sessionstart",yf),pe.addEventListener("sessionend",vf),this.render=function(b,O){if(O!==void 0&&O.isCamera!==!0){ke("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(z===!0)return;if(C!==null)C.renderStart(b,O);let W=pe.enabled===!0&&pe.isPresenting===!0,B=x!==null&&(P===null||W)&&x.begin(M,P);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(O.parent===null&&O.matrixWorldAutoUpdate===!0)O.updateMatrixWorld();if(pe.enabled===!0&&pe.isPresenting===!0&&(x===null||x.isCompositing()===!1)){if(pe.cameraAutoUpdate===!0)pe.updateCamera(O);O=pe.getCamera()}if(b.isScene===!0)b.onBeforeRender(M,b,O,P);if(w=de.get(b,R.length),w.init(O),w.state.textureUnits=H.getTextureUnits(),R.push(w),tt.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),Ge.setFromProjectionMatrix(tt,Yu,O.reversedDepth),ht=this.localClippingEnabled,Ye=oe.init(this.clippingPlanes,ht),y=Ie.get(b,A.length),y.init(),A.push(y),pe.enabled===!0&&pe.isPresenting===!0){let Se=M.xr.getDepthSensingMesh();if(Se!==null)Al(Se,O,-1/0,M.sortObjects)}if(Al(b,O,0,M.sortObjects),y.finish(),C!==null)C.updateLights(w.state.lightsArray);if(M.sortObjects===!0)y.sort(se,xe);if(kt=pe.enabled===!1||pe.isPresenting===!1||pe.hasDepthSensing()===!1,kt)Fe.addToRenderList(y,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ye===!0)oe.beginShadows();let V=w.state.shadowsArray;if(De.render(V,b,O),Ye===!0)oe.endShadows();if((B&&x.hasRenderPass())===!1){let Se=y.opaque,me=y.transmissive;if(w.setupLights(),O.isArrayCamera){let Te=O.cameras;if(me.length>0)for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe];Sf(Se,me,b,Ke)}if(kt)Fe.render(b);for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe];bf(y,b,Ke,Ke.viewport)}}else{if(me.length>0)Sf(Se,me,b,O);if(kt)Fe.render(b);bf(y,b,O)}}if(P!==null&&X===0)H.updateMultisampleRenderTarget(P),H.updateRenderTargetMipmap(P);if(B)x.end(M);if(b.isScene===!0)b.onAfterRender(M,b,O);if(le.resetDefaultState(),j=-1,k=null,R.pop(),R.length>0){if(w=R[R.length-1],H.setTextureUnits(w.state.textureUnits),Ye===!0)oe.setGlobalState(M.clippingPlanes,w.state.camera)}else w=null;if(A.pop(),A.length>0)y=A[A.length-1];else y=null;if(C!==null)C.renderEnd()};function Al(b,O,W,B){if(b.visible===!1)return;if(b.layers.test(O.layers)){if(b.isGroup)W=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(O)}else if(b.isLightProbeGrid)w.pushLightProbeGrid(b);else if(b.isLight){if(w.pushLight(b),b.castShadow)w.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(Ge)){if(B)At.setFromMatrixPosition(b.matrixWorld).applyMatrix4(tt);let Se=Y.update(b),me=b.material;if(me.visible)y.push(b,Se,me,W,At.z,null,O)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(Ge)){let Se=Y.update(b),me=b.material;if(B){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();At.copy(b.boundingSphere.center)}else{if(Se.boundingSphere===null)Se.computeBoundingSphere();At.copy(Se.boundingSphere.center)}At.applyMatrix4(b.matrixWorld).applyMatrix4(tt)}if(Array.isArray(me)){let Te=Se.groups;for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe],Re=me[Ke.materialIndex];if(Re&&Re.visible)y.push(b,Se,Re,W,At.z,Ke,O)}}else if(me.visible)y.push(b,Se,me,W,At.z,null,O)}}}let ge=b.children;for(let Se=0,me=ge.length;Se<me;Se++)Al(ge[Se],O,W,B)}function bf(b,O,W,B){let{opaque:V,transmissive:ge,transparent:Se}=b;if(w.setupLightsView(W),Ye===!0)oe.setGlobalState(M.clippingPlanes,W);if(B)E.viewport(q.copy(B));if(V.length>0)Sa(V,O,W);if(ge.length>0)Sa(ge,O,W);if(Se.length>0)Sa(Se,O,W);E.buffers.depth.setTest(!0),E.buffers.depth.setMask(!0),E.buffers.color.setMask(!0),E.setPolygonOffset(!1)}function Sf(b,O,W,B){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[B.id]===void 0){let Re=ct.has("EXT_color_buffer_half_float")||ct.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[B.id]=new Mn(1,1,{generateMipmaps:!0,type:Re?pi:Qn,minFilter:fi,samples:Math.max(4,Pt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:je.workingColorSpace})}let ge=w.state.transmissionRenderTarget[B.id],Se=B.viewport||q;ge.setSize(Se.z*M.transmissionResolutionScale,Se.w*M.transmissionResolutionScale);let me=M.getRenderTarget(),Te=M.getActiveCubeFace(),Pe=M.getActiveMipmapLevel();if(M.setRenderTarget(ge),M.getClearColor(ue),Be=M.getClearAlpha(),Be<1)M.setClearColor(16777215,0.5);if(M.clear(),kt)Fe.render(W);let We=M.toneMapping;M.toneMapping=Jn;let Ke=B.viewport;if(B.viewport!==void 0)B.viewport=void 0;if(w.setupLightsView(B),Ye===!0)oe.setGlobalState(M.clippingPlanes,B);if(Sa(b,W,B),H.updateMultisampleRenderTarget(ge),H.updateRenderTargetMipmap(ge),ct.has("WEBGL_multisampled_render_to_texture")===!1){let Re=!1;for(let ut=0,Ft=O.length;ut<Ft;ut++){let Tt=O[ut],{object:xt,geometry:en,material:ve,group:ln}=Tt;if(ve.side===kn&&xt.layers.test(B.layers)){let it=ve.side;ve.side=rn,ve.needsUpdate=!0,Mf(xt,W,B,en,ve,ln),ve.side=it,ve.needsUpdate=!0,Re=!0}}if(Re===!0)H.updateMultisampleRenderTarget(ge),H.updateRenderTargetMipmap(ge)}if(M.setRenderTarget(me,Te,Pe),M.setClearColor(ue,Be),Ke!==void 0)B.viewport=Ke;M.toneMapping=We}function Sa(b,O,W){let B=O.isScene===!0?O.overrideMaterial:null;for(let V=0,ge=b.length;V<ge;V++){let Se=b[V],{object:me,geometry:Te,group:Pe}=Se,We=Se.material;if(We.allowOverride===!0&&B!==null)We=B;if(me.layers.test(W.layers))Mf(me,O,W,Te,We,Pe)}}function Mf(b,O,W,B,V,ge){if(C!==null&&V.isNodeMaterial)C.setObject(b,V);if(b.onBeforeRender(M,O,W,B,V,ge),b.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),V.onBeforeRender(M,O,W,B,b,ge),V.transparent===!0&&V.side===kn&&V.forceSinglePass===!1)V.side=rn,V.needsUpdate=!0,M.renderBufferDirect(W,O,B,V,b,ge),V.side=ur,V.needsUpdate=!0,M.renderBufferDirect(W,O,B,V,b,ge),V.side=kn;else M.renderBufferDirect(W,O,B,V,b,ge);b.onAfterRender(M,O,W,B,V,ge)}function Ma(b,O,W){if(O.isScene!==!0)O=mn;let B=N.get(b),V=w.state.lights,ge=w.state.shadowsArray,Se=V.state.version,me=te.getParameters(b,V.state,ge,O,W,w.state.lightProbeGridArray),Te=te.getProgramCacheKey(me),Pe=B.programs;B.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?O.environment:null,B.fog=O.fog;let We=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(B.envMap=ie.get(b.envMap||B.environment,We),B.envMapRotation=B.environment!==null&&b.envMap===null?O.environmentRotation:b.envMapRotation,Pe===void 0)b.addEventListener("dispose",oi),Pe=new Map,B.programs=Pe;let Ke=Pe.get(Te);if(Ke!==void 0){if(B.currentProgram===Ke&&B.lightsStateVersion===Se)return Ef(b,me),Ke}else{if(me.uniforms=te.getUniforms(b),C!==null&&b.isNodeMaterial)C.build(b,W,me);b.onBeforeCompile(me,M),Ke=te.acquireProgram(me,Te),Pe.set(Te,Ke),B.uniforms=me.uniforms}let Re=B.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Re.clippingPlanes=oe.uniform;if(Ef(b,me),B.needsLights=Db(b),B.lightsStateVersion=Se,B.needsLights)Re.ambientLightColor.value=V.state.ambient,Re.lightProbe.value=V.state.probe,Re.sunLights.value=V.state.sun,Re.sunLightShadows.value=V.state.sunShadow,Re.directionalLights.value=V.state.directional,Re.directionalLightShadows.value=V.state.directionalShadow,Re.spotLights.value=V.state.spot,Re.spotLightShadows.value=V.state.spotShadow,Re.rectAreaLights.value=V.state.rectArea,Re.ltc_1.value=V.state.rectAreaLTC1,Re.ltc_2.value=V.state.rectAreaLTC2,Re.pointLights.value=V.state.point,Re.pointLightShadows.value=V.state.pointShadow,Re.hemisphereLights.value=V.state.hemi,Re.sunShadowMatrix.value=V.state.sunShadowMatrix,Re.sunShadowCascade.value=V.state.sunShadowCascade,Re.directionalShadowMatrix.value=V.state.directionalShadowMatrix,Re.spotLightMatrix.value=V.state.spotLightMatrix,Re.spotLightMap.value=V.state.spotLightMap,Re.pointShadowMatrix.value=V.state.pointShadowMatrix;return B.lightProbeGrid=w.state.lightProbeGridArray.length>0,B.currentProgram=Ke,B.uniformsList=null,Ke}function wf(b){if(b.uniformsList===null){let O=b.currentProgram.getUniforms();b.uniformsList=Vo.seqWithValue(O.seq,b.uniforms)}return b.uniformsList}function Ef(b,O){let W=N.get(b);W.outputColorSpace=O.outputColorSpace,W.batching=O.batching,W.batchingColor=O.batchingColor,W.instancing=O.instancing,W.instancingColor=O.instancingColor,W.instancingMorph=O.instancingMorph,W.skinning=O.skinning,W.morphTargets=O.morphTargets,W.morphNormals=O.morphNormals,W.morphColors=O.morphColors,W.morphTargetsCount=O.morphTargetsCount,W.numClippingPlanes=O.numClippingPlanes,W.numIntersection=O.numClipIntersection,W.vertexAlphas=O.vertexAlphas,W.vertexTangents=O.vertexTangents,W.toneMapping=O.toneMapping}function Ib(b,O){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;T.setFromMatrixPosition(O.matrixWorld);for(let W=0,B=b.length;W<B;W++){let V=b[W];if(V.texture!==null&&V.boundingBox.containsPoint(T))return V}return null}function Lb(b,O,W,B,V){if(O.isScene!==!0)O=mn;H.resetTextureUnits();let ge=O.fog,Se=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?O.environment:null,me=P===null?M.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:je.workingColorSpace,Te=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Pe=ie.get(B.envMap||Se,Te),We=B.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,Ke=!!W.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Re=!!W.morphAttributes.position,ut=!!W.morphAttributes.normal,Ft=!!W.morphAttributes.color,Tt=Jn;if(B.toneMapped){if(P===null||P.isXRRenderTarget===!0)Tt=M.toneMapping}let xt=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,en=xt!==void 0?xt.length:0,ve=N.get(B),ln=w.state.lights;if(Ye===!0){if(ht===!0||b!==k){let St=b===k&&B.id===j;oe.setState(B,b,St)}}let it=!1;if(B.version===ve.__version){if(ve.needsLights&&ve.lightsStateVersion!==ln.state.version)it=!0;else if(ve.outputColorSpace!==me)it=!0;else if(V.isBatchedMesh&&ve.batching===!1)it=!0;else if(!V.isBatchedMesh&&ve.batching===!0)it=!0;else if(V.isBatchedMesh&&ve.batchingColor===!0&&V._colorsTexture===null)it=!0;else if(V.isBatchedMesh&&ve.batchingColor===!1&&V._colorsTexture!==null)it=!0;else if(V.isInstancedMesh&&ve.instancing===!1)it=!0;else if(!V.isInstancedMesh&&ve.instancing===!0)it=!0;else if(V.isSkinnedMesh&&ve.skinning===!1)it=!0;else if(!V.isSkinnedMesh&&ve.skinning===!0)it=!0;else if(V.isInstancedMesh&&ve.instancingColor===!0&&V.instanceColor===null)it=!0;else if(V.isInstancedMesh&&ve.instancingColor===!1&&V.instanceColor!==null)it=!0;else if(V.isInstancedMesh&&ve.instancingMorph===!0&&V.morphTexture===null)it=!0;else if(V.isInstancedMesh&&ve.instancingMorph===!1&&V.morphTexture!==null)it=!0;else if(ve.envMap!==Pe)it=!0;else if(B.fog===!0&&ve.fog!==ge)it=!0;else if(ve.numClippingPlanes!==void 0&&(ve.numClippingPlanes!==oe.numPlanes||ve.numIntersection!==oe.numIntersection))it=!0;else if(ve.vertexAlphas!==We)it=!0;else if(ve.vertexTangents!==Ke)it=!0;else if(ve.morphTargets!==Re)it=!0;else if(ve.morphNormals!==ut)it=!0;else if(ve.morphColors!==Ft)it=!0;else if(ve.toneMapping!==Tt)it=!0;else if(ve.morphTargetsCount!==en)it=!0;else if(!!ve.lightProbeGrid!==w.state.lightProbeGridArray.length>0)it=!0}else it=!0,ve.__version=B.version;let On=ve.currentProgram;if(it===!0){if(On=Ma(B,O,V),C&&B.isNodeMaterial)C.onUpdateProgram(B,On,ve)}let ai=!1,Ki=!1,is=!1,mt=On.getUniforms(),Ot=ve.uniforms;if(E.useProgram(On.program))ai=!0,Ki=!0,is=!0;if(B.id!==j)j=B.id,Ki=!0;if(ve.needsLights){let St=Ib(w.state.lightProbeGridArray,V);if(ve.lightProbeGrid!==St)ve.lightProbeGrid=St,Ki=!0}if(ai||k!==b){if(E.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();mt.setValue(D,"projectionMatrix",b.projectionMatrix),mt.setValue(D,"viewMatrix",b.matrixWorldInverse);let er=mt.map.cameraPosition;if(er!==void 0)er.setValue(D,Jt.setFromMatrixPosition(b.matrixWorld));if(Pt.logarithmicDepthBuffer)mt.setValue(D,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)mt.setValue(D,"isOrthographic",b.isOrthographicCamera===!0);if(k!==b)k=b,Ki=!0,is=!0}if(ve.needsLights){if(ln.state.sunShadowMap.length>0)mt.setValue(D,"sunShadowMap",ln.state.sunShadowMap,H);if(ln.state.directionalShadowMap.length>0)mt.setValue(D,"directionalShadowMap",ln.state.directionalShadowMap,H);if(ln.state.spotShadowMap.length>0)mt.setValue(D,"spotShadowMap",ln.state.spotShadowMap,H);if(ln.state.pointShadowMap.length>0)mt.setValue(D,"pointShadowMap",ln.state.pointShadowMap,H)}if(V.isSkinnedMesh){mt.setOptional(D,V,"bindMatrix"),mt.setOptional(D,V,"bindMatrixInverse");let St=V.skeleton;if(St){if(St.boneTexture===null)St.computeBoneTexture();mt.setValue(D,"boneTexture",St.boneTexture,H)}}if(V.isBatchedMesh){if(mt.setOptional(D,V,"batchingTexture"),mt.setValue(D,"batchingTexture",V._matricesTexture,H),mt.setOptional(D,V,"batchingIdTexture"),mt.setValue(D,"batchingIdTexture",V._indirectTexture,H),mt.setOptional(D,V,"batchingColorTexture"),V._colorsTexture!==null)mt.setValue(D,"batchingColorTexture",V._colorsTexture,H)}let Qi=W.morphAttributes;if(Qi.position!==void 0||Qi.normal!==void 0||Qi.color!==void 0)st.update(V,W,On);if(Ki||ve.receiveShadow!==V.receiveShadow)ve.receiveShadow=V.receiveShadow,mt.setValue(D,"receiveShadow",V.receiveShadow);if((B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&O.environment!==null)Ot.envMapIntensity.value=O.environmentIntensity;if(Ot.dfgLUT!==void 0)Ot.dfgLUT.value=TT();if(Ki){if(mt.setValue(D,"toneMappingExposure",M.toneMappingExposure),ve.needsLights)Nb(Ot,is);if(ge&&B.fog===!0)_e.refreshFogUniforms(Ot,ge);if(_e.refreshMaterialUniforms(Ot,B,re,Z,w.state.transmissionRenderTarget[b.id]),ve.needsLights&&ve.lightProbeGrid){let St=ve.lightProbeGrid;Ot.probesSH.value=St.texture,Ot.probesMin.value.copy(St.boundingBox.min),Ot.probesMax.value.copy(St.boundingBox.max),Ot.probesResolution.value.copy(St.resolution)}Vo.upload(D,wf(ve),Ot,H)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0)Vo.upload(D,wf(ve),Ot,H),B.uniformsNeedUpdate=!1;if(B.isSpriteMaterial)mt.setValue(D,"center",V.center);if(mt.setValue(D,"modelViewMatrix",V.modelViewMatrix),mt.setValue(D,"normalMatrix",V.normalMatrix),mt.setValue(D,"modelMatrix",V.matrixWorld),B.uniformsGroups!==void 0){let St=B.uniformsGroups;for(let er=0,rs=St.length;er<rs;er++){let Tf=St[er];ye.update(Tf,On),ye.bind(Tf,On)}}return On}function Nb(b,O){b.ambientLightColor.needsUpdate=O,b.lightProbe.needsUpdate=O,b.sunLights.needsUpdate=O,b.sunLightShadows.needsUpdate=O,b.directionalLights.needsUpdate=O,b.directionalLightShadows.needsUpdate=O,b.pointLights.needsUpdate=O,b.pointLightShadows.needsUpdate=O,b.spotLights.needsUpdate=O,b.spotLightShadows.needsUpdate=O,b.rectAreaLights.needsUpdate=O,b.hemisphereLights.needsUpdate=O}function Db(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(b,O,W){let B=N.get(b);if(B.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1)B.__useRenderToTexture=!1;N.get(b.texture).__webglTexture=O,N.get(b.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:W,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,O){let W=N.get(b);W.__webglFramebuffer=O,W.__useDefaultFramebuffer=O===void 0},this.setRenderTarget=function(b,O=0,W=0){P=b,G=O,X=W;let B=null,V=!1,ge=!1;if(b){let me=N.get(b);if(me.__useDefaultFramebuffer!==void 0){E.bindFramebuffer(D.FRAMEBUFFER,me.__webglFramebuffer),q.copy(b.viewport),Q.copy(b.scissor),Me=b.scissorTest,E.viewport(q),E.scissor(Q),E.setScissorTest(Me),j=-1;return}else if(me.__webglFramebuffer===void 0)H.setupRenderTarget(b);else if(me.__hasExternalTextures)H.rebindTextures(b,N.get(b.texture).__webglTexture,N.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let We=b.depthTexture;if(me.__boundDepthTexture!==We){if(We!==null&&N.has(We)&&(b.width!==We.image.width||b.height!==We.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");H.setupDepthRenderbuffer(b)}}let Te=b.texture;if(Te.isData3DTexture||Te.isDataArrayTexture||Te.isCompressedArrayTexture)ge=!0;let Pe=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Pe[O]))B=Pe[O][W];else B=Pe[O];V=!0}else if(b.samples>0&&H.useMultisampledRTT(b)===!1)B=N.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Pe))B=Pe[W];else B=Pe;q.copy(b.viewport),Q.copy(b.scissor),Me=b.scissorTest}else q.copy(Ee).multiplyScalar(re).floor(),Q.copy(Ae).multiplyScalar(re).floor(),Me=Et;if(W!==0)B=L;if(E.bindFramebuffer(D.FRAMEBUFFER,B))E.drawBuffers(b,B);if(E.viewport(q),E.scissor(Q),E.setScissorTest(Me),V){let me=N.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+O,me.__webglTexture,W)}else if(ge){let me=O;for(let Te=0;Te<b.textures.length;Te++){let Pe=N.get(b.textures[Te]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+Te,Pe.__webglTexture,W,me)}}else if(b!==null&&W!==0){let me=N.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,me.__webglTexture,W)}j=-1};function Af(b){let O=N.get(b);if(O.__readFormat!==b.format||O.__readType!==b.type)O.__readFormat=b.format,O.__readType=b.type,O.__formatReadable=Pt.textureFormatReadable(b.format),O.__typeReadable=Pt.textureTypeReadable(b.type);return O}if(this.readRenderTargetPixels=function(b,O,W,B,V,ge,Se,me=0){if(!(b&&b.isWebGLRenderTarget)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Te=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Se!==void 0)Te=Te[Se];if(Te){E.bindFramebuffer(D.FRAMEBUFFER,Te);try{let Pe=b.textures[me],{format:We,type:Ke}=Pe;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+me);let Re=Af(Pe);if(Re.__formatReadable===!1){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Re.__typeReadable===!1){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(O>=0&&O<=b.width-B&&(W>=0&&W<=b.height-V))D.readPixels(O,W,B,V,ee.convert(We),ee.convert(Ke),ge)}finally{let Pe=P!==null?N.get(P).__webglFramebuffer:null;E.bindFramebuffer(D.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(b,O,W,B,V,ge,Se,me=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Te=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Se!==void 0)Te=Te[Se];if(Te)if(O>=0&&O<=b.width-B&&(W>=0&&W<=b.height-V)){E.bindFramebuffer(D.FRAMEBUFFER,Te);let Pe=b.textures[me],{format:We,type:Ke}=Pe;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+me);let Re=Af(Pe);if(Re.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Re.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let ut=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,ut),D.bufferData(D.PIXEL_PACK_BUFFER,ge.byteLength,D.STREAM_READ),D.readPixels(O,W,B,V,ee.convert(We),ee.convert(Ke),0),D.bindBuffer(D.PIXEL_PACK_BUFFER,null);let Ft=P!==null?N.get(P).__webglFramebuffer:null;E.bindFramebuffer(D.FRAMEBUFFER,Ft);let Tt=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await am(D,Tt,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,ut),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,ge),D.bindBuffer(D.PIXEL_PACK_BUFFER,null),D.deleteBuffer(ut),D.deleteSync(Tt),ge}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,O=null,W=0){let B=Math.pow(2,-W),V=Math.floor(b.image.width*B),ge=Math.floor(b.image.height*B),Se=O!==null?O.x:0,me=O!==null?O.y:0;H.setTexture2D(b,0),D.copyTexSubImage2D(D.TEXTURE_2D,W,0,0,Se,me,V,ge),E.unbindTexture()},this.copyTextureToTexture=function(b,O,W=null,B=null,V=0,ge=0){let Se,me,Te,Pe,We,Ke,Re,ut,Ft,Tt=b.isCompressedTexture?b.mipmaps[ge]:b.image;if(W!==null)Se=W.max.x-W.min.x,me=W.max.y-W.min.y,Te=W.isBox3?W.max.z-W.min.z:1,Pe=W.min.x,We=W.min.y,Ke=W.isBox3?W.min.z:0;else{let Ot=Math.pow(2,-V);if(Se=Math.floor(Tt.width*Ot),me=Math.floor(Tt.height*Ot),b.isDataArrayTexture)Te=Tt.depth;else if(b.isData3DTexture)Te=Math.floor(Tt.depth*Ot);else Te=1;Pe=0,We=0,Ke=0}if(B!==null)Re=B.x,ut=B.y,Ft=B.z;else Re=0,ut=0,Ft=0;let xt=ee.convert(O.format),en=ee.convert(O.type),ve;if(O.isData3DTexture)H.setTexture3D(O,0),ve=D.TEXTURE_3D;else if(O.isDataArrayTexture||O.isCompressedArrayTexture)H.setTexture2DArray(O,0),ve=D.TEXTURE_2D_ARRAY;else H.setTexture2D(O,0),ve=D.TEXTURE_2D;E.activeTexture(D.TEXTURE0),E.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,O.flipY),E.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),E.pixelStorei(D.UNPACK_ALIGNMENT,O.unpackAlignment);let ln=E.getParameter(D.UNPACK_ROW_LENGTH),it=E.getParameter(D.UNPACK_IMAGE_HEIGHT),On=E.getParameter(D.UNPACK_SKIP_PIXELS),ai=E.getParameter(D.UNPACK_SKIP_ROWS),Ki=E.getParameter(D.UNPACK_SKIP_IMAGES);E.pixelStorei(D.UNPACK_ROW_LENGTH,Tt.width),E.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Tt.height),E.pixelStorei(D.UNPACK_SKIP_PIXELS,Pe),E.pixelStorei(D.UNPACK_SKIP_ROWS,We),E.pixelStorei(D.UNPACK_SKIP_IMAGES,Ke);let is=b.isDataArrayTexture||b.isData3DTexture,mt=O.isDataArrayTexture||O.isData3DTexture;if(b.isDepthTexture){let Ot=N.get(b),Qi=N.get(O),St=N.get(Ot.__renderTarget),er=N.get(Qi.__renderTarget);E.bindFramebuffer(D.READ_FRAMEBUFFER,St.__webglFramebuffer),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,er.__webglFramebuffer);for(let rs=0;rs<Te;rs++){if(is)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,N.get(b).__webglTexture,V,Ke+rs),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,N.get(O).__webglTexture,ge,Ft+rs);D.blitFramebuffer(Pe,We,Se,me,Re,ut,Se,me,D.DEPTH_BUFFER_BIT,D.NEAREST)}E.bindFramebuffer(D.READ_FRAMEBUFFER,null),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(V!==0||b.isRenderTargetTexture||N.has(b)){let Ot=N.get(b),Qi=N.get(O);E.bindFramebuffer(D.READ_FRAMEBUFFER,K),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,I);for(let St=0;St<Te;St++){if(is)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Ot.__webglTexture,V,Ke+St);else D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Ot.__webglTexture,V);if(mt)D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Qi.__webglTexture,ge,Ft+St);else D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Qi.__webglTexture,ge);if(V!==0)D.blitFramebuffer(Pe,We,Se,me,Re,ut,Se,me,D.COLOR_BUFFER_BIT,D.NEAREST);else if(mt)D.copyTexSubImage3D(ve,ge,Re,ut,Ft+St,Pe,We,Se,me);else D.copyTexSubImage2D(ve,ge,Re,ut,Pe,We,Se,me)}E.bindFramebuffer(D.READ_FRAMEBUFFER,null),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(mt)if(b.isDataTexture||b.isData3DTexture)D.texSubImage3D(ve,ge,Re,ut,Ft,Se,me,Te,xt,en,Tt.data);else if(O.isCompressedArrayTexture)D.compressedTexSubImage3D(ve,ge,Re,ut,Ft,Se,me,Te,xt,Tt.data);else D.texSubImage3D(ve,ge,Re,ut,Ft,Se,me,Te,xt,en,Tt);else if(b.isDataTexture)D.texSubImage2D(D.TEXTURE_2D,ge,Re,ut,Se,me,xt,en,Tt.data);else if(b.isCompressedTexture)D.compressedTexSubImage2D(D.TEXTURE_2D,ge,Re,ut,Tt.width,Tt.height,xt,Tt.data);else D.texSubImage2D(D.TEXTURE_2D,ge,Re,ut,Se,me,xt,en,Tt);if(E.pixelStorei(D.UNPACK_ROW_LENGTH,ln),E.pixelStorei(D.UNPACK_IMAGE_HEIGHT,it),E.pixelStorei(D.UNPACK_SKIP_PIXELS,On),E.pixelStorei(D.UNPACK_SKIP_ROWS,ai),E.pixelStorei(D.UNPACK_SKIP_IMAGES,Ki),ge===0&&O.generateMipmaps)D.generateMipmap(ve);E.unbindTexture()},this.initRenderTarget=function(b){if(N.get(b).__webglFramebuffer===void 0)H.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)H.setTextureCube(b,0);else if(b.isData3DTexture)H.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)H.setTexture2DArray(b,0);else H.setTexture2D(b,0);E.unbindTexture()},this.resetState=function(){G=0,X=0,P=null,E.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Yu}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=je._getDrawingBufferColorSpace(e),t.unpackColorSpace=je._getUnpackColorSpace()}}var eg={type:"change"},Ph={type:"start"},ng={type:"end"},Nc=new fr,tg=new Fn,RT=Math.cos(70*Mo.DEG2RAD),Wt=new U,yn=2*Math.PI,pt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ch=0.000001;class Ih extends Rc{constructor(e,t=null){super(e,t);if(this.state=pt.NONE,this.target=new U,this.cursor=new U,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:cr.ROTATE,MIDDLE:cr.DOLLY,RIGHT:cr.PAN},this.touches={ONE:lr.ROTATE,TWO:lr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new U,this._lastQuaternion=new Xt,this._lastTargetPosition=new U,this._quat=new Xt().setFromUnitVectors(e.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Fo,this._sphericalDelta=new Fo,this._scale=1,this._panOffset=new U,this._rotateStart=new Ue,this._rotateEnd=new Ue,this._rotateDelta=new Ue,this._panStart=new Ue,this._panEnd=new Ue,this._panDelta=new Ue,this._dollyStart=new Ue,this._dollyEnd=new Ue,this._dollyDelta=new Ue,this._dollyDirection=new U,this._mouse=new Ue,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=PT.bind(this),this._onPointerDown=CT.bind(this),this._onPointerUp=IT.bind(this),this._onContextMenu=zT.bind(this),this._onMouseWheel=DT.bind(this),this._onKeyDown=OT.bind(this),this._onTouchStart=UT.bind(this),this._onTouchMove=FT.bind(this),this._onMouseDown=LT.bind(this),this._onMouseMove=NT.bind(this),this._interceptControlDown=kT.bind(this),this._interceptControlUp=BT.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=pt.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(eg),this.update(),this.state=pt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Wt.copy(t).sub(this.target),Wt.applyQuaternion(this._quat),this._spherical.setFromVector3(Wt),this.autoRotate&&this.state===pt.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=yn;else if(n>Math.PI)n-=yn;if(i<-Math.PI)i+=yn;else if(i>Math.PI)i-=yn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(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);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(Wt.setFromSpherical(this._spherical),Wt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Wt),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);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let o=Wt.length();s=this._clampDistance(o*this._scale);let a=o-s;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),r=!!a}else if(this.object.isOrthographicCamera){let o=new U(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=a!==this.object.zoom;let c=new U(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Wt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if(Nc.origin.copy(this.object.position),Nc.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Nc.direction))<RT)this.object.lookAt(this.target);else tg.setFromNormalAndCoplanarPoint(this.object.up,this.target),Nc.intersectPlane(tg,this.target)}else if(this.object.isOrthographicCamera){let s=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom)this.object.updateProjectionMatrix(),r=!0}if(this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Ch||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ch||this._lastTargetPosition.distanceToSquared(this.target)>Ch)return this.dispatchEvent(eg),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(e){if(e!==null)return yn/60*this.autoRotateSpeed*e;else return yn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Wt.setFromMatrixColumn(t,0),Wt.multiplyScalar(-e),this._panOffset.add(Wt)}_panUp(e,t){if(this.screenSpacePanning===!0)Wt.setFromMatrixColumn(t,1);else Wt.setFromMatrixColumn(t,0),Wt.crossVectors(this.object.up,Wt);Wt.multiplyScalar(e),this._panOffset.add(Wt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Wt.copy(i).sub(this.target);let r=Wt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:o}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(yn*this._rotateDelta.x/t.clientHeight),this._rotateUp(yn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){if(this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){if(this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0)this._dollyIn(this._getZoomScale(e.deltaY));else if(e.deltaY>0)this._dollyOut(this._getZoomScale(e.deltaY));this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(yn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);t=!0;break;case this.keys.BOTTOM:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(-yn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);t=!0;break;case this.keys.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(yn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);t=!0;break;case this.keys.RIGHT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(-yn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);t=!0;break}if(t)e.preventDefault(),this.update()}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enablePan)this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enableRotate)this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=0.5*(e.pageX+n.x),r=0.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(yn*this._rotateDelta.x/t.clientHeight),this._rotateUp(yn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Ue,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function CT(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function PT(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function IT(e){switch(this._removePointer(e),this._pointers.length){case 0:if(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(ng),this.state=pt.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function LT(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case cr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=pt.DOLLY;break;case cr.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=pt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=pt.ROTATE}break;case cr.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=pt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=pt.PAN}break;default:this.state=pt.NONE}if(this.state!==pt.NONE)this.dispatchEvent(Ph)}function NT(e){switch(this.state){case pt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case pt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case pt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function DT(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==pt.NONE)return;e.preventDefault(),this.dispatchEvent(Ph),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(ng)}function OT(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function UT(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case lr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=pt.TOUCH_ROTATE;break;case lr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=pt.TOUCH_PAN;break;default:this.state=pt.NONE}break;case 2:switch(this.touches.TWO){case lr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=pt.TOUCH_DOLLY_PAN;break;case lr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=pt.TOUCH_DOLLY_ROTATE;break;default:this.state=pt.NONE}break;default:this.state=pt.NONE}if(this.state!==pt.NONE)this.dispatchEvent(Ph)}function FT(e){switch(this._trackPointer(e),this.state){case pt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case pt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case pt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case pt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=pt.NONE}}function zT(e){if(this.enabled===!1)return;e.preventDefault()}function kT(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function BT(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class Lh extends Is{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new mr;e.deleteAttribute("uv");let t=new Hi({side:rn}),n=new Hi,i=new Fs(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new Mt(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new Ns(e,n,6),o=new gt;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new Mt(e,Gs(50));a.position.set(-16.116,14.37,8.208),a.scale.set(0.1,2.428,2.739),this.add(a);let c=new Mt(e,Gs(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new Mt(e,Gs(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new Mt(e,Gs(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let d=new Mt(e,Gs(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,0.1),this.add(d);let h=new Mt(e,Gs(100));h.position.set(0,20,0),h.scale.set(1,0.1,1),this.add(h)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function Gs(e){return new vc({color:0,emissive:16777215,emissiveIntensity:e})}function Nh(e,t){if(t===Zu)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Ps||t===So){let n=e.getIndex();if(n===null){let s=[],o=e.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)s.push(a);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===Ps)for(let s=1;s<=i;s++)r.push(n.getX(0)),r.push(n.getX(s)),r.push(n.getX(s+1));else for(let s=0;s<i;s++)if(s%2===0)r.push(n.getX(s)),r.push(n.getX(s+1)),r.push(n.getX(s+2));else r.push(n.getX(s+2)),r.push(n.getX(s+1)),r.push(n.getX(s));if(r.length/3!==i)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(r),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function ig(e){let t=new Map,n=new Map,i=e.clone();return rg(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,o=t.get(r),a=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=a.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function rg(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)rg(e.children[i],t.children[i],n)}class Bh extends Wi{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new dg(t)}),this.register(function(t){return new fg(t)}),this.register(function(t){return new Sg(t)}),this.register(function(t){return new Mg(t)}),this.register(function(t){return new wg(t)}),this.register(function(t){return new mg(t)}),this.register(function(t){return new gg(t)}),this.register(function(t){return new _g(t)}),this.register(function(t){return new xg(t)}),this.register(function(t){return new hg(t)}),this.register(function(t){return new yg(t)}),this.register(function(t){return new pg(t)}),this.register(function(t){return new bg(t)}),this.register(function(t){return new vg(t)}),this.register(function(t){return new lg(t)}),this.register(function(t){return new Fh(t,Je.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Fh(t,Je.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Eg(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=vr.extractUrlBase(e);s=vr.resolveURL(c,this.path)}else s=vr.extractUrlBase(e);this.manager.itemStart(e);let o=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},a=new Oo(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},o)}catch(l){o(l)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){if(this.pluginCallbacks.indexOf(e)===-1)this.pluginCallbacks.push(e);return this}unregister(e){if(this.pluginCallbacks.indexOf(e)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1);return this}parse(e,t,n,i){let r,s={},o={},a=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===Ag){try{s[Je.KHR_BINARY_GLTF]=new Tg(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Je.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new Lg(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],d=r.extensionsRequired||[];switch(u){case Je.KHR_MATERIALS_UNLIT:s[u]=new ug;break;case Je.KHR_DRACO_MESH_COMPRESSION:s[u]=new Rg(r,this.dracoLoader);break;case Je.KHR_TEXTURE_TRANSFORM:s[u]=new Cg;break;case Je.KHR_MESH_QUANTIZATION:s[u]=new Pg;break;default:if(d.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function VT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function Ut(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Je={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class lg{constructor(e){this.parser=e,this.name=Je.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new ze(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],Sn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new zs(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Fs(l),c.distance=u;break;case"spot":c=new Ec(l),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}if(c.position.set(0,0,0),yi(c,a),a.intensity!==void 0)c.intensity=a.intensity;return c.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;if(o===void 0)return null;return this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class ug{constructor(){this.name=Je.KHR_MATERIALS_UNLIT}getMaterialType(){return gi}extendParams(e,t,n){let i=[];e.color=new ze(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],Sn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,dr))}return Promise.all(i)}}class hg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class dg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ue(r,r)}}return Promise.all(i)}}class fg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class pg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class mg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SHEEN}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new ze(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],Sn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,dr));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class gg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class _g{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_VOLUME}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new ze().setRGB(r[0],r[1],r[2],Sn),Promise.all(i)}}class xg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IOR}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class yg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new ze().setRGB(r[0],r[1],r[2],Sn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,dr));return Promise.all(i)}}class vg{constructor(e){this.parser=e,this.name=Je.EXT_MATERIALS_BUMP}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class bg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class Sg{constructor(e){this.parser=e,this.name=Je.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class Mg{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class wg{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Fh{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,d=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,d,i.mode,i.filter).then(function(h){return h.buffer});else return s.ready.then(function(){let h=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(h),l,u,d,i.mode,i.filter),h})})}else return null}}class Eg{constructor(e){this.name=Je.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==Vn.TRIANGLES&&c.mode!==Vn.TRIANGLE_STRIP&&c.mode!==Vn.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],d=c[0].count,h=[];for(let f of u){let m=new $e,_=new U,p=new Xt,g=new U(1,1,1),S=new Ns(f.geometry,f.material,d);for(let y=0;y<d;y++){if(a.TRANSLATION)_.fromBufferAttribute(a.TRANSLATION,y);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,y);if(a.SCALE)g.fromBufferAttribute(a.SCALE,y);S.setMatrixAt(y,m.compose(_,p,g))}let T=null;for(let y in a)if(y==="_COLOR_0"){let w=a[y];S.instanceColor=new ar(w.array,w.itemSize,w.normalized)}else if(y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"){if(T===null){let A=S.geometry;T=new sn,T.name=A.name;for(let R in A.attributes)T.setAttribute(R,A.attributes[R]);for(let R in A.morphAttributes)T.morphAttributes[R]=A.morphAttributes[R];if(A.index!==null)T.setIndex(A.index);T.morphTargetsRelative=A.morphTargetsRelative;for(let R of A.groups)T.addGroup(R.start,R.count,R.materialIndex);if(A.boundingBox!==null)T.boundingBox=A.boundingBox.clone();if(A.boundingSphere!==null)T.boundingSphere=A.boundingSphere.clone();T.drawRange.start=A.drawRange.start,T.drawRange.count=A.drawRange.count,T.userData=Object.assign({},A.userData),S.geometry=T}let w=a[y];T.setAttribute(y,new ar(w.array,w.itemSize,w.normalized))}gt.prototype.copy.call(S,f),this.parser.assignFinalMaterial(S),h.push(S)}if(l.isGroup)return l.clear(),l.add(...h),l;return h[0]})}}var Ag="glTF",Ho=12,sg={JSON:1313821514,BIN:5130562};class Tg{constructor(e){this.name=Je.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Ho),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ag)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-Ho,r=new DataView(e,Ho),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===sg.JSON){let c=new Uint8Array(e,Ho+s,o);this.content=n.decode(c)}else if(a===sg.BIN){let c=Ho+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Rg{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Je.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=zh[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=zh[l]||l.toLowerCase();if(s[l]!==void 0){let d=n.accessors[e.attributes[l]],h=Hs[d.componentType];c[u]=h.name,a[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,d){i.decodeDracoFile(l,function(h){for(let f in h.attributes){let m=h.attributes[f],_=a[f];if(_!==void 0)m.normalized=_}u(h)},o,c,Sn,d)})})}}class Cg{constructor(){this.name=Je.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class Pg{constructor(){this.name=Je.KHR_MESH_QUANTIZATION}}class Vh extends $i{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,d=u*u,h=d*u,f=e*c,m=f-c,_=-2*h+3*d,p=h-d,g=1-_,S=p-d+u;for(let T=0;T!==o;T++){let y=s[m+T+o],w=s[m+T+a]*l,A=s[f+T+o],R=s[f+T]*l;r[T]=g*y+S*w+_*A+p*R}return r}}var GT=new Xt;class Ig extends Vh{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return GT.fromArray(r).normalize().toArray(r),r}}var Vn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Hs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},og={9728:Kn,9729:qt,9984:tc,9985:Rs,9986:Ur,9987:fi},ag={33071:Ts,33648:ec,10497:As},Dh={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},zh={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},br={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},HT={CUBICSPLINE:void 0,LINEAR:cc,STEP:Wu},Oh={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function $T(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new Hi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ur});return e.DefaultMaterial}function Zr(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function yi(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function WT(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let d=t[l];if(d.POSITION!==void 0)i=!0;if(d.NORMAL!==void 0)r=!0;if(d.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let d=t[l];if(i){let h=d.POSITION!==void 0?n.getDependency("accessor",d.POSITION):e.attributes.position;o.push(h)}if(r){let h=d.NORMAL!==void 0?n.getDependency("accessor",d.NORMAL):e.attributes.normal;a.push(h)}if(s){let h=d.COLOR_0!==void 0?n.getDependency("accessor",d.COLOR_0):e.attributes.color;c.push(h)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],d=l[1],h=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=d;if(s)e.morphAttributes.color=h;return e.morphTargetsRelative=!0,e})}function ZT(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++)e.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function XT(e){let t,n=e.extensions&&e.extensions[Je.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Uh(n.attributes);else t=e.indices+":"+Uh(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Uh(e.targets[i]);return t}function Uh(e){let t="",n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function kh(e){switch(e){case Int8Array:return 0.007874015748031496;case Uint8Array:return 0.00392156862745098;case Int16Array:return 0.00003051850947599719;case Uint16Array:return 0.000015259021896696422;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function jT(e){if(e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0)return"image/webp";if(e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var qT=new $e;class Lg{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new VT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;let a=o.match(/Version\/(\d+)/);i=n&&a?parseInt(a[1],10):-1,r=o.indexOf("Firefox")>-1,s=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new Os(this.options.manager);else this.textureLoader=new Ac(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Oo(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let o={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return Zr(r,o,i),yi(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Je.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(vr.resolveURL(t.uri,i.path),r,void 0,function(){s(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let s=Dh[i.type],o=Hs[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new jt(c,s,a))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let o=s[0],a=Dh[i.type],c=Hs[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,d=i.byteOffset||0,h=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0,m,_;if(h&&h!==u){let p=Math.floor(d/h),g="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,S=t.cache.get(g);if(!S)m=new c(o,p*h,i.count*h/l),S=new Ao(m,h/l),t.cache.add(g,S);_=new Ls(S,a,d%h/l,f)}else{if(o===null)m=new c(i.count*a);else m=new c(o,d,i.count*a);_=new jt(m,a,f)}if(i.sparse!==void 0){let p=Dh.SCALAR,g=Hs[i.sparse.indices.componentType],S=i.sparse.indices.byteOffset||0,T=i.sparse.values.byteOffset||0,y=new g(s[1],S,i.sparse.count*p),w=new c(s[2],T,i.sparse.count*a);if(o!==null)_=new jt(_.array.slice(),_.itemSize,_.normalized);_.normalized=!1;for(let A=0,R=y.length;A<R;A++){let x=y[A];if(_.setX(x,w[A*a]),a>=2)_.setY(x,w[A*a+1]);if(a>=3)_.setZ(x,w[A*a+2]);if(a>=4)_.setW(x,w[A*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}_.normalized=f}return _})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let d=(r.samplers||{})[s.sampler]||{};return l.magFilter=og[d.magFilter]||qt,l.minFilter=og[d.minFilter]||fi,l.wrapS=ag[d.wrapS]||As,l.wrapT=ag[d.wrapT]||As,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Kn&&l.minFilter!==qt,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let d=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(d),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(d,h){let f=d;if(t.isImageBitmapLoader===!0)f=function(m){let _=new Nt(m);_.needsUpdate=!0,d(_)};t.load(vr.resolveURL(u,r.path),f,void 0,h)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return yi(u,s),u.userData.mimeType=s.mimeType||jT(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[Je.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Je.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Je.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new Lo,xn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(o,a);n=a}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new Io,xn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return Hi}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Je.KHR_MATERIALS_UNLIT]){let u=i[Je.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new ze(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let d=u.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],Sn),o.opacity=d[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,dr));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=kn;let l=r.alphaMode||Oh.OPAQUE;if(l===Oh.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===Oh.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==gi){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ue(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==gi){if(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)o.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==gi){let u=r.emissiveFactor;o.emissive=new ze().setRGB(u[0],u[1],u[2],Sn)}if(r.emissiveTexture!==void 0&&s!==gi)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,dr));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(yi(u,r),t.associations.set(u,{materials:e}),r.extensions)Zr(i,u,r);return u})}createUniqueName(e){let t=ot.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Je.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return cg(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=XT(c),u=i[l];if(u)s.push(u.promise);else{let d;if(c.extensions&&c.extensions[Je.KHR_DRACO_MESH_COMPRESSION])d=r(c);else d=cg(new sn,c,t);if(c.mode===Vn.TRIANGLE_STRIP)d=d.then((h)=>Nh(h,So));else if(c.mode===Vn.TRIANGLE_FAN)d=d.then((h)=>Nh(h,Ps));i[l]={primitive:c,promise:d},s.push(d)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?$T(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let h=0,f=l.length;h<f;h++){let m=l[h],_=s[h],p,g=c[h];if(_.mode===Vn.TRIANGLES||_.mode===Vn.TRIANGLE_STRIP||_.mode===Vn.TRIANGLE_FAN||_.mode===void 0){let S=r.isSkinnedMesh===!0,T=m.hasAttribute("skinIndex")&&m.hasAttribute("skinWeight");if(S&&T===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=S&&T?new mc(m,g):new Mt(m,g),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(_.mode===Vn.LINES)p=new gc(m,g);else if(_.mode===Vn.LINE_STRIP)p=new pr(m,g);else if(_.mode===Vn.LINE_LOOP)p=new _c(m,g);else if(_.mode===Vn.POINTS)p=new Ds(m,g);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);if(Object.keys(p.geometry.morphAttributes).length>0)ZT(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),yi(p,r),_.extensions)Zr(i,p,_);t.assignFinalMaterial(p),u.push(p)}for(let h=0,f=u.length;h<f;h++)t.associations.set(u[h],{meshes:e,primitives:h});if(u.length===1){if(r.extensions)Zr(i,u[0],r);return u[0]}let d=new li;if(r.extensions)Zr(i,d,r);t.associations.set(d,{meshes:e});for(let h=0,f=u.length;h<f;h++)d.add(u[h]);return d})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Vt(Mo.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new $r(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return yi(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let d=new $e;if(r!==null)d.fromArray(r.array,c*16);a.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Co(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,d=i.channels.length;u<d;u++){let h=i.channels[u],f=i.samplers[h.sampler],m=h.target,_=m.node,p=i.parameters!==void 0?i.parameters[f.input]:f.input,g=i.parameters!==void 0?i.parameters[f.output]:f.output;if(m.node===void 0)continue;s.push(this.getDependency("node",_)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",g)),c.push(f),l.push(m)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let d=u[0],h=u[1],f=u[2],m=u[3],_=u[4],p=[];for(let S=0,T=d.length;S<T;S++){let y=d[S],w=h[S],A=f[S],R=m[S],x=_[S];if(y===void 0)continue;if(y.updateMatrix)y.updateMatrix();let M=n._createAnimationTracks(y,w,A,R,x);if(M)for(let z=0;z<M.length;z++)p.push(M[z])}let g=new Ss(r,void 0,p);return yi(g,i),g})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],d=c[2];if(d!==null)l.traverse(function(h){if(!h.isSkinnedMesh)return;h.bind(d,qT)});for(let h=0,f=u.length;h<f;h++)l.add(u[h]);if(l.userData.pivot!==void 0&&u.length>0){let h=l.userData.pivot,f=u[0];l.pivot=new U().fromArray(h),l.position.x-=h[0],l.position.y-=h[1],l.position.z-=h[2],f.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new To;else if(c.length>1)l=new li;else if(c.length===1)l=c[0];else l=new gt;if(l!==c[0])for(let u=0,d=c.length;u<d;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(yi(l,r),r.extensions)Zr(n,l,r);if(r.matrix!==void 0){let u=new $e;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new li;if(n.name)r.name=i.createUniqueName(n.name);if(yi(r,n),n.extensions)Zr(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let d=a[l];if(d.parent!==null)r.add(ig(d));else r.add(d)}let c=(l)=>{let u=new Map;for(let[d,h]of i.associations)if(d instanceof xn||d instanceof Nt)u.set(d,h);return l.traverse((d)=>{let h=i.associations.get(d);if(h!=null)u.set(d,h)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(h){if(h.morphTargetInfluences)a.push(h.name?h.name:h.uuid)}if(br[r.path]===br.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(br[r.path]){case br.weights:l=_r;break;case br.rotation:l=xr;break;case br.translation:case br.scale:l=Hr;break;default:switch(n.itemSize){case 1:l=_r;break;case 2:case 3:default:l=Hr;break}break}let u=i.interpolation!==void 0?HT[i.interpolation]:cc,d=this._getArrayFromAccessor(n);for(let h=0,f=a.length;h<f;h++){let m=new l(a[h]+"."+br[r.path],t.array,d,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(m);s.push(m)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=kh(t.constructor),i=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof xr?Ig:Vh)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function YT(e,t,n){let i=t.attributes,r=new Gt;if(i.POSITION!==void 0){let a=n.json.accessors[i.POSITION],{min:c,max:l}=a;if(c!==void 0&&l!==void 0){if(r.set(new U(c[0],c[1],c[2]),new U(l[0],l[1],l[2])),a.normalized){let u=kh(Hs[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new U,c=new U;for(let l=0,u=s.length;l<u;l++){let d=s[l];if(d.POSITION!==void 0){let h=n.json.accessors[d.POSITION],{min:f,max:m}=h;if(f!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),h.normalized){let _=kh(Hs[h.componentType]);c.multiplyScalar(_)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new wn;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function cg(e,t,n){let i=t.attributes,r=[];function s(o,a){return n.getDependency("accessor",o).then(function(c){e.setAttribute(a,c)})}for(let o in i){let a=zh[o]||o.toLowerCase();if(a in e.attributes)continue;r.push(s(i[o],a))}if(t.indices!==void 0&&!e.index){let o=n.getDependency("accessor",t.indices).then(function(a){e.setIndex(a)});r.push(o)}if(je.workingColorSpace!==Sn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${je.workingColorSpace}" not supported.`);return yi(e,t),YT(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?WT(e,t.targets,n):e})}function Wo(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function Hh(e,t="|"){return e.map((n)=>Zh(n)).join(t)}function Zo(e,t){if(typeof t==="bigint")return t.toString();return t}class Ng{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function Xo(e){return new Ng(e)}function Dg(e){return e===null||e===void 0}function Mr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Og(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function Gn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function jo(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Zi(e){return jo(e._zod.def)??e._zod.def.shape}function Ug(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Gn(this,t,i),i},enumerable:!0,configurable:!0})}function Fg(e,t,n){if(t in e)Gn(e,t,n);else e[t]=n}function Xr(e,t,n,i){let r=Zi(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)Ug(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else Fg(e,s,i?i(o.value,s):o.value)}}function JT(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)Ug(e,n,()=>t[n]);else Fg(e,n,i.value)}}function Tn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function zg(e){return JSON.stringify(e)}function kg(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var $h="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function $s(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Bg=Xo(()=>{if(hn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function jr(e){if($s(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if($s(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Wh(e){if(jr(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Vg=new Set(["string","number","symbol"]),Gg=new Set(["string","number","bigint","boolean","symbol","undefined"]);function ji(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vi(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function Ce(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Zh(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Hg(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Dc=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Xh={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function KT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return Xr(s,e,Oc(e,t)),vi(e,Tn(n,{shape:s,checks:[]}))}function Oc(e,t){let n=Zi(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function QT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Oc(e,t)),o={};return Xr(o,e,Reflect.ownKeys(Zi(e)).filter((a)=>!s.has(a))),vi(e,Tn(n,{shape:o,checks:[]}))}function e1(e,t){if(!jr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Zi(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return vi(e,Tn(e._zod.def,{shape:$g(e,t)}))}function $g(e,t){let n={};return Xr(n,e,Reflect.ownKeys(Zi(e))),JT(n,t),n}function t1(e,t){if(!jr(t))throw Error("Invalid input to safeExtend: expected a plain object");return vi(e,Tn(e._zod.def,{shape:$g(e,t)}))}function n1(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Xr(n,e,Reflect.ownKeys(Zi(e))),Xr(n,t,Reflect.ownKeys(Zi(t)));let i=Tn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return vi(e,i)}function Wg(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let a=n?new Set(Oc(t,n)):void 0,c={};return Xr(c,t,Reflect.ownKeys(Zi(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),vi(t,Tn(t._zod.def,{shape:c,checks:[]}))}function i1(e,t,n){let i=n?new Set(Oc(t,n)):void 0,r={};return Xr(r,t,Reflect.ownKeys(Zi(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),vi(t,Tn(t._zod.def,{shape:r}))}function Hn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Zg(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function bi(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function $o(e){return typeof e==="string"?e:e?.message}function jh(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function Si(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:$o(e.inst?._zod.def?.error?.(e))??$o(s?.(e))??$o(t?.error?.(e))??$o(n.customError?.(e))??$o(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=e.input;return a}var r1=/[\uD800-\uDBFF]/;function Uc(e){let t=e.length;if(!r1.test(e))return t;let n=t;for(let i=0;i<t-1;i++)if((e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320)n--,i++;return n}function Fc(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Xg(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function qr(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function jg(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else s1(e,n,i.value)}}function Xi(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function zc(e,t,n){return Xi(e,t,n,!1)}function qg(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Xi(this,n,i(this))},set(r){Xi(this,n,r)}})}return t}function s1(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Xi(this,t,n.bind(this))},set(i){Xi(this,t,i)}})}function o1(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Gh,Sr=!1,a1={configurable:!0,get(){Sr=!0;return}};function at(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&Gh!==e._zod){Gh=void 0;return}Gh=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,a1);let r=Sr;Sr=!1;try{let s=n(this);if(Sr)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Sr=Sr||r,s}catch(s){throw delete this[t],Sr=Sr||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function c1(e,t,n,i){let r=o1(e,t);if(!r)return;Object.defineProperty(r,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:s})}})}var l1="~constantCatch";function Yg(e){let t=()=>e;return t[l1]=!0,t}var Jg;var qh={value:void 0,enumerable:!1},Kg="captureStackTrace"in Error?Error:null;function u1(e){let t=Kg;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Kg=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function J(e,t,n,i){let r={};function s(h){this.def=h,this.constr=d,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(h,f){if(!h._zod){qh.value=new s(f);try{Object.defineProperty(h,"_zod",qh)}finally{qh.value=void 0}}else if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,f),a){let _=Object.getPrototypeOf(h),p=h._zod.constr.prototype,g=_;while(g&&g!==p)g=Object.getPrototypeOf(g);let S=g??_;if(!a.has(S))a.add(S),jg(S,o)}let m=d.prototype;for(let _ in m){if(!Object.prototype.hasOwnProperty.call(m,_))continue;if(!(_ in h))h[_]=m[_].bind(h)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(h){let f=i?.Parent?u1(u):this;c(f,h);let m=f._zod.deferred;if(m){for(let p of m)p();f._zod.deferred=void 0}let _=globalThis.__zod_globalConfig?.postProcessor;if(_)_(f);return f}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:(h)=>{if(i?.Parent&&h instanceof i.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(d,"name",{value:e}),d}class Mi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class qo extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Jg=globalThis).__zod_globalConfig??(Jg.__zod_globalConfig={});var hn=globalThis.__zod_globalConfig;function Rn(e){if(e)Object.assign(hn,e);return hn}function h1(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Zo,2)),e.message}function d1(e){this._zod.message=e}var f1={get:h1,set:d1,enumerable:!0,configurable:!0},Jh={value:void 0,enumerable:!1},Qg=new WeakSet([Object.prototype,Error.prototype]),e_=(e,t)=>{e.name="$ZodError",Jh.value=t,Object.defineProperty(e,"issues",Jh),Jh.value=void 0,Object.defineProperty(e,"message",f1);let n=Object.getPrototypeOf(e);if(!Qg.has(n))Qg.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}})},t_=J("$ZodError",e_),UN=J("$ZodError",e_,void 0,{Parent:Error});function p1(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function n_(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)p1(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function i_(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],d=l===a.length-1;if(u==="_errors"){if(d)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=c[u];if(d)h._errors.push(t(o));c=h,l++}}}};return i(e),n}function kc(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Bc=(e)=>{let t=(n,i,r,s)=>{let o=r?{...r,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new Mi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Si(l,o,Rn())));throw $h(c,s?.callee??t),c}return a.value};return t};var Vc=(e)=>{let t=async(n,i,r,s)=>{let o=r?{...r,async:!0}:{async:!0},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Si(l,o,Rn())));throw $h(c,s?.callee??t),c}return a.value};return t};var Gc=(e)=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new Mi;return s.issues.length?r_(e,s.issues,r):{success:!0,data:s.value}};function r_(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>Si(r,n,Rn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Hc=(e)=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?r_(e,s.issues,r):{success:!0,data:s.value}};var m1=Symbol.for("zod.compile.invalid"),g1=Symbol.for("zod.compile.fallback"),Kh=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==m1)return!0;if(i.definite===!0&&n===void 0)return!1}return _1(e,t,n)};function _1(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[g1]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Mi;return s.issues.length===0}var Qh=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)r=await r;return r.issues.length===0},s_=(e)=>{let t=Bc(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,kc(n,o))};return n};var o_=(e)=>{let t=Bc(e),n=(i,r,s,o)=>t(i,r,s,kc(n,o));return n};var a_=(e)=>{let t=Vc(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,kc(n,o))};return n};var c_=(e)=>{let t=Vc(e),n=async(i,r,s,o)=>await t(i,r,s,kc(n,o));return n};var l_=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Gc(e)(t,n,r)};var u_=(e)=>(t,n,i)=>Gc(e)(t,n,i);var h_=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Hc(e)(t,n,r)};var d_=(e)=>async(t,n,i)=>Hc(e)(t,n,i);var f_=/^[cC][0-9a-z]{6,}$/,p_=/^[0-9a-z]+$/,m_=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,g_=/^[0-9a-vA-V]{20}$/,__=/^[A-Za-z0-9]{27}$/,x_=/^[a-zA-Z0-9_-]{21}$/;function y_(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var v_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var b_=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,td=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var S_=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var x1="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function M_(){return new RegExp(x1,"u")}var w_=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,E_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var A_=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,T_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,R_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,C_=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var P_=/^https?$/,I_=/^\+[1-9]\d{6,14}$/;var L_="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function y1(e){return new RegExp(`^${e}$`)}var N_=y1(L_);function ed(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function D_(e){return new RegExp(`^${ed(e)}$`)}function O_(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${ed({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${ed({precision:e.precision})}`:n;return new RegExp(`^${L_}T(?:${i})$`)}var U_=/^[\s\S]{0,}$/,F_=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var $c=/^-?\d+$/,Ws=/^-?\d+(?:\.\d+)?$/,z_=/^(?:true|false)$/i;var k_=/^[^A-Z]*$/,B_=/^[^a-z]*$/;var Kt=J("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var nd=(e)=>{let t=e.value;return!Dg(t)&&t.length!==void 0},Wc={number:"number",bigint:"bigint",object:"date"},id=J("$ZodCheckLessThan",(e,t)=>{Kt.init(e,t);let n=Wc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:Wc[typeof i.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),rd=J("$ZodCheckGreaterThan",(e,t)=>{Kt.init(e,t);let n=Wc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:Wc[typeof i.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),V_=J("$ZodCheckMultipleOf",(e,t)=>{Kt.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Og(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),G_=J("$ZodCheckNumberFormat",(e,t)=>{Kt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Dc[t.format];e._zod.check=(o)=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(a<r)o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(a>s)o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var H_=J("$ZodCheckMaxLength",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=nd),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Uc(r):s)<=t.maximum)return;let a=Fc(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$_=J("$ZodCheckMinLength",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=nd),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Uc(r):s)>=t.minimum)return;let a=Fc(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),W_=J("$ZodCheckLengthEquals",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=nd),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?Uc(r):s;if(o===t.length)return;let a=Fc(r),c=o>t.length;i.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),Jo=J("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Kt.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),Z_=J("$ZodCheckRegex",(e,t)=>{Jo.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),X_=J("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=k_),Jo.init(e,t)}),j_=J("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=B_),Jo.init(e,t)}),q_=J("$ZodCheckIncludes",(e,t)=>{Kt.init(e,t);let n=ji(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Y_=J("$ZodCheckStartsWith",(e,t)=>{Kt.init(e,t);let n=new RegExp(`^${ji(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),J_=J("$ZodCheckEndsWith",(e,t)=>{Kt.init(e,t);let n=new RegExp(`.*${ji(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var K_=J("$ZodCheckOverwrite",(e,t)=>{Kt.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class sd{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(``).filter((s)=>s),i=Math.min(...n.map((s)=>s.length-s.trimStart().length)),r=n.map((s)=>s.slice(i)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of r)this.content.push(s)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {${t.join(``)}-};`)(...Object.values(this.closed))}}var K_={major:4,minor:6,patch:5};var vt=J("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=K_;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=Hn(a),d;for(let h of c){if(h._zod.def.when){if($g(a))continue;if(!h._zod.def.when(a))continue}else if(u)continue;let f=a.issues.length,m=h._zod.check(a);if(m instanceof Promise&&l?.async===!1)throw new Mi;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(Zh(a.issues,f,e),!u)u=Hn(a,f)});else{if(a.issues.length===f)continue;if(Zh(a.issues,f,e),!u)u=Hn(a,f)}}if(d)return d.then(()=>a);return a},o=(a,c,l)=>{if(Hn(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new Mi;return u.then((d)=>e._zod.parse(d,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((d)=>o(d,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new Mi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return Uc(this,"~standard",od(this))},set "~standard"(e){Xi(this,"~standard",e)}}),d0=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>Si(n,t,Cn()))}:{value:e.value};async function _1(e,t){let n={async:!0};return d0(await e._zod.run({value:t,issues:[]},n),n)}function od(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return d0(i,n)}catch(i){}return _1(e,t)},vendor:"zod",version:1}}var Xc=J("$ZodString",(e,t)=>{vt.init(e,t),e._zod.pattern=t.pattern??D_,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Rt=J("$ZodStringFormat",(e,t)=>{Yo.init(e,t),Xc.init(e,t)}),f0=J("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=y_),Rt.init(e,t)}),p0=J("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Qh(i))}else t.pattern??(t.pattern=Qh());Rt.init(e,t)}),m0=J("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=v_),Rt.init(e,t)}),g0=1,Wc=2;function _0(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function x1(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return _0(e)||Wc;return y1(e,t)}function y1(e,t){if(!t.normalize&&t.protocol?.source===R_.source&&!/^https?:\/\//i.test(e))return g0;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Wc}return new URL(e)}catch{return Wc}}var v1=/[\t\n\r]/g;function Q_(e){return e.replace(v1,"")}function b1(e,t){return t.lastIndex=0,t.test(e.hostname)}function S1(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var x0=J("$ZodURL",(e,t)=>{Rt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=x1(i,t);if(r===g0){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===Wc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=Q_(i);return}if(t.hostname&&!b1(r,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!S1(r,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?r.href:Q_(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),y0=J("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=b_()),Rt.init(e,t)}),v0=J("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?g_:__(t.length)),Rt.init(e,t)}),b0=J("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=h_),Rt.init(e,t)}),S0=J("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=d_),Rt.init(e,t)}),M0=J("$ZodULID",(e,t)=>{t.pattern??(t.pattern=f_),Rt.init(e,t)}),w0=J("$ZodXID",(e,t)=>{t.pattern??(t.pattern=p_),Rt.init(e,t)}),E0=J("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=m_),Rt.init(e,t)}),A0=J("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=N_(t)),Rt.init(e,t)}),T0=J("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=I_),Rt.init(e,t)}),R0=J("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=L_(t)),Rt.init(e,t)}),C0=J("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=x_),Rt.init(e,t)}),P0=J("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=S_),Rt.init(e,t)}),M1=/^[0-9a-fA-F:.]+$/;function I0(e){if(!M1.test(e))return!1;return _0(`http://[${e}]`)}var L0=J("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=M_),Rt.init(e,t),e._zod.check=(n)=>{if(!I0(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var N0=J("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=w_),Rt.init(e,t)});function w1(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);if(`${r}`!==i)return!1;if(r<0||r>128)return!1;return I0(n)}var D0=J("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=E_),Rt.init(e,t),e._zod.check=(n)=>{if(!w1(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function O0(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var ad=/^[0-9a-zA-Z+/]*={0,2}$/,U0=J("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ad),Rt.init(e,t),e._zod.check=(n)=>{if(O0(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),jc=/^[A-Za-z0-9_-]*$/;function E1(e){if(!jc.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return O0(n)}var F0=J("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=jc),Rt.init(e,t),e._zod.check=(n)=>{if(E1(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),z0=J("$ZodE164",(e,t)=>{t.pattern??(t.pattern=C_),Rt.init(e,t)});function A1(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&(!("alg"in r)||r.alg!==t))return!1;return!0}catch{return!1}}var k0=J("$ZodJWT",(e,t)=>{Rt.init(e,t),e._zod.check=(n)=>{if(A1(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var cd=J("$ZodNumber",(e,t)=>{vt.init(e,t),e._zod.pattern=Ws,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),B0=J("$ZodNumberFormat",(e,t)=>{B_.init(e,t),cd.init(e,t)}),V0=J("$ZodBoolean",(e,t)=>{vt.init(e,t),e._zod.pattern=U_,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let r=n.value;if(typeof r==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});var G0=J("$ZodUnknown",(e,t)=>{vt.init(e,t),e._zod.parse=(n)=>n}),H0=J("$ZodNever",(e,t)=>{vt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function e0(e,t,n){if(e.issues.length)t.issues.push(...bi(n,e.issues));t.value[n]=e.value}var $0=J("$ZodArray",(e,t)=>{vt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((d)=>e0(d,i,c)));else if(e0(u,i,c),a&&u.issues.length!==0&&Hn(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function Zc(e,t,n,i,r,s){let o=n in i,a=s==="optional";if(!o&&a&&r==="optional")return;if(e.issues.length){if(r!==void 0&&a&&!o)return;t.issues.push(...bi(n,e.issues))}if(!o&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(o||r==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var T1=[];function W0(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:T1,r=i.length?[...t,...i]:t;for(let o of r)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(o)}": expected a Zod schema`);let s=Vg(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Z0(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:d,optout:h}=l,f=0;for(let m in t){if(o&&n.issues.length!==f){if(Hn(n,f))break;f=n.issues.length}if(c.has(m))continue;if(m==="__proto__"){if(u==="never")a.push(m);continue}if(u==="never"){a.push(m);continue}let _=l.run({value:t[m],issues:[]},i);if(_ instanceof Promise)e.push(_.then((p)=>Zc(p,n,m,t,d,h)));else Zc(_,n,m,t,d,h)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var R1=J("$ZodObject",(e,t)=>{vt.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=Zo(()=>W0(t));at(e,"propValues",(l)=>{let u=l.def.shape,d={};for(let h in u){let f=u[h]._zod;if(f.values){if(!Object.prototype.hasOwnProperty.call(d,h))Gn(d,h,new Set);for(let m of f.values)d[h].add(m);if(f.optin!==void 0)d[h].add(void 0)}}return d});let s=$s,o=t.catchall,a,c=dn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let d=l.value;if(!s(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let h=[],f=a.shape,m=u?.abortEarly,_=l.issues.length;for(let p of a.allKeys){if(m&&l.issues.length!==_){if(Hn(l,_))break;_=l.issues.length}if(p==="__proto__")continue;let g=f[p],S=g._zod.optin,T=g._zod.optout,y=g._zod.run({value:d[p],issues:[]},u);if(y instanceof Promise)h.push(y.then((w)=>Zc(w,l,p,d,S,T)));else Zc(y,l,p,d,S,T)}if(!o)return h.length?Promise.all(h).then(()=>l):l;return Z0(h,d,l,u,r.value,e,m===!0)}}),X0=J("$ZodObjectJIT",(e,t)=>{R1.init(e,t);let n=e._zod.parse,i=Zo(()=>W0(t)),r=dn.memoizer,s=(f)=>{let m=i.value,_=m.symbolKeys,p=new id(["payload","ctx"],{shape:f,inst:e,memo:r,syms:_}),g=(w)=>`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`,S=(w,A)=>`+};`)(...Object.values(this.closed))}}var e0={major:4,minor:6,patch:5};var vt=J("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=e0;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=Hn(a),d;for(let h of c){if(h._zod.def.when){if(Zg(a))continue;if(!h._zod.def.when(a))continue}else if(u)continue;let f=a.issues.length,m=h._zod.check(a);if(m instanceof Promise&&l?.async===!1)throw new Mi;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(jh(a.issues,f,e),!u)u=Hn(a,f)});else{if(a.issues.length===f)continue;if(jh(a.issues,f,e),!u)u=Hn(a,f)}}if(d)return d.then(()=>a);return a},o=(a,c,l)=>{if(Hn(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new Mi;return u.then((d)=>e._zod.parse(d,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((d)=>o(d,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new Mi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return zc(this,"~standard",cd(this))},set "~standard"(e){Xi(this,"~standard",e)}}),p0=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>Si(n,t,Rn()))}:{value:e.value};async function v1(e,t){let n={async:!0};return p0(await e._zod.run({value:t,issues:[]},n),n)}function cd(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return p0(i,n)}catch(i){}return v1(e,t)},vendor:"zod",version:1}}var qc=J("$ZodString",(e,t)=>{vt.init(e,t),e._zod.pattern=t.pattern??U_,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Rt=J("$ZodStringFormat",(e,t)=>{Jo.init(e,t),qc.init(e,t)}),m0=J("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=b_),Rt.init(e,t)}),g0=J("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=td(i))}else t.pattern??(t.pattern=td());Rt.init(e,t)}),_0=J("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=S_),Rt.init(e,t)}),x0=1,Xc=2;function y0(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function b1(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return y0(e)||Xc;return S1(e,t)}function S1(e,t){if(!t.normalize&&t.protocol?.source===P_.source&&!/^https?:\/\//i.test(e))return x0;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Xc}return new URL(e)}catch{return Xc}}var M1=/[\t\n\r]/g;function t0(e){return e.replace(M1,"")}function w1(e,t){return t.lastIndex=0,t.test(e.hostname)}function E1(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var v0=J("$ZodURL",(e,t)=>{Rt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=b1(i,t);if(r===x0){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===Xc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=t0(i);return}if(t.hostname&&!w1(r,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!E1(r,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?r.href:t0(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),b0=J("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=M_()),Rt.init(e,t)}),S0=J("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?x_:y_(t.length)),Rt.init(e,t)}),M0=J("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=f_),Rt.init(e,t)}),w0=J("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=p_),Rt.init(e,t)}),E0=J("$ZodULID",(e,t)=>{t.pattern??(t.pattern=m_),Rt.init(e,t)}),A0=J("$ZodXID",(e,t)=>{t.pattern??(t.pattern=g_),Rt.init(e,t)}),T0=J("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=__),Rt.init(e,t)}),R0=J("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=O_(t)),Rt.init(e,t)}),C0=J("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=N_),Rt.init(e,t)}),P0=J("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=D_(t)),Rt.init(e,t)}),I0=J("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=v_),Rt.init(e,t)}),L0=J("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=w_),Rt.init(e,t)}),A1=/^[0-9a-fA-F:.]+$/;function N0(e){if(!A1.test(e))return!1;return y0(`http://[${e}]`)}var D0=J("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=E_),Rt.init(e,t),e._zod.check=(n)=>{if(!N0(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var O0=J("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=A_),Rt.init(e,t)});function T1(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);if(`${r}`!==i)return!1;if(r<0||r>128)return!1;return N0(n)}var U0=J("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=T_),Rt.init(e,t),e._zod.check=(n)=>{if(!T1(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function F0(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var ld=/^[0-9a-zA-Z+/]*={0,2}$/,z0=J("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ld),Rt.init(e,t),e._zod.check=(n)=>{if(F0(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Yc=/^[A-Za-z0-9_-]*$/;function R1(e){if(!Yc.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return F0(n)}var k0=J("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Yc),Rt.init(e,t),e._zod.check=(n)=>{if(R1(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),B0=J("$ZodE164",(e,t)=>{t.pattern??(t.pattern=I_),Rt.init(e,t)});function C1(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&(!("alg"in r)||r.alg!==t))return!1;return!0}catch{return!1}}var V0=J("$ZodJWT",(e,t)=>{Rt.init(e,t),e._zod.check=(n)=>{if(C1(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var ud=J("$ZodNumber",(e,t)=>{vt.init(e,t),e._zod.pattern=Ws,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),G0=J("$ZodNumberFormat",(e,t)=>{G_.init(e,t),ud.init(e,t)}),H0=J("$ZodBoolean",(e,t)=>{vt.init(e,t),e._zod.pattern=z_,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let r=n.value;if(typeof r==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});var $0=J("$ZodUnknown",(e,t)=>{vt.init(e,t),e._zod.parse=(n)=>n}),W0=J("$ZodNever",(e,t)=>{vt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function n0(e,t,n){if(e.issues.length)t.issues.push(...bi(n,e.issues));t.value[n]=e.value}var Z0=J("$ZodArray",(e,t)=>{vt.init(e,t);let n=hn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((d)=>n0(d,i,c)));else if(n0(u,i,c),a&&u.issues.length!==0&&Hn(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function jc(e,t,n,i,r,s){let o=n in i,a=s==="optional";if(!o&&a&&r==="optional")return;if(e.issues.length){if(r!==void 0&&a&&!o)return;t.issues.push(...bi(n,e.issues))}if(!o&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(o||r==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var P1=[];function X0(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:P1,r=i.length?[...t,...i]:t;for(let o of r)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(o)}": expected a Zod schema`);let s=Hg(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function j0(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:d,optout:h}=l,f=0;for(let m in t){if(o&&n.issues.length!==f){if(Hn(n,f))break;f=n.issues.length}if(c.has(m))continue;if(m==="__proto__"){if(u==="never")a.push(m);continue}if(u==="never"){a.push(m);continue}let _=l.run({value:t[m],issues:[]},i);if(_ instanceof Promise)e.push(_.then((p)=>jc(p,n,m,t,d,h)));else jc(_,n,m,t,d,h)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var I1=J("$ZodObject",(e,t)=>{vt.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=Xo(()=>X0(t));at(e,"propValues",(l)=>{let u=l.def.shape,d={};for(let h in u){let f=u[h]._zod;if(f.values){if(!Object.prototype.hasOwnProperty.call(d,h))Gn(d,h,new Set);for(let m of f.values)d[h].add(m);if(f.optin!==void 0)d[h].add(void 0)}}return d});let s=$s,o=t.catchall,a,c=hn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let d=l.value;if(!s(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let h=[],f=a.shape,m=u?.abortEarly,_=l.issues.length;for(let p of a.allKeys){if(m&&l.issues.length!==_){if(Hn(l,_))break;_=l.issues.length}if(p==="__proto__")continue;let g=f[p],S=g._zod.optin,T=g._zod.optout,y=g._zod.run({value:d[p],issues:[]},u);if(y instanceof Promise)h.push(y.then((w)=>jc(w,l,p,d,S,T)));else jc(y,l,p,d,S,T)}if(!o)return h.length?Promise.all(h).then(()=>l):l;return j0(h,d,l,u,r.value,e,m===!0)}}),q0=J("$ZodObjectJIT",(e,t)=>{I1.init(e,t);let n=e._zod.parse,i=Xo(()=>X0(t)),r=hn.memoizer,s=(f)=>{let m=i.value,_=m.symbolKeys,p=new sd(["payload","ctx"],{shape:f,inst:e,memo:r,syms:_}),g=(w)=>`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`,S=(w,A)=>`let ${w}_ab = false;for (let i = 0; i < ${w}.issues.length; i++) {const iss = ${w}.issues[i];@@ -4356,7 +4356,7 @@ ${t.join(`if (${w}_ab && ctx && ctx.abortEarly) {payload.value = newResult;return payload;- }`;p.write("const input = payload.value;");let T=Object.create(null),y=0;for(let w of m.allKeys)T[w]=`key_${y++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let w of m.allKeys){if(w==="__proto__")continue;let A=T[w],R=typeof w==="symbol"?`syms[${_.indexOf(w)}]`:Ug(w),x=`${R} in input`,M=f[w],z=M?._zod?.optin,C=z!==void 0,L=M?._zod?.optout==="optional";if(p.write(`const ${A} = ${g(R)};`),C&&L){let K=z==="optional"?`${A}_present`:`${A}.value !== undefined || ${A}_present`;p.write(`+ }`;p.write("const input = payload.value;");let T=Object.create(null),y=0;for(let w of m.allKeys)T[w]=`key_${y++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let w of m.allKeys){if(w==="__proto__")continue;let A=T[w],R=typeof w==="symbol"?`syms[${_.indexOf(w)}]`:zg(w),x=`${R} in input`,M=f[w],z=M?._zod?.optin,C=z!==void 0,L=M?._zod?.optout==="optional";if(p.write(`const ${A} = ${g(R)};`),C&&L){let K=z==="optional"?`${A}_present`:`${A}.value !== undefined || ${A}_present`;p.write(`const ${A}_present = ${x};if (!${A}.issues.length || ${A}_present) {if (${A}.issues.length) {${S(A,R)}@@ -4395,18 +4395,18 @@ ${t.join(`if (${A}.value !== undefined || ${x}) {newResult[${R}] = ${A}.value;}- `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=$s,c=!dn.jitless,u=c&&zg.value,d=t.catchall,h;e._zod.parse=(f,m)=>{h??(h=i.value);let _=f.value;if(!a(_))return f.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),f;if(c&&u&&m?.async===!1&&m.jitless!==!0){if(!o)o=s(t.shape);if(f=o(f,m),!d)return f;return Z0([],_,f,m,h,e,m?.abortEarly===!0)}return n(f,m)}});function t0(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!Hn(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((o)=>Si(o,i,Cn())))}),t}var ld=J("$ZodUnion",(e,t)=>{vt.init(e,t),at(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),at(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),at(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),at(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>Mr(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}if(!s)return t0(o,i,e,r);return Promise.all(o).then((a)=>t0(a,i,e,r))}});function C1(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var j0=J("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,ld.init(e,t);let n=e._zod.parse;at(e,"propValues",(r)=>{let s={},o=0;for(let a of r.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(a)}"`);if(c[r.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))Gn(s,l,new Set);for(let d of u)s[l].add(d)}}if(!r.def.unionFallback&&o>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let o=Xo(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=Zo(()=>C1(t));e._zod.parse=(r,s)=>{let o=r.value;if(!$s(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let a=o?.[t.discriminator],c=i.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),r}}),q0=J("$ZodIntersection",(e,t)=>{vt.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),o=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||o instanceof Promise)return Promise.all([s,o]).then(([c,l])=>n0(n,c,l));return n0(n,s,o)}});function rd(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(jr(e)&&jr(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let o=rd(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],s=t[i],o=rd(r,s);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function n0(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let d;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),d=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let h=String(l.path[0]);if(!s.has(h))s.set(h,l);d=[h]}else return!1;for(let h of d){if(!i.has(h))i.set(h,{});i.get(h)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=rd(t.value,n.value);if(!c.valid){if(Hn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Y0=J("$ZodTuple",(e,t)=>{vt.init(e,t);let n=t.items,i=dn.memoizer;i?.attach(e),e._zod.parse=(r,s)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(e,r,[],s):[];let a=[],c=i0(n,"optin"),l=i0(n,"optout");if(!t.rest){if(o.length<c)return r.issues.push({code:"too_small",minimum:c,inclusive:!0,input:o,inst:e,origin:"array"}),r;if(o.length>n.length)r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:o,inst:e,origin:"array"})}let u=Array(n.length),d=t.rest?s?.abortEarly:void 0,h=!1;for(let f=0;f<n.length;f++){let m=n[f]._zod.run({value:o[f],issues:[]},s);if(m instanceof Promise)a.push(m.then((_)=>{u[f]=_}));else if(u[f]=m,d&&!h&&m.issues.length)h=Hn(m)}if(t.rest&&!h){let f=n.length-1,m=o.slice(n.length),_=r.issues.length;for(let p of m){if(d&&r.issues.length!==_){if(Hn(r,_))break;_=r.issues.length}f++;let g=t.rest._zod.run({value:p,issues:[]},s);if(g instanceof Promise)a.push(g.then((S)=>r0(S,r,f)));else r0(g,r,f)}}if(a.length)return Promise.all(a).then(()=>s0(u,r,n,o,l));return s0(u,r,n,o,l)}});function i0(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function r0(e,t,n){if(e.issues.length)t.issues.push(...bi(n,e.issues));t.value[n]=e.value}function s0(e,t,n,i,r){for(let s=0;s<n.length;s++){let o=e[s],a=s<i.length;if(!a&&s>=r&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(o.issues.length){if(!a&&s>=r){t.value.length=s;break}t.issues.push(...bi(s,o.issues))}t.value[s]=o.value}for(let s=t.value.length-1;s>=i.length;s--)if(n[s]._zod.optout==="optional"&&t.value[s]===void 0)t.value.length=s;else break;return t}var J0=J("$ZodRecord",(e,t)=>{vt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!jr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((m)=>Si(m,r,Cn())),input:u,path:[u],inst:e});continue}let h=d.value;if(h==="__proto__")continue;let f=t.valueType._zod.run({value:s[u],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...bi(u,m.issues));i.value[h]=m.value}));else{if(f.issues.length)i.issues.push(...bi(u,f.issues));i.value[h]=f.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&Ws.test(l)&&u.issues.length){let m=t.keyType._zod.run({value:Number(l),issues:[]},r);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length===0)u=m}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((m)=>Si(m,r,Cn())),input:l,path:[l],inst:e});continue}let h=u.value;if(h==="__proto__")continue;let f=t.valueType._zod.run({value:s[l],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...bi(l,m.issues));i.value[h]=m.value}));else{if(f.issues.length)i.issues.push(...bi(l,f.issues));i.value[h]=f.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var K0=J("$ZodEnum",(e,t)=>{vt.init(e,t);let n=$o(t.entries),i=new Set(n);e._zod.values=i,at(e,"pattern",(r)=>{let s=$o(r.def.entries).filter((o)=>kg.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>ji(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let o=r.value;if(i.has(o))return r;return r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),Q0=J("$ZodLiteral",(e,t)=>{vt.init(e,t);let n=new Set(t.values);e._zod.values=n,at(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?ji(s):s?ji(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var ex=J("$ZodTransform",(e,t)=>{vt.init(e,t),e._zod.optin="optional",dn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new jo(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((o)=>(n.value=o,n));if(r instanceof Promise)throw new Mi;return n.value=r,n}});function o0(e,t){return e.value=t.issues.length?void 0:t.value,e}var ud=J("$ZodOptional",(e,t)=>{vt.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Mr(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>o0(n,s));return o0(n,r)}return t.innerType._zod.run(n,i)}}),tx=J("$ZodExactOptional",(e,t)=>{ud.init(e,t),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),nx=J("$ZodNullable",(e,t)=>{vt.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Mr(i.source)}|null)$`):void 0}),at(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),ix=J("$ZodDefault",(e,t)=>{vt.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>a0(s,t));return a0(r,t)}});function a0(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var rx=J("$ZodPrefault",(e,t)=>{vt.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),sx=J("$ZodNonOptional",(e,t)=>{vt.init(e,t),at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>c0(s,e));return c0(r,e)}});function c0(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function l0(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>Si(r,i,Cn()))},input:e.value}),e}var ox=J("$ZodCatch",(e,t)=>{vt.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>l0(n,s,t,i));return l0(n,r,t,i)}});var ax=J("$ZodPipe",(e,t)=>{vt.init(e,t),at(e,"values",(n)=>n.def.in._zod.values),at(e,"optin",(n)=>n.def.in._zod.optin),at(e,"optout",(n)=>n.def.out._zod.optout),at(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>$c(o,t.in,i));return $c(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>$c(s,t.out,i));return $c(r,t.out,i)}});function $c(e,t,n){if(e.issues.some((i)=>i.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var cx=J("$ZodReadonly",(e,t)=>{vt.init(e,t),at(e,"propValues",(n)=>n.def.innerType._zod.propValues),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"optin",(n)=>n.def.innerType?._zod?.optin),at(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(u0);return u0(r)}});function u0(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function P1(e){let t=e._zod.def,n=t.pattern,i=!!t.format?.includes("int"),r,s;for(let a of t.checks??[]){let c=a._zod.def;if(c.pattern)n=c.pattern;i||(i=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;if(l!==void 0&&(r===void 0||l>r))r=l;if(u!==void 0&&(s===void 0||u<s))s=u}if(n)return n.source;if(r!==void 0&&s!==void 0&&r>s)return"(?!)";if(r!==void 0||s!==void 0)return O_({minimum:r,maximum:s}).source;let o=e._zod.pattern;return(i&&o===Ws?Gc:o)?.source}function sd(e){let t=e._zod.def,n=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let r=i._zod.pattern?.source,s=sd(i);if(n&&r&&s&&s!==r)return n.replace(Mr(r),()=>Mr(s));return n}if(t.options){let r=t.options.map(sd);if(r.every(Boolean))return`^(${r.map((s)=>Mr(s)).join("|")})$`}return P1(e)}var lx=J("$ZodTemplateLiteral",(e,t)=>{vt.init(e,t);let n=[];for(let i of t.parts)if(typeof i==="object"&&i!==null){let r=sd(i);if(!r)throw Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);n.push(Mr(r))}else if(i===null||Bg.has(typeof i))n.push(ji(`${i}`));else throw Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>{if(typeof i.value!=="string")return i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(i.value))return i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i;return i}});var ux=J("$ZodCustom",(e,t)=>{Kt.init(e,t),vt.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>h0(s,n,i,e));h0(r,n,i,e);return}});function h0(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(qr(r))}}class dx extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var dd="~memo",hx=[];function fx(e){return e!==null&&typeof e==="object"}function hd(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var px=new WeakMap,Jo=0,Jc=1,Ko=2;function Kc(e,t,n){let i=px.get(e);if(i!==void 0)return i?Ko:Jo;if(t.has(e))return Ko;t.add(e);let r=Jo,s=(u)=>{if(r!==Ko&&u?._zod){let d=Kc(u,t,n);if(d>r)r=d}},o=(u,d)=>{let h=Jo;for(let f of Reflect.ownKeys(u)){let m=Object.getOwnPropertyDescriptor(u,f);if(d&&!m.enumerable)continue;let _=m.get?Jc:m.value?._zod?Kc(m.value,t,n):Jo;if(_>h)h=_}return h},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=Xo(c);a(u?o(u,!0):Jc),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?Kc(u,t,!1):Jc);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let d=Object.getOwnPropertyDescriptor(c,u);if(!d||d.get)continue;let h=d.value;if(!h||typeof h!=="object")continue;if(h._zod)s(h);else if(Array.isArray(h))for(let f of h)s(f)}}return t.delete(e),I1(e,r)}function I1(e,t){if(t!==Jc)px.set(e,t===Ko);return t}function L1(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var qc,Yc=[],N1={alloc(e,t,n){let i=qc;if(!i)return n;qc=void 0;let r={value:n,issues:null};return i.set(t.value,r),Yc.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,s)=>{if(s.direction!=="backward"&&D1(s,r.value))throw new dx;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let g=Kc(e,new Set,!1);if(g===Jo){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(g===Ko||i)n=!0;else i=!0}let u=c.value;if(!fx(u))return o(c,l);let d=l[dd];if(!d)d={buckets:new WeakMap,backEdges:void 0},l[dd]=d;let h;if(r===l)h=s;else h=L1(d,e),r=l,s=h;let f=h.get(u);if(f){if(c.value=f.value,f.issues){if(f.issues.length)c.issues.push(...hd(f.issues))}else c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(f.value);return c}qc=h;let m=Yc.length,_=o(c,l);qc=void 0;let p=Yc.length>m?Yc.pop():void 0;if(_ instanceof Promise)return _.then((g)=>{if(p)p.issues=g.issues.length?hd(g.issues):hx;return g});if(p)p.issues=_.issues.length?hd(_.issues):hx;return _};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function mx(){return N1}function D1(e,t){let n=e[dd]?.backEdges;return n!==void 0&&fx(t)&&n.has(t)}var O1=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(s,o){if(s==="number"&&typeof o==="number"&&!Number.isFinite(o))return String(o);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let o=r(s.expected),a=Wg(s.input),c=r(a,s.input);return`Invalid input: expected ${o}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${$h(s.values[0])}`;return`Invalid option: expected one of ${Vh(s.values,"|")}`;case"too_big":{let o=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${o}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${o}${s.maximum.toString()}`}case"too_small":{let o=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${o}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${o}${s.minimum.toString()}`}case"invalid_format":{let o=s;if(o.format==="starts_with")return`Invalid string: must start with "${o.prefix}"`;if(o.format==="ends_with")return`Invalid string: must end with "${o.suffix}"`;if(o.format==="includes")return`Invalid string: must include "${o.includes}"`;if(o.format==="regex")return`Invalid string: must match pattern ${o.pattern}`;return`Invalid ${n[o.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${Vh(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function fd(){return{localeError:O1()}}var gx;class _x{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function U1(){return new _x}(gx=globalThis).__zod_globalRegistry??(gx.__zod_globalRegistry=U1());var Yr=globalThis.__zod_globalRegistry;function xx(e){if(e.checks)e.checks=[...e.checks];return e}function yx(e,t){return new e(xx({type:"string",...Ce(t)}))}function vx(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ce(t)})}function bx(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ce(t)})}function Sx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ce(t)})}function Mx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ce(t)})}function wx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ce(t)})}function Ex(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ce(t)})}function Ax(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ce(t)})}function Tx(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ce(t)})}function Rx(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ce(t)})}function Cx(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ce(t)})}function Px(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ce(t)})}function Ix(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ce(t)})}function Lx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ce(t)})}function Nx(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ce(t)})}function Dx(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ce(t)})}function Ox(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ce(t)})}function Ux(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ce(t)})}function Fx(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ce(t)})}function zx(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ce(t)})}function kx(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ce(t)})}function Bx(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ce(t)})}function Vx(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ce(t)})}function Gx(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ce(t)})}function Hx(e,t){return new e({type:"string",format:"date",check:"string_format",...Ce(t)})}function $x(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ce(t)})}function Wx(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ce(t)})}function Zx(e,t){return new e(xx({type:"number",checks:[],...Ce(t)}))}function Xx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ce(t)})}function jx(e,t){return new e({type:"boolean",...Ce(t)})}function qx(e){return new e({type:"unknown"})}function Yx(e,t){return new e({type:"never",...Ce(t)})}function Qc(e,t){return new td({check:"less_than",...Ce(t),value:e,inclusive:!1})}function Qo(e,t){return new td({check:"less_than",...Ce(t),value:e,inclusive:!0})}function el(e,t){return new nd({check:"greater_than",...Ce(t),value:e,inclusive:!1})}function ea(e,t){return new nd({check:"greater_than",...Ce(t),value:e,inclusive:!0})}function tl(e,t){return new k_({check:"multiple_of",...Ce(t),value:e})}function nl(e,t){return new V_({check:"max_length",...Ce(t),maximum:e})}function Zs(e,t){return new G_({check:"min_length",...Ce(t),minimum:e})}function il(e,t){return new H_({check:"length_equals",...Ce(t),length:e})}function pd(e,t){return new $_({check:"string_format",format:"regex",...Ce(t),pattern:e})}function md(e){return new W_({check:"string_format",format:"lowercase",...Ce(e)})}function gd(e){return new Z_({check:"string_format",format:"uppercase",...Ce(e)})}function _d(e,t){return new X_({check:"string_format",format:"includes",...Ce(t),includes:e})}function xd(e,t){return new j_({check:"string_format",format:"starts_with",...Ce(t),prefix:e})}function yd(e,t){return new q_({check:"string_format",format:"ends_with",...Ce(t),suffix:e})}function wr(e){return new Y_({check:"overwrite",tx:e})}function vd(e){return wr((t)=>t.normalize(e))}function bd(){return wr((e)=>e.trim())}function Sd(){return wr((e)=>e.toLowerCase())}function Md(){return wr((e)=>e.toUpperCase())}function wd(){return wr((e)=>Fg(e))}function Jx(e,t,n){return new e({type:"array",element:t,...Ce(n)})}function Kx(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ce(n)})}function Qx(e,t){let n=F1((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(qr(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(qr(s))}},e(i.value,i)),t);return n}function F1(e,t){let n=new Kt({check:"custom",...Ce(t)});return n._zod.check=e,n}function ta(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Gn(e,i,n[i]);return e}function Ad(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Yr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function qi(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function It(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let h=o.schema,f=t.processors[r.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,h,u)}let d=e._zod.parent;if(d){if(!o.ref)o.ref=d;It(d,t,u),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)ta(o.schema,c);if(t.io==="input"&&fn(e))delete o.schema.examples,delete o.schema.default;if(t.io==="input"&&"_prefault"in o.schema)(i=o.schema).default??(i.default=o.schema._prefault);return delete o.schema._prefault,t.seen.get(e).schema}function ey(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Td(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(o[0])?.id,h=e.external.uri??((m)=>m);if(d)return{ref:h(d)};let f=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=f,{defId:f,ref:`${h("__shared")}#/${a}/${ey(f)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+ey(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let d in u)delete u[d];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>+ `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=$s,c=!hn.jitless,u=c&&Bg.value,d=t.catchall,h;e._zod.parse=(f,m)=>{h??(h=i.value);let _=f.value;if(!a(_))return f.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),f;if(c&&u&&m?.async===!1&&m.jitless!==!0){if(!o)o=s(t.shape);if(f=o(f,m),!d)return f;return j0([],_,f,m,h,e,m?.abortEarly===!0)}return n(f,m)}});function i0(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!Hn(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((o)=>Si(o,i,Rn())))}),t}var hd=J("$ZodUnion",(e,t)=>{vt.init(e,t),at(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),at(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),at(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),at(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>Mr(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}if(!s)return i0(o,i,e,r);return Promise.all(o).then((a)=>i0(a,i,e,r))}});function L1(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var Y0=J("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,hd.init(e,t);let n=e._zod.parse;at(e,"propValues",(r)=>{let s={},o=0;for(let a of r.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(a)}"`);if(c[r.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))Gn(s,l,new Set);for(let d of u)s[l].add(d)}}if(!r.def.unionFallback&&o>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let o=jo(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=Xo(()=>L1(t));e._zod.parse=(r,s)=>{let o=r.value;if(!$s(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let a=o?.[t.discriminator],c=i.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),r}}),J0=J("$ZodIntersection",(e,t)=>{vt.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),o=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||o instanceof Promise)return Promise.all([s,o]).then(([c,l])=>r0(n,c,l));return r0(n,s,o)}});function od(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(jr(e)&&jr(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let o=od(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],s=t[i],o=od(r,s);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function r0(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let d;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),d=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let h=String(l.path[0]);if(!s.has(h))s.set(h,l);d=[h]}else return!1;for(let h of d){if(!i.has(h))i.set(h,{});i.get(h)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=od(t.value,n.value);if(!c.valid){if(Hn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var K0=J("$ZodTuple",(e,t)=>{vt.init(e,t);let n=t.items,i=hn.memoizer;i?.attach(e),e._zod.parse=(r,s)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(e,r,[],s):[];let a=[],c=s0(n,"optin"),l=s0(n,"optout");if(!t.rest){if(o.length<c)return r.issues.push({code:"too_small",minimum:c,inclusive:!0,input:o,inst:e,origin:"array"}),r;if(o.length>n.length)r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:o,inst:e,origin:"array"})}let u=Array(n.length),d=t.rest?s?.abortEarly:void 0,h=!1;for(let f=0;f<n.length;f++){let m=n[f]._zod.run({value:o[f],issues:[]},s);if(m instanceof Promise)a.push(m.then((_)=>{u[f]=_}));else if(u[f]=m,d&&!h&&m.issues.length)h=Hn(m)}if(t.rest&&!h){let f=n.length-1,m=o.slice(n.length),_=r.issues.length;for(let p of m){if(d&&r.issues.length!==_){if(Hn(r,_))break;_=r.issues.length}f++;let g=t.rest._zod.run({value:p,issues:[]},s);if(g instanceof Promise)a.push(g.then((S)=>o0(S,r,f)));else o0(g,r,f)}}if(a.length)return Promise.all(a).then(()=>a0(u,r,n,o,l));return a0(u,r,n,o,l)}});function s0(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function o0(e,t,n){if(e.issues.length)t.issues.push(...bi(n,e.issues));t.value[n]=e.value}function a0(e,t,n,i,r){for(let s=0;s<n.length;s++){let o=e[s],a=s<i.length;if(!a&&s>=r&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(o.issues.length){if(!a&&s>=r){t.value.length=s;break}t.issues.push(...bi(s,o.issues))}t.value[s]=o.value}for(let s=t.value.length-1;s>=i.length;s--)if(n[s]._zod.optout==="optional"&&t.value[s]===void 0)t.value.length=s;else break;return t}var Q0=J("$ZodRecord",(e,t)=>{vt.init(e,t);let n=hn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!jr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((m)=>Si(m,r,Rn())),input:u,path:[u],inst:e});continue}let h=d.value;if(h==="__proto__")continue;let f=t.valueType._zod.run({value:s[u],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...bi(u,m.issues));i.value[h]=m.value}));else{if(f.issues.length)i.issues.push(...bi(u,f.issues));i.value[h]=f.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&Ws.test(l)&&u.issues.length){let m=t.keyType._zod.run({value:Number(l),issues:[]},r);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length===0)u=m}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((m)=>Si(m,r,Rn())),input:l,path:[l],inst:e});continue}let h=u.value;if(h==="__proto__")continue;let f=t.valueType._zod.run({value:s[l],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...bi(l,m.issues));i.value[h]=m.value}));else{if(f.issues.length)i.issues.push(...bi(l,f.issues));i.value[h]=f.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var ex=J("$ZodEnum",(e,t)=>{vt.init(e,t);let n=Wo(t.entries),i=new Set(n);e._zod.values=i,at(e,"pattern",(r)=>{let s=Wo(r.def.entries).filter((o)=>Vg.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>ji(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let o=r.value;if(i.has(o))return r;return r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),tx=J("$ZodLiteral",(e,t)=>{vt.init(e,t);let n=new Set(t.values);e._zod.values=n,at(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?ji(s):s?ji(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var nx=J("$ZodTransform",(e,t)=>{vt.init(e,t),e._zod.optin="optional",hn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new qo(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((o)=>(n.value=o,n));if(r instanceof Promise)throw new Mi;return n.value=r,n}});function c0(e,t){return e.value=t.issues.length?void 0:t.value,e}var dd=J("$ZodOptional",(e,t)=>{vt.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Mr(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>c0(n,s));return c0(n,r)}return t.innerType._zod.run(n,i)}}),ix=J("$ZodExactOptional",(e,t)=>{dd.init(e,t),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),rx=J("$ZodNullable",(e,t)=>{vt.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Mr(i.source)}|null)$`):void 0}),at(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),sx=J("$ZodDefault",(e,t)=>{vt.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>l0(s,t));return l0(r,t)}});function l0(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var ox=J("$ZodPrefault",(e,t)=>{vt.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),ax=J("$ZodNonOptional",(e,t)=>{vt.init(e,t),at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>u0(s,e));return u0(r,e)}});function u0(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function h0(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>Si(r,i,Rn()))},input:e.value}),e}var cx=J("$ZodCatch",(e,t)=>{vt.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>h0(n,s,t,i));return h0(n,r,t,i)}});var lx=J("$ZodPipe",(e,t)=>{vt.init(e,t),at(e,"values",(n)=>n.def.in._zod.values),at(e,"optin",(n)=>n.def.in._zod.optin),at(e,"optout",(n)=>n.def.out._zod.optout),at(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>Zc(o,t.in,i));return Zc(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Zc(s,t.out,i));return Zc(r,t.out,i)}});function Zc(e,t,n){if(e.issues.some((i)=>i.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var ux=J("$ZodReadonly",(e,t)=>{vt.init(e,t),at(e,"propValues",(n)=>n.def.innerType._zod.propValues),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"optin",(n)=>n.def.innerType?._zod?.optin),at(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(d0);return d0(r)}});function d0(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function N1(e){let t=e._zod.def,n=t.pattern,i=!!t.format?.includes("int"),r,s;for(let a of t.checks??[]){let c=a._zod.def;if(c.pattern)n=c.pattern;i||(i=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;if(l!==void 0&&(r===void 0||l>r))r=l;if(u!==void 0&&(s===void 0||u<s))s=u}if(n)return n.source;if(r!==void 0&&s!==void 0&&r>s)return"(?!)";if(r!==void 0||s!==void 0)return F_({minimum:r,maximum:s}).source;let o=e._zod.pattern;return(i&&o===Ws?$c:o)?.source}function ad(e){let t=e._zod.def,n=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let r=i._zod.pattern?.source,s=ad(i);if(n&&r&&s&&s!==r)return n.replace(Mr(r),()=>Mr(s));return n}if(t.options){let r=t.options.map(ad);if(r.every(Boolean))return`^(${r.map((s)=>Mr(s)).join("|")})$`}return N1(e)}var hx=J("$ZodTemplateLiteral",(e,t)=>{vt.init(e,t);let n=[];for(let i of t.parts)if(typeof i==="object"&&i!==null){let r=ad(i);if(!r)throw Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);n.push(Mr(r))}else if(i===null||Gg.has(typeof i))n.push(ji(`${i}`));else throw Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>{if(typeof i.value!=="string")return i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(i.value))return i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i;return i}});var dx=J("$ZodCustom",(e,t)=>{Kt.init(e,t),vt.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>f0(s,n,i,e));f0(r,n,i,e);return}});function f0(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(qr(r))}}class px extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var pd="~memo",fx=[];function mx(e){return e!==null&&typeof e==="object"}function fd(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var gx=new WeakMap,Ko=0,Qc=1,Qo=2;function el(e,t,n){let i=gx.get(e);if(i!==void 0)return i?Qo:Ko;if(t.has(e))return Qo;t.add(e);let r=Ko,s=(u)=>{if(r!==Qo&&u?._zod){let d=el(u,t,n);if(d>r)r=d}},o=(u,d)=>{let h=Ko;for(let f of Reflect.ownKeys(u)){let m=Object.getOwnPropertyDescriptor(u,f);if(d&&!m.enumerable)continue;let _=m.get?Qc:m.value?._zod?el(m.value,t,n):Ko;if(_>h)h=_}return h},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=jo(c);a(u?o(u,!0):Qc),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?el(u,t,!1):Qc);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let d=Object.getOwnPropertyDescriptor(c,u);if(!d||d.get)continue;let h=d.value;if(!h||typeof h!=="object")continue;if(h._zod)s(h);else if(Array.isArray(h))for(let f of h)s(f)}}return t.delete(e),D1(e,r)}function D1(e,t){if(t!==Qc)gx.set(e,t===Qo);return t}function O1(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var Jc,Kc=[],U1={alloc(e,t,n){let i=Jc;if(!i)return n;Jc=void 0;let r={value:n,issues:null};return i.set(t.value,r),Kc.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,s)=>{if(s.direction!=="backward"&&F1(s,r.value))throw new px;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let g=el(e,new Set,!1);if(g===Ko){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(g===Qo||i)n=!0;else i=!0}let u=c.value;if(!mx(u))return o(c,l);let d=l[pd];if(!d)d={buckets:new WeakMap,backEdges:void 0},l[pd]=d;let h;if(r===l)h=s;else h=O1(d,e),r=l,s=h;let f=h.get(u);if(f){if(c.value=f.value,f.issues){if(f.issues.length)c.issues.push(...fd(f.issues))}else c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(f.value);return c}Jc=h;let m=Kc.length,_=o(c,l);Jc=void 0;let p=Kc.length>m?Kc.pop():void 0;if(_ instanceof Promise)return _.then((g)=>{if(p)p.issues=g.issues.length?fd(g.issues):fx;return g});if(p)p.issues=_.issues.length?fd(_.issues):fx;return _};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function _x(){return U1}function F1(e,t){let n=e[pd]?.backEdges;return n!==void 0&&mx(t)&&n.has(t)}var z1=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(s,o){if(s==="number"&&typeof o==="number"&&!Number.isFinite(o))return String(o);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let o=r(s.expected),a=Xg(s.input),c=r(a,s.input);return`Invalid input: expected ${o}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${Zh(s.values[0])}`;return`Invalid option: expected one of ${Hh(s.values,"|")}`;case"too_big":{let o=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${o}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${o}${s.maximum.toString()}`}case"too_small":{let o=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${o}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${o}${s.minimum.toString()}`}case"invalid_format":{let o=s;if(o.format==="starts_with")return`Invalid string: must start with "${o.prefix}"`;if(o.format==="ends_with")return`Invalid string: must end with "${o.suffix}"`;if(o.format==="includes")return`Invalid string: must include "${o.includes}"`;if(o.format==="regex")return`Invalid string: must match pattern ${o.pattern}`;return`Invalid ${n[o.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${Hh(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function md(){return{localeError:z1()}}var xx;class yx{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function k1(){return new yx}(xx=globalThis).__zod_globalRegistry??(xx.__zod_globalRegistry=k1());var Yr=globalThis.__zod_globalRegistry;function vx(e){if(e.checks)e.checks=[...e.checks];return e}function bx(e,t){return new e(vx({type:"string",...Ce(t)}))}function Sx(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ce(t)})}function Mx(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ce(t)})}function wx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ce(t)})}function Ex(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ce(t)})}function Ax(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ce(t)})}function Tx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ce(t)})}function Rx(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ce(t)})}function Cx(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ce(t)})}function Px(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ce(t)})}function Ix(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ce(t)})}function Lx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ce(t)})}function Nx(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ce(t)})}function Dx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ce(t)})}function Ox(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ce(t)})}function Ux(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ce(t)})}function Fx(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ce(t)})}function zx(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ce(t)})}function kx(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ce(t)})}function Bx(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ce(t)})}function Vx(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ce(t)})}function Gx(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ce(t)})}function Hx(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ce(t)})}function $x(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ce(t)})}function Wx(e,t){return new e({type:"string",format:"date",check:"string_format",...Ce(t)})}function Zx(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ce(t)})}function Xx(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ce(t)})}function jx(e,t){return new e(vx({type:"number",checks:[],...Ce(t)}))}function qx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ce(t)})}function Yx(e,t){return new e({type:"boolean",...Ce(t)})}function Jx(e){return new e({type:"unknown"})}function Kx(e,t){return new e({type:"never",...Ce(t)})}function tl(e,t){return new id({check:"less_than",...Ce(t),value:e,inclusive:!1})}function ea(e,t){return new id({check:"less_than",...Ce(t),value:e,inclusive:!0})}function nl(e,t){return new rd({check:"greater_than",...Ce(t),value:e,inclusive:!1})}function ta(e,t){return new rd({check:"greater_than",...Ce(t),value:e,inclusive:!0})}function il(e,t){return new V_({check:"multiple_of",...Ce(t),value:e})}function rl(e,t){return new H_({check:"max_length",...Ce(t),maximum:e})}function Zs(e,t){return new $_({check:"min_length",...Ce(t),minimum:e})}function sl(e,t){return new W_({check:"length_equals",...Ce(t),length:e})}function gd(e,t){return new Z_({check:"string_format",format:"regex",...Ce(t),pattern:e})}function _d(e){return new X_({check:"string_format",format:"lowercase",...Ce(e)})}function xd(e){return new j_({check:"string_format",format:"uppercase",...Ce(e)})}function yd(e,t){return new q_({check:"string_format",format:"includes",...Ce(t),includes:e})}function vd(e,t){return new Y_({check:"string_format",format:"starts_with",...Ce(t),prefix:e})}function bd(e,t){return new J_({check:"string_format",format:"ends_with",...Ce(t),suffix:e})}function wr(e){return new K_({check:"overwrite",tx:e})}function Sd(e){return wr((t)=>t.normalize(e))}function Md(){return wr((e)=>e.trim())}function wd(){return wr((e)=>e.toLowerCase())}function Ed(){return wr((e)=>e.toUpperCase())}function Ad(){return wr((e)=>kg(e))}function Qx(e,t,n){return new e({type:"array",element:t,...Ce(n)})}function ey(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ce(n)})}function ty(e,t){let n=B1((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(qr(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(qr(s))}},e(i.value,i)),t);return n}function B1(e,t){let n=new Kt({check:"custom",...Ce(t)});return n._zod.check=e,n}function na(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Gn(e,i,n[i]);return e}function Rd(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Yr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function qi(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function It(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let h=o.schema,f=t.processors[r.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,h,u)}let d=e._zod.parent;if(d){if(!o.ref)o.ref=d;It(d,t,u),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)na(o.schema,c);if(t.io==="input"&&dn(e))delete o.schema.examples,delete o.schema.default;if(t.io==="input"&&"_prefault"in o.schema)(i=o.schema).default??(i.default=o.schema._prefault);return delete o.schema._prefault,t.seen.get(e).schema}function ny(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Cd(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(o[0])?.id,h=e.external.uri??((m)=>m);if(d)return{ref:h(d)};let f=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=f,{defId:f,ref:`${h("__shared")}#/${a}/${ny(f)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+ny(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let d in u)delete u[d];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>-Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function iy(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!=="object")return;iy(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let o of Array.isArray(s)?s:[s]){if(typeof o!=="string")return;if(!n.includes(o))n.push(o)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var ry=new Set(["type","properties","required","additionalProperties"]),ty=["oneOf","anyOf"];function ny(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Ed(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!ry.has(o))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let o in s.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let l of t){let u=l.properties?.[o]??ny(l);if(u===null||u===void 0)continue;if(!a.some((d)=>JSON.stringify(d)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:Ed(a)??{allOf:a};Gn(n,o,c)}for(let o of s.required??[])i.add(o)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let o of t){let a=ny(o);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function z1(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of ry)if(r in e)return;let n=t.filter((r)=>ty.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=Ed(t);else{let r=n[0],s=ty.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let o=t.filter((c)=>c!==r),a=r[s].map((c)=>Ed([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,ta(e,i)}function Rd(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){i(d);let f=e.seen.get(d),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(m);else ta(l,m);if(ta(l,u),a._zod.parent===d)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(m.$ref&&f.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in f.def&&JSON.stringify(l[p])===JSON.stringify(f.def[p]))delete l[p]}}let h=a._zod.parent;if(h&&h!==d){i(h);let f=e.seen.get(h);if(f?.schema.$ref){if(l.$ref=f.schema.$ref,f.def)for(let m in l){if(m==="$ref"||m==="allOf")continue;if(m in f.def&&JSON.stringify(l[m])===JSON.stringify(f.def[m]))delete l[m]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())iy(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let d=a.get(u);if(d)d.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])z1(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}ta(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;Gn(o,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(o).length>0)if(e.target==="draft-2020-12")r.$defs=o;else r.definitions=o;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:na(t,"input",e.processors),output:na(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function fn(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return fn(i.element,n);if(i.type==="set")return fn(i.valueType,n);if(i.type==="lazy")return fn(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return fn(i.innerType,n);if(i.type==="intersection")return fn(i.left,n)||fn(i.right,n);if(i.type==="record"||i.type==="map")return fn(i.keyType,n)||fn(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return fn(i.in,n)||fn(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(fn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(fn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(fn(r,n))return!0;if(i.rest&&fn(i.rest,n))return!0;return!1}return!1}var sy=(e,t={})=>(n)=>{let i=Ad({...n,processors:t});return It(e,i),Td(i,e),Rd(i,e)},na=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=Ad({...r??{},target:s,io:t,processors:n});return It(e,o),Td(o,e),Rd(o,e)};var Xs=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},js=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},oy=(e,t)=>{Xs(e,"minimum",t),js(e,"maximum",t)},uy=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},hy=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},dy=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},fy=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},ay=(e,t)=>Xs(e,"minimum",t.minimum),cy=(e,t)=>js(e,"maximum",t.maximum),ly=(e)=>(t,n)=>{fy(t,n.format);let[i,r]=e[n.format];Xs(t,"minimum",i),js(t,"maximum",r)},k1={greater_than:(e,t)=>Xs(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>js(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>uy(e,t.value),number_format:ly(Lc),bigint_format:ly(Wh),min_length:ay,max_length:cy,length_equals:(e,t)=>oy(e,t.length),min_size:ay,max_size:cy,size_equals:(e,t)=>oy(e,t.size),string_format:(e,t)=>{if(fy(e,t.format),t.pattern)hy(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>dy(e,t.mime)};function Pn(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)k1[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Xs(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Xs(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)js(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)js(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)uy(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)dy(t,r.mime);for(let s of r.patterns??[])hy(t,s);return t}var B1={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},V1=new Map([[ad,A_],[jc,T_]]),py=(e)=>V1.get(e)??e,my=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=Pn(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=B1[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let d=[...c].map(py);if(d.length===1)r.pattern=d[0].source;else if(d.length>1)r.allOf=[...d.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},gy=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Pn(e);r.type=u?"integer":"number";let d=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),h=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(d)if(f)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(h)if(f)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let m=new Set;for(let g of a)if(Number.isFinite(g)&&g!==0)m.add(Math.abs(g));else qi(e,t,r,i,`A multipleOf divisor of ${g} cannot be represented in JSON Schema`);let[_,...p]=m;if(_!==void 0)r.multipleOf=_;if(p.length)r.allOf=[...r.allOf??[],...p.map((g)=>({multipleOf:g}))]}},_y=(e,t,n,i)=>{n.type="boolean"};var xy=(e,t,n,i)=>{n.not={}};var yy=(e,t,n,i)=>{};var vy=(e,t,n,i)=>{let r=e._zod.def,s=$o(r.entries);if(s.length===0){n.not={};return}if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";n.enum=s},by=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(qi(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(qi(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var Sy=(e,t,n,i)=>{let r=n,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");r.type="string",r.pattern=s.source};var My=(e,t,n,i)=>{qi(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var wy=(e,t,n,i)=>{qi(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var Ey=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=Pn(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=It(s.element,t,{...i,path:[...i.path,"items"]})};function ia(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return ia(t.out);if(t.type==="catch")return ia(t.innerType);return e._zod.optin}var Ay=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&qi(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Gn(r.properties,l,It(o[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?ia(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=It(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},Ty=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>It(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},Ry=(e,t,n,i)=>{let r=e._zod.def,s=It(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=It(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Cy=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((_,p)=>It(_,t,{...i,path:[...i.path,o,p]})),l=s.rest?It(s.rest,t,{...i,path:[...i.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,u=s.items.length;while(u>0){let _=s.items[u-1];if(!(t.io==="input"?ia(_)!==void 0:_._zod.optout==="optional"))break;u--}let d=s.items.length,h=!s.rest;if(t.target==="draft-2020-12"){if(r.prefixItems=c,h)r.items=!1;else if(l)r.items=l;if(u>0)r.minItems=u;if(h)r.maxItems=d}else if(t.target==="openapi-3.0"){if(r.items={anyOf:c},l)r.items.anyOf.push(l);if(u>0)r.minItems=u;if(h)r.maxItems=d}else{if(r.items=c,h)r.additionalItems=!1;else if(l)r.additionalItems=l;if(u>0)r.minItems=u;if(h)r.maxItems=d}let{minimum:f,maximum:m}=Pn(e);if(typeof f==="number")r.minItems=f;if(typeof m==="number")r.maxItems=m};function Cd(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let m=e.get(t)?.def;if(!m)return t;let _=Cd(e,m,n);return _===m?t:_}for(let m of["anyOf","oneOf"]){let _=t[m];if(!Array.isArray(_))continue;let p=_.map((g)=>Cd(e,g,n));if(p.some((g,S)=>g!==_[S]))t={...t,[m]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((m)=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((m)=>typeof m==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:h,...f}=t;if(f.enum)f.enum=f.enum.map((m)=>typeof m==="number"?String(m):m);else if(typeof f.const==="number")f.const=String(f.const);if(!r)return f;if(f.type="string",!s)f.pattern=(i.includes("number")?Ws:Gc).source;return f}var Pd=new WeakMap;function G1(e){let t=new Map;for(let i of e.seen.values())if(i.def&&!t.has(i.schema))t.set(i.schema,i);let n=new Map;for(let i of Pd.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=Cd(t,s,new Set);if(o!==s)n.set(s,o)}if(!n.size)return;for(let i of e.seen.values())for(let r of[i.schema,i.def]){let s=r&&n.get(r.propertyNames);if(s)r.propertyNames=s}}var Py=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=Pn(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=It(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let d of a)Gn(r.patternProperties,py(d).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=It(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=Pd.get(t);if(!u)u=[],Pd.set(t,u),t.deferred.push(()=>G1(t));u.push(e)}r.additionalProperties=It(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&ia(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((d)=>typeof d==="string"||typeof d==="number");if(u.length>0)r.required=u.map(String)}},Iy=(e,t,n,i)=>{let r=e._zod.def,s=It(r.innerType,t,i),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},Ly=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Id=Symbol();function Ny(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return qi(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),Id}var Dy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=Ny(r.defaultValue,e,t,n,i);if(o!==Id)n.default=o},Oy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=Ny(r.defaultValue,e,t,n,i);if(o!==Id)n._prefault=o},Uy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{qi(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},Fy=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;It(o,t,i);let a=t.seen.get(e);a.ref=o},zy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var Ld=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var ky=new WeakSet([Object.prototype,Error.prototype]);function rl(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var Y1=(e,t)=>{Qg.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(ky.has(n))return;ky.add(n),rl(n,"format",(i)=>(r)=>t_(i,r)),rl(n,"flatten",(i)=>(r)=>e_(i,r)),rl(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,Wo,2)}),rl(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,Wo,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var In=J("ZodError",Y1,void 0,{Parent:Error});var By=zc(In),Vy=kc(In),Gy=Bc(In),Hy=Vc(In),$y=i_(In),Wy=r_(In),Zy=s_(In),Xy=o_(In),jy=a_(In),qy=c_(In),Yy=l_(In),Jy=u_(In);function K1(){if(!dn.localeError)Cn(fd())}function ra(){if(!dn.memoizer)Cn({memoizer:mx()})}var Ct=J("ZodType",(e,t)=>(K1(),vt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Rn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return vi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(JR(e,t))},superRefine(e,t){return this.check(KR(e,t))},overwrite(e){return this.check(wr(e))},optional(){return ev(this)},exactOptional(){return UR(this)},nullable(){return tv(this)},nullish(){return ev(tv(this))},nonoptional(e){return GR(this,e)},array(){return _t(this)},or(e){return qs([this,e])},and(e){return IR(this,e)},transform(e){return nv(this,OR(e))},default(e){return kR(this,e)},prefault(e){return VR(this,e)},catch(e){return $R(this,e)},pipe(e){return nv(this,e)},readonly(){return XR(this)},describe(e){let t=this.clone();return Yr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Yr.get(this);let t=this.clone();return Yr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Uc(this,"~standard",{...od(this),jsonSchema:{input:na(this,"input"),output:na(this,"output")}})},set "~standard"(e){Xi(this,"~standard",e)},parse:function e(t,n){return By(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Vy(this,t,n,{callee:e})},safeParse(e,t){return Gy(this,e,t)},async safeParseAsync(e,t){return Hy(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Xi(this,"spa",e)},validate(e,t){return Yh(this,e,t)},validateAsync(e,t){return Jh(this,e,t)},encode:function e(t,n){return $y(this,t,n,{callee:e})},decode:function e(t,n){return Wy(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Zy(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Xy(this,t,n,{callee:e})},safeEncode(e,t){return jy(this,e,t)},safeDecode(e,t){return qy(this,e,t)},async safeEncodeAsync(e,t){return Yy(this,e,t)},async safeDecodeAsync(e,t){return Jy(this,e,t)},toJSONSchema(e){return sy(this,{})(e)},get description(){return Yr.get(this)?.description},get _def(){return this._zod.def}}),iv=J("_ZodString",(e,t)=>{Xc.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>my(e,n,i,r)},Xg({format:(e)=>Pn(e).format??null,minLength:(e)=>Pn(e).minimum??null,maxLength:(e)=>Pn(e).maximum??null},{regex(...e){return this.check(pd(...e))},includes(...e){return this.check(_d(...e))},startsWith(...e){return this.check(xd(...e))},endsWith(...e){return this.check(yd(...e))},min(...e){return this.check(Zs(...e))},max(...e){return this.check(nl(...e))},length(...e){return this.check(il(...e))},nonempty(...e){return this.check(Zs(1,...e))},lowercase(e){return this.check(md(e))},uppercase(e){return this.check(gd(e))},trim(){return this.check(bd())},normalize(...e){return this.check(vd(...e))},toLowerCase(){return this.check(Sd())},toUpperCase(){return this.check(Md())},slugify(){return this.check(wd())}})),Q1=J("ZodString",(e,t)=>{Xc.init(e,t),iv.init(e,t)},{email(e){return this.check(vx(rR,e))},url(e){return this.check(Ax(oR,e))},jwt(e){return this.check(Vx(bR,e))},emoji(e){return this.check(Tx(aR,e))},guid(e){return this.check(bx(sR,e))},uuid(e){return this.check(Sx(sl,e))},uuidv4(e){return this.check(Mx(sl,e))},uuidv6(e){return this.check(wx(sl,e))},uuidv7(e){return this.check(Ex(sl,e))},nanoid(e){return this.check(Rx(cR,e))},cuid(e){return this.check(Cx(lR,e))},cuid2(e){return this.check(Px(uR,e))},ulid(e){return this.check(Ix(hR,e))},base64(e){return this.check(zx(xR,e))},base64url(e){return this.check(kx(yR,e))},xid(e){return this.check(Lx(dR,e))},ksuid(e){return this.check(Nx(fR,e))},ipv4(e){return this.check(Dx(pR,e))},ipv6(e){return this.check(Ox(mR,e))},cidrv4(e){return this.check(Ux(gR,e))},cidrv6(e){return this.check(Fx(_R,e))},e164(e){return this.check(Bx(vR,e))},datetime(e){return this.check(Gx(eR,e))},date(e){return this.check(Hx(tR,e))},time(e){return this.check($x(nR,e))},duration(e){return this.check(Wx(iR,e))}});function Xe(e){return yx(Q1,e)}var Lt=J("ZodStringFormat",(e,t)=>{Rt.init(e,t),iv.init(e,t)}),eR=J("ZodISODateTime",(e,t)=>{A0.init(e,t),Lt.init(e,t)}),tR=J("ZodISODate",(e,t)=>{T0.init(e,t),Lt.init(e,t)}),nR=J("ZodISOTime",(e,t)=>{R0.init(e,t),Lt.init(e,t)}),iR=J("ZodISODuration",(e,t)=>{C0.init(e,t),Lt.init(e,t)}),rR=J("ZodEmail",(e,t)=>{m0.init(e,t),Lt.init(e,t)});var sR=J("ZodGUID",(e,t)=>{f0.init(e,t),Lt.init(e,t)});var sl=J("ZodUUID",(e,t)=>{p0.init(e,t),Lt.init(e,t)});var oR=J("ZodURL",(e,t)=>{x0.init(e,t),Lt.init(e,t)});var aR=J("ZodEmoji",(e,t)=>{y0.init(e,t),Lt.init(e,t)});var cR=J("ZodNanoID",(e,t)=>{v0.init(e,t),Lt.init(e,t)});var lR=J("ZodCUID",(e,t)=>{b0.init(e,t),Lt.init(e,t)});var uR=J("ZodCUID2",(e,t)=>{S0.init(e,t),Lt.init(e,t)});var hR=J("ZodULID",(e,t)=>{M0.init(e,t),Lt.init(e,t)});var dR=J("ZodXID",(e,t)=>{w0.init(e,t),Lt.init(e,t)});var fR=J("ZodKSUID",(e,t)=>{E0.init(e,t),Lt.init(e,t)});var pR=J("ZodIPv4",(e,t)=>{P0.init(e,t),Lt.init(e,t)});var mR=J("ZodIPv6",(e,t)=>{L0.init(e,t),Lt.init(e,t)});var gR=J("ZodCIDRv4",(e,t)=>{N0.init(e,t),Lt.init(e,t)});var _R=J("ZodCIDRv6",(e,t)=>{D0.init(e,t),Lt.init(e,t)});var xR=J("ZodBase64",(e,t)=>{U0.init(e,t),Lt.init(e,t)});var yR=J("ZodBase64URL",(e,t)=>{F0.init(e,t),Lt.init(e,t)});var vR=J("ZodE164",(e,t)=>{z0.init(e,t),Lt.init(e,t)});var bR=J("ZodJWT",(e,t)=>{k0.init(e,t),Lt.init(e,t)});var rv=J("ZodNumber",(e,t)=>{cd.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>gy(e,n,i,r),e.isFinite=!0},Xg({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=Pn(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=Pn(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=Pn(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>Pn(e).format??null},{gt(e,t){return this.check(el(e,t))},gte(e,t){return this.check(ea(e,t))},min(e,t){return this.check(ea(e,t))},lt(e,t){return this.check(Qc(e,t))},lte(e,t){return this.check(Qo(e,t))},max(e,t){return this.check(Qo(e,t))},int(e){return this.check(Ky(e))},safe(e){return this.check(Ky(e))},positive(e){return this.check(el(0,e))},nonnegative(e){return this.check(ea(0,e))},negative(e){return this.check(Qc(0,e))},nonpositive(e){return this.check(Qo(0,e))},multipleOf(e,t){return this.check(tl(e,t))},step(e,t){return this.check(tl(e,t))},finite(){return this}}));function et(e){return Zx(rv,e)}var SR=J("ZodNumberFormat",(e,t)=>{B0.init(e,t),rv.init(e,t)});function Ky(e){return Xx(SR,e)}var MR=J("ZodBoolean",(e,t)=>{V0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_y(e,n,i,r)});function Kr(e){return jx(MR,e)}var wR=J("ZodUnknown",(e,t)=>{G0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yy(e,n,i,r)});function Jr(){return qx(wR)}var ER=J("ZodNever",(e,t)=>{H0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xy(e,n,i,r)});function AR(e){return Yx(ER,e)}var TR=J("ZodArray",(e,t)=>{ra(),$0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ey(e,n,i,r),e.element=t.element},{min(e,t){return this.check(Zs(e,t))},nonempty(e){return this.check(Zs(1,e))},max(e,t){return this.check(nl(e,t))},length(e,t){return this.check(il(e,t))},unwrap(){return this.element}});function _t(e,t){return Jx(TR,e,t)}var RR=J("ZodObject",(e,t)=>{ra(),X0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ay(e,n,i,r),s1(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return wt(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Rn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Rn(this._zod.def,{catchall:Jr()}))},loose(){return this.clone(Rn(this._zod.def,{catchall:Jr()}))},strict(){return this.clone(Rn(this._zod.def,{catchall:AR()}))},strip(){return this.clone(Rn(this._zod.def,{catchall:void 0}))},extend(e){return JT(this,e)},safeExtend(e){return KT(this,e)},merge(e){return QT(this,e)},pick(e){return qT(this,e)},omit(e){return YT(this,e)},partial(...e){return Hg(Od,this,e[0])},exactPartial(...e){return Hg(av,this,e[0],"exactPartial")},required(...e){return e1(cv,this,e[0])}});function be(e,t){let n={type:"object",shape:e??{},...Ce(t)};return new RR(n)}var sv=J("ZodUnion",(e,t)=>{ld.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ty(e,n,i,r),e.options=t.options});function qs(e,t){return new sv({type:"union",options:e,...Ce(t)})}var CR=J("ZodDiscriminatedUnion",(e,t)=>{sv.init(e,t),j0.init(e,t)});function ni(e,t,n){return new CR({type:"union",options:t,discriminator:e,...Ce(n)})}var PR=J("ZodIntersection",(e,t)=>{q0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ry(e,n,i,r)});function IR(e,t){return new PR({type:"intersection",left:e,right:t})}var LR=J("ZodTuple",(e,t)=>{ra(),Y0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Cy(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new Od({type:"optional",innerType:t}))})}});function ov(e,t,n){let i=t instanceof vt,r=i?n:t;return new LR({type:"tuple",items:e,rest:i?t:null,...Ce(r)})}var Qy=J("ZodRecord",(e,t)=>{ra(),J0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Py(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function ol(e,t,n){if(!t||!t._zod)return new Qy({type:"record",keyType:Xe(),valueType:e,...Ce(t)});return new Qy({type:"record",keyType:e,valueType:t,...Ce(n)})}var Dd=J("ZodEnum",(e,t)=>{K0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(i,r,s)=>vy(e,i,r,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let o of i)if(n.has(o))s[o]=t.entries[o];else throw Error(`Key ${o} not found in enum`);return new Dd({...t,checks:[],...Ce(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let o of i)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new Dd({...t,checks:[],...Ce(r),entries:s})}});function wt(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new Dd({type:"enum",entries:n,...Ce(t)})}var NR=J("ZodLiteral",(e,t)=>{Q0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>by(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Oe(e,t){return new NR({type:"literal",values:Array.isArray(e)?e:[e],...Ce(t)})}var DR=J("ZodTransform",(e,t)=>{ra(),ex.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>wy(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new jo(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(qr(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(qr(o))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function OR(e){return new DR({type:"transform",transform:e})}var Od=J("ZodOptional",(e,t)=>{ud.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ld(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function ev(e){return new Od({type:"optional",innerType:e})}var av=J("ZodExactOptional",(e,t)=>{tx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ld(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function UR(e){return new av({type:"optional",innerType:e})}var FR=J("ZodNullable",(e,t)=>{nx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Iy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function tv(e){return new FR({type:"nullable",innerType:e})}var zR=J("ZodDefault",(e,t)=>{ix.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Dy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function kR(e,t){return new zR({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Hh(t)}})}var BR=J("ZodPrefault",(e,t)=>{rx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Oy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function VR(e,t){return new BR({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Hh(t)}})}var cv=J("ZodNonOptional",(e,t)=>{sx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ly(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function GR(e,t){return new cv({type:"nonoptional",innerType:e,...Ce(t)})}var HR=J("ZodCatch",(e,t)=>{ox.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Uy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $R(e,t){return new HR({type:"catch",innerType:e,catchValue:typeof t==="function"?t:jg(t)})}var WR=J("ZodPipe",(e,t)=>{ax.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Fy(e,n,i,r),e.in=t.in,e.out=t.out});function nv(e,t){return new WR({type:"pipe",in:e,out:t})}var ZR=J("ZodReadonly",(e,t)=>{cx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>zy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function XR(e){return new ZR({type:"readonly",innerType:e})}var jR=J("ZodTemplateLiteral",(e,t)=>{lx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Sy(e,n,i,r)});function qR(e,t){return new jR({type:"template_literal",parts:e,...Ce(t)})}var YR=J("ZodCustom",(e,t)=>{ux.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>My(e,n,i,r)});function JR(e,t={}){return Kx(YR,e,t)}function KR(e,t){return Qx(e,t)}var lv=["neutral","dark","light"];var Fd=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),uv=Object.freeze({neutral:Fd("neutral",[170,177,188]),dark:Fd("dark",[26,26,26]),light:Fd("light",[223,227,232])});var YD=uv.neutral.rgb,JD=uv.neutral.hex;/*!+Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function sy(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!=="object")return;sy(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let o of Array.isArray(s)?s:[s]){if(typeof o!=="string")return;if(!n.includes(o))n.push(o)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var oy=new Set(["type","properties","required","additionalProperties"]),iy=["oneOf","anyOf"];function ry(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Td(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!oy.has(o))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let o in s.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let l of t){let u=l.properties?.[o]??ry(l);if(u===null||u===void 0)continue;if(!a.some((d)=>JSON.stringify(d)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:Td(a)??{allOf:a};Gn(n,o,c)}for(let o of s.required??[])i.add(o)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let o of t){let a=ry(o);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function V1(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of oy)if(r in e)return;let n=t.filter((r)=>iy.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=Td(t);else{let r=n[0],s=iy.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let o=t.filter((c)=>c!==r),a=r[s].map((c)=>Td([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,na(e,i)}function Pd(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){i(d);let f=e.seen.get(d),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(m);else na(l,m);if(na(l,u),a._zod.parent===d)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(m.$ref&&f.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in f.def&&JSON.stringify(l[p])===JSON.stringify(f.def[p]))delete l[p]}}let h=a._zod.parent;if(h&&h!==d){i(h);let f=e.seen.get(h);if(f?.schema.$ref){if(l.$ref=f.schema.$ref,f.def)for(let m in l){if(m==="$ref"||m==="allOf")continue;if(m in f.def&&JSON.stringify(l[m])===JSON.stringify(f.def[m]))delete l[m]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())sy(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let d=a.get(u);if(d)d.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])V1(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}na(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;Gn(o,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(o).length>0)if(e.target==="draft-2020-12")r.$defs=o;else r.definitions=o;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:ia(t,"input",e.processors),output:ia(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function dn(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return dn(i.element,n);if(i.type==="set")return dn(i.valueType,n);if(i.type==="lazy")return dn(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return dn(i.innerType,n);if(i.type==="intersection")return dn(i.left,n)||dn(i.right,n);if(i.type==="record"||i.type==="map")return dn(i.keyType,n)||dn(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return dn(i.in,n)||dn(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(dn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(dn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(dn(r,n))return!0;if(i.rest&&dn(i.rest,n))return!0;return!1}return!1}var ay=(e,t={})=>(n)=>{let i=Rd({...n,processors:t});return It(e,i),Cd(i,e),Pd(i,e)},ia=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=Rd({...r??{},target:s,io:t,processors:n});return It(e,o),Cd(o,e),Pd(o,e)};var Xs=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},js=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},cy=(e,t)=>{Xs(e,"minimum",t),js(e,"maximum",t)},dy=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},fy=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},py=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},my=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},ly=(e,t)=>Xs(e,"minimum",t.minimum),uy=(e,t)=>js(e,"maximum",t.maximum),hy=(e)=>(t,n)=>{my(t,n.format);let[i,r]=e[n.format];Xs(t,"minimum",i),js(t,"maximum",r)},G1={greater_than:(e,t)=>Xs(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>js(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>dy(e,t.value),number_format:hy(Dc),bigint_format:hy(Xh),min_length:ly,max_length:uy,length_equals:(e,t)=>cy(e,t.length),min_size:ly,max_size:uy,size_equals:(e,t)=>cy(e,t.size),string_format:(e,t)=>{if(my(e,t.format),t.pattern)fy(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>py(e,t.mime)};function Cn(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)G1[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Xs(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Xs(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)js(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)js(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)dy(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)py(t,r.mime);for(let s of r.patterns??[])fy(t,s);return t}var H1={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},$1=new Map([[ld,R_],[Yc,C_]]),gy=(e)=>$1.get(e)??e,_y=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=Cn(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=H1[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let d=[...c].map(gy);if(d.length===1)r.pattern=d[0].source;else if(d.length>1)r.allOf=[...d.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},xy=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Cn(e);r.type=u?"integer":"number";let d=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),h=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(d)if(f)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(h)if(f)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let m=new Set;for(let g of a)if(Number.isFinite(g)&&g!==0)m.add(Math.abs(g));else qi(e,t,r,i,`A multipleOf divisor of ${g} cannot be represented in JSON Schema`);let[_,...p]=m;if(_!==void 0)r.multipleOf=_;if(p.length)r.allOf=[...r.allOf??[],...p.map((g)=>({multipleOf:g}))]}},yy=(e,t,n,i)=>{n.type="boolean"};var vy=(e,t,n,i)=>{n.not={}};var by=(e,t,n,i)=>{};var Sy=(e,t,n,i)=>{let r=e._zod.def,s=Wo(r.entries);if(s.length===0){n.not={};return}if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";n.enum=s},My=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(qi(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(qi(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var wy=(e,t,n,i)=>{let r=n,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");r.type="string",r.pattern=s.source};var Ey=(e,t,n,i)=>{qi(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var Ay=(e,t,n,i)=>{qi(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var Ty=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=Cn(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=It(s.element,t,{...i,path:[...i.path,"items"]})};function ra(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return ra(t.out);if(t.type==="catch")return ra(t.innerType);return e._zod.optin}var Ry=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&qi(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Gn(r.properties,l,It(o[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?ra(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=It(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},Cy=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>It(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},Py=(e,t,n,i)=>{let r=e._zod.def,s=It(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=It(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Iy=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((_,p)=>It(_,t,{...i,path:[...i.path,o,p]})),l=s.rest?It(s.rest,t,{...i,path:[...i.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,u=s.items.length;while(u>0){let _=s.items[u-1];if(!(t.io==="input"?ra(_)!==void 0:_._zod.optout==="optional"))break;u--}let d=s.items.length,h=!s.rest;if(t.target==="draft-2020-12"){if(r.prefixItems=c,h)r.items=!1;else if(l)r.items=l;if(u>0)r.minItems=u;if(h)r.maxItems=d}else if(t.target==="openapi-3.0"){if(r.items={anyOf:c},l)r.items.anyOf.push(l);if(u>0)r.minItems=u;if(h)r.maxItems=d}else{if(r.items=c,h)r.additionalItems=!1;else if(l)r.additionalItems=l;if(u>0)r.minItems=u;if(h)r.maxItems=d}let{minimum:f,maximum:m}=Cn(e);if(typeof f==="number")r.minItems=f;if(typeof m==="number")r.maxItems=m};function Id(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let m=e.get(t)?.def;if(!m)return t;let _=Id(e,m,n);return _===m?t:_}for(let m of["anyOf","oneOf"]){let _=t[m];if(!Array.isArray(_))continue;let p=_.map((g)=>Id(e,g,n));if(p.some((g,S)=>g!==_[S]))t={...t,[m]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((m)=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((m)=>typeof m==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:h,...f}=t;if(f.enum)f.enum=f.enum.map((m)=>typeof m==="number"?String(m):m);else if(typeof f.const==="number")f.const=String(f.const);if(!r)return f;if(f.type="string",!s)f.pattern=(i.includes("number")?Ws:$c).source;return f}var Ld=new WeakMap;function W1(e){let t=new Map;for(let i of e.seen.values())if(i.def&&!t.has(i.schema))t.set(i.schema,i);let n=new Map;for(let i of Ld.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=Id(t,s,new Set);if(o!==s)n.set(s,o)}if(!n.size)return;for(let i of e.seen.values())for(let r of[i.schema,i.def]){let s=r&&n.get(r.propertyNames);if(s)r.propertyNames=s}}var Ly=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=Cn(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=It(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let d of a)Gn(r.patternProperties,gy(d).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=It(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=Ld.get(t);if(!u)u=[],Ld.set(t,u),t.deferred.push(()=>W1(t));u.push(e)}r.additionalProperties=It(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&ra(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((d)=>typeof d==="string"||typeof d==="number");if(u.length>0)r.required=u.map(String)}},Ny=(e,t,n,i)=>{let r=e._zod.def,s=It(r.innerType,t,i),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},Dy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Nd=Symbol();function Oy(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return qi(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),Nd}var Uy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=Oy(r.defaultValue,e,t,n,i);if(o!==Nd)n.default=o},Fy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=Oy(r.defaultValue,e,t,n,i);if(o!==Nd)n._prefault=o},zy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{qi(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},ky=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;It(o,t,i);let a=t.seen.get(e);a.ref=o},By=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var Dd=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var Vy=new WeakSet([Object.prototype,Error.prototype]);function ol(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var Q1=(e,t)=>{t_.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(Vy.has(n))return;Vy.add(n),ol(n,"format",(i)=>(r)=>i_(i,r)),ol(n,"flatten",(i)=>(r)=>n_(i,r)),ol(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,Zo,2)}),ol(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,Zo,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Pn=J("ZodError",Q1,void 0,{Parent:Error});var Gy=Bc(Pn),Hy=Vc(Pn),$y=Gc(Pn),Wy=Hc(Pn),Zy=s_(Pn),Xy=o_(Pn),jy=a_(Pn),qy=c_(Pn),Yy=l_(Pn),Jy=u_(Pn),Ky=h_(Pn),Qy=d_(Pn);function tR(){if(!hn.localeError)Rn(md())}function sa(){if(!hn.memoizer)Rn({memoizer:_x()})}var Ct=J("ZodType",(e,t)=>(tR(),vt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Tn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return vi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(eC(e,t))},superRefine(e,t){return this.check(tC(e,t))},overwrite(e){return this.check(wr(e))},optional(){return nv(this)},exactOptional(){return kR(this)},nullable(){return iv(this)},nullish(){return nv(iv(this))},nonoptional(e){return WR(this,e)},array(){return _t(this)},or(e){return qs([this,e])},and(e){return DR(this,e)},transform(e){return rv(this,zR(e))},default(e){return GR(this,e)},prefault(e){return $R(this,e)},catch(e){return XR(this,e)},pipe(e){return rv(this,e)},readonly(){return YR(this)},describe(e){let t=this.clone();return Yr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Yr.get(this);let t=this.clone();return Yr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return zc(this,"~standard",{...cd(this),jsonSchema:{input:ia(this,"input"),output:ia(this,"output")}})},set "~standard"(e){Xi(this,"~standard",e)},parse:function e(t,n){return Gy(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Hy(this,t,n,{callee:e})},safeParse(e,t){return $y(this,e,t)},async safeParseAsync(e,t){return Wy(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Xi(this,"spa",e)},validate(e,t){return Kh(this,e,t)},validateAsync(e,t){return Qh(this,e,t)},encode:function e(t,n){return Zy(this,t,n,{callee:e})},decode:function e(t,n){return Xy(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await jy(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await qy(this,t,n,{callee:e})},safeEncode(e,t){return Yy(this,e,t)},safeDecode(e,t){return Jy(this,e,t)},async safeEncodeAsync(e,t){return Ky(this,e,t)},async safeDecodeAsync(e,t){return Qy(this,e,t)},toJSONSchema(e){return ay(this,{})(e)},get description(){return Yr.get(this)?.description},get _def(){return this._zod.def}}),sv=J("_ZodString",(e,t)=>{qc.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_y(e,n,i,r)},qg({format:(e)=>Cn(e).format??null,minLength:(e)=>Cn(e).minimum??null,maxLength:(e)=>Cn(e).maximum??null},{regex(...e){return this.check(gd(...e))},includes(...e){return this.check(yd(...e))},startsWith(...e){return this.check(vd(...e))},endsWith(...e){return this.check(bd(...e))},min(...e){return this.check(Zs(...e))},max(...e){return this.check(rl(...e))},length(...e){return this.check(sl(...e))},nonempty(...e){return this.check(Zs(1,...e))},lowercase(e){return this.check(_d(e))},uppercase(e){return this.check(xd(e))},trim(){return this.check(Md())},normalize(...e){return this.check(Sd(...e))},toLowerCase(){return this.check(wd())},toUpperCase(){return this.check(Ed())},slugify(){return this.check(Ad())}})),nR=J("ZodString",(e,t)=>{qc.init(e,t),sv.init(e,t)},{email(e){return this.check(Sx(aR,e))},url(e){return this.check(Rx(lR,e))},jwt(e){return this.check(Hx(wR,e))},emoji(e){return this.check(Cx(uR,e))},guid(e){return this.check(Mx(cR,e))},uuid(e){return this.check(wx(al,e))},uuidv4(e){return this.check(Ex(al,e))},uuidv6(e){return this.check(Ax(al,e))},uuidv7(e){return this.check(Tx(al,e))},nanoid(e){return this.check(Px(hR,e))},cuid(e){return this.check(Ix(dR,e))},cuid2(e){return this.check(Lx(fR,e))},ulid(e){return this.check(Nx(pR,e))},base64(e){return this.check(Bx(bR,e))},base64url(e){return this.check(Vx(SR,e))},xid(e){return this.check(Dx(mR,e))},ksuid(e){return this.check(Ox(gR,e))},ipv4(e){return this.check(Ux(_R,e))},ipv6(e){return this.check(Fx(xR,e))},cidrv4(e){return this.check(zx(yR,e))},cidrv6(e){return this.check(kx(vR,e))},e164(e){return this.check(Gx(MR,e))},datetime(e){return this.check($x(iR,e))},date(e){return this.check(Wx(rR,e))},time(e){return this.check(Zx(sR,e))},duration(e){return this.check(Xx(oR,e))}});function Xe(e){return bx(nR,e)}var Lt=J("ZodStringFormat",(e,t)=>{Rt.init(e,t),sv.init(e,t)}),iR=J("ZodISODateTime",(e,t)=>{R0.init(e,t),Lt.init(e,t)}),rR=J("ZodISODate",(e,t)=>{C0.init(e,t),Lt.init(e,t)}),sR=J("ZodISOTime",(e,t)=>{P0.init(e,t),Lt.init(e,t)}),oR=J("ZodISODuration",(e,t)=>{I0.init(e,t),Lt.init(e,t)}),aR=J("ZodEmail",(e,t)=>{_0.init(e,t),Lt.init(e,t)});var cR=J("ZodGUID",(e,t)=>{m0.init(e,t),Lt.init(e,t)});var al=J("ZodUUID",(e,t)=>{g0.init(e,t),Lt.init(e,t)});var lR=J("ZodURL",(e,t)=>{v0.init(e,t),Lt.init(e,t)});var uR=J("ZodEmoji",(e,t)=>{b0.init(e,t),Lt.init(e,t)});var hR=J("ZodNanoID",(e,t)=>{S0.init(e,t),Lt.init(e,t)});var dR=J("ZodCUID",(e,t)=>{M0.init(e,t),Lt.init(e,t)});var fR=J("ZodCUID2",(e,t)=>{w0.init(e,t),Lt.init(e,t)});var pR=J("ZodULID",(e,t)=>{E0.init(e,t),Lt.init(e,t)});var mR=J("ZodXID",(e,t)=>{A0.init(e,t),Lt.init(e,t)});var gR=J("ZodKSUID",(e,t)=>{T0.init(e,t),Lt.init(e,t)});var _R=J("ZodIPv4",(e,t)=>{L0.init(e,t),Lt.init(e,t)});var xR=J("ZodIPv6",(e,t)=>{D0.init(e,t),Lt.init(e,t)});var yR=J("ZodCIDRv4",(e,t)=>{O0.init(e,t),Lt.init(e,t)});var vR=J("ZodCIDRv6",(e,t)=>{U0.init(e,t),Lt.init(e,t)});var bR=J("ZodBase64",(e,t)=>{z0.init(e,t),Lt.init(e,t)});var SR=J("ZodBase64URL",(e,t)=>{k0.init(e,t),Lt.init(e,t)});var MR=J("ZodE164",(e,t)=>{B0.init(e,t),Lt.init(e,t)});var wR=J("ZodJWT",(e,t)=>{V0.init(e,t),Lt.init(e,t)});var ov=J("ZodNumber",(e,t)=>{ud.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xy(e,n,i,r),e.isFinite=!0},qg({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=Cn(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=Cn(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=Cn(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>Cn(e).format??null},{gt(e,t){return this.check(nl(e,t))},gte(e,t){return this.check(ta(e,t))},min(e,t){return this.check(ta(e,t))},lt(e,t){return this.check(tl(e,t))},lte(e,t){return this.check(ea(e,t))},max(e,t){return this.check(ea(e,t))},int(e){return this.check(ev(e))},safe(e){return this.check(ev(e))},positive(e){return this.check(nl(0,e))},nonnegative(e){return this.check(ta(0,e))},negative(e){return this.check(tl(0,e))},nonpositive(e){return this.check(ea(0,e))},multipleOf(e,t){return this.check(il(e,t))},step(e,t){return this.check(il(e,t))},finite(){return this}}));function et(e){return jx(ov,e)}var ER=J("ZodNumberFormat",(e,t)=>{G0.init(e,t),ov.init(e,t)});function ev(e){return qx(ER,e)}var AR=J("ZodBoolean",(e,t)=>{H0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yy(e,n,i,r)});function Kr(e){return Yx(AR,e)}var TR=J("ZodUnknown",(e,t)=>{$0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>by(e,n,i,r)});function Jr(){return Jx(TR)}var RR=J("ZodNever",(e,t)=>{W0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vy(e,n,i,r)});function CR(e){return Kx(RR,e)}var PR=J("ZodArray",(e,t)=>{sa(),Z0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ty(e,n,i,r),e.element=t.element},{min(e,t){return this.check(Zs(e,t))},nonempty(e){return this.check(Zs(1,e))},max(e,t){return this.check(rl(e,t))},length(e,t){return this.check(sl(e,t))},unwrap(){return this.element}});function _t(e,t){return Qx(PR,e,t)}var IR=J("ZodObject",(e,t)=>{sa(),q0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ry(e,n,i,r),c1(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return wt(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Tn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Tn(this._zod.def,{catchall:Jr()}))},loose(){return this.clone(Tn(this._zod.def,{catchall:Jr()}))},strict(){return this.clone(Tn(this._zod.def,{catchall:CR()}))},strip(){return this.clone(Tn(this._zod.def,{catchall:void 0}))},extend(e){return e1(this,e)},safeExtend(e){return t1(this,e)},merge(e){return n1(this,e)},pick(e){return KT(this,e)},omit(e){return QT(this,e)},partial(...e){return Wg(Fd,this,e[0])},exactPartial(...e){return Wg(lv,this,e[0],"exactPartial")},required(...e){return i1(uv,this,e[0])}});function be(e,t){let n={type:"object",shape:e??{},...Ce(t)};return new IR(n)}var av=J("ZodUnion",(e,t)=>{hd.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Cy(e,n,i,r),e.options=t.options});function qs(e,t){return new av({type:"union",options:e,...Ce(t)})}var LR=J("ZodDiscriminatedUnion",(e,t)=>{av.init(e,t),Y0.init(e,t)});function ni(e,t,n){return new LR({type:"union",options:t,discriminator:e,...Ce(n)})}var NR=J("ZodIntersection",(e,t)=>{J0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Py(e,n,i,r)});function DR(e,t){return new NR({type:"intersection",left:e,right:t})}var OR=J("ZodTuple",(e,t)=>{sa(),K0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Iy(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new Fd({type:"optional",innerType:t}))})}});function cv(e,t,n){let i=t instanceof vt,r=i?n:t;return new OR({type:"tuple",items:e,rest:i?t:null,...Ce(r)})}var tv=J("ZodRecord",(e,t)=>{sa(),Q0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ly(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function cl(e,t,n){if(!t||!t._zod)return new tv({type:"record",keyType:Xe(),valueType:e,...Ce(t)});return new tv({type:"record",keyType:e,valueType:t,...Ce(n)})}var Ud=J("ZodEnum",(e,t)=>{ex.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(i,r,s)=>Sy(e,i,r,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let o of i)if(n.has(o))s[o]=t.entries[o];else throw Error(`Key ${o} not found in enum`);return new Ud({...t,checks:[],...Ce(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let o of i)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new Ud({...t,checks:[],...Ce(r),entries:s})}});function wt(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new Ud({type:"enum",entries:n,...Ce(t)})}var UR=J("ZodLiteral",(e,t)=>{tx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>My(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Oe(e,t){return new UR({type:"literal",values:Array.isArray(e)?e:[e],...Ce(t)})}var FR=J("ZodTransform",(e,t)=>{sa(),nx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ay(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new qo(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(qr(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(qr(o))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function zR(e){return new FR({type:"transform",transform:e})}var Fd=J("ZodOptional",(e,t)=>{dd.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Dd(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function nv(e){return new Fd({type:"optional",innerType:e})}var lv=J("ZodExactOptional",(e,t)=>{ix.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Dd(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function kR(e){return new lv({type:"optional",innerType:e})}var BR=J("ZodNullable",(e,t)=>{rx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ny(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function iv(e){return new BR({type:"nullable",innerType:e})}var VR=J("ZodDefault",(e,t)=>{sx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Uy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function GR(e,t){return new VR({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Wh(t)}})}var HR=J("ZodPrefault",(e,t)=>{ox.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Fy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function $R(e,t){return new HR({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Wh(t)}})}var uv=J("ZodNonOptional",(e,t)=>{ax.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Dy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function WR(e,t){return new uv({type:"nonoptional",innerType:e,...Ce(t)})}var ZR=J("ZodCatch",(e,t)=>{cx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>zy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function XR(e,t){return new ZR({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Yg(t)})}var jR=J("ZodPipe",(e,t)=>{lx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ky(e,n,i,r),e.in=t.in,e.out=t.out});function rv(e,t){return new jR({type:"pipe",in:e,out:t})}var qR=J("ZodReadonly",(e,t)=>{ux.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>By(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function YR(e){return new qR({type:"readonly",innerType:e})}var JR=J("ZodTemplateLiteral",(e,t)=>{hx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>wy(e,n,i,r)});function KR(e,t){return new JR({type:"template_literal",parts:e,...Ce(t)})}var QR=J("ZodCustom",(e,t)=>{dx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ey(e,n,i,r)});function eC(e,t={}){return ey(QR,e,t)}function tC(e,t){return ty(e,t)}var hv=["neutral","dark","light"];var kd=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),dv=Object.freeze({neutral:kd("neutral",[170,177,188]),dark:kd("dark",[26,26,26]),light:kd("light",[223,227,232])});var QD=dv.neutral.rgb,eO=dv.neutral.hex;/*!fflate - fast JavaScript compression/decompression<https://101arrowz.github.io/fflate>Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSEversion 0.8.2-*/var Dt=Uint8Array,Ln=Uint16Array,Zd=Int32Array,al=new Dt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),cl=new Dt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Vd=new Dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),_v=function(e,t){var n=new Ln(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new Zd(n[30]);for(var i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return{b:n,r}},xv=_v(al,2),{b:yv,r:Gd}=xv;yv[28]=258,Gd[258]=28;var vv=_v(cl,0),{b:QR,r:hv}=vv,Hd=new Ln(32768);for(Qe=0;Qe<32768;++Qe)wi=(Qe&43690)>>1|(Qe&21845)<<1,wi=(wi&52428)>>2|(wi&13107)<<2,wi=(wi&61680)>>4|(wi&3855)<<4,Hd[Qe]=((wi&65280)>>8|(wi&255)<<8)>>1;var wi,Qe,Ei=function(e,t,n){var i=e.length,r=0,s=new Ln(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new Ln(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new Ln(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],d=o[e[r]-1]++<<u;for(var h=d|(1<<u)-1;d<=h;++d)a[Hd[d]>>c]=l}}else{a=new Ln(i);for(r=0;r<i;++r)if(e[r])a[r]=Hd[o[e[r]-1]++]>>15-e[r]}return a},Er=new Dt(288);for(Qe=0;Qe<144;++Qe)Er[Qe]=8;var Qe;for(Qe=144;Qe<256;++Qe)Er[Qe]=9;var Qe;for(Qe=256;Qe<280;++Qe)Er[Qe]=7;var Qe;for(Qe=280;Qe<288;++Qe)Er[Qe]=8;var Qe,aa=new Dt(32);for(Qe=0;Qe<32;++Qe)aa[Qe]=5;var Qe,eC=Ei(Er,9,0),tC=Ei(Er,9,1),nC=Ei(aa,5,0),iC=Ei(aa,5,1),zd=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},ii=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},kd=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Xd=function(e){return(e+7)/8|0},jd=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Dt(e.subarray(t,n))};var rC=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],$n=function(e,t,n){var i=Error(t||rC[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,$n);if(!n)throw i;return i},sC=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Dt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Dt(r*3);var l=function(Ae){var Et=n.length;if(Ae>Et){var Ge=new Dt(Math.max(Et*2,Ae));Ge.set(n),n=Ge}},u=t.f||0,d=t.p||0,h=t.b||0,{l:f,d:m,m:_,n:p}=t,g=r*8;do{if(!f){u=ii(e,d,1);var S=ii(e,d+1,3);if(d+=3,!S){var T=Xd(d)+4,y=e[T-4]|e[T-3]<<8,w=T+y;if(w>r){if(c)$n(0);break}if(a)l(h+y);n.set(e.subarray(T,w),h),t.b=h+=y,t.p=d=w*8,t.f=u;continue}else if(S==1)f=tC,m=iC,_=9,p=5;else if(S==2){var A=ii(e,d,31)+257,R=ii(e,d+10,15)+4,x=A+ii(e,d+5,31)+1;d+=14;var M=new Dt(x),z=new Dt(19);for(var C=0;C<R;++C)z[Vd[C]]=ii(e,d+C*3,7);d+=R*3;var L=zd(z),K=(1<<L)-1,I=Ei(z,L,1);for(var C=0;C<x;){var G=I[ii(e,d,K)];d+=G&15;var T=G>>4;if(T<16)M[C++]=T;else{var X=0,P=0;if(T==16)P=3+ii(e,d,3),d+=2,X=M[C-1];else if(T==17)P=3+ii(e,d,7),d+=3;else if(T==18)P=11+ii(e,d,127),d+=7;while(P--)M[C++]=X}}var j=M.subarray(0,A),k=M.subarray(A);_=zd(j),p=zd(k),f=Ei(j,_,1),m=Ei(k,p,1)}else $n(1);if(d>g){if(c)$n(0);break}}if(a)l(h+131072);var q=(1<<_)-1,Q=(1<<p)-1,Me=d;for(;;Me=d){var X=f[kd(e,d)&q],ue=X>>4;if(d+=X&15,d>g){if(c)$n(0);break}if(!X)$n(2);if(ue<256)n[h++]=ue;else if(ue==256){Me=d,f=null;break}else{var Be=ue-254;if(ue>264){var C=ue-257,we=al[C];Be=ii(e,d,(1<<we)-1)+yv[C],d+=we}var Z=m[kd(e,d)&Q],re=Z>>4;if(!Z)$n(3);d+=Z&15;var k=QR[re];if(re>3){var we=cl[re];k+=kd(e,d)&(1<<we)-1,d+=we}if(d>g){if(c)$n(0);break}if(a)l(h+131072);var se=h+Be;if(h<k){var xe=s-k,Ee=Math.min(k,se);if(xe+h<0)$n(3);for(;h<Ee;++h)n[h]=i[xe+h]}for(;h<se;++h)n[h]=n[h-k]}}if(t.l=f,t.p=Me,t.b=h,t.f=u,f)u=1,t.m=_,t.d=m,t.n=p}while(!u);return h!=n.length&&o?jd(n,0,h):n.subarray(0,h)},Yi=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},sa=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},Bd=function(e,t){var n=[];for(var i=0;i<e.length;++i)if(e[i])n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return{t:Sv,l:0};if(r==1){var o=new Dt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(w,A){return w.f-A.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,d=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(var i=1;i<r;++i)if(s[i].s>h)h=s[i].s;var f=new Ln(h+1),m=$d(n[u-1],f,0);if(m>t){var i=0,_=0,p=m-t,g=1<<p;s.sort(function(A,R){return f[R.s]-f[A.s]||A.f-R.f});for(;i<r;++i){var S=s[i].s;if(f[S]>t)_+=g-(1<<m-f[S]),f[S]=t;else break}_>>=p;while(_>0){var T=s[i].s;if(f[T]<t)_-=1<<t-f[T]++-1;else++i}for(;i>=0&&_;--i){var y=s[i].s;if(f[y]==t)--f[y],++_}m=t}return{t:new Dt(f),l:m}},$d=function(e,t,n){return e.s==-1?Math.max($d(e.l,t,n+1),$d(e.r,t,n+1)):t[e.s]=n},dv=function(e){var t=e.length;while(t&&!e[--t]);var n=new Ln(++t),i=0,r=e[0],s=1,o=function(c){n[i++]=c};for(var a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);if(s>2)o(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){o(r),--s;for(;s>6;s-=6)o(8304);if(s>2)o(s-3<<5|8208),s=0}while(s--)o(r);s=1,r=e[a]}return{c:n.subarray(0,i),n:t}},oa=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},bv=function(e,t,n){var i=n.length,r=Xd(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var s=0;s<i;++s)e[r+s+4]=n[s];return(r+4+i)*8},fv=function(e,t,n,i,r,s,o,a,c,l,u){Yi(t,u++,n),++r[256];var d=Bd(r,15),{t:h,l:f}=d,m=Bd(s,15),{t:_,l:p}=m,g=dv(h),{c:S,n:T}=g,y=dv(_),{c:w,n:A}=y,R=new Ln(19);for(var x=0;x<S.length;++x)++R[S[x]&31];for(var x=0;x<w.length;++x)++R[w[x]&31];var M=Bd(R,7),{t:z,l:C}=M,L=19;for(;L>4&&!z[Vd[L-1]];--L);var K=l+5<<3,I=oa(r,Er)+oa(s,aa)+o,G=oa(r,h)+oa(s,_)+o+14+3*L+oa(R,z)+2*R[16]+3*R[17]+7*R[18];if(c>=0&&K<=I&&K<=G)return bv(t,u,e.subarray(c,c+l));var X,P,j,k;if(Yi(t,u,1+(G<I)),u+=2,G<I){X=Ei(h,f,0),P=h,j=Ei(_,p,0),k=_;var q=Ei(z,C,0);Yi(t,u,T-257),Yi(t,u+5,A-1),Yi(t,u+10,L-4),u+=14;for(var x=0;x<L;++x)Yi(t,u+3*x,z[Vd[x]]);u+=3*L;var Q=[S,w];for(var Me=0;Me<2;++Me){var ue=Q[Me];for(var x=0;x<ue.length;++x){var Be=ue[x]&31;if(Yi(t,u,q[Be]),u+=z[Be],Be>15)Yi(t,u,ue[x]>>5&127),u+=ue[x]>>12}}}else X=eC,P=Er,j=nC,k=aa;for(var x=0;x<a;++x){var we=i[x];if(we>255){var Be=we>>18&31;if(sa(t,u,X[Be+257]),u+=P[Be+257],Be>7)Yi(t,u,we>>23&31),u+=al[Be];var Z=we&31;if(sa(t,u,j[Z]),u+=k[Z],Z>3)sa(t,u,we>>5&8191),u+=cl[Z]}else sa(t,u,X[we]),u+=P[we]}return sa(t,u,X[256]),u+P[256]},oC=new Zd([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Sv=new Dt(0),aC=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Dt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var d=oC[t-1],h=d>>13,f=d&8191,m=(1<<n)-1,_=s.p||new Ln(32768),p=s.h||new Ln(m+1),g=Math.ceil(n/3),S=2*g,T=function(Ye){return(e[Ye]^e[Ye+1]<<g^e[Ye+2]<<S)&m},y=new Zd(25000),w=new Ln(288),A=new Ln(32),R=0,x=0,M=s.i||0,z=0,C=s.w||0,L=0;for(;M+2<o;++M){var K=T(M),I=M&32767,G=p[K];if(_[I]=G,p[K]=I,C<=M){var X=o-M;if((R>7000||z>24576)&&(X>423||!l)){u=fv(e,c,0,y,w,A,x,z,L,M-L,u),z=R=x=0,L=M;for(var P=0;P<286;++P)w[P]=0;for(var P=0;P<30;++P)A[P]=0}var j=2,k=0,q=f,Q=I-G&32767;if(X>2&&K==T(M-Q)){var Me=Math.min(h,X)-1,ue=Math.min(32767,M),Be=Math.min(258,X);while(Q<=ue&&--q&&I!=G){if(e[M+j]==e[M+j-Q]){var we=0;for(;we<Be&&e[M+we]==e[M+we-Q];++we);if(we>j){if(j=we,k=Q,we>Me)break;var Z=Math.min(Q,we-2),re=0;for(var P=0;P<Z;++P){var se=M-Q+P&32767,xe=_[se],Ee=se-xe&32767;if(Ee>re)re=Ee,G=se}}}I=G,G=_[I],Q+=I-G&32767}}if(k){y[z++]=268435456|Gd[j]<<18|hv[k];var Ae=Gd[j]&31,Et=hv[k]&31;x+=al[Ae]+cl[Et],++w[257+Ae],++A[Et],C=M+j,++R}else y[z++]=e[M],++w[e[M]]}}for(M=Math.max(M,C);M<o;++M)y[z++]=e[M],++w[e[M]];if(u=fv(e,c,l,y,w,A,x,z,L,M-L,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=_,s.i=M,s.w=C}else{for(var M=s.w||0;M<o+l;M+=65535){var Ge=M+65535;if(Ge>=o)c[u/8|0]=l,Ge=o;u=bv(c,u+1,e.subarray(M,Ge))}s.i=o}return jd(a,0,i+Xd(u)+r)},cC=function(){var e=new Int32Array(256);for(var t=0;t<256;++t){var n=t,i=9;while(--i)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),lC=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=cC[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var uC=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Dt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return aC(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},Mv=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var Qt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function wv(e,t){return uC(e,t||{},0,0)}function Ev(e,t){return sC(e,{i:2},t&&t.out,t&&t.dictionary)}var Av=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=Mv(i,s[1]),s=s[0];if(s instanceof Dt)n[o]=[s,a];else n[o+="/"]=[new Dt(0),a],Av(s,o,n,i)}},pv=typeof TextEncoder<"u"&&new TextEncoder,hC=typeof TextDecoder<"u"&&new TextDecoder,dC=0;try{hC.decode(Sv,{stream:!0}),dC=1}catch(e){}function mv(e,t){if(t){var n=new Dt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(pv)return pv.encode(e);var r=e.length,s=new Dt(e.length+(e.length>>1)),o=0,a=function(u){s[o++]=u};for(var i=0;i<r;++i){if(o+5>s.length){var c=new Dt(o+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)a(l);else if(l<2048)a(192|l>>6),a(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63);else a(224|l>>12),a(128|l>>6&63),a(128|l&63)}return jd(s,0,o)}var Wd=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)$n(9);t+=i+4}return t},gv=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,d=Wd(l);if(Qt(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var h=new Date(n.mtime==null?Date.now():n.mtime),f=h.getFullYear()-1980;if(f<0||f>119)$n(10);if(Qt(e,t,f<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,s!=-1)Qt(e,t,n.crc),Qt(e,t+4,s<0?-s-2:s),Qt(e,t+8,n.size);if(Qt(e,t+12,c),Qt(e,t+14,d),t+=16,o!=null)Qt(e,t,u),Qt(e,t+6,n.attrs),Qt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,d)for(var m in l){var _=l[m],p=_.length;Qt(e,t,+m),Qt(e,t+2,p),e.set(_,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},fC=function(e,t,n,i,r){Qt(e,t,101010256),Qt(e,t+8,n),Qt(e,t+10,n),Qt(e,t+12,i),Qt(e,t+16,r)};function Tv(e,t){if(!t)t={};var n={},i=[];Av(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,d=mv(o),h=d.length,f=l.comment,m=f&&mv(f),_=m&&m.length,p=Wd(l.extra);if(h>65535)$n(11);var g=u?wv(c,l):c,S=g.length,T=lC();T.p(c),i.push(Mv(l,{size:c.length,crc:T.d(),c:g,f:d,m,u:h!=o.length||m&&f.length!=_,o:r,compression:u})),r+=30+h+p+S,s+=76+2*(h+p)+(_||0)+S}var y=new Dt(s+22),w=r,A=s-r;for(var R=0;R<i.length;++R){var d=i[R];gv(y,d.o,d,d.f,d.u,d.c.length);var x=30+d.f.length+Wd(d.extra);y.set(d.c,d.o+x),gv(y,r,d,d.f,d.u,d.c.length,d.o,d.m),r+=16+x+(d.m?d.m.length:0)}return fC(y,r,i.length,A,w),y}var Ai=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function pC(e){if(e==="PORTABLE_MATERIAL_V3_CONTRACT")return'compilePortableMaterialSpecV3 requires schemaVersion 3, model pbrMetallicRoughness, typed V3 procedural or injected resource references, and complete minFilter/magFilter/wrapS/wrapT samplers. Match texture usage to its slot and split work exceeding the material budget. Resource bindings need a host with verified-byte admission. V2 remains available unchanged. Shader code, paths, raw textures and V3 height derivation are unsupported. Read kiln_discover ids ["compilePortableMaterialSpecV3"] for the exact contract.';if(e==="TEXTURE_ATLAS_CONTRACT")return'textureAtlas requires bounded named integer content rectangles with nonoverlapping gutter allocations, matching source crops and usage, and explicit portable sampling. Sources are V3 recipes or exact host-injected library map pins. Split atlases exceeding aggregate work or allocation budgets. remapUVToAtlas requires finite unit UV0, a named content region, inputOrigin and mapping mode; it preserves topology and does not unwrap or tile a region. Read kiln_discover ids ["textureAtlas", "remapUVToAtlas"] for the exact contracts.';if(e==="PROCEDURAL_TEXTURE_V3_CONTRACT")return'proceduralTexture schemaVersion 3 requires bounded JSON: width/height 4..1024, byte RGBA, integer pixel shapes and at most 64 operations. Palette/dither and seeded stamps support only albedo/emissive. Work includes polygon edges and periodic copies. Read kiln_discover ids ["proceduralTexture"] for the V3 contract; keep schemaVersion 2 for existing opaque patterns.';if(e==="BONE_CHAIN_ARGUMENT")return'createBoneChain requires 1..1024 valid local joint descriptors with unique roles and animation-safe names across the parent hierarchy. Use normalized perpendicular forward/bend axes and finite rest transforms; an explicit parentRole must match the declared parent. Read the retained source and kiln_discover ids ["createBoneChain"] for the exact contract.';if(e==="SKIN_BINDING_ARGUMENT")return'createSkinnedPart requires four valid bone indices and finite nonnegative weights per vertex, summing to one unless normalizeWeights:true is explicit. Zero sums are rejected. Assemble distinct named Bones and the parent in one rest-pose hierarchy before binding. Use unbound geometry within the documented budgets and finite invertible transforms. Read the retained source and kiln_discover ids ["createSkinnedPart"] for the exact contract; the Three exporter is required for skin delivery.';if(e==="EXPORT_MATERIAL_SIDE_UNSUPPORTED")return"EXPORT_MATERIAL_SIDE_UNSUPPORTED: A used material has BackSide, which glTF cannot encode directly. Author inward-facing triangles with FrontSide, or choose DoubleSide when both faces are intended. Neither adds missing geometry. Read the retained program with kiln_source query BackSide to locate the material; source names and exception text do not cross the evaluator boundary.";if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="DELIVERY_CONTRACT")return'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].';if(e==="REQUIRE_SOLID")return'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}class ca extends Error{diagnostic;constructor(e,t=pC(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var ll=1024,ul=4,hl=8,Yd=6,Rv=80,es=256;class rt extends ca{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var Cv=["solid","checker","stripes","gradient","bricks","noise"],Pv=["normal","multiply","screen","overlay"],mC=new Set(["__proto__","prototype","constructor"]);function dl(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new rt(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new rt(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new rt(`${t} must not contain symbol keys.`);if(mC.has(i))throw new rt(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new rt(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new rt(`${t}.${i} must be a plain JSON data field.`)}return e}function gC(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new rt(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new rt(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new rt(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new rt(`${t} must be a dense JSON array (missing index ${n}).`);return e}function Ar(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new rt(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function ri(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new rt(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function Qr(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new rt(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function Lv(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new rt(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function qd(e,t,n){return Lv(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function _C(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>Rv||n)throw new rt(`${t} must be 1..${Rv} visible characters.`);return e}function xC(e,t,n){if(e===void 0)return n;if(!Ai.includes(e))throw new rt(`${t} must be one of ${Ai.join(", ")}, got ${JSON.stringify(e)}.`);return e}function Iv(e,t){let i=(Lv(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function yC(e,t){let n=e.blend??"normal";if(!Pv.includes(n))throw new rt(`${t}.blend ${JSON.stringify(n)} is not one of ${Pv.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function vC(e,t){let n=`proceduralTexture.layers[${t}]`,i=dl(e,n),r=i.op;if(!Cv.includes(r))throw new rt(`${n}.op ${JSON.stringify(r)} is not one of ${Cv.join(", ")}.`);let s=yC(i,n),o=qd(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return Ar(i,["op","color","blend","opacity"],n),{op:r,color:ri(i.color,`${n}.color`),...a};case"checker":return Ar(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:ri(i.colorA,`${n}.colorA`),colorB:ri(i.colorB,`${n}.colorB`),squares:Qr(i.squares,`${n}.squares`,8,1,es),...a};case"stripes":return Ar(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:ri(i.colorA,`${n}.colorA`),colorB:ri(i.colorB,`${n}.colorB`),count:Qr(i.count,`${n}.count`,8,1,es),angleDeg:Iv(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return Ar(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:ri(i.from,`${n}.from`),to:ri(i.to,`${n}.to`),angleDeg:Iv(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return Ar(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:ri(i.brick,`${n}.brick`),mortar:ri(i.mortar,`${n}.mortar`),rows:Qr(i.rows,`${n}.rows`,8,1,es),cols:Qr(i.cols,`${n}.cols`,4,1,es),mortarWidth:qd(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:qd(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return Ar(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:ri(i.colorA,`${n}.colorA`),colorB:ri(i.colorB,`${n}.colorB`),scale:Qr(i.scale,`${n}.scale`,8,1,es),octaves:Qr(i.octaves,`${n}.octaves`,3,1,Yd),seed:Qr(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new rt(`${n}.op is unsupported.`)}}function bC(e){let t=dl(e,"proceduralTexture");if(Ar(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new rt(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function la(e){let t=dl(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?dl(bC(t),"proceduralTexture"):t;if(Ar(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new rt(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<ul||i>ll||(i&i-1)!==0)throw new rt(`proceduralTexture.size must be a power of two between ${ul} and ${ll}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new rt("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=gC(r,"proceduralTexture.layers");if(s.length>hl)throw new rt(`proceduralTexture: ${s.length} layers exceeds the maximum of ${hl}.`);let o=_C(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:xC(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(vC)}}var SC=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ti=(e,t)=>e>>>t|e<<32-t;function Ys(e){let t=new TextEncoder().encode(e),n=t.length*8,i=Math.ceil((t.length+9)/64)*64,r=new Uint8Array(i);r.set(t),r[t.length]=128;let s=new DataView(r.buffer);s.setUint32(i-8,Math.floor(n/4294967296),!1),s.setUint32(i-4,n>>>0,!1);let o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);for(let c=0;c<r.length;c+=64){for(let S=0;S<16;S++)a[S]=s.getUint32(c+S*4,!1);for(let S=16;S<64;S++){let T=a[S-15],y=a[S-2],w=Ti(T,7)^Ti(T,18)^T>>>3,A=Ti(y,17)^Ti(y,19)^y>>>10;a[S]=a[S-16]+w+a[S-7]+A>>>0}let[l,u,d,h,f,m,_,p]=o;for(let S=0;S<64;S++){let T=Ti(f,6)^Ti(f,11)^Ti(f,25),y=f&m^~f&_,w=p+T+y+SC[S]+a[S]>>>0,A=Ti(l,2)^Ti(l,13)^Ti(l,22),R=l&u^l&d^u&d,x=A+R>>>0;p=_,_=m,m=f,f=h+w>>>0,h=d,d=u,u=l,l=w+x>>>0}let g=[l,u,d,h,f,m,_,p];for(let S=0;S<8;S++)o[S]=o[S]+g[S]>>>0}return[...o].map((c)=>c.toString(16).padStart(8,"0")).join("")}var Js="kiln.procedural-rgba.v3.1";var ha=1024,MC=1048576,da=64,pl=64,ua=256,ml=32,Nv=64000000,wC=67108864;function tt(e){throw new rt(`proceduralTexture V3: ${e}`,"PROCEDURAL_TEXTURE_V3_CONTRACT")}var EC=new Set(["__proto__","prototype","constructor"]);function AC(e){let t=0,n=(i,r,s)=>{if(++t>16384||s>10)tt(`${r} exceeds the JSON size/depth budget.`);if(i===null||typeof i==="boolean")return;if(typeof i==="string"){if(i.length>4096)tt(`${r} string is too long.`);return}if(typeof i==="number"){if(!Number.isFinite(i))tt(`${r} must be finite.`);return}if(typeof i!=="object")tt(`${r} must contain only JSON data.`);let o=Array.isArray(i),a=Object.getPrototypeOf(i);if(o?a!==Array.prototype:a!==Object.prototype&&a!==null)tt(`${r} must be a plain JSON ${o?"array":"object"}.`);let c=o?Object.getOwnPropertyDescriptor(i,"length")?.value:void 0;if(o&&(typeof c!=="number"||c>1024))tt(`${r} array is too long.`);let l=Reflect.ownKeys(i);if(l.length>1024)tt(`${r} has too many fields.`);let u=Object.getOwnPropertyDescriptors(i);for(let d of l){if(typeof d!=="string"||EC.has(d))tt(`${r} has a forbidden key.`);if(o&&d==="length")continue;let h=u[d];if(!h.enumerable||!("value"in h))tt(`${r}.${d} must be an enumerable JSON data field, never an accessor.`);if(o&&(!/^(0|[1-9][0-9]*)$/.test(d)||Number(d)>=c))tt(`${r} has an invalid array key.`)}if(o&&l.length!==c+1)tt(`${r} must be a dense JSON array.`);for(let d of l)if(d!=="length"||!o)n(u[d].value,`${r}.${String(d)}`,s+1)};n(e,"recipe",0)}function Wn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))tt(`${n} must be a JSON object.`);let i=e;for(let r of Object.keys(i))if(!t.includes(r))tt(`${n} has unknown field ${r}.`);return i}function pn(e,t,n,i,r){if(e===void 0&&r!==void 0)return r;if(typeof e!=="number"||!Number.isInteger(e)||e<t||e>n)tt(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function Dv(e,t){if(e===void 0)return!1;if(typeof e!=="boolean")tt(`${t} must be boolean.`);return e}function fl(e,t,n,i,r){if(!Array.isArray(e)||e.length!==t)tt(`${n} must be a ${t}-element array.`);return e.map((s,o)=>pn(s,i,r,`${n}[${o}]`))}function Ov(e,t){let n=fl(e,4,t,0,255);return n[3]===0?[0,0,0,0]:n}function Uv(e,t,n){let i=Wn(e,["x","y","width","height",...n?["kind"]:[]],t);return{x:pn(i.x,-4096,4096,`${t}.x`),y:pn(i.y,-4096,4096,`${t}.y`),width:pn(i.width,1,2048,`${t}.width`),height:pn(i.height,1,2048,`${t}.height`)}}function TC(e,t){let n=Wn(e,["kind","x","y","width","height","from","to","points"],t);if(n.kind==="rectangle"||n.kind==="ellipse")return{kind:n.kind,...Uv(n,t,n.kind)};if(n.kind==="polygon"){Wn(n,["kind","points"],t);let i=n.points;if(!Array.isArray(i)||i.length<3||i.length>pl)tt(`${t}.points requires 3..${pl} vertices.`);return{kind:"polygon",points:i.map((r,s)=>fl(r,2,`${t}.points[${s}]`,-4096,4096))}}if(n.kind==="line")return Wn(n,["kind","from","to","width"],t),{kind:"line",from:fl(n.from,2,`${t}.from`,-4096,4096),to:fl(n.to,2,`${t}.to`,-4096,4096),width:pn(n.width,1,2048,`${t}.width`)};return tt(`${t}.kind must be rectangle, ellipse, polygon or line.`)}function Fv(e){if(e.kind==="rectangle"||e.kind==="ellipse")return[e.x,e.y,e.x+e.width,e.y+e.height];let t=e.kind==="polygon"?e.points:[e.from,e.to],n=e.kind==="line"?e.width/2:0;return[Math.min(...t.map((i)=>i[0]))-n,Math.min(...t.map((i)=>i[1]))-n,Math.max(...t.map((i)=>i[0]))+n,Math.max(...t.map((i)=>i[1]))+n]}function RC(e){return e.kind==="polygon"?e.points.length+1:e.kind==="line"?4:e.kind==="ellipse"?3:1}function CC(e,t,n,i=0,r=0){let[s,o,a,c]=Fv(e);return[Math.max(0,Math.ceil(s+i-0.5)),Math.max(0,Math.ceil(o+r-0.5)),Math.min(t,Math.floor(a+i-0.5)+1),Math.min(n,Math.floor(c+r-0.5)+1)]}function gl(e){AC(e);let t=Wn(e,["schemaVersion","width","height","usage","name","background","operations","palette"],"recipe");if(t.schemaVersion!==3)tt("schemaVersion must be 3.");let n=pn(t.width,4,ha,"width"),i=pn(t.height,4,ha,"height"),r=n*i;if(r>MC)tt("output texel budget exceeded.");let s=t.usage===void 0?"albedo":t.usage;if(!Ai.includes(s))tt("usage must be a known texture usage.");let o=s==="albedo"||s==="emissive",a=t.name;if(a!==void 0&&(typeof a!=="string"||!a.length||a.length>80||[...a].some((p)=>p.charCodeAt(0)<32||p.charCodeAt(0)===127)))tt("name must be 1..80 visible characters.");let c=t.operations;if(!Array.isArray(c)||c.length>da)tt(`operations must be an array with at most ${da} entries.`);let l=r,u=0,d=0,h=c.map((p,g)=>{let S=`operations[${g}]`,T=Wn(p,["op","shape","rgba","opacity","alpha","invert","spec","count","seed","area","periodic"],S);if(T.op==="legacy-v2"){Wn(T,["op","spec","alpha","opacity"],S);let j=Wn(T.spec,["schemaVersion","size","usage","name","layers"],`${S}.spec`);if(j.schemaVersion!==2)tt(`${S}.spec requires explicit schemaVersion 2.`);let k=la(j);if(k.size!==n||k.size!==i||k.usage!==s)tt(`${S} legacy-v2 dimensions and usage must match the V3 surface.`);return l+=r*(1+k.layers.reduce((q,Q)=>q+(Q.op==="noise"?Q.octaves*16:4),0)),d+=r*4,{op:"legacy-v2",spec:k,alpha:pn(T.alpha,0,255,`${S}.alpha`,255),opacity:pn(T.opacity,0,255,`${S}.opacity`,255)}}let y=TC(T.shape,`${S}.shape`),w=RC(y),[A,R,x,M]=CC(y,n,i),z=Math.max(0,x-A)*Math.max(0,M-R);if(T.op==="mask")return Wn(T,["op","shape","alpha","invert"],S),l+=r+z*w,{op:"mask",shape:y,alpha:pn(T.alpha,0,255,`${S}.alpha`,255),invert:Dv(T.invert,`${S}.invert`)};if(T.op!=="paint"&&T.op!=="stamps")return tt(`${S}.op must be paint, mask, stamps or legacy-v2.`);let C={shape:y,rgba:Ov(T.rgba,`${S}.rgba`),opacity:pn(T.opacity,0,255,`${S}.opacity`,255)};if(T.op==="paint")return Wn(T,["op","shape","rgba","opacity"],S),l+=z*(w+1),{op:"paint",...C};if(Wn(T,["op","shape","rgba","opacity","count","seed","area","periodic"],S),!o)tt("stamps are supported only for color usages albedo and emissive.");let L=pn(T.count,1,ua,`${S}.count`),K=Dv(T.periodic,`${S}.periodic`),[I,G,X,P]=Fv(y);if(K&&(X-I>n||P-G>i))tt(`${S} periodic shape bounds must fit one surface period.`);if(u+=L*(K?9:1),u>ua)tt(`expanded stamps budget exceeds ${ua}.`);return l+=L*(K?9:1)*Math.min(n,Math.ceil(X-I)+1)*Math.min(i,Math.ceil(P-G)+1)*(w+1),{op:"stamps",...C,count:L,seed:pn(T.seed,0,4294967295,`${S}.seed`),area:Uv(T.area,`${S}.area`),periodic:K}}),f;if(t.palette!==void 0){if(!o)tt("palette and dither are supported only for color usages albedo and emissive.");let p=Wn(t.palette,["colors","dither"],"palette"),g=p.colors;if(!Array.isArray(g)||g.length<1||g.length>ml)tt(`palette.colors requires 1..${ml} entries.`);let S=p.dither===void 0?"none":p.dither;if(S!=="none"&&S!=="bayer4")tt("palette.dither must be none or bayer4.");f={colors:g.map((T,y)=>pn(T,0,16777215,`palette.colors[${y}]`)),dither:S},l+=r*(g.length+1)}if(l>Nv)tt(`estimated work budget ${l} exceeds ${Nv}.`);if(r*4+d>wC)tt("transient allocation budget exceeded.");let m={schemaVersion:3,width:n,height:i,usage:s,...a!==void 0?{name:a}:{},background:t.background===void 0?[0,0,0,0]:Ov(t.background,"background"),operations:h,...f?{palette:f}:{}},_=JSON.stringify(m);if(_.length>262144)tt("canonical JSON byte budget exceeded.");return{spec:m,canonicalJson:_,estimatedWorkUnits:l,conservativePixelAllocationBytes:r*4+d}}function Jd(e){return gl(e).spec}function PC(e){return gl(e).canonicalJson}function Kd(e){return`sha256:${Ys(`${Js}-${PC(e)}`)}`}var Qd=["nearest","linear","nearest-mipmap-nearest","linear-mipmap-nearest","nearest-mipmap-linear","linear-mipmap-linear"],ef=["nearest","linear"],fa=["repeat","clamp-to-edge","mirrored-repeat"];function _l(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new rt("portableSampler requires a complete JSON object.");let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new rt("portableSampler must be plain JSON data.");for(let r of Reflect.ownKeys(e)){let s=Object.getOwnPropertyDescriptor(e,r);if(typeof r!=="string"||!s.enumerable||!("value"in s))throw new rt("portableSampler requires enumerable JSON data fields, never accessors.")}let n=e,i={minFilter:Qd,magFilter:ef,wrapS:fa,wrapT:fa};if(Object.keys(n).some((r)=>!Object.hasOwn(i,r)))throw new rt("portableSampler contains an unsupported field.");for(let[r,s]of Object.entries(i))if(!s.includes(n[r]))throw new rt(`portableSampler.${r} requires one of ${s.join(", ")}.`);return{minFilter:n.minFilter,magFilter:n.magFilter,wrapS:n.wrapS,wrapT:n.wrapT}}var Bv="kiln.texture-atlas.v1.1",Vv="kiln.texture-atlas.v1.2",xl=Object.freeze([Bv,Vv]),ts=Object.freeze({edge:1024,outputTexels:1048576,regions:64,sources:16,sourceTexels:4194304,encodedSourceBytes:8388608,encodedBytes:16777216,jsonBytes:262144,work:64000000,allocatedBytes:67108864,uvVertices:262144,uvAttributeBytes:134217728}),Ji=Object.freeze({...ts,edge:2048,outputTexels:4194304,regions:128,sources:32,work:192000000,allocatedBytes:134217728}),nf=Object.freeze([1024,2048]);function Gv(e){return e.pack===void 0?Bv:Vv}function IC(e){return e.pack===void 0?ts:Ji}class Hv extends ca{constructor(e){super("TEXTURE_ATLAS_CONTRACT",`textureAtlas: ${e}`);this.name="TextureAtlasError"}}function Ne(e){throw new Hv(e)}function rf(e){let t=0,n=0,i=new TextEncoder,r=(o)=>{if(n+=o,n>ts.jsonBytes)Ne("JSON byte budget exceeded.")},s=(o,a)=>{if(++t>65536||a>16)Ne("JSON node/depth budget exceeded.");if(o===null||typeof o==="boolean"){r(o===!1?5:4);return}if(typeof o==="number"){if(!Number.isFinite(o))Ne("JSON numbers must be finite.");r(JSON.stringify(o).length);return}if(typeof o==="string"){if(o.length>4096)Ne("JSON string budget exceeded.");r(i.encode(JSON.stringify(o)).length);return}if(typeof o!=="object")Ne("plain JSON data is required.");let c=Array.isArray(o),l=Object.getPrototypeOf(o);if(c?l!==Array.prototype:l!==null&&l!==Object.prototype)Ne("plain JSON prototypes are required.");let u=c?Object.getOwnPropertyDescriptor(o,"length")?.value:void 0;if(c&&(!Number.isSafeInteger(u)||u>1024))Ne("JSON array budget exceeded.");let d=Reflect.ownKeys(o);if(d.length>1024||c&&d.length!==u+1)Ne("dense bounded JSON fields are required.");r(2+Math.max(0,d.length-(c?1:0)-1));for(let h of d){if(c&&h==="length")continue;if(typeof h!=="string"||["__proto__","prototype","constructor"].includes(h))Ne("forbidden JSON field.");if(h.length>4096)Ne("JSON field name budget exceeded.");if(!c)r(i.encode(JSON.stringify(h)).length+1);let f=Object.getOwnPropertyDescriptor(o,h);if(!f.enumerable||!("value"in f))Ne("JSON accessors/hidden fields are unsupported.");if(c&&(!/^(0|[1-9][0-9]*)$/.test(h)||Number(h)>=u))Ne("invalid JSON array key.");s(f.value,a+1)}};s(e,0)}function mn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))Ne(`${n} must be a JSON object.`);let i=e;if(Object.keys(i).some((r)=>!t.includes(r)))Ne(`${n} has an unknown field.`);return i}function Nn(e,t,n,i){if(typeof e!=="number"||!Number.isSafeInteger(e)||e<t||e>n)Ne(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function Tr(e,t){if(typeof e!=="string"||!/^sha256:[a-f0-9]{64}$/.test(e))Ne(`${t} must be an exact SHA-256 hash.`);return e}function zv(e,t){let n=mn(e,["x","y","width","height"],t);return{x:Nn(n.x,0,4096,`${t}.x`),y:Nn(n.y,0,4096,`${t}.y`),width:Nn(n.width,1,4096,`${t}.width`),height:Nn(n.height,1,4096,`${t}.height`)}}function Ks(e){let{content:t,gutter:n}=e;return{x:t.x-n,y:t.y-n,width:t.width+2*n,height:t.height+2*n}}function $v(e,t,n,i){if(e.x+e.width>n||e.y+e.height>i)Ne("source crop is out of bounds.");if(e.width!==t.width||e.height!==t.height)Ne("source crop/content dimensions must match; resampling is unsupported.")}function tf(e){return e.kind==="procedural"?`procedural:${Kd(e.spec)}`:`resource:${e.pin.resourceId}:${e.pin.revisionId}:${e.resourceId}`}var LC=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,kv=(e,t)=>t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height;function NC(e,t,n,i){let r=[{x:0,y:0,width:e,height:t}],s=(a)=>{let c=[];for(let l of r){if(!LC(l,a)){c.push(l);continue}if(a.x>l.x)c.push({x:l.x,y:l.y,width:a.x-l.x,height:l.height});if(a.x+a.width<l.x+l.width)c.push({x:a.x+a.width,y:l.y,width:l.x+l.width-a.x-a.width,height:l.height});if(a.y>l.y)c.push({x:l.x,y:l.y,width:l.width,height:a.y-l.y});if(a.y+a.height<l.y+l.height)c.push({x:l.x,y:a.y+a.height,width:l.width,height:l.y+l.height-a.y-a.height})}if(r=c.filter((l,u)=>!c.some((d,h)=>h!==u&&kv(d,l)&&(!kv(l,d)||h<u))),r.length>16384)Ne("pack: free-space bookkeeping budget exceeded.")};for(let a of n)s(a);let o=[...i].sort((a,c)=>c.width*c.height-a.width*a.height||(a.region.name<c.region.name?-1:a.region.name>c.region.name?1:0));for(let a of o){let c,l;for(let u of r){if(u.width<a.width||u.height<a.height)continue;let d=u.width-a.width,h=u.height-a.height,f=[Math.min(d,h),Math.max(d,h),u.y,u.x];if(!l||f[0]<l[0]||f[0]===l[0]&&(f[1]<l[1]||f[1]===l[1]&&(f[2]<l[2]||f[2]===l[2]&&f[3]<l[3])))c=u,l=f}if(!c)Ne(`pack: region ${a.region.name} (${a.width}x${a.height} texels with its gutter) does not fit in the ${e}x${t} atlas beside the regions already placed.`);a.region.content={x:c.x+a.region.gutter,y:c.y+a.region.gutter,width:a.region.content.width,height:a.region.content.height},s({x:c.x,y:c.y,width:a.width,height:a.height})}}function pa(e){rf(e);let t=mn(e,["schemaVersion","width","height","usage","sampler","regions","pack"],"atlas");if(t.schemaVersion!==1)Ne("schemaVersion must be 1.");let n;if(t.pack!==void 0){let h=mn(t.pack,["edge","gutter","algorithm"],"pack");if(!nf.includes(h.edge))Ne("pack.edge must be 1024 or 2048.");if(h.algorithm!==void 0&&h.algorithm!=="maxrects")Ne("pack.algorithm must be 'maxrects'.");n={edge:h.edge,gutter:h.gutter===void 0?2:Nn(h.gutter,0,32,"pack.gutter"),algorithm:"maxrects"}}let i=n?Ji:ts,r=n?n.edge:i.edge,s=n&&t.width===void 0?n.edge:Nn(t.width,4,r,"width"),o=n&&t.height===void 0?n.edge:Nn(t.height,4,r,"height");if(s*o>i.outputTexels)Ne("output texel budget exceeded.");if(!Ai.includes(t.usage))Ne("usage must be a texture usage.");let a=t.usage;if(!Array.isArray(t.regions)||!t.regions.length||t.regions.length>i.regions)Ne(`regions must contain 1..${i.regions} entries.`);let c=[],l=t.regions.map((h,f)=>{let m=mn(h,["name","content","gutter","edgeMode","source","crop","packed"],`regions[${f}]`);if(typeof m.name!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(m.name))Ne("region name must be a stable lowercase identifier.");let _=m.content!==void 0;if(!_&&!n)Ne(`region ${m.name}: content is required unless the atlas sets pack.`);if(m.packed!==void 0&&(m.packed!==!0||!n||!_))Ne("packed is the resolved-placement marker: true, with content, in an atlas that sets pack.");let p=_?zv(m.content,"content"):void 0,g=m.gutter===void 0?n?.gutter??2:Nn(m.gutter,0,32,"gutter"),S=m.edgeMode===void 0?"copy-edge":m.edgeMode;if(!["copy-edge","mask-rgb-dilate"].includes(S))Ne("unsupported edgeMode.");if(S==="mask-rgb-dilate"&&a!=="albedo"&&a!=="emissive")Ne("mask RGB dilation requires color usage.");let T=mn(m.source,["kind","spec","resourceId","pin","expected"],"source"),y,w=m.crop===void 0?void 0:zv(m.crop,"crop");if(T.kind==="procedural"){mn(T,["kind","spec"],"procedural source");let R=gl(T.spec);if(R.spec.usage!==a)Ne("source usage does not match atlas usage.");y={kind:"procedural",spec:R.spec},w??={x:0,y:0,width:R.spec.width,height:R.spec.height},p??={x:0,y:0,width:w.width,height:w.height},$v(w,p,R.spec.width,R.spec.height)}else if(T.kind==="resource"){if(mn(T,["kind","resourceId","pin","expected"],"resource source"),typeof T.resourceId!=="string"||!/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/.test(T.resourceId))Ne("source resourceId must be an exact returned map ID.");let R=mn(T.pin,["resourceId","revisionId","sha256"],"source pin");if(typeof R.resourceId!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(R.resourceId))Ne("pin resourceId must be a material ID.");let x=Tr(R.revisionId,"pin revisionId"),M=Tr(R.sha256,"pin sha256");if(x!==M)Ne("source pin revision/hash mismatch.");let z;if(T.expected!==void 0){let C=mn(T.expected,["width","height","imageSha256","decodedPixelHash"],"source expected");z={...C.width===void 0?{}:{width:Nn(C.width,1,4096,"expected.width")},...C.height===void 0?{}:{height:Nn(C.height,1,4096,"expected.height")},...C.imageSha256===void 0?{}:{imageSha256:Tr(C.imageSha256,"expected.imageSha256")},...C.decodedPixelHash===void 0?{}:{decodedPixelHash:Tr(C.decodedPixelHash,"expected.decodedPixelHash")}}}if(y={kind:"resource",resourceId:T.resourceId,pin:{resourceId:R.resourceId,revisionId:x,sha256:M},...z?{expected:z}:{}},!p){let C=w??(z?.width!==void 0&&z.height!==void 0?{width:z.width,height:z.height}:Ne(`region ${m.name}: a packed resource region needs a crop or expected width and height (its size).`));p={x:0,y:0,width:C.width,height:C.height}}if(w&&(w.width!==p.width||w.height!==p.height))Ne("source crop/content dimensions must match; resampling is unsupported.")}else Ne("source kind must be procedural or pinned resource.");let A={name:m.name,content:p,gutter:g,edgeMode:S,source:y,...w?{crop:w}:{},...n&&(!_||m.packed===!0)?{packed:!0}:{}};if(!_)c.push({region:A,width:A.content.width+2*g,height:A.content.height+2*g});return A}).sort((h,f)=>h.name<f.name?-1:h.name>f.name?1:0);if(new Set(l.map((h)=>h.name)).size!==l.length)Ne("duplicate region name.");if(c.length){let h=new Set(c.map((f)=>f.region));NC(s,o,l.filter((f)=>!h.has(f)).map((f)=>Ks(f)),c)}for(let h of l){let f=Ks(h);if(f.x<0||f.y<0||f.x+f.width>s||f.y+f.height>o)Ne("padded allocation is out of bounds.")}for(let h=0;h<l.length;h++)for(let f=h+1;f<l.length;f++){let m=Ks(l[h]),_=Ks(l[f]);if(m.x<_.x+_.width&&_.x<m.x+m.width&&m.y<_.y+_.height&&_.y<m.y+m.height)Ne(`padded allocations overlap: ${l[h].name}, ${l[f].name}.`)}if(new Set(l.map((h)=>tf(h.source))).size>i.sources)Ne(`distinct source budget exceeds ${i.sources}.`);let u;try{u=_l(t.sampler===void 0?{minFilter:"linear-mipmap-linear",magFilter:"linear",wrapS:"clamp-to-edge",wrapT:"clamp-to-edge"}:t.sampler)}catch(h){Ne(`sampler: ${h.message}`)}let d={schemaVersion:1,width:s,height:o,usage:a,sampler:u,regions:l,...n?{pack:n}:{}};if(new TextEncoder().encode(JSON.stringify(d)).length>ts.jsonBytes)Ne("canonical JSON byte budget exceeded.");return d}function DC(e){let t=pa(e);return`sha256:${Ys(`${Gv(t)}-${JSON.stringify(t)}`)}`}function Ri(e){rf(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function OC(e){return`sha256:${Ys(`kiln.atlas-layout.v1-${Ri({width:e.width,height:e.height,origin:"top-left",regions:e.regions.map((t)=>({name:t.name,content:t.content,allocation:Ks(t)}))})}`)}`}function sf(e,t){rf(e);let n=pa(t),i=mn(e,["version","compilerId","width","height","usage","origin","sampler","specHash","layoutHash","decodedPixelHash","atlasPixelHash","sources","regions","manifestHash"],"manifest");if(i.version!=="kiln.atlas-manifest.v1"||i.compilerId!==Gv(n)||i.width!==n.width||i.height!==n.height||i.usage!==n.usage||i.origin!=="top-left")Ne("manifest version/compiler/dimensions/usage/origin mismatch.");if(Ri(i.sampler)!==Ri(n.sampler)||i.specHash!==DC(n)||i.layoutHash!==OC(n))Ne("manifest sampler/spec/layout identity mismatch.");Tr(i.decodedPixelHash,"manifest decodedPixelHash"),Tr(i.atlasPixelHash,"manifest atlasPixelHash");let r=new Map(n.regions.map((c)=>[tf(c.source),c.source]));if(!Array.isArray(i.sources)||i.sources.length!==r.size||!Array.isArray(i.regions)||i.regions.length!==n.regions.length)Ne("manifest source/region inventory mismatch.");let s=new Map;for(let c of i.sources){let l=mn(c,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId","descriptor"],"manifest source");if(typeof l.id!=="string"||s.has(l.id))Ne("duplicate/invalid manifest source identity.");let u=r.get(l.id);if(!u||l.kind!==u.kind)Ne("manifest source identity mismatch.");let d=Nn(l.width,1,4096,"manifest source width"),h=Nn(l.height,1,4096,"manifest source height");if(Tr(l.decodedPixelHash,"manifest source decodedPixelHash"),u.kind==="procedural"){if(mn(l,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId"],"manifest procedural source"),d!==u.spec.width||h!==u.spec.height||l.recipeHash!==Kd(u.spec)||l.compilerId!=="kiln.procedural-rgba.v3.1")Ne("manifest procedural source identity mismatch.")}else{mn(l,["id","kind","width","height","decodedPixelHash","descriptor"],"manifest resource source");let f=mn(l.descriptor,["materialId","revisionId","resourceId","slot","usage","colorSpace","width","height","encodedByteLength","imageSha256","decodedPixelHash"],"manifest source descriptor"),m={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};if(f.materialId!==u.pin.resourceId||f.revisionId!==u.pin.revisionId||f.resourceId!==u.resourceId||f.width!==d||f.height!==h||f.usage!==n.usage||typeof f.slot!=="string"||m[f.slot]!==n.usage||f.colorSpace!==(n.usage==="albedo"||n.usage==="emissive"?"srgb":"linear"))Ne("manifest pinned resource descriptor mismatch.");if(Tr(f.imageSha256,"manifest source imageSha256"),Nn(f.encodedByteLength,1,IC(n).encodedSourceBytes,"manifest encodedByteLength"),f.decodedPixelHash!==void 0&&f.decodedPixelHash!==l.decodedPixelHash)Ne("manifest source decodedPixelHash mismatch.");for(let _ of["width","height","imageSha256","decodedPixelHash"]){let p=u.expected?.[_];if(p!==void 0&&p!==(_==="decodedPixelHash"?l[_]:f[_]))Ne("manifest source expectation mismatch.")}}s.set(l.id,{width:d,height:h})}for(let c=0;c<n.regions.length;c++){let l=n.regions[c],u=mn(i.regions[c],["name","content","allocation","crop","sourceId"],"manifest region"),d=tf(l.source),h=s.get(d),f=l.crop??{x:0,y:0,width:h.width,height:h.height};if($v(f,l.content,h.width,h.height),u.name!==l.name||u.sourceId!==d||Ri(u.content)!==Ri(l.content)||Ri(u.allocation)!==Ri(Ks(l))||Ri(u.crop)!==Ri(f))Ne("manifest named region/crop/allocation identity mismatch.")}let{manifestHash:o,...a}=i;if(o!==`sha256:${Ys(`kiln.atlas-manifest.v1-${Ri(a)}`)}`)Ne("manifest hash mismatch.");return structuredClone(e)}var UC=(()=>{let e=et().int().min(0).max(16777215),t=et().int().min(1).max(es),n=et().min(-36000).max(36000),i=et().min(0).max(1),r={blend:wt(["normal","multiply","screen","overlay"]),opacity:i};return be({schemaVersion:Oe(2),size:et().int().min(ul).max(ll),usage:wt(Ai),name:Xe().min(1).max(80).optional(),layers:_t(ni("op",[be({op:Oe("solid"),color:e,...r}).strict(),be({op:Oe("checker"),colorA:e,colorB:e,squares:t,...r}).strict(),be({op:Oe("stripes"),colorA:e,colorB:e,count:t,angleDeg:n,...r}).strict(),be({op:Oe("gradient"),from:e,to:e,angleDeg:n,...r}).strict(),be({op:Oe("bricks"),brick:e,mortar:e,rows:t,cols:t,mortarWidth:i,stagger:i,...r}).strict(),be({op:Oe("noise"),colorA:e,colorB:e,scale:t,octaves:et().int().min(1).max(Yd),seed:et().int().min(-2147483648).max(2147483647),...r}).strict()])).min(1).max(hl)}).strict()})();function Wv(e,t=UC){let n=(q,Q)=>et().int().min(q).max(Q),i=n(0,255),r=n(-4096,4096),s=ov([r,r]),o=ov([i,i,i,i]),a=wt(Ai),c=qR(["sha256:",Xe().regex(/^[a-f0-9]{64}$/)]),l=Xe().min(1).max(80),u=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),d=Xe().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),h={width:n(1,4096),height:n(1,4096)},f=be({x:r,y:r,width:n(1,2048),height:n(1,2048)}).strict(),m=be({x:n(0,4096),y:n(0,4096),...h}).strict(),_=ni("kind",[f.extend({kind:Oe("rectangle")}).strict(),f.extend({kind:Oe("ellipse")}).strict(),be({kind:Oe("polygon"),points:_t(s).min(3).max(pl)}).strict(),be({kind:Oe("line"),from:s,to:s,width:n(1,2048)}).strict()]),p=be({op:Oe("paint"),shape:_,rgba:o,opacity:i}).strict(),g=be({op:Oe("mask"),shape:_,alpha:i,invert:Kr()}).strict(),S=be({op:Oe("stamps"),shape:_,rgba:o,opacity:i,count:n(1,ua),seed:n(0,4294967295),area:f,periodic:Kr()}).strict(),T=be({op:Oe("legacy-v2"),spec:e,alpha:i,opacity:i}).strict(),y=be({colors:_t(n(0,16777215)).min(1).max(ml),dither:wt(["none","bayer4"])}).strict(),w={schemaVersion:Oe(3),width:n(4,ha),height:n(4,ha),usage:a,name:l.optional(),background:o},A=be({...w,operations:_t(ni("op",[p,g,S,T.extend({spec:t})])).max(da),palette:y.optional()}).strict(),R=be({...w,usage:a.optional(),background:o.optional(),operations:_t(ni("op",[p.partial({opacity:!0}),g.partial({alpha:!0,invert:!0}),S.partial({opacity:!0,periodic:!0}),T.partial({alpha:!0,opacity:!0})])).max(da),palette:y.partial({dither:!0}).optional()}).strict(),x=be({minFilter:wt(Qd),magFilter:wt(ef),wrapS:wt(fa),wrapT:wt(fa)}).strict(),M=be({resourceId:u,revisionId:c,sha256:c}).strict(),z=be({kind:Oe("resource"),resourceId:d,pin:M,expected:be({...h,imageSha256:c,decodedPixelHash:c}).partial().strict().optional()}).strict(),C=be({name:u,content:m,gutter:n(0,32),edgeMode:wt(["copy-edge","mask-rgb-dilate"]),source:ni("kind",[be({kind:Oe("procedural"),spec:A}).strict(),z]),crop:m.optional(),packed:Oe(!0).optional()}).strict(),L={schemaVersion:Oe(1),width:n(4,Ji.edge),height:n(4,Ji.edge),usage:a,sampler:x},K=qs(nf.map((q)=>Oe(q))),I=be({...L,regions:_t(C).min(1).max(Ji.regions),pack:be({edge:K,gutter:n(0,32),algorithm:Oe("maxrects")}).strict().optional()}).strict(),G=be({...L,width:L.width.optional(),height:L.height.optional(),pack:be({edge:K,gutter:n(0,32).optional(),algorithm:Oe("maxrects").optional()}).strict().optional(),sampler:x.optional(),regions:_t(C.extend({source:ni("kind",[be({kind:Oe("procedural"),spec:R}).strict(),z])}).partial({content:!0,gutter:!0,edgeMode:!0})).min(1).max(Ji.regions)}).strict(),X=be({materialId:u,revisionId:c,resourceId:d,slot:wt(["baseColor","normal","metallicRoughness","emissive","occlusion"]),usage:a,colorSpace:wt(["srgb","linear"]),...h,encodedByteLength:n(1,ts.encodedSourceBytes),imageSha256:c,decodedPixelHash:c.optional()}).strict(),P={id:Xe().min(1).max(1024),...h,decodedPixelHash:c},j=ni("kind",[be({...P,kind:Oe("procedural"),recipeHash:c,compilerId:Oe(Js)}).strict(),be({...P,kind:Oe("resource"),descriptor:X}).strict()]),k=be({version:Oe("kiln.atlas-manifest.v1"),compilerId:wt(xl),width:L.width,height:L.height,usage:a,origin:Oe("top-left"),sampler:x,specHash:c,layoutHash:c,decodedPixelHash:c,atlasPixelHash:c,sources:_t(j).min(1).max(Ji.sources),regions:_t(be({name:u,content:m,allocation:m,crop:m,sourceId:Xe().min(1).max(1024)}).strict()).min(1).max(Ji.regions),manifestHash:c}).strict();return{portableSamplerSchema:x,proceduralTextureSpecV3Schema:R,canonicalProceduralTextureSpecV3Schema:A,textureAtlasSpecV1Schema:G,canonicalTextureAtlasSpecV1Schema:I,textureAtlasManifestV1Schema:k,materialMapPinSchema:M,verifiedPinnedMaterialMapDescriptorSchema:X}}var cn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),Xv=["baseColor","normal","metallicRoughness","emissive","occlusion"],jv={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var eo=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),Pi=Xe().regex(/^sha256:[a-f0-9]{64}$/),Ci=Xe().min(1).max(1000),Zv=Xe().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),qv=be({id:eo,kind:wt(["external","procedural"]),provider:Ci,creator:Ci,assetId:Ci.optional(),assetUrl:Zv.optional(),accessedAt:Xe().datetime().optional(),license:be({spdx:Ci,url:Zv,attribution:Xe().max(4000)}).strict(),originalFiles:_t(be({name:Xe().min(1).max(200),sha256:Pi,bytes:et().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),Yv=be({operation:Ci,tool:Ci,version:Ci,parameters:ol(Xe().max(100),qs([Xe().max(2000),et().finite(),Kr()])).optional()}).strict(),si=et().int().min(0).max(16777215),ma=et().int().min(1).max(256),Qs={blend:wt(["normal","multiply","screen","overlay"]).default("normal"),opacity:et().min(0).max(1).default(1)},_a=be({schemaVersion:Oe(2),size:et().int().min(4).max(1024).default(256),usage:wt(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Xe().min(1).max(80).optional(),layers:_t(ni("op",[be({op:Oe("solid"),color:si,...Qs}).strict(),be({op:Oe("checker"),colorA:si,colorB:si,squares:ma.default(8),...Qs}).strict(),be({op:Oe("stripes"),colorA:si,colorB:si,count:ma.default(8),angleDeg:et().min(-36000).max(36000).default(0),...Qs}).strict(),be({op:Oe("gradient"),from:si,to:si,angleDeg:et().min(-36000).max(36000).default(0),...Qs}).strict(),be({op:Oe("bricks"),brick:si,mortar:si,rows:ma.default(8),cols:ma.default(4),mortarWidth:et().min(0).max(1).default(0.06),stagger:et().min(0).max(1).default(0.5),...Qs}).strict(),be({op:Oe("noise"),colorA:si,colorB:si,scale:ma.default(8),octaves:et().int().min(1).max(6).default(3),seed:et().int().min(-2147483648).max(2147483647).default(0),...Qs}).strict()])).min(1).max(8)}).strict(),cf=be({kind:Oe("normal-from-height"),strength:et().finite().positive().max(64)}).strict(),FC=be({compiler:Oe("kiln.procedural-texture.v2"),spec:_a,derive:cf.optional(),recipeHash:Pi,pixelHash:Pi,encoder:be({name:Oe("sharp"),version:Ci}).strict()}).strict(),Jv=be({baseColor:et().int().min(0).max(16777215).optional(),roughness:et().min(0).max(1).default(1),metalness:et().min(0).max(1).default(0),emissive:et().int().min(0).max(16777215).optional(),emissiveIntensity:et().min(0).max(64).default(1),alphaMode:wt(["opaque","mask","blend"]).default("opaque"),alphaCutoff:et().min(0).max(1).default(0.5),doubleSided:Kr().default(!1)}).strict(),ga=be({schemaVersion:Oe(1),materialId:eo,revisionId:Pi,name:Xe().min(1).max(200),tags:_t(Xe().min(1).max(80)).max(30),tileable:Kr(),physicalSizeMeters:be({width:et().finite().positive().max(1e5),height:et().finite().positive().max(1e5)}).strict().optional(),parameters:Jv,sources:_t(qv).min(1).max(20),maps:_t(be({slot:wt(Xv),file:wt(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:Pi,bytes:et().int().positive().max(cn.maxMapBytes),width:et().int().positive().max(cn.maxMapEdge),height:et().int().positive().max(cn.maxMapEdge),usage:wt(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:wt(["srgb","linear"]),normalConvention:Oe("opengl").optional(),channelPacking:Oe("r-occlusion-g-roughness-b-metallic").optional(),sourceId:eo,originalFile:Xe().min(1).max(200).optional(),transforms:_t(Yv).max(30),procedural:FC.optional()}).strict()).min(1).max(5)}).strict(),of=be({materialId:eo,name:Xe().min(1).max(200),tags:_t(Xe().min(1).max(80)).max(30).optional(),tileable:Kr(),physicalSizeMeters:be({width:et().finite().positive().max(1e5),height:et().finite().positive().max(1e5)}).strict().optional(),parameters:Jv.partial().optional(),sources:_t(qv).min(1).max(20),maps:_t(be({slot:wt(Xv),sourceId:eo,transforms:_t(Yv).max(30),normalConvention:Oe("opengl").optional(),channelPacking:Oe("r-occlusion-g-roughness-b-metallic").optional(),procedural:_a,derive:cf.optional()}).strict()).min(1).max(5)}).strict(),af=be({schemaVersion:Oe(1),records:_t(be({manifest:ga,files:ol(Xe().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Xe().max(Math.ceil(cn.maxMapBytes/3)*4))}).strict()).max(cn.maxPayloadRecords)}).strict();function no(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let o=Object.getOwnPropertyDescriptor(e,s);if(!("value"in o)||!o.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");no(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function en(e){no(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function zC(e){if(no(e),new TextEncoder().encode(JSON.stringify(e)).length>cn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=ga.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==jv[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let o=t.sources.find((a)=>a.id===r.sourceId);if(!o)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(en(r.procedural.spec)!==en(la(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(o.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(o.kind!=="external"||!o.originalFiles.some((a)=>a.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>cn.maxRecordBytes||i>cn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var to=Wv(_a),Kv=to.portableSamplerSchema.refine((e)=>{try{return en(e)===en(_l(e))}catch{return!1}}),kC=to.canonicalProceduralTextureSpecV3Schema.refine((e)=>{try{return en(e)===en(Jd(e))}catch{return!1}}),BC=to.canonicalTextureAtlasSpecV1Schema.refine((e)=>{try{return en(e)===en(pa(e))}catch{return!1}}),VC=to.textureAtlasManifestV1Schema,GC=be({resourceId:eo,revisionId:Pi,sha256:Pi}).strict().refine((e)=>e.sha256===e.revisionId,"Material pin hash must match revision"),HC=ni("kind",[be({kind:Oe("procedural"),compilerId:wt(["kiln.procedural-texture.v2",Js]),spec:qs([_a,kC]),recipeHash:Pi,pixelHash:Pi,encoder:be({name:Oe("sharp"),version:Ci}).strict(),derive:cf.optional()}).strict(),be({kind:Oe("atlas"),compilerId:wt(xl),spec:BC,manifest:VC,encoder:be({name:Oe("sharp"),version:Ci}).strict()}).strict().superRefine((e,t)=>{try{if(sf(e.manifest,e.spec),e.compilerId!==e.manifest.compilerId)throw Error("compiler id")}catch{t.addIssue({code:"custom",message:"Invalid stored atlas manifest"})}})]),Qv=ga.omit({schemaVersion:!0,maps:!0}).extend({schemaVersion:Oe(2),dependencies:_t(GC).max(16),maps:_t(ga.shape.maps.element.omit({procedural:!0}).extend({sampler:Kv,pixelHash:Pi,recipe:HC.optional()}).strict()).min(1).max(5)}).strict(),$C=ni("schemaVersion",[ga,Qv]),WC=af.extend({schemaVersion:Oe(2),records:_t(af.shape.records.element.extend({manifest:$C}).strict()).max(cn.maxPayloadRecords)}).strict(),eb=ni("schemaVersion",[af,WC]);function tb(e){return e.schemaVersion===1?[]:e.dependencies.map((t)=>({...t}))}var ZC=of.extend({schemaVersion:Oe(2),maps:_t(of.shape.maps.element.omit({procedural:!0}).extend({sampler:Kv,procedural:qs([_a,to.proceduralTextureSpecV3Schema.refine((e)=>{try{return Jd(e),!0}catch{return!1}})]).optional(),atlas:to.textureAtlasSpecV1Schema.refine((e)=>{try{return pa(e),!0}catch{return!1}}).optional()}).strict().refine((e)=>e.procedural!==void 0!==(e.atlas!==void 0),"Supply exactly one procedural or atlas recipe")).min(1).max(5)}).strict(),CO=qs([of,ZC]);function lf(e){if(no(e),new TextEncoder().encode(JSON.stringify(e)).length>cn.maxManifestBytes)throw Error("Material manifest exceeds size limit");if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Invalid material manifest");if(e.schemaVersion===1)return zC(e);let t=Qv.parse(e);if(new Set(t.sources.map((o)=>o.id)).size!==t.sources.length||new Set(t.maps.map((o)=>o.slot)).size!==t.maps.length)throw Error("Duplicate material source or slot");let n=0,i=0,r=new Map;for(let o of t.maps){let a=t.sources.find((l)=>l.id===o.sourceId);if(!a||o.file!==`${o.slot}.png`||o.usage!==jv[o.slot]||o.colorSpace!==(o.slot==="baseColor"||o.slot==="emissive"?"srgb":"linear")||o.slot==="normal"!==(o.normalConvention==="opengl")||o.slot==="metallicRoughness"!==(o.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map source/usage/convention mismatch");let c=o.recipe;if(c){if(a.kind!=="procedural"||o.originalFile)throw Error("Procedural/atlas map source convention mismatch");if(c.kind==="procedural"){let l=c.spec;if(l.schemaVersion===3){if(c.compilerId!==Js||c.derive||l.width!==o.width||l.height!==o.height)throw Error("V3 compiler/dimensions/derivation mismatch")}else if(c.compilerId!=="kiln.procedural-texture.v2"||l.size!==o.width||o.width!==o.height||en(l)!==en(la(l)))throw Error("V2 compiler/canonical recipe dimensions mismatch");if(l.usage!==o.usage||c.pixelHash!==o.pixelHash||c.derive&&o.slot!=="normal")throw Error("Procedural recipe pixel/usage mismatch")}else{if(sf(c.manifest,c.spec),c.spec.width!==o.width||c.spec.height!==o.height||c.spec.usage!==o.usage||en(c.spec.sampler)!==en(o.sampler)||c.manifest.decodedPixelHash!==o.pixelHash)throw Error("Atlas recipe map mismatch");for(let l of c.spec.regions)if(l.source.kind==="resource"){let u=l.source.pin;r.set(`${u.resourceId}/${u.revisionId}`,u)}}}else if(a.kind!=="external"||!a.originalFiles.some((l)=>l.name===o.originalFile))throw Error("External material source original file missing");n+=o.bytes,i+=o.width*o.height}let s=t.dependencies.map((o)=>`${o.resourceId}/${o.revisionId}`);if(new Set(s).size!==s.length||s.length!==r.size||s.some((o)=>!r.has(o)))throw Error("Material dependency pin inventory mismatch");if(n>cn.maxRecordBytes||i>cn.maxRecordPixels)throw Error("Material record exceeds byte/pixel budget");return structuredClone(t)}var yl=67108864,uf=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),XC=Xe().regex(/^sha256:[a-f0-9]{64}$/),hf=be({version:Oe("kiln.asset.v1"),assetId:uf,revisionId:uf,parentRevision:uf.optional(),name:Xe().min(1).max(200),tags:_t(Xe().max(80)).max(30),createdAt:Xe().datetime(),description:Xe().max(4000).optional(),brief:Xe().max(8000).optional(),attribution:be({model:Xe().max(200).optional(),harness:Xe().max(200).optional(),author:Xe().max(200).optional()}).optional(),editable:Kr(),files:ol(Xe(),be({sha256:XC,bytes:et().int().nonnegative().max(yl)})),build:be({engine:Xe(),options:ol(Xe(),Jr()),warnings:_t(Xe()),integration:Jr().optional(),qa:Jr().optional(),dependencies:_t(Jr()).optional(),rebuild:wt(["engine-required","external-dependencies-required"])}).optional(),preview:be({fidelity:Jr().optional(),error:Xe().optional(),backdrop:wt(lv).optional()}).optional()}),jC="materials.kiln.json",qC=25165824;function YC(e){let t=new Map;for(let n of e.manifest.build?.dependencies??[]){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Invalid saved asset dependency");let i=n;if(i.kind!=="kiln.material.v1"&&i.kind!=="kiln.material.v2"){if(i.delivery==="runtime")throw Error("Unsupported runtime dependency");if(i.delivery!=="embedded")throw Error("Unsupported saved asset dependency");continue}if(i.delivery!=="runtime")throw Error("Invalid saved material dependency");let r=lf(i.manifest);if(i.kind!==`kiln.material.v${r.schemaVersion}`)throw Error("Saved material dependency kind/version mismatch");let s=`${r.materialId}/${r.revisionId}`,o=t.get(s);if(o&&en(o)!==en(r))throw Error("Conflicting saved material dependency manifests");if(t.set(s,r),t.size>cn.maxPayloadRecords)throw Error("Saved asset material dependency count exceeds limit")}return[...t.values()]}function nb(e,t=!1){let n=YC(e),i=new Map(n.map((d)=>[`${d.materialId}/${d.revisionId}`,en(d)]));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}no(e.materialResources);let r=eb.parse(e.materialResources),s=0,o=0,a=new Map;for(let d of r.records){let h=lf(d.manifest),f=`${d.manifest.materialId}/${d.manifest.revisionId}`;if(a.has(f)||i.has(f)&&i.get(f)!==en(h))throw Error("Asset material closure mismatch");if(a.set(f,h),Object.keys(d.files).length!==d.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let m of d.manifest.maps){if(d.files[m.file]?.length!==Math.ceil(m.bytes/3)*4)throw Error("Asset material map size mismatch");s+=m.bytes,o+=m.width*m.height}}if(s>cn.maxPayloadBytes||o>cn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits");let c=new Set,l=new Set,u=(d)=>{if(l.has(d))throw Error("Asset material closure contains a cycle");if(c.has(d))return;let h=a.get(d);if(!h)throw Error("Asset material closure incomplete");l.add(d);for(let f of tb(h))u(`${f.resourceId}/${f.revisionId}`);l.delete(d),c.add(d)};for(let d of i.keys())u(d);if(c.size!==a.size)throw Error("Asset material closure has unrelated records")}var JC=new Set(["asset.glb","source.kiln.js","preview.png"]);function KC(e){let t=hf.parse(e.manifest),n=Object.keys(e.files);if(n.length!==Object.keys(t.files).length||!n.includes("asset.glb"))throw Error("Asset file inventory mismatch");let i=0;for(let r of n){if(!JC.has(r)||!t.files[r]||t.files[r].bytes!==e.files[r].length)throw Error("Invalid asset file inventory");i+=e.files[r].length}if(i>yl||t.editable!==n.includes("source.kiln.js"))throw Error("Invalid asset size or source inventory");if((e.files["source.kiln.js"]?.length??0)>1048576)throw Error("Source exceeds 1 MiB");df(e.files["asset.glb"]),nb(e)}function df(e){if(e.length<20||e.length>yl)throw Error("Invalid GLB size");let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.length||t.getUint32(16,!0)!==1313821514)throw Error("Invalid GLB header");let n=20+t.getUint32(12,!0);if(n>e.length)throw Error("Invalid GLB JSON length");let i=JSON.parse(new TextDecoder().decode(e.subarray(20,n)));for(let r of[...i.buffers??[],...i.images??[]])if(r.uri&&!String(r.uri).startsWith("data:"))throw Error("GLB must embed its resources")}function ib(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){KC(i),nb(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,o]of Object.entries(i.files))t[r+s]=o;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>qC)throw Error("Asset material payload exceeds byte limit");t[r+jC]=s}}for(let i of Object.values(t))n+=i.length;if(n>yl)throw Error("Bundle exceeds 64 MiB");return Tv(t,{level:0})}function Ii(e){let t=new Set,n=new Set,i=new Set;e.traverse((r)=>{let s=r;if(!s.isMesh)return;t.add(s.geometry);for(let o of Array.isArray(s.material)?s.material:[s.material]){n.add(o);for(let a of Object.values(o))if(a instanceof Nt)i.add(a)}});for(let r of[...t,...n,...i])r.dispose()}async function rb(e){df(e);let t=new No,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new Os(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new zh(t);i.register((s)=>({name:"KILN_embedded_images",async beforeRoot(){for(let o of s.json.images??[]){if(o.bufferView===void 0)continue;let a=new Uint8Array(await s.getDependency("bufferView",o.bufferView)),c="";for(let l=0;l<a.length;l+=8192)c+=String.fromCharCode(...a.subarray(l,l+8192));if(!/^image\/(png|jpeg|webp|avif)$/.test(o.mimeType??""))throw Error("Unsupported embedded image type");o.uri=`data:${o.mimeType};base64,${btoa(c)}`,delete o.bufferView}}}));let r=await i.parseAsync(Uint8Array.from(e).buffer,"");if(n){for(let s of r.scenes)Ii(s);throw Error("An embedded texture could not be decoded.")}return Object.assign(r,{assertTexturesLoaded(){if(n)throw Error("An embedded texture could not be decoded.")}})}function sb(e,t,n=40,i=[e]){let r=e.getCenter(new U),s=Math.max(e.getSize(new U).length()/2,0.01),o=new U(1,0.65,1.25).normalize(),a=new U().crossVectors(new U(0,1,0),o).normalize(),c=new U().crossVectors(o,a),l=[];for(let S of i.length?i:[e])for(let T of[S.min.x,S.max.x])for(let y of[S.min.y,S.max.y])for(let w of[S.min.z,S.max.z])l.push(new U(T,y,w));let u=1/0,d=-1/0,h=1/0,f=-1/0;for(let S of l){let T=S.clone().sub(r),y=T.dot(a),w=T.dot(c);u=Math.min(u,y),d=Math.max(d,y),h=Math.min(h,w),f=Math.max(f,w)}r.addScaledVector(a,(u+d)/2),r.addScaledVector(c,(h+f)/2);let m=Math.tan(n*Math.PI/360),_=m*t,p=s;for(let S of l){let T=S.clone().sub(r),y=T.dot(o);p=Math.max(p,y+Math.abs(T.dot(a))*1.12/_,y+Math.abs(T.dot(c))*1.12/m)}let g=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:g}}function ff(e,t){return{position:e.position.clone(),target:t.clone()}}function pf(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new U).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new U))+r*20,10),e.updateProjectionMatrix()}function ob(e,t,n){let i=e.getWorldDirection(new U);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new U(0,1,0)),s=new U;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function ab(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}function cb(e,t,n){if(t())return e;n(e);return}function vl(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,o)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(o)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((o)=>{let a=e.parser.associations.get(o)?.nodes;if(a===void 0||!i.has(a))return;o.visible=!1,r++});return r}function bl(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Gt().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Gt,i=new Gt,r=new U;return e.traverseVisible((s)=>{let o=s,a=o.geometry;if(!a)return;let c=a.getAttribute("position");if(c&&o.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(o.isMesh)o.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(a.boundingBox===null)a.computeBoundingBox();i.copy(a.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new Gt().setFromObject(e,!0):n}function xa(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function lb(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((m)=>!Number.isInteger(m)||!t[m]||n.has(m)))continue;let d=l.parent;while(d&&!i.has(d))d=d.parent;if(d)continue;let h=[l];for(let m of u)h.push(await e.parser.getDependency("node",m));vl(e,h.slice(1)),i.add(l);let f=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:f,levels:h})}if(r.length===0)return;let s=xa(e.scene)-r.reduce((c,l)=>c+mf(l,0),0),o=Math.max(...r.map((c)=>c.levels.length)),a=Array.from({length:o},(c,l)=>s+r.reduce((u,d)=>u+mf(d,l),0));return{chains:r,triangles:a}}var ub=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function mf(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return xa(ub(e,t))}function hb(e,t){let n=ub(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function db(e,t){for(let n of e.chains)hb(n,t)}function fb(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return hb(i,n),!0}function pb(e,t){if(!e)return;return{triangles:xa(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>mf(n,r))}))}}function io(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function mb(e){let t=new Ah({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=xo,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new Is,i=new Vt(40,1,0.01,1000),r=new Ch(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,o=!1,a=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(P)=>{if(!o||!c.has(P.code))return;P.preventDefault(),s.add(P.code)},u=(P)=>s.delete(P.code),d=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",d);let h=new Vo(t),f=new Ph,m=h.fromScene(f,0.04);n.environment=m.texture,f.dispose(),h.dispose();let _=new zs(16773591,2.4);_.position.set(4,8,5),n.add(_),n.add(new bc(14806490,5065021,1.7));let p,g,S,T=[],y=!0,w=performance.now(),A=0,R=0,x=!1,M,z,C,L=(P)=>{if(!C)return;clearTimeout(C.timeout),C.reject(Error(P)),C=void 0},K=(P)=>{let j=t.getContext(),k=j.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:P-C.started,frameMs:ab(C.samples),...z===void 0?{}:{loadToFirstFrameMs:z},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(j.getParameter(j.VERSION)),vendor:String(j.getParameter(j.VENDOR)),renderer:String(j.getParameter(j.RENDERER)),browser:navigator.userAgent,...k?{unmaskedVendor:String(j.getParameter(k.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(j.getParameter(k.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},I=()=>{if(!p)return;let P=bl(p),j=[];p.traverseVisible((ue)=>{if(ue instanceof Mt||ue instanceof pr||ue instanceof Ds){let Be=new Gt().setFromObject(ue,!0);if(!Be.isEmpty())j.push(Be)}});let{center:k,radius:q,distance:Q,position:Me}=sb(P,i.aspect,i.fov,j);if(r.target.copy(k),i.position.copy(Me),i.near=Math.max(q/1000,0.0001),i.far=Q+q*100,r.minDistance=q*0.1,r.maxDistance=q*80,a=Math.max(q*0.35,0.01),o)r.minDistance=q*0.00001;i.updateProjectionMatrix(),r.update()},G=new ResizeObserver(()=>{let{clientWidth:P,clientHeight:j}=e;if(!P||!j)return;t.setSize(P,j),i.aspect=P/j,i.updateProjectionMatrix()});G.observe(e);let X=(P)=>{if(x)return;let j=Math.min((P-w)/1000,0.1);if(w=P,e.clientWidth&&e.clientHeight){if(y)S?.update(j);if(o&&s.size){let k=ob(i,s,j*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(k),r.target.add(k)}if(r.update(),t.render(n,i),M!==void 0)z=performance.now()-M,M=void 0;if(C){if(C.previous>0&&C.samples.length<1800)C.samples.push(P-C.previous);if(C.previous=P,P-C.started>=C.duration&&C.samples.length){let k=K(P);clearTimeout(C.timeout),C.resolve(k),C=void 0}}}else s.clear(),L("Keep the measured viewport visible for the complete sampling window.");A=requestAnimationFrame(X)};return A=requestAnimationFrame(X),{async load(P,j={}){let k=performance.now(),q=++R;L("The artifact changed during measurement. Measure the new revision again.");let Q=await rb(P);vl(Q,[Q.scene]);let Me=await lb(Q);try{Q.assertTexturesLoaded()}catch(xe){Ii(Q.scene);for(let Ee of io(Me))Ii(Ee);throw xe}let ue=cb(Q,()=>!x&&q===R&&j.isCurrent?.()!==!1,(xe)=>{Ii(xe.scene);for(let Ee of io(Me))Ii(Ee)});if(!ue)return;let Be=p&&j.preserveView?ff(i,r.target):void 0;if(p){S?.stopAllAction(),S?.uncacheRoot(p),n.remove(p),Ii(p);for(let xe of io(g))Ii(xe)}p=ue.scene,g=Me,M=k,z=void 0,n.add(p),T=ue.animations,S=new Ec(p),y=!0;let{clientWidth:we,clientHeight:Z}=e;if(t.setSize(we,Z),i.aspect=we&&Z?we/Z:i.aspect,I(),Be)pf(i,r.target,Be,bl(p)),r.update();let re=0,se=new Set;return p.traverseVisible((xe)=>{let Ee=xe;if(!Ee.isMesh)return;re++;for(let Ae of Array.isArray(Ee.material)?Ee.material:[Ee.material])se.add(Ae)}),j.onCommit?.(),{triangles:xa(p),meshes:re,materials:se.size,clips:T.map((xe)=>xe.name),...g?{levels:g.triangles}:{}}},level(P){if(L("The level of detail changed. Measure the displayed combination again."),g)db(g,P)},partLevel(P,j){if(L("The level of detail changed. Measure the displayed combination again."),g)fb(g,P,j)},lod(){return p?pb(g,p):void 0},reset:I,cancelMeasurement:L,measure(P=3000){if(x||!p||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(P)||P<1000||P>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(C)return Promise.reject(Error("A measurement is already running."));return new Promise((j,k)=>{C={started:performance.now(),previous:0,duration:P,samples:[],resolve:j,reject:k,timeout:setTimeout(()=>L("Measurement was interrupted or the browser stopped delivering frames."),P+2000)}})},view(){return ff(i,r.target)},setView(P){if(!p)return;pf(i,r.target,P,bl(p)),r.update()},navigation(P){if(o=P==="explore",s.clear(),r.minDistance=o?0.00001:a/3.5,o)i.near=0.0001,i.updateProjectionMatrix()},wire(P){for(let j of p?[p,...io(g)]:[])j.traverse((k)=>{let q=k;if(q.isMesh){for(let Q of Array.isArray(q.material)?q.material:[q.material])if("wireframe"in Q)Q.wireframe=P}})},lighting(P){t.toneMappingExposure=P==="bright"?1.65:P==="soft"?0.85:1.15,_.intensity=P==="soft"?0.8:2.4},clip(P){if(S?.stopAllAction(),T[P])S?.clipAction(T[P]).play()},pause(P){y=!P},dispose(){if(L("The viewport closed before measurement finished."),x=!0,R++,cancelAnimationFrame(A),G.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",d),p)Ii(p);for(let P of io(g))Ii(P);m.dispose(),t.dispose(),e.replaceChildren()}}}var gb=["127.0.0.1","localhost","[::1]"];async function _b(e,t,n,i,r,s){let o="";for(let a=0;a<e.length;a+=8192)o+=String.fromCharCode(...e.subarray(a,a+8192));try{if((await i("ui/download-file",{contents:[{type:"resource",resource:{uri:`file:///${t}`,mimeType:n,blob:btoa(o)}}]}))?.isError)throw Error("The chat host could not download this file.");return{}}catch(a){if(a.code!==-32601)throw a;if(s){let d=new URL(s);if(d.protocol!=="https:"&&!(d.protocol==="http:"&&gb.includes(d.hostname)))throw Error("Invalid host download URL");return{downloadUrl:d.href}}if(!r)throw a;let c=new File([Uint8Array.from(e)],t,{type:n}),{fileId:l}=await r.uploadFile(c),{downloadUrl:u}=await r.getFileDownloadUrl({fileId:l});if(new URL(u).protocol!=="https:")throw Error("Invalid host download URL");return{downloadUrl:u}}}var yb=16777216,vb=Math.ceil(yb/3)*4,Yt=(e)=>{throw Error(`Asset transfer ${e}. Present the saved asset again or open it in Kiln; the saved files are unchanged.`)};function QC(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function xb(e){if(typeof e!=="string"||e.length>vb)return Yt("exceeds the encoded size limit");if(e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))Yt("contains damaged base64 data");let t;try{t=atob(e)}catch{return Yt("contains damaged base64 data")}let n=Uint8Array.from(t,(i)=>i.charCodeAt(0));if(QC(n)!==e)Yt("contains noncanonical base64 data");return n}function ya(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}async function bb(e){if(!ya(e))return Yt("metadata is missing");if(typeof e.error==="string")throw Error(e.error);let t=hf.safeParse(e.manifest);if(!t.success||!ya(e.files))return Yt("metadata is malformed");let n=t.data,i=Object.entries(e.files);if(!i.length||i.length>16||!Object.hasOwn(e.files,"asset.glb"))return Yt("file list is missing or invalid");let r=0,s=0;for(let[c,l]of i){if(!/^[a-z0-9][a-z0-9._-]{0,127}$/.test(c)||!Object.hasOwn(n.files,c))return Yt("file metadata is missing");if(r+=n.files[c].bytes,r>yb)return Yt("exceeds the decoded size limit");let u=typeof l==="string"?l:ya(l)?l.data:void 0;if(typeof u!=="string")return Yt("file encoding is malformed");if(s+=u.length,s>vb)return Yt("exceeds the encoded size limit")}let o={};for(let[c,l]of i){let u=n.files[c],d;if(typeof l==="string")d=xb(l);else{if(!ya(l)||l.encoding!=="kiln.deflate-base64.v1")return Yt("encoding is unsupported");let m=xb(l.data);try{d=Ev(m,{out:new Uint8Array(u.bytes+1)})}catch{return Yt("compressed data is damaged")}}if(d.length!==u.bytes)return Yt("byte count does not match the saved file");let h=await crypto.subtle.digest("SHA-256",Uint8Array.from(d));if(`sha256:${Array.from(new Uint8Array(h),(m)=>m.toString(16).padStart(2,"0")).join("")}`!==u.sha256)return Yt("integrity check failed");o[c]=d}for(let c of Object.keys(n.files))if(!Object.hasOwn(o,c))return Yt("is missing a saved file");let a={};if(e.downloadUrls!==void 0){if(!ya(e.downloadUrls))return Yt("download metadata is malformed");for(let[c,l]of Object.entries(e.downloadUrls)){if(typeof l!=="string")return Yt("download metadata is malformed");a[c]=l}}return{record:{manifest:n,files:o},downloadUrls:a}}function Sb(e){let t=e.attribution;if(!t)return[];return[t.model?{label:"Model",value:t.model}:null,t.harness?{label:"Harness",value:t.harness}:null,t.author?{label:"Author",value:t.author}:null].filter((n)=>n!==null)}var Dn=(e)=>document.getElementById(e),Li=Dn("status"),ln,wb={},ns,eP=0,Ni=0,Sl=new Map;function Eb(e,t){let n=++eP;return new Promise((i,r)=>{let s=setTimeout(()=>{Sl.delete(n),r(Error("Chat host did not respond."))},20000);Sl.set(n,{resolve(o){clearTimeout(s),i(o)},reject(o){clearTimeout(s),r(o)}}),window.parent.postMessage({jsonrpc:"2.0",id:n,method:e,params:t},"*")})}function Mb(e,t={}){window.parent.postMessage({jsonrpc:"2.0",method:e,params:t},"*")}function tP(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}async function nP(e){let t=++Ni;ln=void 0,Dn("stats").textContent="",Dn("clips").hidden=!0;for(let n of document.querySelectorAll("button[data-download]"))n.disabled=!0;try{if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Asset transfer metadata is missing. Present the saved asset again.");await iP(e,t)}catch(n){if(t!==Ni)return;Li.textContent=n instanceof Error?n.message:"Asset transfer failed. Present the saved asset again."}}async function iP(e,t){if(e.isError){Li.textContent=e.content?.find((i)=>i.type==="text")?.text??"This asset could not be opened.";return}let n;try{n=await bb(e._meta?.kilnAsset)}catch(i){if(t!==Ni)return;Li.textContent=i instanceof Error?i.message:"Asset transfer failed. Present the saved asset again.";return}if(t!==Ni)return;ln=n.record,Dn("name").textContent=ln.manifest.name,wb=n.downloadUrls,Dn("revision").textContent=`${ln.manifest.editable?"Editable source included":"GLB asset"} · ${ln.manifest.revisionId.slice(0,10)}`,Dn("attribution").textContent=Sb(ln.manifest).map(({label:i,value:r})=>`${i}: ${r}`).join(" · ");try{ns??=mb(Dn("stage"));let i=await ns.load(ln.files["asset.glb"]);if(t!==Ni)return;if(i){Dn("stats").textContent=`${i.triangles.toLocaleString()} triangles · ${i.materials} materials · ${(ln.files["asset.glb"].length/1024).toFixed(0)} KB`;let r=Dn("clips");r.replaceChildren(new Option("Rest pose","-1"),...i.clips.map((s,o)=>new Option(s,String(o)))),r.hidden=!i.clips.length}Li.textContent="Drag to orbit · Scroll to zoom"}catch(i){if(t!==Ni)return;ns?.dispose(),ns=void 0;let r=ln.files["preview.png"];if(r){let s=new Image;s.alt=`${ln.manifest.name} · saved preview image`,s.src=`data:image/png;base64,${tP(r)}`,Dn("stage").replaceChildren(s)}Li.textContent=`${r?"Showing saved preview. ":""}3D preview unavailable: ${String(i)}`}for(let i of document.querySelectorAll("button[data-download]"))i.disabled=!1;Dn("source").hidden=!ln.files["source.kiln.js"]}window.addEventListener("message",(e)=>{if(e.source!==window.parent||e.data?.jsonrpc!=="2.0")return;let t=e.data;if(t.id!==void 0&&!t.method){let n=Sl.get(t.id);if(Sl.delete(t.id),t.error)n?.reject(Object.assign(Error(t.error.message),{code:t.error.code}));else n?.resolve(t.result)}if(t.method==="ui/notifications/tool-result")nP(t.params);if(t.method==="ui/resource-teardown")ns?.dispose(),window.parent.postMessage({jsonrpc:"2.0",id:t.id,result:{}},"*")});Dn("reset").onclick=()=>ns?.reset();Dn("clips").onchange=(e)=>ns?.clip(Number(e.target.value));for(let e of document.querySelectorAll("button[data-download]"))e.onclick=async()=>{if(!ln)return;let t=Ni,n=e.dataset.download,i=n==="bundle"?"editable.zip":n==="source"?"source.kiln.js":"asset.glb",r=n==="bundle"?ib([ln]):ln.files[i],s=n==="bundle"?"application/zip":n==="source"?"text/javascript":"model/gltf-binary",o=ln.manifest.name.replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80);e.disabled=!0,Li.textContent="Requesting download…";try{let a=typeof window.openai?.uploadFile==="function"&&typeof window.openai?.getFileDownloadUrl==="function"?window.openai:void 0,c=await _b(r,`${o}-${i}`,s,Eb,a,wb[i]);if(t!==Ni)return;if(c.downloadUrl){let l=document.createElement("a");l.href=c.downloadUrl,l.textContent=`Save ${o}-${i}`,l.style.color="#d5f4a2",l.target="_blank",l.rel="noopener noreferrer",l.onclick=(u)=>{if(window.openai?.openExternal)u.preventDefault(),window.openai.openExternal({href:c.downloadUrl})},Li.replaceChildren("Download ready. ",l)}else Li.textContent="Download requested."}catch(a){if(t===Ni)Li.textContent=`Download unavailable in this host: ${a.message}`}finally{e.disabled=!ln||t!==Ni}};Eb("ui/initialize",{appInfo:{name:"Kiln Asset Viewer",version:"0.6.0"},appCapabilities:{},protocolVersion:"2026-01-26"}).then(()=>{Mb("ui/notifications/initialized"),Mb("ui/notifications/size-changed",{height:document.documentElement.scrollHeight})}).catch((e)=>{Li.textContent=e.message});+*/var Dt=Uint8Array,In=Uint16Array,jd=Int32Array,ll=new Dt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ul=new Dt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Hd=new Dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),yv=function(e,t){var n=new In(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new jd(n[30]);for(var i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return{b:n,r}},vv=yv(ll,2),{b:bv,r:$d}=vv;bv[28]=258,$d[258]=28;var Sv=yv(ul,0),{b:nC,r:fv}=Sv,Wd=new In(32768);for(Qe=0;Qe<32768;++Qe)wi=(Qe&43690)>>1|(Qe&21845)<<1,wi=(wi&52428)>>2|(wi&13107)<<2,wi=(wi&61680)>>4|(wi&3855)<<4,Wd[Qe]=((wi&65280)>>8|(wi&255)<<8)>>1;var wi,Qe,Ei=function(e,t,n){var i=e.length,r=0,s=new In(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new In(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new In(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],d=o[e[r]-1]++<<u;for(var h=d|(1<<u)-1;d<=h;++d)a[Wd[d]>>c]=l}}else{a=new In(i);for(r=0;r<i;++r)if(e[r])a[r]=Wd[o[e[r]-1]++]>>15-e[r]}return a},Er=new Dt(288);for(Qe=0;Qe<144;++Qe)Er[Qe]=8;var Qe;for(Qe=144;Qe<256;++Qe)Er[Qe]=9;var Qe;for(Qe=256;Qe<280;++Qe)Er[Qe]=7;var Qe;for(Qe=280;Qe<288;++Qe)Er[Qe]=8;var Qe,ca=new Dt(32);for(Qe=0;Qe<32;++Qe)ca[Qe]=5;var Qe,iC=Ei(Er,9,0),rC=Ei(Er,9,1),sC=Ei(ca,5,0),oC=Ei(ca,5,1),Bd=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},ii=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},Vd=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},qd=function(e){return(e+7)/8|0},Yd=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Dt(e.subarray(t,n))};var aC=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],$n=function(e,t,n){var i=Error(t||aC[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,$n);if(!n)throw i;return i},cC=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Dt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Dt(r*3);var l=function(Ae){var Et=n.length;if(Ae>Et){var Ge=new Dt(Math.max(Et*2,Ae));Ge.set(n),n=Ge}},u=t.f||0,d=t.p||0,h=t.b||0,{l:f,d:m,m:_,n:p}=t,g=r*8;do{if(!f){u=ii(e,d,1);var S=ii(e,d+1,3);if(d+=3,!S){var T=qd(d)+4,y=e[T-4]|e[T-3]<<8,w=T+y;if(w>r){if(c)$n(0);break}if(a)l(h+y);n.set(e.subarray(T,w),h),t.b=h+=y,t.p=d=w*8,t.f=u;continue}else if(S==1)f=rC,m=oC,_=9,p=5;else if(S==2){var A=ii(e,d,31)+257,R=ii(e,d+10,15)+4,x=A+ii(e,d+5,31)+1;d+=14;var M=new Dt(x),z=new Dt(19);for(var C=0;C<R;++C)z[Hd[C]]=ii(e,d+C*3,7);d+=R*3;var L=Bd(z),K=(1<<L)-1,I=Ei(z,L,1);for(var C=0;C<x;){var G=I[ii(e,d,K)];d+=G&15;var T=G>>4;if(T<16)M[C++]=T;else{var X=0,P=0;if(T==16)P=3+ii(e,d,3),d+=2,X=M[C-1];else if(T==17)P=3+ii(e,d,7),d+=3;else if(T==18)P=11+ii(e,d,127),d+=7;while(P--)M[C++]=X}}var j=M.subarray(0,A),k=M.subarray(A);_=Bd(j),p=Bd(k),f=Ei(j,_,1),m=Ei(k,p,1)}else $n(1);if(d>g){if(c)$n(0);break}}if(a)l(h+131072);var q=(1<<_)-1,Q=(1<<p)-1,Me=d;for(;;Me=d){var X=f[Vd(e,d)&q],ue=X>>4;if(d+=X&15,d>g){if(c)$n(0);break}if(!X)$n(2);if(ue<256)n[h++]=ue;else if(ue==256){Me=d,f=null;break}else{var Be=ue-254;if(ue>264){var C=ue-257,we=ll[C];Be=ii(e,d,(1<<we)-1)+bv[C],d+=we}var Z=m[Vd(e,d)&Q],re=Z>>4;if(!Z)$n(3);d+=Z&15;var k=nC[re];if(re>3){var we=ul[re];k+=Vd(e,d)&(1<<we)-1,d+=we}if(d>g){if(c)$n(0);break}if(a)l(h+131072);var se=h+Be;if(h<k){var xe=s-k,Ee=Math.min(k,se);if(xe+h<0)$n(3);for(;h<Ee;++h)n[h]=i[xe+h]}for(;h<se;++h)n[h]=n[h-k]}}if(t.l=f,t.p=Me,t.b=h,t.f=u,f)u=1,t.m=_,t.d=m,t.n=p}while(!u);return h!=n.length&&o?Yd(n,0,h):n.subarray(0,h)},Yi=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},oa=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},Gd=function(e,t){var n=[];for(var i=0;i<e.length;++i)if(e[i])n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return{t:wv,l:0};if(r==1){var o=new Dt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(w,A){return w.f-A.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,d=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(var i=1;i<r;++i)if(s[i].s>h)h=s[i].s;var f=new In(h+1),m=Zd(n[u-1],f,0);if(m>t){var i=0,_=0,p=m-t,g=1<<p;s.sort(function(A,R){return f[R.s]-f[A.s]||A.f-R.f});for(;i<r;++i){var S=s[i].s;if(f[S]>t)_+=g-(1<<m-f[S]),f[S]=t;else break}_>>=p;while(_>0){var T=s[i].s;if(f[T]<t)_-=1<<t-f[T]++-1;else++i}for(;i>=0&&_;--i){var y=s[i].s;if(f[y]==t)--f[y],++_}m=t}return{t:new Dt(f),l:m}},Zd=function(e,t,n){return e.s==-1?Math.max(Zd(e.l,t,n+1),Zd(e.r,t,n+1)):t[e.s]=n},pv=function(e){var t=e.length;while(t&&!e[--t]);var n=new In(++t),i=0,r=e[0],s=1,o=function(c){n[i++]=c};for(var a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);if(s>2)o(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){o(r),--s;for(;s>6;s-=6)o(8304);if(s>2)o(s-3<<5|8208),s=0}while(s--)o(r);s=1,r=e[a]}return{c:n.subarray(0,i),n:t}},aa=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},Mv=function(e,t,n){var i=n.length,r=qd(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var s=0;s<i;++s)e[r+s+4]=n[s];return(r+4+i)*8},mv=function(e,t,n,i,r,s,o,a,c,l,u){Yi(t,u++,n),++r[256];var d=Gd(r,15),{t:h,l:f}=d,m=Gd(s,15),{t:_,l:p}=m,g=pv(h),{c:S,n:T}=g,y=pv(_),{c:w,n:A}=y,R=new In(19);for(var x=0;x<S.length;++x)++R[S[x]&31];for(var x=0;x<w.length;++x)++R[w[x]&31];var M=Gd(R,7),{t:z,l:C}=M,L=19;for(;L>4&&!z[Hd[L-1]];--L);var K=l+5<<3,I=aa(r,Er)+aa(s,ca)+o,G=aa(r,h)+aa(s,_)+o+14+3*L+aa(R,z)+2*R[16]+3*R[17]+7*R[18];if(c>=0&&K<=I&&K<=G)return Mv(t,u,e.subarray(c,c+l));var X,P,j,k;if(Yi(t,u,1+(G<I)),u+=2,G<I){X=Ei(h,f,0),P=h,j=Ei(_,p,0),k=_;var q=Ei(z,C,0);Yi(t,u,T-257),Yi(t,u+5,A-1),Yi(t,u+10,L-4),u+=14;for(var x=0;x<L;++x)Yi(t,u+3*x,z[Hd[x]]);u+=3*L;var Q=[S,w];for(var Me=0;Me<2;++Me){var ue=Q[Me];for(var x=0;x<ue.length;++x){var Be=ue[x]&31;if(Yi(t,u,q[Be]),u+=z[Be],Be>15)Yi(t,u,ue[x]>>5&127),u+=ue[x]>>12}}}else X=iC,P=Er,j=sC,k=ca;for(var x=0;x<a;++x){var we=i[x];if(we>255){var Be=we>>18&31;if(oa(t,u,X[Be+257]),u+=P[Be+257],Be>7)Yi(t,u,we>>23&31),u+=ll[Be];var Z=we&31;if(oa(t,u,j[Z]),u+=k[Z],Z>3)oa(t,u,we>>5&8191),u+=ul[Z]}else oa(t,u,X[we]),u+=P[we]}return oa(t,u,X[256]),u+P[256]},lC=new jd([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),wv=new Dt(0),uC=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Dt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var d=lC[t-1],h=d>>13,f=d&8191,m=(1<<n)-1,_=s.p||new In(32768),p=s.h||new In(m+1),g=Math.ceil(n/3),S=2*g,T=function(Ye){return(e[Ye]^e[Ye+1]<<g^e[Ye+2]<<S)&m},y=new jd(25000),w=new In(288),A=new In(32),R=0,x=0,M=s.i||0,z=0,C=s.w||0,L=0;for(;M+2<o;++M){var K=T(M),I=M&32767,G=p[K];if(_[I]=G,p[K]=I,C<=M){var X=o-M;if((R>7000||z>24576)&&(X>423||!l)){u=mv(e,c,0,y,w,A,x,z,L,M-L,u),z=R=x=0,L=M;for(var P=0;P<286;++P)w[P]=0;for(var P=0;P<30;++P)A[P]=0}var j=2,k=0,q=f,Q=I-G&32767;if(X>2&&K==T(M-Q)){var Me=Math.min(h,X)-1,ue=Math.min(32767,M),Be=Math.min(258,X);while(Q<=ue&&--q&&I!=G){if(e[M+j]==e[M+j-Q]){var we=0;for(;we<Be&&e[M+we]==e[M+we-Q];++we);if(we>j){if(j=we,k=Q,we>Me)break;var Z=Math.min(Q,we-2),re=0;for(var P=0;P<Z;++P){var se=M-Q+P&32767,xe=_[se],Ee=se-xe&32767;if(Ee>re)re=Ee,G=se}}}I=G,G=_[I],Q+=I-G&32767}}if(k){y[z++]=268435456|$d[j]<<18|fv[k];var Ae=$d[j]&31,Et=fv[k]&31;x+=ll[Ae]+ul[Et],++w[257+Ae],++A[Et],C=M+j,++R}else y[z++]=e[M],++w[e[M]]}}for(M=Math.max(M,C);M<o;++M)y[z++]=e[M],++w[e[M]];if(u=mv(e,c,l,y,w,A,x,z,L,M-L,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=_,s.i=M,s.w=C}else{for(var M=s.w||0;M<o+l;M+=65535){var Ge=M+65535;if(Ge>=o)c[u/8|0]=l,Ge=o;u=Mv(c,u+1,e.subarray(M,Ge))}s.i=o}return Yd(a,0,i+qd(u)+r)},hC=function(){var e=new Int32Array(256);for(var t=0;t<256;++t){var n=t,i=9;while(--i)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),dC=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=hC[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var fC=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Dt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return uC(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},Ev=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var Qt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Av(e,t){return fC(e,t||{},0,0)}function Tv(e,t){return cC(e,{i:2},t&&t.out,t&&t.dictionary)}var Rv=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=Ev(i,s[1]),s=s[0];if(s instanceof Dt)n[o]=[s,a];else n[o+="/"]=[new Dt(0),a],Rv(s,o,n,i)}},gv=typeof TextEncoder<"u"&&new TextEncoder,pC=typeof TextDecoder<"u"&&new TextDecoder,mC=0;try{pC.decode(wv,{stream:!0}),mC=1}catch(e){}function _v(e,t){if(t){var n=new Dt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(gv)return gv.encode(e);var r=e.length,s=new Dt(e.length+(e.length>>1)),o=0,a=function(u){s[o++]=u};for(var i=0;i<r;++i){if(o+5>s.length){var c=new Dt(o+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)a(l);else if(l<2048)a(192|l>>6),a(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63);else a(224|l>>12),a(128|l>>6&63),a(128|l&63)}return Yd(s,0,o)}var Xd=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)$n(9);t+=i+4}return t},xv=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,d=Xd(l);if(Qt(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var h=new Date(n.mtime==null?Date.now():n.mtime),f=h.getFullYear()-1980;if(f<0||f>119)$n(10);if(Qt(e,t,f<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,s!=-1)Qt(e,t,n.crc),Qt(e,t+4,s<0?-s-2:s),Qt(e,t+8,n.size);if(Qt(e,t+12,c),Qt(e,t+14,d),t+=16,o!=null)Qt(e,t,u),Qt(e,t+6,n.attrs),Qt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,d)for(var m in l){var _=l[m],p=_.length;Qt(e,t,+m),Qt(e,t+2,p),e.set(_,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},gC=function(e,t,n,i,r){Qt(e,t,101010256),Qt(e,t+8,n),Qt(e,t+10,n),Qt(e,t+12,i),Qt(e,t+16,r)};function Cv(e,t){if(!t)t={};var n={},i=[];Rv(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,d=_v(o),h=d.length,f=l.comment,m=f&&_v(f),_=m&&m.length,p=Xd(l.extra);if(h>65535)$n(11);var g=u?Av(c,l):c,S=g.length,T=dC();T.p(c),i.push(Ev(l,{size:c.length,crc:T.d(),c:g,f:d,m,u:h!=o.length||m&&f.length!=_,o:r,compression:u})),r+=30+h+p+S,s+=76+2*(h+p)+(_||0)+S}var y=new Dt(s+22),w=r,A=s-r;for(var R=0;R<i.length;++R){var d=i[R];xv(y,d.o,d,d.f,d.u,d.c.length);var x=30+d.f.length+Xd(d.extra);y.set(d.c,d.o+x),xv(y,r,d,d.f,d.u,d.c.length,d.o,d.m),r+=16+x+(d.m?d.m.length:0)}return gC(y,r,i.length,A,w),y}var Ai=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function _C(e){if(e==="PORTABLE_MATERIAL_V3_CONTRACT")return'compilePortableMaterialSpecV3 requires schemaVersion 3, model pbrMetallicRoughness, typed V3 procedural or injected resource references, and complete minFilter/magFilter/wrapS/wrapT samplers. Match texture usage to its slot and split work exceeding the material budget. Resource bindings need a host with verified-byte admission. V2 remains available unchanged. Shader code, paths, raw textures and V3 height derivation are unsupported. Read kiln_discover ids ["compilePortableMaterialSpecV3"] for the exact contract.';if(e==="TEXTURE_ATLAS_CONTRACT")return'textureAtlas requires bounded named integer content rectangles with nonoverlapping gutter allocations, matching source crops and usage, and explicit portable sampling. Sources are V3 recipes or exact host-injected library map pins. Split atlases exceeding aggregate work or allocation budgets. remapUVToAtlas requires finite unit UV0, a named content region, inputOrigin and mapping mode; it preserves topology and does not unwrap or tile a region. Read kiln_discover ids ["textureAtlas", "remapUVToAtlas"] for the exact contracts.';if(e==="PROCEDURAL_TEXTURE_V3_CONTRACT")return'proceduralTexture schemaVersion 3 requires bounded JSON: width/height 4..1024, byte RGBA, integer pixel shapes and at most 64 operations. Palette/dither supports only albedo/emissive; seeded stamps accept every usage. Work includes polygon edges and periodic copies. Read kiln_discover ids ["proceduralTexture"] for the V3 contract; keep schemaVersion 2 for existing opaque patterns.';if(e==="BONE_CHAIN_ARGUMENT")return'createBoneChain requires 1..1024 valid local joint descriptors with unique roles and animation-safe names across the parent hierarchy. Use normalized perpendicular forward/bend axes and finite rest transforms; an explicit parentRole must match the declared parent. Read the retained source and kiln_discover ids ["createBoneChain"] for the exact contract.';if(e==="SKIN_BINDING_ARGUMENT")return'createSkinnedPart requires four valid bone indices and finite nonnegative weights per vertex, summing to one unless normalizeWeights:true is explicit. Zero sums are rejected. Assemble distinct named Bones and the parent in one rest-pose hierarchy before binding. Use unbound geometry within the documented budgets and finite invertible transforms. Read the retained source and kiln_discover ids ["createSkinnedPart"] for the exact contract; the Three exporter is required for skin delivery.';if(e==="EXPORT_MATERIAL_SIDE_UNSUPPORTED")return"EXPORT_MATERIAL_SIDE_UNSUPPORTED: A used material has BackSide, which glTF cannot encode directly. Author inward-facing triangles with FrontSide, or choose DoubleSide when both faces are intended. Neither adds missing geometry. Read the retained program with kiln_source query BackSide to locate the material; source names and exception text do not cross the evaluator boundary.";if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="DELIVERY_CONTRACT")return'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].';if(e==="REQUIRE_SOLID")return'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="PROCEDURAL_TEXTURE_USAGE")return'proceduralTexture usage is one of albedo (the default), emissive, normal, roughness, metalness, metallicRoughness or occlusion; there is no data or height usage. Match it to the slot it fills: portable material baseColor takes albedo, normal takes normal, metallicRoughness takes metallicRoughness (G roughness, B metalness), emissive takes emissive and occlusion takes occlusion; pbrMaterial albedo, normal, roughness, metalness, metallicRoughness, emissive and aoMap take the matching usage. Call kiln_discover with ids ["proceduralTexture"].';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}class la extends Error{diagnostic;constructor(e,t=_C(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var hl=1024,dl=4,fl=8,Kd=6,Pv=80,es=256;class rt extends la{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var Iv=["solid","checker","stripes","gradient","bricks","noise"],Lv=["normal","multiply","screen","overlay"],xC=new Set(["__proto__","prototype","constructor"]);function pl(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new rt(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new rt(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new rt(`${t} must not contain symbol keys.`);if(xC.has(i))throw new rt(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new rt(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new rt(`${t}.${i} must be a plain JSON data field.`)}return e}function yC(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new rt(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new rt(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new rt(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new rt(`${t} must be a dense JSON array (missing index ${n}).`);return e}function Ar(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new rt(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function ri(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new rt(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function Qr(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new rt(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function Dv(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new rt(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function Jd(e,t,n){return Dv(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function vC(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>Pv||n)throw new rt(`${t} must be 1..${Pv} visible characters.`);return e}function bC(e,t,n){if(e===void 0)return n;if(!Ai.includes(e))throw new rt(`${t} must be one of ${Ai.join(", ")}, got ${JSON.stringify(e)}.`,"PROCEDURAL_TEXTURE_USAGE");return e}function Nv(e,t){let i=(Dv(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function SC(e,t){let n=e.blend??"normal";if(!Lv.includes(n))throw new rt(`${t}.blend ${JSON.stringify(n)} is not one of ${Lv.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function MC(e,t){let n=`proceduralTexture.layers[${t}]`,i=pl(e,n),r=i.op;if(!Iv.includes(r))throw new rt(`${n}.op ${JSON.stringify(r)} is not one of ${Iv.join(", ")}.`);let s=SC(i,n),o=Jd(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return Ar(i,["op","color","blend","opacity"],n),{op:r,color:ri(i.color,`${n}.color`),...a};case"checker":return Ar(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:ri(i.colorA,`${n}.colorA`),colorB:ri(i.colorB,`${n}.colorB`),squares:Qr(i.squares,`${n}.squares`,8,1,es),...a};case"stripes":return Ar(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:ri(i.colorA,`${n}.colorA`),colorB:ri(i.colorB,`${n}.colorB`),count:Qr(i.count,`${n}.count`,8,1,es),angleDeg:Nv(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return Ar(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:ri(i.from,`${n}.from`),to:ri(i.to,`${n}.to`),angleDeg:Nv(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return Ar(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:ri(i.brick,`${n}.brick`),mortar:ri(i.mortar,`${n}.mortar`),rows:Qr(i.rows,`${n}.rows`,8,1,es),cols:Qr(i.cols,`${n}.cols`,4,1,es),mortarWidth:Jd(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:Jd(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return Ar(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:ri(i.colorA,`${n}.colorA`),colorB:ri(i.colorB,`${n}.colorB`),scale:Qr(i.scale,`${n}.scale`,8,1,es),octaves:Qr(i.octaves,`${n}.octaves`,3,1,Kd),seed:Qr(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new rt(`${n}.op is unsupported.`)}}function wC(e){let t=pl(e,"proceduralTexture");if(Ar(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new rt(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function ua(e){let t=pl(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?pl(wC(t),"proceduralTexture"):t;if(Ar(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new rt(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<dl||i>hl||(i&i-1)!==0)throw new rt(`proceduralTexture.size must be a power of two between ${dl} and ${hl}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new rt("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=yC(r,"proceduralTexture.layers");if(s.length>fl)throw new rt(`proceduralTexture: ${s.length} layers exceeds the maximum of ${fl}.`);let o=vC(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:bC(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(MC)}}var EC=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ti=(e,t)=>e>>>t|e<<32-t;function Ys(e){let t=new TextEncoder().encode(e),n=t.length*8,i=Math.ceil((t.length+9)/64)*64,r=new Uint8Array(i);r.set(t),r[t.length]=128;let s=new DataView(r.buffer);s.setUint32(i-8,Math.floor(n/4294967296),!1),s.setUint32(i-4,n>>>0,!1);let o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);for(let c=0;c<r.length;c+=64){for(let S=0;S<16;S++)a[S]=s.getUint32(c+S*4,!1);for(let S=16;S<64;S++){let T=a[S-15],y=a[S-2],w=Ti(T,7)^Ti(T,18)^T>>>3,A=Ti(y,17)^Ti(y,19)^y>>>10;a[S]=a[S-16]+w+a[S-7]+A>>>0}let[l,u,d,h,f,m,_,p]=o;for(let S=0;S<64;S++){let T=Ti(f,6)^Ti(f,11)^Ti(f,25),y=f&m^~f&_,w=p+T+y+EC[S]+a[S]>>>0,A=Ti(l,2)^Ti(l,13)^Ti(l,22),R=l&u^l&d^u&d,x=A+R>>>0;p=_,_=m,m=f,f=h+w>>>0,h=d,d=u,u=l,l=w+x>>>0}let g=[l,u,d,h,f,m,_,p];for(let S=0;S<8;S++)o[S]=o[S]+g[S]>>>0}return[...o].map((c)=>c.toString(16).padStart(8,"0")).join("")}var Js="kiln.procedural-rgba.v3.1";var da=1024,AC=1048576,fa=64,gl=64,ha=256,_l=32,Ov=64000000,TC=67108864;function nt(e,t="PROCEDURAL_TEXTURE_V3_CONTRACT"){throw new rt(`proceduralTexture V3: ${e}`,t)}var RC=new Set(["__proto__","prototype","constructor"]);function CC(e){let t=0,n=(i,r,s)=>{if(++t>16384||s>10)nt(`${r} exceeds the JSON size/depth budget.`);if(i===null||typeof i==="boolean")return;if(typeof i==="string"){if(i.length>4096)nt(`${r} string is too long.`);return}if(typeof i==="number"){if(!Number.isFinite(i))nt(`${r} must be finite.`);return}if(typeof i!=="object")nt(`${r} must contain only JSON data.`);let o=Array.isArray(i),a=Object.getPrototypeOf(i);if(o?a!==Array.prototype:a!==Object.prototype&&a!==null)nt(`${r} must be a plain JSON ${o?"array":"object"}.`);let c=o?Object.getOwnPropertyDescriptor(i,"length")?.value:void 0;if(o&&(typeof c!=="number"||c>1024))nt(`${r} array is too long.`);let l=Reflect.ownKeys(i);if(l.length>1024)nt(`${r} has too many fields.`);let u=Object.getOwnPropertyDescriptors(i);for(let d of l){if(typeof d!=="string"||RC.has(d))nt(`${r} has a forbidden key.`);if(o&&d==="length")continue;let h=u[d];if(!h.enumerable||!("value"in h))nt(`${r}.${d} must be an enumerable JSON data field, never an accessor.`);if(o&&(!/^(0|[1-9][0-9]*)$/.test(d)||Number(d)>=c))nt(`${r} has an invalid array key.`)}if(o&&l.length!==c+1)nt(`${r} must be a dense JSON array.`);for(let d of l)if(d!=="length"||!o)n(u[d].value,`${r}.${String(d)}`,s+1)};n(e,"recipe",0)}function Wn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))nt(`${n} must be a JSON object.`);let i=e;for(let r of Object.keys(i))if(!t.includes(r))nt(`${n} has unknown field ${r}.`);return i}function fn(e,t,n,i,r){if(e===void 0&&r!==void 0)return r;if(typeof e!=="number"||!Number.isInteger(e)||e<t||e>n)nt(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function Uv(e,t){if(e===void 0)return!1;if(typeof e!=="boolean")nt(`${t} must be boolean.`);return e}function ml(e,t,n,i,r){if(!Array.isArray(e)||e.length!==t)nt(`${n} must be a ${t}-element array.`);return e.map((s,o)=>fn(s,i,r,`${n}[${o}]`))}function Fv(e,t){let n=ml(e,4,t,0,255);return n[3]===0?[0,0,0,0]:n}function zv(e,t,n){let i=Wn(e,["x","y","width","height",...n?["kind"]:[]],t);return{x:fn(i.x,-4096,4096,`${t}.x`),y:fn(i.y,-4096,4096,`${t}.y`),width:fn(i.width,1,2048,`${t}.width`),height:fn(i.height,1,2048,`${t}.height`)}}function PC(e,t){let n=Wn(e,["kind","x","y","width","height","from","to","points"],t);if(n.kind==="rectangle"||n.kind==="ellipse")return{kind:n.kind,...zv(n,t,n.kind)};if(n.kind==="polygon"){Wn(n,["kind","points"],t);let i=n.points;if(!Array.isArray(i)||i.length<3||i.length>gl)nt(`${t}.points requires 3..${gl} vertices.`);return{kind:"polygon",points:i.map((r,s)=>ml(r,2,`${t}.points[${s}]`,-4096,4096))}}if(n.kind==="line")return Wn(n,["kind","from","to","width"],t),{kind:"line",from:ml(n.from,2,`${t}.from`,-4096,4096),to:ml(n.to,2,`${t}.to`,-4096,4096),width:fn(n.width,1,2048,`${t}.width`)};return nt(`${t}.kind must be rectangle, ellipse, polygon or line.`)}function kv(e){if(e.kind==="rectangle"||e.kind==="ellipse")return[e.x,e.y,e.x+e.width,e.y+e.height];let t=e.kind==="polygon"?e.points:[e.from,e.to],n=e.kind==="line"?e.width/2:0;return[Math.min(...t.map((i)=>i[0]))-n,Math.min(...t.map((i)=>i[1]))-n,Math.max(...t.map((i)=>i[0]))+n,Math.max(...t.map((i)=>i[1]))+n]}function IC(e){return e.kind==="polygon"?e.points.length+1:e.kind==="line"?4:e.kind==="ellipse"?3:1}function LC(e,t,n,i=0,r=0){let[s,o,a,c]=kv(e);return[Math.max(0,Math.ceil(s+i-0.5)),Math.max(0,Math.ceil(o+r-0.5)),Math.min(t,Math.floor(a+i-0.5)+1),Math.min(n,Math.floor(c+r-0.5)+1)]}function xl(e){CC(e);let t=Wn(e,["schemaVersion","width","height","usage","name","background","operations","palette"],"recipe");if(t.schemaVersion!==3)nt("schemaVersion must be 3.");let n=fn(t.width,4,da,"width"),i=fn(t.height,4,da,"height"),r=n*i;if(r>AC)nt("output texel budget exceeded.");let s=t.usage===void 0?"albedo":t.usage;if(!Ai.includes(s))nt("usage must be a known texture usage.","PROCEDURAL_TEXTURE_USAGE");let o=s==="albedo"||s==="emissive",a=t.name;if(a!==void 0&&(typeof a!=="string"||!a.length||a.length>80||[...a].some((p)=>p.charCodeAt(0)<32||p.charCodeAt(0)===127)))nt("name must be 1..80 visible characters.");let c=t.operations;if(!Array.isArray(c)||c.length>fa)nt(`operations must be an array with at most ${fa} entries.`);let l=r,u=0,d=0,h=c.map((p,g)=>{let S=`operations[${g}]`,T=Wn(p,["op","shape","rgba","opacity","alpha","invert","spec","count","seed","area","periodic"],S);if(T.op==="legacy-v2"){Wn(T,["op","spec","alpha","opacity"],S);let j=Wn(T.spec,["schemaVersion","size","usage","name","layers"],`${S}.spec`);if(j.schemaVersion!==2)nt(`${S}.spec requires explicit schemaVersion 2.`);let k=ua(j);if(k.size!==n||k.size!==i||k.usage!==s)nt(`${S} legacy-v2 dimensions and usage must match the V3 surface.`);return l+=r*(1+k.layers.reduce((q,Q)=>q+(Q.op==="noise"?Q.octaves*16:4),0)),d+=r*4,{op:"legacy-v2",spec:k,alpha:fn(T.alpha,0,255,`${S}.alpha`,255),opacity:fn(T.opacity,0,255,`${S}.opacity`,255)}}let y=PC(T.shape,`${S}.shape`),w=IC(y),[A,R,x,M]=LC(y,n,i),z=Math.max(0,x-A)*Math.max(0,M-R);if(T.op==="mask")return Wn(T,["op","shape","alpha","invert"],S),l+=r+z*w,{op:"mask",shape:y,alpha:fn(T.alpha,0,255,`${S}.alpha`,255),invert:Uv(T.invert,`${S}.invert`)};if(T.op!=="paint"&&T.op!=="stamps")return nt(`${S}.op must be paint, mask, stamps or legacy-v2.`);let C={shape:y,rgba:Fv(T.rgba,`${S}.rgba`),opacity:fn(T.opacity,0,255,`${S}.opacity`,255)};if(T.op==="paint")return Wn(T,["op","shape","rgba","opacity"],S),l+=z*(w+1),{op:"paint",...C};Wn(T,["op","shape","rgba","opacity","count","seed","area","periodic"],S);let L=fn(T.count,1,ha,`${S}.count`),K=Uv(T.periodic,`${S}.periodic`),[I,G,X,P]=kv(y);if(K&&(X-I>n||P-G>i))nt(`${S} periodic shape bounds must fit one surface period.`);if(u+=L*(K?9:1),u>ha)nt(`expanded stamps budget exceeds ${ha}.`);return l+=L*(K?9:1)*Math.min(n,Math.ceil(X-I)+1)*Math.min(i,Math.ceil(P-G)+1)*(w+1),{op:"stamps",...C,count:L,seed:fn(T.seed,0,4294967295,`${S}.seed`),area:zv(T.area,`${S}.area`),periodic:K}}),f;if(t.palette!==void 0){if(!o)nt("palette and dither are supported only for color usages albedo and emissive.");let p=Wn(t.palette,["colors","dither"],"palette"),g=p.colors;if(!Array.isArray(g)||g.length<1||g.length>_l)nt(`palette.colors requires 1..${_l} entries.`);let S=p.dither===void 0?"none":p.dither;if(S!=="none"&&S!=="bayer4")nt("palette.dither must be none or bayer4.");f={colors:g.map((T,y)=>fn(T,0,16777215,`palette.colors[${y}]`)),dither:S},l+=r*(g.length+1)}if(l>Ov)nt(`estimated work budget ${l} exceeds ${Ov}.`);if(r*4+d>TC)nt("transient allocation budget exceeded.");let m={schemaVersion:3,width:n,height:i,usage:s,...a!==void 0?{name:a}:{},background:t.background===void 0?[0,0,0,0]:Fv(t.background,"background"),operations:h,...f?{palette:f}:{}},_=JSON.stringify(m);if(_.length>262144)nt("canonical JSON byte budget exceeded.");return{spec:m,canonicalJson:_,estimatedWorkUnits:l,conservativePixelAllocationBytes:r*4+d}}function Qd(e){return xl(e).spec}function NC(e){return xl(e).canonicalJson}function ef(e){return`sha256:${Ys(`${Js}+${NC(e)}`)}`}var tf=["nearest","linear","nearest-mipmap-nearest","linear-mipmap-nearest","nearest-mipmap-linear","linear-mipmap-linear"],nf=["nearest","linear"],pa=["repeat","clamp-to-edge","mirrored-repeat"];function yl(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new rt("portableSampler requires a complete JSON object.");let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new rt("portableSampler must be plain JSON data.");for(let r of Reflect.ownKeys(e)){let s=Object.getOwnPropertyDescriptor(e,r);if(typeof r!=="string"||!s.enumerable||!("value"in s))throw new rt("portableSampler requires enumerable JSON data fields, never accessors.")}let n=e,i={minFilter:tf,magFilter:nf,wrapS:pa,wrapT:pa};if(Object.keys(n).some((r)=>!Object.hasOwn(i,r)))throw new rt("portableSampler contains an unsupported field.");for(let[r,s]of Object.entries(i))if(!s.includes(n[r]))throw new rt(`portableSampler.${r} requires one of ${s.join(", ")}.`);return{minFilter:n.minFilter,magFilter:n.magFilter,wrapS:n.wrapS,wrapT:n.wrapT}}var Gv="kiln.texture-atlas.v1.1",Hv="kiln.texture-atlas.v1.2",vl=Object.freeze([Gv,Hv]),ts=Object.freeze({edge:1024,outputTexels:1048576,regions:64,sources:16,sourceTexels:4194304,encodedSourceBytes:8388608,encodedBytes:16777216,jsonBytes:262144,work:64000000,allocatedBytes:67108864,uvVertices:262144,uvAttributeBytes:134217728}),Ji=Object.freeze({...ts,edge:2048,outputTexels:4194304,regions:128,sources:32,work:192000000,allocatedBytes:134217728}),sf=Object.freeze([1024,2048]);function $v(e){return e.pack===void 0?Gv:Hv}function DC(e){return e.pack===void 0?ts:Ji}class Wv extends la{constructor(e){super("TEXTURE_ATLAS_CONTRACT",`textureAtlas: ${e}`);this.name="TextureAtlasError"}}function Ne(e){throw new Wv(e)}function of(e){let t=0,n=0,i=new TextEncoder,r=(o)=>{if(n+=o,n>ts.jsonBytes)Ne("JSON byte budget exceeded.")},s=(o,a)=>{if(++t>65536||a>16)Ne("JSON node/depth budget exceeded.");if(o===null||typeof o==="boolean"){r(o===!1?5:4);return}if(typeof o==="number"){if(!Number.isFinite(o))Ne("JSON numbers must be finite.");r(JSON.stringify(o).length);return}if(typeof o==="string"){if(o.length>4096)Ne("JSON string budget exceeded.");r(i.encode(JSON.stringify(o)).length);return}if(typeof o!=="object")Ne("plain JSON data is required.");let c=Array.isArray(o),l=Object.getPrototypeOf(o);if(c?l!==Array.prototype:l!==null&&l!==Object.prototype)Ne("plain JSON prototypes are required.");let u=c?Object.getOwnPropertyDescriptor(o,"length")?.value:void 0;if(c&&(!Number.isSafeInteger(u)||u>1024))Ne("JSON array budget exceeded.");let d=Reflect.ownKeys(o);if(d.length>1024||c&&d.length!==u+1)Ne("dense bounded JSON fields are required.");r(2+Math.max(0,d.length-(c?1:0)-1));for(let h of d){if(c&&h==="length")continue;if(typeof h!=="string"||["__proto__","prototype","constructor"].includes(h))Ne("forbidden JSON field.");if(h.length>4096)Ne("JSON field name budget exceeded.");if(!c)r(i.encode(JSON.stringify(h)).length+1);let f=Object.getOwnPropertyDescriptor(o,h);if(!f.enumerable||!("value"in f))Ne("JSON accessors/hidden fields are unsupported.");if(c&&(!/^(0|[1-9][0-9]*)$/.test(h)||Number(h)>=u))Ne("invalid JSON array key.");s(f.value,a+1)}};s(e,0)}function pn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))Ne(`${n} must be a JSON object.`);let i=e;if(Object.keys(i).some((r)=>!t.includes(r)))Ne(`${n} has an unknown field.`);return i}function Ln(e,t,n,i){if(typeof e!=="number"||!Number.isSafeInteger(e)||e<t||e>n)Ne(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function Tr(e,t){if(typeof e!=="string"||!/^sha256:[a-f0-9]{64}$/.test(e))Ne(`${t} must be an exact SHA-256 hash.`);return e}function Bv(e,t){let n=pn(e,["x","y","width","height"],t);return{x:Ln(n.x,0,4096,`${t}.x`),y:Ln(n.y,0,4096,`${t}.y`),width:Ln(n.width,1,4096,`${t}.width`),height:Ln(n.height,1,4096,`${t}.height`)}}function Ks(e){let{content:t,gutter:n}=e;return{x:t.x-n,y:t.y-n,width:t.width+2*n,height:t.height+2*n}}function Zv(e,t,n,i){if(e.x+e.width>n||e.y+e.height>i)Ne("source crop is out of bounds.");if(e.width!==t.width||e.height!==t.height)Ne("source crop/content dimensions must match; resampling is unsupported.")}function rf(e){return e.kind==="procedural"?`procedural:${ef(e.spec)}`:`resource:${e.pin.resourceId}:${e.pin.revisionId}:${e.resourceId}`}var OC=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,Vv=(e,t)=>t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height;function UC(e,t,n,i){let r=[{x:0,y:0,width:e,height:t}],s=(a)=>{let c=[];for(let l of r){if(!OC(l,a)){c.push(l);continue}if(a.x>l.x)c.push({x:l.x,y:l.y,width:a.x-l.x,height:l.height});if(a.x+a.width<l.x+l.width)c.push({x:a.x+a.width,y:l.y,width:l.x+l.width-a.x-a.width,height:l.height});if(a.y>l.y)c.push({x:l.x,y:l.y,width:l.width,height:a.y-l.y});if(a.y+a.height<l.y+l.height)c.push({x:l.x,y:a.y+a.height,width:l.width,height:l.y+l.height-a.y-a.height})}if(r=c.filter((l,u)=>!c.some((d,h)=>h!==u&&Vv(d,l)&&(!Vv(l,d)||h<u))),r.length>16384)Ne("pack: free-space bookkeeping budget exceeded.")};for(let a of n)s(a);let o=[...i].sort((a,c)=>c.width*c.height-a.width*a.height||(a.region.name<c.region.name?-1:a.region.name>c.region.name?1:0));for(let a of o){let c,l;for(let u of r){if(u.width<a.width||u.height<a.height)continue;let d=u.width-a.width,h=u.height-a.height,f=[Math.min(d,h),Math.max(d,h),u.y,u.x];if(!l||f[0]<l[0]||f[0]===l[0]&&(f[1]<l[1]||f[1]===l[1]&&(f[2]<l[2]||f[2]===l[2]&&f[3]<l[3])))c=u,l=f}if(!c)Ne(`pack: region ${a.region.name} (${a.width}x${a.height} texels with its gutter) does not fit in the ${e}x${t} atlas beside the regions already placed.`);a.region.content={x:c.x+a.region.gutter,y:c.y+a.region.gutter,width:a.region.content.width,height:a.region.content.height},s({x:c.x,y:c.y,width:a.width,height:a.height})}}function ma(e){of(e);let t=pn(e,["schemaVersion","width","height","usage","sampler","regions","pack"],"atlas");if(t.schemaVersion!==1)Ne("schemaVersion must be 1.");let n;if(t.pack!==void 0){let h=pn(t.pack,["edge","gutter","algorithm"],"pack");if(!sf.includes(h.edge))Ne("pack.edge must be 1024 or 2048.");if(h.algorithm!==void 0&&h.algorithm!=="maxrects")Ne("pack.algorithm must be 'maxrects'.");n={edge:h.edge,gutter:h.gutter===void 0?2:Ln(h.gutter,0,32,"pack.gutter"),algorithm:"maxrects"}}let i=n?Ji:ts,r=n?n.edge:i.edge,s=n&&t.width===void 0?n.edge:Ln(t.width,4,r,"width"),o=n&&t.height===void 0?n.edge:Ln(t.height,4,r,"height");if(s*o>i.outputTexels)Ne("output texel budget exceeded.");if(!Ai.includes(t.usage))Ne("usage must be a texture usage.");let a=t.usage;if(!Array.isArray(t.regions)||!t.regions.length||t.regions.length>i.regions)Ne(`regions must contain 1..${i.regions} entries.`);let c=[],l=t.regions.map((h,f)=>{let m=pn(h,["name","content","gutter","edgeMode","source","crop","packed"],`regions[${f}]`);if(typeof m.name!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(m.name))Ne("region name must be a stable lowercase identifier.");let _=m.content!==void 0;if(!_&&!n)Ne(`region ${m.name}: content is required unless the atlas sets pack.`);if(m.packed!==void 0&&(m.packed!==!0||!n||!_))Ne("packed is the resolved-placement marker: true, with content, in an atlas that sets pack.");let p=_?Bv(m.content,"content"):void 0,g=m.gutter===void 0?n?.gutter??2:Ln(m.gutter,0,32,"gutter"),S=m.edgeMode===void 0?"copy-edge":m.edgeMode;if(!["copy-edge","mask-rgb-dilate"].includes(S))Ne("unsupported edgeMode.");if(S==="mask-rgb-dilate"&&a!=="albedo"&&a!=="emissive")Ne("mask RGB dilation requires color usage.");let T=pn(m.source,["kind","spec","resourceId","pin","expected"],"source"),y,w=m.crop===void 0?void 0:Bv(m.crop,"crop");if(T.kind==="procedural"){pn(T,["kind","spec"],"procedural source");let R=xl(T.spec);if(R.spec.usage!==a)Ne("source usage does not match atlas usage.");y={kind:"procedural",spec:R.spec},w??={x:0,y:0,width:R.spec.width,height:R.spec.height},p??={x:0,y:0,width:w.width,height:w.height},Zv(w,p,R.spec.width,R.spec.height)}else if(T.kind==="resource"){if(pn(T,["kind","resourceId","pin","expected"],"resource source"),typeof T.resourceId!=="string"||!/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/.test(T.resourceId))Ne("source resourceId must be an exact returned map ID.");let R=pn(T.pin,["resourceId","revisionId","sha256"],"source pin");if(typeof R.resourceId!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(R.resourceId))Ne("pin resourceId must be a material ID.");let x=Tr(R.revisionId,"pin revisionId"),M=Tr(R.sha256,"pin sha256");if(x!==M)Ne("source pin revision/hash mismatch.");let z;if(T.expected!==void 0){let C=pn(T.expected,["width","height","imageSha256","decodedPixelHash"],"source expected");z={...C.width===void 0?{}:{width:Ln(C.width,1,4096,"expected.width")},...C.height===void 0?{}:{height:Ln(C.height,1,4096,"expected.height")},...C.imageSha256===void 0?{}:{imageSha256:Tr(C.imageSha256,"expected.imageSha256")},...C.decodedPixelHash===void 0?{}:{decodedPixelHash:Tr(C.decodedPixelHash,"expected.decodedPixelHash")}}}if(y={kind:"resource",resourceId:T.resourceId,pin:{resourceId:R.resourceId,revisionId:x,sha256:M},...z?{expected:z}:{}},!p){let C=w??(z?.width!==void 0&&z.height!==void 0?{width:z.width,height:z.height}:Ne(`region ${m.name}: a packed resource region needs a crop or expected width and height (its size).`));p={x:0,y:0,width:C.width,height:C.height}}if(w&&(w.width!==p.width||w.height!==p.height))Ne("source crop/content dimensions must match; resampling is unsupported.")}else Ne("source kind must be procedural or pinned resource.");let A={name:m.name,content:p,gutter:g,edgeMode:S,source:y,...w?{crop:w}:{},...n&&(!_||m.packed===!0)?{packed:!0}:{}};if(!_)c.push({region:A,width:A.content.width+2*g,height:A.content.height+2*g});return A}).sort((h,f)=>h.name<f.name?-1:h.name>f.name?1:0);if(new Set(l.map((h)=>h.name)).size!==l.length)Ne("duplicate region name.");if(c.length){let h=new Set(c.map((f)=>f.region));UC(s,o,l.filter((f)=>!h.has(f)).map((f)=>Ks(f)),c)}for(let h of l){let f=Ks(h);if(f.x<0||f.y<0||f.x+f.width>s||f.y+f.height>o)Ne("padded allocation is out of bounds.")}for(let h=0;h<l.length;h++)for(let f=h+1;f<l.length;f++){let m=Ks(l[h]),_=Ks(l[f]);if(m.x<_.x+_.width&&_.x<m.x+m.width&&m.y<_.y+_.height&&_.y<m.y+m.height)Ne(`padded allocations overlap: ${l[h].name}, ${l[f].name}.`)}if(new Set(l.map((h)=>rf(h.source))).size>i.sources)Ne(`distinct source budget exceeds ${i.sources}.`);let u;try{u=yl(t.sampler===void 0?{minFilter:"linear-mipmap-linear",magFilter:"linear",wrapS:"clamp-to-edge",wrapT:"clamp-to-edge"}:t.sampler)}catch(h){Ne(`sampler: ${h.message}`)}let d={schemaVersion:1,width:s,height:o,usage:a,sampler:u,regions:l,...n?{pack:n}:{}};if(new TextEncoder().encode(JSON.stringify(d)).length>ts.jsonBytes)Ne("canonical JSON byte budget exceeded.");return d}function FC(e){let t=ma(e);return`sha256:${Ys(`${$v(t)}+${JSON.stringify(t)}`)}`}function Ri(e){of(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function zC(e){return`sha256:${Ys(`kiln.atlas-layout.v1+${Ri({width:e.width,height:e.height,origin:"top-left",regions:e.regions.map((t)=>({name:t.name,content:t.content,allocation:Ks(t)}))})}`)}`}function af(e,t){of(e);let n=ma(t),i=pn(e,["version","compilerId","width","height","usage","origin","sampler","specHash","layoutHash","decodedPixelHash","atlasPixelHash","sources","regions","manifestHash"],"manifest");if(i.version!=="kiln.atlas-manifest.v1"||i.compilerId!==$v(n)||i.width!==n.width||i.height!==n.height||i.usage!==n.usage||i.origin!=="top-left")Ne("manifest version/compiler/dimensions/usage/origin mismatch.");if(Ri(i.sampler)!==Ri(n.sampler)||i.specHash!==FC(n)||i.layoutHash!==zC(n))Ne("manifest sampler/spec/layout identity mismatch.");Tr(i.decodedPixelHash,"manifest decodedPixelHash"),Tr(i.atlasPixelHash,"manifest atlasPixelHash");let r=new Map(n.regions.map((c)=>[rf(c.source),c.source]));if(!Array.isArray(i.sources)||i.sources.length!==r.size||!Array.isArray(i.regions)||i.regions.length!==n.regions.length)Ne("manifest source/region inventory mismatch.");let s=new Map;for(let c of i.sources){let l=pn(c,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId","descriptor"],"manifest source");if(typeof l.id!=="string"||s.has(l.id))Ne("duplicate/invalid manifest source identity.");let u=r.get(l.id);if(!u||l.kind!==u.kind)Ne("manifest source identity mismatch.");let d=Ln(l.width,1,4096,"manifest source width"),h=Ln(l.height,1,4096,"manifest source height");if(Tr(l.decodedPixelHash,"manifest source decodedPixelHash"),u.kind==="procedural"){if(pn(l,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId"],"manifest procedural source"),d!==u.spec.width||h!==u.spec.height||l.recipeHash!==ef(u.spec)||l.compilerId!=="kiln.procedural-rgba.v3.1")Ne("manifest procedural source identity mismatch.")}else{pn(l,["id","kind","width","height","decodedPixelHash","descriptor"],"manifest resource source");let f=pn(l.descriptor,["materialId","revisionId","resourceId","slot","usage","colorSpace","width","height","encodedByteLength","imageSha256","decodedPixelHash"],"manifest source descriptor"),m={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};if(f.materialId!==u.pin.resourceId||f.revisionId!==u.pin.revisionId||f.resourceId!==u.resourceId||f.width!==d||f.height!==h||f.usage!==n.usage||typeof f.slot!=="string"||m[f.slot]!==n.usage||f.colorSpace!==(n.usage==="albedo"||n.usage==="emissive"?"srgb":"linear"))Ne("manifest pinned resource descriptor mismatch.");if(Tr(f.imageSha256,"manifest source imageSha256"),Ln(f.encodedByteLength,1,DC(n).encodedSourceBytes,"manifest encodedByteLength"),f.decodedPixelHash!==void 0&&f.decodedPixelHash!==l.decodedPixelHash)Ne("manifest source decodedPixelHash mismatch.");for(let _ of["width","height","imageSha256","decodedPixelHash"]){let p=u.expected?.[_];if(p!==void 0&&p!==(_==="decodedPixelHash"?l[_]:f[_]))Ne("manifest source expectation mismatch.")}}s.set(l.id,{width:d,height:h})}for(let c=0;c<n.regions.length;c++){let l=n.regions[c],u=pn(i.regions[c],["name","content","allocation","crop","sourceId"],"manifest region"),d=rf(l.source),h=s.get(d),f=l.crop??{x:0,y:0,width:h.width,height:h.height};if(Zv(f,l.content,h.width,h.height),u.name!==l.name||u.sourceId!==d||Ri(u.content)!==Ri(l.content)||Ri(u.allocation)!==Ri(Ks(l))||Ri(u.crop)!==Ri(f))Ne("manifest named region/crop/allocation identity mismatch.")}let{manifestHash:o,...a}=i;if(o!==`sha256:${Ys(`kiln.atlas-manifest.v1+${Ri(a)}`)}`)Ne("manifest hash mismatch.");return structuredClone(e)}var kC=(()=>{let e=et().int().min(0).max(16777215),t=et().int().min(1).max(es),n=et().min(-36000).max(36000),i=et().min(0).max(1),r={blend:wt(["normal","multiply","screen","overlay"]),opacity:i};return be({schemaVersion:Oe(2),size:et().int().min(dl).max(hl),usage:wt(Ai),name:Xe().min(1).max(80).optional(),layers:_t(ni("op",[be({op:Oe("solid"),color:e,...r}).strict(),be({op:Oe("checker"),colorA:e,colorB:e,squares:t,...r}).strict(),be({op:Oe("stripes"),colorA:e,colorB:e,count:t,angleDeg:n,...r}).strict(),be({op:Oe("gradient"),from:e,to:e,angleDeg:n,...r}).strict(),be({op:Oe("bricks"),brick:e,mortar:e,rows:t,cols:t,mortarWidth:i,stagger:i,...r}).strict(),be({op:Oe("noise"),colorA:e,colorB:e,scale:t,octaves:et().int().min(1).max(Kd),seed:et().int().min(-2147483648).max(2147483647),...r}).strict()])).min(1).max(fl)}).strict()})();function Xv(e,t=kC){let n=(q,Q)=>et().int().min(q).max(Q),i=n(0,255),r=n(-4096,4096),s=cv([r,r]),o=cv([i,i,i,i]),a=wt(Ai),c=KR(["sha256:",Xe().regex(/^[a-f0-9]{64}$/)]),l=Xe().min(1).max(80),u=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),d=Xe().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),h={width:n(1,4096),height:n(1,4096)},f=be({x:r,y:r,width:n(1,2048),height:n(1,2048)}).strict(),m=be({x:n(0,4096),y:n(0,4096),...h}).strict(),_=ni("kind",[f.extend({kind:Oe("rectangle")}).strict(),f.extend({kind:Oe("ellipse")}).strict(),be({kind:Oe("polygon"),points:_t(s).min(3).max(gl)}).strict(),be({kind:Oe("line"),from:s,to:s,width:n(1,2048)}).strict()]),p=be({op:Oe("paint"),shape:_,rgba:o,opacity:i}).strict(),g=be({op:Oe("mask"),shape:_,alpha:i,invert:Kr()}).strict(),S=be({op:Oe("stamps"),shape:_,rgba:o,opacity:i,count:n(1,ha),seed:n(0,4294967295),area:f,periodic:Kr()}).strict(),T=be({op:Oe("legacy-v2"),spec:e,alpha:i,opacity:i}).strict(),y=be({colors:_t(n(0,16777215)).min(1).max(_l),dither:wt(["none","bayer4"])}).strict(),w={schemaVersion:Oe(3),width:n(4,da),height:n(4,da),usage:a,name:l.optional(),background:o},A=be({...w,operations:_t(ni("op",[p,g,S,T.extend({spec:t})])).max(fa),palette:y.optional()}).strict(),R=be({...w,usage:a.optional(),background:o.optional(),operations:_t(ni("op",[p.partial({opacity:!0}),g.partial({alpha:!0,invert:!0}),S.partial({opacity:!0,periodic:!0}),T.partial({alpha:!0,opacity:!0})])).max(fa),palette:y.partial({dither:!0}).optional()}).strict(),x=be({minFilter:wt(tf),magFilter:wt(nf),wrapS:wt(pa),wrapT:wt(pa)}).strict(),M=be({resourceId:u,revisionId:c,sha256:c}).strict(),z=be({kind:Oe("resource"),resourceId:d,pin:M,expected:be({...h,imageSha256:c,decodedPixelHash:c}).partial().strict().optional()}).strict(),C=be({name:u,content:m,gutter:n(0,32),edgeMode:wt(["copy-edge","mask-rgb-dilate"]),source:ni("kind",[be({kind:Oe("procedural"),spec:A}).strict(),z]),crop:m.optional(),packed:Oe(!0).optional()}).strict(),L={schemaVersion:Oe(1),width:n(4,Ji.edge),height:n(4,Ji.edge),usage:a,sampler:x},K=qs(sf.map((q)=>Oe(q))),I=be({...L,regions:_t(C).min(1).max(Ji.regions),pack:be({edge:K,gutter:n(0,32),algorithm:Oe("maxrects")}).strict().optional()}).strict(),G=be({...L,width:L.width.optional(),height:L.height.optional(),pack:be({edge:K,gutter:n(0,32).optional(),algorithm:Oe("maxrects").optional()}).strict().optional(),sampler:x.optional(),regions:_t(C.extend({source:ni("kind",[be({kind:Oe("procedural"),spec:R}).strict(),z])}).partial({content:!0,gutter:!0,edgeMode:!0})).min(1).max(Ji.regions)}).strict(),X=be({materialId:u,revisionId:c,resourceId:d,slot:wt(["baseColor","normal","metallicRoughness","emissive","occlusion"]),usage:a,colorSpace:wt(["srgb","linear"]),...h,encodedByteLength:n(1,ts.encodedSourceBytes),imageSha256:c,decodedPixelHash:c.optional()}).strict(),P={id:Xe().min(1).max(1024),...h,decodedPixelHash:c},j=ni("kind",[be({...P,kind:Oe("procedural"),recipeHash:c,compilerId:Oe(Js)}).strict(),be({...P,kind:Oe("resource"),descriptor:X}).strict()]),k=be({version:Oe("kiln.atlas-manifest.v1"),compilerId:wt(vl),width:L.width,height:L.height,usage:a,origin:Oe("top-left"),sampler:x,specHash:c,layoutHash:c,decodedPixelHash:c,atlasPixelHash:c,sources:_t(j).min(1).max(Ji.sources),regions:_t(be({name:u,content:m,allocation:m,crop:m,sourceId:Xe().min(1).max(1024)}).strict()).min(1).max(Ji.regions),manifestHash:c}).strict();return{portableSamplerSchema:x,proceduralTextureSpecV3Schema:R,canonicalProceduralTextureSpecV3Schema:A,textureAtlasSpecV1Schema:G,canonicalTextureAtlasSpecV1Schema:I,textureAtlasManifestV1Schema:k,materialMapPinSchema:M,verifiedPinnedMaterialMapDescriptorSchema:X}}var an=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),qv=["baseColor","normal","metallicRoughness","emissive","occlusion"],Yv={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var eo=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),Pi=Xe().regex(/^sha256:[a-f0-9]{64}$/),Ci=Xe().min(1).max(1000),jv=Xe().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),Jv=be({id:eo,kind:wt(["external","procedural"]),provider:Ci,creator:Ci,assetId:Ci.optional(),assetUrl:jv.optional(),accessedAt:Xe().datetime().optional(),license:be({spdx:Ci,url:jv,attribution:Xe().max(4000)}).strict(),originalFiles:_t(be({name:Xe().min(1).max(200),sha256:Pi,bytes:et().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),Kv=be({operation:Ci,tool:Ci,version:Ci,parameters:cl(Xe().max(100),qs([Xe().max(2000),et().finite(),Kr()])).optional()}).strict(),si=et().int().min(0).max(16777215),ga=et().int().min(1).max(256),Qs={blend:wt(["normal","multiply","screen","overlay"]).default("normal"),opacity:et().min(0).max(1).default(1)},ya=be({schemaVersion:Oe(2),size:et().int().min(4).max(1024).default(256),usage:wt(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Xe().min(1).max(80).optional(),layers:_t(ni("op",[be({op:Oe("solid"),color:si,...Qs}).strict(),be({op:Oe("checker"),colorA:si,colorB:si,squares:ga.default(8),...Qs}).strict(),be({op:Oe("stripes"),colorA:si,colorB:si,count:ga.default(8),angleDeg:et().min(-36000).max(36000).default(0),...Qs}).strict(),be({op:Oe("gradient"),from:si,to:si,angleDeg:et().min(-36000).max(36000).default(0),...Qs}).strict(),be({op:Oe("bricks"),brick:si,mortar:si,rows:ga.default(8),cols:ga.default(4),mortarWidth:et().min(0).max(1).default(0.06),stagger:et().min(0).max(1).default(0.5),...Qs}).strict(),be({op:Oe("noise"),colorA:si,colorB:si,scale:ga.default(8),octaves:et().int().min(1).max(6).default(3),seed:et().int().min(-2147483648).max(2147483647).default(0),...Qs}).strict()])).min(1).max(8)}).strict(),uf=be({kind:Oe("normal-from-height"),strength:et().finite().positive().max(64)}).strict(),BC=be({compiler:Oe("kiln.procedural-texture.v2"),spec:ya,derive:uf.optional(),recipeHash:Pi,pixelHash:Pi,encoder:be({name:Oe("sharp"),version:Ci}).strict()}).strict(),Qv=be({baseColor:et().int().min(0).max(16777215).optional(),roughness:et().min(0).max(1).default(1),metalness:et().min(0).max(1).default(0),emissive:et().int().min(0).max(16777215).optional(),emissiveIntensity:et().min(0).max(64).default(1),alphaMode:wt(["opaque","mask","blend"]).default("opaque"),alphaCutoff:et().min(0).max(1).default(0.5),doubleSided:Kr().default(!1)}).strict(),_a=be({schemaVersion:Oe(1),materialId:eo,revisionId:Pi,name:Xe().min(1).max(200),tags:_t(Xe().min(1).max(80)).max(30),tileable:Kr(),physicalSizeMeters:be({width:et().finite().positive().max(1e5),height:et().finite().positive().max(1e5)}).strict().optional(),parameters:Qv,sources:_t(Jv).min(1).max(20),maps:_t(be({slot:wt(qv),file:wt(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:Pi,bytes:et().int().positive().max(an.maxMapBytes),width:et().int().positive().max(an.maxMapEdge),height:et().int().positive().max(an.maxMapEdge),usage:wt(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:wt(["srgb","linear"]),normalConvention:Oe("opengl").optional(),channelPacking:Oe("r-occlusion-g-roughness-b-metallic").optional(),sourceId:eo,originalFile:Xe().min(1).max(200).optional(),transforms:_t(Kv).max(30),procedural:BC.optional()}).strict()).min(1).max(5)}).strict(),cf=be({materialId:eo,name:Xe().min(1).max(200),tags:_t(Xe().min(1).max(80)).max(30).optional(),tileable:Kr(),physicalSizeMeters:be({width:et().finite().positive().max(1e5),height:et().finite().positive().max(1e5)}).strict().optional(),parameters:Qv.partial().optional(),sources:_t(Jv).min(1).max(20),maps:_t(be({slot:wt(qv),sourceId:eo,transforms:_t(Kv).max(30),normalConvention:Oe("opengl").optional(),channelPacking:Oe("r-occlusion-g-roughness-b-metallic").optional(),procedural:ya,derive:uf.optional()}).strict()).min(1).max(5)}).strict(),lf=be({schemaVersion:Oe(1),records:_t(be({manifest:_a,files:cl(Xe().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Xe().max(Math.ceil(an.maxMapBytes/3)*4))}).strict()).max(an.maxPayloadRecords)}).strict();function io(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let o=Object.getOwnPropertyDescriptor(e,s);if(!("value"in o)||!o.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");io(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Nn(e){io(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function VC(e){if(io(e),new TextEncoder().encode(JSON.stringify(e)).length>an.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=_a.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==Yv[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let o=t.sources.find((a)=>a.id===r.sourceId);if(!o)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(Nn(r.procedural.spec)!==Nn(ua(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(o.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(o.kind!=="external"||!o.originalFiles.some((a)=>a.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>an.maxRecordBytes||i>an.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var to=Xv(ya),no={when:(e)=>!e.issues.length},eb=(e)=>e instanceof Error?e.message:String(e);function xa(e,t,n){return(i,r)=>{try{let s=t(i);if(n&&Nn(i)!==Nn(s))r.addIssue({code:"custom",message:`${e} must be stored in canonical form.`})}catch(s){r.addIssue({code:"custom",message:eb(s)})}}}var tb=to.portableSamplerSchema.superRefine(xa("sampler",yl,!0),no),GC=to.canonicalProceduralTextureSpecV3Schema.superRefine(xa("procedural V3 spec",Qd,!0),no),HC=to.canonicalTextureAtlasSpecV1Schema.superRefine(xa("atlas spec",ma,!0),no),$C=to.textureAtlasManifestV1Schema,WC=be({resourceId:eo,revisionId:Pi,sha256:Pi}).strict().refine((e)=>e.sha256===e.revisionId,"Material pin hash must match revision"),ZC=ni("kind",[be({kind:Oe("procedural"),compilerId:wt(["kiln.procedural-texture.v2",Js]),spec:qs([ya,GC]),recipeHash:Pi,pixelHash:Pi,encoder:be({name:Oe("sharp"),version:Ci}).strict(),derive:uf.optional()}).strict(),be({kind:Oe("atlas"),compilerId:wt(vl),spec:HC,manifest:$C,encoder:be({name:Oe("sharp"),version:Ci}).strict()}).strict().superRefine((e,t)=>{try{if(af(e.manifest,e.spec),e.compilerId!==e.manifest.compilerId)throw Error(`recipe compilerId ${e.compilerId} does not match the manifest's ${e.manifest.compilerId}.`)}catch(n){t.addIssue({code:"custom",message:`stored atlas manifest: ${eb(n)}`})}},no)]),nb=_a.omit({schemaVersion:!0,maps:!0}).extend({schemaVersion:Oe(2),dependencies:_t(WC).max(16),maps:_t(_a.shape.maps.element.omit({procedural:!0}).extend({sampler:tb,pixelHash:Pi,recipe:ZC.optional()}).strict()).min(1).max(5)}).strict(),XC=ni("schemaVersion",[_a,nb]),jC=lf.extend({schemaVersion:Oe(2),records:_t(lf.shape.records.element.extend({manifest:XC}).strict()).max(an.maxPayloadRecords)}).strict(),ib=ni("schemaVersion",[lf,jC]);function rb(e){return e.schemaVersion===1?[]:e.dependencies.map((t)=>({...t}))}var qC=cf.extend({schemaVersion:Oe(2),maps:_t(cf.shape.maps.element.omit({procedural:!0}).extend({sampler:tb,procedural:qs([ya,to.proceduralTextureSpecV3Schema.superRefine(xa("procedural V3 spec",Qd,!1),no)]).optional(),atlas:to.textureAtlasSpecV1Schema.superRefine(xa("atlas spec",ma,!1),no).optional()}).strict().refine((e)=>e.procedural!==void 0!==(e.atlas!==void 0),"Supply exactly one procedural or atlas recipe")).min(1).max(5)}).strict(),LO=qs([cf,qC]);function hf(e){if(io(e),new TextEncoder().encode(JSON.stringify(e)).length>an.maxManifestBytes)throw Error("Material manifest exceeds size limit");if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Invalid material manifest");if(e.schemaVersion===1)return VC(e);let t=nb.parse(e);if(new Set(t.sources.map((o)=>o.id)).size!==t.sources.length||new Set(t.maps.map((o)=>o.slot)).size!==t.maps.length)throw Error("Duplicate material source or slot");let n=0,i=0,r=new Map;for(let o of t.maps){let a=t.sources.find((l)=>l.id===o.sourceId);if(!a||o.file!==`${o.slot}.png`||o.usage!==Yv[o.slot]||o.colorSpace!==(o.slot==="baseColor"||o.slot==="emissive"?"srgb":"linear")||o.slot==="normal"!==(o.normalConvention==="opengl")||o.slot==="metallicRoughness"!==(o.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map source/usage/convention mismatch");let c=o.recipe;if(c){if(a.kind!=="procedural"||o.originalFile)throw Error("Procedural/atlas map source convention mismatch");if(c.kind==="procedural"){let l=c.spec;if(l.schemaVersion===3){if(c.compilerId!==Js||l.width!==o.width||l.height!==o.height)throw Error("V3 compiler/dimensions mismatch")}else if(c.compilerId!=="kiln.procedural-texture.v2"||l.size!==o.width||o.width!==o.height||Nn(l)!==Nn(ua(l)))throw Error("V2 compiler/canonical recipe dimensions mismatch");if(l.usage!==o.usage||c.pixelHash!==o.pixelHash||c.derive&&o.slot!=="normal")throw Error("Procedural recipe pixel/usage mismatch")}else{if(af(c.manifest,c.spec),c.spec.width!==o.width||c.spec.height!==o.height||c.spec.usage!==o.usage||Nn(c.spec.sampler)!==Nn(o.sampler)||c.manifest.decodedPixelHash!==o.pixelHash)throw Error("Atlas recipe map mismatch");for(let l of c.spec.regions)if(l.source.kind==="resource"){let u=l.source.pin;r.set(`${u.resourceId}/${u.revisionId}`,u)}}}else if(a.kind!=="external"||!a.originalFiles.some((l)=>l.name===o.originalFile))throw Error("External material source original file missing");n+=o.bytes,i+=o.width*o.height}let s=t.dependencies.map((o)=>`${o.resourceId}/${o.revisionId}`);if(new Set(s).size!==s.length||s.length!==r.size||s.some((o)=>!r.has(o)))throw Error("Material dependency pin inventory mismatch");if(n>an.maxRecordBytes||i>an.maxRecordPixels)throw Error("Material record exceeds byte/pixel budget");return structuredClone(t)}var bl=67108864,df=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),YC=Xe().regex(/^sha256:[a-f0-9]{64}$/),ff=be({version:Oe("kiln.asset.v1"),assetId:df,revisionId:df,parentRevision:df.optional(),name:Xe().min(1).max(200),tags:_t(Xe().max(80)).max(30),createdAt:Xe().datetime(),description:Xe().max(4000).optional(),brief:Xe().max(8000).optional(),attribution:be({model:Xe().max(200).optional(),harness:Xe().max(200).optional(),author:Xe().max(200).optional()}).optional(),editable:Kr(),files:cl(Xe(),be({sha256:YC,bytes:et().int().nonnegative().max(bl)})),build:be({engine:Xe(),options:cl(Xe(),Jr()),warnings:_t(Xe()),integration:Jr().optional(),qa:Jr().optional(),dependencies:_t(Jr()).optional(),rebuild:wt(["engine-required","external-dependencies-required"])}).optional(),preview:be({fidelity:Jr().optional(),error:Xe().optional(),backdrop:wt(hv).optional()}).optional()}),JC="materials.kiln.json",KC=25165824;function QC(e){let t=new Map;for(let n of e.manifest.build?.dependencies??[]){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Invalid saved asset dependency");let i=n;if(i.kind!=="kiln.material.v1"&&i.kind!=="kiln.material.v2"){if(i.delivery==="runtime")throw Error("Unsupported runtime dependency");if(i.delivery!=="embedded")throw Error("Unsupported saved asset dependency");continue}if(i.delivery!=="runtime")throw Error("Invalid saved material dependency");let r=hf(i.manifest);if(i.kind!==`kiln.material.v${r.schemaVersion}`)throw Error("Saved material dependency kind/version mismatch");let s=`${r.materialId}/${r.revisionId}`,o=t.get(s);if(o&&Nn(o)!==Nn(r))throw Error("Conflicting saved material dependency manifests");if(t.set(s,r),t.size>an.maxPayloadRecords)throw Error("Saved asset material dependency count exceeds limit")}return[...t.values()]}function sb(e,t=!1){let n=QC(e),i=new Map(n.map((d)=>[`${d.materialId}/${d.revisionId}`,Nn(d)]));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}io(e.materialResources);let r=ib.parse(e.materialResources),s=0,o=0,a=new Map;for(let d of r.records){let h=hf(d.manifest),f=`${d.manifest.materialId}/${d.manifest.revisionId}`;if(a.has(f)||i.has(f)&&i.get(f)!==Nn(h))throw Error("Asset material closure mismatch");if(a.set(f,h),Object.keys(d.files).length!==d.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let m of d.manifest.maps){if(d.files[m.file]?.length!==Math.ceil(m.bytes/3)*4)throw Error("Asset material map size mismatch");s+=m.bytes,o+=m.width*m.height}}if(s>an.maxPayloadBytes||o>an.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits");let c=new Set,l=new Set,u=(d)=>{if(l.has(d))throw Error("Asset material closure contains a cycle");if(c.has(d))return;let h=a.get(d);if(!h)throw Error("Asset material closure incomplete");l.add(d);for(let f of rb(h))u(`${f.resourceId}/${f.revisionId}`);l.delete(d),c.add(d)};for(let d of i.keys())u(d);if(c.size!==a.size)throw Error("Asset material closure has unrelated records")}var eP=new Set(["asset.glb","source.kiln.js","preview.png"]);function tP(e){let t=ff.parse(e.manifest),n=Object.keys(e.files);if(n.length!==Object.keys(t.files).length||!n.includes("asset.glb"))throw Error("Asset file inventory mismatch");let i=0;for(let r of n){if(!eP.has(r)||!t.files[r]||t.files[r].bytes!==e.files[r].length)throw Error("Invalid asset file inventory");i+=e.files[r].length}if(i>bl||t.editable!==n.includes("source.kiln.js"))throw Error("Invalid asset size or source inventory");if((e.files["source.kiln.js"]?.length??0)>1048576)throw Error("Source exceeds 1 MiB");pf(e.files["asset.glb"]),sb(e)}function pf(e){if(e.length<20||e.length>bl)throw Error("Invalid GLB size");let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.length||t.getUint32(16,!0)!==1313821514)throw Error("Invalid GLB header");let n=20+t.getUint32(12,!0);if(n>e.length)throw Error("Invalid GLB JSON length");let i=JSON.parse(new TextDecoder().decode(e.subarray(20,n)));for(let r of[...i.buffers??[],...i.images??[]])if(r.uri&&!String(r.uri).startsWith("data:"))throw Error("GLB must embed its resources")}function ob(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){tP(i),sb(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,o]of Object.entries(i.files))t[r+s]=o;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>KC)throw Error("Asset material payload exceeds byte limit");t[r+JC]=s}}for(let i of Object.values(t))n+=i.length;if(n>bl)throw Error("Bundle exceeds 64 MiB");return Cv(t,{level:0})}function Ii(e){let t=new Set,n=new Set,i=new Set;e.traverse((r)=>{let s=r;if(!s.isMesh)return;t.add(s.geometry);for(let o of Array.isArray(s.material)?s.material:[s.material]){n.add(o);for(let a of Object.values(o))if(a instanceof Nt)i.add(a)}});for(let r of[...t,...n,...i])r.dispose()}async function ab(e){pf(e);let t=new Do,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new Os(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new Bh(t);i.register((s)=>({name:"KILN_embedded_images",async beforeRoot(){for(let o of s.json.images??[]){if(o.bufferView===void 0)continue;let a=new Uint8Array(await s.getDependency("bufferView",o.bufferView)),c="";for(let l=0;l<a.length;l+=8192)c+=String.fromCharCode(...a.subarray(l,l+8192));if(!/^image\/(png|jpeg|webp|avif)$/.test(o.mimeType??""))throw Error("Unsupported embedded image type");o.uri=`data:${o.mimeType};base64,${btoa(c)}`,delete o.bufferView}}}));let r=await i.parseAsync(Uint8Array.from(e).buffer,"");if(n){for(let s of r.scenes)Ii(s);throw Error("An embedded texture could not be decoded.")}return Object.assign(r,{assertTexturesLoaded(){if(n)throw Error("An embedded texture could not be decoded.")}})}function cb(e,t,n=40,i=[e]){let r=e.getCenter(new U),s=Math.max(e.getSize(new U).length()/2,0.01),o=new U(1,0.65,1.25).normalize(),a=new U().crossVectors(new U(0,1,0),o).normalize(),c=new U().crossVectors(o,a),l=[];for(let S of i.length?i:[e])for(let T of[S.min.x,S.max.x])for(let y of[S.min.y,S.max.y])for(let w of[S.min.z,S.max.z])l.push(new U(T,y,w));let u=1/0,d=-1/0,h=1/0,f=-1/0;for(let S of l){let T=S.clone().sub(r),y=T.dot(a),w=T.dot(c);u=Math.min(u,y),d=Math.max(d,y),h=Math.min(h,w),f=Math.max(f,w)}r.addScaledVector(a,(u+d)/2),r.addScaledVector(c,(h+f)/2);let m=Math.tan(n*Math.PI/360),_=m*t,p=s;for(let S of l){let T=S.clone().sub(r),y=T.dot(o);p=Math.max(p,y+Math.abs(T.dot(a))*1.12/_,y+Math.abs(T.dot(c))*1.12/m)}let g=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:g}}function mf(e,t){return{position:e.position.clone(),target:t.clone()}}function gf(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new U).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new U))+r*20,10),e.updateProjectionMatrix()}function lb(e,t,n){let i=e.getWorldDirection(new U);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new U(0,1,0)),s=new U;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function ub(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}function hb(e,t,n){if(t())return e;n(e);return}function Sl(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,o)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(o)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((o)=>{let a=e.parser.associations.get(o)?.nodes;if(a===void 0||!i.has(a))return;o.visible=!1,r++});return r}function Ml(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Gt().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Gt,i=new Gt,r=new U;return e.traverseVisible((s)=>{let o=s,a=o.geometry;if(!a)return;let c=a.getAttribute("position");if(c&&o.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(o.isMesh)o.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(a.boundingBox===null)a.computeBoundingBox();i.copy(a.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new Gt().setFromObject(e,!0):n}function va(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function db(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((m)=>!Number.isInteger(m)||!t[m]||n.has(m)))continue;let d=l.parent;while(d&&!i.has(d))d=d.parent;if(d)continue;let h=[l];for(let m of u)h.push(await e.parser.getDependency("node",m));Sl(e,h.slice(1)),i.add(l);let f=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:f,levels:h})}if(r.length===0)return;let s=va(e.scene)-r.reduce((c,l)=>c+_f(l,0),0),o=Math.max(...r.map((c)=>c.levels.length)),a=Array.from({length:o},(c,l)=>s+r.reduce((u,d)=>u+_f(d,l),0));return{chains:r,triangles:a}}var fb=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function _f(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return va(fb(e,t))}function pb(e,t){let n=fb(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function mb(e,t){for(let n of e.chains)pb(n,t)}function gb(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return pb(i,n),!0}function _b(e,t){if(!e)return;return{triangles:va(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>_f(n,r))}))}}function ro(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function xb(e){let t=new Rh({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=yo,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new Is,i=new Vt(40,1,0.01,1000),r=new Ih(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,o=!1,a=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(P)=>{if(!o||!c.has(P.code))return;P.preventDefault(),s.add(P.code)},u=(P)=>s.delete(P.code),d=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",d);let h=new Go(t),f=new Lh,m=h.fromScene(f,0.04);n.environment=m.texture,f.dispose(),h.dispose();let _=new zs(16773591,2.4);_.position.set(4,8,5),n.add(_),n.add(new Mc(14806490,5065021,1.7));let p,g,S,T=[],y=!0,w=performance.now(),A=0,R=0,x=!1,M,z,C,L=(P)=>{if(!C)return;clearTimeout(C.timeout),C.reject(Error(P)),C=void 0},K=(P)=>{let j=t.getContext(),k=j.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:P-C.started,frameMs:ub(C.samples),...z===void 0?{}:{loadToFirstFrameMs:z},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(j.getParameter(j.VERSION)),vendor:String(j.getParameter(j.VENDOR)),renderer:String(j.getParameter(j.RENDERER)),browser:navigator.userAgent,...k?{unmaskedVendor:String(j.getParameter(k.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(j.getParameter(k.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},I=()=>{if(!p)return;let P=Ml(p),j=[];p.traverseVisible((ue)=>{if(ue instanceof Mt||ue instanceof pr||ue instanceof Ds){let Be=new Gt().setFromObject(ue,!0);if(!Be.isEmpty())j.push(Be)}});let{center:k,radius:q,distance:Q,position:Me}=cb(P,i.aspect,i.fov,j);if(r.target.copy(k),i.position.copy(Me),i.near=Math.max(q/1000,0.0001),i.far=Q+q*100,r.minDistance=q*0.1,r.maxDistance=q*80,a=Math.max(q*0.35,0.01),o)r.minDistance=q*0.00001;i.updateProjectionMatrix(),r.update()},G=new ResizeObserver(()=>{let{clientWidth:P,clientHeight:j}=e;if(!P||!j)return;t.setSize(P,j),i.aspect=P/j,i.updateProjectionMatrix()});G.observe(e);let X=(P)=>{if(x)return;let j=Math.min((P-w)/1000,0.1);if(w=P,e.clientWidth&&e.clientHeight){if(y)S?.update(j);if(o&&s.size){let k=lb(i,s,j*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(k),r.target.add(k)}if(r.update(),t.render(n,i),M!==void 0)z=performance.now()-M,M=void 0;if(C){if(C.previous>0&&C.samples.length<1800)C.samples.push(P-C.previous);if(C.previous=P,P-C.started>=C.duration&&C.samples.length){let k=K(P);clearTimeout(C.timeout),C.resolve(k),C=void 0}}}else s.clear(),L("Keep the measured viewport visible for the complete sampling window.");A=requestAnimationFrame(X)};return A=requestAnimationFrame(X),{async load(P,j={}){let k=performance.now(),q=++R;L("The artifact changed during measurement. Measure the new revision again.");let Q=await ab(P);Sl(Q,[Q.scene]);let Me=await db(Q);try{Q.assertTexturesLoaded()}catch(xe){Ii(Q.scene);for(let Ee of ro(Me))Ii(Ee);throw xe}let ue=hb(Q,()=>!x&&q===R&&j.isCurrent?.()!==!1,(xe)=>{Ii(xe.scene);for(let Ee of ro(Me))Ii(Ee)});if(!ue)return;let Be=p&&j.preserveView?mf(i,r.target):void 0;if(p){S?.stopAllAction(),S?.uncacheRoot(p),n.remove(p),Ii(p);for(let xe of ro(g))Ii(xe)}p=ue.scene,g=Me,M=k,z=void 0,n.add(p),T=ue.animations,S=new Tc(p),y=!0;let{clientWidth:we,clientHeight:Z}=e;if(t.setSize(we,Z),i.aspect=we&&Z?we/Z:i.aspect,I(),Be)gf(i,r.target,Be,Ml(p)),r.update();let re=0,se=new Set;return p.traverseVisible((xe)=>{let Ee=xe;if(!Ee.isMesh)return;re++;for(let Ae of Array.isArray(Ee.material)?Ee.material:[Ee.material])se.add(Ae)}),j.onCommit?.(),{triangles:va(p),meshes:re,materials:se.size,clips:T.map((xe)=>xe.name),...g?{levels:g.triangles}:{}}},level(P){if(L("The level of detail changed. Measure the displayed combination again."),g)mb(g,P)},partLevel(P,j){if(L("The level of detail changed. Measure the displayed combination again."),g)gb(g,P,j)},lod(){return p?_b(g,p):void 0},reset:I,cancelMeasurement:L,measure(P=3000){if(x||!p||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(P)||P<1000||P>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(C)return Promise.reject(Error("A measurement is already running."));return new Promise((j,k)=>{C={started:performance.now(),previous:0,duration:P,samples:[],resolve:j,reject:k,timeout:setTimeout(()=>L("Measurement was interrupted or the browser stopped delivering frames."),P+2000)}})},view(){return mf(i,r.target)},setView(P){if(!p)return;gf(i,r.target,P,Ml(p)),r.update()},navigation(P){if(o=P==="explore",s.clear(),r.minDistance=o?0.00001:a/3.5,o)i.near=0.0001,i.updateProjectionMatrix()},wire(P){for(let j of p?[p,...ro(g)]:[])j.traverse((k)=>{let q=k;if(q.isMesh){for(let Q of Array.isArray(q.material)?q.material:[q.material])if("wireframe"in Q)Q.wireframe=P}})},lighting(P){t.toneMappingExposure=P==="bright"?1.65:P==="soft"?0.85:1.15,_.intensity=P==="soft"?0.8:2.4},clip(P){if(S?.stopAllAction(),T[P])S?.clipAction(T[P]).play()},pause(P){y=!P},dispose(){if(L("The viewport closed before measurement finished."),x=!0,R++,cancelAnimationFrame(A),G.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",d),p)Ii(p);for(let P of ro(g))Ii(P);m.dispose(),t.dispose(),e.replaceChildren()}}}var yb=["127.0.0.1","localhost","[::1]"];async function vb(e,t,n,i,r,s){let o="";for(let a=0;a<e.length;a+=8192)o+=String.fromCharCode(...e.subarray(a,a+8192));try{if((await i("ui/download-file",{contents:[{type:"resource",resource:{uri:`file:///${t}`,mimeType:n,blob:btoa(o)}}]}))?.isError)throw Error("The chat host could not download this file.");return{}}catch(a){if(a.code!==-32601)throw a;if(s){let d=new URL(s);if(d.protocol!=="https:"&&!(d.protocol==="http:"&&yb.includes(d.hostname)))throw Error("Invalid host download URL");return{downloadUrl:d.href}}if(!r)throw a;let c=new File([Uint8Array.from(e)],t,{type:n}),{fileId:l}=await r.uploadFile(c),{downloadUrl:u}=await r.getFileDownloadUrl({fileId:l});if(new URL(u).protocol!=="https:")throw Error("Invalid host download URL");return{downloadUrl:u}}}var Sb=16777216,Mb=Math.ceil(Sb/3)*4,Yt=(e)=>{throw Error(`Asset transfer ${e}. Present the saved asset again or open it in Kiln; the saved files are unchanged.`)};function nP(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function bb(e){if(typeof e!=="string"||e.length>Mb)return Yt("exceeds the encoded size limit");if(e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))Yt("contains damaged base64 data");let t;try{t=atob(e)}catch{return Yt("contains damaged base64 data")}let n=Uint8Array.from(t,(i)=>i.charCodeAt(0));if(nP(n)!==e)Yt("contains noncanonical base64 data");return n}function ba(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}async function wb(e){if(!ba(e))return Yt("metadata is missing");if(typeof e.error==="string")throw Error(e.error);let t=ff.safeParse(e.manifest);if(!t.success||!ba(e.files))return Yt("metadata is malformed");let n=t.data,i=Object.entries(e.files);if(!i.length||i.length>16||!Object.hasOwn(e.files,"asset.glb"))return Yt("file list is missing or invalid");let r=0,s=0;for(let[c,l]of i){if(!/^[a-z0-9][a-z0-9._-]{0,127}$/.test(c)||!Object.hasOwn(n.files,c))return Yt("file metadata is missing");if(r+=n.files[c].bytes,r>Sb)return Yt("exceeds the decoded size limit");let u=typeof l==="string"?l:ba(l)?l.data:void 0;if(typeof u!=="string")return Yt("file encoding is malformed");if(s+=u.length,s>Mb)return Yt("exceeds the encoded size limit")}let o={};for(let[c,l]of i){let u=n.files[c],d;if(typeof l==="string")d=bb(l);else{if(!ba(l)||l.encoding!=="kiln.deflate-base64.v1")return Yt("encoding is unsupported");let m=bb(l.data);try{d=Tv(m,{out:new Uint8Array(u.bytes+1)})}catch{return Yt("compressed data is damaged")}}if(d.length!==u.bytes)return Yt("byte count does not match the saved file");let h=await crypto.subtle.digest("SHA-256",Uint8Array.from(d));if(`sha256:${Array.from(new Uint8Array(h),(m)=>m.toString(16).padStart(2,"0")).join("")}`!==u.sha256)return Yt("integrity check failed");o[c]=d}for(let c of Object.keys(n.files))if(!Object.hasOwn(o,c))return Yt("is missing a saved file");let a={};if(e.downloadUrls!==void 0){if(!ba(e.downloadUrls))return Yt("download metadata is malformed");for(let[c,l]of Object.entries(e.downloadUrls)){if(typeof l!=="string")return Yt("download metadata is malformed");a[c]=l}}return{record:{manifest:n,files:o},downloadUrls:a}}function Eb(e){let t=e.attribution;if(!t)return[];return[t.model?{label:"Model",value:t.model}:null,t.harness?{label:"Harness",value:t.harness}:null,t.author?{label:"Author",value:t.author}:null].filter((n)=>n!==null)}var Dn=(e)=>document.getElementById(e),Li=Dn("status"),cn,Tb={},ns,iP=0,Ni=0,wl=new Map;function Rb(e,t){let n=++iP;return new Promise((i,r)=>{let s=setTimeout(()=>{wl.delete(n),r(Error("Chat host did not respond."))},20000);wl.set(n,{resolve(o){clearTimeout(s),i(o)},reject(o){clearTimeout(s),r(o)}}),window.parent.postMessage({jsonrpc:"2.0",id:n,method:e,params:t},"*")})}function Ab(e,t={}){window.parent.postMessage({jsonrpc:"2.0",method:e,params:t},"*")}function rP(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}async function sP(e){let t=++Ni;cn=void 0,Dn("stats").textContent="",Dn("clips").hidden=!0;for(let n of document.querySelectorAll("button[data-download]"))n.disabled=!0;try{if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Asset transfer metadata is missing. Present the saved asset again.");await oP(e,t)}catch(n){if(t!==Ni)return;Li.textContent=n instanceof Error?n.message:"Asset transfer failed. Present the saved asset again."}}async function oP(e,t){if(e.isError){Li.textContent=e.content?.find((i)=>i.type==="text")?.text??"This asset could not be opened.";return}let n;try{n=await wb(e._meta?.kilnAsset)}catch(i){if(t!==Ni)return;Li.textContent=i instanceof Error?i.message:"Asset transfer failed. Present the saved asset again.";return}if(t!==Ni)return;cn=n.record,Dn("name").textContent=cn.manifest.name,Tb=n.downloadUrls,Dn("revision").textContent=`${cn.manifest.editable?"Editable source included":"GLB asset"} · ${cn.manifest.revisionId.slice(0,10)}`,Dn("attribution").textContent=Eb(cn.manifest).map(({label:i,value:r})=>`${i}: ${r}`).join(" · ");try{ns??=xb(Dn("stage"));let i=await ns.load(cn.files["asset.glb"]);if(t!==Ni)return;if(i){Dn("stats").textContent=`${i.triangles.toLocaleString()} triangles · ${i.materials} materials · ${(cn.files["asset.glb"].length/1024).toFixed(0)} KB`;let r=Dn("clips");r.replaceChildren(new Option("Rest pose","-1"),...i.clips.map((s,o)=>new Option(s,String(o)))),r.hidden=!i.clips.length}Li.textContent="Drag to orbit · Scroll to zoom"}catch(i){if(t!==Ni)return;ns?.dispose(),ns=void 0;let r=cn.files["preview.png"];if(r){let s=new Image;s.alt=`${cn.manifest.name} · saved preview image`,s.src=`data:image/png;base64,${rP(r)}`,Dn("stage").replaceChildren(s)}Li.textContent=`${r?"Showing saved preview. ":""}3D preview unavailable: ${String(i)}`}for(let i of document.querySelectorAll("button[data-download]"))i.disabled=!1;Dn("source").hidden=!cn.files["source.kiln.js"]}window.addEventListener("message",(e)=>{if(e.source!==window.parent||e.data?.jsonrpc!=="2.0")return;let t=e.data;if(t.id!==void 0&&!t.method){let n=wl.get(t.id);if(wl.delete(t.id),t.error)n?.reject(Object.assign(Error(t.error.message),{code:t.error.code}));else n?.resolve(t.result)}if(t.method==="ui/notifications/tool-result")sP(t.params);if(t.method==="ui/resource-teardown")ns?.dispose(),window.parent.postMessage({jsonrpc:"2.0",id:t.id,result:{}},"*")});Dn("reset").onclick=()=>ns?.reset();Dn("clips").onchange=(e)=>ns?.clip(Number(e.target.value));for(let e of document.querySelectorAll("button[data-download]"))e.onclick=async()=>{if(!cn)return;let t=Ni,n=e.dataset.download,i=n==="bundle"?"editable.zip":n==="source"?"source.kiln.js":"asset.glb",r=n==="bundle"?ob([cn]):cn.files[i],s=n==="bundle"?"application/zip":n==="source"?"text/javascript":"model/gltf-binary",o=cn.manifest.name.replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80);e.disabled=!0,Li.textContent="Requesting download…";try{let a=typeof window.openai?.uploadFile==="function"&&typeof window.openai?.getFileDownloadUrl==="function"?window.openai:void 0,c=await vb(r,`${o}-${i}`,s,Rb,a,Tb[i]);if(t!==Ni)return;if(c.downloadUrl){let l=document.createElement("a");l.href=c.downloadUrl,l.textContent=`Save ${o}-${i}`,l.style.color="#d5f4a2",l.target="_blank",l.rel="noopener noreferrer",l.onclick=(u)=>{if(window.openai?.openExternal)u.preventDefault(),window.openai.openExternal({href:c.downloadUrl})},Li.replaceChildren("Download ready. ",l)}else Li.textContent="Download requested."}catch(a){if(t===Ni)Li.textContent=`Download unavailable in this host: ${a.message}`}finally{e.disabled=!cn||t!==Ni}};Rb("ui/initialize",{appInfo:{name:"Kiln Asset Viewer",version:"0.6.0"},appCapabilities:{},protocolVersion:"2026-01-26"}).then(()=>{Ab("ui/notifications/initialized"),Ab("ui/notifications/size-changed",{height:document.documentElement.scrollHeight})}).catch((e)=>{Li.textContent=e.message});</script></body>diff --git a/docs/atlas-provenance.md b/docs/atlas-provenance.mdindex c4d88ee0..deab5ff8 100644--- a/docs/atlas-provenance.md+++ b/docs/atlas-provenance.md@@ -18,6 +18,6 @@ Admission allows 128 unique identities, at most 256 KiB per JSON entry, a 4 MiBBefore first PNG encoding, baking verifies raw RGBA dimensions and SHA-256 against the compiled manifest. Already encoded source maps receive bounded PNG dimension/decode verification. Editing pixels while retaining an atlas stamp fails with a stale-provenance diagnostic. A validated GLB loader establishes a private WeakMap identity for exporter-derived delivery bytes; authored flags cannot establish this identity. Re-export checks those exact bytes against the validated delivery reference rather than comparing legitimate converted normal pixels to the original compiler pixels. The source recipe/pixel identity and final encoded-image identity remain separate. No GLB contains its own final artifact hash; that hash remains in external baked provenance.-Both exporters write the same table, references and compact bindings. The optimizer validates input lineage and refreshes the final image identities after its transforms. Composition admits and merges the tables before copying source graphs and deleting their scenes. Import validates final bytes and samplers, never repairs a tampered reference. External transforms that rewrite images must update delivery references through the validated engine export path; retaining old image hashes makes the transformed artifact fail import validation.+Both exporters write the same table, references and compact bindings. The optimizer validates input lineage and refreshes the final image identities after its transforms. Composition admits and merges the tables before copying source graphs and deleting their scenes. Import validates final bytes and samplers, never repairs a tampered reference. External transforms that rewrite images must update delivery references through the validated engine export path; retaining old image hashes makes the transformed artifact fail import validation. The three.js runtime target's KTX2 encoding is such a path: after replacing each image with its KTX2 bytes it calls `refreshAtlasDocumentProvenance` and then `validateAtlasDocumentProvenance`, so every `kilnAtlasReference.finalImageSha256` and `finalMime` name the delivered KTX2 image (and equal its runtime texture manifest `sha256` and `mimeType`). The external `.gltf` layout moves images to files without changing these identities, which hash bytes, not locations.Structural metadata proves identities, named selectors and remap formulas. It does not prove an author's intended corner orientation after arbitrary within-domain UV edits, visual quality, or inferred physical density. Generic author `kiln*` userData remains excluded; only this owner's validated engine metadata is explicitly promoted.diff --git a/docs/backlog.md b/docs/backlog.mdindex 3147487c..993b8f44 100644--- a/docs/backlog.md+++ b/docs/backlog.md@@ -92,7 +92,7 @@ its own review and completion boundary.| Directory submissions | Separate from package publication and hosted deployment; the HOL catalog listing is merged. Vendor review remains separate from local plugin distribution || Further packs | Separate product work; ten-pack production is not a Troy release chore || Broader importer qualification | Actual destination tests for LOD, visibility and supported export profiles |-| Optional compressed runtime derivatives | Explicit loader/profile adoption and measured size/startup/render tradeoffs; current shared runtime loading is not universal Meshopt/Draco/KTX2 support |+| Optional compressed runtime derivatives | Explicit loader/profile adoption and measured size/startup/render tradeoffs; current shared runtime loading is not universal Meshopt/Draco/KTX2 support. Opt-in texture manifests and content-addressed external textures ([#213](https://github.com/instruktlabs/kiln/issues/213)) give hosts a dedup key, and `--ktx2` encodes through the optional `ktx2-encoder` peer ([#201](https://github.com/instruktlabs/kiln/issues/201)); measured savings and KTX2 visual quality on a real asset set remain open, as does an external `ktx create` fallback if the WebAssembly encoder falls short || New derivative guidance | Demonstrated authoring/workflow evidence beyond Troy before promoting a scene-specific lesson to shared guidance |Full optimization preserves semantic nodes while potentially emptying ordinarydiff --git a/docs/delivery-contract.md b/docs/delivery-contract.mdindex 01efe741..2f6ce48d 100644--- a/docs/delivery-contract.md+++ b/docs/delivery-contract.md@@ -131,6 +131,15 @@ Consumer rules that follow from it:- **Collider transforms are exact.** A collider's proxy mesh moves to a child named`<collider>_Proxy`, so the collider node's scale is still its size.- **Custom attributes stay float.** `_EDGE` and `_CAVITY` are never quantized.+- **KTX2 needs `KTX2Loader`.** With `--ktx2`, `KHR_texture_basisu` is required and there is+ no PNG fallback: configure `GLTFLoader.setKTX2Loader` with the Basis transcoder before+ loading. `delivery.ktx2.encoder` names the encoder version and settings that produced+ the images. See [KTX2 textures](export-profiles.md#ktx2-textures).+- **Deduplicate textures by hash, not by name.** With `--textures manifest` the sidecar's+ `textures[]` gives each image's exact `sha256`; with `--textures external` the images are+ shared `textures/<sha256>.<ext>` files beside a `.gltf`. Keep `textures/` beside every+ `.gltf` that references it, and never rewrite a file in place: its name is its content.+ See [runtime textures](export-profiles.md#runtime-textures-manifest-and-shared-files).- **Find nodes by role, not by name alone.** three's `GLTFLoader` makes object namesunique, so an asset root that shares the scene's name loads with a numeric suffix.- **Choose LOD levels in the consumer.** `GLTFLoader` preserves `MSFT_lod` extensiondiff --git a/docs/export-profiles.md b/docs/export-profiles.mdindex d22e24c0..7864aceb 100644--- a/docs/export-profiles.md+++ b/docs/export-profiles.md@@ -82,7 +82,8 @@ node kiln.mjs export ASSET_ID REVISION_ID --profile runtime --out mech.glb# mech.kiln-metadata.json```-Runtime requires GLB format and an output ending in `.glb`. Bundle/source formats+Runtime requires GLB format and an output ending in `.glb`, except `--textures external`,+which writes `.gltf` (see runtime textures). Bundle/source formatsuse `editable`. Use a portable filename stem containing ASCII letters, digits,periods, underscores or hyphens, beginning with a letter or digit. The generatedsidecar filename must be at most 200 characters; Windows device names are rejected.@@ -194,9 +195,10 @@ What it does, in order:FLOAT. Buffers are written with `EXT_meshopt_compression` (required) unless thecaller passes `compression: 'none'` (CLI `--compression none`): then buffers stay plain,no Meshopt decoder is needed, and quantization, instancing and everything below stay.-4. Textures become KTX2 (`KHR_texture_basisu`) only when the library caller passes a- `ktx2Encoder`; Kiln ships none, so the CLI reports `ktx2: { status: 'skipped' }` and- textures stay PNG or JPEG.+4. Textures become KTX2 (`KHR_texture_basisu`, required, no PNG fallback) only with+ `--ktx2` or a library `ktx2Encoder`; otherwise the sidecar reports+ `ktx2: { status: 'skipped' }` and textures stay PNG or JPEG. See+ [KTX2 textures](#ktx2-textures).Roles and kit extras, hidden collider nodes (`KHR_node_visibility`), anchors, ports and`MSFT_lod` chains are kept. The sidecar `delivery` block states what a consumer needs:@@ -210,7 +212,7 @@ Roles and kit extras, hidden collider nodes (`KHR_node_visibility`), anchors, po| `colliderProxies` | Collider node and proxy child paths || `customAttributes` | Each underscore attribute, its mesh count, `FLOAT`, not normalized || `instancing` | Each batch node, its mesh, count and instance names in order |-| `ktx2` | `encoded` or `skipped` with the texture count and reason |+| `ktx2` | `encoded` or `skipped` with the texture count and reason; `encoder` (name, version, Basis WebAssembly hash and every setting) when the encoder declared it || `preserved` | Counts of LOD chains, hidden nodes, colliders, anchors, ports and kit modules |Quantization stores positions as normalized integers and moves the metre scale onto@@ -231,6 +233,148 @@ decoder. three's `GLTFLoader` keeps unknown node extensions in `userData.gltfExtKiln's tests load the derived GLB from both converters this way. On a very small assetthe extension JSON can outweigh the saved geometry; compare real assets.+## KTX2 textures++`--ktx2` (with `--target three`) encodes every PNG, JPEG or WebP image to KTX2 through+the optional peer `[email protected]`. Kiln does not install or bundle it; add it to the+installation that runs `kiln`:++```sh+npm install [email protected]+node kiln.mjs export ASSET_ID REVISION_ID --profile runtime --target three --ktx2 --textures manifest --out door.glb --json+```++Without the peer, `--ktx2` fails and names that install command. Another installed+version is refused, because the settings below are qualified on 0.6.0. The mode follows+the slot: ETC1S with the sRGB transfer function for base colour and emissive, UASTC with+Zstandard supercompression for normal, metallic-roughness, occlusion and other linear+maps (normal maps also use the encoder's normal-map preset). Every level gets mipmaps. An+image used by both an sRGB and a linear slot stops the export, because one encoding+cannot serve both; give each slot its own image.++`delivery.ktx2.encoder` records `name`, `version`, `basisWasmSha256` and the exact+`settings` per profile, and the `--json` receipt repeats `delivery.ktx2`. Because the+sidecar hash is stamped into the GLB, these facts are bound to the delivered bytes. With+`--textures manifest`, each entry's `sha256` is the KTX2 bytes and `sourceSha256` the+image before encoding; a library pin is matched on the pre-encode bytes. Encoding the same+image twice gives identical bytes in Kiln's tests; if a platform ever differs, the+recorded version and settings are the contract, and the only cost is a new hash.++Encoding runs inside the same document as the rest of the target, so `MSFT_lod` chains,+roles and atlas provenance survive: every atlas reference is rebound to its KTX2 bytes and+MIME type and validated as import will validate it. The library form is:++```ts+import { createKtx2Encoder, exportAssetGlb } from '@instruktlabs/kiln/asset-export';++const output = await exportAssetGlb(record, {+ profile: 'runtime',+ target: 'three',+ ktx2Encoder: await createKtx2Encoder(),+});+```++A host may pass its own `ktx2Encoder` instead. It receives `{ image, mimeType, name,+colorSpace, slot }`, must return bytes that start with the KTX2 identifier, and may carry+an `identity` property that Kiln records as `delivery.ktx2.encoder`.++A consumer needs `KTX2Loader` (with its Basis transcoder files served by the application)+in addition to the meshopt decoder:++```ts+import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';++const ktx2 = new KTX2Loader().setTranscoderPath('/basis/').detectSupport(renderer);+const loader = new GLTFLoader().setMeshoptDecoder(MeshoptDecoder).setKTX2Loader(ktx2);+```++Licences: `ktx2-encoder` is MIT. Its package bundles a precompiled Basis Universal+encoder (Apache-2.0, Binomial LLC) as WebAssembly, which links Zstandard (BSD-3-Clause)+and MIT-licensed image loaders, and the package ships `THIRD_PARTY_NOTICES.md` reproducing+the Basis Universal NOTICE. Kiln (MIT) only imports the peer that the user installed; it+redistributes none of that code, so the notice travels with the installed package. Anyone+who redistributes `ktx2-encoder` itself, for example inside a self-contained archive, must+keep that notice file. KTX2 output is data produced by the encoder, not a copy of it.++## Runtime textures: manifest and shared files++Runtime GLBs embed every texture, so forty assets that use one library material carry+forty copies of its maps. Two opt-in choices let a host share them. Neither is the+default: without `--textures`, the GLB, sidecar and `--json` receipt bytes are unchanged.++**Manifest.** `--textures manifest` (runtime profile, with or without `--target three`)+adds `textures[]` to the sidecar. The GLB is unchanged apart from the provenance hash of+that larger sidecar.++```sh+node kiln.mjs export ASSET_ID REVISION_ID --profile runtime --textures manifest --out wall.glb+```++```ts+const output = await exportAssetGlb(record, { profile: 'runtime', textures: 'manifest' });+```++One entry per glTF image, sorted by image index:++| Field | Meaning |+| --- | --- |+| `image` | glTF image index |+| `sha256`, `bytes`, `mimeType` | Identity of the exact delivered bytes |+| `width`, `height` | Pixel size read from the image header |+| `colorSpace` | `srgb` when a base colour or emissive slot uses the image, otherwise `linear` |+| `sourceSha256` | The bytes before KTX2 encoding, only when encoding changed them |+| `material` | `{ pin: { resourceId, revisionId, sha256 }, slot }`, only when the pre-encode bytes exactly equal a map in the record's saved material closure (`materials.kiln.json`). Never inferred from names |+| `uri` | External layout only: the image file relative to the `.gltf` |++Equal `sha256` means equal bytes, so a host can deduplicate images across assets on that+key without decoding a GLB. Library textures keep their encoded bytes in the GLB, so two+assets that use one library map report the same `sha256` and the same `material.pin`.++**External textures.** `--textures external` (requires `--target three` and `--out`+ending in `.gltf`) writes standard JSON glTF with content-addressed images instead of a+GLB, and implies the manifest with a `uri` on each entry:++```sh+node kiln.mjs export ASSET_ID REVISION_ID --profile runtime --target three \+ --textures external --out assets/wall.gltf --json+# assets/wall.gltf (asset.extras.kilnProvenanceV1 points at the sidecar)+# assets/wall.bin+# assets/wall.kiln-metadata.json+# assets/textures/<sha256>.png (or .jpg, .webp, .ktx2)+```++The file name of each texture is the hex SHA-256 of its exact bytes. Exports into one+folder share those files:++- Textures are published first, then the sidecar, the `.bin` and the `.gltf` last.+- An existing texture with the same bytes is reused and never rewritten; the receipt+ marks it `"reused": true`. A file with that name but different bytes stops the export+ before any model file is published.+- The model files keep the never-replace rule: an existing `.gltf`, `.bin` or sidecar+ stops the export before any texture is written.+- A failed export rolls back its model files but never removes a texture, even one it+ created, because a concurrent export may already reference it. A leftover texture is+ harmless.++The library form returns `layout: 'gltf'` with `gltf`, `buffers`, `textures` and+`metadata` to write, plus the equivalent embedded `glb` for inspection:++```ts+const output = await exportAssetGlb(record, {+ profile: 'runtime',+ target: 'three',+ textures: 'external',+ gltfFileName: 'wall.gltf',+ metadataFileName: 'wall.kiln-metadata.json',+});+```++three.js loads the `.gltf` and resolves `wall.bin` and `textures/...` relative to it:+`new GLTFLoader().setMeshoptDecoder(MeshoptDecoder).loadAsync('assets/wall.gltf')`.+Plain `--profile runtime` keeps `.glb` only, because that profile copies the binary chunk+byte for byte. Kiln's tests validate the `.gltf` with `gltf-validator` and load it through+`GLTFLoader`. MCP `kiln_export` does not offer these options.+## Pointer and hash contractThe runtime GLB contains this record in `asset.extras.kilnProvenanceV1`:@@ -268,7 +412,9 @@ sidecar points back to the canonical input GLB hash, not the derived runtime GLBso there is no circular hash dependency. IDs and hashes let a tool locate and verifythe corresponding editable revision; they are integrity/provenance data, not signaturesor authenticated authorship. The sidecar deliberately does not embed the full manifest,-source or build record.+source or build record. Optional fields appear only when requested: `target` and+`delivery` with `--target three`, `textures` with `--textures`. In the external layout the+same record sits in the `.gltf` file's `asset.extras`.The URI is informational, not a glTF buffer/image URI. Kiln does not automaticallyfetch it or execute its contents. Standard glTF playback works without the sidecar,diff --git a/docs/material-library.md b/docs/material-library.mdindex f2eaafa2..e78e7459 100644--- a/docs/material-library.md+++ b/docs/material-library.md@@ -100,6 +100,11 @@ project ZIPs carry resources for their selected saved inventory as well as the cBoth preserve normalized maps, recipes and provenance without fetching original source URLs.Runtime GLBs already embed their rendering resources. An editable export fails clearly if adeclared library dependency is unavailable; creating a project is not a workaround or requirement.+Runtime exports can opt in to a texture manifest (`--textures manifest`) that names each+embedded image by its exact `sha256` and, when those bytes equal a map of the saved closure,+by that material pin and slot. `--textures external` writes the images once as shared+`textures/<sha256>.<ext>` files beside a `.gltf`. See+[runtime textures](export-profiles.md#runtime-textures-manifest-and-shared-files).Physical repeat scale is recorded metadata. The author still chooses UV scale appropriate to themesh. Repeating a one-meter material across a ten-meter wall requires corresponding UV repeats;diff --git a/package.json b/package.jsonindex 727ba530..a44be1e5 100644--- a/package.json+++ b/package.json@@ -370,7 +370,8 @@"peerDependencies": {"@ai-sdk/provider": "^3.0.0","@strands-agents/sdk": "^1.18.0",- "@openrouter/ai-sdk-provider": "^2.10.0"+ "@openrouter/ai-sdk-provider": "^2.10.0",+ "ktx2-encoder": "0.6.0"},"overrides": {"sharp": "^0.35.5"@@ -384,6 +385,9 @@},"@openrouter/ai-sdk-provider": {"optional": true+ },+ "ktx2-encoder": {+ "optional": true}},"devDependencies": {@@ -396,6 +400,7 @@"@strands-agents/sdk": "1.21.0","@types/bun": "^1.4.2","ai": "^6.0.300",+ "ktx2-encoder": "0.6.0","openai": "^6.49.0","typescript": "^7.0.2"},diff --git a/scripts/build-viewer.mjs b/scripts/build-viewer.mjsindex a752f8d7..857d5036 100644--- a/scripts/build-viewer.mjs+++ b/scripts/build-viewer.mjs@@ -4,9 +4,18 @@ import { fileURLToPath } from 'node:url';import { dirname, join, resolve } from 'node:path';const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');await mkdir(join(root, 'dist/viewer'), { recursive: true });+// The viewer exports through asset-export, which lazily loads the Node-only KTX2 encoder+// (#201); the viewer never encodes KTX2, so that module stays out of the browser bundle.const result = spawnSync('bun',- ['build', 'src/viewer/app.ts', '--target=browser', '--minify', '--outfile=dist/viewer/app.js'],+ [+ 'build',+ 'src/viewer/app.ts',+ '--target=browser',+ '--minify',+ '--external=./ktx2-basis*',+ '--outfile=dist/viewer/app.js',+ ],{ cwd: root, stdio: 'inherit', windowsHide: true },);if (result.status !== 0) process.exit(result.status ?? 1);diff --git a/skills/kiln-author-asset/references/export-profiles.md b/skills/kiln-author-asset/references/export-profiles.mdindex 0df1335f..32025f08 100644--- a/skills/kiln-author-asset/references/export-profiles.md+++ b/skills/kiln-author-asset/references/export-profiles.md@@ -94,9 +94,30 @@ node kiln.mjs export ASSET_ID REVISION_ID --profile runtime --out mech.glb# Optional Three.js derivative, with a machine-readable export receipt.node kiln.mjs export ASSET_ID REVISION_ID --profile runtime --target three --out mech-three.glb --json++# Optional texture identities in the sidecar (any runtime export).+node kiln.mjs export ASSET_ID REVISION_ID --profile runtime --textures manifest --out mech.glb++# Optional shared textures: JSON glTF plus textures/<sha256>.<ext> files.+node kiln.mjs export ASSET_ID REVISION_ID --profile runtime --target three --textures external --out assets/mech.gltf --json```-Runtime requires GLB format and an output ending in `.glb`. Bundle/source formats+Both texture options are opt-in; without them the runtime files are unchanged. The+manifest lists each image's exact `sha256`, size, colour space and, when its bytes equal+a saved library map, that material pin. External textures are named by the hash of their+bytes: exports into one folder share them, an identical existing file is reused (`reused:+true` in the receipt), a different one stops the export, and nothing ever replaces or+removes a texture. Deliver the `.gltf`, `.bin`, sidecar and `textures/` together.++`--ktx2` (with `--target three`) encodes textures to KTX2 only when the optional peer is+installed (`npm install [email protected]`); without it the export fails and names that+command. Colour maps use ETC1S, normal and data maps UASTC, and an image shared by a+colour and a data slot is refused. The sidecar's `delivery.ktx2.encoder` and the receipt+record the encoder version and settings. The consumer then needs `KTX2Loader` as well as+the Meshopt decoder. Use it only when the destination asks for KTX2.++Runtime requires GLB format and an output ending in `.glb`, except `--textures external`,+which writes `.gltf` (see runtime textures). Bundle/source formatsuse `editable`. Use a portable filename stem containing ASCII letters, digits,periods, underscores or hyphens, beginning with a letter or digit. The generatedsidecar filename must be at most 200 characters; Windows device names are rejected.diff --git a/src/__tests__/runtime-three-export.test.ts b/src/__tests__/runtime-three-export.test.tsindex 7e6eb517..b8a3d513 100644--- a/src/__tests__/runtime-three-export.test.ts+++ b/src/__tests__/runtime-three-export.test.ts@@ -9,6 +9,9 @@*/import { describe, expect, test } from 'bun:test';import { createHash } from 'node:crypto';+import { readFileSync } from 'node:fs';+import { resolve } from 'node:path';+import { Document, WebIO } from '@gltf-transform/core';import * as THREE from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';import { MeshoptDecoder } from 'three/addons/libs/meshopt_decoder.module.js';@@ -17,6 +20,11 @@ import type { AssetRecord } from '../assets';import { KILN_REPEAT_INSTANCES_KEY, repeatInstances } from '../delivery';import { buildSandboxGlobals } from '../primitives';import { renderGLBInProcess, renderSceneToGLB } from '../render';+import { validateAtlasDocumentProvenance } from '../atlas-provenance';+import { createGltfIO } from '../gltf-io';+import { encodePng } from '../views/png';++const BUNKER = readFileSync(resolve('src/__tests__/fixtures/bunker-door-frame.kiln.js'), 'utf8');/** Bytes of the GLB's binary chunk: the geometry the compression acts on. */const binaryChunkBytes = (glb: Uint8Array) =>@@ -414,3 +422,100 @@ function build(){}});});++/** A KTX2 header with the identifier and pixel size; enough for the manifest to read. */+function fakeKtx2(width: number, height: number, marker = 0): Uint8Array {+ const bytes = new Uint8Array(80);+ bytes.set([0xab, 0x4b, 0x54, 0x58, 0x20, 0x32, 0x30, 0xbb, 0x0d, 0x0a, 0x1a, 0x0a]);+ const view = new DataView(bytes.buffer);+ view.setUint32(20, width, true);+ view.setUint32(24, height, true);+ bytes[79] = marker;+ return bytes;+}+/** Read a delivered GLB back as a glTF-Transform document. */+async function readDelivered(glb: Uint8Array) {+ await MeshoptDecoder.ready;+ return createGltfIO().registerDependencies({ 'meshopt.decoder': MeshoptDecoder }).readBinary(glb);+}+/** One triangle whose material uses `base` as base colour and `normal` as normal map. */+async function twoSlotGlb(shared: boolean) {+ const doc = new Document();+ const buffer = doc.createBuffer();+ const accessor = (type: 'VEC2' | 'VEC3', values: number[]) =>+ doc.createAccessor().setType(type).setArray(new Float32Array(values)).setBuffer(buffer);+ const png = (value: number) => new Uint8Array(encodePng(new Uint8Array(12).fill(value), 2, 2));+ const base = doc.createTexture('base').setImage(png(200)).setMimeType('image/png');+ const normal = shared+ ? base+ : doc.createTexture('normal').setImage(png(128)).setMimeType('image/png');+ const primitive = doc+ .createPrimitive()+ .setAttribute('POSITION', accessor('VEC3', [0, 0, 0, 1, 0, 0, 0, 1, 0]))+ .setAttribute('TEXCOORD_0', accessor('VEC2', [0, 0, 1, 0, 0, 1]))+ .setMaterial(doc.createMaterial('M').setBaseColorTexture(base).setNormalTexture(normal));+ doc+ .createScene('S')+ .addChild(doc.createNode('N').setMesh(doc.createMesh('N').addPrimitive(primitive)));+ return new WebIO().writeBinary(doc);+}++describe('KTX2 encoding through the hook', () => {+ test('atlas references are refreshed to the encoded KTX2 bytes and match the manifest', async () => {+ const rendered = await renderGLBInProcess(BUNKER);+ const source = new Uint8Array(rendered.glb);+ const output = await exportAssetGlb(assetRecord(source), {+ profile: 'runtime',+ target: 'three',+ textures: 'manifest',+ ktx2Encoder: async ({ image }) => fakeKtx2(1024, 1024, image.byteLength % 251),+ });+ if (output.profile !== 'runtime') throw new Error('expected runtime');+ const metadata = JSON.parse(new TextDecoder().decode(output.metadata.bytes));+ expect(metadata.delivery.ktx2).toMatchObject({ status: 'encoded' });+ expect(metadata.delivery.preserved.lodChains).toBeGreaterThan(0);+ const doc = await readDelivered(output.glb);+ // Import validation accepts the delivered atlas: its final image identity is the KTX2.+ await validateAtlasDocumentProvenance(doc);+ const references = doc+ .getRoot()+ .listMaterials()+ .flatMap((material) => [material.getBaseColorTextureInfo()])+ .map((info) => info?.getExtras().kilnAtlasReference as Record<string, string> | undefined)+ .filter((reference) => reference !== undefined);+ expect(references.length).toBeGreaterThan(0);+ for (const reference of references) {+ const entry = metadata.textures.find(+ (candidate: { sha256: string }) => candidate.sha256 === reference.finalImageSha256,+ );+ expect(entry).toMatchObject({ mimeType: 'image/ktx2', width: 1024, height: 1024 });+ expect(reference.finalMime).toBe(entry.mimeType);+ expect(entry.sourceSha256).toMatch(/^sha256:[0-9a-f]{64}$/);+ expect(entry.sourceSha256).not.toBe(entry.sha256);+ }+ });++ test('the hook input names the slot and the output must carry the KTX2 identifier', async () => {+ const bytes = await twoSlotGlb(false);+ const calls: string[] = [];+ await deliverThreeRuntimeGlb(bytes, {+ ktx2Encoder: async ({ slot, colorSpace }) => {+ calls.push(`${slot}:${colorSpace}`);+ return fakeKtx2(2, 2);+ },+ });+ expect(calls).toEqual(['baseColor:srgb', 'normal:linear']);+ await expect(+ deliverThreeRuntimeGlb(bytes, { ktx2Encoder: async () => new Uint8Array(80) }),+ ).rejects.toThrow(/KTX2 identifier/);+ });++ test('an image used by both an sRGB and a linear slot cannot be encoded once', async () => {+ const bytes = await twoSlotGlb(true);+ // Without an encoder the image is delivered unchanged.+ expect((await deliverThreeRuntimeGlb(bytes)).delivery.ktx2.status).toBe('skipped');+ await expect(+ deliverThreeRuntimeGlb(bytes, { ktx2Encoder: async () => fakeKtx2(2, 2) }),+ ).rejects.toThrow(/both sRGB and linear/);+ });+});diff --git a/src/asset-cli-textures.test.ts b/src/asset-cli-textures.test.tsnew file mode 100644index 00000000..bb3cf199--- /dev/null+++ b/src/asset-cli-textures.test.ts@@ -0,0 +1,248 @@+/**+ * `kiln export --textures manifest|external` (#213): an opt-in sidecar manifest, and a `.gltf`+ * whose images are shared content-addressed files that a re-export never replaces.+ */+import { expect, test } from 'bun:test';+import { spawnSync } from 'node:child_process';+import { createHash } from 'node:crypto';+import { existsSync } from 'node:fs';+import { mkdtemp, readdir, readFile, rm, stat, writeFile } from 'node:fs/promises';+import { tmpdir } from 'node:os';+import { join, resolve } from 'node:path';+import { Document, WebIO } from '@gltf-transform/core';+import { encodePng } from './views/png';++const sha = (bytes: Uint8Array) => `sha256:${createHash('sha256').update(bytes).digest('hex')}`;++async function texturedGlb(): Promise<Uint8Array> {+ const doc = new Document();+ const buffer = doc.createBuffer();+ const accessor = (type: 'VEC2' | 'VEC3', values: number[]) =>+ doc.createAccessor().setType(type).setArray(new Float32Array(values)).setBuffer(buffer);+ const png = (rgb: number[]) => new Uint8Array(encodePng(new Uint8Array(rgb), 2, 2));+ const base = doc+ .createTexture('base')+ .setImage(png([200, 40, 40, 40, 200, 40, 40, 40, 200, 220, 220, 220]))+ .setMimeType('image/png');+ const normal = doc+ .createTexture('normal')+ .setImage(png(Array.from({ length: 4 }, () => [128, 128, 255]).flat()))+ .setMimeType('image/png');+ const primitive = doc+ .createPrimitive()+ .setAttribute('POSITION', accessor('VEC3', [0, 0, 0, 1, 0, 0, 0, 1, 0]))+ .setAttribute('TEXCOORD_0', accessor('VEC2', [0, 0, 1, 0, 0, 1]))+ .setMaterial(doc.createMaterial('Wall').setBaseColorTexture(base).setNormalTexture(normal));+ doc+ .createScene('Scene')+ .addChild(doc.createNode('Wall').setMesh(doc.createMesh('Wall').addPrimitive(primitive)));+ return new WebIO().writeBinary(doc);+}++test('CLI texture manifest and external content-addressed textures', async () => {+ const root = await mkdtemp(join(tmpdir(), 'kiln-asset-cli-textures-'));+ const run = (args: string[]) =>+ spawnSync(process.execPath, [resolve('src/cli.ts'), ...args], {+ cwd: root,+ env: {+ ...process.env,+ KILN_RENDER: 'cpu',+ KILN_PROGRAM_STORE: join(root, '.kiln', 'programs'),+ KILN_COLLECTIONS: JSON.stringify({ project: join(root, 'collection') }),+ },+ encoding: 'utf8',+ windowsHide: true,+ });+ try {+ const source = join(root, 'wall.glb');+ await writeFile(source, await texturedGlb());+ const imported = run(['import', source, '--name', 'Wall']);+ expect(imported.stderr).toBe('');+ const { assetId, revisionId } = JSON.parse(imported.stdout).assets[0];+ const exportArgs = (...args: string[]) => ['export', assetId, revisionId, ...args];++ // Manifest: the GLB layout is unchanged; the sidecar names every image.+ const manifestRun = run(+ exportArgs('--out', join(root, 'm.glb'), '--profile', 'runtime', '--textures', 'manifest'),+ );+ expect(manifestRun.stderr).toBe('');+ const manifest = JSON.parse(await readFile(join(root, 'm.kiln-metadata.json'), 'utf8'));+ expect(manifest.textures).toEqual([+ expect.objectContaining({ image: 0, colorSpace: 'srgb', mimeType: 'image/png' }),+ expect.objectContaining({ image: 1, colorSpace: 'linear', mimeType: 'image/png' }),+ ]);++ const external = (name: string) =>+ run(+ exportArgs(+ '--out',+ join(root, 'out', name),+ '--profile',+ 'runtime',+ '--target',+ 'three',+ '--textures',+ 'external',+ '--json',+ ),+ );+ const first = external('a.gltf');+ expect(first.stderr).toBe('');+ const receipt = JSON.parse(first.stdout);+ expect(receipt).toMatchObject({+ ok: true,+ profile: 'runtime',+ target: 'three',+ format: 'gltf',+ });+ const metadata = JSON.parse(await readFile(join(root, 'out', 'a.kiln-metadata.json'), 'utf8'));+ const textures = metadata.textures.map((entry: { uri: string }) =>+ join(root, 'out', ...entry.uri.split('/')),+ );+ expect(receipt.files).toEqual(+ await Promise.all(+ [+ ['gltf', join(root, 'out', 'a.gltf')],+ ['bin', join(root, 'out', 'a.bin')],+ ['metadata', join(root, 'out', 'a.kiln-metadata.json')],+ ...textures.map((path: string) => ['texture', path]),+ ].map(async ([kind, path]) => {+ const bytes = new Uint8Array(await readFile(path!));+ return {+ kind,+ path,+ bytes: bytes.length,+ sha256: sha(bytes),+ ...(kind === 'texture' ? { reused: false } : {}),+ };+ }),+ ),+ );+ const before = await Promise.all(textures.map((path: string) => stat(path)));++ // A second export into the same folder shares the texture files.+ const second = external('b.gltf');+ expect(second.stderr).toBe('');+ expect(+ JSON.parse(second.stdout)+ .files.filter(({ kind }: { kind: string }) => kind === 'texture')+ .map(({ reused }: { reused: boolean }) => reused),+ ).toEqual([true, true]);+ expect((await readdir(join(root, 'out', 'textures'))).length).toBe(2);+ expect((await readdir(join(root, 'out'))).sort()).toEqual([+ 'a.bin',+ 'a.gltf',+ 'a.kiln-metadata.json',+ 'b.bin',+ 'b.gltf',+ 'b.kiln-metadata.json',+ 'textures',+ ]);++ // A re-export never replaces a model file or a texture.+ const again = external('a.gltf');+ expect(again.status).toBe(1);+ expect(again.stderr).toContain('already exists and is never replaced');+ const after = await Promise.all(textures.map((path: string) => stat(path)));+ expect(after.map((entry) => entry.mtimeMs)).toEqual(before.map((entry) => entry.mtimeMs));++ for (const flags of [+ ['--out', join(root, 'bad.gltf'), '--profile', 'runtime', '--textures', 'external'],+ [+ '--out',+ join(root, 'bad.glb'),+ '--profile',+ 'runtime',+ '--target',+ 'three',+ '--textures',+ 'external',+ ],+ ['--out', join(root, 'bad.gltf'), '--profile', 'runtime', '--textures', 'manifest'],+ ['--out', join(root, 'bad.glb'), '--profile', 'editable', '--textures', 'manifest'],+ ['--out', join(root, 'bad.glb'), '--profile', 'runtime', '--textures', 'embedded'],+ ]) {+ const refused = run(exportArgs(...flags));+ expect(refused.status).toBe(1);+ }+ expect((await readdir(root)).filter((name) => name.startsWith('bad'))).toEqual([]);+ } finally {+ await rm(root, { recursive: true, force: true });+ }+}, 120_000); // Seven compiled-CLI runs; see asset-cli.test.ts for the measured range.++const peer = existsSync(resolve('node_modules/ktx2-encoder/package.json'));++test('CLI --ktx2 requires --target three and records the encoder in the sidecar and receipt', async () => {+ const root = await mkdtemp(join(tmpdir(), 'kiln-asset-cli-ktx2-'));+ const run = (args: string[]) =>+ spawnSync(process.execPath, [resolve('src/cli.ts'), ...args], {+ cwd: root,+ env: {+ ...process.env,+ KILN_RENDER: 'cpu',+ KILN_PROGRAM_STORE: join(root, '.kiln', 'programs'),+ KILN_COLLECTIONS: JSON.stringify({ project: join(root, 'collection') }),+ },+ encoding: 'utf8',+ windowsHide: true,+ });+ try {+ const source = join(root, 'wall.glb');+ await writeFile(source, await texturedGlb());+ const { assetId, revisionId } = JSON.parse(run(['import', source, '--name', 'Wall']).stdout)+ .assets[0];+ const exportArgs = (...args: string[]) => ['export', assetId, revisionId, ...args];+ for (const flags of [+ ['--profile', 'runtime', '--ktx2'],+ ['--profile', 'editable', '--format', 'glb', '--ktx2'],+ ]) {+ const refused = run(exportArgs('--out', join(root, 'bad.glb'), ...flags));+ expect(refused.status).toBe(1);+ expect(refused.stderr).toContain('--ktx2 requires --target three');+ }+ if (!peer) return;+ const encoded = run(+ exportArgs(+ '--out',+ join(root, 'k.glb'),+ '--profile',+ 'runtime',+ '--target',+ 'three',+ '--ktx2',+ '--textures',+ 'manifest',+ '--json',+ ),+ );+ expect(encoded.stderr).toBe('');+ // Stdout is the receipt alone: the encoder writes no progress there.+ const receipt = JSON.parse(encoded.stdout);+ const metadata = JSON.parse(await readFile(join(root, 'k.kiln-metadata.json'), 'utf8'));+ expect(metadata.delivery.ktx2).toEqual({+ status: 'encoded',+ textures: 2,+ encoder: {+ name: 'ktx2-encoder',+ version: '0.6.0',+ basisWasmSha256: expect.stringMatching(/^sha256:[0-9a-f]{64}$/),+ settings: expect.objectContaining({ srgb: expect.any(Object), linear: expect.any(Object) }),+ },+ });+ expect(receipt.ktx2).toEqual(metadata.delivery.ktx2);+ expect(metadata.delivery.extensionsRequired).toContain('KHR_texture_basisu');+ expect(+ metadata.textures.map((entry: { mimeType: string; colorSpace: string }) => [+ entry.mimeType,+ entry.colorSpace,+ ]),+ ).toEqual([+ ['image/ktx2', 'srgb'],+ ['image/ktx2', 'linear'],+ ]);+ for (const entry of metadata.textures) expect(entry.sourceSha256).toMatch(/^sha256:/);+ } finally {+ await rm(root, { recursive: true, force: true });+ }+}, 120_000); // Three compiled-CLI runs plus a WebAssembly encoder start.diff --git a/src/asset-cli.ts b/src/asset-cli.tsindex 303601ce..a89f910d 100644--- a/src/asset-cli.ts+++ b/src/asset-cli.ts@@ -8,8 +8,8 @@ import { ASSET_LIMIT, assetIdSchema, decodeAssetBundle } from './assets';import { localProgramStore } from './program-store-node';import { programRefPattern, retainProgram } from './program-store';import { createKilnProgramToolRegistry, newestRevision } from './tools/registry';-import { writeNewDestinationsAtomic } from './cli-output';-import { exportAssetGlb } from './asset-export';+import { writeExternalTextureExport, writeNewDestinationsAtomic } from './cli-output';+import { createKtx2Encoder, exportAssetGlb } from './asset-export';import { inspectDrawDiagnostics } from './draw-diagnostics';import { createPackagedLocalToolContext } from './local-runtime';import { buildRenderPort, resolveRenderMode } from './cli-render-mode';@@ -52,9 +52,14 @@ ${SAVE_LINES}kiln export <id> <revision> --out asset.zip [--format bundle|glb|source][--profile editable|runtime] runtime writes GLB + sibling metadata JSON[--target three] runtime only: meshopt + quantization, repeatInstances GPU- instancing, KTX2 skipped (no encoder); sidecar states node scales+ instancing; sidecar states node scales; KTX2 skipped unless --ktx2[--compression meshopt|none] with --target three: none writes plain buffersfor loaders without a Meshopt decoder (default meshopt)+ [--ktx2] with --target three: KTX2 through the optional [email protected] peer+ (npm install [email protected]), ETC1S colour, UASTC data maps+ [--textures manifest] runtime only: the sidecar names each image's exact bytes+ [--textures external] with --target three and --out x.gltf: x.gltf, x.bin and+ shared textures/<sha256>.<ext> files that are never replaced[--json] receipt naming each file with its bytes and sha256export never replaces an existing file: an export hands off one exactsaved revision, while render --out replaces its own working output@@ -94,6 +99,7 @@ export async function assetMain(argv: readonly string[]): Promise<number> {'profile','target','compression',+ 'textures','port','render','backdrop',@@ -128,6 +134,10 @@ export async function assetMain(argv: readonly string[]): Promise<number> {flags.json = 'true';continue;}+ if (arg === '--ktx2' && command === 'export') {+ flags.ktx2 = 'true';+ continue;+ }if (arg === '--restore' || arg === '--rebuild' || arg === '--no-project') {flags[arg.slice(2)] = 'true';continue;@@ -387,32 +397,88 @@ export async function assetMain(argv: readonly string[]): Promise<number> {throw new Error('--compression must be meshopt or none');if (compression !== undefined && target !== 'three')throw new Error('--compression requires --target three');- const format = flags.format ?? (profile === 'runtime' ? 'glb' : 'bundle');- if (!['bundle', 'glb', 'source'].includes(format)) throw new Error('Unknown export format');- const written: { kind: string; path: string; data: Uint8Array }[] = [];+ const textures = flags.textures;+ if (textures !== undefined && textures !== 'manifest' && textures !== 'external')+ throw new Error('Unknown --textures value; use manifest or external');+ if (textures !== undefined && profile !== 'runtime')+ throw new Error('--textures requires --profile runtime');+ if (textures === 'external' && target !== 'three')+ throw new Error('--textures external requires --target three');+ if (flags.ktx2 && (target !== 'three' || profile !== 'runtime'))+ throw new Error('--ktx2 requires --target three with --profile runtime');+ const gltfLayout = textures === 'external';+ const format =+ flags.format ?? (profile === 'runtime' ? (gltfLayout ? 'gltf' : 'glb') : 'bundle');+ if (!['bundle', 'glb', 'source', 'gltf'].includes(format))+ throw new Error('Unknown export format');+ if (format === 'gltf' && !gltfLayout)+ throw new Error('gltf format requires --textures external');+ const written: { kind: string; path: string; data: Uint8Array; reused?: boolean }[] = [];+ let drawGlb: Uint8Array | undefined;+ let ktx2Receipt: unknown;if (profile === 'runtime') {- if (format !== 'glb')- throw new Error('Runtime profile requires GLB format; use editable for source or bundle');+ if (format !== (gltfLayout ? 'gltf' : 'glb'))+ throw new Error(+ gltfLayout+ ? '--textures external writes gltf format'+ : 'Runtime profile requires GLB format; use editable for source or bundle',+ );const destination = resolve(flags.out);- if (!destination.toLowerCase().endsWith('.glb'))- throw new Error('Runtime output must end in .glb');- const metadataFileName = `${basename(destination).slice(0, -4)}.kiln-metadata.json`;+ const extension = gltfLayout ? '.gltf' : '.glb';+ if (!destination.toLowerCase().endsWith(extension))+ throw new Error(`Runtime output must end in ${extension}`);+ const stem = basename(destination).slice(0, -extension.length);+ const metadataFileName = `${stem}.kiln-metadata.json`;const output = await exportAssetGlb(record, {profile,metadataFileName,...(target ? { target } : {}),...(compression ? { compression } : {}),+ ...(textures ? { textures } : {}),+ ...(gltfLayout ? { gltfFileName: basename(destination) } : {}),+ ...(flags.ktx2 ? { ktx2Encoder: await createKtx2Encoder() } : {}),});if (output.profile !== 'runtime') throw new Error('Expected runtime export');const metadataPath = resolve(dirname(destination), output.metadata.name);- await writeNewDestinationsAtomic([- { path: metadataPath, data: output.metadata.bytes },- { path: destination, data: output.glb },- ]);- written.push(- { kind: 'glb', path: destination, data: output.glb },- { kind: 'metadata', path: metadataPath, data: output.metadata.bytes },- );+ drawGlb = output.glb;+ if (flags.ktx2)+ ktx2Receipt = JSON.parse(new TextDecoder().decode(output.metadata.bytes)).delivery?.ktx2;+ if (output.layout === 'gltf') {+ const directory = dirname(destination);+ const files = output.textures.map(({ uri, bytes }) => ({+ path: resolve(directory, ...uri.split('/')),+ data: bytes,+ }));+ const buffers = output.buffers.map(({ uri, bytes }) => ({+ path: resolve(directory, uri),+ data: bytes,+ }));+ const published = await writeExternalTextureExport(files, [+ { path: metadataPath, data: output.metadata.bytes },+ ...buffers,+ { path: destination, data: output.gltf.bytes },+ ]);+ written.push(+ { kind: 'gltf', path: destination, data: output.gltf.bytes },+ ...buffers.map(({ path, data }) => ({ kind: 'bin', path, data })),+ { kind: 'metadata', path: metadataPath, data: output.metadata.bytes },+ ...files.map(({ path, data }, index) => ({+ kind: 'texture',+ path,+ data,+ reused: published[index]!.reused,+ })),+ );+ } else {+ await writeNewDestinationsAtomic([+ { path: metadataPath, data: output.metadata.bytes },+ { path: destination, data: output.glb },+ ]);+ written.push(+ { kind: 'glb', path: destination, data: output.glb },+ { kind: 'metadata', path: metadataPath, data: output.metadata.bytes },+ );+ }} else {const bytes =format === 'bundle'@@ -423,7 +489,10 @@ export async function assetMain(argv: readonly string[]): Promise<number> {await writeNewDestinationsAtomic([{ path: destination, data: bytes }]);written.push({ kind: format, path: destination, data: bytes });}- if (!flags.json) console.log(written.map(({ path }) => `Saved ${path}`).join('\n'));+ if (!flags.json)+ console.log(+ written.map(({ path, reused }) => `${reused ? 'Reused' : 'Saved'} ${path}`).join('\n'),+ );elseconsole.log(JSON.stringify(@@ -436,19 +505,22 @@ export async function assetMain(argv: readonly string[]): Promise<number> {...(target ? { target } : {}),...(compression ? { compression } : {}),format,+ ...(ktx2Receipt ? { ktx2: ktx2Receipt } : {}),...(format !== 'source'? {drawDiagnostics: await inspectDrawDiagnostics(- written.find(({ kind }) => kind === 'glb')?.data ??+ drawGlb ??+ written.find(({ kind }) => kind === 'glb')?.data ??record.files['asset.glb']!,),}: {}),- files: written.map(({ kind, path, data }) => ({+ files: written.map(({ kind, path, data, reused }) => ({kind,path,bytes: data.byteLength,sha256: `sha256:${createHash('sha256').update(data).digest('hex')}`,+ ...(reused === undefined ? {} : { reused }),})),},null,diff --git a/src/asset-export-textures.test.ts b/src/asset-export-textures.test.tsnew file mode 100644index 00000000..00ed06b1--- /dev/null+++ b/src/asset-export-textures.test.ts@@ -0,0 +1,366 @@+/**+ * Runtime texture manifest and content-addressed external textures (#213).+ *+ * The fixture GLB is built with glTF-Transform from two fixed PNGs, so its bytes depend only+ * on pinned packages, never on Kiln's renderer.+ */+import { expect, test } from 'bun:test';+import { createHash } from 'node:crypto';+import { Document, WebIO } from '@gltf-transform/core';+import { validateBytes } from 'gltf-validator';+import { LoadingManager } from 'three';+import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { MeshoptDecoder } from 'three/addons/libs/meshopt_decoder.module.js';+import { exportAssetGlb } from './asset-export';+import type { AssetRecord } from './assets';+import { canonicalMaterialJson, type MaterialManifestV1 } from './material-library';++const sha = (bytes: Uint8Array) => `sha256:${createHash('sha256').update(bytes).digest('hex')}`;+const BASE_PNG = new Uint8Array(+ Buffer.from(+ 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAFklEQVR4nGM4oaGhcUKDQUPjxJ07dwAhpgXd58qIBQAAAABJRU5ErkJggg==',+ 'base64',+ ),+);+const NORMAL_PNG = new Uint8Array(+ Buffer.from(+ 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAEklEQVR4nGNoaPjf0PCfAUIBADX2B/1D9pjhAAAAAElFTkSuQmCC',+ 'base64',+ ),+);++/** One textured triangle: base colour then normal map, in that image order. */+async function texturedGlb(): Promise<Uint8Array> {+ const doc = new Document();+ const buffer = doc.createBuffer();+ const position = doc+ .createAccessor()+ .setType('VEC3')+ .setArray(new Float32Array([0, 0, 0, 1, 0, 0, 0, 1, 0]))+ .setBuffer(buffer);+ const uv = doc+ .createAccessor()+ .setType('VEC2')+ .setArray(new Float32Array([0, 0, 1, 0, 0, 1]))+ .setBuffer(buffer);+ const base = doc.createTexture('base').setImage(BASE_PNG).setMimeType('image/png');+ const normal = doc.createTexture('normal').setImage(NORMAL_PNG).setMimeType('image/png');+ const material = doc.createMaterial('Brick').setBaseColorTexture(base).setNormalTexture(normal);+ const primitive = doc+ .createPrimitive()+ .setAttribute('POSITION', position)+ .setAttribute('TEXCOORD_0', uv)+ .setMaterial(material);+ const node = doc.createNode('Tri').setMesh(doc.createMesh('Tri').addPrimitive(primitive));+ doc.createScene('Scene').addChild(node);+ return new WebIO().writeBinary(doc);+}++function texturedRecord(assetId: string, glb: Uint8Array): AssetRecord {+ return {+ manifest: {+ version: 'kiln.asset.v1',+ assetId,+ revisionId: `r_${assetId}`,+ name: assetId,+ tags: [],+ createdAt: '2026-10-22T00:00:00.000Z',+ editable: false,+ files: { 'asset.glb': { bytes: glb.length, sha256: sha(glb) as `sha256:${string}` } },+ },+ files: { 'asset.glb': glb },+ };+}++test('without a texture option, runtime and three exports keep their pre-manifest bytes', async () => {+ const record = texturedRecord('a_tex', await texturedGlb());+ const plain = await exportAssetGlb(record, { profile: 'runtime' });+ const three = await exportAssetGlb(record, { profile: 'runtime', target: 'three' });+ if (plain.profile !== 'runtime' || three.profile !== 'runtime') throw new Error('runtime');+ // Recorded on main before the manifest existed (2026-10-22): the default stays byte-identical.+ expect({+ plainGlb: sha(plain.glb),+ plainMetadata: sha(plain.metadata.bytes),+ threeGlb: sha(three.glb),+ threeMetadata: sha(three.metadata.bytes),+ }).toEqual({+ plainGlb: 'sha256:975e9ee4580d90ea61948ee28da42494c78b89e61ced4c79c6ebc4f4fea961e3',+ plainMetadata: 'sha256:cb34dde89a001478c04fa165c2eb64197b9cd490de2f50266425b9dc8cd1a44b',+ threeGlb: 'sha256:159cf047413a6501ed0e4dd75e418bc78c961b6022ef38ccb8ac2e8381fde09f',+ threeMetadata: 'sha256:9f8a384e00f85511c3a7f7ce70951943722cf35aa96e2b9c9854a32975233385',+ });+});++/** A library material whose two maps are exactly the fixture PNGs. */+function brickMaterial(): MaterialManifestV1 {+ const license = {+ spdx: 'CC0-1.0',+ url: 'https://creativecommons.org/publicdomain/zero/1.0/',+ attribution: '',+ };+ const map = (slot: 'baseColor' | 'normal', png: Uint8Array) =>+ ({+ slot,+ file: `${slot}.png`,+ sha256: sha(png),+ bytes: png.length,+ width: 2,+ height: 2,+ usage: slot === 'baseColor' ? 'albedo' : 'normal',+ colorSpace: slot === 'baseColor' ? 'srgb' : 'linear',+ ...(slot === 'normal' ? { normalConvention: 'opengl' } : {}),+ sourceId: 'scan',+ originalFile: `${slot}.png`,+ transforms: [],+ }) as MaterialManifestV1['maps'][number];+ const body = {+ schemaVersion: 1 as const,+ materialId: 'brick',+ name: 'Brick',+ tags: [],+ tileable: true,+ parameters: {+ roughness: 1,+ metalness: 0,+ emissiveIntensity: 1,+ alphaMode: 'opaque' as const,+ alphaCutoff: 0.5,+ doubleSided: false,+ },+ sources: [+ {+ id: 'scan',+ kind: 'external' as const,+ provider: 'Test',+ creator: 'Test',+ assetUrl: 'https://example.com/brick',+ license,+ originalFiles: [+ { name: 'baseColor.png', bytes: BASE_PNG.length, sha256: sha(BASE_PNG) },+ { name: 'normal.png', bytes: NORMAL_PNG.length, sha256: sha(NORMAL_PNG) },+ ],+ },+ ],+ maps: [map('baseColor', BASE_PNG), map('normal', NORMAL_PNG)],+ };+ return { ...body, revisionId: sha(new TextEncoder().encode(canonicalMaterialJson(body))) };+}++function withMaterial(record: AssetRecord, manifest: MaterialManifestV1): AssetRecord {+ record.manifest.build = {+ engine: 'test',+ options: {},+ warnings: [],+ rebuild: 'external-dependencies-required',+ dependencies: [{ kind: 'kiln.material.v1', delivery: 'runtime', manifest }],+ };+ record.materialResources = {+ schemaVersion: 1,+ records: [+ {+ manifest,+ files: {+ 'baseColor.png': Buffer.from(BASE_PNG).toString('base64'),+ 'normal.png': Buffer.from(NORMAL_PNG).toString('base64'),+ },+ },+ ],+ };+ return record;+}++const sidecar = (bytes: Uint8Array) => JSON.parse(new TextDecoder().decode(bytes));++for (const target of [undefined, 'three'] as const)+ test(`texture manifest names exact image bytes and library pins (${target ?? 'plain'} runtime)`, async () => {+ const glb = await texturedGlb();+ const material = brickMaterial();+ const pin = {+ resourceId: 'brick',+ revisionId: material.revisionId,+ sha256: material.revisionId,+ };+ const manifests = [];+ for (const assetId of ['a_wall', 'a_floor']) {+ const output = await exportAssetGlb(withMaterial(texturedRecord(assetId, glb), material), {+ profile: 'runtime',+ textures: 'manifest',+ ...(target ? { target } : {}),+ });+ if (output.profile !== 'runtime') throw new Error('runtime');+ const metadata = sidecar(output.metadata.bytes);+ // The provenance hash binds the GLB to the sidecar that carries the manifest.+ const stamped = JSON.parse(+ new TextDecoder().decode(+ output.glb.subarray(+ 20,+ 20 + new DataView(output.glb.buffer, output.glb.byteOffset).getUint32(12, true),+ ),+ ),+ ).asset.extras.kilnProvenanceV1;+ expect(stamped.metadata.sha256).toBe(sha(output.metadata.bytes));+ manifests.push(metadata.textures);+ }+ expect(manifests[0]).toEqual([+ {+ image: 0,+ sha256: sha(BASE_PNG),+ bytes: BASE_PNG.length,+ mimeType: 'image/png',+ width: 2,+ height: 2,+ colorSpace: 'srgb',+ material: { pin, slot: 'baseColor' },+ },+ {+ image: 1,+ sha256: sha(NORMAL_PNG),+ bytes: NORMAL_PNG.length,+ mimeType: 'image/png',+ width: 2,+ height: 2,+ colorSpace: 'linear',+ material: { pin, slot: 'normal' },+ },+ ]);+ // Two assets that use one library material share one identity per image.+ expect(manifests[1]).toEqual(manifests[0]);+ });++test('texture manifest without a material closure carries no pin, and options are validated', async () => {+ const record = texturedRecord('a_bare', await texturedGlb());+ const output = await exportAssetGlb(record, { profile: 'runtime', textures: 'manifest' });+ if (output.profile !== 'runtime') throw new Error('runtime');+ expect(+ sidecar(output.metadata.bytes).textures.map((entry: { material?: unknown }) => entry.material),+ ).toEqual([undefined, undefined]);+ await expect(exportAssetGlb(record, { textures: 'manifest' })).rejects.toThrow(/runtime/);+ await expect(+ exportAssetGlb(record, { profile: 'runtime', textures: 'external' }),+ ).rejects.toThrow(/target three/);+ await expect(+ exportAssetGlb(record, { profile: 'runtime', textures: 'embedded' as never }),+ ).rejects.toThrow(/texture/i);+});++test('external textures write JSON glTF with content-addressed images that validators and GLTFLoader resolve', async () => {+ const record = withMaterial(texturedRecord('a_ext', await texturedGlb()), brickMaterial());+ const names = { metadataFileName: 'wall.kiln-metadata.json' };+ const output = await exportAssetGlb(record, {+ profile: 'runtime',+ target: 'three',+ textures: 'external',+ gltfFileName: 'wall.gltf',+ ...names,+ });+ if (output.profile !== 'runtime' || output.layout !== 'gltf') throw new Error('gltf layout');+ const uris = [BASE_PNG, NORMAL_PNG].map((png) => `textures/${sha(png).slice(7)}.png`);+ const metadata = sidecar(output.metadata.bytes);+ expect(metadata.textures.map((entry: { uri: string }) => entry.uri)).toEqual(uris);+ expect(output.textures.map(({ uri }) => uri)).toEqual(uris);+ expect(output.textures.map(({ bytes }) => sha(bytes))).toEqual([sha(BASE_PNG), sha(NORMAL_PNG)]);+ expect(output.buffers.map(({ uri }) => uri)).toEqual(['wall.bin']);+ const json = JSON.parse(new TextDecoder().decode(output.gltf.bytes));+ expect(output.gltf.name).toBe('wall.gltf');+ expect(json.images.map((image: { uri: string }) => image.uri)).toEqual(uris);+ expect(json.images.some((image: object) => 'bufferView' in image)).toBe(false);+ expect(json.asset.extras.kilnProvenanceV1).toEqual({+ version: 'kiln.provenance.v1',+ profile: 'runtime',+ target: 'three',+ metadata: { uri: 'wall.kiln-metadata.json', sha256: sha(output.metadata.bytes) },+ });+ // The embedded form names the same images; only the content addresses are added.+ const embedded = await exportAssetGlb(record, {+ profile: 'runtime',+ target: 'three',+ textures: 'manifest',+ ...names,+ });+ if (embedded.profile !== 'runtime') throw new Error('runtime');+ expect(sidecar(embedded.metadata.bytes).textures).toEqual(+ metadata.textures.map(({ uri: _uri, ...entry }: { uri: string }) => entry),+ );+ // Deterministic for the same input.+ const again = await exportAssetGlb(record, {+ profile: 'runtime',+ target: 'three',+ textures: 'external',+ gltfFileName: 'wall.gltf',+ ...names,+ });+ if (again.profile !== 'runtime' || again.layout !== 'gltf') throw new Error('gltf layout');+ expect(again.gltf.bytes).toEqual(output.gltf.bytes);+ expect(again.metadata.bytes).toEqual(output.metadata.bytes);++ const files = new Map(+ [...output.buffers, ...output.textures].map(({ uri, bytes }) => [uri, bytes] as const),+ );+ const resource = async (uri: string) => {+ const bytes = files.get(decodeURIComponent(uri));+ if (!bytes) throw new Error(`missing ${uri}`);+ return bytes;+ };+ const report = (await validateBytes(output.gltf.bytes, {+ uri: 'wall.gltf',+ externalResourceFunction: resource,+ })) as { issues: { numErrors: number }; info: { resources: { uri?: string }[] } };+ expect(report.issues.numErrors).toBe(0);+ // The validator read the buffer and both images through their relative URIs.+ expect(report.info.resources.map(({ uri }) => uri).filter(Boolean)).toEqual(+ expect.arrayContaining(['wall.bin', ...uris]),+ );++ await MeshoptDecoder.ready;+ const requested: string[] = [];+ const manager = new LoadingManager();+ manager.setURLModifier((url) => {+ const path = url.replace(/^\.\//, '');+ requested.push(path);+ const bytes = files.get(path);+ if (!bytes) throw new Error(`Unexpected resource request ${url}`);+ return `data:application/octet-stream;base64,${Buffer.from(bytes).toString('base64')}`;+ });+ // Node has no image decoder: GLTFLoader reports each texture and loads the geometry.+ // FileLoader reports progress with the DOM ProgressEvent, which Bun does not define.+ const errors = console.error;+ const scope = globalThis as { ProgressEvent?: unknown };+ const progress = scope.ProgressEvent;+ scope.ProgressEvent ??= class extends Event {};+ console.error = () => {};+ try {+ const loaded = await new GLTFLoader(manager)+ .setMeshoptDecoder(MeshoptDecoder)+ .parseAsync(new TextDecoder().decode(output.gltf.bytes), './');+ expect(loaded.scene.getObjectByName('Tri')).toBeDefined();+ } finally {+ console.error = errors;+ scope.ProgressEvent = progress;+ }+ expect([...new Set(requested)].sort()).toEqual(['wall.bin', ...uris].sort());+});++test('external textures combine with compression none: plain buffers, same content-addressed images', async () => {+ const record = withMaterial(texturedRecord('a_plain', await texturedGlb()), brickMaterial());+ const output = await exportAssetGlb(record, {+ profile: 'runtime',+ target: 'three',+ compression: 'none',+ textures: 'external',+ gltfFileName: 'wall.gltf',+ metadataFileName: 'wall.kiln-metadata.json',+ });+ if (output.profile !== 'runtime' || output.layout !== 'gltf') throw new Error('gltf layout');+ const json = JSON.parse(new TextDecoder().decode(output.gltf.bytes));+ expect(json.extensionsUsed ?? []).not.toContain('EXT_meshopt_compression');+ expect(sidecar(output.metadata.bytes).delivery.compression).toEqual({ extension: 'none' });+ expect(output.textures.map(({ bytes }) => sha(bytes))).toEqual([sha(BASE_PNG), sha(NORMAL_PNG)]);+ const files = new Map(+ [...output.buffers, ...output.textures].map(({ uri, bytes }) => [uri, bytes] as const),+ );+ const report = (await validateBytes(output.gltf.bytes, {+ uri: 'wall.gltf',+ externalResourceFunction: async (uri: string) => files.get(decodeURIComponent(uri))!,+ })) as { issues: { numErrors: number } };+ expect(report.issues.numErrors).toBe(0);+});diff --git a/src/asset-export.ts b/src/asset-export.tsindex 81628a73..0b02ee13 100644--- a/src/asset-export.ts+++ b/src/asset-export.ts@@ -2,11 +2,43 @@* Saved-asset delivery profiles. No renderer, filesystem, or network dependencies; the* three.js runtime target loads its glTF passes and the meshopt encoder lazily.*/-import { ASSET_LIMIT, validateRecordShape, type AssetRecord } from './assets';-import type { RuntimeThreeDeliveryV1, RuntimeThreeOptionsV1 } from './runtime-three';+import {+ ASSET_LIMIT,+ assetMaterialRootManifests,+ validateRecordShape,+ type AssetRecord,+} from './assets';+import type { MaterialManifest } from './material-library';+import type {+ RuntimeThreeDeliveryV1,+ RuntimeThreeKtx2EncoderIdentityV1,+ RuntimeThreeKtx2EncoderV1,+ RuntimeThreeOptionsV1,+ RuntimeThreeResult,+} from './runtime-three';+import {+ runtimeTextureManifest,+ sha256Hex,+ textureFileExtension,+ type RuntimeTextureManifestEntryV1,+ type RuntimeTextureMaterialMapV1,+} from './runtime-textures';-export type { RuntimeThreeDeliveryV1, RuntimeThreeOptionsV1 } from './runtime-three';+export type {+ RuntimeThreeDeliveryV1,+ RuntimeThreeKtx2EncoderIdentityV1,+ RuntimeThreeKtx2EncoderV1,+ RuntimeThreeKtx2InputV1,+ RuntimeThreeKtx2SlotV1,+ RuntimeThreeOptionsV1,+} from './runtime-three';+export type { RuntimeTextureManifestEntryV1 } from './runtime-textures';export type AssetExportProfile = 'editable' | 'runtime';+/**+ * Runtime only, opt-in. `manifest` adds sidecar `textures[]`; `external` (three target only)+ * also writes JSON glTF whose images are content-addressed files `textures/<sha256>.<ext>`.+ */+export type AssetExportTextures = 'manifest' | 'external';/** Runtime delivery target; `three` adds meshopt, quantization, instancing and optional KTX2. */export type AssetExportTarget = 'three';export interface AssetGlbExportOptions extends RuntimeThreeOptionsV1 {@@ -16,10 +48,32 @@ export interface AssetGlbExportOptions extends RuntimeThreeOptionsV1 {metadataFileName?: string;/** Runtime only: derive for a three.js application (see docs/export-profiles.md). */target?: AssetExportTarget;+ /** Runtime only, opt-in: a texture manifest, or external content-addressed textures. */+ textures?: AssetExportTextures;+ /** External textures only: a portable sibling `*.gltf` filename. */+ gltfFileName?: string;}export type AssetGlbExport =| { profile: 'editable'; glb: Uint8Array }- | { profile: 'runtime'; glb: Uint8Array; metadata: { name: string; bytes: Uint8Array } };+ | {+ profile: 'runtime';+ layout?: undefined;+ glb: Uint8Array;+ metadata: { name: string; bytes: Uint8Array };+ }+ | {+ profile: 'runtime';+ /** `textures: 'external'`: the delivery is `gltf`, `buffers`, `textures` and `metadata`. */+ layout: 'gltf';+ /** The same delivery embedded as GLB, for inspection; it is not part of the layout. */+ glb: Uint8Array;+ gltf: { name: string; bytes: Uint8Array };+ /** Buffers beside the `.gltf`, by relative URI. */+ buffers: { uri: string; bytes: Uint8Array }[];+ /** Content-addressed images, by relative URI `textures/<hex>.<ext>`, once each. */+ textures: { uri: string; sha256: string; bytes: Uint8Array }[];+ metadata: { name: string; bytes: Uint8Array };+ };export interface RuntimeMetadataV1 {version: 'kiln.runtime-metadata.v1';@@ -34,6 +88,8 @@ export interface RuntimeMetadataV1 {target?: AssetExportTarget;/** Quantization, node-scale, attribute, instancing and extension facts of that target. */delivery?: RuntimeThreeDeliveryV1;+ /** Opt-in texture manifest: each delivered image's exact identity, by image index. */+ textures?: RuntimeTextureManifestEntryV1[];}const encoder = new TextEncoder();@@ -59,6 +115,53 @@ export function validateMetadataFileName(name: string): void {);}+/** Validate before writing: a portable sibling `*.gltf` filename. */+export function validateGltfFileName(name: string): void {+ if (+ name.length > 200 ||+ !/^[a-z0-9][a-z0-9._-]*\.gltf$/i.test(name) ||+ /^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(name)+ )+ throw new Error('External texture output must be a portable sibling *.gltf filename');+}++/** The GLB binary chunk's data, when present. */+function readGlbBinary(bytes: Uint8Array, jsonEnd: number): Uint8Array | undefined {+ if (jsonEnd + 8 > bytes.length) return undefined;+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);+ if (view.getUint32(jsonEnd + 4, true) !== 0x004e4942) return undefined;+ return bytes.subarray(jsonEnd + 8, jsonEnd + 8 + view.getUint32(jsonEnd, true));+}++/** Every map of the record's saved material closure, in a stable order, keyed by its bytes. */+function closureMaps(record: AssetRecord): RuntimeTextureMaterialMapV1[] {+ const manifests = new Map<string, MaterialManifest>();+ for (const manifest of [+ ...assetMaterialRootManifests(record),+ ...(record.materialResources?.records ?? []).map(({ manifest }) => manifest),+ ])+ manifests.set(`${manifest.materialId}/${manifest.revisionId}`, manifest);+ const order = (value: string, other: string) => (value < other ? -1 : value > other ? 1 : 0);+ return [...manifests.values()]+ .flatMap((manifest) =>+ manifest.maps.map((map) => ({+ sha256: map.sha256,+ pin: {+ resourceId: manifest.materialId,+ revisionId: manifest.revisionId,+ sha256: manifest.revisionId,+ },+ slot: map.slot,+ })),+ )+ .sort(+ (a, b) =>+ order(a.pin.resourceId, b.pin.resourceId) ||+ order(a.pin.revisionId, b.pin.revisionId) ||+ order(a.slot, b.slot),+ );+}+function readGlbJson(bytes: Uint8Array): { json: Record<string, unknown>; jsonEnd: number } {const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);let end = 12;@@ -97,12 +200,32 @@ export async function deliverThreeRuntimeGlb(glb: Uint8Array,options: RuntimeThreeOptionsV1 = {},): Promise<{ glb: Uint8Array; delivery: RuntimeThreeDeliveryV1 }> {+ const { glb: derived, delivery } = await deriveThree(glb, options);+ return { glb: derived, delivery };+}+/**+ * A `ktx2Encoder` over the optional `[email protected]` peer, which the caller installs:+ * ETC1S for base colour and emissive, UASTC for normal and other linear maps. Its identity+ * (name, version, Basis WebAssembly hash, settings) lands in `delivery.ktx2.encoder`. Loaded+ * lazily; a missing peer fails with the install command.+ */+export async function createKtx2Encoder(): Promise<+ RuntimeThreeKtx2EncoderV1 & { identity: RuntimeThreeKtx2EncoderIdentityV1 }+> {+ const { createKtx2Encoder: create } = await import('./ktx2-basis');+ return create();+}+async function deriveThree(+ glb: Uint8Array,+ options: RuntimeThreeOptionsV1,+ layout: { gltfBasename?: string } = {},+): Promise<RuntimeThreeResult> {const [{ deliverRuntimeThreeGlb }, { MeshoptEncoder }] = await Promise.all([import('./runtime-three'),import('meshoptimizer'),]);await MeshoptEncoder.ready;- const result = await deliverRuntimeThreeGlb(glb, MeshoptEncoder, options);+ const result = await deliverRuntimeThreeGlb(glb, MeshoptEncoder, options, layout);if (result.glb.byteLength > ASSET_LIMIT) throw new Error('Runtime export exceeds 64 MiB');return result;}@@ -124,6 +247,15 @@ export async function exportAssetGlb(throw new Error('A runtime export target requires the runtime profile');if (options.compression !== undefined && options.target !== 'three')throw new Error('Runtime compression requires the three runtime target');+ const textures = options.textures;+ if (textures !== undefined && textures !== 'manifest' && textures !== 'external')+ throw new Error('Unknown runtime texture option');+ if (textures !== undefined && profile !== 'runtime')+ throw new Error('A texture manifest requires the runtime profile');+ if (textures === 'external' && options.target !== 'three')+ throw new Error('External textures require target three');+ const gltfName = options.gltfFileName ?? 'runtime.gltf';+ if (textures === 'external') validateGltfFileName(gltfName);validateRecordShape(record);const bytes = record.files['asset.glb']!;if (profile === 'editable') return { profile, glb: bytes };@@ -175,29 +307,97 @@ export async function exportAssetGlb(// The three target derives from the review-free GLB; provenance is stamped on its result.let base = bytes,baseJson: Record<string, unknown> = json,- baseJsonEnd = jsonEnd;+ baseJsonEnd = jsonEnd,+ imageSources: ReadonlyMap<number, string> | undefined,+ gltf: RuntimeThreeResult['gltf'];if (options.target === 'three') {- const derived = await deliverThreeRuntimeGlb(writeGlbJson(bytes, jsonEnd, json), {- ...(options.ktx2Encoder ? { ktx2Encoder: options.ktx2Encoder } : {}),- ...(options.compression ? { compression: options.compression } : {}),- });+ const derived = await deriveThree(+ writeGlbJson(bytes, jsonEnd, json),+ {+ ...(options.ktx2Encoder ? { ktx2Encoder: options.ktx2Encoder } : {}),+ ...(options.compression ? { compression: options.compression } : {}),+ },+ textures === 'external' ? { gltfBasename: gltfName.slice(0, -'.gltf'.length) } : {},+ );metadata.target = 'three';metadata.delivery = derived.delivery;base = derived.glb;+ imageSources = derived.imageSources;+ gltf = derived.gltf;({ json: baseJson, jsonEnd: baseJsonEnd } = readGlbJson(base));}+ if (textures !== undefined)+ metadata.textures = await runtimeTextureManifest(baseJson, readGlbBinary(base, baseJsonEnd), {+ ...(imageSources ? { sources: imageSources } : {}),+ maps: closureMaps(record),+ });+ // Content addresses join the manifest before the sidecar is hashed into the provenance.+ const external = gltf ? await externalLayout(gltf, metadata.textures ?? []) : undefined;const metadataBytes = encoder.encode(JSON.stringify(metadata));if (metadataBytes.length > ASSET_LIMIT) throw new Error('Runtime export exceeds 64 MiB');+ const provenance = {+ version: 'kiln.provenance.v1',+ profile: 'runtime',+ ...(options.target ? { target: options.target } : {}),+ metadata: { uri: name, sha256: await sha256(metadataBytes) },+ };const baseAsset = baseJson.asset as Record<string, unknown>;baseAsset.extras = {...((baseAsset.extras as Record<string, unknown> | undefined) ?? extras),- kilnProvenanceV1: {- version: 'kiln.provenance.v1',- profile: 'runtime',- ...(options.target ? { target: options.target } : {}),- metadata: { uri: name, sha256: await sha256(metadataBytes) },- },+ kilnProvenanceV1: provenance,};const result = writeGlbJson(base, baseJsonEnd, baseJson);- return { profile, glb: result, metadata: { name, bytes: metadataBytes } };+ if (!external) return { profile, glb: result, metadata: { name, bytes: metadataBytes } };+ const gltfAsset = external.json.asset as Record<string, unknown>;+ gltfAsset.extras = {+ ...((gltfAsset.extras as Record<string, unknown> | undefined) ?? extras),+ kilnProvenanceV1: provenance,+ };+ const gltfBytes = encoder.encode(JSON.stringify(external.json));+ if (gltfBytes.length > ASSET_LIMIT) throw new Error('Runtime export exceeds 64 MiB');+ return {+ profile,+ layout: 'gltf',+ glb: result,+ gltf: { name: gltfName, bytes: gltfBytes },+ buffers: external.buffers,+ textures: external.textures,+ metadata: { name, bytes: metadataBytes },+ };+}++/**+ * Rename each image of the JSON glTF to its content address and add that `uri` to its manifest+ * entry. The writer's own image names are dropped; buffers keep the writer's `<basename>.bin`.+ */+async function externalLayout(+ gltf: NonNullable<RuntimeThreeResult['gltf']>,+ manifest: RuntimeTextureManifestEntryV1[],+): Promise<{+ json: Record<string, unknown>;+ buffers: { uri: string; bytes: Uint8Array }[];+ textures: { uri: string; sha256: string; bytes: Uint8Array }[];+}> {+ const json = structuredClone(gltf.json);+ const resources = new Map(Object.entries(gltf.resources));+ const images = (Array.isArray(json.images) ? json.images : []) as Record<string, unknown>[];+ if (images.length !== manifest.length) throw new Error('External texture layout mismatch');+ const textures = new Map<string, { uri: string; sha256: string; bytes: Uint8Array }>();+ for (const [index, image] of images.entries()) {+ const entry = manifest[index]!;+ const written = typeof image.uri === 'string' ? image.uri : '';+ const bytes = resources.get(written);+ if (!bytes || `sha256:${await sha256Hex(bytes)}` !== entry.sha256)+ throw new Error('External texture bytes differ from the delivered GLB');+ resources.delete(written);+ const uri = `textures/${entry.sha256.slice('sha256:'.length)}.${textureFileExtension(entry.mimeType)}`;+ image.uri = uri;+ entry.uri = uri;+ textures.set(uri, { uri, sha256: entry.sha256, bytes });+ }+ const buffers = [...resources].map(([uri, bytes]) => ({ uri, bytes }));+ for (const { uri } of buffers)+ if (!/^[a-z0-9][a-z0-9._-]*\.bin$/i.test(uri))+ throw new Error(`Unexpected external glTF resource ${uri}`);+ return { json, buffers, textures: [...textures.values()] };}diff --git a/src/cli-output.test.ts b/src/cli-output.test.tsindex 13bf9f3c..782a4c1a 100644--- a/src/cli-output.test.ts+++ b/src/cli-output.test.ts@@ -1,4 +1,5 @@import { expect, it } from 'bun:test';+import { createHash } from 'node:crypto';import {chmod,lstat,@@ -13,7 +14,11 @@ import {} from 'node:fs/promises';import { tmpdir } from 'node:os';import { join } from 'node:path';-import { writeDestinationAtomic, writeNewDestinationsAtomic } from './cli-output';+import {+ writeDestinationAtomic,+ writeExternalTextureExport,+ writeNewDestinationsAtomic,+} from './cli-output';async function fixture(run: (directory: string) => Promise<void>) {const directory = await mkdtemp(join(tmpdir(), 'kiln-output-'));@@ -184,3 +189,81 @@ it('does not publish either output after a partial staging write fails', () =>]),).rejects.toThrow('distinct');}));++const contentAddress = (directory: string, data: string, extension = 'png') =>+ join(directory, 'textures', `${createHash('sha256').update(data).digest('hex')}.${extension}`);++it('publishes a content-addressed texture once and reuses identical bytes without rewriting', () =>+ fixture(async (directory) => {+ const texture = contentAddress(directory, 'shared texture');+ const first = await writeExternalTextureExport(+ [{ path: texture, data: Buffer.from('shared texture') }],+ [{ path: join(directory, 'a.gltf'), data: 'first model' }],+ );+ expect(first).toEqual([{ path: texture, reused: false }]);+ const before = await stat(texture);+ const second = await writeExternalTextureExport(+ [{ path: texture, data: Buffer.from('shared texture') }],+ [{ path: join(directory, 'b.gltf'), data: 'second model' }],+ );+ expect(second).toEqual([{ path: texture, reused: true }]);+ expect((await stat(texture)).ino).toBe(before.ino);+ expect((await stat(texture)).mtimeMs).toBe(before.mtimeMs);+ expect(await readFile(texture, 'utf8')).toBe('shared texture');+ expect((await readdir(join(directory, 'textures'))).length).toBe(1);+ expect((await readdir(directory)).sort()).toEqual(['a.gltf', 'b.gltf', 'textures']);+ }));++it('refuses a texture name that differs from its bytes or from an existing file, before any model file', () =>+ fixture(async (directory) => {+ const texture = contentAddress(directory, 'expected bytes');+ await expect(+ writeExternalTextureExport(+ [{ path: texture, data: Buffer.from('other bytes') }],+ [{ path: join(directory, 'a.gltf'), data: 'model' }],+ ),+ ).rejects.toThrow('content address');+ await mkdir(join(directory, 'textures'), { recursive: true });+ await writeFile(texture, 'tampered bytes');+ await expect(+ writeExternalTextureExport(+ [{ path: texture, data: Buffer.from('expected bytes') }],+ [+ { path: join(directory, 'a.kiln-metadata.json'), data: 'metadata' },+ { path: join(directory, 'a.gltf'), data: 'model' },+ ],+ ),+ ).rejects.toThrow(`${texture} already exists with different bytes`);+ expect(await readFile(texture, 'utf8')).toBe('tampered bytes');+ expect(await readdir(directory)).toEqual(['textures']);+ }));++it('refuses an existing model file before publishing textures, and a failed model publish keeps textures', () =>+ fixture(async (directory) => {+ const texture = contentAddress(directory, 'texture');+ const gltf = join(directory, 'a.gltf');+ await writeFile(gltf, 'existing model');+ const refused = writeExternalTextureExport(+ [{ path: texture, data: Buffer.from('texture') }],+ [{ path: gltf, data: 'new model' }],+ );+ await expect(refused).rejects.toThrow(`${gltf} already exists and is never replaced`);+ await expect(refused).rejects.toMatchObject({ code: 'EEXIST' });+ expect(await readdir(directory)).toEqual(['a.gltf']);+ async function* interrupted() {+ yield Buffer.from('partial');+ throw new Error('interrupted');+ }+ await expect(+ writeExternalTextureExport(+ [{ path: texture, data: Buffer.from('texture') }],+ [+ { path: join(directory, 'b.kiln-metadata.json'), data: 'metadata' },+ { path: join(directory, 'b.gltf'), data: interrupted() },+ ],+ ),+ ).rejects.toThrow('interrupted');+ // Another export may already reference the texture, so rollback never removes it.+ expect(await readFile(texture, 'utf8')).toBe('texture');+ expect((await readdir(directory)).sort()).toEqual(['a.gltf', 'textures']);+ }));diff --git a/src/cli-output.ts b/src/cli-output.tsindex e2ce2351..a0aa1ad4 100644--- a/src/cli-output.ts+++ b/src/cli-output.ts@@ -1,4 +1,4 @@-import { randomUUID } from 'node:crypto';+import { createHash, randomUUID } from 'node:crypto';import type { Stats } from 'node:fs';import {chmod,@@ -6,13 +6,14 @@ import {link,mkdir,open,+ readFile,realpath,rename,stat,unlink,writeFile,} from 'node:fs/promises';-import { dirname, join, resolve } from 'node:path';+import { basename, dirname, join, resolve } from 'node:path';/*** Prepare the directories leading to a CLI destination.@@ -133,3 +134,90 @@ export async function writeNewDestinationsAtomic(await Promise.all(staged.map(({ temporary }) => unlink(temporary).catch(() => {})));}}++/**+ * Publish content-addressed files (`<sha256 hex>.<ext>`). A file that already exists with the+ * same bytes is reused and never rewritten; one with different bytes is an error. Nothing here+ * ever removes a published file, including one this call created: another export may already+ * reference it, and a leftover file is harmless.+ */+export async function writeContentAddressedFiles(+ files: { path: string; data: Uint8Array }[],+): Promise<{ path: string; reused: boolean }[]> {+ const hex = (data: Uint8Array) => createHash('sha256').update(data).digest('hex');+ for (const { path, data } of files) {+ const name = basename(path);+ if (!/^[a-f0-9]{64}\.[a-z0-9]+$/.test(name) || name.slice(0, 64) !== hex(data))+ throw new Error(`${path} is not the content address of its bytes`);+ }+ const published: { path: string; reused: boolean }[] = [];+ const same = async (path: string, data: Uint8Array) => {+ const existing = await readFile(path);+ if (hex(existing) !== hex(data))+ throw Object.assign(+ new Error(+ `${path} already exists with different bytes; a content-addressed file is never replaced.`,+ ),+ { code: 'EEXIST' },+ );+ };+ for (const { path, data } of files) {+ try {+ await same(path, data);+ published.push({ path, reused: true });+ continue;+ } catch (error) {+ if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;+ }+ await prepareDestination(path);+ const temporary = join(dirname(path), `.kiln-write-${randomUUID()}.tmp`);+ const file = await open(temporary, 'wx');+ try {+ try {+ await writeFile(file, data);+ } finally {+ await file.close();+ }+ try {+ await link(temporary, path);+ published.push({ path, reused: false });+ } catch (error) {+ // A concurrent export published the same name first: reuse it only if identical.+ if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error;+ await same(path, data);+ published.push({ path, reused: true });+ }+ } finally {+ await unlink(temporary).catch(() => {});+ }+ }+ return published;+}++/**+ * External glTF export: content-addressed textures first, then the exclusive model files+ * (sidecar, buffers, `.gltf` last) under `writeNewDestinationsAtomic`'s never-replace and+ * rollback rules. An existing model destination is refused before any texture is written.+ */+export async function writeExternalTextureExport(+ textures: { path: string; data: Uint8Array }[],+ outputs: { path: string; data: Parameters<typeof writeFile>[1] }[],+): Promise<{ path: string; reused: boolean }[]> {+ for (const { path } of outputs) {+ try {+ await lstat(path);+ } catch (error) {+ if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue;+ throw error;+ }+ throw Object.assign(+ new Error(+ `${path} already exists and is never replaced; choose a new output path or remove the file.`,+ ),+ { code: 'EEXIST' },+ );+ }+ const published = await writeContentAddressedFiles(textures);+ await writeNewDestinationsAtomic(outputs);+ return published;+}diff --git a/src/ktx2-basis.test.ts b/src/ktx2-basis.test.tsnew file mode 100644index 00000000..bf4021d9--- /dev/null+++ b/src/ktx2-basis.test.ts@@ -0,0 +1,81 @@+/**+ * KTX2 through the optional `ktx2-encoder` peer (#201). Real-encoder cases skip when the peer+ * is not installed; it is a pinned devDependency, so the repository's own installs have it.+ */+import { describe, expect, test } from 'bun:test';+import { createHash } from 'node:crypto';+import { existsSync } from 'node:fs';+import { resolve } from 'node:path';+import { createKtx2Encoder, KTX2_ENCODER_PACKAGE, loadKtx2Encoder } from './ktx2-basis';+import { isKtx2 } from './runtime-textures';+import { encodePng } from './views/png';++const peer = existsSync(resolve('node_modules/ktx2-encoder/package.json'));+const sha = (bytes: Uint8Array) => `sha256:${createHash('sha256').update(bytes).digest('hex')}`;+const png = (rgb: number[]) => new Uint8Array(encodePng(new Uint8Array(rgb), 4, 4));+const COLOR = png(Array.from({ length: 16 }, (_, i) => [i * 16, 255 - i * 16, 90]).flat());+const NORMAL = png(Array.from({ length: 16 }, () => [128, 128, 255]).flat());++describe('ktx2-encoder peer', () => {+ test('a missing peer names the exact install command', async () => {+ const missing = Object.assign(new Error("Cannot find package 'ktx2-encoder'"), {+ code: 'ERR_MODULE_NOT_FOUND',+ });+ await expect(+ loadKtx2Encoder(async () => {+ throw missing;+ }),+ ).rejects.toThrow('npm install [email protected]');+ expect(KTX2_ENCODER_PACKAGE).toEqual({ name: 'ktx2-encoder', version: '0.6.0' });+ });++ test.skipIf(!peer)(+ 'per-slot modes, recorded identity and identical bytes for the same input',+ async () => {+ const encoder = await createKtx2Encoder();+ expect(encoder.identity).toEqual({+ name: 'ktx2-encoder',+ version: '0.6.0',+ basisWasmSha256: 'sha256:9807719e87cf3d979b0d69ae7112eb88aec6a0e0206c0b2d00dc0bed0d581b80',+ settings: {+ srgb: expect.objectContaining({ mode: 'etc1s', isSetKTX2SRGBTransferFunc: true }),+ linear: expect.objectContaining({ mode: 'uastc', isSetKTX2SRGBTransferFunc: false }),+ normal: expect.objectContaining({ mode: 'uastc', isNormalMap: true }),+ },+ });+ const input = { mimeType: 'image/png', name: 'map' };+ const color = await encoder({+ ...input,+ image: COLOR,+ colorSpace: 'srgb',+ slot: 'baseColor',+ });+ const again = await encoder({+ ...input,+ image: COLOR,+ colorSpace: 'srgb',+ slot: 'baseColor',+ });+ const normal = await encoder({+ ...input,+ image: NORMAL,+ colorSpace: 'linear',+ slot: 'normal',+ });+ expect(isKtx2(color)).toBe(true);+ expect(isKtx2(normal)).toBe(true);+ expect(sha(again)).toBe(sha(color));+ const { read } = await import('ktx-parse');+ const etc1s = read(color);+ const uastc = read(normal);+ // ETC1S is BasisLZ-supercompressed; UASTC is Zstandard-supercompressed (KTX2 spec 3.2).+ expect(etc1s.supercompressionScheme).toBe(1);+ expect(uastc.supercompressionScheme).toBe(2);+ expect([etc1s.pixelWidth, etc1s.pixelHeight]).toEqual([4, 4]);+ // Colour carries the sRGB transfer function (2), data stays linear (1).+ expect(etc1s.dataFormatDescriptor[0]!.transferFunction).toBe(2);+ expect(uastc.dataFormatDescriptor[0]!.transferFunction).toBe(1);+ },+ 60_000, // The first encode compiles 3.3 MB of WebAssembly.+ );+});diff --git a/src/ktx2-basis.ts b/src/ktx2-basis.tsnew file mode 100644index 00000000..9fcf1a4d--- /dev/null+++ b/src/ktx2-basis.ts@@ -0,0 +1,185 @@+/**+ * KTX2 encoding through the optional `ktx2-encoder` peer (#201).+ *+ * `ktx2-encoder` (MIT) bundles a precompiled Basis Universal encoder (Apache-2.0, with+ * Zstandard under BSD-3-Clause) as WebAssembly and ships its own THIRD_PARTY_NOTICES.md.+ * Kiln neither bundles nor redistributes it: users install the exact peer themselves, and+ * every bundle keeps it external. Loaded lazily, only when KTX2 is requested.+ *+ * Modes are chosen per slot: ETC1S for colour (base colour and emissive, sRGB transfer), UASTC+ * with Zstandard supercompression for normal and other linear data. Settings are fixed and+ * recorded in the encoder identity, which the runtime sidecar and receipt repeat.+ */+import { createHash } from 'node:crypto';+import { readFile } from 'node:fs/promises';+import { dirname, join } from 'node:path';+import { fileURLToPath, pathToFileURL } from 'node:url';+import type {+ RuntimeThreeKtx2EncoderIdentityV1,+ RuntimeThreeKtx2EncoderV1,+ RuntimeThreeKtx2InputV1,+} from './runtime-three';++/** The exact peer Kiln is qualified with. */+export const KTX2_ENCODER_PACKAGE = Object.freeze({ name: 'ktx2-encoder', version: '0.6.0' });+const INSTALL = `npm install ${KTX2_ENCODER_PACKAGE.name}@${KTX2_ENCODER_PACKAGE.version}`;++type ImageDecoder = (+ buffer: Uint8Array,+) => Promise<{ data: Uint8Array; width: number; height: number }>;+type EncodeOptions = Record<string, unknown> & { imageDecoder: ImageDecoder };+interface Ktx2EncoderModule {+ encodeToKTX2(image: Uint8Array, options: EncodeOptions): Promise<Uint8Array>;+}+/** The package's own internals (0.6.0 layout), loaded by file URL past its exports map. */+interface BasisFactory {+ default(module: { print(text: string): void; printErr(text: string): void }): Promise<{+ initializeBasis(): void;+ }>;+}+interface EncodeCore {+ encodeWithModule(basis: unknown, image: Uint8Array, options: EncodeOptions): Promise<Uint8Array>;+}++/** Fixed encoder options, by profile. Option names are the package's own. */+const SETTINGS = Object.freeze({+ srgb: Object.freeze({+ mode: 'etc1s',+ isUASTC: false,+ qualityLevel: 128,+ compressionLevel: 2,+ generateMipmap: true,+ isSetKTX2SRGBTransferFunc: true,+ isPerceptual: true,+ }),+ linear: Object.freeze({+ mode: 'uastc',+ isUASTC: true,+ uastcLDRQualityLevel: 2,+ needSupercompression: true,+ generateMipmap: true,+ isSetKTX2SRGBTransferFunc: false,+ isPerceptual: false,+ }),+ normal: Object.freeze({+ mode: 'uastc',+ isUASTC: true,+ uastcLDRQualityLevel: 2,+ needSupercompression: true,+ generateMipmap: true,+ isSetKTX2SRGBTransferFunc: false,+ isPerceptual: false,+ isNormalMap: true,+ }),+});+const profile = (input: RuntimeThreeKtx2InputV1) =>+ input.colorSpace === 'srgb'+ ? SETTINGS.srgb+ : input.slot === 'normal'+ ? SETTINGS.normal+ : SETTINGS.linear;++const hex = (bytes: Uint8Array) => createHash('sha256').update(bytes).digest('hex');++/** The installed package directory, from its resolved entry. */+async function packageDirectory(): Promise<string> {+ let directory = dirname(fileURLToPath(import.meta.resolve(KTX2_ENCODER_PACKAGE.name)));+ for (let depth = 0; depth < 6; depth++) {+ try {+ const manifest = JSON.parse(await readFile(join(directory, 'package.json'), 'utf8'));+ if (manifest.name === KTX2_ENCODER_PACKAGE.name) return directory;+ } catch {+ /* Keep walking up. */+ }+ directory = dirname(directory);+ }+ throw new Error(`Cannot locate the installed ${KTX2_ENCODER_PACKAGE.name} package`);+}++/**+ * Import the optional peer and read its identity. A missing peer fails with the exact install+ * command; another version is refused, because the settings above are qualified on 0.6.0.+ */+export async function loadKtx2Encoder(+ importer: () => Promise<unknown> = () => import('ktx2-encoder'),+): Promise<{+ encode: (image: Uint8Array, options: EncodeOptions) => Promise<Uint8Array>;+ version: string;+ basisWasmSha256?: string;+}> {+ let module: Ktx2EncoderModule;+ try {+ module = (await importer()) as Ktx2EncoderModule;+ } catch (error) {+ throw new Error(+ `KTX2 encoding needs the optional peer ${KTX2_ENCODER_PACKAGE.name}@${KTX2_ENCODER_PACKAGE.version}. Install it with: ${INSTALL}`,+ { cause: error },+ );+ }+ if (typeof module?.encodeToKTX2 !== 'function')+ throw new Error(`${KTX2_ENCODER_PACKAGE.name} has no encodeToKTX2 export. ${INSTALL}`);+ const directory = await packageDirectory();+ const { version } = JSON.parse(await readFile(join(directory, 'package.json'), 'utf8'));+ if (version !== KTX2_ENCODER_PACKAGE.version)+ throw new Error(+ `${KTX2_ENCODER_PACKAGE.name} ${version} is installed; Kiln's KTX2 settings are qualified on ${KTX2_ENCODER_PACKAGE.version}. ${INSTALL}`,+ );+ let basisWasmSha256: string | undefined;+ try {+ basisWasmSha256 = `sha256:${hex(await readFile(join(directory, 'dist', 'basis', 'basis_encoder.wasm')))}`;+ } catch {+ /* The identity then omits the WebAssembly hash. */+ }+ // The package's Node entry starts Basis with the default print, and Basis writes progress to+ // stdout even with debug off, which would corrupt `--json` output. Start the same bundled+ // WebAssembly with its output silenced, and use the package's own encode routine.+ const internal = (path: string) => import(pathToFileURL(join(directory, 'dist', path)).href);+ const [factory, core] = (await Promise.all([+ internal('basis/basis_encoder.js'),+ internal('encodeCore.js'),+ ])) as [BasisFactory, EncodeCore];+ if (typeof factory.default !== 'function' || typeof core.encodeWithModule !== 'function')+ throw new Error(`${KTX2_ENCODER_PACKAGE.name} ${version} has an unexpected layout. ${INSTALL}`);+ basis ??= factory.default({ print: () => {}, printErr: () => {} }).then((instance) => {+ instance.initializeBasis();+ return instance;+ });+ const instance = basis;+ return {+ encode: async (image, options) => core.encodeWithModule(await instance, image, options),+ version,+ ...(basisWasmSha256 ? { basisWasmSha256 } : {}),+ };+}+let basis: Promise<unknown> | undefined;++/** Decode PNG, JPEG or WebP to RGBA for the encoder, with Kiln's existing sharp. */+const decode: ImageDecoder = async (buffer) => {+ const { default: sharp } = await import('sharp');+ const { data, info } = await sharp(buffer)+ .ensureAlpha()+ .raw()+ .toBuffer({ resolveWithObject: true });+ return { data: new Uint8Array(data), width: info.width, height: info.height };+};++/**+ * A `ktx2Encoder` for `exportAssetGlb` / `deliverThreeRuntimeGlb`: ETC1S for colour, UASTC for+ * normal and data maps, with its identity attached for the delivery receipt.+ */+export async function createKtx2Encoder(+ options: { importer?: () => Promise<unknown> } = {},+): Promise<RuntimeThreeKtx2EncoderV1 & { identity: RuntimeThreeKtx2EncoderIdentityV1 }> {+ const { encode: run, version, basisWasmSha256 } = await loadKtx2Encoder(options.importer);+ const identity: RuntimeThreeKtx2EncoderIdentityV1 = {+ name: KTX2_ENCODER_PACKAGE.name,+ version,+ ...(basisWasmSha256 ? { basisWasmSha256 } : {}),+ settings: structuredClone({ ...SETTINGS }),+ };+ const encode = async (input: RuntimeThreeKtx2InputV1) => {+ const { mode: _mode, ...settings } = profile(input);+ return run(input.image, { ...settings, imageDecoder: decode });+ };+ return Object.assign(encode, { identity });+}diff --git a/src/runtime-textures.ts b/src/runtime-textures.tsnew file mode 100644index 00000000..08ab4cfe--- /dev/null+++ b/src/runtime-textures.ts@@ -0,0 +1,220 @@+/**+ * Runtime texture manifest (#213): one entry per glTF image naming its exact delivered bytes,+ * so a host can deduplicate shared library textures without decoding every GLB.+ *+ * Pure: reads the GLB JSON and binary chunk directly; no renderer, filesystem or network.+ */+import type { MaterialMapPinV1, MaterialMapSlotV1 } from './pinned-material-map';++/** One delivered image. Additive to `kiln.runtime-metadata.v1` as sidecar `textures[]`. */+export interface RuntimeTextureManifestEntryV1 {+ /** glTF image index in the delivered asset. */+ image: number;+ /** `sha256:<hex>` of the exact delivered bytes. */+ sha256: string;+ bytes: number;+ mimeType: string;+ width: number;+ height: number;+ /** sRGB when a base colour or emissive slot uses the image, linear otherwise. */+ colorSpace: 'srgb' | 'linear';+ /** The bytes before KTX2 encoding, present only when encoding changed them. */+ sourceSha256?: string;+ /** Present only when the pre-encode bytes exactly equal a map of the saved material closure. */+ material?: { pin: MaterialMapPinV1; slot: MaterialMapSlotV1 };+ /** External layout only: the image file, relative to the `.gltf`. */+ uri?: string;+}++/** A library map the record's saved material closure declares, keyed by its exact bytes. */+export interface RuntimeTextureMaterialMapV1 {+ sha256: string;+ pin: MaterialMapPinV1;+ slot: MaterialMapSlotV1;+}++const object = (value: unknown): value is Record<string, unknown> =>+ value !== null && typeof value === 'object' && !Array.isArray(value);+const index = (value: unknown): number | undefined =>+ Number.isInteger(value) && (value as number) >= 0 ? (value as number) : undefined;++export async function sha256Hex(bytes: Uint8Array): Promise<string> {+ const digest = await crypto.subtle.digest('SHA-256', Uint8Array.from(bytes));+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');+}++/** The KTX 2.0 file identifier: <<KTX 20>>\r\n\x1A\n. */+export const KTX2_IDENTIFIER = Object.freeze([+ 0xab, 0x4b, 0x54, 0x58, 0x20, 0x32, 0x30, 0xbb, 0x0d, 0x0a, 0x1a, 0x0a,+]);+export const isKtx2 = (bytes: Uint8Array) =>+ bytes.byteLength >= 12 && KTX2_IDENTIFIER.every((value, at) => bytes[at] === value);++/** Pixel dimensions from the image header (PNG, JPEG, WebP or KTX2). */+export function imageDimensions(bytes: Uint8Array): { width: number; height: number } {+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);+ const fail = (): never => {+ throw new Error('Texture manifest cannot read image dimensions');+ };+ const at = (offset: number, length: number) => {+ if (offset + length > bytes.byteLength) fail();+ };+ if (bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47) {+ at(16, 8);+ return { width: view.getUint32(16), height: view.getUint32(20) };+ }+ if (isKtx2(bytes)) {+ at(20, 8);+ return { width: view.getUint32(20, true), height: view.getUint32(24, true) };+ }+ if (bytes[0] === 0xff && bytes[1] === 0xd8) {+ let offset = 2;+ while (offset + 4 <= bytes.byteLength) {+ if (bytes[offset] !== 0xff) fail();+ const marker = bytes[offset + 1]!;+ if (marker === 0xff) {+ offset++;+ continue;+ }+ if (marker === 0xd8 || marker === 0x01 || (marker >= 0xd0 && marker <= 0xd7)) {+ offset += 2;+ continue;+ }+ const length = view.getUint16(offset + 2);+ // Start-of-frame markers, excluding DHT (C4), JPG (C8) and DAC (CC).+ if (marker >= 0xc0 && marker <= 0xcf && ![0xc4, 0xc8, 0xcc].includes(marker)) {+ at(offset + 5, 4);+ return { width: view.getUint16(offset + 7), height: view.getUint16(offset + 5) };+ }+ offset += 2 + length;+ }+ fail();+ }+ const text = (offset: number) =>+ String.fromCharCode(...bytes.subarray(offset, Math.min(offset + 4, bytes.byteLength)));+ if (text(0) === 'RIFF' && text(8) === 'WEBP') {+ at(12, 19);+ const chunk = text(12);+ if (chunk === 'VP8X')+ return {+ width: 1 + (view.getUint32(24, true) & 0xffffff),+ height: 1 + (view.getUint32(27, true) & 0xffffff),+ };+ if (chunk === 'VP8L') {+ const bits = view.getUint32(21, true);+ return { width: 1 + (bits & 0x3fff), height: 1 + ((bits >> 14) & 0x3fff) };+ }+ if (chunk === 'VP8 ') {+ at(26, 4);+ return {+ width: view.getUint16(26, true) & 0x3fff,+ height: view.getUint16(28, true) & 0x3fff,+ };+ }+ }+ return fail();+}++/** Image indices a texture reads, including the compressed-image extensions' sources. */+function textureSource(texture: unknown): number | undefined {+ if (!object(texture)) return undefined;+ const extensions = object(texture.extensions) ? texture.extensions : {};+ for (const name of ['KHR_texture_basisu', 'EXT_texture_webp', 'EXT_texture_avif']) {+ const extension = extensions[name];+ if (object(extension) && index(extension.source) !== undefined) return index(extension.source);+ }+ return index(texture.source);+}++/** sRGB image indices: those a base colour or emissive slot uses (the KTX2 encoder's rule). */+export function srgbImages(json: Record<string, unknown>): Set<number> {+ const textures = Array.isArray(json.textures) ? json.textures : [];+ const result = new Set<number>();+ for (const material of Array.isArray(json.materials) ? json.materials : []) {+ if (!object(material)) continue;+ const pbr = object(material.pbrMetallicRoughness) ? material.pbrMetallicRoughness : {};+ for (const info of [pbr.baseColorTexture, material.emissiveTexture]) {+ const texture = object(info) ? index(info.index) : undefined;+ const image = texture === undefined ? undefined : textureSource(textures[texture]);+ if (image !== undefined) result.add(image);+ }+ }+ return result;+}++function base64(text: string): Uint8Array {+ const binary = atob(text);+ return Uint8Array.from(binary, (character) => character.charCodeAt(0));+}++/** The exact bytes of each embedded image, in image index order. */+export function embeddedImages(+ json: Record<string, unknown>,+ binary: Uint8Array | undefined,+): { bytes: Uint8Array; mimeType: string }[] {+ const views = Array.isArray(json.bufferViews) ? json.bufferViews : [];+ return (Array.isArray(json.images) ? json.images : []).map((image) => {+ if (!object(image)) throw new Error('Invalid glTF image');+ const view = index(image.bufferView);+ if (view !== undefined) {+ const def = views[view];+ if (!object(def) || index(def.buffer) !== 0 || !binary)+ throw new Error('Texture manifest requires images embedded in the GLB binary chunk');+ const offset = index(def.byteOffset) ?? 0;+ const length = index(def.byteLength);+ if (length === undefined || offset + length > binary.byteLength)+ throw new Error('Invalid glTF image buffer view');+ if (typeof image.mimeType !== 'string') throw new Error('Embedded image needs a mimeType');+ return { bytes: binary.subarray(offset, offset + length), mimeType: image.mimeType };+ }+ const match =+ typeof image.uri === 'string' ? /^data:([^;,]+);base64,(.*)$/s.exec(image.uri) : null;+ if (!match) throw new Error('Texture manifest requires embedded image bytes');+ return { bytes: base64(match[2]!), mimeType: match[1]! };+ });+}++/**+ * Build the manifest of a delivered asset. `sources` gives the pre-encode hash of each image+ * that KTX2 encoding changed; `maps` are the saved material closure's maps.+ */+export async function runtimeTextureManifest(+ json: Record<string, unknown>,+ binary: Uint8Array | undefined,+ options: {+ sources?: ReadonlyMap<number, string>;+ maps?: readonly RuntimeTextureMaterialMapV1[];+ } = {},+): Promise<RuntimeTextureManifestEntryV1[]> {+ const srgb = srgbImages(json);+ const entries: RuntimeTextureManifestEntryV1[] = [];+ for (const [image, { bytes, mimeType }] of embeddedImages(json, binary).entries()) {+ const sha256 = `sha256:${await sha256Hex(bytes)}`;+ const sourceSha256 = options.sources?.get(image);+ const original = sourceSha256 ?? sha256;+ const map = options.maps?.find((candidate) => candidate.sha256 === original);+ entries.push({+ image,+ sha256,+ bytes: bytes.byteLength,+ mimeType,+ ...imageDimensions(bytes),+ colorSpace: srgb.has(image) ? 'srgb' : 'linear',+ ...(sourceSha256 && sourceSha256 !== sha256 ? { sourceSha256 } : {}),+ ...(map ? { material: { pin: { ...map.pin }, slot: map.slot } } : {}),+ });+ }+ return entries;+}++/** File extension of a delivered image in the external layout. */+export function textureFileExtension(mimeType: string): string {+ const extension = {+ 'image/png': 'png',+ 'image/jpeg': 'jpg',+ 'image/webp': 'webp',+ 'image/ktx2': 'ktx2',+ }[mimeType];+ if (!extension) throw new Error(`External textures do not support ${mimeType}`);+ return extension;+}diff --git a/src/runtime-three.ts b/src/runtime-three.tsindex 6c84846d..e60eec41 100644--- a/src/runtime-three.ts+++ b/src/runtime-three.ts@@ -18,6 +18,7 @@*/import {type Document,+ Format,Logger,type Mesh,type Node,@@ -37,6 +38,7 @@ import { createGltfIO, MSFT_LOD } from './gltf-io';import { deliveryNodePaths } from './delivery-inspect';import { KILN_REPEAT_INSTANCES_KEY } from './delivery';import { isHiddenGltfNode } from './metrics';+import { isKtx2, sha256Hex } from './runtime-textures';/** Bits per quantized attribute class; custom underscore attributes stay float32. */export const RUNTIME_THREE_QUANTIZATION = Object.freeze({@@ -50,6 +52,14 @@ export const RUNTIME_THREE_QUANTIZATION = Object.freeze({const QUANTIZED_SEMANTICS =/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/;+/** The material slot an image serves; `other` covers extension textures. */+export type RuntimeThreeKtx2SlotV1 =+ | 'baseColor'+ | 'emissive'+ | 'normal'+ | 'metallicRoughness'+ | 'occlusion'+ | 'other';export interface RuntimeThreeKtx2InputV1 {/** The encoded source image (PNG or JPEG). */image: Uint8Array;@@ -58,13 +68,34 @@ export interface RuntimeThreeKtx2InputV1 {name: string;/** sRGB for base colour and emissive slots, linear otherwise. */colorSpace: 'srgb' | 'linear';+ /**+ * The slot this image serves. An image in several linear slots reports the first of+ * normal, metallicRoughness, occlusion, other. An image in both an sRGB and a linear slot+ * is refused, because one encoding cannot serve both.+ */+ slot: RuntimeThreeKtx2SlotV1;}+/** What an encoder records about itself: the receipt binds these facts to the bytes. */+export interface RuntimeThreeKtx2EncoderIdentityV1 {+ name: string;+ version: string;+ /** `sha256:` of the Basis Universal WebAssembly the encoder ran, when known. */+ basisWasmSha256?: string;+ /** Every mode, quality, mipmap and supercompression setting, per colour space. */+ settings: Record<string, unknown>;+}+/** A KTX2 encoder function, optionally carrying its identity for `delivery.ktx2.encoder`. */+export type RuntimeThreeKtx2EncoderV1 = ((+ input: RuntimeThreeKtx2InputV1,+) => Promise<Uint8Array>) & {+ identity?: RuntimeThreeKtx2EncoderIdentityV1;+};export interface RuntimeThreeOptionsV1 {/**- * Optional host KTX2 encoder (for example a Basis Universal or toktx binding). Kiln ships- * none; without one, textures stay PNG/JPEG and the report says `skipped`.+ * Optional KTX2 encoder: a host binding, or `createKtx2Encoder()` over the optional+ * `ktx2-encoder` peer. Without one, textures stay PNG/JPEG and the report says `skipped`.*/- ktx2Encoder?: (input: RuntimeThreeKtx2InputV1) => Promise<Uint8Array>;+ ktx2Encoder?: RuntimeThreeKtx2EncoderV1;/*** Buffer compression. `meshopt` (default) requires `EXT_meshopt_compression` and a* Meshopt decoder in the loader. `none` writes plain buffers for loaders without one;@@ -108,7 +139,13 @@ export interface RuntimeThreeDeliveryV1 {colliderProxies: { collider: string; proxy: string }[];customAttributes: { name: string; meshes: number; componentType: 'FLOAT'; normalized: false }[];instancing: { node: string; mesh: string; count: number; instances: string[] }[];- ktx2: { status: 'encoded' | 'skipped'; textures: number; reason?: string };+ ktx2: {+ status: 'encoded' | 'skipped';+ textures: number;+ reason?: string;+ /** The encoder's own identity, when it declared one. */+ encoder?: RuntimeThreeKtx2EncoderIdentityV1;+ };preserved: {lodChains: number;hiddenNodes: number;@@ -250,6 +287,7 @@ function splitColliderProxies(doc: Document) {async function encodeKtx2(doc: Document,encoder: RuntimeThreeOptionsV1['ktx2Encoder'],+ sources: Map<Texture, string>,): Promise<RuntimeThreeDeliveryV1['ktx2']> {const textures = doc.getRoot()@@ -261,26 +299,71 @@ async function encodeKtx2(textures: textures.length,reason: 'No KTX2 encoder was supplied; textures stay PNG or JPEG.',};- const srgb = new Set<Texture>();+ const slots = new Map<Texture, Set<RuntimeThreeKtx2SlotV1>>();+ const use = (texture: Texture | null, slot: RuntimeThreeKtx2SlotV1) => {+ if (texture) slots.set(texture, (slots.get(texture) ?? new Set()).add(slot));+ };for (const material of doc.getRoot().listMaterials()) {- for (const texture of [material.getBaseColorTexture(), material.getEmissiveTexture()])- if (texture) srgb.add(texture);+ use(material.getBaseColorTexture(), 'baseColor');+ use(material.getEmissiveTexture(), 'emissive');+ use(material.getNormalTexture(), 'normal');+ use(material.getMetallicRoughnessTexture(), 'metallicRoughness');+ use(material.getOcclusionTexture(), 'occlusion');}+ const order: RuntimeThreeKtx2SlotV1[] = [+ 'baseColor',+ 'emissive',+ 'normal',+ 'metallicRoughness',+ 'occlusion',+ ];for (const texture of textures) {+ const used = slots.get(texture) ?? new Set<RuntimeThreeKtx2SlotV1>();+ const srgb = used.has('baseColor') || used.has('emissive');+ // Any other parent (an extension texture info) is a linear use the core slots do not name.+ const other = texture+ .listParents()+ .some((parent) => parent.propertyType !== PropertyType.ROOT && !isCoreMaterialUse(parent));+ const linear = [...used].some((slot) => slot !== 'baseColor' && slot !== 'emissive') || other;+ if (srgb && linear)+ throw new Error(+ `Texture ${JSON.stringify(texture.getName())} is used by both sRGB and linear material slots; one KTX2 encoding cannot serve both. Use separate images.`,+ );+ const original = texture.getImage()!;const image = await encoder({- image: texture.getImage()!,+ image: original,mimeType: texture.getMimeType(),name: texture.getName(),- colorSpace: srgb.has(texture) ? 'srgb' : 'linear',+ colorSpace: srgb ? 'srgb' : 'linear',+ slot: order.find((slot) => used.has(slot)) ?? 'other',});- if (!(image instanceof Uint8Array) || image.byteLength < 12)- throw new Error('ktx2Encoder must return KTX2 bytes');+ if (!(image instanceof Uint8Array) || !isKtx2(image))+ throw new Error('ktx2Encoder must return KTX2 bytes starting with the KTX2 identifier');+ sources.set(texture, `sha256:${await sha256Hex(original)}`);texture.setImage(image).setMimeType('image/ktx2');const uri = texture.getURI();if (uri) texture.setURI(uri.replace(/\.(png|jpe?g)$/i, '.ktx2'));}- if (textures.length) doc.createExtension(KHRTextureBasisu).setRequired(true);- return { status: 'encoded', textures: textures.length };+ if (textures.length) {+ doc.createExtension(KHRTextureBasisu).setRequired(true);+ // Atlas references name the final image bytes and MIME type: rebind them to the KTX2+ // bytes, then check exactly as import will.+ const { refreshAtlasDocumentProvenance, validateAtlasDocumentProvenance } = await import(+ './atlas-provenance'+ );+ await refreshAtlasDocumentProvenance(doc);+ await validateAtlasDocumentProvenance(doc);+ }+ return {+ status: 'encoded',+ textures: textures.length,+ ...(encoder.identity ? { encoder: structuredClone(encoder.identity) } : {}),+ };+}++/** A material's core texture info, as opposed to an extension property's. */+function isCoreMaterialUse(parent: Property): boolean {+ return parent.propertyType === PropertyType.MATERIAL;}function decomposeDelta(before: number[], after: number[]) {@@ -298,16 +381,29 @@ function decomposeDelta(before: number[], after: number[]) {};}+/** What the derivation returns beside the GLB: facts and, on request, the `.gltf` layout. */+export interface RuntimeThreeResult {+ glb: Uint8Array;+ delivery: RuntimeThreeDeliveryV1;+ /** Pre-encode `sha256:` of each image index KTX2 encoding replaced. */+ imageSources: Map<number, string>;+ /** The same document as JSON glTF, when `layout.gltfBasename` was given. */+ gltf?: { json: Record<string, unknown>; resources: Record<string, Uint8Array> };+}+/*** Transform written GLB bytes into the three.js runtime delivery GLB. `meshoptEncoder` is the* `MeshoptEncoder` from the `meshoptimizer` package (loaded by the caller so this module stays- * import-light).+ * import-light). `layout.gltfBasename` also writes the same document as JSON glTF, whose+ * buffers are named `<basename>.bin`; its image URIs are the writer's and are renamed by the+ * caller.*/export async function deliverRuntimeThreeGlb(bytes: Uint8Array,meshoptEncoder: unknown,options: RuntimeThreeOptionsV1 = {},-): Promise<{ glb: Uint8Array; delivery: RuntimeThreeDeliveryV1 }> {+ layout: { gltfBasename?: string } = {},+): Promise<RuntimeThreeResult> {const compression = options.compression ?? 'meshopt';if (compression !== 'meshopt' && compression !== 'none')throw new Error('Runtime three compression must be meshopt or none');@@ -343,7 +439,8 @@ export async function deliverRuntimeThreeGlb(.createExtension(EXTMeshoptCompression).setRequired(true).setEncoderOptions({ method: EXTMeshoptCompression.EncoderMethod.QUANTIZE });- const ktx2 = await encodeKtx2(doc, options.ktx2Encoder);+ const encodedSources = new Map<Texture, string>();+ const ktx2 = await encodeKtx2(doc, options.ktx2Encoder, encodedSources);// The quantizer moves a mesh to a new unnamed child when its node has children or is// animated; name it after its authored node so the delivery path is stable.@@ -403,6 +500,18 @@ export async function deliverRuntimeThreeGlb(const all = doc.getRoot().listNodes();const glb = await io.writeBinary(doc);const json = (await io.binaryToJSON(glb)).json;+ // The writer emits one glTF image per texture, in list order.+ const imageSources = new Map<number, string>();+ doc+ .getRoot()+ .listTextures()+ .forEach((texture, image) => {+ const source = encodedSources.get(texture);+ if (source) imageSources.set(image, source);+ });+ const gltf = layout.gltfBasename+ ? await io.writeJSON(doc, { format: Format.GLTF, basename: layout.gltfBasename })+ : undefined;const delivery: RuntimeThreeDeliveryV1 = {target: 'three',extensionsUsed: [...(json.extensionsUsed ?? [])].sort(),@@ -453,5 +562,17 @@ export async function deliverRuntimeThreeGlb(.length,},};- return { glb, delivery };+ return {+ glb,+ delivery,+ imageSources,+ ...(gltf+ ? {+ gltf: {+ json: gltf.json as unknown as Record<string, unknown>,+ resources: gltf.resources,+ },+ }+ : {}),+ };}