@needle-tools/engine 4.1.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/dist/needle-engine.bundle.js +182 -178
- package/dist/needle-engine.bundle.light.js +182 -178
- package/dist/needle-engine.bundle.light.min.js +30 -30
- package/dist/needle-engine.bundle.light.umd.cjs +2 -2
- package/dist/needle-engine.bundle.min.js +2 -2
- package/dist/needle-engine.bundle.umd.cjs +2 -2
- package/dist/needle-engine.d.ts +9 -9
- package/dist/needle-engine.light.d.ts +9 -9
- package/lib/engine/engine_input.d.ts +4 -0
- package/lib/engine/engine_input.js +4 -0
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine-components/particlesystem/ParticleSystem.js +2 -1
- package/lib/engine-components/particlesystem/ParticleSystem.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/engine_input.ts +4 -0
- package/src/engine-components/particlesystem/ParticleSystem.ts +2 -1
|
@@ -130,7 +130,7 @@ Open this page to get the console: `+t.toString())}const s=Y.isMobileDevice()||Y
|
|
|
130
130
|
#__vconsole .vc-mask {
|
|
131
131
|
overflow: hidden;
|
|
132
132
|
}
|
|
133
|
-
`,Xi?.prepend(n),s===!0&&jm()<=0&&rb(),console.log("\u{1F335} Debug console has loaded")}},t.onerror=()=>{console.warn("\u{1F335} Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),nc=!1,ai=null},t.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(t)}function gP(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),t=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(i){const n=globalThis["needle:codegen_files"];if(!n||n.length===0)return;let o=globalThis["needle:codegen_files"][0];const r=o.indexOf("?");r>-1&&(o=o.substring(0,r));const l=location.protocol+"//"+location.host+location.pathname+"/"+o,c=encodeURIComponent(l);s.fullUrl="https://viewer.needle.tools?inspect&file="+c;var h='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';i(h)}),s.on("show",function(){const i=t();i&&i.src!==s.fullUrl&&(i.src=s.fullUrl)}),s.on("hide",function(){const i=t();i&&(i.src="")}),s.on("addTopBar",function(i){var n=new Array;n.push({name:"Open in new window \u2197",onClick:function(o){window.open(s.fullUrl,"_blank"),ai?.hide()}}),n.push({name:"Reload",onClick:function(o){const r=t();r&&(r.src=s.fullUrl)}}),n.push({name:"Fullscreen",onClick:function(o){const r=t();r.requestFullscreen?r.requestFullscreen():r.webkitRequestFullscreen instanceof Function&&r.webkitRequestFullscreen()}}),i(n)}),s}function fP(){return document.querySelector("#__vconsole .vc-switch")||null}function yP(){return document.querySelector("#__vconsole")||null}const hb=O("debugdefines");ho('if(!globalThis[""4.1.
|
|
133
|
+
`,Xi?.prepend(n),s===!0&&jm()<=0&&rb(),console.log("\u{1F335} Debug console has loaded")}},t.onerror=()=>{console.warn("\u{1F335} Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),nc=!1,ai=null},t.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(t)}function gP(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),t=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(i){const n=globalThis["needle:codegen_files"];if(!n||n.length===0)return;let o=globalThis["needle:codegen_files"][0];const r=o.indexOf("?");r>-1&&(o=o.substring(0,r));const l=location.protocol+"//"+location.host+location.pathname+"/"+o,c=encodeURIComponent(l);s.fullUrl="https://viewer.needle.tools?inspect&file="+c;var h='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';i(h)}),s.on("show",function(){const i=t();i&&i.src!==s.fullUrl&&(i.src=s.fullUrl)}),s.on("hide",function(){const i=t();i&&(i.src="")}),s.on("addTopBar",function(i){var n=new Array;n.push({name:"Open in new window \u2197",onClick:function(o){window.open(s.fullUrl,"_blank"),ai?.hide()}}),n.push({name:"Reload",onClick:function(o){const r=t();r&&(r.src=s.fullUrl)}}),n.push({name:"Fullscreen",onClick:function(o){const r=t();r.requestFullscreen?r.requestFullscreen():r.webkitRequestFullscreen instanceof Function&&r.webkitRequestFullscreen()}}),i(n)}),s}function fP(){return document.querySelector("#__vconsole .vc-switch")||null}function yP(){return document.querySelector("#__vconsole")||null}const hb=O("debugdefines");ho('if(!globalThis[""4.1.1""]) globalThis[""4.1.1""] = "0.0.0";'),ho('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),ho('if(!globalThis[""Fri Feb 14 2025 12:52:39 GMT+0100 (Central European Standard Time)""]) globalThis[""Fri Feb 14 2025 12:52:39 GMT+0100 (Central European Standard Time)""] = "unknown";'),ho('if(!globalThis[""npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9""]) globalThis[""npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9""] = "unknown";'),ho('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.1.1";'),ho('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),ho('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Fri Feb 14 2025 12:52:39 GMT+0100 (Central European Standard Time)";'),ho('globalThis["__NEEDLE_PUBLIC_KEY__"] = "npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9";');const vs="4.1.1",Cd="undefined",ig="Fri Feb 14 2025 12:52:39 GMT+0100 (Central European Standard Time)";hb&&console.log(`Engine version: ${vs} (generator: ${Cd})
|
|
134
134
|
Project built at ${ig}`);const rc="npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9",xn="needle_isActiveInHierarchy",br="builtin_components",ac="needle_editor_guid";function ho(s){try{(0,eval)(s)}catch(t){hb&&console.error(t)}}const vP='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 160 187.74"><defs><linearGradient id="a" x1="89.64" y1="184.81" x2="90.48" y2="21.85" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#62d399"/><stop offset=".51" stop-color="#acd842"/><stop offset=".9" stop-color="#d7db0a"/></linearGradient><linearGradient id="b" x1="69.68" y1="178.9" x2="68.08" y2="16.77" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0ba398"/><stop offset=".5" stop-color="#4ca352"/><stop offset="1" stop-color="#76a30a"/></linearGradient><linearGradient id="c" x1="36.6" y1="152.17" x2="34.7" y2="84.19" gradientUnits="userSpaceOnUse"><stop offset=".19" stop-color="#36a382"/><stop offset=".54" stop-color="#49a459"/><stop offset="1" stop-color="#76a30b"/></linearGradient><linearGradient id="d" x1="15.82" y1="153.24" x2="18" y2="90.86" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#267880"/><stop offset=".51" stop-color="#457a5c"/><stop offset="1" stop-color="#717516"/></linearGradient><linearGradient id="e" x1="135.08" y1="135.43" x2="148.93" y2="63.47" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#b0d939"/><stop offset="1" stop-color="#eadb04"/></linearGradient><linearGradient id="f" x1="-4163.25" y1="2285.12" x2="-4160.81" y2="2215.34" gradientTransform="rotate(20 4088.49 13316.712)" gradientUnits="userSpaceOnUse"><stop offset=".17" stop-color="#74af52"/><stop offset=".48" stop-color="#99be32"/><stop offset="1" stop-color="#c0c40a"/></linearGradient><symbol id="g" viewBox="0 0 160 187.74"><path style="fill:url(#a)" d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75z"/><path style="fill:url(#b)" d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98z"/><path style="fill:url(#c)" d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z"/><path style="fill:url(#d)" d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04z"/><path style="fill:#9c3" d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5z"/><path style="fill:url(#e)" d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59z"/><path style="fill:url(#f)" d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z"/><path style="fill:#ffe113" d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1z"/><path style="fill:#f3e600" d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75z"/></symbol></defs><use width="160" height="187.74" xlink:href="#g"/></svg>',bP=btoa(vP),_P="data:image/svg+xml;base64,"+bP,wP=_P,xP=`<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'> <svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" version="1.1" viewBox="0 0 1014 282" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m665.95 132.73v44.88l-10.56-8.4c-0.8-0.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18 0.4-6.06 1.2s-3.54 1.8-4.98 3-2.56 2.5-3.36 3.9-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c0.32 0.24 0.56 0.44 0.72 0.6s0.36 0.32 0.6 0.48c0.96-1.2 2.14-2.28 3.54-3.24s2.92-1.76 4.56-2.4 3.34-1.14 5.1-1.5 3.44-0.54 5.04-0.54c1.44 0 2.92 0.04 4.44 0.12s2.84 0.28 3.96 0.6c4.56 1.12 7.8 3.12 9.72 6s2.88 6.56 2.88 11.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m732.38 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m795.93 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m858.57 97.21c0.64 0.48 0.96 1.16 0.96 2.04v74.88c-0.08 1.04-0.12 2.12-0.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18s-2.06-1.66-2.46-1.98c-1.76 2.48-4.26 4.44-7.5 5.88s-7.02 2.16-11.34 2.16c-3.84 0-7.4-0.7-10.68-2.1s-6.14-3.44-8.58-6.12-4.34-5.94-5.7-9.78-2.04-8.16-2.04-12.96c0-4.32 0.78-8.34 2.34-12.06s3.6-6.92 6.12-9.6 5.38-4.78 8.58-6.3 6.48-2.28 9.84-2.28c2.56 0 4.82 0.22 6.78 0.66s3.68 1.06 5.16 1.86 2.78 1.74 3.9 2.82 2.16 2.22 3.12 3.42v-35.04l10.68 8.64zm-27.96 67.92c3.6 0 6.52-0.68 8.76-2.04s3.98-3.06 5.22-5.1 2.1-4.22 2.58-6.54 0.72-4.44 0.72-6.36v-1.2c0-1.12-0.22-2.7-0.66-4.74s-1.28-4.06-2.52-6.06-3-3.7-5.28-5.1-5.22-2.02-8.82-1.86c-3.44 0-6.26 0.74-8.46 2.22s-3.96 3.26-5.28 5.34-2.24 4.2-2.76 6.36-0.78 3.92-0.78 5.28c0 1.84 0.24 3.92 0.72 6.24s1.36 4.48 2.64 6.48 3.04 3.68 5.28 5.04 5.12 2.04 8.64 2.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m882.81 97.09c0.64 0.48 0.96 1.12 0.96 1.92l-0.12 41.04v37.08l-10.56-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-77.88l10.8 8.64z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m950.36 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.8559 0 0 .7642 45.348 36.475)"> <g transform="translate(2.7114)"> <path d="m3.935 173.02c-0.331 0-0.497-0.402-0.497-1.207v-51.002c0-0.738 0.138-1.107 0.414-1.107h1.781c0.277 0 0.415 0.335 0.415 1.006v5.935c0 0.336 0.027 0.553 0.083 0.654 0.055 0.101 0.151-0.017 0.289-0.352 0.912-1.744 1.754-3.236 2.527-4.477 0.773-1.24 1.554-2.179 2.341-2.816s1.65-0.956 2.588-0.956c1.685 0 3.011 0.922 3.977 2.766 0.967 1.845 1.602 3.84 1.905 5.986 0.056 0.268 0.139 0.369 0.249 0.302s0.221-0.235 0.331-0.503c0.939-1.811 1.802-3.353 2.589-4.628 0.787-1.274 1.581-2.246 2.382-2.917s1.671-1.006 2.61-1.006c2.016 0 3.569 1.392 4.66 4.175 1.09 2.783 1.636 6.421 1.636 10.915v37.925c0 0.871-0.18 1.307-0.539 1.307h-1.739c-0.138 0-0.249-0.1-0.332-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.338-6.321-1.015-8.3-0.676-1.978-1.76-2.967-3.251-2.967-0.884 0-1.726 0.386-2.527 1.157s-1.519 1.727-2.154 2.867-1.201 2.213-1.699 3.219c-0.248 0.469-0.421 0.905-0.517 1.308-0.097 0.402-0.145 0.972-0.145 1.71v37.221c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.166 0-0.29-0.1-0.373-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.332-6.321-0.994-8.3-0.663-1.978-1.754-2.967-3.273-2.967-1.242 0-2.375 0.704-3.396 2.112-1.022 1.409-2.223 3.555-3.604 6.439v39.031c0 0.805-0.18 1.207-0.539 1.207h-1.698z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m53.642 166.28c-1.077 2.549-2.237 4.477-3.479 5.785-1.243 1.307-2.61 1.961-4.101 1.961-2.154 0-3.853-1.324-5.095-3.973-1.243-2.649-1.864-6.187-1.864-10.613 0-3.488 0.4-6.489 1.201-9.004s1.988-4.51 3.562-5.985c1.574-1.476 3.521-2.414 5.841-2.817l3.686-0.704c0.221-0.067 0.394-0.218 0.518-0.453 0.124-0.234 0.187-0.587 0.187-1.056v-2.917c0-3.89-0.504-6.975-1.512-9.255s-2.354-3.42-4.039-3.42c-1.298 0-2.472 0.72-3.521 2.162s-2.002 3.572-2.858 6.388c-0.083 0.268-0.159 0.453-0.228 0.554-0.069 0.1-0.172 0.083-0.311-0.051l-1.698-1.71c-0.083-0.134-0.138-0.285-0.166-0.453-0.027-0.167 0.014-0.452 0.125-0.855 0.856-3.353 2.009-6.052 3.459-8.098 1.449-2.045 3.224-3.068 5.322-3.068 1.74 0 3.211 0.687 4.412 2.062s2.112 3.37 2.734 5.986c0.621 2.615 0.932 5.7 0.932 9.255v35.712c0 0.536-0.035 0.888-0.104 1.056s-0.2 0.251-0.393 0.251h-1.533c-0.166 0-0.29-0.117-0.373-0.352-0.083-0.234-0.124-0.553-0.124-0.955l-0.083-5.231c-0.055-0.939-0.221-1.006-0.497-0.202zm0.456-19.314c0-1.14-0.194-1.643-0.58-1.509l-3.107 0.603c-1.436 0.202-2.686 0.638-3.749 1.308-1.063 0.671-1.953 1.543-2.671 2.616s-1.257 2.33-1.616 3.772-0.538 3.102-0.538 4.98c0 3.152 0.455 5.616 1.367 7.393 0.911 1.778 2.14 2.666 3.686 2.666 0.939 0 1.85-0.419 2.734-1.257s1.671-1.895 2.361-3.169c0.663-1.408 1.181-2.85 1.553-4.326 0.373-1.475 0.56-2.883 0.56-4.225v-8.852z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m79.034 173.02c-0.166 0-0.297-0.117-0.394-0.352-0.096-0.234-0.145-0.553-0.145-0.955v-4.628c0-0.536-0.041-0.838-0.124-0.905s-0.207 0.1-0.373 0.503c-0.276 0.67-0.69 1.593-1.242 2.766-0.553 1.174-1.271 2.23-2.154 3.169-0.884 0.939-1.961 1.408-3.231 1.408-1.74 0-3.314-0.989-4.722-2.967-1.409-1.979-2.534-4.963-3.376-8.953-0.843-3.991-1.264-8.937-1.264-14.838 0-5.701 0.415-10.68 1.243-14.939s1.988-7.595 3.479-10.009c1.492-2.415 3.204-3.622 5.137-3.622 1.436 0 2.616 0.57 3.541 1.71 0.926 1.14 1.719 2.381 2.382 3.722 0.249 0.47 0.414 0.637 0.497 0.503s0.125-0.536 0.125-1.207v-23.841c0-0.805 0.151-1.208 0.455-1.208h1.864c0.276 0 0.414 0.369 0.414 1.107v72.128c0 0.537-0.041 0.905-0.124 1.107-0.083 0.201-0.235 0.301-0.455 0.301h-1.533zm-0.621-42.049c-0.939-2.213-1.885-3.94-2.838-5.181s-2.009-1.861-3.169-1.861c-1.463 0-2.768 0.889-3.914 2.666s-2.044 4.376-2.693 7.796-0.973 7.578-0.973 12.474c0 5.097 0.338 9.272 1.015 12.524 0.676 3.253 1.567 5.651 2.672 7.193 1.104 1.543 2.305 2.314 3.603 2.314 1.188 0 2.258-0.704 3.211-2.113 0.952-1.408 1.705-3.118 2.257-5.13s0.829-3.957 0.829-5.835v-24.847z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m89.514 149.38c0 3.42 0.345 6.606 1.035 9.557 0.691 2.951 1.609 5.315 2.755 7.092s2.437 2.666 3.873 2.666c1.519 0 2.837-0.738 3.956-2.213 1.118-1.476 2.064-3.655 2.837-6.539 0.083-0.336 0.166-0.52 0.249-0.554 0.083-0.033 0.179 0.017 0.29 0.151l1.408 1.912c0.221 0.268 0.235 0.67 0.041 1.207-0.69 2.548-1.47 4.661-2.34 6.337-0.87 1.677-1.857 2.935-2.962 3.773-1.104 0.838-2.319 1.257-3.645 1.257-2.043 0-3.838-1.14-5.385-3.42-1.546-2.28-2.761-5.482-3.645-9.607-0.884-4.124-1.325-8.836-1.325-14.134 0-5.901 0.455-10.931 1.367-15.089 0.911-4.158 2.14-7.377 3.686-9.658 1.547-2.28 3.3-3.42 5.261-3.42 1.988 0 3.714 1.073 5.178 3.219 1.463 2.146 2.595 5.231 3.396 9.255s1.201 8.886 1.201 14.587c0 0.469-0.02 0.939-0.062 1.408-0.041 0.469-0.214 0.704-0.517 0.704h-16.362c-0.083 0-0.152 0.151-0.207 0.453-0.056 0.302-0.083 0.654-0.083 1.056zm13.752-6.237c0.304 0 0.497-0.1 0.58-0.302 0.083-0.201 0.124-0.57 0.124-1.106 0-3.219-0.283-6.187-0.849-8.903s-1.367-4.896-2.402-6.539c-1.036-1.643-2.272-2.464-3.708-2.464-1.629 0-2.996 0.955-4.101 2.867-1.104 1.911-1.94 4.342-2.506 7.293s-0.849 6.002-0.849 9.154h13.711z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m148.54 119.7c0.165 0 0.283 0.117 0.352 0.352s0.076 0.52 0.02 0.855l-6.254 50.902c-0.028 0.47-0.104 0.788-0.228 0.956s-0.297 0.251-0.518 0.251h-1.615c-0.442 0-0.718-0.402-0.829-1.207l-5.26-40.138c-0.111-0.604-0.201-0.905-0.27-0.905s-0.131 0.301-0.186 0.905l-5.012 40.138c-0.028 0.47-0.097 0.788-0.207 0.956-0.111 0.168-0.277 0.251-0.497 0.251h-1.74c-0.442 0-0.718-0.402-0.829-1.207l-6.503-50.801c-0.055-0.403-0.048-0.721 0.021-0.956s0.2-0.352 0.393-0.352h1.823c0.166 0 0.297 0.067 0.393 0.201 0.097 0.134 0.159 0.403 0.187 0.805l5.302 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.219-41.949c0.055-0.268 0.124-0.47 0.207-0.604s0.193-0.201 0.331-0.201h1.533c0.138 0 0.262 0.067 0.373 0.201 0.11 0.134 0.179 0.403 0.207 0.805l5.468 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.053-41.849c0.055-0.335 0.138-0.57 0.249-0.704 0.11-0.134 0.234-0.201 0.373-0.201h1.284z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m156.49 171.51c0 0.604-0.042 1.006-0.125 1.208-0.082 0.201-0.262 0.301-0.538 0.301h-1.533c-0.221 0-0.366-0.083-0.435-0.251s-0.103-0.486-0.103-0.956v-50.902c0-0.805 0.152-1.207 0.456-1.207h1.822c0.304 0 0.456 0.402 0.456 1.207v50.6zm0.165-63.979c0 1.207-0.207 1.811-0.621 1.811h-1.905c-0.221 0-0.366-0.135-0.435-0.403s-0.104-0.67-0.104-1.207v-7.847c0-1.006 0.18-1.509 0.539-1.509h1.988c0.359 0 0.538 0.47 0.538 1.409v7.746z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m168.3 124.83c-0.221 0-0.331 0.269-0.331 0.805v33.801c0 3.42 0.221 5.667 0.663 6.74 0.441 1.073 1.09 1.609 1.946 1.609h3.024c0.138 0 0.242 0.084 0.311 0.252 0.069 0.167 0.103 0.419 0.103 0.754v2.716c0 0.537-0.138 0.906-0.414 1.107-0.248 0.067-0.614 0.134-1.098 0.201-0.483 0.067-0.959 0.118-1.429 0.151-0.469 0.034-0.828 0.05-1.077 0.05-1.712 0-2.934-0.955-3.665-2.867-0.732-1.911-1.098-5.013-1.098-9.305v-35.108c0-0.604-0.124-0.906-0.373-0.906h-3.521c-0.248 0-0.373-0.268-0.373-0.804v-3.521c0-0.537 0.111-0.805 0.332-0.805h3.686c0.166 0 0.263-0.268 0.29-0.805l0.415-16.095c0-0.805 0.124-1.207 0.372-1.207h1.492c0.303 0 0.455 0.436 0.455 1.307v15.995c0 0.537 0.097 0.805 0.29 0.805h5.468c0.221 0 0.331 0.268 0.331 0.805v3.521c0 0.536-0.124 0.804-0.373 0.804h-5.426z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m179.4 173.02c-0.331 0-0.497-0.402-0.497-1.207v-72.329c0-0.738 0.138-1.107 0.414-1.107h1.782c0.276 0 0.414 0.336 0.414 1.006v27.162c0 0.335 0.034 0.536 0.103 0.603s0.159-0.033 0.27-0.302c0.994-1.81 1.898-3.319 2.713-4.526 0.814-1.208 1.629-2.113 2.444-2.717 0.814-0.603 1.691-0.905 2.63-0.905 2.182 0 3.839 1.375 4.971 4.125 1.132 2.749 1.698 6.404 1.698 10.965v37.925c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.165 0-0.29-0.1-0.373-0.301-0.082-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.366-6.321-1.097-8.3-0.732-1.978-1.899-2.967-3.501-2.967-0.883 0-1.705 0.318-2.464 0.956-0.76 0.637-1.526 1.576-2.299 2.816-0.773 1.241-1.643 2.834-2.61 4.779v39.031c0 0.805-0.179 1.207-0.538 1.207h-1.699z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> </g> <g transform="matrix(.80638 0 0 .80638 452.53 65.421)" fill-rule="nonzero"> <path d="m79.32 36.98v150.76l15.68-13.2 6.59-156.31-22.27 18.75z" fill="url(#f)"/> <path d="m79.32 36.98-22.27-18.75 6.59 156.31 15.68 13.2v-150.76z" fill="url(#e)"/> <path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z" fill="url(#d)"/> <path d="m25.19 104.83-25.19-14.59 16.97 53.86 16.85 9.77-8.63-49.04z" fill="url(#c)"/> <path d="M43.86,82.5L18.69,67.98L0,90.24L25.18,104.83L43.86,82.5Z" fill="#9c3"/> <path d="m134.82 78.69-9.97 56.5 15.58-9.04 19.57-62.05-25.18 14.59z" fill="url(#b)"/> <path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z" fill="url(#a)"/> <path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33 25.19-14.59z" fill="#ffe113"/> <path d="M101.59,18.23L79.32,0L57.05,18.23L79.32,36.98L101.59,18.23Z" fill="#f3e600"/> </g> <defs> <linearGradient id="f" x2="1" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)" gradientUnits="userSpaceOnUse"><stop stop-color="#62d399" offset="0"/><stop stop-color="#acd842" offset=".51"/><stop stop-color="#d7db0a" offset=".9"/><stop stop-color="#d7db0a" offset="1"/></linearGradient> <linearGradient id="e" x2="1" gradientTransform="matrix(-1.6,-162.13,162.13,-1.6,69.68,178.9)" gradientUnits="userSpaceOnUse"><stop stop-color="#0ba398" offset="0"/><stop stop-color="#4ca352" offset=".5"/><stop stop-color="#76a30a" offset="1"/></linearGradient> <linearGradient id="d" x2="1" gradientTransform="matrix(-1.9,-67.98,67.98,-1.9,36.6,152.17)" gradientUnits="userSpaceOnUse"><stop stop-color="#36a382" offset="0"/><stop stop-color="#36a382" offset=".19"/><stop stop-color="#49a459" offset=".54"/><stop stop-color="#76a30b" offset="1"/></linearGradient> <linearGradient id="c" x2="1" gradientTransform="matrix(2.18,-62.38,62.38,2.18,15.82,153.24)" gradientUnits="userSpaceOnUse"><stop stop-color="#267880" offset="0"/><stop stop-color="#457a5c" offset=".51"/><stop stop-color="#717516" offset="1"/></linearGradient> <linearGradient id="b" x2="1" gradientTransform="matrix(13.85,-71.96,71.96,13.85,135.08,135.43)" gradientUnits="userSpaceOnUse"><stop stop-color="#b0d939" offset="0"/><stop stop-color="#eadb04" offset="1"/></linearGradient> <linearGradient id="a" x2="1" gradientTransform="matrix(26.159 -64.737 64.737 26.159 107.42 128.14)" gradientUnits="userSpaceOnUse"><stop stop-color="#74af52" offset="0"/><stop stop-color="#74af52" offset=".17"/><stop stop-color="#99be32" offset=".48"/><stop stop-color="#c0c40a" offset="1"/></linearGradient> </defs> </svg>`;btoa(xP);const SP='<svg viewBox="0 0 509 154" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M665.95 132.73v44.88l-10.56-8.4c-.8-.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18.4-6.06 1.2-1.88.8-3.54 1.8-4.98 3-1.44 1.2-2.56 2.5-3.36 3.9-.8 1.4-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-.72-.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c.32.24.56.44.72.6.16.16.36.32.6.48.96-1.2 2.14-2.28 3.54-3.24 1.4-.96 2.92-1.76 4.56-2.4 1.64-.64 3.34-1.14 5.1-1.5 1.76-.36 3.44-.54 5.04-.54 1.44 0 2.92.04 4.44.12 1.52.08 2.84.28 3.96.6 4.56 1.12 7.8 3.12 9.72 6 1.92 2.88 2.88 6.56 2.88 11.04ZM732.38 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM795.93 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM858.57 97.21c.64.48.96 1.16.96 2.04v74.88c-.08 1.04-.12 2.12-.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18-1.24-1-2.06-1.66-2.46-1.98-1.76 2.48-4.26 4.44-7.5 5.88-3.24 1.44-7.02 2.16-11.34 2.16-3.84 0-7.4-.7-10.68-2.1-3.28-1.4-6.14-3.44-8.58-6.12-2.44-2.68-4.34-5.94-5.7-9.78-1.36-3.84-2.04-8.16-2.04-12.96 0-4.32.78-8.34 2.34-12.06 1.56-3.72 3.6-6.92 6.12-9.6 2.52-2.68 5.38-4.78 8.58-6.3 3.2-1.52 6.48-2.28 9.84-2.28 2.56 0 4.82.22 6.78.66 1.96.44 3.68 1.06 5.16 1.86s2.78 1.74 3.9 2.82a35.92 35.92 0 0 1 3.12 3.42V88.57l10.68 8.64Zm-27.96 67.92c3.6 0 6.52-.68 8.76-2.04 2.24-1.36 3.98-3.06 5.22-5.1a20.5 20.5 0 0 0 2.58-6.54c.48-2.32.72-4.44.72-6.36v-1.2c0-1.12-.22-2.7-.66-4.74-.44-2.04-1.28-4.06-2.52-6.06s-3-3.7-5.28-5.1c-2.28-1.4-5.22-2.02-8.82-1.86-3.44 0-6.26.74-8.46 2.22-2.2 1.48-3.96 3.26-5.28 5.34-1.32 2.08-2.24 4.2-2.76 6.36-.52 2.16-.78 3.92-.78 5.28 0 1.84.24 3.92.72 6.24.48 2.32 1.36 4.48 2.64 6.48s3.04 3.68 5.28 5.04c2.24 1.36 5.12 2.04 8.64 2.04ZM882.81 97.09c.64.48.96 1.12.96 1.92l-.12 41.04v37.08l-10.56-8.4c-.72-.64-1.08-1.44-1.08-2.4V88.45l10.8 8.64ZM950.36 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14Z" style="fill-rule:nonzero" transform="translate(-452.406 -63.709) scale(1.00797)"/><path d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75Z" style="fill:url(#a);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98Z" style="fill:url(#b);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33Z" style="fill:url(#c);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04Z" style="fill:url(#d);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5Z" style="fill:#9c3;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59Z" style="fill:url(#e);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5Z" style="fill:url(#f);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1Z" style="fill:#ffe113;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75Z" style="fill:#f3e600;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><defs><linearGradient id="a" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)"><stop offset="0" style="stop-color:#62d399;stop-opacity:1"/><stop offset=".51" style="stop-color:#acd842;stop-opacity:1"/><stop offset=".9" style="stop-color:#d7db0a;stop-opacity:1"/><stop offset="1" style="stop-color:#d7db0a;stop-opacity:1"/></linearGradient><linearGradient id="b" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-90.565 123.412 54.953) scale(162.14)"><stop offset="0" style="stop-color:#0ba398;stop-opacity:1"/><stop offset=".5" style="stop-color:#4ca352;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30a;stop-opacity:1"/></linearGradient><linearGradient id="c" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="scale(-68) rotate(88.4 .881 -1.396)"><stop offset="0" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".19" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".54" style="stop-color:#49a459;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30b;stop-opacity:1"/></linearGradient><linearGradient id="d" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-88 87.255 68.431) scale(62.42)"><stop offset="0" style="stop-color:#267880;stop-opacity:1"/><stop offset=".51" style="stop-color:#457a5c;stop-opacity:1"/><stop offset="1" style="stop-color:#717516;stop-opacity:1"/></linearGradient><linearGradient id="e" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-79.1 149.53 -14.065) scale(73.28)"><stop offset="0" style="stop-color:#b0d939;stop-opacity:1"/><stop offset="1" style="stop-color:#eadb04;stop-opacity:1"/></linearGradient><linearGradient id="f" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-67.997 148.705 -15.558) scale(69.8226)"><stop offset="0" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".17" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".48" style="stop-color:#99be32;stop-opacity:1"/><stop offset="1" style="stop-color:#c0c40a;stop-opacity:1"/></linearGradient></defs></svg>',CP=btoa(SP),OP="data:image/svg+xml;charset=utf-8;base64,"+CP,PP=OP,kP=O("debugpatch");function Od(s,t,i,n){const o=kP===t;if(!i&&!n)return;const r=t+"___needle";RP(s,t,i,n);const l=Object.getOwnPropertyDescriptor(s,t),c=s[t];o&&console.log("Patch",s.constructor.name,t,l,c),l?(o&&console.log("Apply patch with existing descriptor",s.constructor.name,t,l),typeof l.value=="function"&&(s[t]=ub(l.value,s,t))):(o&&console.log("Create patch with new property",s.constructor.name,t,l),Object.defineProperty(s,t,{set:function(h){if(typeof h=="function")this[r]=ub(h,s,t);else{const d=this[r];pb(s,t,this,d,h),this[r]=h,mb(s,t,this,d,h)}},get:function(){const h=this[r];return typeof h=="function"&&h[r]?h[r]:h}}))}function MP(s,t,i){const n=ng(s,t);if(n)for(let o=n.length-1;o>=0;o--){const r=n[o];r.prefix===i&&(r.prefix=null),r.postfix===i&&(r.postfix=null),!r.prefix&&!r.postfix&&n.splice(o,1)}}const db=Symbol("Needle:Patches:WrappedFunction");function ub(s,t,i){if(s[db])return s;const n=function(...o){pb(t,i,this,...o);const r=s.apply(this,o);return mb(t,i,this,r,...o),r};return n[db]=!0,n}const Pd="Needle:Patches";function sg(){return globalThis[Pd]||(globalThis[Pd]=new WeakMap),globalThis[Pd]}function ng(s,t){const i=sg().get(s);return i?i.get(t):null}function RP(s,t,i,n){let o=sg().get(s);o||(o=new Map,sg().set(s,o));let r=o.get(t);r||(r=[],o.set(t,r)),r.push({prefix:i,postfix:n})}function pb(s,t,i,...n){var o;if(!i)return;const r=ng(s,t);if(r)for(const l of r)(o=l.prefix)==null||o.call(i,...n)}function mb(s,t,i,n,...o){var r;if(!i)return;const l=ng(s,t);if(l)for(const c of l)(r=c.postfix)==null||r.call(i,n,...o)}const Pa=[];function kd(s){Pa.indexOf(s)===-1&&Pa.push(s)}function TP(s){const t=Pa.indexOf(s);t!==-1&&Pa.splice(t,1)}const ka=[];function og(s){ka.indexOf(s)===-1&&ka.push(s)}function EP(s){const t=ka.indexOf(s);t!==-1&&ka.splice(t,1)}function gb(s){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-start",{detail:s}));for(let t=0;t<Pa.length;t++)Pa[t](s)}function fb(s){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-end",{detail:s}));for(let t=0;t<ka.length;t++)ka[t](s)}const ht=O("debuginput");var Md=(s=>(s.Mouse="mouse",s.Touch="touch",s.Controller="controller",s.Hand="hand",s))(Md||{}),De=(s=>(s.PointerDown="pointerdown",s.PointerUp="pointerup",s.PointerMove="pointermove",s.KeyDown="keydown",s.KeyUp="keyup",s.KeyPressed="keypress",s))(De||{});class Sn extends PointerEvent{constructor(t,i,n){super(t,n),a(this,"clientZ"),a(this,"deviceIndex"),a(this,"origin"),a(this,"source"),a(this,"mode"),a(this,"_ray"),a(this,"space"),a(this,"isClick",!1),a(this,"isDoubleClick",!1),a(this,"_used",!1),a(this,"_pointerid"),a(this,"_pointerType"),a(this,"_type"),a(this,"metadata",{}),a(this,"intersections",new Array),a(this,"_immediatePropagationStopped",!1),a(this,"_propagationStopped",!1),this.clientZ=n.clientZ,this._pointerid=n.pointerId,this._pointerType=n.pointerType,this._type=t,this.deviceIndex=n.deviceIndex,this.origin=n.origin,this.source=i,this.mode=n.mode,this._ray=n.ray,this.space=n.device}get isSpatial(){return this.mode!="screen"}get ray(){return this._ray||(this._ray=new hr(this.space.worldPosition.clone(),this.space.worldForward.clone())),this._ray}set ray(t){this._ray=t}get hasRay(){return this._ray!==void 0}get used(){return this._used}use(){this._used=!0}get pointerId(){return this._pointerid}get pointerType(){return this._pointerType}get type(){return this._type}get immediatePropagationStopped(){return this._immediatePropagationStopped}get propagationStopped(){return this._immediatePropagationStopped||this._propagationStopped}stopImmediatePropagation(){var t;this._immediatePropagationStopped=!0,super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}stopPropagation(){var t;this._propagationStopped=!0,super.stopPropagation(),(t=this.source)==null||t.stopPropagation(),ht&&console.warn("Stop propagation...",this.pointerId,this.pointerType)}}class lc extends KeyboardEvent{constructor(t,i,n){super(t,n),a(this,"source"),this.source=i}stopImmediatePropagation(){var t;super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}}class AP{constructor(t){a(this,"key"),a(this,"keyType"),a(this,"source"),this.key=t.key,this.keyType=t.type,this.source=t}}var Ci=(s=>(s[s.Early=-100]="Early",s[s.Default=0]="Default",s[s.Late=100]="Late",s))(Ci||{});class yb{constructor(t){a(this,"_eventListeners",{}),a(this,"_doubleClickTimeThreshold",.2),a(this,"_longPressTimeThreshold",1),a(this,"_specialCursorTrigger",0),a(this,"context"),a(this,"_pointerDown",[!1]),a(this,"_pointerUp",[!1]),a(this,"_pointerClick",[!1]),a(this,"_pointerDoubleClick",[!1]),a(this,"_pointerPressed",[!1]),a(this,"_pointerPositions",[new oe]),a(this,"_pointerPositionsLastFrame",[new oe]),a(this,"_pointerPositionsDelta",[new oe]),a(this,"_pointerPositionsRC",[new oe]),a(this,"_pointerPositionDown",[new x]),a(this,"_pointerDownTime",[]),a(this,"_pointerUpTime",[]),a(this,"_pointerUpTimestamp",[]),a(this,"_pointerIds",[]),a(this,"_pointerTypes",[""]),a(this,"_mouseWheelChanged",[!1]),a(this,"_mouseWheelDeltaY",[0]),a(this,"_pointerEvent",[]),a(this,"_pointerEventsPressed",[]),a(this,"_pointerSpace",[]),a(this,"_pressedStack",new Map),a(this,"_htmlEventSource"),a(this,"onLostFocus",()=>{for(const i in this.keysPressed)this.keysPressed[i].pressed=!1}),a(this,"onEndOfFrame",()=>{for(let i=0;i<this._pointerUp.length;i++)this._pointerUp[i]=!1;for(let i=0;i<this._pointerDown.length;i++)this._pointerDown[i]=!1;for(let i=0;i<this._pointerClick.length;i++)this._pointerClick[i]=!1;for(let i=0;i<this._pointerDoubleClick.length;i++)this._pointerDoubleClick[i]=!1;for(const i of this._pointerPositionsDelta)i.set(0,0);for(let i=0;i<this._mouseWheelChanged.length;i++)this._mouseWheelChanged[i]=!1;for(let i=0;i<this._mouseWheelDeltaY.length;i++)this._mouseWheelDeltaY[i]=0}),a(this,"onContextMenu",i=>{this.canReceiveInput(i)!==!1&&i instanceof PointerEvent&&i.pointerType}),a(this,"keysPressed",{}),a(this,"onKeyDown",i=>{if(ht&&console.log(`key down ${i.code}, ${this.context.application.hasFocus}`,i),!this.context.application.hasFocus)return;const n=this.keysPressed[i.code];if(n&&n.pressed)return;this.keysPressed[i.code]={pressed:!0,frame:this.context.time.frameCount+1,startFrame:this.context.time.frameCount+1,key:i.key,code:i.code};const o=new lc("keydown",i,i);this.onDispatchEvent(o)}),a(this,"onKeyPressed",i=>{if(!this.context.application.hasFocus)return;const n=this.keysPressed[i.code];if(!n)return;n.pressed=!0,n.frame=this.context.time.frameCount+1;const o=new lc("keypress",i,i);this.onDispatchEvent(o)}),a(this,"onKeyUp",i=>{if(!this.context.application.hasFocus)return;const n=this.keysPressed[i.code];if(!n)return;n.pressed=!1,n.frame=this.context.time.frameCount+1;const o=new lc("keyup",i,i);this.onDispatchEvent(o)}),a(this,"onWheelWindow",i=>{document.pointerLockElement&&this.onMouseWheel(i)}),a(this,"onMouseWheel",i=>{if(this.canReceiveInput(i)===!1)return;this._mouseWheelDeltaY.length<=0&&this._mouseWheelDeltaY.push(0),this._mouseWheelChanged.length<=0&&this._mouseWheelChanged.push(!1),this._mouseWheelChanged[0]=!0;const n=this._mouseWheelDeltaY[0];this._mouseWheelDeltaY[0]=n+i.deltaY}),a(this,"onPointerDown",i=>{if(this.context.isInAR||this.canReceiveInput(i)===!1)return;i.target instanceof HTMLElement&&i.target.setPointerCapture(i.pointerId);const n=this.getPointerId(i);ht&&Le(`pointer down #${n}, identifier:${i.pointerId}`);const o=this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),r=new Sn("pointerdown",i,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:i.button,clientX:i.clientX,clientY:i.clientY,pointerType:i.pointerType,buttonName:this.getButtonName(i),device:o,pressure:i.pressure});this.onDown(r)}),a(this,"onPointerMove",i=>{if(this.context.isInAR)return;let n=i.button;i.pointerType==="mouse"&&(n=this.getFirstPressedButtonForPointer(0)??0);const o=this.getPointerId(i,n);n===-1&&(n=o);const r=this.getAndUpdateSpatialObjectForScreenPosition(o,i.clientX,i.clientY),l=new Sn("pointermove",i,{origin:this,mode:"screen",deviceIndex:0,pointerId:o,button:n,clientX:i.clientX,clientY:i.clientY,pointerType:i.pointerType,buttonName:this.getButtonName(i),device:r,pressure:i.pressure});this.onMove(l)}),a(this,"onPointerCancel",i=>{this.context.isInAR||(ht&&console.log("Pointer cancel",i),this.onPointerUp(i))}),a(this,"onPointerUp",i=>{if(this.context.isInAR)return;i.target instanceof HTMLElement&&i.target.releasePointerCapture(i.pointerId);const n=this.getPointerId(i),o=new Sn("pointerup",i,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:i.button,clientX:i.clientX,clientY:i.clientY,pointerType:i.pointerType,buttonName:this.getButtonName(i),device:this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),pressure:i.pressure});this.onUp(o),this._pointerIds[n]=-1,ht&&console.log("ID="+n,"PointerId="+i.pointerId,"ALL:",[...this._pointerIds])}),a(this,"onTouchStart",i=>{if(this.context.isInAR)for(let n=0;n<i.changedTouches.length;n++){const o=i.changedTouches[n],r=this.getPointerIndex(o.identifier),l=this.getAndUpdateSpatialObjectForScreenPosition(r,o.clientX,o.clientY),c=new Sn("pointerdown",i,{origin:this,mode:"screen",deviceIndex:0,pointerId:r,button:0,clientX:o.clientX,clientY:o.clientY,pointerType:"touch",buttonName:"unknown",device:l,pressure:o.force});this.onDown(c)}}),a(this,"onTouchMove",i=>{if(this.context.isInAR)for(let n=0;n<i.changedTouches.length;n++){const o=i.changedTouches[n],r=this.getPointerIndex(o.identifier),l=this.getAndUpdateSpatialObjectForScreenPosition(r,o.clientX,o.clientY),c=new Sn("pointermove",i,{origin:this,mode:"screen",deviceIndex:0,pointerId:r,button:0,clientX:o.clientX,clientY:o.clientY,pointerType:"touch",buttonName:"unknown",device:l,pressure:o.force});this.onMove(c)}}),a(this,"onTouchEnd",i=>{if(this.context.isInAR)for(let n=0;n<i.changedTouches.length;n++){const o=i.changedTouches[n],r=this.getPointerIndex(o.identifier),l=new Sn("pointerup",i,{origin:this,mode:"screen",deviceIndex:0,pointerId:r,button:0,clientX:o.clientX,clientY:o.clientY,pointerType:"touch",buttonName:"unknown",device:this.getAndUpdateSpatialObjectForScreenPosition(r,o.clientX,o.clientY),pressure:o.force});this.onUp(l),this._pointerIds[r]=-1}}),a(this,"tempNearPlaneVector",new x),a(this,"tempFarPlaneVector",new x),a(this,"tempLookMatrix",new ne),this.context=t,this.context.post_render_callbacks.push(this.onEndOfFrame)}addEventListener(t,i,n){if(this._eventListeners[t]||(this._eventListeners[t]=[]),!i||typeof i!="function"){console.error("Invalid call to addEventListener: callback is required and must be a function!");return}n?n={...n}:n={};let o=0;n?.queue!=null&&(o=n.queue);const r=this._eventListeners[t],l=r.find(c=>c.priority===o);l?l.listeners.push({callback:i,options:n}):(r.push({priority:o,listeners:[{callback:i,options:n}]}),r.sort((c,h)=>c.priority-h.priority))}removeEventListener(t,i,n){if(!this._eventListeners[t]||!i)return;const o=this._eventListeners[t];if(n?.queue!=null){const r=o.find(c=>c.priority===n.queue);if(!r)return;const l=r.listeners.findIndex(c=>c.callback===i);l>=0&&r.listeners.splice(l,1)}else for(const r of o){const l=r.listeners.findIndex(c=>c.callback===i);l>=0&&r.listeners.splice(l,1)}}dispatchEvent(t){var i,n,o,r;let l=!1;if(t instanceof lc){const c=this._eventListeners[t.type];if(c)for(const h of c)for(let d=0;d<h.listeners.length;d++){const u=h.listeners[d];if((n=(i=u.options)==null?void 0:i.signal)!=null&&n.aborted){h.listeners.splice(d,1),d--;continue}u.options.once&&(h.listeners.splice(d,1),d--),u.callback(t)}}if(t instanceof Sn){const c=this._eventListeners[t.type];if(c)for(const h of c){if(l)break;for(let d=0;d<h.listeners.length;d++){const u=h.listeners[d];if((r=(o=u.options)==null?void 0:o.signal)!=null&&r.aborted){h.listeners.splice(d,1),d--;continue}if(t.immediatePropagationStopped){l=!0,ht&&console.log("immediatePropagationStopped",t.type);break}else t.propagationStopped&&(l=!0,ht&&console.log("propagationStopped",t.type));u.options.once&&(h.listeners.splice(d,1),d--),u.callback(t)}}}}get mousePosition(){return this._pointerPositions[0]}get mousePositionRC(){return this._pointerPositionsRC[0]}get mouseDown(){return this._pointerDown[0]}get mouseUp(){return this._pointerUp[0]}get mouseClick(){return this._pointerClick[0]}get mouseDoubleClick(){return this._pointerDoubleClick[0]}get mousePressed(){return this._pointerPressed[0]}get mouseWheelChanged(){return this.getMouseWheelChanged(0)}get click(){return this._pointerClick[0]}get doubleClick(){return this._pointerDoubleClick[0]}setCursorPointer(){this._specialCursorTrigger+=1,this.context.domElement.style.cursor="pointer"}setCursorNormal(){this._specialCursorTrigger-=1,this._specialCursorTrigger=Math.max(0,this._specialCursorTrigger),this._specialCursorTrigger===0&&(this.context.domElement.style.cursor="default")}getIsPointerIdInUse(t){for(const i of this._pointerEventsPressed)if(i.pointerId===t&&i.used)return!0;return!1}getPointerPressedCount(){let t=0;for(let i=0;i<this._pointerPressed.length;i++)this._pointerPressed[i]&&t++;return t}getPointerPosition(t){return t>=this._pointerPositions.length?null:this._pointerPositions[t]}getPointerPositionLastFrame(t){return t>=this._pointerPositionsLastFrame.length?null:this._pointerPositionsLastFrame[t]}getPointerPositionDelta(t){return t>=this._pointerPositionsDelta.length?null:this._pointerPositionsDelta[t]}getPointerPositionRC(t){return t>=this._pointerPositionsRC.length?null:this._pointerPositionsRC[t]}getPointerDown(t){return t>=this._pointerDown.length?!1:this._pointerDown[t]}getPointerUp(t){return t>=this._pointerUp.length?!1:this._pointerUp[t]}getPointerPressed(t){return t>=this._pointerPressed.length?!1:this._pointerPressed[t]}getPointerClicked(t){return t>=this._pointerClick.length?!1:this._pointerClick[t]}getPointerDoubleClicked(t){return t>=this._pointerDoubleClick.length?!1:this._pointerDoubleClick[t]}getPointerDownTime(t){return t>=this._pointerDownTime.length?-1:this._pointerDownTime[t]}getPointerUpTime(t){return t>=this._pointerUpTime.length?-1:this._pointerUpTime[t]}getPointerLongPress(t){return t>=this._pointerDownTime.length?!1:this.getPointerPressed(t)&&this.context.time.time-this._pointerDownTime[t]>this._longPressTimeThreshold}getIsMouse(t){return t<0||t>=this._pointerTypes.length?!1:this._pointerTypes[t]==="mouse"}getIsTouch(t){return t<0||t>=this._pointerTypes.length?!1:this._pointerTypes[t]==="touch"}getTouchesPressedCount(){let t=0;for(let i=0;i<this._pointerPressed.length;i++)this._pointerPressed[i]&&this.getIsTouch(i)&&t++;return t}getMouseWheelChanged(t=0){return t>=this._mouseWheelChanged.length?!1:this._mouseWheelChanged[t]}getMouseWheelDeltaY(t=0){return t>=this._mouseWheelDeltaY.length?0:this._mouseWheelDeltaY[t]}getPointerEvent(t){if(!(t>=this._pointerEvent.length))return this._pointerEvent[t]??void 0}*foreachPointerId(t){for(let i=0;i<this._pointerTypes.length;i++)if(this._pointerIsActive(i)){if(t!==void 0){const n=this._pointerTypes[i];if(Array.isArray(t)){let o=!1;for(const r of t)if(n===r){o=!0;break}if(!o)continue}else if(t!==n)continue}yield i}}*foreachTouchId(){for(let t=0;t<this._pointerTypes.length;t++)this._pointerTypes[t]==="touch"&&this._pointerIsActive[t]&&(yield t)}_pointerIsActive(t){return t<0?!1:this._pointerPressed[t]||this._pointerDown[t]||this._pointerUp[t]}onDownButton(t,i){let n=this._pressedStack.get(t);n||(n=[],this._pressedStack.set(t,n)),n.push(i)}onReleaseButton(t,i){const n=this._pressedStack.get(t);if(!n)return;const o=n.indexOf(i);o>=0&&n.splice(o,1)}getFirstPressedButtonForPointer(t){const i=this._pressedStack.get(t);if(i)return i[0]}getLatestPressedButtonForPointer(t){const i=this._pressedStack.get(t);if(i)return i[i.length-1]}getKeyDown(){for(const t in this.keysPressed){const i=this.keysPressed[t];if(i.startFrame===this.context.time.frameCount)return i.key}return null}getKeyPressed(){for(const t in this.keysPressed){const i=this.keysPressed[t];if(i.pressed)return i.key}return null}isKeyDown(t){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const n=this.getCodeForCommonKeyName(t);if(n!==null){for(const o of n)if(this.isKeyDown(o))return!0;return!1}return((i=this.keysPressed[t])==null?void 0:i.startFrame)===this.context.time.frameCount&&this.keysPressed[t].pressed}isKeyUp(t){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const n=this.getCodeForCommonKeyName(t);if(n!==null){for(const o of n)if(this.isKeyUp(o))return!0;return!1}return((i=this.keysPressed[t])==null?void 0:i.frame)===this.context.time.frameCount&&!this.keysPressed[t].pressed}isKeyPressed(t){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const n=this.getCodeForCommonKeyName(t);if(n!==null){for(const o of n)if(this.isKeyPressed(o))return!0;return!1}return(i=this.keysPressed[t])==null?void 0:i.pressed}getCodeForCommonKeyName(t){if(t.length===1){if(t>="0"&&t<="9")return["Digit"+t];if(t>="a"&&t<="z")return["Key"+t.toUpperCase()];if(t==" ")return["Space"]}switch(t){case"shift":case"Shift":return["ShiftLeft","ShiftRight"];case"control":case"Control":return["ControlLeft","ControlRight"];case"alt":case"Alt":return["AltLeft","AltRight"]}return null}createInputEvent(t){switch(t.type){case"pointerdown":ht&&Le("Create Pointer down"),this.onDownButton(t.deviceIndex,t.button),this.onDown(t);break;case"pointermove":ht&&Le("Create Pointer move"),this.onMove(t);break;case"pointerup":ht&&Le("Create Pointer up"),this.onUp(t),this.onReleaseButton(t.deviceIndex,t.button);break}}convertScreenspaceToRaycastSpace(t){return t.x=(t.x-this.context.domX)/this.context.domWidth*2-1,t.y=-((t.y-this.context.domY)/this.context.domHeight)*2+1,t}bindEvents(){this.unbindEvents(),this._htmlEventSource=this.context.renderer.domElement,window.addEventListener("contextmenu",this.onContextMenu),this._htmlEventSource.addEventListener("pointerdown",this.onPointerDown,{passive:!0}),window.addEventListener("pointermove",this.onPointerMove,{passive:!0,capture:!0}),window.addEventListener("pointerup",this.onPointerUp,{passive:!0}),window.addEventListener("pointercancel",this.onPointerCancel,{passive:!0}),window.addEventListener("touchstart",this.onTouchStart,{passive:!0}),window.addEventListener("touchmove",this.onTouchMove,{passive:!0}),window.addEventListener("touchend",this.onTouchEnd,{passive:!0}),this._htmlEventSource.addEventListener("wheel",this.onMouseWheel,{passive:!0}),window.addEventListener("wheel",this.onWheelWindow,{passive:!0}),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keypress",this.onKeyPressed,!1),window.addEventListener("keyup",this.onKeyUp,!1),window.addEventListener("blur",this.onLostFocus)}unbindEvents(){var t,i;window.removeEventListener("contextmenu",this.onContextMenu),(t=this._htmlEventSource)==null||t.removeEventListener("pointerdown",this.onPointerDown),window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerCancel),(i=this._htmlEventSource)==null||i.removeEventListener("wheel",this.onMouseWheel,!1),window.removeEventListener("wheel",this.onWheelWindow,!1),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keypress",this.onKeyPressed,!1),window.removeEventListener("keyup",this.onKeyUp,!1),window.removeEventListener("blur",this.onLostFocus)}dispose(){const t=this.context.post_render_callbacks.indexOf(this.onEndOfFrame);t>=0&&this.context.post_render_callbacks.splice(t,1),this.unbindEvents()}canReceiveInput(t){var i;return t.target===((i=this.context.renderer)==null?void 0:i.domElement)||t.target===this.context.domElement||this.context.isInAR||this.context.isInAR&&t.target===document.body&&Y.isMozillaXR()?!0:(ht&&console.warn("CanReceiveInput:False for",t.target),!1)}getPointerId(t,i){return t.pointerType==="mouse"?0+(i??t.button):this.getPointerIndex(t.pointerId)}getButtonName(t){const i=t.button;if(t.pointerType==="mouse")switch(i){case 0:return"left";case 1:return"middle";case 2:return"right"}return"unknown"}getAndUpdateSpatialObjectForScreenPosition(t,i,n){let o=this._pointerSpace[t];o||(o=new j,this._pointerSpace[t]=o),this._pointerSpace[t]=o;const r=this.context.mainCamera;if(r){const l=this.tempNearPlaneVector.set(i,n,-1);this.convertScreenspaceToRaycastSpace(l);const c=this.tempFarPlaneVector.set(l.x,l.y,1);l.unproject(r),c.unproject(r);const h=r.worldUp||$(0,1,0).applyQuaternion(Se(r));this.tempLookMatrix.lookAt(c,l,h),o.position.set(l.x,l.y,l.z),o.quaternion.setFromRotationMatrix(this.tempLookMatrix)}return o}isInRect(t){if(this.context.isInXR)return!0;const i=this.context.domElement.getBoundingClientRect(),n=t.clientX,o=t.clientY,r=n>=i.x&&n<=i.right&&o>=i.y&&o<=i.bottom;return ht&&!r&&console.log("Not in rect",i,n,o),r}onDown(t){const i=t.pointerId;if(this.getPointerPressed(i)&&console.warn(`Received pointerDown for pointerId that is already pressed: ${i}`,ht?t:""),ht&&console.log(t.pointerType,"DOWN",i),!!this.isInRect(t)){for(this.setPointerState(i,this._pointerPressed,!0),this.setPointerState(i,this._pointerDown,!0),this.setPointerStateT(i,this._pointerEvent,t.source);i>=this._pointerTypes.length;)this._pointerTypes.push(t.pointerType);for(this._pointerTypes[i]=t.pointerType;i>=this._pointerPositionDown.length;)this._pointerPositionDown.push(new x);for(this._pointerPositionDown[i].set(t.clientX,t.clientY,t.clientZ??0);i>=this._pointerPositions.length;)this._pointerPositions.push(new oe);this._pointerPositions[i].set(t.clientX,t.clientY),i>=this._pointerDownTime.length&&this._pointerDownTime.push(0),this._pointerDownTime[i]=this.context.time.realtimeSinceStartup,this.updatePointerPosition(t),this._pointerEventsPressed.push(t),this.onDispatchEvent(t)}}onMove(t){const i=t.pointerId,n=this.getPointerPressed(i);n===!1&&!this.isInRect(t)||t.pointerType==="touch"&&!n||(this.updatePointerPosition(t),this.setPointerStateT(i,this._pointerEvent,t.source),this.onDispatchEvent(t))}onUp(t){const i=t.pointerId;if(!this.getPointerPressed(i)){ht&&console.log(t.pointerType,"UP",i,"was not down");return}ht&&console.log(t.pointerType,"UP",i),this.setPointerState(i,this._pointerPressed,!1),this.setPointerStateT(i,this._pointerEvent,t.source),this.setPointerState(i,this._pointerUp,!0),this.updatePointerPosition(t);for(let c=this._pointerEventsPressed.length-1;c>=0;c--)if(this._pointerEventsPressed[c].pointerId===i){this._pointerEventsPressed.splice(c,1);break}if(!this._pointerPositionDown[i]){ht&&_e("Received pointer up event without matching down event for button: "+i),console.warn("Received pointer up event without matching down event for button: "+i);return}const n=this._pointerUpTime[i],o=this._pointerDownTime[i],r=this.context.time.realtimeSinceStartup,l=r-o;if(i>=this._pointerUpTime.length&&this._pointerUpTime.push(-99),this._pointerUpTime[i]=r,l<1){let c=t.clientX-this._pointerPositionDown[i].x,h=t.clientY-this._pointerPositionDown[i].y,d=0;if(t.isSpatial&&t.clientZ!=null&&(d=t.clientZ-this._pointerPositionDown[i].z,c*=200,h*=200,d*=200),Math.abs(c)<5&&Math.abs(h)<5&&Math.abs(d)<5){this.setPointerState(i,this._pointerClick,!0),t.isClick=!0;const u=r-n;ht&&console.log("CLICK",i,c,h,d,u),u<this._doubleClickTimeThreshold&&u>0&&(this.setPointerState(i,this._pointerDoubleClick,!0),t.isDoubleClick=!0)}}this.onDispatchEvent(t)}updatePointerPosition(t){const i=t.pointerId;for(;i>=this._pointerPositions.length;)this._pointerPositions.push(new oe);for(;i>=this._pointerPositionsLastFrame.length;)this._pointerPositionsLastFrame.push(new oe);for(;i>=this._pointerPositionsDelta.length;)this._pointerPositionsDelta.push(new oe);const n=this._pointerPositionsLastFrame[i];n.copy(this._pointerPositions[i]);const o=this._pointerPositionsDelta[i];let r=t.clientX-n.x,l=t.clientY-n.y;if(t.source instanceof MouseEvent||t.source instanceof TouchEvent){const u=t.source;r===0&&u.movementX!==0&&(r=u.movementX||0),l===0&&u.movementY!==0&&(l=u.movementY||0)}o.x+=r,o.y+=l,this._pointerPositions[i].x=t.clientX,this._pointerPositions[i].y=t.clientY;const c=t.clientX,h=t.clientY;for(;i>=this._pointerPositionsRC.length;)this._pointerPositionsRC.push(new oe);const d=this._pointerPositionsRC[i];d.set(c,h),this.convertScreenspaceToRaycastSpace(d)}getPointerIndex(t){let i=-1;for(let n=0;n<this._pointerIds.length;n++){if(this._pointerIds[n]===t)return n;i===-1&&this._pointerIds[n]===-1&&(i=n)}return i!==-1?(this._pointerIds[i]=t,i):(ht&&console.log("PUSH pointerId:",t),this._pointerIds.push(t),this._pointerIds.length-1)}setPointerState(t,i,n){i[t]=n}setPointerStateT(t,i,n){return i[t]=n,n}onDispatchEvent(t){const i=te.Current;try{te.Current=this.context,this.dispatchEvent(t)}finally{te.Current=i}}}const Ma=new ne().makeRotationY(Math.PI),Qi=new V().setFromAxisAngle(new x(0,1,0),Math.PI),IP=O("debugwebxr");class jP{constructor(){if(a(this,"priority",-1e5),a(this,"gameObject"),this.gameObject=new j,this.gameObject.name="Implicit XR Rig",IP){const t=wg(16733661);t.position.y+=.5,this.gameObject.add(t)}}isXRRig(){return!0}get isActive(){return this.gameObject.visible}}const zs=O("debugwebxr"),Rd=O("debugcustomgesture"),LP="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",DP="generic-trigger",BP=new V().setFromEuler(new Ft(vn.degToRad(0),vn.degToRad(-90),vn.degToRad(-90))),FP=new x(.04,-.04,0);class rg{constructor(t,i,n){a(this,"xr"),a(this,"inputSource"),a(this,"index",0),a(this,"emitEvents",!0),a(this,"_connected",!0),a(this,"_isTracking",!1),a(this,"__gamepad"),a(this,"__hand"),a(this,"__side"),a(this,"_hitTestSource"),a(this,"_hasSelectEvent",!1),a(this,"_isMxInk",!1),a(this,"_isMxInkFallback",!1),a(this,"_isMetaQuestTouchController",!1),a(this,"_handJointPoses",new Map),a(this,"_gripMatrix",new ne),a(this,"_gripPosition",new x),a(this,"_gripQuaternion",new V),a(this,"_linearVelocity",new x),a(this,"_rayPositionRaw",new x),a(this,"_rayRotationRaw",new V),a(this,"_rayMatrix",new ne),a(this,"_rayPosition",new x),a(this,"_rayQuaternion",new V),a(this,"_gripWorldPosition",new x),a(this,"_gripWorldQuaternion",new V),a(this,"_rayWorldPosition",new x),a(this,"_rayWorldQuaternion",new V),a(this,"_pinchPosition",new x),a(this,"_ray"),a(this,"_hand_wristDotUp"),a(this,"_object"),a(this,"_gripSpaceObject"),a(this,"_raySpaceObject"),a(this,"model",null),a(this,"_debugAxesHelper",new bi(.15)),a(this,"_debugGripAxesHelper",new bi(.07)),a(this,"_debugRayAxesHelper",new bi(.07)),a(this,"_hitTestSourcePromise",null),a(this,"onPointerHits",o=>{}),a(this,"_needleGamepadButtons",{}),a(this,"_buttonMap",new Map),a(this,"_motioncontroller"),a(this,"_layout"),a(this,"getMotionController"),a(this,"emitPointerDownEvent",!0),a(this,"emitPointerUpEvent",!0),a(this,"emitPointerMoveEvent",!0),a(this,"pointerMoveDistanceThreshold",.03),a(this,"pointerMoveAngleThreshold",.05),a(this,"_selectButtonIndex"),a(this,"_squeezeButtonIndex"),a(this,"onSelectStart",o=>{var r,l,c,h;if(!this.emitPointerDownEvent||this.inputSource!==o.inputSource)return;this.onUpdateFrame(o.frame),this._hasSelectEvent=!0;const d=(r=this._layout)==null?void 0:r.selectComponentId,u=(h=(c=(l=this._layout)==null?void 0:l.components[d])==null?void 0:c.gamepadIndices)==null?void 0:h.button;u!==void 0&&(this._selectButtonIndex=u),!Rd&&(zs&&q.DrawDirection(this.rayWorldPosition,$(0,.01,1).applyQuaternion(this.rayWorldQuaternion),16711680,10),this.emitPointerEvent(De.PointerDown,this._selectButtonIndex||0,"xr-standard-trigger",!0,o))}),a(this,"onSelectEnd",o=>{this.emitPointerUpEvent&&(Rd||this.inputSource===o.inputSource&&this.emitPointerEvent(De.PointerUp,this._selectButtonIndex||0,"xr-standard-trigger",!0,o))}),a(this,"onSequeezeStart",o=>{var r,l,c;this.emitPointerDownEvent&&this.inputSource===o.inputSource&&(this._squeezeButtonIndex=(c=(l=(r=this._layout)==null?void 0:r.components["xr-standard-squeeze"])==null?void 0:l.gamepadIndices)==null?void 0:c.button,this._squeezeButtonIndex!==void 0&&(zs&&q.DrawDirection(this.rayWorldPosition,$(0,.01,1).applyQuaternion(this.rayWorldQuaternion),255,10),this.emitPointerEvent(De.PointerDown,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,o)))}),a(this,"onSequeezeEnd",o=>{this.emitPointerUpEvent&&this.inputSource===o.inputSource&&this._squeezeButtonIndex!==void 0&&this.emitPointerEvent(De.PointerUp,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,o)}),a(this,"states",{}),a(this,"_didMoveLastFrame",!1),a(this,"_lastPointerMovePosition",new x),a(this,"_lastPointerMoveQuaternion",new V),a(this,"pointerInit"),this.xr=t,this.inputSource=i,this.index=n,this._object=new j,this._object.name=`NeedleXRController_${n}`,zs&&(this._object.add(this._debugAxesHelper),this._gripSpaceObject=new j,this._raySpaceObject=new j,this._gripSpaceObject.name=`NeedleXRController_${n}_gripSpace`,this._raySpaceObject.name=`NeedleXRController_${n}_raySpace`,this._gripSpaceObject.add(this._debugGripAxesHelper),this._raySpaceObject.add(this._debugRayAxesHelper),this.xr.context.scene.add(this._gripSpaceObject),this.xr.context.scene.add(this._raySpaceObject)),this.xr.context.scene.add(this._object),this._ray=new hr,this.pointerInit={origin:this,pointerType:this.hand?"hand":"controller",deviceIndex:this.index,pointerId:-1,mode:this.inputSource.targetRayMode,ray:this._ray,device:this._object,buttonName:"none"},this.initialize(),this.subscribeEvents()}get context(){return this.xr.context}get connected(){return this._connected}get isTracking(){return this._isTracking}get gamepad(){return this.__gamepad??(this.__gamepad=this.inputSource.gamepad)}get isHand(){return this.hand!=null}get hand(){return this.__hand??(this.__hand=this.inputSource.hand)}get handObject(){return this.context.renderer.xr.getHand(this.index)}get profiles(){return this.inputSource.profiles}get layout(){return this._layout}get targetRayMode(){return this.inputSource.targetRayMode}get targetRaySpace(){return this.inputSource.targetRaySpace}get gripSpace(){return this.inputSource.gripSpace}get side(){return this.__side??(this.__side=this.inputSource.handedness)}get isRight(){return this.side==="right"}get isLeft(){return this.side==="left"}get isStylus(){return this._isMxInk}getHitTestSource(){return this._hitTestSource||this._requestHitTestSource(),this._hitTestSource}get hasHitTestSource(){return this._hitTestSource}cancelHitTestSource(){this._hitTestSource&&(this._hitTestSource.cancel(),this._hitTestSource=void 0)}get hasSelectEvent(){return this._hasSelectEvent}getHitTest(){return this.xr.getHitTest(this)}getHandJointPose(t,i){var n;if(i=i||this.xr.frame,!this.hand||!(i!=null&&i.getJointPose)||!this.xr.referenceSpace)return null;let o=(n=this._handJointPoses)==null?void 0:n.get(t);return o||(o=i.getJointPose(t,this.xr.referenceSpace),o&&this._handJointPoses.set(t,o),o)}get gripPosition(){return $(this._gripPosition)}get gripQuaternion(){return fs(this._gripQuaternion)}get gripMatrix(){return this._gripMatrix}get gripLinearVelocity(){return $(this._linearVelocity).applyQuaternion(Qi)}get rayPosition(){return $(this._rayPosition)}get rayQuaternion(){return fs(this._rayQuaternion)}get gripWorldPosition(){return $(this._gripWorldPosition)}get gripWorldQuaternion(){return fs(this._gripWorldQuaternion)}get rayWorldPosition(){return $(this._rayWorldPosition)}updateRayWorldPosition(){var t;const i=(t=this.xr.context.mainCamera)==null?void 0:t.parent;this._rayWorldPosition.copy(this._rayPositionRaw),i&&this._rayWorldPosition.applyMatrix4(i.matrixWorld)}get rayWorldQuaternion(){return fs(this._rayWorldQuaternion)}get pinchPosition(){return $(this._pinchPosition)}updateRayWorldQuaternion(){var t;const i=(t=this.xr.context.mainCamera)==null?void 0:t.parent,n=i?Se(i):void 0;this._rayWorldQuaternion.copy(this._rayRotationRaw).multiply(Qi),n&&this._rayWorldQuaternion.premultiply(n)}get ray(){return this._ray.origin.copy(this.rayWorldPosition),this._ray.direction.copy($(0,0,1).applyQuaternion(this.rayWorldQuaternion)),this._ray}get handWristDotUp(){var t;if(this._hand_wristDotUp!==void 0)return this._hand_wristDotUp;const i=(t=this.handObject)==null?void 0:t.joints.wrist;if(i){const n=$(0,1,0).applyQuaternion(i.quaternion),o=$(0,1,0).dot(n);return this._hand_wristDotUp=o}}get isHandUpsideDown(){return this.handWristDotUp!==void 0?this.handWristDotUp<-.7:!1}get isTeleportGesture(){var t;return this.isHandUpsideDown&&((t=this.getGesture("pinch"))==null?void 0:t.isDown)}get object(){return this._object}async getModelUrl(){var t;return(t=this.getMotionController)==null?void 0:t.then(i=>i?.assetUrl||null)}_requestHitTestSource(){var t;return this._hitTestSourcePromise?this._hitTestSourcePromise:this.xr.mode==="immersive-ar"&&this.inputSource.targetRayMode==="tracked-pointer"&&this.xr.session.requestHitTestSourceForTransientInput?this._hitTestSourcePromise=((t=this.xr.session.requestHitTestSourceForTransientInput({profile:this.inputSource.profiles[0],offsetRay:new XRRay}))==null?void 0:t.then(i=>(this._hitTestSourcePromise=null,this.connected?this._hitTestSource=i:(i.cancel(),null))))??null:null}onUpdate(t){performance.mark("NeedleXRController onUpdate start"),this.onUpdateFrame(t),this.updateInputEvents(),this.onUpdateMove(),performance.mark("NeedleXRController onUpdate end"),performance.measure("NeedleXRController onUpdate","NeedleXRController onUpdate start","NeedleXRController onUpdate end")}onRenderDebug(){var t;q.DrawSphere(this.rayWorldPosition,.003),q.DrawDirection(this.rayWorldPosition,$(0,0,10).applyQuaternion(this.rayWorldQuaternion));const i=(this.inputSource.gripSpace?this.gripWorldPosition:this.object.worldPosition).sub(this.object.worldForward.multiplyScalar(.1)),n=this.inputSource.profiles.join(`
|
|
135
135
|
`);let o=`Controller[${this.index}] (${this.inputSource.targetRayMode}, ${this.side})
|
|
136
136
|
C:${this.connected?"x":"-"} T:${this.isTracking?"x":"-"} Hand:${this.inputSource.hand?"x":"-"} Pen: ${this._isMxInk?"x":"-"}`;if(this.inputSource.hand&&(o+=`
|
|
@@ -1198,7 +1198,7 @@ dateFormat X
|
|
|
1198
1198
|
axisFormat %s
|
|
1199
1199
|
`;const g=Array.from(r),y=new Set;for(const w of g)if(w.affectedObjects&&typeof w.affectedObjects!="string"){if(Array.isArray(w.affectedObjects))for(const _ of w.affectedObjects)y.add(_);else y.add(w.affectedObjects);l&&(p+=`section ${w.animationName} (${w.id})
|
|
1200
1200
|
`,p+=`${w.id} : ${w.start}, ${w.duration}s
|
|
1201
|
-
`)}l&&console.log(p);const f=new Set;for(const w of y){w.getPath||console.error("USDZExporter: Animation target object has no getPath method. This is likely a bug",w);let _=w.getPath();_.startsWith("<")&&(_=_.substring(1)),_.endsWith(">")&&(_=_.substring(0,_.length-1)),f.add({path:_,obj:w})}const v=Array.from(f).sort((w,_)=>w.path.length-_.path.length),b=new Array;for(let w=0;w<v.length;w++)for(let _=w+1;_<v.length;_++)if(v[_].path.startsWith(v[w].path)){const C=v[_],R=v[w];b.push({child:C.obj.displayName+" ("+C.path+")",parent:R.obj.displayName+" ("+R.path+")"})}b.length&&console.warn("USDZExporter: There are overlapping PlayAnimation actions. This can lead to undefined runtime behaviour when playing multiple animations. Please restructure the hierarchy so that animations don't overlap.",{overlappingTargets:b,playAnimationActions:r})}for(const p of new Set([...i,...n]))if(Array.isArray(p))for(const g of p)o.add(g.uuid);else o.add(p.uuid);cp&&console.log("All Behavior trigger sources and action targets",i,n,o),this.targetUuids=new Set(o)}onAfterHierarchy(t,i){var n;if((n=this.behaviours)!=null&&n.length){i.beginBlock('def Scope "Behaviors"');for(const o of this.behaviours)o.writeTo(this,t.document,i);i.closeBlock()}}async onAfterSerialize(t){cp&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const i of this.behaviourComponentsCopy)typeof i.afterSerialize=="function"&&(i.afterSerialize.constructor.name==="AsyncFunction"?await i.afterSerialize(this,t):i.afterSerialize(this,t));for(const{clipUrl:i,filesKey:n}of this.audioClipsCopy){if(t.files[n])return;const o=await(await(await fetch(i)).blob()).arrayBuffer(),r=new Uint8Array(o);t.files[n]=r}this.behaviourComponentsCopy.length=0,this.audioClipsCopy.length=0}}var pT=Object.defineProperty,mT=Object.getOwnPropertyDescriptor,$e=(s,t,i,n)=>{for(var o=n>1?void 0:n?mT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&pT(t,i,o),o};const zx=O("debugusdzbehaviours");function rh(s){s&&(s.getComponentInParent(zc)||(F()&&console.debug('Raycaster on "'+s.name+'" was automatically added, because no raycaster was found in the parent hierarchy.'),s.addComponent(Ti)))}class $r extends A{constructor(){super(...arguments),a(this,"object"),a(this,"target"),a(this,"duration",1),a(this,"relativeMotion",!1),a(this,"coroutine",null),a(this,"targetPos",new x),a(this,"targetRot",new V),a(this,"targetScale",new x)}start(){rh(this.gameObject)}onPointerClick(t){t.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}*moveToTarget(){if(!this.target||!this.object)return;const t=ee(this.object).clone(),i=ee(this.target).clone(),n=Se(this.object).clone(),o=Se(this.target).clone(),r=Ke(this.object).clone(),l=Ke(this.target).clone(),c=t.distanceTo(i),h=n.angleTo(o),d=r.distanceTo(l);if(c<.01&&h<.01&&d<.01){ct(this.object,i),qi(this.object,o),Oa(this.object,l),this.coroutine=null;return}let u=0,p=0;for(;u<1;)u+=this.context.time.deltaTime/this.duration,u>1&&(u=1),p=u<.5?4*u*u*u:1-Math.pow(-2*u+2,3)/2,this.targetPos.lerpVectors(t,i,p),this.targetRot.slerpQuaternions(n,o,p),this.targetScale.lerpVectors(r,l,p),ct(this.object,this.targetPos),qi(this.object,this.targetRot),Oa(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const t=this.object.position.clone(),i=this.object.quaternion.clone(),n=this.object.scale.clone(),o=this.target.position.clone(),r=this.target.quaternion.clone(),l=this.target.scale.clone();o.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(o),this.targetRot.copy(this.object.quaternion).multiply(r),this.targetScale.copy(this.object.scale).multiply(l);let c=0,h=0;for(;c<1;)c+=this.context.time.deltaTime/this.duration,c>1&&(c=1),h=c<.5?4*c*c*c:1-Math.pow(-2*c+2,3)/2,this.object.position.lerpVectors(t,this.targetPos,h),this.object.quaternion.slerpQuaternions(i,this.targetRot,h),this.object.scale.lerpVectors(n,this.targetScale,h),yield;this.coroutine=null}beforeCreateDocument(t){var i;if(this.target&&this.object&&this.gameObject){const n=new _t("Move to "+((i=this.target)==null?void 0:i.name),wt.tapTrigger(this.gameObject),ue.transformAction(this.object,this.target,this.duration,this.relativeMotion?"relative":"absolute"));t.addBehavior(n)}}}$e([m(j)],$r.prototype,"object",2),$e([m(j)],$r.prototype,"target",2),$e([m()],$r.prototype,"duration",2),$e([m()],$r.prototype,"relativeMotion",2);var dp;const sn=(dp=class extends A{constructor(){super(...arguments),a(this,"materialToSwitch"),a(this,"variantMaterial"),a(this,"fadeDuration",0),a(this,"_objectsWithThisMaterial",null),a(this,"selfModel"),a(this,"targetModels")}start(){var s;this._objectsWithThisMaterial=this.objectsWithThisMaterial,rh(this.gameObject),F()&&this._objectsWithThisMaterial.length<=0&&console.warn('ChangeMaterialOnClick: No objects found with material "'+((s=this.materialToSwitch)==null?void 0:s.name)+'"')}onPointerEnter(s){this.context.input.setCursorPointer()}onPointerExit(s){this.context.input.setCursorNormal()}onPointerClick(s){if(s.use(),!!this.variantMaterial)for(let t=0;t<this.objectsWithThisMaterial.length;t++){const i=this.objectsWithThisMaterial[t];i.material=this.variantMaterial}}get objectsWithThisMaterial(){return this._objectsWithThisMaterial!=null?this._objectsWithThisMaterial:(this._objectsWithThisMaterial=[],this.variantMaterial&&this.materialToSwitch&&this.context.scene.traverse(s=>{if(s instanceof Q)if(Array.isArray(s.material)){for(const t of s.material)if(t===this.materialToSwitch){this.objectsWithThisMaterial.push(s);break}}else s.material===this.materialToSwitch?this.objectsWithThisMaterial.push(s):g_(s.material,this.materialToSwitch)&&this.objectsWithThisMaterial.push(s)}),this._objectsWithThisMaterial)}async beforeCreateDocument(s,t){this.targetModels=[],sn._materialTriggersPerId={},sn.variantSwitchIndex=0,this.materialToSwitch&&await et.assignTextureLOD(this.materialToSwitch,0),this.variantMaterial&&await et.assignTextureLOD(this.variantMaterial,0)}createBehaviours(s,t,i){this.objectsWithThisMaterial.find(n=>n.uuid===t.uuid)&&this.targetModels.push(t),this.gameObject.uuid===t.uuid&&(this.selfModel=t,this.materialToSwitch&&(sn._materialTriggersPerId[this.materialToSwitch.uuid]||(sn._materialTriggersPerId[this.materialToSwitch.uuid]=[]),sn._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(s,t){if(!this.materialToSwitch)return;const i=sn._materialTriggersPerId[this.materialToSwitch.uuid];if(i){const n={};for(const o of i){const r=o.createVariants();r&&r.length>0&&(n[o.selfModel.uuid]=r)}for(const o of i){const r=[];for(const l in n)l!==o.selfModel.uuid&&r.push(...n[l]);o.createAndAttachBehaviors(s,n[o.selfModel.uuid],r)}}delete sn._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(s,t,i){const n=[],o=[],r=Math.max(0,this.fadeDuration);o.push(ue.fadeAction([...this.targetModels,...i],r,!1)),n.push(ue.fadeAction(t,r,!1)),o.push(ue.fadeAction(t,r,!0)),s.addBehavior(new _t("Select_"+this.selfModel.name,wt.tapTrigger(this.selfModel),ue.parallel(...o))),s.addBehavior(new _t("StartHidden_"+this.selfModel.name,wt.sceneStartTrigger(),ue.parallel(...n)))}static getMaterialName(s){return Ms(s.name||"Material")+"_"+s.id}createVariants(){if(!this.variantMaterial)return null;const s=[];for(const t of this.targetModels){const i=t.clone();i.name+="_Variant_"+sn.variantSwitchIndex+++"_"+sn.getMaterialName(this.variantMaterial),i.displayName=i.displayName+": Variant with material "+this.variantMaterial.name,i.material=this.variantMaterial,i.geometry=t.geometry,i.transform=t.transform,(!t.parent||!t.parent.isEmpty())&&Zt.createEmptyParent(t),t.parent&&t.parent.add(i),s.push(i)}return s}},a(dp,"_materialTriggersPerId",{}),a(dp,"variantSwitchIndex",0),dp);let ml=sn;$e([m(Oe)],ml.prototype,"materialToSwitch",2),$e([m(Oe)],ml.prototype,"variantMaterial",2),$e([m()],ml.prototype,"fadeDuration",2);var gl;const qe=(gl=class extends A{constructor(){super(...arguments),a(this,"target"),a(this,"toggleOnClick",!1),a(this,"targetState",!0),a(this,"hideSelf",!0),a(this,"selfModel"),a(this,"selfModelClone"),a(this,"targetModel"),a(this,"toggleModel"),a(this,"stateBeforeCreatingDocument",!1),a(this,"targetStateBeforeCreatingDocument",!1)}start(){rh(this.gameObject)}onPointerClick(s){s.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(s,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t,this.selfModelClone=t.clone())}beforeCreateDocument(){this.target&&(this.gameObject[qe.wasVisible]===void 0&&(this.gameObject[qe.wasVisible]=this.gameObject.activeSelf),this.target[qe.wasVisible]===void 0&&(this.target[qe.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[qe.wasVisible],this.targetStateBeforeCreatingDocument=this.target[qe.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(s,t){if(!this.target)return;this.targetModel=t.document.findById(this.target.uuid);const i=this.selfModel;if(this.selfModel&&this.targetModel){let n=this.selfModel,o=this.targetState;if(this.toggleOnClick)if(o=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&Jf.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[qe.toggleClone]){const c=this.selfModelClone.clone();c.setMatrix(new ne),c.name+="_toggle"+qe.clonedToggleIndex++,i.add(c),this.gameObject[qe.toggleClone]=c,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const l=this.gameObject[qe.toggleClone];if(!this.gameObject[qe.reverseToggleClone]){const c=this.selfModelClone.clone();c.setMatrix(new ne),c.name+="_toggleReverse"+qe.clonedToggleIndex++,i.add(c),this.gameObject[qe.reverseToggleClone]=c}this.toggleModel=this.gameObject[qe.reverseToggleClone],(!this.toggleModel.geometry||!l.geometry)&&console.error("triggers without childs and without geometry won't work!",this,i.geometry),n=l,i.geometry=null,i.material=null}if(this.toggleModel){if(this.toggleOnClick){const l=[];l.push(ue.fadeAction(n,0,!1)),l.push(ue.fadeAction(this.toggleModel,0,!0)),l.push(ue.fadeAction(this.targetModel,0,o)),s.addBehavior(new _t("Toggle_"+n.name+"_toggleTo"+(o?"On":"Off"),wt.tapTrigger(n),ue.parallel(...l)));const c=[];c.push(ue.fadeAction(this.toggleModel,0,!1)),c.push(ue.fadeAction(n,0,!0)),c.push(ue.fadeAction(this.targetModel,0,!o)),s.addBehavior(new _t("Toggle_"+n.name+"_toggleTo"+(o?"Off":"On"),wt.tapTrigger(this.toggleModel),ue.parallel(...c)))}}else{const l=[];this.hideSelf&&l.push(ue.fadeAction(n,0,!1)),l.push(ue.fadeAction(this.targetModel,0,o)),s.addBehavior(new _t("Toggle_"+n.name+"_toggleTo"+(o?"On":"Off"),wt.tapTrigger(n),ue.parallel(...l)))}const r=new Array;this.targetStateBeforeCreatingDocument||r.push(this.targetModel),this.stateBeforeCreatingDocument||r.push(i),this.toggleModel&&r.push(this.toggleModel),s.addBehavior(new _t("HideOnStart_"+this.gameObject.name,wt.sceneStartTrigger(),ue.fadeAction(r,0,!1)))}}afterSerialize(s,t){this.gameObject[qe.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[qe.wasVisible],delete this.gameObject[qe.wasVisible]),this.target&&this.target[qe.wasVisible]!==void 0&&(this.target.visible=this.target[qe.wasVisible],delete this.target[qe.wasVisible]),delete this.gameObject[qe.toggleClone],delete this.gameObject[qe.reverseToggleClone]}},a(gl,"clonedToggleIndex",0),a(gl,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),a(gl,"toggleClone",Symbol("clone for toggling")),a(gl,"reverseToggleClone",Symbol("clone for reverse toggling")),gl);let qr=qe;$e([m(j)],qr.prototype,"target",2),$e([m()],qr.prototype,"toggleOnClick",2),$e([m()],qr.prototype,"targetState",2),$e([m()],qr.prototype,"hideSelf",2);class u0 extends A{constructor(){super(...arguments),a(this,"wasVisible",!1)}start(){P.setActive(this.gameObject,!1)}createBehaviours(t,i,n){i.uuid===this.gameObject.uuid&&(this.wasVisible||t.addBehavior(new _t("HideOnStart_"+this.gameObject.name,wt.sceneStartTrigger(),ue.fadeAction(i,0,!1))))}beforeCreateDocument(){this.wasVisible=P.isActiveSelf(this.gameObject)}}class fl extends A{constructor(){super(...arguments),a(this,"target"),a(this,"duration",.5),a(this,"motionType","bounce")}beforeCreateDocument(){}createBehaviours(t,i,n){if(this.target&&i.uuid===this.gameObject.uuid){const o=new _t("emphasize "+this.name,wt.tapTrigger(this.gameObject),ue.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));t.addBehavior(o)}}afterCreateDocument(t,i){}}$e([m()],fl.prototype,"target",2),$e([m()],fl.prototype,"duration",2),$e([m()],fl.prototype,"motionType",2);class Io extends A{constructor(){super(...arguments),a(this,"target"),a(this,"clip",""),a(this,"toggleOnClick",!1),a(this,"trigger","tap")}start(){rh(this.gameObject)}ensureAudioSource(){if(!this.target){const t=this.gameObject.addComponent(We);t&&(this.target=t,t.spatialBlend=1,t.volume=1,t.loop=!1,t.preload=!0)}}onPointerClick(t){var i;t.use(),!(!((i=this.target)!=null&&i.clip)&&!this.clip)&&(this.ensureAudioSource(),this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play())))}createBehaviours(t,i,n){if(!(!this.target&&!this.clip)&&i.uuid===this.gameObject.uuid){const o=this.clip?this.clip:this.target?this.target.clip:void 0;if(!o||typeof o!="string")return;const r=this.target?this.target.gameObject:this.gameObject;lr.getName(o);const l=this.target?this.target.volume:1,c=this.target&&this.target.spatialBlend==0?"nonSpatial":"spatial";let h=!1;this.gameObject.traverse(g=>{g instanceof Q&&g.visible&&(h=!0)}),h=!0;const d=t.addAudioClip(o);let u=ue.playAudioAction(r,d,"play",l,c);this.target&&this.target.loop&&(u=ue.sequence(u).makeLooping());const p=this.name?"_"+this.name:"";if(h&&this.trigger==="tap"){this.toggleOnClick&&(u.multiplePerformOperation="stop");const g=new _t("playAudio"+p,wt.tapTrigger(i),u);t.addBehavior(g)}if(this.target&&this.target.playOnAwake&&this.target.enabled)if(h&&this.trigger==="tap")console.warn("USDZExport: Audio sources that are played on tap can't also auto-play at scene start due to a QuickLook bug.");else{const g=new _t("playAudioOnStart"+p,wt.sceneStartTrigger(),u);t.addBehavior(g)}}}}$e([m(We)],Io.prototype,"target",2),$e([m(URL)],Io.prototype,"clip",2),$e([m()],Io.prototype,"toggleOnClick",2);var up;const nn=(up=class extends A{constructor(){super(...arguments),a(this,"animator"),a(this,"stateName"),a(this,"trigger","tap"),a(this,"animation"),a(this,"selfModel"),a(this,"stateAnimationModel"),a(this,"animationSequence",new Array),a(this,"animationLoopAfterSequence",new Array),a(this,"randomOffsetNormalized",0)}get target(){var s,t;return((s=this.animator)==null?void 0:s.gameObject)||((t=this.animation)==null?void 0:t.gameObject)}start(){rh(this.gameObject)}onPointerClick(s){var t;s.use(),this.target&&this.stateName&&((t=this.animator)==null||t.play(this.stateName,0,0,.1))}createBehaviours(s,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}afterSerialize(){if(nn.rootsWithExclusivePlayback.size>1){const s='Multiple root objects targeted by more than one animation. To work around QuickLook bug FB13410767, animations will be set as "exclusive" and activating them will stop other animations being marked as exclusive.';F()&&_e(s),console.warn(s,...nn.rootsWithExclusivePlayback)}nn.animationActions=[],nn.rootsWithExclusivePlayback=new Set}afterCreateDocument(s,t){if(this.animationSequence===void 0&&this.animationLoopAfterSequence===void 0||!this.stateAnimationModel||!this.target)return;const i=t.document,n=t.extensions.find(l=>l instanceof oh);if(!n)return;const o=n.getClipCount(this.target)>1;o&&(F()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+n.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),nn.rootsWithExclusivePlayback.add(this.target));const r=this.name?this.name:"";i.traverse(l=>{var c,h;if(l.uuid===((c=this.target)==null?void 0:c.uuid)){const d=nn.getActionForSequences(i,l,this.animationSequence,this.animationLoopAfterSequence,this.randomOffsetNormalized),u=new _t(this.trigger+"_"+r+"_toPlayAnimation_"+this.stateName+"_on_"+((h=this.target)==null?void 0:h.name),this.trigger=="tap"?wt.tapTrigger(this.selfModel):wt.sceneStartTrigger(),d);o&&u.makeExclusive(!0),s.addBehavior(u)}})}static getActionForSequences(s,t,i,n,o){const r=(c,h)=>{let d=nn.animationActions.find(u=>u.affectedObjects==c&&u.start==h.start&&u.duration==h.duration&&u.animationSpeed==h.speed);return d||(d=ue.startAnimationAction(c,h),nn.animationActions.push(d)),d},l=ue.sequence();if(i&&i.length>0)for(const c of i)l.addAction(r(t,c));if(n&&n.length>0){const c=l.actions.length==0?l:ue.sequence();for(const h of n)c.addAction(r(t,h));c.makeLooping(),l!==c&&l.addAction(c)}return o&&o>0&&l.actions.unshift(ue.waitAction(o)),l}static getAndRegisterAnimationSequences(s,t,i){var n,o,r,l,c,h,d,u;if(!t)return;const p=t.getComponent(kt),g=t.getComponent(Ut);if(!p&&!g)return;if(p&&!i)throw new Error("PlayAnimationOnClick: No stateName specified for animator "+p.name+" on "+t.name);let y=[],f=[];if(g){const M=s.registerAnimation(t,g.clip);M&&(g.loop?f.push(M):y.push(M));let E=0;if(g.minMaxOffsetNormalized){const B=g.minMaxOffsetNormalized.x,L=g.minMaxOffsetNormalized.y;E=(((n=g.clip)==null?void 0:n.duration)||1)*(B+Math.random()*(L-B))}return{animationSequence:y,animationLoopAfterSequence:f,randomTimeOffset:E}}const v=p?.runtimeAnimatorController;let b=v?.findState(i),w=[],_=[];if(v&&b){const M=new Array;M.push(b);let E=!1;for(;M.length<100;){if(!b||b===null||!b.transitions||b.transitions.length===0){(o=b.motion)!=null&&o.isLooping&&(E=!0);break}const B=b.transitions.find(U=>U.conditions.length===0),L=B?v.getState(B.destinationState,0):null;if(L&&M.includes(L)){b=L,E=!0;break}else if(B){if(b=L,!b)break;M.push(b)}else{E=((r=b.motion)==null?void 0:r.isLooping)??!1;break}}if(E&&b){const B=M.indexOf(b);w=M.slice(0,B),_=M.slice(B),zx&&console.log("found loop from "+i,"states until loop",w,"states looping",_)}else w=M,_=[],zx&&console.log("found no loop from "+i,"states",w);if(!_.length){const B=w[w.length-1],L=(l=B.motion)==null?void 0:l.clip;if(L){let U;if(s.holdClipMap.has(L))U=s.holdClipMap.get(L);else{const z=B.name+"_hold";U=L.clone(),U.duration=1,U.name=z;const H=L.duration;U.tracks=L.tracks.map(T=>{const I=T.clone();I.times=new Float32Array([0,H]);const G=T.values.length,J=T.getValueSize(),se=T.values.slice(G-J,G);return I.values=new Float32Array(2*J),I.values.set(se,0),I.values.set(se,J),I}),U.name=z,s.holdClipMap.set(L,U)}if(U){const z={name:U.name,motion:{clip:U,isLooping:!1,name:U.name},speed:1,transitions:[],behaviours:[],hash:B.hash+1};_.push(z)}}}}if(w.length===1&&(!((c=w[0].motion)!=null&&c.clip)||((d=(h=w[0].motion)==null?void 0:h.clip.tracks)==null?void 0:d.length)===0)){y=new Array;const M=s.registerAnimation(t,null);M&&y.push(M);return}if(w=w.filter(M=>{var E,B,L;return((E=M.motion)==null?void 0:E.clip)&&((L=(B=M.motion)==null?void 0:B.clip.tracks)==null?void 0:L.length)>0}),_=_.filter(M=>{var E,B,L;return((E=M.motion)==null?void 0:E.clip)&&((L=(B=M.motion)==null?void 0:B.clip.tracks)==null?void 0:L.length)>0}),w.length===0&&_.length===0){console.warn("No clips found for state "+i+" on "+p?.name+", can't export animation data");return}const C=(M,E)=>{if(!t)return;const B=s.registerAnimation(t,M.motion.clip??null);B?(B.speed=M.speed,E.push(B)):console.warn("Couldn't register animation for state "+M.name+" on "+p?.name)};if(w.length>0){y=new Array;for(const M of w)C(M,y)}if(_.length>0){f=new Array;for(const M of _)C(M,f)}let R=0;if(p&&v&&p.minMaxOffsetNormalized){const M=p.minMaxOffsetNormalized.x,E=p.minMaxOffsetNormalized.y,B=w.length?w[0]:_.length?_[0]:null;R=(((u=B?.motion.clip)==null?void 0:u.duration)||1)*(M+Math.random()*(E-M))}return{animationSequence:y,animationLoopAfterSequence:f,randomTimeOffset:R}}createAnimation(s,t,i){if(!this.target||!this.animator&&!this.animation)return;const n=nn.getAndRegisterAnimationSequences(s,this.target,this.stateName);n&&(this.animationSequence=n.animationSequence,this.animationLoopAfterSequence=n.animationLoopAfterSequence,this.randomOffsetNormalized=n.randomTimeOffset,this.stateAnimationModel=t)}},a(up,"animationActions",[]),a(up,"rootsWithExclusivePlayback",new Set),up);let Gr=nn;$e([m(kt)],Gr.prototype,"animator",2),$e([m()],Gr.prototype,"stateName",2);class yl extends A{constructor(){super(...arguments),a(this,"target")}getType(){}getDuration(){}}$e([m(j)],yl.prototype,"target",2);class ah extends A{constructor(){super(...arguments),a(this,"target")}}$e([m(yl)],ah.prototype,"target",2);class lh extends yl{constructor(){super(...arguments),a(this,"type",1),a(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}$e([m()],lh.prototype,"type",2),$e([m()],lh.prototype,"duration",2);class p0 extends ah{}class pp{get extensionName(){return"Physics"}onExportObject(t,i,n){const o=P.getComponents(t,ye).filter(h=>h.enabled),r=P.getComponents(t,hi).filter(h=>h.enabled&&!h.isTrigger);let l=o.length>0?o[0]:null;const c=r.length>0?r[0]:null;c&&!l&&(l=new ye,l.isKinematic=!0),l&&i.addEventListener("serialize",(h,d)=>{var u,p,g;if(l){if(h.appendLine(),h.beginBlock('def RealityKitComponent "RigidBody"',"{",!0),l.useGravity||h.appendLine("bool gravityEnabled = 0"),h.appendLine('uniform token info:id = "RealityKit.RigidBody"'),l.isKinematic&&h.appendLine('token motionType = "Kinematic"'),h.beginBlock('def RealityKitStruct "massFrame"',"{",!0),h.appendLine(`float m_mass = ${l.mass}`),h.beginBlock('def RealityKitStruct "m_pose"',"{",!0),h.appendLine(`float3 position = (${l.centerOfMass.x}, ${l.centerOfMass.y}, ${l.centerOfMass.z})`),h.closeBlock("}"),h.closeBlock("}"),r.length>0){const y=r[0];h.beginBlock('def RealityKitStruct "material"',"{",!0);const f=y.sharedMaterial;f&&f.dynamicFriction!==void 0&&h.appendLine(`double dynamicFriction = ${(u=y.sharedMaterial)==null?void 0:u.dynamicFriction}`),f&&f.bounciness!==void 0&&h.appendLine(`double restitution = ${(p=y.sharedMaterial)==null?void 0:p.bounciness}`),f&&f.staticFriction!==void 0&&h.appendLine(`double staticFriction = ${(g=y.sharedMaterial)==null?void 0:g.staticFriction}`),h.closeBlock("}")}h.closeBlock("}")}}),c&&(i.addEventListener("serialize",(h,d)=>{var u;h.beginBlock('def RealityKitComponent "Collider"',"{",!0),h.appendLine("uint group = 1"),h.appendLine('uniform token info:id = "RealityKit.Collider"'),h.appendLine("uint mask = 4294967295");const p=c.isTrigger?"Trigger":"Default";if(h.appendLine(`token type = "${p}"`),h.beginBlock('def RealityKitStruct "Shape"',"{",!0),c instanceof Za){const g=c;h.appendLine('token shapeType = "Sphere"'),h.appendLine(`float radius = ${g.radius}`)}else if(c instanceof Ja){const g=c;h.appendLine('token shapeType = "Box"'),h.appendLine(`float3 extent = (${g.size.x}, ${g.size.y}, ${g.size.z})`)}else if(c instanceof In){const g=c;h.appendLine('token shapeType = "Capsule"'),h.appendLine(`float radius = ${g.radius}`),h.appendLine(`float height = ${g.height}`)}else if(c instanceof To&&(u=c.sharedMesh)!=null&&u.geometry){const g=c.sharedMesh.geometry;g.boundingBox||g.computeBoundingBox();const y=c.sharedMesh.geometry.boundingBox;y&&(h.appendLine('token shapeType = "Box"'),h.appendLine(`float3 extent = (${y.max.x-y.min.x}, ${y.max.y-y.min.y}, ${y.max.z-y.min.z})`),console.log("[USDZ] Only Box, Sphere, and Capsule colliders are supported in visionOS/iOS. MeshCollider will be exported as Box",c))}else console.warn("[USDZ] Only Box, Sphere, and Capsule colliders are supported in visionOS/iOS. Ignoring collider:",c);h.beginBlock('def RealityKitStruct "pose"',"{",!0),h.closeBlock("}"),h.closeBlock("}"),h.closeBlock("}")}),r.length>1&&console.log("WARNING: Multiple colliders detected. visionOS / iOS can only support objects with a single collider, only exporting the first collider: ",c))}}class m0{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(t){}}var gT=Object.defineProperty,fT=Object.getOwnPropertyDescriptor,ch=(s,t,i,n)=>{for(var o=n>1?void 0:n?fT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&gT(t,i,o),o};const g0=O("debugui"),f0=O("debuguilayout");class y0{constructor(){a(this,"width"),a(this,"height")}}class v0{constructor(){a(this,"x"),a(this,"y"),a(this,"width"),a(this,"height")}}const Rs=new x,hh=new ne,mp=new V,Ux=class extends ls{constructor(){super(...arguments),a(this,"_anchoredPosition"),a(this,"sizeDelta",new oe(100,100)),a(this,"pivot",new oe(.5,.5)),a(this,"anchorMin",new oe(0,0)),a(this,"anchorMax",new oe(1,1)),a(this,"minWidth"),a(this,"minHeight"),a(this,"lastMatrix"),a(this,"rectBlock"),a(this,"_transformNeedsUpdate",!1),a(this,"_initialPosition"),a(this,"_parentRectTransform"),a(this,"_lastUpdateFrame",-1),a(this,"_lastAnchoring"),a(this,"_createdBlocks",[]),a(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new oe),this._anchoredPosition}set anchoredPosition(s){this._anchoredPosition=s}get width(){let s=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const t=this._parentRectTransform.width,i=this.anchorMax.x-this.anchorMin.x;s=t*i,s+=this.sizeDelta.x}return this.minWidth!==void 0&&s<this.minWidth?this.minWidth:s}get height(){let s=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const t=this._parentRectTransform.height,i=this.anchorMax.y-this.anchorMin.y;s=t*i,s+=this.sizeDelta.y}return this.minHeight!==void 0&&s<this.minHeight?this.minHeight:s}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new oe),this.lastMatrix=new ne,this.rectBlock=new j,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,Xa(this,"_anchoredPosition",()=>{this.markDirty()}),Xa(this,"sizeDelta",()=>{this.markDirty()}),Xa(this,"pivot",()=>{this.markDirty()}),Xa(this,"anchorMin",()=>{this.markDirty()}),Xa(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var s;super.onEnable(),this.rectBlock||(this.rectBlock=new j),this.lastMatrix||(this.lastMatrix=new ne),this._lastAnchoring||(this._lastAnchoring=new oe),this._initialPosition||(this._initialPosition=new x),this._anchoredPosition||(this._anchoredPosition=new oe),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(s=this.canvas)==null||s.registerTransform(this)}onDisable(){var s;super.onDisable(),this.removeShadowComponent(),(s=this.canvas)==null||s.unregisterTransform(this)}onParentRectTransformChanged(s){this._transformNeedsUpdate||this.onApplyTransform(f0?`${s.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(f0&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(s){var t;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const i=this.shadowComponent;if(!i)return;this.gameObject.parent?this._parentRectTransform=P.getComponentInParent(this.gameObject.parent,Ux):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,f0&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+s),this.isRoot()?this.Root.screenspace||(i.rotation.y=Math.PI):(i.matrix.identity(),i.matrixAutoUpdate=!1,Rs.set(0,0,0),this.applyPivot(Rs),i.matrix.setPosition(Rs.x,Rs.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(mp.copy(this.gameObject.quaternion),mp.x*=-1,mp.z*=-1,hh.makeRotationFromQuaternion(mp),i.matrix.premultiply(hh)),Rs.set(0,0,0),this.applyAnchoring(Rs),(t=this.canvas)!=null&&t.screenspace?Rs.z+=.1:Rs.z+=.01,hh.identity(),hh.setPosition(Rs.x,Rs.y,Rs.z),i.matrix.premultiply(hh),i.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const n=!0;for(const o of eu(this.gameObject,ls,n,1)){if(o===this||!o.activeAndEnabled)continue;const r=o;r.onParentRectTransformChanged&&r.onParentRectTransformChanged(this)}}applyAnchoring(s){this._lastAnchoring||(this._lastAnchoring=new oe);const t=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=t.x,this.gameObject.position.y+=t.y,this._lastAnchoring.copy(this._anchoredPosition),s.x+=this._initialPosition.x-this.gameObject.position.x,s.y+=this._initialPosition.y-this.gameObject.position.y,s.z+=this._initialPosition.z-this.gameObject.position.z;const i=this._parentRectTransform;if(i){let n=0;const o=1-this.anchorMax.y-this.anchorMin.y;n-=i.height*.5*o,s.y+=n;let r=0;const l=1-this.anchorMax.x-this.anchorMin.x;r-=i.width*.5*l,s.x+=r}}applyPivot(s){if(this.pivot&&!this.isRoot()){const t=this.pivot.x-.5;s.x-=t*this.sizeDelta.x*this.gameObject.scale.x;const i=this.pivot.y-.5;s.y-=i*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const s={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(s),s}ensureValidSize(s,t=1e-4){return s.width<=0&&(s.width=t),s.height<=0&&(s.height=1e-4),s}createNewBlock(s){s={...this.getBasicOptions(),...s},g0&&console.log(this.name,s);const t=new bv(s);return this._createdBlocks.push(t),t}createNewText(s){g0&&console.log(s),s={...this.getBasicOptions(),...s},g0&&console.log(this.name,s);const t=new vv(s);return this._createdTextBlocks.push(t),t}};let Wt=Ux;ch([m(oe)],Wt.prototype,"anchoredPosition",1),ch([m(oe)],Wt.prototype,"sizeDelta",2),ch([m(oe)],Wt.prototype,"pivot",2),ch([m(oe)],Wt.prototype,"anchorMin",2),ch([m(oe)],Wt.prototype,"anchorMax",2);var yT=Object.defineProperty,vT=Object.getOwnPropertyDescriptor,Nx=(s,t,i,n)=>{for(var o=n>1?void 0:n?vT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&yT(t,i,o),o};class vl extends A{constructor(){super(...arguments),a(this,"effectColor"),a(this,"effectDistance")}}Nx([m(we)],vl.prototype,"effectColor",2),Nx([m(oe)],vl.prototype,"effectDistance",2);var bT=Object.defineProperty,_T=Object.getOwnPropertyDescriptor,Wx=(s,t,i,n)=>{for(var o=n>1?void 0:n?_T(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&bT(t,i,o),o};const gp={backgroundColor:new ae(1,1,1),backgroundOpacity:1,borderColor:new ae(1,1,1),borderOpacity:1};var b0;const dh=(b0=class extends ls{constructor(){super(...arguments),a(this,"_alphaFactor",1),a(this,"sRGBColor",new ae(1,0,1)),a(this,"raycastTarget",!0),a(this,"uiObject",null),a(this,"_color",null),a(this,"_rect",null),a(this,"_stateManager",null),a(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new we(1,1,1,1)),this._color}set color(s){(!this._color||this._color.r!==s.r||this._color.g!==s.g||this._color.b!==s.b||this._color.alpha!==s.alpha)&&(this._color||(this._color=new we(1,1,1,1)),this._color.copy(s),this.onColorChanged())}setAlphaFactor(s){this._alphaFactor=s,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),gp.backgroundColor=this.sRGBColor,gp.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(gp,this._alphaFactor),this.uiObject.set(gp),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=P.getComponent(this.gameObject,Wt)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var s;(s=this.uiObject)==null||s.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(s){return super.__internalNewInstanceCreated(s),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone()),this}setState(s){this.makePanel(),this.uiObject&&(this.uiObject.setState(s),this==null||this.markDirty())}setupState(s){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new lO(this.uiObject)),this.uiObject.setupState(s.state,s.attributes))}setOptions(s){this.makePanel(),this.uiObject&&this.uiObject.set(s)}awake(){super.awake(),this.makePanel(),Xa(this,"_color",()=>yM(this,this.onColorChanged))}onEnable(){var s;super.onEnable(),this.uiObject&&((s=this.rectTransform.shadowComponent)==null||s.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const s=.015,t={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:s};this.onBeforeCreate(t),this.applyEffects(t),this.onCreate(t),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(s){}onCreate(s){this.uiObject=this.rectTransform.createNewBlock(s),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(s,t=1){var i;const n=(i=this.gameObject)==null?void 0:i.getComponent(vl);n&&(n.effectDistance&&(s.borderWidth=Math.max(Math.abs(n.effectDistance.x),Math.abs(n.effectDistance.y))),n.effectColor&&(s.borderColor=n.effectColor,s.borderOpacity=n.effectColor.alpha*t))}async setTexture(s){if(this.setOptions({backgroundOpacity:0}),s){if(dh.textureCache.has(s))s=dh.textureCache.get(s);else if(!s.isRenderTargetTexture){const t=s.clone();t.colorSpace=pr,dh.textureCache.set(s,t),s=t}this.setOptions({backgroundImage:s,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"}),et.assignTextureLOD(s,0).then(t=>{t instanceof Ne&&(s&&dh.textureCache.set(s,t),this.setOptions({backgroundImage:t}),this.markDirty())})}else this.setOptions({backgroundImage:void 0,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},a(b0,"textureCache",new Map),b0);let Xr=dh;Wx([m(we)],Xr.prototype,"color",1),Wx([m()],Xr.prototype,"raycastTarget",2);class uh extends Xr{constructor(){super(...arguments),a(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var wT=Object.defineProperty,xT=Object.getOwnPropertyDescriptor,Nn=(s,t,i,n)=>{for(var o=n>1?void 0:n?xT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&wT(t,i,o),o};const Qr=O("debugtext");var ut=(s=>(s[s.UpperLeft=0]="UpperLeft",s[s.UpperCenter=1]="UpperCenter",s[s.UpperRight=2]="UpperRight",s[s.MiddleLeft=3]="MiddleLeft",s[s.MiddleCenter=4]="MiddleCenter",s[s.MiddleRight=5]="MiddleRight",s[s.LowerLeft=6]="LowerLeft",s[s.LowerCenter=7]="LowerCenter",s[s.LowerRight=8]="LowerRight",s))(ut||{}),Vx=(s=>(s[s.Normal=0]="Normal",s[s.Bold=1]="Bold",s[s.Italic=2]="Italic",s[s.BoldAndItalic=3]="BoldAndItalic",s))(Vx||{});class Vt extends Xr{constructor(){super(...arguments),a(this,"alignment",0),a(this,"verticalOverflow",0),a(this,"horizontalOverflow",0),a(this,"lineSpacing",1),a(this,"supportRichText",!1),a(this,"font"),a(this,"fontStyle",0),a(this,"sRGBTextColor",new ae(1,0,1)),a(this,"_text",""),a(this,"_fontSize",12),a(this,"_textMeshUi",null),a(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(t){var i;super.setAlphaFactor(t),(i=this.uiObject)==null||i.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(t){t!==this._text&&(this._text=t,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(t){this.text=t}get fontSize(){return this._fontSize}set fontSize(t){var i;this._fontSize=t,(i=this.uiObject)==null||i.set({fontSize:t})}onColorChanged(){var t;this.sRGBTextColor.copy(this.color),this.sRGBTextColor.convertLinearToSRGB(),(t=this.uiObject)==null||t.set({color:this.sRGBTextColor,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeCanvasRender(t){this.updateOverflow()}updateOverflow(){var t;const i=(t=this.uiObject)==null?void 0:t._overflow;i&&(i._needsUpdate=!0)}onCreate(t){Qr&&console.log(this),this.horizontalOverflow==1&&(t.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,t.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,t.lineHeight=this.lineSpacing,delete t.backgroundOpacity,delete t.backgroundColor,Qr&&(t.backgroundColor=16750848,t.backgroundOpacity=.5);const i=this.rectTransform;t={...t,...this.getTextOpts()},this.getAlignment(t),Qr&&(t.backgroundColor=Math.random()*16777215,t.backgroundOpacity=.1),this.uiObject=i.createNewText(t),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const t=this.fontSize,i={color:this.color,fontOpacity:this.color.alpha,fontSize:t,fontKerning:"normal"};return this.setFont(i,this.fontStyle),i}onEnable(){var t;super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10),(t=this.canvas)==null||t.registerEventReceiver(this)}onDisable(){var t;super.onDisable(),(t=this.canvas)==null||t.unregisterEventReceiver(this)}getAlignment(t){switch(t.flexDirection="column",this.alignment){case 0:case 3:case 6:t.textAlign="left";break;case 1:case 4:case 7:t.textAlign="center";break;case 2:case 5:case 8:t.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:t.alignItems="start";break;case 3:case 4:case 5:t.alignItems="center";break;case 6:case 7:case 8:t.alignItems="end";break}return t}feedText(t,i){var n,o,r;if(Qr&&console.log("feedText",this.uiObject,t,i),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!i||t.length===0)this.uiObject.textContent=t;else{let l=this.getNextTag(t);if(l){if(l.startIndex>0){for(let d=this.uiObject.children.length-1;d>=0;d--){const u=this.uiObject.children[d];u.isUI&&(this.uiObject.remove(u),u.clear())}const h=new Om({textContent:t.substring(0,l.startIndex),color:"inherit"});this.uiObject.add(h)}}else{this.uiObject.textContent="",this.setOptions({textContent:t});return}const c=[];for(;l;){const h=this.getNextTag(t,l.endIndex),d={fontFamily:(n=this.uiObject)==null?void 0:n.get("fontFamily"),color:"inherit",textContent:""};if(h){d.textContent=this.getText(t,l,h),this.handleTag(l,d,c);const u=new Om(d);(o=this.uiObject)==null||o.add(u)}else{d.textContent=t.substring(l.endIndex),this.handleTag(l,d,c);const u=new Om(d);(r=this.uiObject)==null||r.add(u)}l=h}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const t=[],i=this.canvas,n={renderOnTop:i.renderOnTop,depthWrite:i.depthWrite,doubleSided:i.doubleSided};for(;;){let o=!1;if(this._textMeshUi)for(let r=0;r<this._textMeshUi.length;r++){if(t[r]===!0)continue;o=!0;const l=this._textMeshUi[r];l.textContent&&(Au(l,n),t[r]=!0)}if(!o)break;yield}}handleTag(t,i,n){if(!t.isEndTag){if(t.type.includes("color")){const o=new _0(t,{color:i.color});if(n.push(o),t.type.length>6){const r=parseInt("0x"+t.type.substring(7));i.color=r}else i.color=new ae(1,1,1)}else if(t.type=="b"){this.setFont(i,1);const o=new _0(t,{fontWeight:700});n.push(o)}else if(t.type=="i"){this.setFont(i,2);const o=new _0(t,{fontStyle:"italic"});n.push(o)}}}getText(t,i,n){return t.substring(i.endIndex,n.startIndex)}getNextTag(t,i=0){const n=t.indexOf("<",i),o=t.indexOf(">",n);if(n>=0&&o>=0){const r=t.substring(n+1,o);return{type:r,startIndex:n,endIndex:o+1,isEndTag:r.startsWith("/")}}return null}setFont(t,i){if(!this.font)return;const n=this.font,o=this.getFamilyNameWithCorrectSuffix(n,i);Qr&&console.log("Selected font family:"+o);let r=_v.getFontFamily(o);switch(r||(r=_v.addFontFamily(o)),t.fontFamily=r,i){default:case 0:t.fontWeight=400,t.fontStyle="normal";break;case 1:t.fontWeight=700,t.fontStyle="normal";break;case 2:t.fontWeight=400,t.fontStyle="italic";break;case 3:t.fontStyle="italic",t.fontWeight=400}let l=r.getVariant(t.fontWeight,t.fontStyle);if(!l){let c=o;c!=null&&c.endsWith("-msdf.json")||(c+="-msdf.json");let h=o;h!=null&&h.endsWith(".png")||(h+=".png"),l=r.addVariant(t.fontWeight,t.fontStyle,c,h),l?.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(t,i){var n;const o=t.lastIndexOf("-");if(o<0)return t;const r=(n=t.substring(o+1))==null?void 0:n.toLowerCase();if(ST.includes(r))return Qr&&console.warn("Unsupported font style: "+r),t;const l=t.lastIndexOf("/");let c=t;l>=0&&(c=c.substring(l+1));const h=c[0]===c[0].toUpperCase(),d=t.substring(0,o);switch(Qr&&console.log("Select font: ",t,Vx[i],c,h,d),i){case 0:return h?d+"-Regular":d+"-regular";case 1:return h?d+"-Bold":d+"-bold";case 2:return h?d+"-Italic":d+"-italic";case 3:return h?d+"-BoldItalic":d+"-bolditalic";default:return t}}}Nn([m()],Vt.prototype,"alignment",2),Nn([m()],Vt.prototype,"verticalOverflow",2),Nn([m()],Vt.prototype,"horizontalOverflow",2),Nn([m()],Vt.prototype,"lineSpacing",2),Nn([m()],Vt.prototype,"supportRichText",2),Nn([m(URL)],Vt.prototype,"font",2),Nn([m()],Vt.prototype,"fontStyle",2),Nn([m()],Vt.prototype,"text",1),Nn([m()],Vt.prototype,"fontSize",1);class _0{constructor(t,i){a(this,"tag"),a(this,"previousValues"),this.tag=t,this.previousValues=i}}const ST=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class jo{constructor(t){a(this,"id"),a(this,"content",""),a(this,"font",[]),a(this,"pointSize",144),a(this,"width"),a(this,"height"),a(this,"depth"),a(this,"wrapMode"),a(this,"horizontalAlignment"),a(this,"verticalAlignment"),a(this,"material"),this.id=t}static getId(){return this.global_id++}setDepth(t){return this.depth=t,this}setPointSize(t){return this.pointSize=t,this}setHorizontalAlignment(t){return this.horizontalAlignment=t,this}setVerticalAlignment(t){return this.verticalAlignment=t,this}writeTo(t,i){var n;i.beginBlock(`def Preliminary_Text "${this.id}"`,"(",!1),i.appendLine('prepend apiSchemas = ["MaterialBindingAPI"]'),i.closeBlock(")"),i.beginBlock(),this.content&&i.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(n=this.font)==null||n.push("sans-serif"));const o=this.font.map(r=>`"${r}"`).join(", ");i.appendLine(`string[] font = [ ${o} ]`),i.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&i.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&i.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&i.appendLine(`double depth = ${this.depth}`),this.wrapMode&&i.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&i.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&i.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&i.appendLine(`rel material:binding = </StageRoot/Materials/${s0(this.material)}>`),i.closeBlock()}}a(jo,"global_id",0);class fp{static singleLine(t,i,n){const o=new jo("text_"+jo.getId());return o.content=t,i&&(o.pointSize=i),n&&(o.depth=n),o}static multiLine(t,i,n,o,r,l){const c=new jo("text_"+jo.getId());return c.content=t,c.width=i,c.height=n,c.horizontalAlignment=o,c.verticalAlignment=r,l!==void 0&&(c.wrapMode=l),c}}const CT=new ne().makeRotationY(Math.PI),OT=new ne().makeScale(-1,1,-1);class ph{get extensionName(){return"text"}exportText(t,i,n){const o=P.getComponent(t,Vt);if(!o)return;const r=P.getComponent(t,Wt);let l=100,c=100;r&&(l=r.width,c=r.height);const h=CT.clone();r&&h.premultiply(OT),i.setMatrix(h);const d=o.color.clone();i.material=new ri({color:d,emissive:d}),i.addEventListener("serialize",(u,p)=>{let g=o.text;g=g.replace(/\r/g,""),g=g.replace(/\n/g,"\\n");const y=fp.multiLine(g,l,c,"center","bottom","flowing");this.setTextAlignment(y,o.alignment),this.setOverflow(y,o),i.material&&(y.material=i.material),y.pointSize=this.convertToTextSize(o.fontSize),y.depth=.001,y.writeTo(void 0,u)})}convertToTextSize(t){return 1/.0502*144*t}setOverflow(t,i){i.horizontalOverflow?t.wrapMode="singleLine":t.wrapMode="flowing"}setTextAlignment(t,i){switch(i){case ut.LowerLeft:case ut.MiddleLeft:case ut.UpperLeft:t.horizontalAlignment="left";break;case ut.LowerCenter:case ut.MiddleCenter:case ut.UpperCenter:t.horizontalAlignment="center";break;case ut.LowerRight:case ut.MiddleRight:case ut.UpperRight:t.horizontalAlignment="right";break}switch(i){case ut.LowerLeft:case ut.LowerCenter:case ut.LowerRight:t.verticalAlignment="bottom";break;case ut.MiddleLeft:case ut.MiddleCenter:case ut.MiddleRight:t.verticalAlignment="middle";break;case ut.UpperLeft:case ut.UpperCenter:case ut.UpperRight:t.verticalAlignment="top";break}}}var PT=Object.defineProperty,kT=Object.getOwnPropertyDescriptor,ot=(s,t,i,n)=>{for(var o=n>1?void 0:n?kT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&PT(t,i,o),o};const Hx=O("debuguilayout");class Lo{constructor(){a(this,"left",0),a(this,"right",0),a(this,"top",0),a(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}ot([m()],Lo.prototype,"left",2),ot([m()],Lo.prototype,"right",2),ot([m()],Lo.prototype,"top",2),ot([m()],Lo.prototype,"bottom",2);class Ii extends A{constructor(){super(...arguments),a(this,"_rectTransform",null),a(this,"_needsUpdate",!1),a(this,"childAlignment",0),a(this,"reverseArrangement",!1),a(this,"spacing",0),a(this,"padding"),a(this,"minWidth",0),a(this,"minHeight",0),a(this,"flexibleHeight",0),a(this,"flexibleWidth",0),a(this,"preferredHeight",0),a(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(t){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(Hx&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){Hx&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(Wt);const t=this.gameObject.getComponentInParent(Tt);t&&t.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const t=this.gameObject.getComponentInParent(Tt);t&&t.unregisterLayoutGroup(this)}set m_Spacing(t){t!==this.spacing&&(this._needsUpdate=!0,this.spacing=t)}get m_Spacing(){return this.spacing}}ot([m()],Ii.prototype,"childAlignment",2),ot([m()],Ii.prototype,"reverseArrangement",2),ot([m()],Ii.prototype,"spacing",2),ot([m(Lo)],Ii.prototype,"padding",2),ot([m()],Ii.prototype,"minWidth",2),ot([m()],Ii.prototype,"minHeight",2),ot([m()],Ii.prototype,"flexibleHeight",2),ot([m()],Ii.prototype,"flexibleWidth",2),ot([m()],Ii.prototype,"preferredHeight",2),ot([m()],Ii.prototype,"preferredWidth",2);class Do extends Ii{constructor(){super(...arguments),a(this,"childControlHeight",!0),a(this,"childControlWidth",!0),a(this,"childForceExpandHeight",!1),a(this,"childForceExpandWidth",!1),a(this,"childScaleHeight",!1),a(this,"childScaleWidth",!1)}onCalculateLayout(t){var i;const n=this.primaryAxis,o=t.width;let r=o;const l=t.height;let c=l;r-=this.padding.horizontal,c-=this.padding.vertical,n==="x"?this.padding.horizontal:this.padding.vertical;const h=n==="x",d=h?"y":"x",u=h?this.childControlWidth:this.childControlHeight,p=h?this.childControlHeight:this.childControlWidth,g=h?this.childForceExpandWidth:this.childForceExpandHeight,y=h?this.childForceExpandHeight:this.childForceExpandWidth,f=h?c:r,v=h?o:l,b=.5*(h?this.childAlignment%3:Math.floor(this.childAlignment/3));let w=0;h?w+=this.padding.left:w+=this.padding.top;let _=0,C=0;for(let L=0;L<this.gameObject.children.length;L++){const U=this.gameObject.children[L],z=P.getComponent(U,Wt);z!=null&&z.activeAndEnabled&&(C+=1,h?_+=z.width:_+=z.height)}let R=0;const M=this.spacing*(C-1);if(g||u){let L=0;h?L=r-=M:L=c-=M,C>0&&(R=L/C)}let E=0;E+=this.padding.left,E-=this.padding.right,b!==0&&(w=v-_,w*=b,w-=M*b,h?(w-=this.padding.right*b,w+=this.padding.left*(1-b),w<this.padding.left&&(w=this.padding.left)):(w-=this.padding.bottom*b,w+=this.padding.top*(1-b),w<this.padding.top&&(w=this.padding.top)));let B=1;for(let L=0;L<this.gameObject.children.length;L++){const U=this.gameObject.children[L],z=P.getComponent(U,Wt);if(z!=null&&z.activeAndEnabled){(i=z.pivot)==null||i.set(.5,.5),z.anchorMin.set(0,1),z.anchorMax.set(0,1);const H=o*.5+E*.5;z.anchoredPosition.x!==H&&(z.anchoredPosition.x=H);const T=l*-.5;z.anchoredPosition.y!==T&&(z.anchoredPosition.y=T),y&&p&&z.sizeDelta[d]!==f&&(z.sizeDelta[d]=f),g&&u&&z.sizeDelta[n]!==R&&(z.sizeDelta[n]=R);const I=h?z.width:z.height,G=I*.5;if(w+=G,g){const se=R*B-R*.5;se>w&&(w=se-R*.5+I+this.padding.left,w-=G)}let J=w;n==="y"&&(J=-J),z.anchoredPosition[n]!==J&&(z.anchoredPosition[n]=J),w+=G,w+=this.spacing,B+=1}}}}ot([m()],Do.prototype,"childControlHeight",2),ot([m()],Do.prototype,"childControlWidth",2),ot([m()],Do.prototype,"childForceExpandHeight",2),ot([m()],Do.prototype,"childForceExpandWidth",2),ot([m()],Do.prototype,"childScaleHeight",2),ot([m()],Do.prototype,"childScaleWidth",2);class w0 extends Do{get primaryAxis(){return"y"}}class x0 extends Do{get primaryAxis(){return"x"}}class S0 extends Ii{onCalculateLayout(){}}var MT=Object.defineProperty,RT=Object.getOwnPropertyDescriptor,on=(s,t,i,n)=>{for(var o=n>1?void 0:n?RT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&MT(t,i,o),o},$x=(s=>(s[s.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",s[s.ScreenSpaceCamera=1]="ScreenSpaceCamera",s[s.WorldSpace=2]="WorldSpace",s[s.Undefined=-1]="Undefined",s))($x||{});const C0=O("debuguilayout"),qx=class extends Fc{constructor(){super(...arguments),a(this,"_renderOnTop"),a(this,"_depthWrite",!1),a(this,"_doubleSided",!0),a(this,"_castShadows",!1),a(this,"_receiveShadows",!1),a(this,"_renderMode",-1),a(this,"_rootCanvas"),a(this,"_scaleFactor",1),a(this,"worldCamera"),a(this,"planeDistance",-1),a(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this)),a(this,"previousParent",null),a(this,"_lastMatrixWorld",null),a(this,"_rectTransforms",[]),a(this,"_layoutGroups",new Map),a(this,"_receivers",[]),a(this,"onBeforeRenderRoutine",()=>{var s,t,i,n;if(this.previousParent=this.gameObject.parent,((s=this.context.xr)!=null&&s.isVR||(t=this.context.xr)!=null&&t.isPassThrough)&&this.screenspace){this.gameObject.visible=!1,this.gameObject.removeFromParent();return}this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(n=this.shadowComponent)==null||n.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),ts.ensureUpdateMeshUI(wv,this.context))}),a(this,"onAfterRenderRoutine",()=>{var s,t,i,n,o;if(((s=this.context.xr)!=null&&s.isVR||(t=this.context.xr)!=null&&t.isPassThrough)&&this.screenspace){(i=this.previousParent)==null||i.add(this.gameObject);return}if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const c=this.context.mainCamera;c?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const r=this.context.renderer.autoClear,l=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(n=this.shadowComponent)==null||n.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),ts.ensureUpdateMeshUI(wv,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=r,this.context.renderer.autoClearColor=l,this.previousParent.add(this.gameObject)}(o=this._lastMatrixWorld)==null||o.copy(this.gameObject.matrixWorld)}),a(this,"_updateRenderSettingsRoutine"),a(this,"_activeRenderMode",-1),a(this,"_lastWidth",-1),a(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(s){s!==this._renderOnTop&&(this._renderOnTop=s,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(s){this._depthWrite!==s&&(this._depthWrite=s,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(s){this._doubleSided!==s&&(this._doubleSided=s,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(s){this._castShadows!==s&&(this._castShadows=s,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(s){this._receiveShadows!==s&&(this._receiveShadows=s,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(s){this._renderMode!==s&&(this._renderMode=s,this.onRenderSettingsChanged())}set rootCanvas(s){this._rootCanvas instanceof qx||(this._rootCanvas=s)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(s){this._scaleFactor=s}awake(){var s;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,C0&&console.log("Canvas.Awake()",((s=this.previousParent)==null?void 0:s.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new ne,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const s=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);s!==-1&&this.context.pre_render_callbacks.splice(s,1);const t=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);t!==-1&&this.context.post_render_callbacks.splice(t,1)}registerTransform(s){this._rectTransforms.push(s)}unregisterTransform(s){const t=this._rectTransforms.indexOf(s);t!==-1&&this._rectTransforms.splice(t,1)}registerLayoutGroup(s){const t=s.gameObject;this._layoutGroups.set(t,s)}unregisterLayoutGroup(s){const t=s.gameObject;this._layoutGroups.delete(t)}registerEventReceiver(s){this._receivers.push(s)}unregisterEventReceiver(s){const t=this._receivers.indexOf(s);t!==-1&&this._receivers.splice(t,1)}async onEnterXR(s){this.screenspace?(s.xr.isVR||s.xr.isPassThrough)&&(this.gameObject.visible=!1):(this.gameObject.visible=!1,await Ql(1).then(()=>{this.gameObject.visible=!0}))}onLeaveXR(s){this.screenspace&&(s.xr.isVR||s.xr.isPassThrough)&&(this.gameObject.visible=!0)}invokeBeforeRenderEvents(){var s;for(const t of this._receivers)(s=t.onBeforeCanvasRender)==null||s.call(t,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new ne);const s=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);C0&&s&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const t=!1;for(const i of this._rectTransforms){s&&i.markDirty();let n=this._layoutGroups.get(i.gameObject);i.isDirty&&!n&&(n=i.gameObject.getComponentInParent(Ii)),(i.isDirty||n!=null&&n.isDirty)&&(C0&&!t&&console.log("CANVAS UPDATE ### "+i.name+" ##################################### "+this.context.time.frame),n?.updateLayout(),i.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),Ce.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),Au(this.shadowComponent,this);for(const s of P.getComponentsInChildren(this.gameObject,ls))Au(s.shadowComponent,this)}}onUpdateRenderMode(s=!1){if(!s&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let t=this.context.mainCameraComponent,i=10;switch(t&&t.nearClipPlane>0&&t.farClipPlane>0&&(i=W.lerp(t.nearClipPlane,t.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(t=this.worldCamera),this.planeDistance>0&&(i=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!t)return;const n=i+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-n,this.gameObject.quaternion.identity();const o=this.gameObject.getComponent(Wt);let r=!1;o.sizeDelta.x!==this.context.domWidth&&(r=!0),o.sizeDelta.y!==this.context.domHeight&&(r=!0);const l=t.fieldOfView*Math.PI/180,c=2*Math.tan(l/2)*Math.abs(n);this.gameObject.scale.x=c/this.context.domHeight,this.gameObject.scale.y=c/this.context.domHeight,this.gameObject.scale.z=.01,r&&(o.sizeDelta.x=this.context.domWidth,o.sizeDelta.y=this.context.domHeight,o?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let Tt=qx;on([m()],Tt.prototype,"renderOnTop",1),on([m()],Tt.prototype,"depthWrite",1),on([m()],Tt.prototype,"doubleSided",1),on([m()],Tt.prototype,"castShadows",1),on([m()],Tt.prototype,"receiveShadows",1),on([m()],Tt.prototype,"renderMode",1),on([m(Tt)],Tt.prototype,"rootCanvas",1),on([m()],Tt.prototype,"scaleFactor",1),on([m(Pe)],Tt.prototype,"worldCamera",2),on([m()],Tt.prototype,"planeDistance",2);var TT=Object.defineProperty,ET=Object.getOwnPropertyDescriptor,O0=(s,t,i,n)=>{for(var o=n>1?void 0:n?ET(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&TT(t,i,o),o};class Bo extends A{constructor(){super(...arguments),a(this,"_alpha",1),a(this,"interactable",!0),a(this,"blocksRaycasts",!0),a(this,"_isDirty",!1),a(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(t){t!==this._alpha&&(this._alpha=t,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),Ce.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){this._buffer.length=0;for(const t of P.getComponentsInChildren(this.gameObject,ls,this._buffer)){const i=t;i.setAlphaFactor&&i.setAlphaFactor(this._alpha)}}}O0([m()],Bo.prototype,"alpha",1),O0([m()],Bo.prototype,"interactable",2),O0([m()],Bo.prototype,"blocksRaycasts",2);class yp{get extensionName(){return"tmui"}onExportObject(t,i,n){const o=P.getComponent(t,Tt);if(o&&o.enabled&&o.renderMode===$x.WorldSpace){const r=new ph,l=P.getComponent(t,Wt),c=P.getComponent(t,Bo),h=new Array;if(l){if(!P.isActiveSelf(t)){const p=P.isActiveSelf(t);P.setActive(t,!0),l.onEnable(),l.updateTransform(),h.push(()=>{l.onDisable(),P.setActive(t,p)})}t.traverse(p=>{if(!P.isActiveInHierarchy(p)){const g=P.isActiveSelf(p);P.setActive(p,!0);const y=P.getComponent(p,ls);y&&(y.onEnable(),h.push(()=>{y.onDisable()}));const f=P.getComponent(p,Wt);f&&(f.onEnable(),f.updateTransform(),f.onApplyTransform(),h.push(()=>{f.onDisable()}));const v=P.getComponent(p,Vt);v&&(v.onEnable(),h.push(()=>{v.onDisable()})),h.push(()=>{P.setActive(p,g)})}}),l.width,l.height;const d=Zt.createEmpty(),u=l.shadowComponent;if(i.add(d),u){const p=u.matrix;d.setMatrix(p);const g=new Map,y=new Map;g.set(u,d),y.set(u,c?c.alpha:1),u.traverse(f=>{if(f===u)return;const v=Zt.createEmpty();v.setMatrix(f.matrix);const b=f.parent,w=!!b&&typeof b.textContent=="string"&&b.textContent.length>0;let _=y.get(b)||1;const C=P.getComponent(f,Bo);if(C&&(_*=C.alpha),f instanceof Q&&w){const M=f[es];M?r.exportText(M.gameObject,v,n):console.error("Error when exporting UI: shadow component owner not found. This is likely a bug.",f)}if(f instanceof Q&&!w){const M=f.geometry.clone();M.scale(1,1,-1),this.flipWindingOrder(M),v.geometry=M;const E=new ae,B=f.material.opacity;E.copy(f.material.color),v.material=new Me({color:E,opacity:B*_,map:f.material.map,transparent:!0})}g.set(f,v),y.set(f,_);const R=g.get(b);if(!R){console.error("Error when exporting UI: shadow component parent not found!",f,f.parent);return}R.add(v)})}}for(const d of h)d()}}flipWindingOrder(t){const i=t.index.array;for(let n=0,o=i.length/3;n<o;n++){const r=i[n*3];i[n*3]=i[n*3+2],i[n*3+2]=r}t.index.needsUpdate=!0}}const Gx=class{constructor(){a(this,"_quicklookButton"),a(this,"_arButton"),a(this,"_vrButton"),a(this,"_sendToQuestButton")}static create(){return new Gx}static getOrCreate(){return this._instance||(this._instance=this.create()),this._instance}get isSecureConnection(){return window.location.protocol==="https:"}get quicklookButton(){return this._quicklookButton}get arButton(){return this._arButton}get vrButton(){return this._vrButton}get sendToQuestButton(){return this._sendToQuestButton}get qrButton(){return Mn.getOrCreate().createQRCode()}createQuicklookButton(){if(this._quicklookButton)return this._quicklookButton;const s=document.createElement("button");this._quicklookButton=s,s.dataset.needle="quicklook-button";const t=Y.supportsQuickLookAR();s.innerText="View in AR",s.prepend(Pt("view_in_ar"));let i=!1,n=null;return s.addEventListener("click",()=>{n=Gd(Ge),n||(i=!0,n=new Ge),i&&(n.objectToExport=te.Current.scene),n?(s.classList.add("this-mode-is-requested"),n.exportAndOpen().then(()=>{s.classList.remove("this-mode-is-requested")}).catch(o=>{s.classList.remove("this-mode-is-requested"),console.error(o)})):console.warn("No USDZExporter component found in the scene")}),this.hideElementDuringXRSession(s),s}createARButton(s){var t;if(this._arButton)return this._arButton;const i="immersive-ar",n=document.createElement("button");return this._arButton=n,n.classList.add("webxr-button"),n.dataset.needle="webxr-ar-button",n.innerText="Enter AR",n.prepend(Pt("view_in_ar")),n.title="Click to start an AR session",n.addEventListener("click",()=>Z.start(i,s)),this.updateSessionSupported(n,i),this.listenToXRSessionState(n,i),this.hideElementDuringXRSession(n),this.isSecureConnection||(n.disabled=!0,n.title="WebXR requires a secure connection (HTTPS)"),Y.isMozillaXR()||(t=navigator.xr)==null||t.addEventListener("devicechange",()=>this.updateSessionSupported(n,i)),n}createVRButton(s){var t;if(this._vrButton)return this._vrButton;const i="immersive-vr",n=document.createElement("button");return this._vrButton=n,n.classList.add("webxr-button"),n.dataset.needle="webxr-vr-button",n.innerText="Enter VR",n.prepend(Pt("panorama_photosphere")),n.title="Click to start a VR session",n.addEventListener("click",()=>Z.start(i,s)),this.updateSessionSupported(n,i),this.listenToXRSessionState(n,i),this.hideElementDuringXRSession(n),this.isSecureConnection||(n.disabled=!0,n.title="WebXR requires a secure connection (HTTPS)"),Y.isMozillaXR()||(t=navigator.xr)==null||t.addEventListener("devicechange",()=>this.updateSessionSupported(n,i)),n}createSendToQuestButton(){var s;if(this._sendToQuestButton)return this._sendToQuestButton;const t="https://oculus.com/open_url/?url=",i=document.createElement("button");return this._sendToQuestButton=i,i.dataset.needle="webxr-sendtoquest-button",i.innerText="Open on Quest",i.prepend(Pt("share_windows")),i.title="Click to send this page to the Oculus Browser on your Quest",i.addEventListener("click",()=>{const n=encodeURIComponent(window.location.href),o=t+n;window.open(o)==null&&Le("This page doesn't allow popups. Please paste "+o+" into your browser.")}),this.listenToXRSessionState(i),this.hideElementDuringXRSession(i),Y.isMozillaXR()||(s=navigator.xr)==null||s.addEventListener("devicechange",()=>{var n;(n=navigator.xr)!=null&&n.isSessionSupported("immersive-vr")?i.style.display="none":i.style.display=""}),i}createQRCode(){return Mn.getOrCreate().createQRCode()}updateSessionSupported(s,t){if(!("xr"in navigator)){s.style.display="none";return}Z.isSessionSupported(t).then(i=>{s.style.display=i?"":"none",F()&&!i&&console.log('[WebXR] "'+t+'" is not supported on this device \u2013 make sure your server runs using HTTPS and you have a device connected that supports '+t)})}hideElementDuringXRSession(s){kd(t=>{s["previous-display"]=s.style.display,s.style.display="none"}),og(t=>{s["previous-display"]!=null&&(s.style.display=s["previous-display"])})}listenToXRSessionState(s,t){t&&(Z.onSessionRequestStart(i=>{i.mode===t?s.classList.add("this-mode-is-requested"):(s["was-disabled"]=s.disabled,s.disabled=!0,s.classList.add("other-mode-is-requested"))}),Z.onSessionRequestEnd(i=>{s.classList.remove("this-mode-is-requested"),s.classList.remove("other-mode-is-requested"),s.disabled=s["was-disabled"]}))}};let Yr=Gx;a(Yr,"_instance");var AT=Object.defineProperty,IT=Object.getOwnPropertyDescriptor,xt=(s,t,i,n)=>{for(var o=n>1?void 0:n?IT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&AT(t,i,o),o};const vp=O("debugspriterenderer"),jT=O("wireframe"),P0=class{static getOrCreateGeometry(s){if(s.__cached_geometry)return s.__cached_geometry;if(s.guid&&P0.cache[s.guid])return vp&&console.log("Take cached geometry for sprite",s.guid),P0.cache[s.guid];const t=new no;s.__cached_geometry=t;const i=new Float32Array(s.triangles.length*3),n=new Float32Array(s.triangles.length*2);for(let o=0;o<s.triangles.length;o+=1){const r=s.triangles[o];i[o*3]=-s.vertices[r].x,i[o*3+1]=s.vertices[r].y,i[o*3+2]=0;const l=s.uv[r];n[o*2]=l.x,n[o*2+1]=1-l.y}return t.setAttribute("position",new gt(i,3)),t.setAttribute("uv",new gt(n,2)),s.guid&&(this.cache[s.guid]=t),vp&&console.log("Built sprite geometry",s,t),t}};let mh=P0;a(mh,"cache",{});class LT{constructor(){a(this,"x"),a(this,"y")}}function Xx(s){s&&(s.colorSpace!=ps&&(s.colorSpace=ps,s.needsUpdate=!0),s.minFilter==hd&&s.magFilter==hd&&(s.anisotropy=1,s.needsUpdate=!0))}let rn=class{constructor(s){a(this,"guid"),a(this,"texture"),a(this,"triangles"),a(this,"uv"),a(this,"vertices"),a(this,"__cached_geometry"),a(this,"_mesh"),a(this,"_material"),s&&(this.texture=s,this.triangles=[0,1,2,0,2,3],this.uv=[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}],this.vertices=[{x:-.5,y:-.5},{x:.5,y:-.5},{x:.5,y:.5},{x:-.5,y:.5}])}get mesh(){return this._mesh||(this._mesh=new Q(mh.getOrCreateGeometry(this),this.material)),this._mesh}get material(){return this._material||(this.texture&&Xx(this.texture),this._material=new Me({map:this.texture,color:16777215,side:_i,transparent:!0})),this._material}getGeometry(){return mh.getOrCreateGeometry(this)}};xt([m()],rn.prototype,"guid",2),xt([m(Ne)],rn.prototype,"texture",2),xt([Ha()],rn.prototype,"triangles",2),xt([Ha()],rn.prototype,"uv",2),xt([Ha()],rn.prototype,"vertices",2);const k0=Symbol("spriteOwner");class Fo{constructor(){a(this,"sprites")}}xt([m(rn)],Fo.prototype,"sprites",2);const Qx=class{constructor(){a(this,"spriteSheet"),a(this,"index",0)}static create(){const s=new Qx;return s.spriteSheet=new Fo,s}set sprite(s){s&&(this.spriteSheet?((this.index===null||this.index===void 0)&&(this.index=0),this.spriteSheet.sprites[this.index]=s):(this.spriteSheet=new Fo,this.spriteSheet.sprites=[s],this.index=0))}get sprite(){if(this.spriteSheet)return this.spriteSheet.sprites[this.index]}update(s){if(!this.spriteSheet)return;const t=this.index;if(t<0||t>=this.spriteSheet.sprites.length)return;const i=this.spriteSheet.sprites[t],n=i?.texture;if(n&&(Xx(n),!i.__hasLoadedProgressive)){i.__hasLoadedProgressive=!0;const o=n;et.assignTextureLOD(n,0).then(r=>{r instanceof Ne&&(i.texture=r,s?.map===o&&(s.map=r,s.needsUpdate=!0))})}}};let Wn=Qx;xt([m(Fo)],Wn.prototype,"spriteSheet",2),xt([m()],Wn.prototype,"index",2);class pi extends A{constructor(){super(...arguments),a(this,"drawMode",0),a(this,"size",{x:1,y:1}),a(this,"color"),a(this,"sharedMaterial"),a(this,"transparent",!0),a(this,"cutoutThreshold",0),a(this,"castShadows",!1),a(this,"renderOrder",0),a(this,"toneMapped",!0),a(this,"_spriteSheet"),a(this,"_currentSprite")}set texture(t){var i;if(!this._spriteSheet)return;const n=(i=this._spriteSheet.spriteSheet)==null?void 0:i.sprites[this.spriteIndex];n&&(n.texture=t,this.updateSprite())}addSprite(t,i=!1){var n,o;if(this._spriteSheet||(this._spriteSheet=Wn.create()),!this._spriteSheet.spriteSheet)return-1;(n=this._spriteSheet.spriteSheet)==null||n.sprites.push(t);const r=((o=this._spriteSheet.spriteSheet)==null?void 0:o.sprites.length)-1;return i&&(this.spriteIndex=r),r}get sprite(){return this._spriteSheet}set sprite(t){if(t!==this._spriteSheet)if(typeof t=="number"){const i=Math.floor(t);this.spriteIndex=i;return}else t instanceof rn?(this._spriteSheet||(this._spriteSheet=Wn.create()),this._spriteSheet.sprite!=t&&(this._spriteSheet.sprite=t,this.updateSprite())):t!=this._spriteSheet&&(this._spriteSheet=t,this.updateSprite())}set spriteIndex(t){this._spriteSheet&&t!==this.spriteIndex&&(this._spriteSheet.index=t,this.updateSprite())}get spriteIndex(){var t;return((t=this._spriteSheet)==null?void 0:t.index)??0}get spriteFrames(){var t,i;return((i=(t=this._spriteSheet)==null?void 0:t.spriteSheet)==null?void 0:i.sprites.length)??0}awake(){this._currentSprite=void 0,this._spriteSheet||(this._spriteSheet=new Wn,this._spriteSheet.spriteSheet=new Fo),vp&&console.log("Awake",this.name,this,this.sprite)}start(){this._currentSprite?this.gameObject&&this.gameObject.add(this._currentSprite):this.updateSprite()}updateSprite(t=!1){var i;if(!this.__didAwake&&!t)return!1;const n=this._spriteSheet;if(!((i=n?.spriteSheet)!=null&&i.sprites))return console.warn("SpriteRenderer has no data or spritesheet assigned..."),!1;const o=n.spriteSheet.sprites[this.spriteIndex];if(!o)return vp&&console.warn("Sprite not found",this.spriteIndex,n.spriteSheet.sprites),!1;if(this._currentSprite)this._currentSprite.geometry=mh.getOrCreateGeometry(o),this._currentSprite.material.map=o.texture;else{const r=new Me({color:16777215,side:_i});if(jT&&(r.wireframe=!0),this.color&&(r.color||(r.color=new ae),r.color.copy(this.color),r.opacity=this.color.alpha),r.transparent=!0,r.toneMapped=this.toneMapped,o.texture&&!r.wireframe){let l=o.texture;l[k0]!==void 0&&l[k0]!==this&&this.spriteFrames>1&&(l=o.texture=l.clone()),l[k0]=this,r.map=l}this.sharedMaterial=r,this._currentSprite=new Q(mh.getOrCreateGeometry(o),r),this._currentSprite.renderOrder=Math.round(this.renderOrder),et.assignTextureLOD(r,0)}return this._currentSprite.parent!==this.gameObject&&(this.drawMode===2&&this._currentSprite.scale.set(this.size.x,this.size.y,1),this.gameObject&&this.gameObject.add(this._currentSprite)),this._currentSprite&&this._currentSprite.layers.set(this.layer),this.sharedMaterial&&(this.sharedMaterial.alphaTest=this.cutoutThreshold,this.sharedMaterial.transparent=this.transparent),this._currentSprite.castShadow=this.castShadows,n?.update(this.sharedMaterial),!0}}xt([m()],pi.prototype,"drawMode",2),xt([m(LT)],pi.prototype,"size",2),xt([m(we)],pi.prototype,"color",2),xt([m(Oe)],pi.prototype,"sharedMaterial",2),xt([m()],pi.prototype,"transparent",2),xt([m()],pi.prototype,"cutoutThreshold",2),xt([m()],pi.prototype,"castShadows",2),xt([m()],pi.prototype,"renderOrder",2),xt([m()],pi.prototype,"toneMapped",2),xt([m(Wn)],pi.prototype,"sprite",1);const Yx=O("debugwebxr"),DT=new ne().makeRotationY(Math.PI);class Vn extends A{constructor(){super(...arguments),a(this,"_arScale",1),a(this,"invertForward",!1),a(this,"customReticle"),a(this,"arTouchTransform",!0),a(this,"autoPlace",!1),a(this,"autoCenter",!1),a(this,"useXRAnchor",!1),a(this,"_isPlacing",!0),a(this,"_startOffset",new ne),a(this,"_createdPlacementObject",null),a(this,"_reparentedComponents",[]),a(this,"_placementScene",new $i),a(this,"_reticle",[]),a(this,"_hits",[]),a(this,"_placementStartTime",-1),a(this,"_rigPlacementMatrix"),a(this,"_anchor",null),a(this,"userInput"),a(this,"onPlaceScene",t=>{var i;if(this._isPlacing==!1||t!=null&&t.used)return;let n=this._reticle[0];if(!n){console.warn("No reticle to place...");return}if(!n.visible&&!this.autoPlace){console.warn("Reticle is not visible (can not place)");return}if((i=Z.active)!=null&&i.isTrackingImages){console.warn("Scene Placement is disabled while images are being tracked");return}let o=this._hits[0];if(t&&t.origin instanceof rg){const r=this._reticle[t.origin.index];r&&(n=r,o=this._hits[t.origin.index])}if(t&&(t.stopImmediatePropagation(),t.stopPropagation(),t.use()),this._isPlacing=!1,this.context.input.removeEventListener("pointerup",this.onPlaceScene),this.onRevertSceneChanges(),n.position.copy(n.lastPos),n.quaternion.copy(n.lastQuat),this.onApplyPose(n),this.useXRAnchor&&this.onCreateAnchor(Z.active,o),this.context.xr)for(const r of this.context.xr.controllers)r.cancelHitTestSource()}),a(this,"upVec",new x(0,1,0)),a(this,"lookPoint",new x),a(this,"worldUpVec",new x(0,1,0))}static onPlaced(t){const i="placed";return this._eventListeners[i]||(this._eventListeners[i]=[]),this._eventListeners[i].push(t),()=>{const n=this._eventListeners[i].indexOf(t);n>=0&&this._eventListeners[i].splice(n,1)}}get arScale(){return this._arScale}set arScale(t){t!==this._arScale&&(this._arScale=t,this.onScaleChanged())}onEnable(){var t;(t=this.customReticle)==null||t.preload()}supportsXR(t){return t==="immersive-ar"}onEnterXR(t){Yx&&console.log("ENTER WEBXR: SessionRoot start..."),this._anchor=null,this.gameObject.updateMatrixWorld(),this._startOffset.copy(this.gameObject.matrixWorld);const i=new j;this._createdPlacementObject=i,i.name="AR Session Root",this._placementScene.name="AR Placement Scene",this._placementScene.children.length=0;for(let n=this.context.scene.children.length-1;n>=0;n--){const o=this.context.scene.children[n];this._placementScene.add(o)}if(this.context.scene.add(i),this.autoCenter){const n=Si(this._placementScene.children),o=n.getCenter(new x),r=n.getSize(new x),l=new ne;l.makeTranslation(o.x,o.y-r.y*.5,o.z),this._startOffset.multiply(l)}this._reparentedComponents.length=0,this._reparentedComponents.push({comp:this,originalObject:this.gameObject}),P.addComponent(i,this);for(const n of this._reticle)Mi(n);this._reticle.length=0,this._isPlacing=!0,this.context.input.addEventListener("pointerup",this.onPlaceScene,{queue:Ci.Early})}onLeaveXR(){this.context.input.removeEventListener("pointerup",this.onPlaceScene,{queue:Ci.Early}),this.onRevertSceneChanges(),this._anchor=null,this._rigPlacementMatrix=void 0}onUpdateXR(t){var i,n,o,r;if(t.xr.isTrackingImages){for(const l of this._reticle)l.visible=!1;return}if(this._isPlacing){const l=(i=t.xr.rig)==null?void 0:i.gameObject;l&&l.parent!==this.context.scene&&this.context.scene.add(l);let c=!1;if(t.xr.isPassThrough&&t.xr.controllers.length>0&&!this.autoPlace)for(const h of t.xr.controllers){const d=h.getHitTest();d&&(c=!0,this.updateReticleAndHits(t.xr,h.index,d,t.xr.rigScale))}if(!c){const h=t.xr.getHitTest();h&&this.updateReticleAndHits(t.xr,0,h,t.xr.rigScale)}}else{if(this._anchor&&t.xr.referenceSpace){const l=t.xr.frame.getPose(this._anchor.anchorSpace,t.xr.referenceSpace);if(l&&this.context.time.frame%20===0){const c=t.xr.convertSpace(l.transform),h=this._reticle[0];h&&(h.position.copy(c.position),h.quaternion.copy(c.quaternion),this.onApplyPose(h))}}if(this.arTouchTransform?(this.userInput||(this.userInput=new bp(this.context)),(n=this.userInput)==null||n.enable()):(o=this.userInput)==null||o.disable(),this.arTouchTransform&&(r=this.userInput)!=null&&r.hasChanged){if(t.xr.rig){const l=t.xr.rig.gameObject;this.userInput.applyMatrixTo(l.matrix,!0),l.matrix.decompose(l.position,l.quaternion,l.scale),this.userInput.factor=l.scale.x}this.userInput.reset()}}}updateReticleAndHits(t,i,n,o){this._hits[i]=n.hit;let r=this._reticle[i];if(!r){if(this.customReticle)if(this.customReticle.asset)r=za(this.customReticle.asset);else{this.customReticle.loadAssetAsync();return}else r=new Q(new rC(.07,.09,32).rotateX(-Math.PI/2),new Me({side:_i,depthTest:!1,depthWrite:!1,transparent:!0,opacity:1,color:15658734})),r.name="AR Placement Reticle";if(Yx){const l=new bi(1);l.position.y+=.01,r.add(l)}this._reticle[i]=r,r.matrixAutoUpdate=!1,r.visible=!1}if(r.lastPos=r.lastPos||n.position.clone(),r.lastQuat=r.lastQuat||n.quaternion.clone(),r.position.copy(r.lastPos.lerp(n.position,this.context.time.deltaTime/.1)),r.lastPos.copy(r.position),r.quaternion.copy(r.lastQuat.slerp(n.quaternion,this.context.time.deltaTime/.05)),r.lastQuat.copy(r.quaternion),r.scale.set(o,o,o),this.customReticle&&this.applyViewBasedTransform(r),r.updateMatrix(),r.visible=!0,r.parent!==this.context.scene&&this.context.scene.add(r),this._placementStartTime<0&&(this._placementStartTime=this.context.time.realtimeSinceStartup),this.autoPlace)if(this.upVec.set(0,1,0).applyQuaternion(r.quaternion),this.upVec.dot($(0,1,0))>.9){let l=r["autoplace:timer"]||0;l>=1?(r.visible=!1,this.onPlaceScene(null)):(l+=this.context.time.deltaTime,r["autoplace:timer"]=l)}else r["autoplace:timer"]=0}onScaleChanged(){}onRevertSceneChanges(){var t;for(const i of this._reticle)i&&(i.visible=!1,i?.removeFromParent());this._reticle.length=0;for(let i=this._placementScene.children.length-1;i>=0;i--){const n=this._placementScene.children[i];this.context.scene.add(n)}(t=this._createdPlacementObject)==null||t.removeFromParent();for(const i of this._reparentedComponents)P.addComponent(i.originalObject,i.comp)}async onCreateAnchor(t,i){if(i.createAnchor===void 0){console.warn("Hit does not support creating an anchor",i),F()&&_e("Hit does not support creating an anchor");return}else{const n=await i.createAnchor(t.viewerPose.transform);t.running&&n&&(this._anchor=n)}}applyViewBasedTransform(t){const i=this.context.mainCamera,n=t,o=i.worldPosition,r=n.worldPosition;this.upVec.set(0,1,0).applyQuaternion(t.quaternion);const l=i.worldPosition;l&&t.position.clone().sub(l).angleTo(this.upVec)<Math.PI/2&&this.upVec.negate();const c=this.upVec.angleTo(this.worldUpVec)*180/Math.PI,h=30;c>h&&c<180-h||c<-h&&c>-180+h?(this.lookPoint.copy(t.position).add(this.upVec),this.lookPoint.y=t.position.y,t.lookAt(this.lookPoint)):(o.y=r.y,t.lookAt(o))}onApplyPose(t){var i,n,o,r;const l=(n=(i=Z.active)==null?void 0:i.rig)==null?void 0:n.gameObject;if(!l){console.warn("No rig object to place");return}(o=Z.active)!=null&&o.rigScale;const c=l.parent||this.context.scene;this._rigPlacementMatrix?(r=this._rigPlacementMatrix)==null||r.decompose(l.position,l.quaternion,l.scale):this._rigPlacementMatrix=l.matrix.clone(),this.applyViewBasedTransform(t),t.updateMatrix(),this.context.scene.add(t),t.attach(l),t.removeFromParent(),l.scale.set(this.arScale,this.arScale,this.arScale),l.position.multiplyScalar(this.arScale),l.updateMatrix(),this.invertForward&&l.matrix.premultiply(DT),l.matrix.premultiply(this._startOffset),l.matrix.decompose(l.position,l.quaternion,l.scale),c.add(l)}}a(Vn,"_eventListeners",{});const M0=class{constructor(s){a(this,"oneFingerDrag",!0),a(this,"twoFingerRotate",!0),a(this,"twoFingerScale",!0),a(this,"factor",1),a(this,"context"),a(this,"offset"),a(this,"plane"),a(this,"_scale",1),a(this,"_hasChanged",!1),a(this,"_enabled",!1),a(this,"currentlyUsedPointerIds",new Set),a(this,"currentlyUnusedPointerIds",new Set),a(this,"onPointerDownEarly",t=>{this.isActive&&t.stopPropagation()}),a(this,"onPointerDownLate",t=>{t.used?this.currentlyUsedPointerIds.add(t.pointerId):this.currentlyUsedPointerIds.size<=0&&this.currentlyUnusedPointerIds.add(t.pointerId)}),a(this,"onPointerUpEarly",t=>{this.currentlyUsedPointerIds.delete(t.pointerId),this.currentlyUnusedPointerIds.delete(t.pointerId)}),a(this,"prev",new Map),a(this,"_didMultitouch",!1),a(this,"touchStart",t=>{if(!t.defaultPrevented)for(let i=0;i<t.changedTouches.length;i++){const n=t.changedTouches[i],o=Y.isAndroidDevice()&&n.clientY<window.innerHeight*.1;this.prev.has(n.identifier)||this.prev.set(n.identifier,{ignore:o,x:0,z:0,screenx:0,screeny:0});const r=this.prev.get(n.identifier);if(r){const l=this.getPositionOnPlane(n.clientX,n.clientY);r.x=l.x,r.z=l.z,r.screenx=n.clientX,r.screeny=n.clientY}}}),a(this,"touchEnd",t=>{t.touches.length<=0&&(this._didMultitouch=!1);for(let i=0;i<t.changedTouches.length;i++){const n=t.changedTouches[i];this.prev.delete(n.identifier)}}),a(this,"touchMove",t=>{if(!t.defaultPrevented&&this.isActive){if(t.touches.length===1){if(this._didMultitouch)return;const i=t.touches[0],n=this.prev.get(i.identifier);if(!n||n.ignore)return;const o=this.getPositionOnPlane(i.clientX,i.clientY),r=o.x-n.x,l=o.z-n.z;if(r===0&&l===0)return;this.oneFingerDrag&&this.addMovement(r,l),n.x=o.x,n.z=o.z,n.screenx=i.clientX,n.screeny=i.clientY;return}else if(t.touches.length===2){this._didMultitouch=!0;const i=t.touches[0],n=t.touches[1],o=this.prev.get(i.identifier),r=this.prev.get(n.identifier);if(!o||!r)return;if(this.twoFingerRotate){const l=Math.atan2(i.clientY-n.clientY,i.clientX-n.clientX),c=Math.atan2(o.screeny-r.screeny,o.screenx-r.screenx),h=l-c;Math.abs(h)>.001&&this.addRotation(h)}if(this.twoFingerScale){const l=i.clientX-n.clientX,c=i.clientY-n.clientY,h=Math.sqrt(l*l+c*c),d=o.screenx-r.screenx,u=o.screeny-r.screeny,p=Math.sqrt(d*d+u*u),g=h-p;Math.abs(g)>2&&this.addScale(g)}o.screenx=i.clientX,o.screeny=i.clientY,r.screenx=n.clientX,r.screeny=n.clientY}}}),a(this,"_raycaster",new ld),a(this,"_intersection",new x),a(this,"_screenPos",new x),a(this,"_tempMatrix",new ne),this.context=s,this.offset=new ne,this.plane=new dr,this.plane.setFromNormalAndCoplanarPoint(M0.up,M0.zero)}reset(){this._scale=1,this.offset.identity()}get hasChanged(){return this._hasChanged}applyMatrixTo(s,t){this._hasChanged=!1,t?(this.offset.invert(),s.premultiply(this.offset)):s.multiply(this.offset)}get isActive(){return this.currentlyUsedPointerIds.size<=0&&this.currentlyUnusedPointerIds.size>0}enable(){this._enabled||(this._enabled=!0,this.context.input.addEventListener("pointerdown",this.onPointerDownEarly,{queue:Ci.Early}),this.context.input.addEventListener("pointerdown",this.onPointerDownLate,{queue:Ci.Late}),this.context.input.addEventListener("pointerup",this.onPointerUpEarly,{queue:Ci.Early}),window.addEventListener("touchstart",this.touchStart,{passive:!1}),window.addEventListener("touchmove",this.touchMove,{passive:!1}),window.addEventListener("touchend",this.touchEnd,{passive:!1}))}disable(){this._enabled&&(this._enabled=!1,this.context.input.removeEventListener("pointerdown",this.onPointerDownEarly,{queue:Ci.Early}),this.context.input.removeEventListener("pointerdown",this.onPointerDownLate,{queue:Ci.Late}),this.context.input.removeEventListener("pointerup",this.onPointerUpEarly,{queue:Ci.Early}),window.removeEventListener("touchstart",this.touchStart),window.removeEventListener("touchmove",this.touchMove),window.removeEventListener("touchend",this.touchEnd))}getPositionOnPlane(s,t){const i=this.context.mainCamera;return this._screenPos.x=s/window.innerWidth*2-1,this._screenPos.y=-(t/window.innerHeight)*2+1,this._screenPos.z=1,this._screenPos.unproject(i),this._raycaster.set(i.position,this._screenPos.sub(i.position)),this._raycaster.ray.intersectPlane(this.plane,this._intersection),this._intersection}addMovement(s,t){s/=this._scale,t/=this._scale,s*=this.factor,t*=this.factor,this.offset.elements[12]+=s,this.offset.elements[14]+=t,(s!==0||t!==0)&&(this._hasChanged=!0)}addScale(s){s/=window.innerWidth,s*=-1,this._scale*=1+s,this._tempMatrix.makeScale(1-s,1-s,1-s),this.offset.premultiply(this._tempMatrix),s!==0&&(this._hasChanged=!0)}addRotation(s){s*=-1,this._tempMatrix.makeRotationY(s),this.offset.premultiply(this._tempMatrix),s!==0&&(this._hasChanged=!0)}};let bp=M0;a(bp,"up",new x(0,1,0)),a(bp,"zero",new x(0,0,0)),a(bp,"one",new x(1,1,1));const zo=O("debugautosync"),R0=Symbol("syncerId");class BT{constructor(){a(this,"_syncers",{})}getOrCreateSyncer(t){if(!t.guid)return null;if(this._syncers[t.guid])return this._syncers[t.guid];const i=new FT(t);return i[R0]=t.guid,this._syncers[i[R0]]=i,i}removeSyncer(t){delete this._syncers[t[R0]]}}const T0=new BT;class FT{constructor(t){a(this,"comp"),a(this,"hasChanges",!1),a(this,"changedProperties",{}),a(this,"_isReceiving",!1),a(this,"_isInit",!1),a(this,"onHandleSending",()=>{if(!this.hasChanges)return;this.hasChanges=!1;const i=this.comp.context.connection;if(!i||!i.isConnected||!i.isInRoom){for(const n in this.changedProperties)delete this.changedProperties[n];return}for(const n in this.changedProperties){const o=this.changedProperties[n];zo&&console.log("SEND",this.comp.guid,this.networkingKey),i.send(this.networkingKey,{guid:this.comp.guid,property:n,data:o},bs.Queued),delete this.changedProperties[n]}}),a(this,"onHandleReceiving",i=>{if(zo&&console.log("SYNCFIELD RECEIVE",this.comp.name,this.comp.guid,i),!!this._isInit&&this.comp&&i.guid===this.comp.guid)try{this._isReceiving=!0,this.comp[i.property]=i.data}catch(n){console.error(n)}finally{this._isReceiving=!1}}),this.comp=t}get networkingKey(){return this.comp.guid}init(t){if(this._isInit)return;this._isInit=!0,this.comp=t,this.comp.context.post_render_callbacks.push(this.onHandleSending),this.comp.context.connection.beginListen(this.networkingKey,this.onHandleReceiving);const i=this.comp.context.connection.tryGetState(this.comp.guid);i&&this.onHandleReceiving(i)}destroy(){this._isInit&&(this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this.onHandleSending),1),this.comp.context.connection.stopListen(this.networkingKey,this.onHandleReceiving),this.comp=null,this._isInit=!1)}notifyChanged(t,i){this._isReceiving||(zo&&console.log("Property changed: "+t,i),this.hasChanges=!0,this.changedProperties[t]=i)}}function zT(s,t){let i=t!==s;return!i&&s&&t&&(Array.isArray(s)&&Array.isArray(t)||typeof s=="object"&&typeof t=="object")&&(i=!0),i}const gh=Symbol("AutoSyncHandler");function UT(s){if(s[gh])return s[gh];const t=T0.getOrCreateSyncer(s);return t?.init(s),s[gh]=t,t}function NT(s){const t=s[gh];t&&(T0.removeSyncer(t),t.destroy(),delete s[gh])}const E0=function(s=null){return function(t,i){var n;let o="";typeof i=="string"?o=i:o=i.name;let r=null,l;typeof s=="string"?l=t[s]:typeof s=="function"&&(l=s),l==null&&(F()||zo)&&s!=null&&console.warn('syncField: no callback function found for property "'+o+'"','"'+s+'"');const c=t,h=c.__internalAwake;if(typeof h!="function"){(zo||F())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((n=t?.constructor)==null?void 0:n.name)+'" is not supported',t);return}zo&&console.log(o);const d=Symbol(o);c.__internalAwake=function(){if(this[d]!==void 0)return;this[d]=this[o],r=T0.getOrCreateSyncer(this);const p=Object.getOwnPropertyDescriptor(this,o);if(p?.set===void 0){let g=!1;Object.defineProperty(this,o,{set:function(y){var f;const v=this[d];if(this[d]=y,g){(F()||zo)&&console.warn("Recursive call detected",o);return}g=!0;try{const b=zT(y,v);zo&&console.log("SyncField assignment",o,"changed?",b,y,l),b&&l?.call(this,y,v)!==!1&&((f=UT(this))==null||f.notifyChanged(o,y))}finally{g=!1}},get:function(){return this[d]},configurable:!0,enumerable:!0})}r?.init(this),h.call(this)};const u=c.__internalDestroy;c.__internalDestroy=function(){NT(this),u.call(this)}}};var WT=Object.defineProperty,VT=Object.getOwnPropertyDescriptor,_p=(s,t,i,n)=>{for(var o=n>1?void 0:n?VT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&WT(t,i,o),o};const ti=O("debugplayersync"),Kx=class extends A{constructor(){super(...arguments),a(this,"autoSync",!0),a(this,"asset"),a(this,"onPlayerSpawned"),a(this,"_localInstance"),a(this,"onJoinedRoom",()=>{ti&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()}),a(this,"destroyInstance",()=>{var s;(s=this._localInstance)==null||s.then(t=>{ti&&console.log("PlayerSync.destroyInstance",t),vc(t,this.context.connection,!0,{saveInRoom:!1})}),this._localInstance=void 0})}static async setupFrom(s,t){const i=le.getOrCreateFromUrl(s);if(!i.asset){const r=await i.loadAssetAsync();r&&P.getOrAddComponent(r,ji)}const n=new Kx;n._internalInit(t),n.asset=i;const o=new j;return o.guid=s,P.addComponent(o,n),n}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new ke)}onEnable(){this.context.connection.beginListen(ie.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(ie.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(ie.LeftRoom,this.destroyInstance),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(ie.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(ie.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(ie.LeftRoom,this.destroyInstance)}async getInstance(){var s,t,i,n,o,r;if(this._localInstance)return this._localInstance;if(ti&&console.log("PlayerSync.createInstance",(s=this.asset)==null?void 0:s.url),!((t=this.asset)!=null&&t.asset)&&!((i=this.asset)!=null&&i.url))return console.error('PlayerSync: can not create an instance because "asset" is not set and or has no URL!'),null;this.gameObject.guid||console.warn("PlayerSync: gameObject has no guid! This might cause issues with syncing the player state."),this._localInstance=(n=this.asset)==null?void 0:n.instantiateSynced({parent:this.gameObject,deleteOnDisconnect:!0},!0);const l=await this._localInstance;if(l){const c=P.getComponentsInChildren(l,ji);if(ti&&console.log(`PlayerSync.createInstance: found ${c?.length} PlayerState components. Owner: ${this.context.connection.connectionId}`),c!=null&&c.length){for(const h of c)h.owner=this.context.connection.connectionId;(o=this.onPlayerSpawned)==null||o.invoke(l)}else this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((r=this.asset)==null?void 0:r.url)+"</strong>: please make sure the asset has a PlayerState component!"),P.destroySynced(l)}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}watchTabVisible(){window.addEventListener("visibilitychange",s=>{if(document.visibilityState==="visible")for(let t=ji.all.length-1;t>=0;t--){const i=ji.all[t];(!i.owner||!this.context.connection.userIsInRoom(i.owner))&&i.doDestroy()}})}};let bl=Kx;_p([m()],bl.prototype,"autoSync",2),_p([m(le)],bl.prototype,"asset",2),_p([m(ke)],bl.prototype,"onPlayerSpawned",2);var Zx=(s=>(s.OwnerChanged="ownerChanged",s))(Zx||{}),fh;const Et=(fh=class extends A{constructor(){super(...arguments),a(this,"onOwnerChangeEvent",new ke),a(this,"onFirstOwnerChangeEvent",new ke),a(this,"hasOwner",!1),a(this,"owner"),a(this,"dontDestroy",!1),a(this,"onUserLeftRoom",s=>{if(s.userId===this.owner){ti&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return Et._all}static get local(){return Et._local}static getFor(s){if(s instanceof j)return P.getComponentInParent(s,Et);if(s instanceof A)return P.getComponentInParent(s.gameObject,Et)}static isLocalPlayer(s){const t=Et.getFor(s);return t?.isLocalPlayer??!1}static addEventListener(s,t){return this._callbacks[s]||(this._callbacks[s]=[]),this._callbacks[s].push(t),t}static removeEventListener(s,t){if(!this._callbacks[s])return;const i=this._callbacks[s].indexOf(t);i>=0&&this._callbacks[s].splice(i,1)}static dispatchEvent(s,t){if(this._callbacks[s])for(const i of this._callbacks[s])i(t)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(s,t){var i,n;ti&&console.log(`PlayerSync.onOwnerChange: ${t} \u2192 ${s} (me: ${this.context.connection.connectionId})`);const o=Et._local.indexOf(this);o>=0&&Et._local.splice(o,1);const r={playerState:this,oldValue:t,newValue:s};if(this.hasOwner||(this.hasOwner=!0,(i=this.onFirstOwnerChangeEvent)==null||i.invoke(r)),(n=this.onOwnerChangeEvent)==null||n.invoke(r),this.owner===this.context.connection.connectionId){Et._local.push(this);const c=new CustomEvent("local-owner-changed",{detail:r});this.dispatchEvent(c)}const l=new CustomEvent("owner-changed",{detail:r});this.dispatchEvent(l),Et.dispatchEvent("ownerChanged",l)}awake(){Et.all.push(this),ti&&console.log("Registered new PlayerState",this.guid,Et.all.length-1,Et.all),this.context.connection.beginListen(ie.UserLeftRoom,this.onUserLeftRoom)}async start(){ti&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await gs(300),this.context.connection.userIsInRoom(this.owner)==!1&&(ti&&console.log(`PlayerSync.start \u2192 doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(ti&&console.warn("PlayerState.start \u2192 owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?ti&&console.warn("PlayerState.start \u2192 owner is still undefined but dontDestroy is set to true",this.name):(ti&&console.warn(`PlayerState.start \u2192 owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):ti&&console.log("PlayerState.start \u2192 owner is assigned",this.owner)},2e3))}doDestroy(){ti&&console.log("PlayerSync.doDestroy \u2192 syncDestroy",this.name),vc(this.gameObject,this.context.connection,!0,{saveInRoom:!1})}onDestroy(){if(ti&&console.warn("PlayerState.onDestroy",this.owner),this.context.connection.stopListen(ie.UserLeftRoom,this.onUserLeftRoom),Et.all.splice(Et.all.indexOf(this),1),this.isLocalPlayer){const s=Et._local.indexOf(this);s>=0&&Et._local.splice(s,1)}}},a(fh,"_all",[]),a(fh,"_local",[]),a(fh,"_callbacks",{}),fh);let ji=Et;_p([E0(ji.prototype.onOwnerChange)],ji.prototype,"owner",2);var HT=Object.defineProperty,$T=Object.getOwnPropertyDescriptor,_l=(s,t,i,n)=>{for(var o=n>1?void 0:n?$T(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&HT(t,i,o),o};class an extends A{constructor(){super(...arguments),a(this,"position","bottom"),a(this,"showNeedleLogo",!0),a(this,"showSpatialMenu"),a(this,"createFullscreenButton"),a(this,"createMuteButton"),a(this,"createQRCodeButton")}onEnable(){this.applyOptions()}applyOptions(){this.context.menu.setPosition(this.position),this.context.menu.showNeedleLogo(this.showNeedleLogo),this.createFullscreenButton===!0&&this.context.menu.showFullscreenOption(!0),this.createMuteButton===!0&&this.context.menu.showAudioPlaybackOption(!0),this.showSpatialMenu===!0&&this.context.menu.showSpatialMenu(this.showSpatialMenu),this.createQRCodeButton===!0&&(Y.isMobileDevice()||this.context.menu.showQRCodeButton(!0))}}_l([m()],an.prototype,"position",2),_l([m()],an.prototype,"showNeedleLogo",2),_l([m()],an.prototype,"showSpatialMenu",2),_l([m()],an.prototype,"createFullscreenButton",2),_l([m()],an.prototype,"createMuteButton",2),_l([m()],an.prototype,"createQRCodeButton",2);var qT=Object.defineProperty,GT=Object.getOwnPropertyDescriptor,A0=(s,t,i,n)=>{for(var o=n>1?void 0:n?GT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&qT(t,i,o),o};const yh=O("debugwebxr"),Jx=new V().setFromAxisAngle(new x(0,1,0),Math.PI);class Uo extends A{constructor(){super(...arguments),a(this,"head"),a(this,"leftHand"),a(this,"rightHand"),a(this,"_leftHandMeshes"),a(this,"_rightHandMeshes"),a(this,"_syncTransforms")}async onEnterXR(t){if(!this.activeAndEnabled)return;yh&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const i=ji.getFor(this);if(i!=null&&i.owner){const n=this.gameObject.addComponent(Rt);n.avatar=this.gameObject,n.connectionId=i.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):i&&!this.context.connection.isConnected&&(i.dontDestroy=!0)}onLeaveXR(t){const i=this.gameObject.getComponent(Rt);i&&i.destroy()}onUpdateXR(t){var i,n;if(!this.activeAndEnabled)return;const o=ji.isLocalPlayer(this);if(!o)return;const r=t.xr;if(r.rig&&r.rig.gameObject!==this.gameObject.parent&&(this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),this.gameObject.scale.set(1,1,1),r.rig.gameObject.add(this.gameObject)),this._syncTransforms&&o)for(const u of this._syncTransforms)u.fastMode=!0,u.isOwned()||u.requestOwnership();if(this.head&&this.context.mainCamera){const u=this.head.asset;if(u.position.copy(this.context.mainCamera.position),u.position.x*=-1,u.position.z*=-1,u.quaternion.copy(this.context.mainCamera.quaternion),u.quaternion.x*=-1,this.context.time.frameCount%10===0&&this.head.asset){const p=P.getComponentsInChildren(this.head.asset,Ei);for(const g of p)g.enabled=!1,g.gameObject.visible=!1}}const l=t.xr.leftController,c=(i=this.leftHand)==null?void 0:i.asset;l&&c?(c.position.copy(l.gripPosition),c.quaternion.copy(l.gripQuaternion),c.quaternion.multiply(Jx),c.visible=l.isTracking,this.updateHandVisibility(l,c,this._leftHandMeshes)):c&&c.visible&&(c.visible=!1);const h=t.xr.rightController,d=(n=this.rightHand)==null?void 0:n.asset;h&&d?(d.position.copy(h.gripPosition),d.quaternion.copy(h.gripQuaternion),d.quaternion.multiply(Jx),d.visible=h.isTracking,this.updateHandVisibility(h,d,this._rightHandMeshes)):d&&d.visible&&(d.visible=!1)}onBeforeRender(){this.context.xr&&this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateHandVisibility(t,i,n){if(n){const o=t.model&&t.model.visible&&t.model!==i;n.forEach(r=>{Pn(r,!o)})}}updateRemoteAvatarVisibility(){var t,i,n;if(this.context.connection.isConnected){const o=ji.getFor(this);if(o&&o.isLocalPlayer==!1){const r=Z.getXRSync(this.context);if(r&&r.hasState(o.owner)){this.tryFindAvatarObjectsIfMissing();const l=(t=this.leftHand)==null?void 0:t.asset;l&&(l.visible=r?.isTracking(o.owner,"left")??!1);const c=(i=this.rightHand)==null?void 0:i.asset;c&&(c.visible=r?.isTracking(o.owner,"right")??!1)}if((n=this.head)!=null&&n.asset){const l=P.getComponentsInChildren(this.head.asset,Ei);for(const c of l)c.enabled=!1,c.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const t={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};Wb.tryFindAvatarObjects(this.gameObject,this.sourceId||"",t),t.head&&(this.head=t.head),t.leftHand&&(this.leftHand=t.leftHand),t.rightHand&&(this.rightHand=t.rightHand)}}async prepareAvatar(){var t,i;if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof j&&(this.head=new le("",this.sourceId,this.head));else{const n=new j;n.name="Head";const o=po.createPrimitive(_r.Cube);n.add(o),this.gameObject.add(n),this.head=new le("",this.sourceId,n),yh&&console.log("Create head",n)}if(this.rightHand)this.rightHand instanceof j&&(this.rightHand=new le("",this.sourceId,this.rightHand));else{const n=new j;n.name="Right Hand",this.gameObject.add(n),this.rightHand=new le("",this.sourceId,n),yh&&console.log("Create right hand",n)}if(this.leftHand)this.leftHand instanceof j&&(this.leftHand=new le("",this.sourceId,this.leftHand));else{const n=new j;n.name="Left Hand",this.gameObject.add(n),this.leftHand=new le("",this.sourceId,n),yh&&console.log("Create left hand",n)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),this._leftHandMeshes=[],(t=this.leftHand.asset)==null||t.traverse(n=>{n!=null&&n.isMesh&&this._leftHandMeshes.push(n)}),this._rightHandMeshes=[],(i=this.rightHand.asset)==null||i.traverse(n=>{n!=null&&n.isMesh&&this._rightHandMeshes.push(n)}),ji.isLocalPlayer(this.gameObject)&&(this._syncTransforms=P.getComponentsInChildren(this.gameObject,$s))}async loadAvatarObjects(t,i,n){const o=t.loadAssetAsync(),r=i.loadAssetAsync(),l=n.loadAssetAsync(),c=new Array;o&&c.push(o),r&&c.push(r),l&&c.push(l);const h=await yd(c);yh&&console.log("Avatar loaded results:",h)}}A0([m(le)],Uo.prototype,"head",2),A0([m(le)],Uo.prototype,"leftHand",2),A0([m(le)],Uo.prototype,"rightHand",2);var XT=Object.defineProperty,QT=Object.getOwnPropertyDescriptor,wp=(s,t,i,n)=>{for(var o=n>1?void 0:n?QT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&XT(t,i,o),o};const Hn=O("debugwebxr"),No=new Array;class ln extends A{constructor(){super(...arguments),a(this,"createControllerModel",!0),a(this,"createHandModel",!0),a(this,"customLeftHand"),a(this,"customRightHand"),a(this,"_models",new Array)}supportsXR(t){return t==="immersive-vr"||t==="immersive-ar"}async onXRControllerAdded(t){var i;if(!(t.xr.isVR||t.xr.isPassThrough))return;const{controller:n}=t;if(Hn&&console.warn("Add Controller Model for",n.side,n.index),this.createControllerModel||this.createHandModel){if(n.hand){if(this.createHandModel){const o=await this.loadHandModel(this,n);if(!o||!n.connected||!n.isHand){o!=null&&o.handObject&&Fa(o.handObject,!1),(i=o?.handObject)==null||i.destroy();return}this._models.push({controller:n,model:o.handObject,handmesh:o.handmesh}),this._models.sort((r,l)=>r.controller.index-l.controller.index),this.scene.add(o.handObject),n.model=o.handObject}}else if(this.createControllerModel){const o=await n.getModelUrl();if(o){const r=await this.loadModel(n,o);if(!r||!n.connected||n.isHand)return;this._models.push({controller:n,model:r}),this._models.sort((l,c)=>l.controller.index-c.controller.index),this.scene.add(r),r.traverse(l=>{l.layers.set(2),l.matrixAutoUpdate=!1,l.updateMatrix()}),n.model=r}else n.targetRayMode!=="transient-pointer"&&console.warn("XRControllerModel: no model found for "+n.side)}}}onXRControllerRemoved(t){console.debug("XR Controller Removed",t.controller.side,t.controller.index);const i=this._models.findIndex(o=>o.controller===t.controller),n=this._models[i];n&&(this._models.splice(i,1),n.model&&(Fa(n.model,!1),n.model.destroy(),n.model=void 0))}onLeaveXR(t){for(const i of this._models)i&&(i.model&&(Fa(i.model,!1),i.model.destroy(),i.model=void 0),i.controller.model===i.model&&(i.controller.model=null));this._models.length=0}onBeforeRender(){if(Z.active&&(Hn&&(No[0]=Date.now()),this.updateRendering(Z.active),Hn)){const t=Date.now()-No[0];No.push(t),No.length>=30&&(No[0]=0,No.reduce((i,n)=>i+n,0)/No.length,No.length=0)}}updateRendering(t){var i,n,o,r,l;for(let c=0;c<this._models.length;c++){const h=this._models[c];if(!h)continue;const d=h.controller;if(!d.connected){Hn&&console.warn("XRControllerModel.onUpdateXR: controller is not connected anymore",d.side,d.hand);continue}if(h.model&&!h.handmesh)h.model.matrixAutoUpdate=!1,h.model.matrix.copy(d.gripMatrix),h.model.visible=d.isTracking,(i=t.rig)==null||i.gameObject.add(h.model);else if(d.inputSource.hand&&h.handmesh){const u=t.referenceSpace,p=this.context.renderer.xr.getHand(d.index);if(u&&t.frame.getJointPose){for(const g of d.inputSource.hand.values()){const y=p.joints[g.jointName];if(y){const f=d.getHandJointPose(g);if(f){const v=f.transform.position,b=f.transform.orientation;y.position.copy(v),y.quaternion.copy(b),y.matrixAutoUpdate=!1}y.visible=f!=null}}h.model&&(h.model.visible=d.isTracking,h.model.visible&&h.model.parent!==((n=t.rig)==null?void 0:n.gameObject)&&((o=t.rig)==null||o.gameObject.add(h.model))),(r=h.model)!=null&&r.visible&&((l=h.handmesh)==null||l.updateMesh(),h.model.matrixAutoUpdate=!1,h.model.matrix.identity(),h.model.applyMatrix4(Ma))}}}}async loadModel(t,i){var n;if(!t.connected)return console.warn("XRControllerModel.onXRControllerAdded: controller is not connected anymore",t.side),null;const o=await le.getOrCreate("",i).instantiate();return Fa(o),(n=Z.active)!=null&&n.isPassThrough&&o.traverseVisible(r=>{this.makeOccluder(r)}),o}async loadHandModel(t,i){const n=this.context,o=n.renderer.xr.getHand(i.index);o||(Hn?q.DrawLabel(i.rayWorldPosition,"No hand found for index "+i.index,.05,5):console.warn("No hand found for index "+i.index));const r=new mr;bu(r,n),await Yu(r,n,this.sourceId??"");const l=Qu(r);let c="";const h=i.side==="left"?this.customLeftHand:this.customRightHand;h?(c=h.url.split(".").slice(0,-1).join("."),r.setPath("")):(c=i.inputSource.handedness==="left"?"left":"right",r.setPath("https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles/generic-hand/"));const d=new j;Fa(d);const u=new zC(d,o,r.path,c,r,p=>{var g;const y=l.gltf;((g=y?.scene.children)==null?void 0:g.length)===0&&(y.scene.children[0]=p),ms().createBuiltinComponents(t.context,t.sourceId||c,l.gltf,null,l),p.traverse(f=>{var v;f.layers.set(2),(v=Z.active)!=null&&v.isPassThrough&&!h&&this.makeOccluder(f),f instanceof Q&&et.assignMeshLOD(f,0)}),i.connected||(Hn&&q.DrawLabel(i.rayWorldPosition,"Hand is loaded but not connected anymore",.05,5),p.removeFromParent())});if(Hn&&d.add(new bi(.5)),i.inputSource.hand){Hn&&console.log(i.inputSource.hand);for(const p of i.inputSource.hand.values())if(o.joints[p.jointName]===void 0){const g=new oo;g.matrixAutoUpdate=!1,g.visible=!0,o.joints[p.jointName]=g,o.add(g)}}else Hn&&q.DrawLabel(i.rayWorldPosition,"No inputSource.hand found for index "+i.index,.05,5);return{handObject:d,handmesh:u}}makeOccluder(t){if(t instanceof Q){let i=t.material;i instanceof Oe&&(i=t.material=i.clone(),i.depthWrite=!0,i.depthTest=!0,i.colorWrite=!1,t.receiveShadow=!1,t.renderOrder=-100)}}}a(ln,"factory",new FC),wp([m()],ln.prototype,"createControllerModel",2),wp([m()],ln.prototype,"createHandModel",2),wp([m(le)],ln.prototype,"customLeftHand",2),wp([m(le)],ln.prototype,"customRightHand",2);class xp extends A{}var YT=Object.defineProperty,KT=Object.getOwnPropertyDescriptor,Wo=(s,t,i,n)=>{for(var o=n>1?void 0:n?KT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&YT(t,i,o),o};const I0=O("debugwebxr");class Li extends A{constructor(){super(...arguments),a(this,"movementSpeed",1.5),a(this,"rotationStep",30),a(this,"useTeleport",!0),a(this,"usePinchToTeleport",!0),a(this,"useTeleportTarget",!1),a(this,"useTeleportFade",!1),a(this,"showRays",!0),a(this,"showHits",!0),a(this,"isXRMovementHandler",!0),a(this,"xrSessionMode","immersive-vr"),a(this,"_didApplyRotation",!1),a(this,"_didTeleport",!1),a(this,"_teleportBuffer",new Array),a(this,"_plane",null),a(this,"_lines",[]),a(this,"_hitDiscs",[]),a(this,"_hitDistances",[]),a(this,"_lastHitDistances",[]),a(this,"hitPointRaycastFilter",t=>t.type==="SkinnedMesh"?"continue in children":!0)}onUpdateXR(t){const i=t.xr.rig;if(!(i!=null&&i.gameObject)||t.xr.isPassThrough)return;const n=t.xr.leftController,o=t.xr.rightController;n&&this.onHandleMovement(n,i.gameObject),o&&(this.onHandleRotation(o,i.gameObject),this.useTeleport&&this.onHandleTeleport(o,i.gameObject))}onLeaveXR(t){for(const i of this._lines)i.removeFromParent();for(const i of this._hitDiscs)i?.removeFromParent()}onBeforeRender(){var t;(t=this.context.xr)!=null&&t.running&&(this.showRays&&this.renderRays(this.context.xr),this.showHits&&this.renderHits(this.context.xr))}onHandleMovement(t,i){const n=t.getStick("xr-standard-thumbstick");if(n.x!=0||n.y!=0){const o=$(n.x,0,n.y);o.multiplyScalar(this.context.time.deltaTimeUnscaled*this.movementSpeed);const r=Ke(i);o.multiplyScalar(r.x),o.applyQuaternion(t.xr.poseOrientation),o.y=0,o.applyQuaternion(i.worldQuaternion),i.position.add(o),i.updateWorldMatrix(!1,!1);for(const l of i.children)l.updateWorldMatrix(!1,!1)}}onHandleRotation(t,i){if(t._isMxInk)return;const n=t.getStick("xr-standard-thumbstick").x;if(this._didApplyRotation)Math.abs(n)<.3&&(this._didApplyRotation=!1);else if(Math.abs(n)>.5){this._didApplyRotation=!0;const o=n>0?1:-1,r=ee(this.context.mainCamera).clone();i.rotateY(o*W.toRadians(this.rotationStep));const l=ee(this.context.mainCamera).clone().sub(r);l.y=0,i.position.sub(l)}}onHandleTeleport(t,i){var n,o,r,l,c;let h=0;if(t.hand&&this.usePinchToTeleport&&t.isTeleportGesture){const d=t.getPointerId("primary");if(d!=null&&this.context.input.getIsPointerIdInUse(d))return;const u=t.getGesture("pinch");u&&(h=u.value)}else h=(n=t.getStick("xr-standard-thumbstick"))==null?void 0:n.y;if(this._didTeleport)h>=0&&h<.4?this._didTeleport=!1:h<0&&h>-.4&&(this._didTeleport=!1);else if(h>.8){this._didTeleport=!0;const d=this.context.physics.raycastFromRay(t.ray)[0];if(d&&d.object instanceof xa){const p=(o=d.normal)==null?void 0:o.dot($(0,1,0));if(p!==void 0&&p<.4)return}let u=d?.point;if(!u&&!this.useTeleportTarget){this._plane||(this._plane=new dr(new x(0,1,0),0));const p=i.worldPosition;this._plane.setFromNormalAndCoplanarPoint(new x(0,1,0),p);const g=t.ray;u=p.clone(),this._plane.intersectLine(new aC(g.origin,$(g.direction).multiplyScalar(1e4).add(g.origin)),u),u.distanceTo(p)>i.scale.x*10&&(u=null)}if(u){if(this.useTeleportTarget&&!P.getComponentInParent(d.object,xp))return;const p=u.clone();if(I0&&q.DrawSphere(u,.025,16711680,5),(r=this.context.mainCamera)==null?void 0:r.position){const g=(l=this.context.xr)==null?void 0:l.getUserOffsetInRig();g&&(g.y=0,p.sub(g),I0&&q.DrawWireSphere(g.add(p),.025,65280,5))}this._teleportBuffer.push(i.matrix.clone()),this._teleportBuffer.length>10&&this._teleportBuffer.shift(),this.useTeleportFade?(c=t.xr.fadeTransition())==null||c.then(()=>{i.worldPosition=p}):i.worldPosition=p}}else if(h<-.8&&(this._didTeleport=!0,this._teleportBuffer.length>0)){const d=this._teleportBuffer.pop();d&&d.decompose(i.position,i.quaternion,i.scale)}}renderRays(t){var i;for(let n=0;n<this._lines.length;n++){const o=this._lines[n];o&&(o.visible=!1)}for(let n=0;n<t.controllers.length;n++){const o=t.controllers[n];let r=this._lines[n];if(!o.connected||!o.isTracking||!o.ray||o.targetRayMode==="transient-pointer"||!o.hasSelectEvent){r&&(r.visible=!1);continue}r||(r=this.createRayLineObject(),r.scale.z=.5,this._lines[n]=r),o.updateRayWorldPosition(),o.updateRayWorldQuaternion();const l=o.rayWorldPosition,c=o.rayWorldQuaternion;r.position.copy(l),r.quaternion.copy(c);const h=t.rigScale,d=this.usePinchToTeleport&&o.isTeleportGesture,u=this._lastHitDistances[n],p=this._hitDistances[n]!=null,g=u??h;r.scale.set(h,h,g),r.visible=!0,r.layers.disableAll(),r.layers.enable(2);let y=r.material.opacity;d?y=1:this.showHits&&g<t.rigScale*.5?y=0:(i=o.getButton("primary"))!=null&&i.pressed?y=.5:y=p?.2:.1,r.material.opacity=W.lerp(r.material.opacity,y,this.context.time.deltaTimeUnscaled/.1),r.parent!==this.context.scene&&this.context.scene.add(r)}}renderHits(t){var i;for(const n of this._hitDiscs){if(!n)continue;const o=n.controller;if(!o||!o.connected||!o.isTracking){n.visible=!1;continue}}for(let n=0;n<t.controllers.length;n++){const o=t.controllers[n];if(!o.connected||!o.isTracking||!o.ray||!o.hasSelectEvent)continue;let r=this._hitDiscs[n],l=!0;const c=o.getPointerId("primary");c!=null&&this.context.input.getIsPointerIdInUse(c)&&(r&&(r.visible=!1),this._hitDistances[n]=null,this._lastHitDistances[n]=0,l=!1);const h=this.context.time.smoothedFps>=59?1:10;if((this.context.time.frame+o.index)%h!==0&&(l=!1),!l){const p=this._hitDiscs[n];p&&p.visible&&p.hit&&this.updateHitPointerPosition(o,p,p.hit.distance);continue}const d=this.context.physics.raycastFromRay(o.ray,{testObject:this.hitPointRaycastFilter,precise:!1});let u=d.find(p=>this.usePinchToTeleport&&o.isTeleportGesture?!0:this.isObjectWithInteractiveComponent(p.object));if(u||(u=d[0]),r&&(r.controller=o,r.hit=u),this._hitDistances[n]=u?.distance||null,u){this._lastHitDistances[n]=u.distance;const p=t.rigScale??1;I0&&(q.DrawWireSphere(u.point,.025*p,16711680),q.DrawLabel($(0,.2,0).add(u.point),u.object.name,.02,0)),r||(r=this.createHitPointObject(),this._hitDiscs[n]=r),r.hit=u,r.visible=u.distance>p*.05;let g=.01*(p+u.distance);const y=(i=o.getButton("primary"))==null?void 0:i.pressed;y&&(g*=1.1),r.scale.set(g,g,g),r.layers.set(2);let f=r.material.opacity;if(y?f=1:f=u.distance<.15*p?.2:.6,r.material.opacity=W.lerp(r.material.opacity,f,this.context.time.deltaTimeUnscaled/.1),r.visible){if(u.normal){this.updateHitPointerPosition(o,r,u.distance);const v=u.normal.applyQuaternion(Se(u.object));r.quaternion.setFromUnitVectors(ZT,v)}else this.updateHitPointerPosition(o,r,u.distance);r.parent!==this.context.scene&&this.context.scene.add(r)}}else this._hitDiscs[n]&&(this._hitDiscs[n].visible=!1)}}isObjectWithInteractiveComponent(t,i=0){return Pu(t)||t.isUI===!0?!0:t.isScene?!1:t.parent?this.isObjectWithInteractiveComponent(t.parent,i+1):!1}updateHitPointerPosition(t,i,n){const o=$(t.rayWorldPosition);o.add($(0,0,n-.01).applyQuaternion(t.rayWorldQuaternion)),i.position.lerp(o,this.context.time.deltaTimeUnscaled/.05)}createHitPointObject(){const t=new Q(new rd(.3,6,6),new Me({color:15658734,opacity:.7,transparent:!0,depthTest:!1,depthWrite:!1,side:_i}));return t.layers.disableAll(),t.layers.enable(2),t}createRayLineObject(){const t=new UC;t.layers.disableAll(),t.layers.enable(2);const i=new NC;t.geometry=i;const n=new Float32Array(9);n.set([0,0,.02,0,0,.4,0,0,1]),i.setPositions(n);const o=new Float32Array(9);o.set([1,1,1,.1,.1,.1,0,0,0]),i.setColors(o);const r=new WC({color:16777215,vertexColors:!0,worldUnits:!0,linewidth:.004,transparent:!0,depthWrite:!1,blending:nv,dashed:!1});return t.material=r,t}}Wo([m()],Li.prototype,"movementSpeed",2),Wo([m()],Li.prototype,"rotationStep",2),Wo([m()],Li.prototype,"useTeleport",2),Wo([m()],Li.prototype,"usePinchToTeleport",2),Wo([m()],Li.prototype,"useTeleportTarget",2),Wo([m()],Li.prototype,"useTeleportFade",2),Wo([m()],Li.prototype,"showRays",2),Wo([m()],Li.prototype,"showHits",2);const ZT=new x(0,1,0);var JT=Object.defineProperty,eE=Object.getOwnPropertyDescriptor,St=(s,t,i,n)=>{for(var o=n>1?void 0:n?eE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&JT(t,i,o),o};const vh=O("debugwebxr"),tE=O("debugusdz");var j0;const wl=(j0=class extends A{constructor(){super(...arguments),a(this,"createVRButton",!0),a(this,"createARButton",!0),a(this,"createSendToQuestButton",!0),a(this,"createQRCode",!0),a(this,"useDefaultControls",!0),a(this,"showControllerModels",!0),a(this,"showHandModels",!0),a(this,"usePlacementReticle",!0),a(this,"customARPlacementReticle"),a(this,"usePlacementAdjustment",!0),a(this,"arScale",1),a(this,"useXRAnchor",!1),a(this,"autoPlace",!0),a(this,"autoCenter",!1),a(this,"useQuicklookExport",!1),a(this,"useDepthSensing",!1),a(this,"useSpatialGrab",!0),a(this,"defaultAvatar"),a(this,"_playerSync"),a(this,"_createdComponentsInSession",[]),a(this,"_usdzExporter"),a(this,"_exitXRMenuButton"),a(this,"_previousXRState",0),a(this,"_spatialGrabRaycaster"),a(this,"onAvatarSpawned",s=>{vh&&console.log("WebXR.onAvatarSpawned",s),P.getComponentInChildren(s,Uo)??(e=P.addComponent(s,Uo))}),a(this,"_buttonFactory"),a(this,"_buttons",[])}awake(){Z.getXRSync(this.context)}onEnable(){var s,t;window.location.protocol!=="https:"&&_e('<a href="https://developer.mozilla.org/en-US/docs/Web/API/WebXR_Device_API" target="_blank">WebXR</a> only works on secure connections (https).'),this.useQuicklookExport&&(P.findObjectOfType(Ge)||(vh&&console.log("WebXR: Adding USDZExporter"),this._usdzExporter=P.addComponent(this.gameObject,Ge),this._usdzExporter.objectToExport=this.context.scene,this._usdzExporter.autoExportAnimations=!0,this._usdzExporter.autoExportAudioSources=!0)),this.handleCreatingHTML(),this.handleOfferSession(),this.defaultAvatar===!0&&(vh&&console.warn("WebXR: No default avatar set, using static default avatar"),this.defaultAvatar=new le("https://cdn.needle.tools/static/avatars/DefaultAvatar.glb")),this.defaultAvatar&&(this._playerSync=this.gameObject.getOrAddComponent(bl),this._playerSync.autoSync=!1),this._playerSync&&typeof this.defaultAvatar!="boolean"&&(this._playerSync.asset=this.defaultAvatar,(s=this._playerSync.onPlayerSpawned)==null||s.removeEventListener(this.onAvatarSpawned),(t=this._playerSync.onPlayerSpawned)==null||t.addEventListener(this.onAvatarSpawned))}onDisable(){var s;(s=this._usdzExporter)==null||s.destroy(),this.removeButtons()}async handleOfferSession(){return this.createVRButton&&await Z.isVRSupported()&&this.createVRButton?Z.offerSession("immersive-vr","default",this.context):this.createARButton&&await Z.isARSupported()&&this.createARButton?Z.offerSession("immersive-ar","default",this.context):!1}get session(){return Z.active??null}get sessionMode(){return Z.activeMode??null}async enterVR(s){return Z.start("immersive-vr",s,this.context)}async enterAR(s){return Z.start("immersive-ar",s,this.context)}exitXR(){Z.stop()}get isActiveWebXR(){return!wl.activeWebXRComponent||wl.activeWebXRComponent===this}onBeforeXR(s,t){var i;if(!this.isActiveWebXR){console.warn(`WebXR: another WebXR component is already active (${(i=wl.activeWebXRComponent)==null?void 0:i.name}). This is ignored: ${this.name}`);return}wl.activeWebXRComponent=this,s=="immersive-ar"&&this.useDepthSensing&&(t.optionalFeatures=t.optionalFeatures||[],t.optionalFeatures.push("depth-sensing"))}async onEnterXR(s){if(!this.isActiveWebXR)return;vh&&console.log("WebXR onEnterXR"),this._previousXRState=Kt.Global.Mask;const t=s.xr.isVR;if(Kt.Global.Set(t?Ks.VR:Ks.AR),s.xr.isAR){let i=P.findObjectOfType(Vn);if(!i)if(this.usePlacementReticle){const n=new j;for(const o of this.context.scene.children)n.add(o);this.context.scene.add(n),i=P.addComponent(n,Vn),this._createdComponentsInSession.push(i)}else(vh||F())&&console.warn("WebXR: No WebARSessionRoot found in scene and usePlacementReticle is disabled in WebXR component.");i&&(i.customReticle=this.customARPlacementReticle,i.arScale=this.arScale,i.arTouchTransform=this.usePlacementAdjustment,i.autoPlace=this.autoPlace,i.autoCenter=this.autoCenter,i.useXRAnchor=this.useXRAnchor)}this.useDefaultControls&&this.setDefaultMovementEnabled(!0),(this.showControllerModels||this.showHandModels)&&this.setDefaultControllerRenderingEnabled(!0),this.useSpatialGrab&&(this._spatialGrabRaycaster=P.findObjectOfType(Ga)??void 0,this._spatialGrabRaycaster||(this._spatialGrabRaycaster=this.gameObject.addComponent(Ga))),this.createLocalAvatar(s.xr),s.xr.isScreenBasedAR||(this._exitXRMenuButton=this.context.menu.appendChild({label:"Quit XR",onClick:()=>this.exitXR(),icon:"exit_to_app",priority:2e4}))}onUpdateXR(s){this.isActiveWebXR&&this._spatialGrabRaycaster&&(this._spatialGrabRaycaster.enabled=this.useSpatialGrab)}onLeaveXR(s){var t,i;if((t=this._exitXRMenuButton)==null||t.remove(),!!this.isActiveWebXR){Kt.Global.Set(this._previousXRState),(i=this._playerSync)==null||i.destroyInstance();for(const n of this._createdComponentsInSession)n.destroy();this._createdComponentsInSession.length=0,this.handleOfferSession(),Ql(1).then(()=>wl.activeWebXRComponent=null)}}setDefaultMovementEnabled(s){let t=this.gameObject.getComponent(Li);return!t&&s&&(t=this.gameObject.addComponent(Li),this._createdComponentsInSession.push(t)),t&&(t.enabled=s),t}setDefaultControllerRenderingEnabled(s){let t=this.gameObject.getComponent(ln);return!t&&s&&(t=this.gameObject.addComponent(ln),this._createdComponentsInSession.push(t),t.createControllerModel=this.showControllerModels,t.createHandModel==this.showHandModels),t&&(t.enabled=s),t}async createLocalAvatar(s){this._playerSync&&s.running&&typeof this.defaultAvatar!="boolean"&&(this._playerSync.asset=this.defaultAvatar,await this._playerSync.getInstance())}getButtonsContainer(){return this.getButtonsFactory()}getButtonsFactory(){return this._buttonFactory||(this._buttonFactory=Yr.getOrCreate()),this._buttonFactory}handleCreatingHTML(){if(this.createARButton||this.createVRButton||this.useQuicklookExport){if((Y.isiOS()&&Y.isSafari()||tE)&&this.useQuicklookExport){const s=P.findObjectOfType(Ge);if(!s||s&&s.allowCreateQuicklookButton){const t=this.getButtonsFactory().createQuicklookButton();this.addButton(t,50)}}if(this.createARButton){const s=this.getButtonsFactory().createARButton();this.addButton(s,50)}if(this.createVRButton){const s=this.getButtonsFactory().createVRButton();this.addButton(s,50)}}if(this.createSendToQuestButton&&!Y.isQuest()&&Z.isVRSupported().then(s=>{if(!s){const t=this.getButtonsFactory().createSendToQuestButton();this.addButton(t,50)}}),this.createQRCode){const s=Gd(an);if(s&&s.createQRCodeButton===!1)F()&&console.warn("WebXR: QRCode button is disabled in the Needle Menu component");else if(!Y.isMobileDevice()){const t=Mn.getOrCreate().createQRCode();this.addButton(t,50)}}}addButton(s,t){this._buttons.push(s),s.setAttribute("priority",t.toString()),this.context.menu.appendChild(s)}removeButtons(){for(const s of this._buttons)s.remove();this._buttons.length=0}},a(j0,"activeWebXRComponent",null),j0);let Je=wl;St([m()],Je.prototype,"createVRButton",2),St([m()],Je.prototype,"createARButton",2),St([m()],Je.prototype,"createSendToQuestButton",2),St([m()],Je.prototype,"createQRCode",2),St([m()],Je.prototype,"useDefaultControls",2),St([m()],Je.prototype,"showControllerModels",2),St([m()],Je.prototype,"showHandModels",2),St([m()],Je.prototype,"usePlacementReticle",2),St([m(le)],Je.prototype,"customARPlacementReticle",2),St([m()],Je.prototype,"usePlacementAdjustment",2),St([m()],Je.prototype,"arScale",2),St([m()],Je.prototype,"useXRAnchor",2),St([m()],Je.prototype,"autoPlace",2),St([m()],Je.prototype,"autoCenter",2),St([m()],Je.prototype,"useQuicklookExport",2),St([m()],Je.prototype,"useDepthSensing",2),St([m()],Je.prototype,"useSpatialGrab",2),St([m(le)],Je.prototype,"defaultAvatar",2);const bh=O("debugusdz");function iE(s,t){var i;const n=[],o=P.getComponentsInChildren(s,kt),r=P.getComponentsInChildren(s,Ut),l=new Array,c=new Array;if(t.injectImplicitBehaviours)for(const h of o){if(!h||!h.runtimeAnimatorController||!h.enabled)continue;const d=h.runtimeAnimatorController.activeState;if(!d||!d.motion||!d.motion.clip||((i=d.motion.clip.tracks)==null?void 0:i.length)<1||l.includes(h))continue;const u=new Gr;u.animator=h,u.stateName=d.name,u.trigger="start",u.name="PlayAnimationOnClick_implicitAtStart_"+u.stateName;const p=new j;P.addComponent(p,u),c.push(p),l.push(h),s.add(p)}else for(const h of o){if(!h||!h.runtimeAnimatorController||!h.enabled)continue;bh&&console.log(h);const d=[];for(const u of h.runtimeAnimatorController.enumerateActions()){bh&&console.log(u);const p=u.getClip();d.includes(p)||d.push(p)}n.push({root:h.gameObject,clips:d})}if(t.injectImplicitBehaviours)for(const h of r){if(!h||!h.clip||!h.enabled||!h.playAutomatically||l.includes(h))continue;const d=new Gr;d.animation=h,d.stateName=h.clip.name,d.trigger="start",d.name="PlayAnimationOnClick_implicitAtStart_"+d.stateName;const u=new j;P.addComponent(u,d),c.push(u),l.push(h),s.add(u)}else for(const h of r){bh&&console.log(h);const d=[];for(const u of h.animations)d.includes(u)||d.push(u);n.push({root:h.gameObject,clips:d})}bh&&n?.length>0&&console.log("USDZ Animation Clips without behaviours",n);for(const h of n)for(const d of h.clips)t.registerAnimation(h.root,d);return c}function sE(s,t){const i=P.getComponentsInChildren(s,We),n=P.getComponentsInChildren(s,Io),o=new Array,r=new Array;bh&&console.log({audioSources:i,playAudioOnClicks:n});for(const l of n){if(!l.target)continue;const c=i.indexOf(l.target);c>-1&&i.splice(c,1)}for(const l of i){if(!l||!l.clip||l.volume<=0||o.includes(l))continue;const c=new Io;c.target=l,c.name="PlayAudioOnClick_implicitAtStart_",c.trigger="start";const h=new j;P.addComponent(h,c),console.log("implicit PlayAudioOnStart",h,c),r.push(h),o.push(l),s.add(h)}return r}function nE(s){return new _t("DisableAtStart",wt.sceneStartTrigger(),ue.fadeAction(s,0,!1))}function e1(s,t){const i=s.domElement.shadowRoot.querySelector("link[rel='ar']");if(i)return i;const n=document.createElement("div");n.classList.add("menu"),n.classList.add("quicklook-menu"),n.style.display="none",n.style.visibility="hidden";const o=document.createElement("button");o.id="open-in-ar",t?(o.innerText="View in AR",o.title="View this scene in AR. The scene will be exported to USDZ and opened with Apple's QuickLook."):(o.innerText="View in AR",o.title="Download this scene for AR. Open the downloaded USDZ file to view it in AR using Apple's QuickLook."),n.appendChild(o);const r=document.createElement("a");r.id="needle-usdz-link",r.style.display="none",r.rel="ar",r.href="",r.target="_blank",n.appendChild(r);const l=document.createElement("img");return l.id="button",r.appendChild(l),s.domElement.shadowRoot.appendChild(n),r}var oE=Object.defineProperty,rE=Object.getOwnPropertyDescriptor,At=(s,t,i,n)=>{for(var o=n>1?void 0:n?rE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&oE(t,i,o),o};const Di=O("debugusdz"),aE=O("debugusdzpruning");class Vo{constructor(){a(this,"callToAction"),a(this,"checkoutTitle"),a(this,"checkoutSubtitle"),a(this,"callToActionURL")}}At([m()],Vo.prototype,"callToAction",2),At([m()],Vo.prototype,"checkoutTitle",2),At([m()],Vo.prototype,"checkoutSubtitle",2),At([m()],Vo.prototype,"callToActionURL",2);var Sp;const L0=(Sp=class extends A{constructor(){super(...arguments),a(this,"objectToExport"),a(this,"autoExportAnimations",!0),a(this,"autoExportAudioSources",!0),a(this,"exportFileName"),a(this,"customUsdzFile"),a(this,"customBranding"),a(this,"anchoringType","plane"),a(this,"maxTextureSize",2048),a(this,"planeAnchoringAlignment","horizontal"),a(this,"interactive",!0),a(this,"physics",!0),a(this,"allowCreateQuicklookButton",!0),a(this,"quickLookCompatible",!0),a(this,"extensions",[]),a(this,"link"),a(this,"button"),a(this,"onClickedOpenInARElement",s=>{s.preventDefault(),this.exportAndOpen()}),a(this,"_currentExportTasks",new Map),a(this,"_previousTimeScale",1),a(this,"lastCallback"),a(this,"_rootSessionRootWasAppliedTo",null),a(this,"_rootPositionBeforeExport",new x),a(this,"_rootRotationBeforeExport",new V),a(this,"_rootScaleBeforeExport",new x)}start(){var s,t,i;Di&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",n=>{switch(n.key){case"t":this.exportAndOpen();break}})),this.objectToExport||(this.objectToExport=this.gameObject),!((t=(s=this.objectToExport)==null?void 0:s.children)!=null&&t.length)&&!((i=this.objectToExport)!=null&&i.isMesh)&&(this.objectToExport=this.context.scene)}onEnable(){var s;const t=Y.supportsQuickLookAR(),i=Y.isiOS()||Y.isiPad();!this.button&&(Di||t||i)&&(this.allowCreateQuicklookButton&&(this.button=this.createQuicklookButton()),this.lastCallback=this.quicklookCallback.bind(this),this.link=e1(this.context,t),this.link.addEventListener("message",this.lastCallback)),Di&&Le("USDZ Exporter enabled: "+this.name),(s=document.getElementById("open-in-ar"))==null||s.addEventListener("click",this.onClickedOpenInARElement),dc.registerExporter(this)}onDisable(){var s,t,i;(s=this.button)==null||s.remove(),(t=this.link)==null||t.removeEventListener("message",this.lastCallback),Di&&Le("USDZ Exporter disabled: "+this.name),(i=document.getElementById("open-in-ar"))==null||i.removeEventListener("click",this.onClickedOpenInARElement),dc.unregisterExporter(this)}async exportAsync(){return this.exportAndOpen()}async exportAndOpen(){var s;let t=this.exportFileName??((s=this.objectToExport)==null?void 0:s.name)??this.name;if(t+="-"+fx(),vo()||(t!==""&&(t+="-"),t+="MadeWithNeedle"),this.link||(this.link=e1(this.context,Y.supportsQuickLookAR())),this.customUsdzFile)return Di&&console.log("Exporting custom usdz",this.customUsdzFile),this.openInQuickLook(this.customUsdzFile,t),null;if(!this.objectToExport)return console.warn("No object to export",this),null;const i=await this.export(this.objectToExport);return i?(Di&&console.log("USDZ generation done. Downloading as "+t),this.openInQuickLook(i,t),i):(console.error("USDZ generation failed. Please report a bug",this),null)}async export(s){if(!s)return console.warn("No object to export"),null;const t=this._currentExportTasks.get(s);if(t)return t;const i=this.internalExport(s);return i instanceof Promise?(this._currentExportTasks.set(s,i),i.then(n=>(this._currentExportTasks.delete(s),n)).catch(n=>(this._currentExportTasks.delete(s),console.error("Error during USDZ export \u2013 please report a bug!",n),null))):i}async internalExport(s){ce.start("export-usdz",{onProgress:C=>{this.dispatchEvent(new CustomEvent("export-progress",{detail:{progress:C}}))}}),ce.report("export-usdz",{message:"Starting export",totalSteps:40,currentStep:0}),ce.report("export-usdz",{message:"Load progressive textures",autoStep:5}),ce.start("export-usdz-textures","export-usdz");const t=P.getComponentsInChildren(s,pi);for(const C of t)C&&C.enabled&&C.updateSprite(!0);const i=P.getComponentsInChildren(s,Ze),n=new Array;let o=0;for(const C of i){for(const R of C.sharedMeshes)if(R){const M=et.assignMeshLOD(R,0);M instanceof Promise&&n.push(new Promise((E,B)=>{M.then(()=>{o++,ce.report("export-usdz-textures",{message:"Loaded progressive mesh",currentStep:o,totalSteps:n.length}),E()}).catch(L=>B(L))}))}for(const R of C.sharedMaterials)if(R){const M=et.assignTextureLOD(R,0);M instanceof Promise&&n.push(new Promise((E,B)=>{M.then(()=>{o++,ce.report("export-usdz-textures",{message:"Loaded progressive texture",currentStep:o,totalSteps:n.length}),E()}).catch(L=>B(L))}))}}Di&&Le("Progressive Loading: "+n.length),await Promise.all(n),Di&&Le("Progressive Loading: done"),ce.end("export-usdz-textures");const r=Kt.Global.Mask;Kt.Global.Set(Ks.AR);const l=new wx,c=new oh(this.quickLookCompatible);let h;const d=[];this.interactive&&(d.push(new hp),d.push(new lr),globalThis.true&&P.getComponentsInChildren(s,ye).length>0&&(this.physics?(h=new pp,d.push(h)):F()&&console.warn("USDZExporter: Physics export is disabled, but there are active Rigidbody components in the scene. They will not be exported.")),d.push(new ph),d.push(new yp));const u=[c,...d,...this.extensions],p={self:this,exporter:l,extensions:u,object:s};ce.report("export-usdz","Invoking before-export"),this.dispatchEvent(new CustomEvent("before-export",{detail:p})),this.applyWebARSessionRoot(),this._previousTimeScale=this.context.time.timeScale,this.context.time.timeScale=0,ce.report("export-usdz","auto export animations and audio sources");const g=new Array;this.autoExportAnimations&&g.push(...iE(s,c)),this.extensions.find(C=>C.extensionName==="Audio")&&this.autoExportAudioSources&&g.push(...sE(s)),l.debug=Di,l.pruneUnusedNodes=!aE;const y=Vr.instance.objs.map(C=>C.batchedMesh);l.keepObject=C=>{let R=!0;const M=P.getComponent(C,Ze);return M&&!M.enabled&&(R=!1),R&&y.includes(C)&&(R=!1),R&&P.getComponentInParent(C,Os)&&(R=!1),R&&P.getComponentInParent(C,Vs)&&(R=!1),Di&&!R&&console.log("USDZExporter: Discarding object",C),R},l.beforeWritingDocument=()=>{if(F()&&c&&h){const C=c.animatedRoots;for(const R of C){const M=P.getComponentsInChildren(R,ye).filter(B=>B.enabled),E=P.getComponents(R,hi).filter(B=>B.enabled&&!B.isTrigger);(M.length>0||E.length>0)&&console.error("An animated object has physics components in its child hierarchy. This can lead to undefined behaviour due to a bug in Apple's QuickLook (FB15925487). Remove the physics components from child objects or verify that you get the expected results.",R)}}};const f=new Array;this.objectToExport&&this.quickLookCompatible&&this.interactive&&this.objectToExport.traverse(C=>{C.visible||f.push(C)});const v=this.extensions.find(C=>C.extensionName==="Behaviour");this.interactive&&v&&f.length>0&&v.addBehavior(nE(f));let b=!0;this.quickLookCompatible&&!this.interactive&&(b=!1),this.anchoringType!=="plane"&&this.anchoringType!=="none"&&this.anchoringType!=="image"&&this.anchoringType!=="face"&&(this.anchoringType="plane"),this.planeAnchoringAlignment!=="horizontal"&&this.planeAnchoringAlignment!=="vertical"&&this.planeAnchoringAlignment!=="any"&&(this.planeAnchoringAlignment="horizontal"),ce.report("export-usdz","Invoking exporter.parse");const w=await l.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:u,quickLookCompatible:this.quickLookCompatible,maxTextureSize:this.maxTextureSize,exportInvisible:b}),_=new Blob([w],{type:"model/vnd.usdz+zip"});this.revertWebARSessionRoot(),this.context.time.timeScale=this._previousTimeScale,ce.report("export-usdz","Invoking after-export"),this.dispatchEvent(new CustomEvent("after-export",{detail:p}));for(const C of g)P.destroy(C);return Kt.Global.Set(r),ce.end("export-usdz"),_}openInQuickLook(s,t){const i=s instanceof Blob?URL.createObjectURL(s):s,n=this.buildQuicklookOverlay();Di&&console.log("QuickLook Overlay",n);const o=n.callToAction?encodeURIComponent(n.callToAction):"",r=n.checkoutTitle?encodeURIComponent(n.checkoutTitle):"",l=n.checkoutSubtitle?encodeURIComponent(n.checkoutSubtitle):"";this.link.href=i+`#callToAction=${o}&checkoutTitle=${r}&checkoutSubtitle=${l}&callToActionURL=${n.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click()}download(s,t){L0.save(s,t)}static save(s,t){const i=document.createElement("a");i.style.display="none",document.body.appendChild(i),typeof s=="string"?i.href=s:i.href=URL.createObjectURL(s),i.download=t,i.click(),i.remove()}quicklookCallback(s){if(s?.data=="_apple_ar_quicklook_button_tapped"){Di&&_e("Quicklook closed via call to action button");var t=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(t),!t.defaultPrevented){const i=new URLSearchParams(this.link.href);if(i){const n=i.get("callToActionURL");Di&&Le("Quicklook url: "+n),n&&(vo()?globalThis.open(n,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",n))}}}}buildQuicklookOverlay(){var s,t,i,n,o,r;const l={};return this.customBranding&&Object.assign(l,this.customBranding),vo()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),l.callToAction="Close",l.checkoutTitle="\u{1F335} Made with Needle",l.checkoutSubtitle="_"),(((s=l.callToAction)==null?void 0:s.length)||((t=l.checkoutTitle)==null?void 0:t.length)||((i=l.checkoutSubtitle)==null?void 0:i.length))&&((n=l.callToAction)!=null&&n.length||(l.callToAction="\0"),(o=l.checkoutTitle)!=null&&o.length||(l.checkoutTitle="\0"),(r=l.checkoutSubtitle)!=null&&r.length||(l.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:l})),l}getARScaleAndTarget(){if(!this.objectToExport)return{scale:1,_invertForward:!1,target:this.gameObject,sessionRoot:null};const s=P.findObjectOfType(Je);let t=P.getComponentInParent(this.objectToExport,Vn);t||(t=P.getComponentInChildren(this.objectToExport,Vn));let i=1,n=!1;const o=this.objectToExport;return s?i=s.arScale:t&&(i=t.arScale,n=t.invertForward),{scale:1/i,_invertForward:n,target:o,sessionRoot:t?.gameObject??null}}applyWebARSessionRoot(){if(!this.objectToExport)return;const{scale:s,_invertForward:t,target:i,sessionRoot:n}=this.getARScaleAndTarget(),o=n?.matrixWorld.clone().invert();this._rootSessionRootWasAppliedTo=i,this._rootPositionBeforeExport.copy(i.position),this._rootRotationBeforeExport.copy(i.quaternion),this._rootScaleBeforeExport.copy(i.scale),i.scale.multiplyScalar(s),t&&i.quaternion.multiply(L0.invertForwardQuaternion),i.updateMatrix(),i.updateMatrixWorld(!0),n&&o&&i.matrix.premultiply(o)}revertWebARSessionRoot(){if(!this.objectToExport||!this._rootSessionRootWasAppliedTo)return;const s=this._rootSessionRootWasAppliedTo;s.position.copy(this._rootPositionBeforeExport),s.quaternion.copy(this._rootRotationBeforeExport),s.scale.copy(this._rootScaleBeforeExport),s.updateMatrix(),s.updateMatrixWorld(!0),this._rootSessionRootWasAppliedTo=null}createQuicklookButton(){const s=Yr.getOrCreate().createQuicklookButton();return s.parentNode||this.context.menu.appendChild(s),s}},a(Sp,"invertForwardMatrix",new ne().makeRotationY(Math.PI)),a(Sp,"invertForwardQuaternion",new V().setFromEuler(new Ft(0,Math.PI,0))),Sp);let Ge=L0;At([m(j)],Ge.prototype,"objectToExport",2),At([m()],Ge.prototype,"autoExportAnimations",2),At([m()],Ge.prototype,"autoExportAudioSources",2),At([m()],Ge.prototype,"exportFileName",2),At([m(URL)],Ge.prototype,"customUsdzFile",2),At([m(Vo)],Ge.prototype,"customBranding",2),At([m()],Ge.prototype,"anchoringType",2),At([m()],Ge.prototype,"maxTextureSize",2),At([m()],Ge.prototype,"planeAnchoringAlignment",2),At([m()],Ge.prototype,"interactive",2),At([m()],Ge.prototype,"physics",2),At([m()],Ge.prototype,"allowCreateQuicklookButton",2),At([m()],Ge.prototype,"quickLookCompatible",2);var lE=Object.defineProperty,cE=Object.getOwnPropertyDescriptor,D0=(s,t,i,n)=>{for(var o=n>1?void 0:n?cE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&lE(t,i,o),o};class xl extends A{constructor(){super(...arguments),a(this,"_fog")}get fog(){return this._fog||(this._fog=new Gy(0,0,50)),this._fog}get mode(){return 1}set near(t){this.fog.near=t}get near(){return this.fog.near}set far(t){this.fog.far=t}get far(){return this.fog.far}set color(t){this.fog.color.copy(t)}get color(){return this.fog.color}onEnable(){this.scene.fog=this.fog}onDisable(){this.scene.fog===this._fog&&(this.scene.fog=null)}}D0([m()],xl.prototype,"near",1),D0([m()],xl.prototype,"far",1),D0([m(ae)],xl.prototype,"color",1);var hE=Object.defineProperty,dE=Object.getOwnPropertyDescriptor,B0=(s,t,i,n)=>{for(var o=n>1?void 0:n?dE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&hE(t,i,o),o};class Kr extends A{constructor(){super(...arguments),a(this,"objectBounds",!1),a(this,"color"),a(this,"isGizmo",!0),a(this,"_gizmoObject",null),a(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!bc||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new lC(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=wg(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),Ce.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){for(var t;this._boxHelper;)(t=this._boxHelper)==null||t.update(),yield}}B0([m()],Kr.prototype,"objectBounds",2),B0([m(ae)],Kr.prototype,"color",2),B0([m()],Kr.prototype,"isGizmo",2);var uE=Object.defineProperty,pE=Object.getOwnPropertyDescriptor,F0=(s,t,i,n)=>{for(var o=n>1?void 0:n?pE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&uE(t,i,o),o};class Sl extends A{constructor(){super(...arguments),a(this,"isGizmo",!1),a(this,"color0"),a(this,"color1"),a(this,"gridHelper"),a(this,"size"),a(this,"divisions"),a(this,"offset")}onEnable(){if(this.isGizmo&&!bc)return;const t=this.size,i=this.divisions;this.gridHelper||(this.gridHelper=new lm(t,i,this.color0??new ae(.4,.4,.4),this.color1??new ae(.6,.6,.6)),this.offset!==void 0&&(this.gridHelper.position.y+=this.offset)),this.gridHelper&&this.gameObject.add(this.gridHelper)}onDisable(){this.gridHelper&&(this.gameObject.remove(this.gridHelper),this.gridHelper=null)}}F0([m()],Sl.prototype,"isGizmo",2),F0([m(ae)],Sl.prototype,"color0",2),F0([m(ae)],Sl.prototype,"color1",2);var mE=Object.defineProperty,gE=Object.getOwnPropertyDescriptor,z0=(s,t,i,n)=>{for(var o=n>1?void 0:n?gE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&mE(t,i,o),o};class U0 extends A{constructor(){super(...arguments),a(this,"connectedBody"),a(this,"_rigidBody",null)}get rigidBody(){return this._rigidBody}onEnable(){this._rigidBody||(this._rigidBody=this.gameObject.getComponent(ye)),this.rigidBody&&this.connectedBody&&this.startCoroutine(this.create())}*create(){yield,this.rigidBody&&this.connectedBody&&this.activeAndEnabled&&this.createJoint(this.rigidBody,this.connectedBody)}}z0([m(ye)],U0.prototype,"connectedBody",2);class N0 extends U0{createJoint(t,i){var n;(n=this.context.physics.engine)==null||n.addFixedJoint(t,i)}}class _h extends U0{constructor(){super(...arguments),a(this,"anchor"),a(this,"axis")}createJoint(t,i){var n;this.axis&&this.anchor&&((n=this.context.physics.engine)==null||n.addHingeJoint(t,i,this.anchor,this.axis))}}z0([m(x)],_h.prototype,"anchor",2),z0([m(x)],_h.prototype,"axis",2);var fE=Object.defineProperty,yE=Object.getOwnPropertyDescriptor,cn=(s,t,i,n)=>{for(var o=n>1?void 0:n?yE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&fE(t,i,o),o};function W0(s){return s*Math.PI/180}const t1=300,Ho=O("debuglights");class mi extends A{constructor(){super(...arguments),a(this,"type",0),a(this,"range",1),a(this,"spotAngle",1),a(this,"innerSpotAngle",1),a(this,"_color",new ae(16777215)),a(this,"_shadowNearPlane",.1),a(this,"_shadowBias",0),a(this,"_shadowNormalBias",0),a(this,"_overrideShadowBiasSettings",!1),a(this,"_shadows",1),a(this,"lightmapBakeType",4),a(this,"_intensity",-1),a(this,"_shadowDistance"),a(this,"shadowWidth"),a(this,"shadowHeight"),a(this,"_shadowResolution"),a(this,"light"),a(this,"_webXRStartedListener"),a(this,"_webXREndedListener"),a(this,"_webARRoot")}set color(t){this._color=t,this.light!==void 0&&(this.light.color=t)}get color(){return this.light?this.light.color:this._color}set shadowNearPlane(t){var i,n;if(t!==this._shadowNearPlane&&(this._shadowNearPlane=t,((n=(i=this.light)==null?void 0:i.shadow)==null?void 0:n.camera)!==void 0)){const o=this.light.shadow.camera;o.near=t}}get shadowNearPlane(){return this._shadowNearPlane}set shadowBias(t){var i,n;t!==this._shadowBias&&(this._shadowBias=t,((n=(i=this.light)==null?void 0:i.shadow)==null?void 0:n.bias)!==void 0&&(this.light.shadow.bias=t,this.light.shadow.needsUpdate=!0))}get shadowBias(){return this._shadowBias}set shadowNormalBias(t){var i,n;t!==this._shadowNormalBias&&(this._shadowNormalBias=t,((n=(i=this.light)==null?void 0:i.shadow)==null?void 0:n.normalBias)!==void 0&&(this.light.shadow.normalBias=t,this.light.shadow.needsUpdate=!0))}get shadowNormalBias(){return this._shadowNormalBias}set shadows(t){this._shadows=t,this.light&&(this.light.castShadow=t!==0,this.updateShadowSoftHard())}get shadows(){return this._shadows}set intensity(t){var i;if(this._intensity=t,this.light){let n=1;if(this.context.isInXR&&this._webARRoot){const o=(i=this._webARRoot)==null?void 0:i.arScale;typeof o=="number"&&o>0&&(n/=o)}this.light.intensity=t*n}Ho&&console.log("Set light intensity to "+this._intensity,t,this)}get intensity(){return this._intensity}get shadowDistance(){const t=this.light;return t!=null&&t.shadow?t.shadow.camera.far:-1}set shadowDistance(t){this._shadowDistance=t;const i=this.light;if(i!=null&&i.shadow){const n=i.shadow.camera;n.far=t,n.updateProjectionMatrix()}}get shadowResolution(){const t=this.light;return t!=null&&t.shadow?t.shadow.mapSize.x:-1}set shadowResolution(t){if(t===this._shadowResolution)return;this._shadowResolution=t;const i=this.light;i!=null&&i.shadow&&(i.shadow.mapSize.set(t,t),i.shadow.needsUpdate=!0)}get isBaked(){return this.lightmapBakeType===2}get selfIsLight(){if(this.gameObject.isLight===!0)return!0;switch(this.gameObject.type){case"SpotLight":case"PointLight":case"DirectionalLight":return!0}return!1}getWorldPosition(t){return this.light?this.type===1?this.light.getWorldPosition(t).multiplyScalar(1):this.light.getWorldPosition(t):t}awake(){this.color=new ae(this.color??16777215),Ho&&console.log(this.name,this)}onEnable(){Ho&&console.log("ENABLE LIGHT",this.name),this.createLight(),!this.isBaked&&(this.light&&(this.light.visible=!0,this.light.intensity=this._intensity,Ho&&console.log("Set light intensity to "+this.light.intensity,this.name),this.selfIsLight||this.light.parent!==this.gameObject&&this.gameObject.add(this.light)),this.type===1&&this.startCoroutine(this.updateMainLightRoutine(),Ce.LateUpdate))}onDisable(){Ho&&console.log("DISABLE LIGHT",this.name),this.light&&(this.selfIsLight?this.light.intensity=0:this.light.visible=!1)}onEnterXR(t){this._webARRoot=P.getComponentInParent(this.gameObject,Vn)??void 0}onLeaveXR(t){}createLight(){const t=this.selfIsLight;if(t&&!this.light)switch(this.light=this.gameObject,this.light.name=this.name,this._intensity=this.light.intensity,this.type){case 1:this.setDirectionalLight(this.light);break}else if(!this.light)switch(this.type){case 1:const i=new cm(this.color,this.intensity*Math.PI);if(i.position.set(0,0,-t1*.5).applyQuaternion(this.gameObject.quaternion),this.gameObject.add(i.target),fr(i.target,0,0,0),this.light=i,this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),Ho){const l=new hC(this.light,.2,this.color);this.context.scene.add(l)}break;case 0:const n=new cC(this.color,this.intensity*Math.PI,this.range,W0(this.spotAngle/2),1-W0(this.innerSpotAngle/2)/W0(this.spotAngle/2),2);n.position.set(0,0,0),n.rotation.set(0,0,0),this.light=n;const o=n.target;n.add(o),o.position.set(0,0,this.range),o.rotation.set(0,0,0);break;case 2:const r=new Xy(this.color,this.intensity*Math.PI,this.range);this.light=r;break}if(this.light){if(this._intensity>=0?this.light.intensity=this._intensity:this._intensity=this.light.intensity,this.shadows!==0?this.light.castShadow=!0:this.light.castShadow=!1,this.light.shadow){this._shadowResolution!==void 0&&this._shadowResolution>4?(this.light.shadow.mapSize.width=this._shadowResolution,this.light.shadow.mapSize.height=this._shadowResolution):(this.light.shadow.mapSize.width=2048,this.light.shadow.mapSize.height=2048),Ho&&console.log("Override shadow bias?",this._overrideShadowBiasSettings,this.shadowBias,this.shadowNormalBias),this.light.shadow.bias=this.shadowBias,this.light.shadow.normalBias=this.shadowNormalBias,this.updateShadowSoftHard();const i=this.light.shadow.camera;if(i.near=this.shadowNearPlane,this._shadowDistance!==void 0&&typeof this._shadowDistance=="number"?i.far=this._shadowDistance:i.far=t1*Math.abs(this.gameObject.scale.z),this.gameObject.scale.set(1,1,1),this.shadowWidth!==void 0)i.left=-this.shadowWidth/2,i.right=this.shadowWidth/2;else{const n=this.gameObject.scale.x;i.left*=n,i.right*=n}if(this.shadowHeight!==void 0)i.top=this.shadowHeight/2,i.bottom=-this.shadowHeight/2;else{const n=this.gameObject.scale.y;i.top*=n,i.bottom*=n}this.light.shadow.needsUpdate=!0,Ho&&this.context.scene.add(new dC(i))}this.isBaked?this.light.removeFromParent():t||this.gameObject.add(this.light)}}*updateMainLightRoutine(){for(;;){this.type===1&&((!this.context.mainLight||this.intensity>this.context.mainLight.intensity)&&(this.context.mainLight=this),yield);break}}updateShadowSoftHard(){this.light&&this.light.shadow&&(this.shadows===2||(this.light.shadow.radius=1,this.light.shadow.blurSamples=1))}setDirectionalLight(t){t.add(t.target),t.target.position.set(0,0,-1)}}a(mi,"allowChangingRendererShadowMapType",!0),cn([m()],mi.prototype,"type",2),cn([m(ae)],mi.prototype,"color",1),cn([m()],mi.prototype,"shadowNearPlane",1),cn([m()],mi.prototype,"shadowBias",1),cn([m()],mi.prototype,"shadowNormalBias",1),cn([m()],mi.prototype,"shadows",1),cn([m()],mi.prototype,"lightmapBakeType",2),cn([m()],mi.prototype,"intensity",1),cn([m()],mi.prototype,"shadowDistance",1),cn([m()],mi.prototype,"shadowResolution",1),new x(0,0,0);var vE=Object.defineProperty,bE=Object.getOwnPropertyDescriptor,wh=(s,t,i,n)=>{for(var o=n>1?void 0:n?bE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&vE(t,i,o),o};const V0=O("debuglods"),_E=O("nolods");class Zr{constructor(){a(this,"screenRelativeTransitionHeight"),a(this,"distance"),a(this,"renderers")}}wh([m()],Zr.prototype,"screenRelativeTransitionHeight",2),wh([m()],Zr.prototype,"distance",2),wh([m(Ze)],Zr.prototype,"renderers",2);class wE{constructor(t){a(this,"model"),this.model=t}get renderers(){return this.model.renderers}}class xh extends A{constructor(){super(...arguments),a(this,"fadeMode",0),a(this,"localReferencePoint"),a(this,"lodCount",0),a(this,"size",0),a(this,"animateCrossFading",!1),a(this,"lodModels"),a(this,"_lods",[]),a(this,"_settings",[]),a(this,"_lodsHandler"),a(this,"_distanceFactor",1)}start(){if(V0&&console.log("LODGROUP",this.name,this.lodModels,this),!_E&&!this._lodsHandler&&this.gameObject&&this.lodModels&&Array.isArray(this.lodModels)){const t=[];for(const n of this.lodModels){const o=new wE(n);this._lods.push(o);for(const r of o.renderers)t.includes(r)||t.push(r)}this._lodsHandler=new Array;for(let n=0;n<t.length;n++){const o=new uC;this._lodsHandler.push(o),this.gameObject.add(o)}const i=new j;i.name="Cull "+this.name;for(let n=0;n<t.length;n++){const o=t[n],r=this._lodsHandler[n],l=o.gameObject;V0&&console.log(n,l.name);for(const c of this._lods){const h=c.model.distance;let d=null;if(c.renderers.includes(o)?d=l:d=i,d.type==="Group"){console.warn(`LODGroup ${this.name}: Group or MultiMaterial object's are not supported as LOD object: ${d.name}`);continue}V0&&console.log("LEVEL",d.name,h),r.autoUpdate=!1,this.onAddLodLevel(r,d,c.model.distance)}}}}onAfterRender(){if(!this.gameObject||!this._lodsHandler)return;const t=this.context.mainCamera;if(t)for(const i of this._lodsHandler){i.update(t);const n=i.getCurrentLevel(),o=i.levels[n];i.layers.mask=o.object.layers.mask}}onAddLodLevel(t,i,n){if(i===this.gameObject){console.warn("LODGroup component must be on parent object and not mesh directly at the moment",i.name,i);return}t.addLevel(i,n*this._distanceFactor,.01);const o={lod:t,levelIndex:t.levels.length-1,distance:n};this._settings.push(o)}distanceFactor(t){if(t!==this._distanceFactor){this._distanceFactor=t;for(const i of this._settings){const n=i.lod.levels[i.levelIndex];n.distance=i.distance*t}}}}wh([m(x)],xh.prototype,"localReferencePoint",2),wh([m(Zr)],xh.prototype,"lodModels",2);var xE=Object.defineProperty,SE=Object.getOwnPropertyDescriptor,CE=(s,t,i,n)=>{for(var o=n>1?void 0:n?SE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&xE(t,i,o),o};const Cp=O("debugnestedgltf");class Op extends A{constructor(){super(...arguments),a(this,"filePath"),a(this,"loadAssetInParent",!0),a(this,"_isLoadingOrDoneLoading",!1)}listenToProgress(t){var i;(i=this.filePath)==null||i.beginListenDownload(t)}preload(){var t;(t=this.filePath)==null||t.preload()}async start(){var t,i,n,o,r;if(this._isLoadingOrDoneLoading)return;Cp&&console.log(this,this.guid);const l=this.gameObject.parent;if(l){this._isLoadingOrDoneLoading=!0;const c=new js;c.idProvider=new Bt(this.hash(this.guid)),c.parent=this.loadAssetInParent!==!1?l:this.gameObject,this.gameObject.updateMatrix();const h=this.gameObject.matrix;Cp&&console.log("Load nested:",((t=this.filePath)==null?void 0:t.url)??this.filePath,this.gameObject.position);const d=await((n=(i=this.filePath)==null?void 0:i.instantiate)==null?void 0:n.call(this.filePath,c));Cp&&console.log("Nested loaded:",((o=this.filePath)==null?void 0:o.url)??this.filePath,d),d&&this.loadAssetInParent!==!1&&(d.matrixAutoUpdate=!1,d.matrix.identity(),d.applyMatrix4(h),d.matrixAutoUpdate=!0,d.layers.disableAll(),d.layers.set(this.layer),this.dispatchEvent(new CustomEvent("loaded",{detail:{instance:d,assetReference:this.filePath}}))),Cp&&console.log("Nested loading done:",((r=this.filePath)==null?void 0:r.url)??this.filePath,d)}}onDestroy(){var t;(t=this.filePath)==null||t.unload()}hash(t){let i=0;for(let n=0;n<t.length;n++)i=t.charCodeAt(n)+((i<<5)-i);return i}}CE([m(le)],Op.prototype,"filePath",2);var OE=Object.defineProperty,PE=Object.getOwnPropertyDescriptor,H0=(s,t,i,n)=>{for(var o=n>1?void 0:n?PE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&OE(t,i,o),o};const kE=O("debugnet"),$0=class extends A{constructor(){super(...arguments),a(this,"url",null),a(this,"urlParameterName",null),a(this,"localhost",null)}awake(){kE&&console.log(this),this.context.connection.registerProvider(this)}getWebsocketUrl(){let s=this.url?$0.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){const i=O(this.urlParameterName);i&&typeof i=="string"&&(s=i)}if(!s)return null;const t=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(s);return t!=null&&t.groups?t?.groups.socket_prefix?s:"wss://"+t?.groups.url:null}static GetUrl(s,t){let i=s;const n=$0.IsLocalNetwork()&&t;if(n&&(i=t),s!=null&&s.startsWith("/")){const o=n?i:window.location.origin;o!=null&&o.endsWith("/")&&s.startsWith("/")&&(s=s.substring(1)),i=o+s}return i}static IsLocalNetwork(s=window.location.hostname){return Gt(s)}};let Cl=$0;H0([m()],Cl.prototype,"url",2),H0([m()],Cl.prototype,"urlParameterName",2),H0([m()],Cl.prototype,"localhost",2);var ME=Object.defineProperty,RE=Object.getOwnPropertyDescriptor,Pp=(s,t,i,n)=>{for(var o=n>1?void 0:n?RE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&ME(t,i,o),o};class Jr extends A{constructor(){super(...arguments),a(this,"referenceSpace"),a(this,"from"),a(this,"affectPosition",!1),a(this,"affectRotation",!1),a(this,"alignLookDirection",!1),a(this,"levelLookDirection",!1),a(this,"levelPosition",!1),a(this,"positionOffset",new x(0,0,0)),a(this,"rotationOffset",new x(0,0,0)),a(this,"offset",new x(0,0,0))}update(){if(!this.from)return;var t=ee(this.from),i=Se(this.from);this.offset.copy(this.positionOffset);const n=this.offset.length();if(this.referenceSpace&&this.offset.transformDirection(this.referenceSpace.matrixWorld).multiplyScalar(n),t.add(this.offset),this.levelPosition&&this.referenceSpace){const c=new dr(this.gameObject.up,0),h=ee(this.referenceSpace);c.setFromNormalAndCoplanarPoint(this.gameObject.up,h);const d=new x(0,0,0);c.projectPoint(t,d),t.copy(d)}this.affectPosition&&ct(this.gameObject,t);const o=new Ft(this.rotationOffset.x,this.rotationOffset.y,this.rotationOffset.z),r=new V().setFromEuler(o);this.affectRotation&&qi(this.gameObject,i.multiply(r));const l=new x;this.from.getWorldDirection(l).multiplyScalar(50),this.levelLookDirection&&(l.y=0),this.alignLookDirection&&this.gameObject.lookAt(l)}}Pp([m(P)],Jr.prototype,"referenceSpace",2),Pp([m(P)],Jr.prototype,"from",2),Pp([m(x)],Jr.prototype,"positionOffset",2),Pp([m(x)],Jr.prototype,"rotationOffset",2);var TE=Object.defineProperty,EE=Object.getOwnPropertyDescriptor,k=(s,t,i,n)=>{for(var o=n>1?void 0:n?EE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&TE(t,i,o),o};const kp=O("debugparticles");var $n=(s=>(s[s.Billboard=0]="Billboard",s[s.Stretch=1]="Stretch",s[s.HorizontalBillboard=2]="HorizontalBillboard",s[s.VerticalBillboard=3]="VerticalBillboard",s[s.Mesh=4]="Mesh",s))($n||{});class $o{constructor(){a(this,"alphaKeys",[]),a(this,"colorKeys",[])}get duration(){return 1}evaluate(t,i){let n,o=0,r=null,l=0;for(let c=0;c<this.alphaKeys.length;c++){const h=this.alphaKeys[c];(h.time<t||!n)&&(n=h,o=c)}for(let c=0;c<this.colorKeys.length;c++){const h=this.colorKeys[c];(h.time<t||!r)&&(r=h,l=c)}if(r)if(l+1<this.colorKeys.length){const c=this.colorKeys[l+1],h=W.remap(t,r.time,c.time,0,1);i.r=W.lerp(r.color.r,c.color.r,h),i.g=W.lerp(r.color.g,c.color.g,h),i.b=W.lerp(r.color.b,c.color.b,h)}else i.r=r.color.r,i.g=r.color.g,i.b=r.color.b;if(n)if(o+1<this.alphaKeys.length){const c=this.alphaKeys[o+1],h=W.remap(t,n.time,c.time,0,1);i.alpha=W.lerp(n.alpha,c.alpha,h)}else i.alpha=n.alpha;return i}}k([m()],$o.prototype,"alphaKeys",2),k([m()],$o.prototype,"colorKeys",2);var Sh=(s=>(s[s.Local=0]="Local",s[s.World=1]="World",s[s.Custom=2]="Custom",s))(Sh||{}),Mp=(s=>(s[s.Sphere=0]="Sphere",s[s.SphereShell=1]="SphereShell",s[s.Hemisphere=2]="Hemisphere",s[s.HemisphereShell=3]="HemisphereShell",s[s.Cone=4]="Cone",s[s.Box=5]="Box",s[s.Mesh=6]="Mesh",s[s.ConeShell=7]="ConeShell",s[s.ConeVolume=8]="ConeVolume",s[s.ConeVolumeShell=9]="ConeVolumeShell",s[s.Circle=10]="Circle",s[s.CircleEdge=11]="CircleEdge",s[s.SingleSidedEdge=12]="SingleSidedEdge",s[s.MeshRenderer=13]="MeshRenderer",s[s.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",s[s.BoxShell=15]="BoxShell",s[s.BoxEdge=16]="BoxEdge",s[s.Donut=17]="Donut",s[s.Rectangle=18]="Rectangle",s[s.Sprite=19]="Sprite",s[s.SpriteRenderer=20]="SpriteRenderer",s))(Mp||{});const Ch=class{constructor(){a(this,"mode","Constant"),a(this,"constant"),a(this,"constantMin"),a(this,"constantMax"),a(this,"curve"),a(this,"curveMin"),a(this,"curveMax"),a(this,"curveMultiplier")}static constant(s){const t=new Ch;return t.setConstant(s),t}static betweenTwoConstants(s,t){const i=new Ch;return i.setMinMaxConstant(s,t),i}static curve(s,t=1){const i=new Ch;return i.setCurve(s,t),i}setConstant(s){this.mode=0,this.constant=s}setMinMaxConstant(s,t){this.mode=3,this.constantMin=s,this.constantMax=t}setCurve(s,t=1){this.mode=1,this.curve=s,this.curveMultiplier=t}clone(){var s,t,i;const n=new Ch;return n.mode=this.mode,n.constant=this.constant,n.constantMin=this.constantMin,n.constantMax=this.constantMax,n.curve=(s=this.curve)==null?void 0:s.clone(),n.curveMin=(t=this.curveMin)==null?void 0:t.clone(),n.curveMax=(i=this.curveMax)==null?void 0:i.clone(),n.curveMultiplier=this.curveMultiplier,n}evaluate(s,t){const i=t===void 0?Math.random():t;switch(this.mode){case 0:case"Constant":return this.constant;case 1:case"Curve":return s=W.clamp01(s),this.curve.evaluate(s)*this.curveMultiplier;case 2:case"TwoCurves":const n=s*this.curveMin.duration,o=s*this.curveMax.duration;return W.lerp(this.curveMin.evaluate(n),this.curveMax.evaluate(o),i%1)*this.curveMultiplier;case 3:case"TwoConstants":return W.lerp(this.constantMin,this.constantMax,i%1);default:this.curveMax.evaluate(s)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:case"Constant":return this.constant;case 1:case"Curve":return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:case"TwoCurves":return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:case"TwoConstants":return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(s){if(!s)return 0;let t=Number.MIN_VALUE;for(let i=0;i<s.keys.length;i++){const n=s.keys[i];n.value>t&&(t=n.value)}return t}};let X=Ch;k([m()],X.prototype,"mode",2),k([m()],X.prototype,"constant",2),k([m()],X.prototype,"constantMin",2),k([m()],X.prototype,"constantMax",2),k([m(Lr)],X.prototype,"curve",2),k([m(Lr)],X.prototype,"curveMin",2),k([m(Lr)],X.prototype,"curveMax",2),k([m()],X.prototype,"curveMultiplier",2);var Rp;const It=(Rp=class{constructor(){a(this,"mode",0),a(this,"color"),a(this,"colorMin"),a(this,"colorMax"),a(this,"gradient"),a(this,"gradientMin"),a(this,"gradientMax")}static constant(s){const t=new It;return t.constant(s),t}static betweenTwoColors(s,t){const i=new It;return i.betweenTwoColors(s,t),i}constant(s){return this.mode=0,this.color=s,this}betweenTwoColors(s,t){return this.mode=2,this.colorMin=s,this.colorMax=t,this}evaluate(s,t){const i=t===void 0?Math.random():t;switch(this.mode){case 0:case"Color":return this.color;case 1:case"Gradient":return this.gradient.evaluate(s,It._temp),It._temp;case 2:case"TwoColors":return It._temp.lerpColors(this.colorMin,this.colorMax,i);case 3:case"TwoGradients":return this.gradientMin.evaluate(s,It._temp),this.gradientMax.evaluate(s,It._temp2),It._temp.lerp(It._temp2,i);case 4:case"RandomColor":const n=Math.random();return this.gradientMin.evaluate(s,It._temp),this.gradientMax.evaluate(s,It._temp2),It._temp.lerp(It._temp2,n)}return It._temp.set(16777215),It._temp.alpha=1,It._temp}},a(Rp,"_temp",new we(0,0,0,1)),a(Rp,"_temp2",new we(0,0,0,1)),Rp);let ii=It;k([m()],ii.prototype,"mode",2),k([m(we)],ii.prototype,"color",2),k([m(we)],ii.prototype,"colorMin",2),k([m(we)],ii.prototype,"colorMax",2),k([m($o)],ii.prototype,"gradient",2),k([m($o)],ii.prototype,"gradientMin",2),k([m($o)],ii.prototype,"gradientMax",2);var q0=(s=>(s[s.Hierarchy=0]="Hierarchy",s[s.Local=1]="Local",s[s.Shape=2]="Shape",s))(q0||{});class jt{constructor(){a(this,"cullingMode"),a(this,"duration"),a(this,"emitterVelocityMode"),a(this,"flipRotation"),a(this,"gravityModifier"),a(this,"gravityModifierMultiplier"),a(this,"loop"),a(this,"maxParticles"),a(this,"playOnAwake"),a(this,"prewarm"),a(this,"ringBufferLoopRange"),a(this,"ringBufferMode"),a(this,"scalingMode"),a(this,"simulationSpace"),a(this,"simulationSpeed"),a(this,"startColor"),a(this,"startDelay"),a(this,"startDelayMultiplier"),a(this,"startLifetime"),a(this,"startLifetimeMultiplier"),a(this,"startRotation"),a(this,"startRotationMultiplier"),a(this,"startRotation3D"),a(this,"startRotationX"),a(this,"startRotationXMultiplier"),a(this,"startRotationY"),a(this,"startRotationYMultiplier"),a(this,"startRotationZ"),a(this,"startRotationZMultiplier"),a(this,"startSize"),a(this,"startSize3D"),a(this,"startSizeMultiplier"),a(this,"startSizeX"),a(this,"startSizeXMultiplier"),a(this,"startSizeY"),a(this,"startSizeYMultiplier"),a(this,"startSizeZ"),a(this,"startSizeZMultiplier"),a(this,"startSpeed"),a(this,"startSpeedMultiplier"),a(this,"stopAction"),a(this,"useUnscaledTime")}}k([m(X)],jt.prototype,"gravityModifier",2),k([m(ii)],jt.prototype,"startColor",2),k([m(X)],jt.prototype,"startDelay",2),k([m(X)],jt.prototype,"startLifetime",2),k([m(X)],jt.prototype,"startRotation",2),k([m(X)],jt.prototype,"startRotationX",2),k([m(X)],jt.prototype,"startRotationY",2),k([m(X)],jt.prototype,"startRotationZ",2),k([m(X)],jt.prototype,"startSize",2),k([m(X)],jt.prototype,"startSizeX",2),k([m(X)],jt.prototype,"startSizeY",2),k([m(X)],jt.prototype,"startSizeZ",2),k([m(X)],jt.prototype,"startSpeed",2);class Oh{constructor(){a(this,"cycleCount"),a(this,"maxCount"),a(this,"minCount"),a(this,"probability"),a(this,"repeatInterval"),a(this,"time"),a(this,"count"),a(this,"_performed",0)}reset(){this._performed=0}run(t){if(t<=this.time)return 0;let i=0;if(this.cycleCount===0||this._performed<this.cycleCount){const n=this.time+this.repeatInterval*this._performed;if(t>=n&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:i=this.count.constant;break;case 3:i=W.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:i=this.count.curve.evaluate(Math.random());break;case 2:const o=Math.random();i=W.lerp(this.count.curveMin.evaluate(o),this.count.curveMax.evaluate(o),Math.random());break}}return i}}class hn{constructor(){a(this,"enabled"),a(this,"bursts"),a(this,"rateOverTime"),a(this,"rateOverTimeMultiplier"),a(this,"rateOverDistance"),a(this,"rateOverDistanceMultiplier"),a(this,"system")}get burstCount(){var t;return((t=this.bursts)==null?void 0:t.length)??0}reset(){var t;(t=this.bursts)==null||t.forEach(i=>i.reset())}getBurst(){let t=0;if(this.burstCount>0)for(let i=0;i<this.burstCount;i++){const n=this.bursts[i];this.system.main.loop&&n.time>=this.system.time&&n.reset(),t+=Math.round(n.run(this.system.time))}return t}}k([m()],hn.prototype,"enabled",2),k([m()],hn.prototype,"bursts",2),k([m(X)],hn.prototype,"rateOverTime",2),k([m()],hn.prototype,"rateOverTimeMultiplier",2),k([m(X)],hn.prototype,"rateOverDistance",2),k([m()],hn.prototype,"rateOverDistanceMultiplier",2);class Ph{constructor(){a(this,"enabled"),a(this,"color")}}k([m(ii)],Ph.prototype,"color",2);class qo{constructor(){a(this,"enabled"),a(this,"separateAxes"),a(this,"size"),a(this,"sizeMultiplier"),a(this,"x"),a(this,"xMultiplier"),a(this,"y"),a(this,"yMultiplier"),a(this,"z"),a(this,"zMultiplier"),a(this,"_time",0),a(this,"_temp",new x)}evaluate(t,i,n){if(i||(i=this._temp),!this.enabled)return i.x=i.y=i.z=1,i;if(this.separateAxes)i.x=this.x.evaluate(t,n)*this.xMultiplier,i.y=this.y.evaluate(t,n)*this.yMultiplier,i.z=this.z.evaluate(t,n)*this.zMultiplier;else{const o=this.size.evaluate(t,n)*this.sizeMultiplier;i.x=o}return i}}k([m(X)],qo.prototype,"size",2),k([m(X)],qo.prototype,"x",2),k([m(X)],qo.prototype,"y",2),k([m(X)],qo.prototype,"z",2);var Tp;const kh=(Tp=class{constructor(){a(this,"shapeType",5),a(this,"enabled",!0),a(this,"alignToDirection",!1),a(this,"angle",0),a(this,"arc",360),a(this,"arcSpread"),a(this,"arcSpeedMultiplier"),a(this,"arcMode"),a(this,"boxThickness"),a(this,"position"),a(this,"rotation"),a(this,"_rotation",new Ft),a(this,"scale"),a(this,"radius"),a(this,"radiusThickness"),a(this,"sphericalDirectionAmount"),a(this,"randomDirectionAmount"),a(this,"randomPositionAmount"),a(this,"meshShapeType"),a(this,"meshRenderer"),a(this,"_meshObj"),a(this,"_meshGeometry"),a(this,"system"),a(this,"_space"),a(this,"_worldSpaceMatrix",new ne),a(this,"_worldSpaceMatrixInverse",new ne),a(this,"_vector",new x(0,0,0)),a(this,"_temp",new x(0,0,0)),a(this,"_triangle",new pC),a(this,"_dir",new x),a(this,"_loopTime",0),a(this,"_loopDirection",1),kp&&console.log(this)}get type(){return Mp[this.shapeType]}initialize(s){this.onInitialize(s),s.position.x=this._vector.x,s.position.y=this._vector.y,s.position.z=this._vector.z}toJSON(){return this}clone(){return new kh}setMesh(s){this.meshRenderer=s,s?(this._meshObj=s.sharedMeshes[Math.floor(Math.random()*s.sharedMeshes.length)],this._meshGeometry=this._meshObj.geometry):(this._meshObj=void 0,this._meshGeometry=void 0)}update(s,t){}onUpdate(s,t,i,n){this.system=s,this._space=i,i===1&&(this._worldSpaceMatrix.copy(n.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(s){const t=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return t&&(this._rotation.x=W.toRadians(this.rotation.x),this._rotation.y=W.toRadians(this.rotation.y),this._rotation.z=W.toRadians(this.rotation.z),this._rotation.order="ZYX",s.applyEuler(this._rotation)),t}onInitialize(s){this._vector.set(0,0,0),s.mesh=void 0,s.mesh_geometry=void 0;const t=this._temp.copy(this.position),i=this._space===1;i&&t.applyQuaternion(this.system.worldQuaternion);let n=this.radius;if(i&&(n*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:kp&&q.DrawWireBox(this.position,this.scale,14540253,1),this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(t);break;case 4:this.randomConePoint(this.position,this.angle,n,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,n,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,n,this.radiusThickness,this.arc,this._vector);break;case 13:const o=this.meshRenderer;o?.destroyed==!1&&this.setMesh(o);const r=s.mesh=this._meshObj,l=s.mesh_geometry=this._meshGeometry;if(r&&l)switch(this.meshShapeType){case 0:{const c=l.getAttribute("position"),h=Math.floor(Math.random()*c.count);this._vector.fromBufferAttribute(c,h),this._vector.applyMatrix4(r.matrixWorld),s.mesh_normal=h}break;case 1:break;case 2:{const c=l.index;if(c){let h=Math.random(),d=Math.random();h+d>1&&(h=1-h,d=1-d);const u=Math.floor(Math.random()*(c.count/3));let p=u*3,g=u*3+1,y=u*3+2;p=c.getX(p),g=c.getX(g),y=c.getX(y);const f=l.getAttribute("position");this._triangle.a.fromBufferAttribute(f,p),this._triangle.b.fromBufferAttribute(f,g),this._triangle.c.fromBufferAttribute(f,y),this._vector.set(0,0,0).addScaledVector(this._triangle.a,h).addScaledVector(this._triangle.b,d).addScaledVector(this._triangle.c,1-(h+d)),this._vector.applyMatrix4(r.matrixWorld),s.mesh_normal=u}}break}break;default:this._vector.set(0,0,0),F()&&!globalThis.__particlesystem_shapetype_unsupported&&(console.warn("ParticleSystem ShapeType is not supported:",Mp[this.shapeType]),globalThis.__particlesystem_shapetype_unsupported=!0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),i&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),kp&&q.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(s,t){var i;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const n=t.x,o=t.y,r=t.z;this._dir.set(n,o,r),(i=this.system)!=null&&i.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;case 13:const l=s.mesh,c=s.mesh_geometry;if(l&&c)switch(this.meshShapeType){case 0:{const h=c.getAttribute("normal"),d=s.mesh_normal;this._dir.fromBufferAttribute(h,d)}break;case 1:break;case 2:{const h=c.index;if(h){const d=s.mesh_normal,u=h.getX(d*3),p=h.getX(d*3+1),g=h.getX(d*3+2),y=c.getAttribute("position"),f=$(),v=$(),b=$();f.fromBufferAttribute(y,u),v.fromBufferAttribute(y,p),b.fromBufferAttribute(y,g),f.sub(v),b.sub(v),f.cross(b),this._dir.copy(f).multiplyScalar(-1);const w=Se(l);this._dir.applyQuaternion(w)}}break}break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),kp&&(q.DrawSphere(t,.01,8925952,.5,!0),q.DrawDirection(t,this._dir,8925952,.5,!0)),this._dir}randomizePosition(s,t){if(t<=0)return;const i=kh._tempVec;i.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),i.x*=t*this.scale.x,i.y*=t*this.scale.y,i.z*=t*this.scale.z,s.add(i)}randomizeDirection(s,t){if(t===0)return;const i=kh._randomQuat,n=kh._tempVec;n.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),i.setFromAxisAngle(n,t*Math.random()*Math.PI),s.applyQuaternion(i)}spherizeDirection(s,t){if(t===0)return;const i=Math.random()*Math.PI*2,n=Math.acos(1-Math.random()*2),o=Math.sin(n)*Math.cos(i),r=Math.sin(n)*Math.sin(i),l=Math.cos(n),c=new x(o,r,l);s.lerp(c,t)}randomSpherePoint(s,t,i,n,o){const r=Math.random(),l=Math.random(),c=2*Math.PI*r*(n/360),h=Math.acos(2*l-1),d=W.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*t,u=s.x+this.scale.x*(-d*Math.sin(h)*Math.cos(c)),p=s.y+this.scale.y*(d*Math.sin(h)*Math.sin(c)),g=s.z+this.scale.z*(d*Math.cos(h));o.x=u,o.y=p,o.z=g}randomCirclePoint(s,t,i,n,o){const r=Math.random(),l=2*Math.PI*r*(n/360),c=W.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*t,h=s.x+this.scale.x*c*Math.cos(l),d=s.y+this.scale.y*c*Math.sin(l),u=s.z;o.x=h,o.y=d,o.z=u}randomConePoint(s,t,i,n,o,r,l){let c=0,h=0;switch(r){case 0:c=Math.random(),h=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:c=.5,h=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let d=2*Math.PI*c*(o/360);switch(r){case 2:case 1:d+=Math.PI+.5,d+=this._loopTime*Math.PI*2,d%=W.toRadians(o);break}const u=Math.acos(2*h-1),p=W.lerp(1,1-Math.pow(1-Math.random(),Math.PI),n)*i,g=s.x+-p*Math.sin(u)*Math.cos(d),y=s.y+p*Math.sin(u)*Math.sin(d),f=s.z;l.x=g*this.scale.x,l.y=y*this.scale.y,l.z=f*this.scale.z}},a(Tp,"_randomQuat",new V),a(Tp,"_tempVec",new x),Tp);let Xe=kh;k([m()],Xe.prototype,"shapeType",2),k([m()],Xe.prototype,"enabled",2),k([m()],Xe.prototype,"alignToDirection",2),k([m()],Xe.prototype,"angle",2),k([m()],Xe.prototype,"arc",2),k([m()],Xe.prototype,"arcSpread",2),k([m()],Xe.prototype,"arcSpeedMultiplier",2),k([m()],Xe.prototype,"arcMode",2),k([m(x)],Xe.prototype,"boxThickness",2),k([m(x)],Xe.prototype,"position",2),k([m(x)],Xe.prototype,"rotation",2),k([m(x)],Xe.prototype,"scale",2),k([m()],Xe.prototype,"radius",2),k([m()],Xe.prototype,"radiusThickness",2),k([m()],Xe.prototype,"sphericalDirectionAmount",2),k([m()],Xe.prototype,"randomDirectionAmount",2),k([m()],Xe.prototype,"randomPositionAmount",2),k([m()],Xe.prototype,"meshShapeType",2),k([m(ih)],Xe.prototype,"meshRenderer",2);class xe{constructor(){a(this,"damping"),a(this,"enabled"),a(this,"frequency"),a(this,"octaveCount"),a(this,"octaveMultiplier"),a(this,"octaveScale"),a(this,"positionAmount"),a(this,"quality"),a(this,"remap"),a(this,"remapEnabled"),a(this,"remapMultiplier"),a(this,"remapX"),a(this,"remapXMultiplier"),a(this,"remapY"),a(this,"remapYMultiplier"),a(this,"remapZ"),a(this,"remapZMultiplier"),a(this,"scrollSpeedMultiplier"),a(this,"separateAxes"),a(this,"strengthMultiplier"),a(this,"strengthX"),a(this,"strengthXMultiplier"),a(this,"strengthY"),a(this,"strengthYMultiplier"),a(this,"strengthZ"),a(this,"strengthZMultiplier"),a(this,"_noise"),a(this,"_time",0),a(this,"_temp",new x)}update(t){this._time+=t.time.deltaTime*this.scrollSpeedMultiplier}apply(t,i,n,o,r,l){if(!this.enabled)return;this._noise||(this._noise=ZC(()=>0));const c=this._temp.set(i.x,i.y,i.z).multiplyScalar(this.frequency),h=this._noise(c.x,c.y,c.z,this._time),d=this._noise(c.x,c.y,c.z,this._time+1e3*this.frequency),u=this._noise(c.x,c.y,c.z,this._time+2e3*this.frequency);this._temp.set(h,d,u).normalize();const p=r/l;let g=this.positionAmount.evaluate(p);this.separateAxes?(this._temp.x*=g*this.strengthXMultiplier,this._temp.y*=g*this.strengthYMultiplier,this._temp.z*=g*this.strengthZMultiplier):(this.strengthX&&(g*=this.strengthX.evaluate(p)*1.5),this._temp.multiplyScalar(g)),n.x+=this._temp.x,n.y+=this._temp.y,n.z+=this._temp.z}}k([m()],xe.prototype,"damping",2),k([m()],xe.prototype,"enabled",2),k([m()],xe.prototype,"frequency",2),k([m()],xe.prototype,"octaveCount",2),k([m()],xe.prototype,"octaveMultiplier",2),k([m()],xe.prototype,"octaveScale",2),k([m(X)],xe.prototype,"positionAmount",2),k([m()],xe.prototype,"quality",2),k([m(X)],xe.prototype,"remap",2),k([m()],xe.prototype,"remapEnabled",2),k([m()],xe.prototype,"remapMultiplier",2),k([m(X)],xe.prototype,"remapX",2),k([m()],xe.prototype,"remapXMultiplier",2),k([m(X)],xe.prototype,"remapY",2),k([m()],xe.prototype,"remapYMultiplier",2),k([m(X)],xe.prototype,"remapZ",2),k([m()],xe.prototype,"remapZMultiplier",2),k([m()],xe.prototype,"scrollSpeedMultiplier",2),k([m()],xe.prototype,"separateAxes",2),k([m()],xe.prototype,"strengthMultiplier",2),k([m(X)],xe.prototype,"strengthX",2),k([m()],xe.prototype,"strengthXMultiplier",2),k([m(X)],xe.prototype,"strengthY",2),k([m()],xe.prototype,"strengthYMultiplier",2),k([m(X)],xe.prototype,"strengthZ",2),k([m()],xe.prototype,"strengthZMultiplier",2);class ze{constructor(){a(this,"enabled"),a(this,"attachRibbonToTransform",!1),a(this,"colorOverLifetime"),a(this,"colorOverTrail"),a(this,"dieWithParticles",!0),a(this,"inheritParticleColor",!0),a(this,"lifetime"),a(this,"lifetimeMultiplier"),a(this,"minVertexDistance",.2),a(this,"mode",0),a(this,"ratio",1),a(this,"ribbonCount",1),a(this,"shadowBias",0),a(this,"sizeAffectsLifetime",!1),a(this,"sizeAffectsWidth",!1),a(this,"splitSubEmitterRibbons",!1),a(this,"textureMode",0),a(this,"widthOverTrail"),a(this,"widthOverTrailMultiplier"),a(this,"worldSpace",!1)}getWidth(t,i,n,o){const r=this.widthOverTrail.evaluate(n,o);return t*=r,t}getColor(t,i,n){const o=this.colorOverTrail.evaluate(n),r=this.colorOverLifetime.evaluate(i);t.x*=o.r*r.r,t.y*=o.g*r.g,t.z*=o.b*r.b,"alpha"in o&&"alpha"in r&&(t.w*=o.alpha*r.alpha)}}k([m()],ze.prototype,"enabled",2),k([m()],ze.prototype,"attachRibbonToTransform",2),k([m(ii)],ze.prototype,"colorOverLifetime",2),k([m(ii)],ze.prototype,"colorOverTrail",2),k([m()],ze.prototype,"dieWithParticles",2),k([m()],ze.prototype,"inheritParticleColor",2),k([m(X)],ze.prototype,"lifetime",2),k([m()],ze.prototype,"lifetimeMultiplier",2),k([m()],ze.prototype,"minVertexDistance",2),k([m()],ze.prototype,"mode",2),k([m()],ze.prototype,"ratio",2),k([m()],ze.prototype,"ribbonCount",2),k([m()],ze.prototype,"shadowBias",2),k([m()],ze.prototype,"sizeAffectsLifetime",2),k([m()],ze.prototype,"sizeAffectsWidth",2),k([m()],ze.prototype,"splitSubEmitterRibbons",2),k([m()],ze.prototype,"textureMode",2),k([m(X)],ze.prototype,"widthOverTrail",2),k([m()],ze.prototype,"widthOverTrailMultiplier",2),k([m()],ze.prototype,"worldSpace",2);class Qe{constructor(){a(this,"enabled"),a(this,"space",0),a(this,"orbitalX"),a(this,"orbitalY"),a(this,"orbitalZ"),a(this,"orbitalXMultiplier"),a(this,"orbitalYMultiplier"),a(this,"orbitalZMultiplier"),a(this,"orbitalOffsetX"),a(this,"orbitalOffsetY"),a(this,"orbitalOffsetZ"),a(this,"speedModifier"),a(this,"speedModifierMultiplier"),a(this,"x"),a(this,"xMultiplier"),a(this,"y"),a(this,"yMultiplier"),a(this,"z"),a(this,"zMultiplier"),a(this,"_system"),a(this,"_temp",new x),a(this,"_temp2",new x),a(this,"_temp3",new x),a(this,"_hasOrbital",!1),a(this,"_index",0),a(this,"_orbitalMatrix",new ne)}update(t){this._system=t}init(t){this._index==0&&(t.debug=!0),this._index+=1,t.orbitx=this.orbitalX.evaluate(Math.random()),t.orbity=this.orbitalY.evaluate(Math.random()),t.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=t.orbitx!=0||t.orbity!=0||t.orbitz!=0}apply(t,i,n,o,r,l,c){var h;if(!this.enabled)return;const d=l/c,u=this.speedModifier.evaluate(d)*this.speedModifierMultiplier,p=this.x.evaluate(d),g=this.y.evaluate(d),y=this.z.evaluate(d);if(this._temp.set(-p,g,y),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((h=this._system)==null?void 0:h.worldPos)){const f=this._temp2.set(n.x,n.y,n.z),v=this.orbitalXMultiplier,b=this.orbitalYMultiplier,w=this.orbitalZMultiplier,_=u*Math.PI*2*10,C=Math.cos(_*v),R=Math.sin(_*v),M=Math.cos(_*b),E=Math.sin(_*b),B=Math.cos(_*w),L=Math.sin(_*w),U=f.x*(M*B)+f.y*(M*L)+f.z*-E,z=f.x*(R*E*B-C*L)+f.y*(R*E*L+C*B)+f.z*(R*M),H=f.x*(C*E*B+R*L)+f.y*(C*E*L-R*B)+f.z*(C*M),T=this._temp3.set(f.x-U,f.y-z,f.z-H);T.normalize(),T.multiplyScalar(.2/r*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),o.x+=T.x,o.y+=T.y,o.z+=T.z}o.x+=this._temp.x,o.y+=this._temp.y,o.z+=this._temp.z,o.x*=u,o.y*=u,o.z*=u}}k([m()],Qe.prototype,"enabled",2),k([m()],Qe.prototype,"space",2),k([m(X)],Qe.prototype,"orbitalX",2),k([m(X)],Qe.prototype,"orbitalY",2),k([m(X)],Qe.prototype,"orbitalZ",2),k([m()],Qe.prototype,"orbitalXMultiplier",2),k([m()],Qe.prototype,"orbitalYMultiplier",2),k([m()],Qe.prototype,"orbitalZMultiplier",2),k([m()],Qe.prototype,"orbitalOffsetX",2),k([m()],Qe.prototype,"orbitalOffsetY",2),k([m()],Qe.prototype,"orbitalOffsetZ",2),k([m(X)],Qe.prototype,"speedModifier",2),k([m()],Qe.prototype,"speedModifierMultiplier",2),k([m(X)],Qe.prototype,"x",2),k([m()],Qe.prototype,"xMultiplier",2),k([m(X)],Qe.prototype,"y",2),k([m()],Qe.prototype,"yMultiplier",2),k([m(X)],Qe.prototype,"z",2),k([m()],Qe.prototype,"zMultiplier",2);class Lt{constructor(){a(this,"animation"),a(this,"enabled"),a(this,"cycleCount"),a(this,"frameOverTime"),a(this,"frameOverTimeMultiplier"),a(this,"numTilesX"),a(this,"numTilesY"),a(this,"startFrame"),a(this,"startFrameMultiplier"),a(this,"rowMode"),a(this,"rowIndex"),a(this,"spriteCount"),a(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(t){if(!this.sampleOnceAtStart())return this.getIndex(t)}getIndex(t){const i=this.numTilesX*this.numTilesY;t=t*this.cycleCount;let n=this.frameOverTime.evaluate(t%1);return n*=this.frameOverTimeMultiplier,n*=i,n=n%i,n=Math.floor(n),n}}k([m()],Lt.prototype,"animation",2),k([m()],Lt.prototype,"enabled",2),k([m()],Lt.prototype,"cycleCount",2),k([m(X)],Lt.prototype,"frameOverTime",2),k([m()],Lt.prototype,"frameOverTimeMultiplier",2),k([m()],Lt.prototype,"numTilesX",2),k([m()],Lt.prototype,"numTilesY",2),k([m(X)],Lt.prototype,"startFrame",2),k([m()],Lt.prototype,"startFrameMultiplier",2),k([m()],Lt.prototype,"rowMode",2),k([m()],Lt.prototype,"rowIndex",2),k([m()],Lt.prototype,"spriteCount",2),k([m()],Lt.prototype,"timeMode",2);class ns{constructor(){a(this,"enabled"),a(this,"separateAxes"),a(this,"x"),a(this,"xMultiplier"),a(this,"y"),a(this,"yMultiplier"),a(this,"z"),a(this,"zMultiplier")}evaluate(t,i){return this.enabled?this.separateAxes?0:this.z.evaluate(t,i)*-1:0}}k([m()],ns.prototype,"enabled",2),k([m()],ns.prototype,"separateAxes",2),k([m(X)],ns.prototype,"x",2),k([m()],ns.prototype,"xMultiplier",2),k([m(X)],ns.prototype,"y",2),k([m()],ns.prototype,"yMultiplier",2),k([m(X)],ns.prototype,"z",2),k([m()],ns.prototype,"zMultiplier",2);class Bi{constructor(){a(this,"enabled"),a(this,"range"),a(this,"separateAxes"),a(this,"x"),a(this,"xMultiplier"),a(this,"y"),a(this,"yMultiplier"),a(this,"z"),a(this,"zMultiplier")}evaluate(t,i){if(!this.enabled)return 0;if(!this.separateAxes){const n=W.lerp(this.range.x,this.range.y,i);return this.z.evaluate(n)*-1}return 0}}k([m()],Bi.prototype,"enabled",2),k([m()],Bi.prototype,"range",2),k([m()],Bi.prototype,"separateAxes",2),k([m(X)],Bi.prototype,"x",2),k([m()],Bi.prototype,"xMultiplier",2),k([m(X)],Bi.prototype,"y",2),k([m()],Bi.prototype,"yMultiplier",2),k([m(X)],Bi.prototype,"z",2),k([m()],Bi.prototype,"zMultiplier",2);class rt{constructor(){a(this,"enabled"),a(this,"dampen"),a(this,"drag"),a(this,"dragMultiplier"),a(this,"limit"),a(this,"limitMultiplier"),a(this,"separateAxes"),a(this,"limitX"),a(this,"limitXMultiplier"),a(this,"limitY"),a(this,"limitYMultiplier"),a(this,"limitZ"),a(this,"limitZMultiplier"),a(this,"multiplyDragByParticleSize",!1),a(this,"multiplyDragByParticleVelocity",!1),a(this,"space"),a(this,"_temp",new x),a(this,"_temp2",new x)}apply(t,i,n,o,r,l,c){if(this.enabled){const h=this.limit.evaluate(r)*this.limitMultiplier;if(i.length()>h){this._temp.copy(i).normalize().multiplyScalar(h);const d=this.dampen*.5;i.x=W.lerp(i.x,this._temp.x,d),i.y=W.lerp(i.y,this._temp.y,d),i.z=W.lerp(i.z,this._temp.z,d),n.x=W.lerp(n.x,this._temp.x,d),n.y=W.lerp(n.y,this._temp.y,d),n.z=W.lerp(n.z,this._temp.z,d)}}}}k([m()],rt.prototype,"enabled",2),k([m()],rt.prototype,"dampen",2),k([m(X)],rt.prototype,"drag",2),k([m()],rt.prototype,"dragMultiplier",2),k([m(X)],rt.prototype,"limit",2),k([m()],rt.prototype,"limitMultiplier",2),k([m()],rt.prototype,"separateAxes",2),k([m(X)],rt.prototype,"limitX",2),k([m()],rt.prototype,"limitXMultiplier",2),k([m(X)],rt.prototype,"limitY",2),k([m()],rt.prototype,"limitYMultiplier",2),k([m(X)],rt.prototype,"limitZ",2),k([m()],rt.prototype,"limitZMultiplier",2),k([m()],rt.prototype,"multiplyDragByParticleSize",2),k([m()],rt.prototype,"multiplyDragByParticleVelocity",2),k([m()],rt.prototype,"space",2);const i1=class{constructor(){a(this,"enabled"),a(this,"curve"),a(this,"curveMultiplier"),a(this,"mode"),a(this,"system"),a(this,"_temp",new x),a(this,"_firstUpdate",!0),a(this,"_frames",0)}clone(){var s;const t=new i1;return t.enabled=this.enabled,t.curve=(s=this.curve)==null?void 0:s.clone(),t.curveMultiplier=this.curveMultiplier,t.mode=this.mode,t}get _lastWorldPosition(){return this.system._iv_lastWorldPosition||(this.system._iv_lastWorldPosition=new x),this.system._iv_lastWorldPosition}get _velocity(){return this.system._iv_velocity||(this.system._iv_velocity=new x),this.system._iv_velocity}awake(s){this.system=s,this.reset()}reset(){this._firstUpdate=!0}update(s){this.enabled&&this.system.worldspace!==!1&&(this._firstUpdate?(this._firstUpdate=!1,this._velocity.set(0,0,0),this._lastWorldPosition.copy(this.system.worldPos)):this._lastWorldPosition&&(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)))}applyInitial(s){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const t=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(t),s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z}}applyCurrent(s,t,i){if(this.enabled&&this.system&&this.system.worldspace!==!1&&this.mode===1){const n=this.curve.evaluate(t,i);this._temp.copy(this._velocity).multiplyScalar(n),s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z}}};let Go=i1;k([m()],Go.prototype,"enabled",2),k([m(X)],Go.prototype,"curve",2),k([m()],Go.prototype,"curveMultiplier",2),k([m()],Go.prototype,"mode",2);class si{constructor(){a(this,"enabled"),a(this,"range"),a(this,"separateAxes"),a(this,"size"),a(this,"sizeMultiplier"),a(this,"x"),a(this,"xMultiplier"),a(this,"y"),a(this,"yMultiplier"),a(this,"z"),a(this,"zMultiplier")}evaluate(t,i,n,o){const r=t.length(),l=W.remap(r,this.range.x,this.range.y,0,1),c=this.size.evaluate(l,n);return o.x*=c,o.y*=c,o.z*=c,o}}k([m()],si.prototype,"enabled",2),k([m(oe)],si.prototype,"range",2),k([m()],si.prototype,"separateAxes",2),k([m(X)],si.prototype,"size",2),k([m()],si.prototype,"sizeMultiplier",2),k([m(X)],si.prototype,"x",2),k([m()],si.prototype,"xMultiplier",2),k([m(X)],si.prototype,"y",2),k([m()],si.prototype,"yMultiplier",2),k([m(X)],si.prototype,"z",2),k([m()],si.prototype,"zMultiplier",2);class ea{constructor(){a(this,"enabled"),a(this,"range"),a(this,"color")}evaluate(t,i,n){const o=t.length(),r=W.remap(o,this.range.x,this.range.y,0,1),l=this.color.evaluate(r,i);n.x*=l.r,n.y*=l.g,n.z*=l.b,"alpha"in l&&(n.w*=l.alpha)}}k([m()],ea.prototype,"enabled",2),k([m(oe)],ea.prototype,"range",2),k([m(ii)],ea.prototype,"color",2),new x(1,1,1),new x(0,0,1);class Ep{constructor(t,i,n,o){a(this,"type","NeedleParticleSubEmitter"),a(this,"emitterType"),a(this,"emitterProbability"),a(this,"q_",new V),a(this,"v_",new x),a(this,"v2_",new x),a(this,"_emitterMatrix",new Cm),a(this,"_circularBuffer"),this.system=t,this.particleSystem=i,this.subSystem=n,this.subParticleSystem=o,this.subParticleSystem&&this.subParticleSystem&&(this.subParticleSystem.onlyUsedByOther=!0);const r=1e3;this._circularBuffer=new wi(()=>new Cm,r)}clone(){throw new Error("Method not implemented.")}initialize(t){t.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0},this._emitterMatrix.copy(this.subSystem.matrixWorld).invert().premultiply(this.system.matrixWorld),this._emitterMatrix.setPosition(0,0,0),this.emitterType===G0.Birth&&this.run(t)}update(t,i){this.run(t)}frameUpdate(t){}toJSON(){}reset(){}run(t){if(this.subSystem.currentParticles>=this.subSystem.main.maxParticles||!this.subParticleSystem||!t.emissionState||this.emitterProbability&&Math.random()>this.emitterProbability)return;const i=this.system.deltaTime;if(this.emitterType===G0.Death){let o=t.life;if(t[Ol]!==void 0&&(o=t[Ol]),!(t.age+i*1.2>=o))return;const r=this.subSystem.main.maxParticles-this.subSystem.currentParticles;t.emissionState.waitEmiting=r}const n=new Cm;n.set(1,0,0,t.position.x,0,1,0,t.position.y,0,0,1,t.position.z,0,0,0,1),this.particleSystem.worldSpace||n.multiplyMatrices(this._emitterMatrix,n),this.subParticleSystem.emit(i,t.emissionState,n)}}var AE=Object.defineProperty,IE=Object.getOwnPropertyDescriptor,Ye=(s,t,i,n)=>{for(var o=n>1?void 0:n?IE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&AE(t,i,o),o};const Xo=O("debugparticles"),jE=O("noprogressive"),LE=O("debugprogressive");var G0=(s=>(s[s.Birth=0]="Birth",s[s.Collision=1]="Collision",s[s.Death=2]="Death",s[s.Trigger=3]="Trigger",s[s.Manual=4]="Manual",s))(G0||{});class os extends A{constructor(){super(...arguments),a(this,"renderMode"),a(this,"particleMaterial"),a(this,"trailMaterial"),a(this,"particleMesh"),a(this,"maxParticleSize"),a(this,"minParticleSize"),a(this,"velocityScale"),a(this,"cameraVelocityScale"),a(this,"lengthScale")}start(){if(this.maxParticleSize!==.5&&this.minParticleSize!==0&&F()){const t=`ParticleSystem "${this.name}" has non-default min/max particle size. This may not render correctly. Please set min size to 0 and the max size to 0.5 and use the "StartSize" setting instead`;console.warn(t)}}get transparent(){var t;return((t=this.particleMaterial)==null?void 0:t.transparent)??!1}getMaterial(t=!1){let i=t===!0&&this.trailMaterial?this.trailMaterial:this.particleMaterial;if(i){if(i.type==="MeshStandardMaterial"){Xo&&console.debug("ParticleSystemRenderer.getMaterial: MeshStandardMaterial detected, converting to MeshBasicMaterial. See https://github.com/Alchemist0823/three.quarks/issues/101"),"map"in i&&i.map&&(i.map.colorSpace=pr,i.map.premultiplyAlpha=!1);const n=new Me({map:i.map});t?this.trailMaterial=n:this.particleMaterial=n}i.map&&(i.map.colorSpace=pr,i.map.premultiplyAlpha=!1),t&&i.side===ao&&(i=i.clone(),i.side=fm,t?this.trailMaterial=i:this.particleMaterial=i)}return i&&!jE&&i._didRequestTextureLOD===void 0&&(i._didRequestTextureLOD=0,LE&&console.log("Load material LOD",i.name),et.assignTextureLOD(i,0)),i}getMesh(t){let i=null;if(!i&&(this.particleMesh instanceof Q&&(i=this.particleMesh.geometry),i===null)){i=new Ds(1,1);const n=i.attributes.uv;for(let o=0;o<n.count;o++)n.setX(o,1-n.getX(o))}return new Q(i,this.getMaterial())}}Ye([m()],os.prototype,"renderMode",2),Ye([m(Oe)],os.prototype,"particleMaterial",2),Ye([m(Oe)],os.prototype,"trailMaterial",2),Ye([m()],os.prototype,"maxParticleSize",2),Ye([m()],os.prototype,"minParticleSize",2),Ye([m()],os.prototype,"velocityScale",2),Ye([m()],os.prototype,"cameraVelocityScale",2),Ye([m()],os.prototype,"lengthScale",2);class Ap{constructor(t,i=1){a(this,"_curve"),a(this,"_factor"),a(this,"type","function"),this._curve=t,this._factor=i}startGen(t){}genValue(t,i){return this._curve.evaluate(i,Math.random())*this._factor}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class X0{constructor(t){a(this,"type","value"),a(this,"system"),this.system=t}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}startGen(t){}}class DE extends X0{genValue(){return this.system.textureSheetAnimation.getStartIndex()}}class BE extends X0{constructor(){super(...arguments),a(this,"_lastPosition",new x),a(this,"_lastDistance",0)}update(){const t=ee(this.system.gameObject);this._lastDistance=this._lastPosition.distanceTo(t),this._lastPosition.copy(t)}genValue(){if(!this.system.isPlaying||!this.system.emission.enabled||this.system.currentParticles>=this.system.maxParticles)return 0;let t=this.system.emission.rateOverTime.evaluate(this.system.time/this.system.duration,Math.random());if(this.system.deltaTime>0){const o=this.system.emission.rateOverDistance.evaluate(this.system.time/this.system.duration,Math.random());let r=this._lastDistance/this.system.deltaTime*o;Number.isFinite(r)||(r=0),t+=r}const i=this.system.emission.getBurst();i>0&&(t+=i/this.system.deltaTime);const n=this.system.maxParticles-this.system.currentParticles;return W.clamp(t,0,n/this.system.deltaTime)}}class FE extends X0{genValue(){return this.system.isPlaying,0}}class Qo{constructor(t){a(this,"system"),a(this,"type"),this.type=Object.getPrototypeOf(this).constructor.name||"ParticleSystemBaseBehaviour",t&&(this.system=t)}get context(){return this.system.context}initialize(t){}update(t,i){}frameUpdate(t){}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}reset(){}}class zE extends Qo{constructor(){super(...arguments),a(this,"type","NeedleTextureSheet")}update(t,i){const n=this.system.textureSheetAnimation;if(n.enabled){const o=t.age/t.life,r=n.evaluate(o);r!==void 0&&(t.uvTile=r)}}}const s1=Symbol("particleRotation");class UE extends Qo{constructor(){super(...arguments),a(this,"type","NeedleRotation")}initialize(t){t[s1]=Math.random()}update(t,i){if(t.rotation===void 0)return;const n=t.age/t.life;if(typeof t.rotation=="number"&&(this.system.rotationOverLifetime.enabled?t.rotation+=this.system.rotationOverLifetime.evaluate(n,t[s1])*i:this.system.renderer.renderMode===$n.Billboard&&(t.rotation=Math.PI),this.system.rotationBySpeed.enabled)){const o=t.velocity.length();t.rotation+=this.system.rotationBySpeed.evaluate(n,o)*i}}}const n1=Symbol("sizeLerpFactor"),NE=new x;class WE extends Qo{constructor(){super(...arguments),a(this,"type","NeedleSize"),a(this,"_minSize",0),a(this,"_maxSize",1)}initialize(t){t[n1]=Math.random(),this._minSize=this.system.renderer.minParticleSize,this._maxSize=this.system.renderer.maxParticleSize}update(t,i){const n=t.age/t.life;let o=1;this.system.sizeOverLifetime.enabled&&(o*=this.system.sizeOverLifetime.evaluate(n,void 0,t[n1]).x);let r=1;this.system.renderer.renderMode!==$n.Mesh&&(r=this.system.worldScale.x/this.system.cameraScale);const l=$(t.startSize).multiplyScalar(o*r);if(t.size.set(l.x,l.y,l.z),this.system.localspace){const c=c1(this.system,NE);t.size.x*=c.x,t.size.y*=c.y,t.size.z*=c.z}}}const Ol=Symbol("particleLife"),Q0=Symbol("trailLifetime"),o1=Symbol("trailStartLength"),Y0=Symbol("trailWidthRandom");class VE extends Qo{constructor(){super(...arguments),a(this,"type","NeedleTrail")}initialize(t){t instanceof yv&&(t[Ol]=t.life,this.system.trails.enabled&&this.system.trails.dieWithParticles===!1&&(t[Q0]=this.system.trails.lifetime.evaluate(Math.random(),Math.random()),t.life+=t[Q0]),t[o1]=t.length,t[Y0]=Math.random())}update(t){var i;if((i=this.system.trails)!=null&&i.enabled&&t instanceof yv){const n=t,o=t.age/t[Ol],r=t.previous.values(),l=t.previous.length;for(let c=0;c<l;c++){const h=r.next().value,d=1-c/(l-1),u=t.size;if(u.x<=0&&!this.system.trails.sizeAffectsWidth){const p=20*this.system.trails.widthOverTrail.evaluate(.5,n[Y0]);u.x=p,u.y=p,u.z=p}h.size=this.system.trails.getWidth(u.x,o,d,n[Y0]),h.color.copy(t.color),this.system.trails.getColor(h.color,o,d)}if(t.age>t[Ol]){t.velocity.set(0,0,0);const c=(t.age-t[Ol])/t[Q0];n.length=W.lerp(t[o1],0,c)}}}}const Ip=Symbol("startVelocity"),r1=Symbol("gravityModifier"),K0=Symbol("gravitySpeed"),jp=Symbol("velocity lerp factor"),Z0=new x;class HE extends Qo{constructor(){super(...arguments),a(this,"type","NeedleVelocity"),a(this,"_gravityDirection",new x)}initialize(t){var i,n;const o=this.system.main.simulationSpeed;t.startSpeed=this.system.main.startSpeed.evaluate(Math.random(),Math.random());const r=this.system.shape.getDirection(t,t.position);t.velocity.x=r.x*t.startSpeed,t.velocity.y=r.y*t.startSpeed,t.velocity.z=r.z*t.startSpeed,(i=this.system.inheritVelocity)!=null&&i.enabled&&this.system.inheritVelocity.applyInitial(t.velocity),t[Ip]?t[Ip].copy(t.velocity):t[Ip]=t.velocity.clone();const l=this.system.main.gravityModifier.evaluate(Math.random(),Math.random());t[r1]=l*o,t[K0]=l*o*.5,t[jp]=Math.random(),(n=this.system.velocityOverLifetime)==null||n.init(t),this._gravityDirection.set(0,-1,0),this.system.main.simulationSpace===Sh.Local&&this._gravityDirection.applyQuaternion(this.system.worldQuaternionInverted).normalize()}update(t,i){var n;const o=t[Ip],r=t[r1];if(r!==0){const g=r*t[K0];Z0.copy(this._gravityDirection).multiplyScalar(g),t[K0]+=i*.05,o.add(Z0)}t.velocity.copy(o);const l=t.age/t.life;(n=this.system.inheritVelocity)!=null&&n.enabled&&this.system.inheritVelocity.applyCurrent(t.velocity,l,t[jp]);const c=this.system.noise;c.enabled&&c.apply(0,t.position,t.velocity,i,t.age,t.life);const h=this.system.sizeBySpeed;h!=null&&h.enabled&&(t.size=h.evaluate(t.velocity,l,t[jp],t.size));const d=this.system.colorBySpeed;d!=null&&d.enabled&&d.evaluate(t.velocity,t[jp],t.color);const u=this.system.velocityOverLifetime;u.enabled&&u.apply(t,0,t.position,t.velocity,i,t.age,t.life);const p=this.system.limitVelocityOverLifetime;if(p.enabled&&p.apply(t.position,o,t.velocity,t.size,l,i,1),this.system.worldspace){const g=this.system.worldScale;t.velocity.x*=g.x,t.velocity.y*=g.y,t.velocity.z*=g.z}}}const a1=Symbol("colorLerpFactor"),l1=new we(1,1,1,1),ta=new we(1,1,1,1);class $E extends Qo{constructor(){super(...arguments),a(this,"type","NeedleColor")}initialize(t){}_init(t){const i=this.system.renderer.particleMaterial;ta.copy(this.system.main.startColor.evaluate(Math.random())),i!=null&&i.color&&(l1.copy(i.color),ta.multiply(l1)),ta.convertLinearToSRGB(),t.startColor.set(ta.r,ta.g,ta.b,ta.alpha),t.color.copy(t.startColor),t[a1]=Math.random()}update(t,i){if(t.age===0&&this._init(t),this.system.colorOverLifetime.enabled){const n=t.age/t.life,o=this.system.colorOverLifetime.color.evaluate(n,t[a1]);t.color.set(o.r,o.g,o.b,"alpha"in o?o.alpha:1).multiply(t.startColor)}else t.color.copy(t.startColor)}}class qE{constructor(t){a(this,"system"),a(this,"emission"),a(this,"autoDestroy"),a(this,"startLength"),a(this,"emissionBursts"),a(this,"onlyUsedByOther"),a(this,"behaviors",[]),a(this,"rendererEmitterSettings",{startLength:new sO(220),followLocalOrigin:!1}),a(this,"flatWhiteTexture"),a(this,"clonedTexture",{original:void 0,clone:void 0}),this.system=t,this.emission=new BE(this.system)}get anim(){return this.system.textureSheetAnimation}get prewarm(){return!1}get material(){return this.system.renderer.getMaterial(this.system.trails.enabled)}get layers(){return this.system.gameObject.layers}update(){this.emission.update()}get looping(){return this.system.main.loop}get duration(){return this.system.duration}get shape(){return this.system.shape}get startLife(){return new Ap(this.system.main.startLifetime)}get startSpeed(){return new Ap(this.system.main.startSpeed)}get startRotation(){return new Ap(this.system.main.startRotation)}get startSize(){return new Ap(this.system.main.startSize)}get startColor(){return new tO(new iO(1,1,1,1))}get emissionOverTime(){return this.emission}get emissionOverDistance(){return new FE(this.system)}get instancingGeometry(){return this.system.renderer.getMesh(this.system.renderer.renderMode).geometry}get renderMode(){if(this.system.trails.enabled===!0)return wn.Trail;switch(this.system.renderer.renderMode){case $n.Billboard:return wn.BillBoard;case $n.Stretch:return wn.StretchedBillBoard;case $n.HorizontalBillboard:return wn.HorizontalBillBoard;case $n.VerticalBillboard:return wn.VerticalBillBoard;case $n.Mesh:return wn.Mesh}return wn.BillBoard}get speedFactor(){var t;let i=this.system.main.simulationSpeed;return((t=this.system.renderer)==null?void 0:t.renderMode)===$n.Stretch&&(i*=this.system.renderer.velocityScale??1),i}get texture(){const t=this.material;if(t&&t.map){const i=t.map;if(this.clonedTexture.original!==i||!this.clonedTexture.clone){const n=i.clone();n.premultiplyAlpha=!1,n.colorSpace=pr,this.clonedTexture.original=i,this.clonedTexture.clone=n}return this.clonedTexture.clone}return this.flatWhiteTexture||(this.flatWhiteTexture=Zg(new we(1,1,1,1),1)),this.flatWhiteTexture}get startTileIndex(){return new DE(this.system)}get uTileCount(){var t;return this.anim.enabled?(t=this.anim)==null?void 0:t.numTilesX:void 0}get vTileCount(){var t;return this.anim.enabled?(t=this.anim)==null?void 0:t.numTilesY:void 0}get renderOrder(){return 1}get blending(){var t;return((t=this.system.renderer.particleMaterial)==null?void 0:t.blending)??mC}get transparent(){return this.system.renderer.transparent}get worldSpace(){return this.system.main.simulationSpace===Sh.World}}class GE{constructor(){a(this,"burstParticleIndex",0),a(this,"burstParticleCount",0),a(this,"isBursting",!1),a(this,"travelDistance",0),a(this,"previousWorldPos"),a(this,"burstIndex",0),a(this,"burstWaveIndex",0),a(this,"time",0),a(this,"waitEmiting",0)}}const Lp=class extends A{constructor(){super(...arguments),a(this,"_state"),a(this,"colorOverLifetime"),a(this,"main"),a(this,"emission"),a(this,"sizeOverLifetime"),a(this,"shape"),a(this,"noise"),a(this,"trails"),a(this,"velocityOverLifetime"),a(this,"limitVelocityOverLifetime"),a(this,"inheritVelocity"),a(this,"colorBySpeed"),a(this,"textureSheetAnimation"),a(this,"rotationOverLifetime"),a(this,"rotationBySpeed"),a(this,"sizeBySpeed"),a(this,"_cameraScale",1),a(this,"__worldQuaternion",new V),a(this,"_worldQuaternionInverted",new V),a(this,"_worldScale",new x),a(this,"_worldPositionFrame",-1),a(this,"_worldPos",new x),a(this,"_renderer"),a(this,"_batchSystem"),a(this,"_particleSystem"),a(this,"_interface"),a(this,"_container"),a(this,"_time",0),a(this,"_isPlaying",!0),a(this,"_isUsedAsSubsystem",!1),a(this,"_didPreWarm",!1),a(this,"_bursts"),a(this,"_subEmitterSystems"),a(this,"_lastBatchesCount",-1)}play(s=!1){var t;s&&P.foreachComponent(this.gameObject,i=>{i instanceof Lp&&i!==this&&i.play(!1)},!0),this._isPlaying=!0,this._particleSystem&&(this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1),(t=this.emission)==null||t.reset()}pause(s=!0){s&&P.foreachComponent(this.gameObject,t=>{t instanceof Lp&&t!==this&&t.pause(!1)},!0),this._isPlaying=!1}stop(s=!0,t=!1){s&&P.foreachComponent(this.gameObject,i=>{i instanceof Lp&&i!==this&&i.stop(!1,t)},!0),this._isPlaying=!1,this._time=0,t&&this.reset()}reset(){var s;this._time=0,this._particleSystem&&(this._particleSystem.particleNum=0,this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1,(s=this.emission)==null||s.reset())}emit(s){if(this._particleSystem){this.onUpdate(),s=Math.min(s,this.maxParticles-this.currentParticles),this._state||(this._state=new GE),this._state.waitEmiting=s,this._state.time=0;const t=this._particleSystem.emitEnded;this._particleSystem.emitEnded=!1,this._particleSystem.emit(this.deltaTime,this._state,this._particleSystem.emitter.matrixWorld),this._particleSystem.emitEnded=t}}get playOnAwake(){return this.main.playOnAwake}set playOnAwake(s){this.main.playOnAwake=s}get renderer(){return this._renderer}get isPlaying(){return this._isPlaying}get currentParticles(){var s;return((s=this._particleSystem)==null?void 0:s.particleNum)??0}get maxParticles(){return this.main.maxParticles}get time(){return this._time}get duration(){return this.main.duration}get deltaTime(){return this.context.time.deltaTime*this.main.simulationSpeed}get scale(){return this.gameObject.scale.x}get cameraScale(){return this._cameraScale}get container(){return this._container}get worldspace(){return this.main.simulationSpace===Sh.World}get localspace(){return this.main.simulationSpace===Sh.Local}get worldQuaternion(){return this.__worldQuaternion}get worldQuaternionInverted(){return this._worldQuaternionInverted}get worldScale(){return this._worldScale}get worldPos(){return this._worldPositionFrame!==this.context.time.frame&&(this._worldPositionFrame=this.context.time.frame,ee(this.gameObject,this._worldPos)),this._worldPos}get matrixWorld(){return this._container.matrixWorld}get isSubsystem(){return this._isUsedAsSubsystem}addBehaviour(s){return this._particleSystem?(s instanceof Qo&&(s.system=this),(F()||Xo)&&console.debug("Add custom ParticleSystem Behaviour",s),this._particleSystem.addBehavior(s),!0):!1}removeBehaviour(s){if(!this._particleSystem)return!1;const t=this._particleSystem.behaviors,i=t.indexOf(s);return i!==-1&&((F()||Xo)&&console.debug("Remove custom ParticleSystem Behaviour",i,s),t.splice(i,1)),!0}removeAllBehaviours(){return this._particleSystem?(this._particleSystem.behaviors.length=0,!0):!1}get behaviours(){return this._particleSystem?this._particleSystem.behaviors:null}get particleSystem(){return this._particleSystem??null}set bursts(s){for(let t=0;t<s.length;t++){const i=s[t];if(!(i instanceof Oh)){const n=new Oh;La(n,i),s[t]=n}}this._bursts=s}set subEmitterSystems(s){for(let t=0;t<s.length;t++){const i=s[t];if(!(i instanceof Mh)){const n=new Mh;La(n,i),s[t]=n}}Xo&&s.length>0&&console.log("SubEmitters: ",s,this),this._subEmitterSystems=s}onAfterDeserialize(s){if(this._subEmitterSystems&&Array.isArray(this._subEmitterSystems))for(const t of this._subEmitterSystems)t._deserialize(this.context,this.gameObject)}awake(){if(this._worldPositionFrame=-1,this._renderer=this.gameObject.getComponent(os),!this.main)throw new Error("Not Supported: ParticleSystem needs a serialized MainModule. Creating new particle systems at runtime is currently not supported.");this._container=new j,this._container.matrixAutoUpdate=!1,this.context.scene.add(this._container),this._batchSystem=new JC,this._batchSystem.name=this.gameObject.name,this._container.add(this._batchSystem),this._interface=new qE(this),this._particleSystem=new eO(this._interface),this._particleSystem.addBehavior(new WE(this)),this._particleSystem.addBehavior(new $E(this)),this._particleSystem.addBehavior(new zE(this)),this._particleSystem.addBehavior(new UE(this)),this._particleSystem.addBehavior(new HE(this)),this._particleSystem.addBehavior(new VE(this)),this._batchSystem.addSystem(this._particleSystem);const s=this._particleSystem.emitter;this.context.scene.add(s),this.inheritVelocity.system&&this.inheritVelocity.system!==this&&(this.inheritVelocity=this.inheritVelocity.clone()),this.inheritVelocity.awake(this),Xo&&(console.log(this),this.gameObject.add(new bi(1)))}start(){this.addSubParticleSystems(),this.updateLayers(),this.renderer.particleMesh instanceof Q&&this._interface.renderMode==wn.Mesh&&et.assignMeshLOD(this.renderer.particleMesh,0).then(s=>{s&&this.particleSystem&&this._interface.renderMode==wn.Mesh&&(this.particleSystem.instancingGeometry=s)})}onDestroy(){var s,t,i,n;(s=this._container)==null||s.removeFromParent(),(t=this._batchSystem)==null||t.removeFromParent(),(i=this._particleSystem)==null||i.emitter.removeFromParent(),(n=this._particleSystem)==null||n.dispose()}onEnable(){this.main&&(this.inheritVelocity&&(this.inheritVelocity.system=this),this._batchSystem&&(this._batchSystem.visible=!0),this.playOnAwake&&this.play(),this._isPlaying=this.playOnAwake)}onDisable(){this._batchSystem&&(this._batchSystem.visible=!1)}onBeforeRender(){var s;this.main&&(this._didPreWarm===!1&&((s=this.main)==null?void 0:s.prewarm)===!0&&(this._didPreWarm=!0,this.preWarm()),this.onUpdate(),this.onSimulate(this.deltaTime))}preWarm(){var s;if(!((s=this.emission)!=null&&s.enabled)||this.emission.rateOverTime.getMax()<=0)return;const t=1/60,i=this.main.duration,n=this.main.startLifetime.getMax(),o=1e3,r=Math.min(Math.max(i,n)/Math.max(.01,this.main.simulationSpeed),o),l=Math.ceil(r/t),c=Date.now();Xo&&console.log(`Particles ${this.name} - Prewarm for ${l} frames (${r} sec). Duration: ${i}, Lifetime: ${n}`);for(let h=0;h<l&&!(this.currentParticles>=this.maxParticles);h++){const d=Date.now()-c;if(d>2e3){console.warn(`Particles ${this.name} - Prewarm took too long. Aborting: ${d}`);break}this.onUpdate(),this.onSimulate(t)}}onSimulate(s){if(this._batchSystem){let t=this.context.time.frameCount%60===0;this._lastBatchesCount!==this._batchSystem.batches.length&&(this._lastBatchesCount=this._batchSystem.batches.length,t=!0),t&&this.updateLayers(),this._batchSystem.update(s)}this._time+=s,this._time>this.duration&&(this._time=0)}updateLayers(){if(this._batchSystem)for(let s=0;s<this._batchSystem.batches.length;s++){const t=this._batchSystem.batches[s];t.layers.disableAll();const i=this.layer;t.layers.mask=1<<i}}onUpdate(){var s,t;if(this._bursts&&(this.emission.bursts=this._bursts,delete this._bursts),!this._isPlaying)return;const i=this.context.mainCamera;if(i){const r=Ke(i);this._cameraScale=r.x}const n=!this.worldspace,o=this.gameObject;if(Se(o,this.__worldQuaternion),this._worldQuaternionInverted.copy(this.__worldQuaternion).invert(),Ke(this.gameObject,this._worldScale),n&&this._container&&(s=this.gameObject)!=null&&s.parent){const r=c1(this,Z0);this._container.matrix.makeScale(r.x,r.y,r.z),this._container.matrix.makeRotationFromQuaternion(this.__worldQuaternion),this._container.matrix.setPosition(this.worldPos),this._container.matrix.scale(this.gameObject.scale)}this.emission.system=this,this._interface.update(),this.shape.onUpdate(this,this.context,this.main.simulationSpace,this.gameObject),this.noise.update(this.context),(t=this.inheritVelocity)==null||t.update(this.context),this.velocityOverLifetime.update(this)}addSubParticleSystems(){var s;if(this._subEmitterSystems&&this._particleSystem)for(const t of this._subEmitterSystems){t.particleSystem&&(t.particleSystem.__internalAwake?t.particleSystem.__internalAwake():F()&&console.warn("SubParticleSystem serialization issue(?)",t.particleSystem,t));const i=(s=t.particleSystem)==null?void 0:s._particleSystem;if(i){t.particleSystem._isUsedAsSubsystem=!0;const n=new Ep(this,this._particleSystem,t.particleSystem,i);n.emitterType=t.type,n.emitterProbability=t.emitProbability,this._particleSystem.addBehavior(n)}else Xo&&console.warn("Could not add SubParticleSystem",t,this)}}};let at=Lp;Ye([m(Ph)],at.prototype,"colorOverLifetime",2),Ye([m(jt)],at.prototype,"main",2),Ye([m(hn)],at.prototype,"emission",2),Ye([m(qo)],at.prototype,"sizeOverLifetime",2),Ye([m(Xe)],at.prototype,"shape",2),Ye([m(xe)],at.prototype,"noise",2),Ye([m(ze)],at.prototype,"trails",2),Ye([m(Qe)],at.prototype,"velocityOverLifetime",2),Ye([m(rt)],at.prototype,"limitVelocityOverLifetime",2),Ye([m(Go)],at.prototype,"inheritVelocity",2),Ye([m(ea)],at.prototype,"colorBySpeed",2),Ye([m(Lt)],at.prototype,"textureSheetAnimation",2),Ye([m(ns)],at.prototype,"rotationOverLifetime",2),Ye([m(Bi)],at.prototype,"rotationBySpeed",2),Ye([m(si)],at.prototype,"sizeBySpeed",2);class Mh{constructor(){a(this,"particleSystem"),a(this,"emitProbability",1),a(this,"properties"),a(this,"type")}_deserialize(t,i){const n=this.particleSystem;if(n instanceof at)return;let o="";n&&typeof n.guid=="string"&&(o=n.guid,this.particleSystem=P.findByGuid(o,i)),Xo&&!(this.particleSystem instanceof at)&&console.warn("Could not find particle system for sub emitter",o,i,this)}}function c1(s,t){if(t.set(1,1,1),s.gameObject.parent&&s.localspace)switch(s.main.scalingMode){case q0.Local:t=Ke(s.gameObject.parent,t),t.x=1/t.x,t.y=1/t.y,t.z=1/t.z;break;default:if(!s.unsupported_scaling_mode){s.unsupported_scaling_mode=!0;const i="ParticleSystem scale mode "+q0[s.main.scalingMode]+" is not supported";F()&&_e(i),console.warn(i,s.name,s)}t=Ke(s.gameObject,t);break}return t}class Ul extends A{constructor(){super(...arguments),a(this,"_didAssignPlayerColor",!1),a(this,"tryAssignColor",()=>{const t=P.getComponentInParent(this.gameObject,ji);if(t&&t.owner)return this._didAssignPlayerColor=!0,this.assignUserColor(t.owner),!0;const i=P.getComponentInParent(this.gameObject,Rt);return i!=null&&i.connectionId?(this._didAssignPlayerColor=!0,this.assignUserColor(i.connectionId),!0):!1})}onEnable(){this.context.connection.beginListen(ie.JoinedRoom,this.tryAssignColor),this._didAssignPlayerColor||this.startCoroutine(this.waitForConnection())}onDisable(){this.context.connection.stopListen(ie.JoinedRoom,this.tryAssignColor)}*waitForConnection(){for(;!this.destroyed&&this.activeAndEnabled&&(yield H_(.2),!this.tryAssignColor()););}assignUserColor(t){const i=Ul.hashCode(t),n=Ul.colorFromHashCode(i);if(this.gameObject.type==="Mesh"){const o=this.gameObject;this.assignColor(n,t,o)}else if(this.gameObject.children)for(const o of this.gameObject.children){const r=o;r.material&&r.material.color&&this.assignColor(n,t,r)}}assignColor(t,i,n){let o=n.material;o&&(o._playerMaterial!==i&&(o=o.clone(),o._playerMaterial=i,n.material=o),o.color=t)}static hashCode(t){var i=0,n,o;if(t.length===0)return i;for(n=0;n<t.length;n++)o=t.charCodeAt(n),i=(i<<5)-i+o,i|=0;return i}static colorFromHashCode(t){const i=(t&16711680)>>16,n=(t&65280)>>8,o=t&255;return new ae(i/255,n/255,o/255)}}const XE=O("debugpost");let J0=null;function QE(s){J0=s}function h1(s){let t=s.gameObject;for(;t;){for(const i of eu(t))if(i.isPostProcessingManager===!0)return i;t=t.parent}return null}function YE(s){let t=h1(s);if(!t)if(J0){XE&&console.warn("Adding postprocessing manager to the scene.");const i=s.scene;t=ki(i,J0)}else F()&&console.warn("No post processing manager found");return t}var KE=Object.defineProperty,ZE=Object.getOwnPropertyDescriptor,d1=(s,t,i,n)=>{for(var o=n>1?void 0:n?ZE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&KE(t,i,o),o};const JE=O("debugpost");class N{constructor(t){a(this,"isVolumeParameter",!0),a(this,"_isInitialized",!1),a(this,"_active",!0),a(this,"_value"),a(this,"_valueRaw"),a(this,"_defaultValue"),a(this,"valueProcessor"),a(this,"onValueChanged"),t!==void 0&&this.initialize(t)}get isInitialized(){return this._isInitialized}initialize(t){t!==void 0&&(this._value=t,this._defaultValue=t,this._valueRaw=t,this._isInitialized=!0)}get overrideState(){return this._active}set overrideState(t){if(this._active===t)return;this._active=t;const i=t?this._valueRaw:this._defaultValue;this.processValue(i,!0)}get value(){return this._valueRaw}set value(t){this.isInitialized||this.initialize(t),this.processValue(t,!1)}set defaultValue(t){this._defaultValue=t}__init(){this.processValue(this._valueRaw,!0)}processValue(t,i){if(t==null||!i&&this.testIfValueChanged(t)===!1)return;const n=this._value;JE&&typeof n=="number"&&typeof t=="number"&&(n?.toFixed(4),t?.toFixed(4)),!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,t=this._defaultValue,this._valueRaw=t):(this._valueRaw=t,this._active&&this.valueProcessor&&(t=this.valueProcessor(t)),this._value=t),this.onValueChanged&&this.onValueChanged(t,n,this)}testIfValueChanged(t){return this._valueRaw!==t}}d1([m()],N.prototype,"overrideState",1),d1([m()],N.prototype,"value",1);class eA extends Ki{constructor(){super([N])}onSerialize(t,i){}onDeserialize(t,i){const n=i.target,o=i.path;let r;if(n&&o&&(r=n[o]),(typeof r!="object"||typeof r=="object"&&r.isVolumeParameter!==!0)&&(r=new N),typeof t=="object"&&"value"in t){const l=t.value;r.initialize(l),r.overrideState=t.overrideState}else r.value=t;return r}}new eA;var tA=Object.defineProperty,iA=Object.getOwnPropertyDescriptor,sA=(s,t,i,n)=>{for(var o=n>1?void 0:n?iA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&tA(t,i,o),o};const nA=O("debugpost");class lt extends A{constructor(t=void 0){if(super(),a(this,"active",!0),a(this,"_manager",null),a(this,"_result"),a(this,"_postprocessingContext",null),t)for(const i of Object.keys(t)){const n=t[i],o=this[i];o instanceof N?o.initialize(n):o!==void 0&&(this[i]=n)}}get isPostProcessingEffect(){return!0}onEnable(){super.onEnable(),this.onEffectEnabled(),this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){var t;super.onDisable(),(t=this._manager)==null||t.removeEffect(this),this.active=!1}onEffectEnabled(t){var i;t&&t.isPostProcessingManager===!0?this._manager=t:this._manager||(this._manager=YE(this)),(i=this._manager)==null||i.addEffect(this)}init(){}get postprocessingContext(){return this._postprocessingContext}apply(t){var i;return this._postprocessingContext=t,this._result||(this.initParameters(),this._result=(i=this.onCreateEffect)==null?void 0:i.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){nA&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(t=>t.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const t=Object.keys(this);for(const i of t){const n=this[i];n instanceof N&&n.__init()}}onEditorModification(t){const i=t.propertyName;if(this[i]instanceof N){const n=t.value;return this[i].value=n,!0}}}sA([m()],lt.prototype,"active",2);var oA=Object.defineProperty,rA=Object.getOwnPropertyDescriptor,aA=(s,t,i,n)=>{for(var o=n>1?void 0:n?rA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&oA(t,i,o),o};const lA=O("debugpost"),ey={};function rs(s,t){ey[s]=t}function cA(s){return s.__type in ey?ey[s.__type]:(lA&&s.__type&&console.warn("Unknown postprocessing type",s.__type,s),lt)}class Rh{constructor(){a(this,"components",[])}init(){var t;(t=this.components)==null||t.forEach(i=>i.init())}addEffect(t){this.components.push(t)}removeEffect(t){const i=this.components.indexOf(t);i>=0&&this.components.splice(i,1)}}aA([Ha([s=>cA(s),lt])],Rh.prototype,"components",2);var hA=Object.defineProperty,dA=Object.getOwnPropertyDescriptor,uA=(s,t,i,n)=>{for(var o=n>1?void 0:n?dA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&hA(t,i,o),o};class Th extends lt{constructor(){super(...arguments),a(this,"preset",new N(2))}get typeName(){return"Antialiasing"}onCreateEffect(){const t=new D.POSTPROCESSING.MODULE.SMAAEffect({preset:D.POSTPROCESSING.MODULE.SMAAPreset.HIGH,edgeDetectionMode:D.POSTPROCESSING.MODULE.EdgeDetectionMode.DEPTH});return this.preset.onValueChanged=i=>{t.applyPreset(i)},t}}uA([m(N)],Th.prototype,"preset",2),rs("Antialiasing",Th);var pA=Object.defineProperty,mA=Object.getOwnPropertyDescriptor,ty=(s,t,i,n)=>{for(var o=n>1?void 0:n?mA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&pA(t,i,o),o},iy;const u1=(iy=class extends lt{constructor(){super(...arguments),a(this,"threshold",new N(.9)),a(this,"intensity",new N(1)),a(this,"scatter",new N(.3)),a(this,"selectiveBloom")}get typeName(){return"Bloom"}init(){this.threshold.valueProcessor=s=>s,this.intensity.valueProcessor=s=>s,this.scatter.valueProcessor=s=>s}onCreateEffect(){let s;if(this.selectiveBloom==null&&(this.selectiveBloom=u1.useSelectiveBloom),this.selectiveBloom){const t=s=new D.POSTPROCESSING.MODULE.SelectiveBloomEffect(this.context.scene,this.context.mainCamera,{blendFunction:D.POSTPROCESSING.MODULE.BlendFunction.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,radius:.85,intensity:this.intensity.value});t.inverted=!0}else s=new D.POSTPROCESSING.MODULE.BloomEffect({blendFunction:D.POSTPROCESSING.MODULE.BlendFunction.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,radius:.85,intensity:this.intensity.value});return this.intensity.onValueChanged=t=>{s.intensity=t},this.threshold.onValueChanged=t=>{s.luminanceMaterial.threshold=Math.pow(t,2.2)},this.scatter.onValueChanged=t=>{s.luminancePass.enabled=!0,s.luminanceMaterial.smoothing=t,s.mipmapBlurPass&&(s.mipmapBlurPass.radius=vn.lerp(.1,.9,t))},s}},a(iy,"useSelectiveBloom",!1),iy);let ia=u1;ty([m(N)],ia.prototype,"threshold",2),ty([m(N)],ia.prototype,"intensity",2),ty([m(N)],ia.prototype,"scatter",2),rs("Bloom",ia);var gA=Object.defineProperty,fA=Object.getOwnPropertyDescriptor,yA=(s,t,i,n)=>{for(var o=n>1?void 0:n?fA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&gA(t,i,o),o};class Eh extends lt{constructor(){super(...arguments),a(this,"intensity",new N(0))}get typeName(){return"ChromaticAberration"}onCreateEffect(){const t=new D.POSTPROCESSING.MODULE.ChromaticAberrationEffect;return t.offset=new oe(0,0),t.radialModulation=!0,t.modulationOffset=.15,this.intensity.valueProcessor=i=>i*.02,this.intensity.onValueChanged=i=>{t.offset.x=-i,t.offset.y=i},t}}yA([m(N)],Eh.prototype,"intensity",2),rs("ChromaticAberration",Eh);var vA=Object.defineProperty,bA=Object.getOwnPropertyDescriptor,p1=(s,t,i,n)=>{for(var o=n>1?void 0:n?bA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&vA(t,i,o),o};const m1=O("debugpost");var Dp=(s=>(s[s.None=0]="None",s[s.Neutral=1]="Neutral",s[s.ACES=2]="ACES",s[s.AgX=3]="AgX",s[s.KhronosNeutral=4]="KhronosNeutral",s))(Dp||{});function sy(s){switch(s){case 0:return ud;case 1:return bm;case 2:return vm;case 3:return dd;case 4:return $l;default:return $l}}function _A(s){switch(s){case ud:return 0;case vm:return 2;case dd:return 3;case $l:return 1;case bm:return 1;default:return 0}}function g1(s){switch(s){case ud:return D.POSTPROCESSING.MODULE.ToneMappingMode.LINEAR;case vm:return D.POSTPROCESSING.MODULE.ToneMappingMode.ACES_FILMIC;case dd:return D.POSTPROCESSING.MODULE.ToneMappingMode.AGX;case $l:return D.POSTPROCESSING.MODULE.ToneMappingMode.NEUTRAL;case bm:return D.POSTPROCESSING.MODULE.ToneMappingMode.REINHARD;default:return D.POSTPROCESSING.MODULE.ToneMappingMode.LINEAR}}const f1=class extends lt{constructor(){super(...arguments),a(this,"mode",new N(void 0)),a(this,"exposure",new N(1))}get typeName(){return"ToneMapping"}setMode(s){const t=Dp[s];return t===void 0?(console.error("Invalid ToneMapping mode",s),this):(this.mode.value=t,this)}get isToneMapping(){return!0}onEffectEnabled(){const s=h1(this);s&&super.onEffectEnabled(s)}onCreateEffect(){if(this.postprocessingContext)for(const i of this.postprocessingContext.components){if(i===this)break;if(i!=this&&i instanceof f1){console.warn("Multiple tonemapping effects found in the same postprocessing stack: Please check your scene setup.",{activeEffect:i,ignoredEffect:this});return}}if(this.mode.isInitialized==!1){const i=_A(this.context.renderer.toneMapping);this.mode.initialize(i)}const s=sy(this.mode.value),t=new D.POSTPROCESSING.MODULE.ToneMappingEffect({mode:g1(s)});return this.mode.onValueChanged=i=>{const n=sy(i);t.mode=g1(n),m1&&console.log("ToneMapping mode changed to",Dp[i],n,t.mode)},m1&&console.log("Use ToneMapping",Dp[this.mode.value],s,t.mode,"renderer.tonemapping: "+this.context.renderer.toneMapping),this.exposure.onValueChanged=i=>{this.context.renderer.toneMappingExposure=i},t}onBeforeRender(){this.mode.overrideState&&(this.context.renderer.toneMapping=sy(this.mode.value)),this.exposure.overrideState&&(this.context.renderer.toneMappingExposure=this.exposure.value)}};let Yo=f1;p1([m(N)],Yo.prototype,"mode",2),p1([m(N)],Yo.prototype,"exposure",2),rs("Tonemapping",Yo);var wA=Object.defineProperty,xA=Object.getOwnPropertyDescriptor,Bp=(s,t,i,n)=>{for(var o=n>1?void 0:n?xA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&wA(t,i,o),o};class Ko extends lt{constructor(){super(...arguments),a(this,"postExposure",new N(0)),a(this,"contrast",new N(0)),a(this,"hueShift",new N(0)),a(this,"saturation",new N(0))}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=t=>(t=Math.pow(2,t),t),this.contrast.valueProcessor=t=>{let i=1;return t>0?i=200:t<0&&(i=100),t/i},this.contrast.defaultValue=0,this.hueShift.valueProcessor=t=>Math.PI*t/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=t=>t<0?t/100:t/(100*Math.PI),this.saturation.defaultValue=0}onCreateEffect(){var t,i;const n=[];this.context.renderer.toneMapping!==_a&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=_a);let o=(t=this.postprocessingContext)==null?void 0:t.components.find(c=>c instanceof Yo);o||(o=new Yo,(i=this.postprocessingContext)==null||i.components.push(o)),this.postExposure.onValueChanged=c=>{this.postExposure.overrideState&&(o.exposure.value=c)};const r=new D.POSTPROCESSING.MODULE.BrightnessContrastEffect;this.contrast.onValueChanged=c=>r.contrast=c;const l=new D.POSTPROCESSING.MODULE.HueSaturationEffect;return n.push(r),n.push(l),this.hueShift.onValueChanged=c=>l.hue=c,this.saturation.onValueChanged=c=>l.saturation=c,n}}Bp([m(N)],Ko.prototype,"postExposure",2),Bp([m(N)],Ko.prototype,"contrast",2),Bp([m(N)],Ko.prototype,"hueShift",2),Bp([m(N)],Ko.prototype,"saturation",2),rs("ColorAdjustments",Ko);var SA=Object.defineProperty,CA=Object.getOwnPropertyDescriptor,sa=(s,t,i,n)=>{for(var o=n>1?void 0:n?CA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&SA(t,i,o),o};const OA=O("debugpost");class Ts extends lt{constructor(){super(...arguments),a(this,"mode"),a(this,"focusDistance",new N(1)),a(this,"focalLength",new N(.2)),a(this,"aperture",new N(20)),a(this,"gaussianMaxRadius",new N),a(this,"resolutionScale",new N(1*1/window.devicePixelRatio)),a(this,"bokehScale",new N)}get typeName(){return"DepthOfField"}init(){this.focalLength.valueProcessor=i=>{const n=i/300,o=2;return W.lerp(o,.01,n)};const t=20;this.aperture.valueProcessor=i=>{const n=1-i/32;return W.lerp(1,t,n)}}onCreateEffect(){if(this.mode===0){OA&&console.warn("DepthOfField: Mode is set to Off");return}const t=new D.POSTPROCESSING.MODULE.DepthOfFieldEffect(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=i=>{t.cocMaterial.worldFocusDistance=i},this.focalLength.onValueChanged=i=>t.cocMaterial.worldFocusRange=i,this.aperture.onValueChanged=i=>t.bokehScale=i,this.resolutionScale&&(this.resolutionScale.onValueChanged=i=>t.resolution.scale=i),[t]}unapply(){}}sa([m()],Ts.prototype,"mode",2),sa([m(N)],Ts.prototype,"focusDistance",2),sa([m(N)],Ts.prototype,"focalLength",2),sa([m(N)],Ts.prototype,"aperture",2),sa([m(N)],Ts.prototype,"gaussianMaxRadius",2),sa([m(N)],Ts.prototype,"resolutionScale",2),sa([m(N)],Ts.prototype,"bokehScale",2),rs("DepthOfField",Ts);class Ah extends lt{constructor(t){super(),a(this,"effect"),this.effect=t}get typeName(){return this.effect.constructor.name}onCreateEffect(){return this.effect}}var PA=Object.defineProperty,kA=Object.getOwnPropertyDescriptor,MA=(s,t,i,n)=>{for(var o=n>1?void 0:n?kA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&PA(t,i,o),o};class Ih extends lt{constructor(){super(...arguments),a(this,"granularity",new N(10))}get typeName(){return"PixelationEffect"}onCreateEffect(){const t=new D.POSTPROCESSING.MODULE.PixelationEffect;return this.granularity.onValueChanged=i=>{t.granularity=i},t}}MA([m(N)],Ih.prototype,"granularity",2),rs("PixelationEffect",Ih);var RA=Object.defineProperty,TA=Object.getOwnPropertyDescriptor,jh=(s,t,i,n)=>{for(var o=n>1?void 0:n?TA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&RA(t,i,o),o};class qn extends lt{constructor(){super(...arguments),a(this,"intensity",new N(2)),a(this,"falloff",new N(1)),a(this,"samples",new N(9)),a(this,"color",new N(new ae(0,0,0))),a(this,"luminanceInfluence",new N(.7)),a(this,"_ssao")}get typeName(){return"ScreenSpaceAmbientOcclusion"}onBeforeRender(){if(this._ssao&&this.context.mainCamera instanceof be){const t=this.context.mainCamera.far-this.context.mainCamera.near;this._ssao.ssaoMaterial.worldDistanceFalloff=t*.01,this._ssao.ssaoMaterial.worldDistanceThreshold=this.context.mainCamera.far}}onCreateEffect(){const t=this.context.mainCamera,i=new D.POSTPROCESSING.MODULE.NormalPass(this.context.scene,t),n=new D.POSTPROCESSING.MODULE.DepthDownsamplingPass({normalBuffer:i.texture,resolutionScale:.5}),o=this._ssao=new D.POSTPROCESSING.MODULE.SSAOEffect(t,i.texture,{normalDepthBuffer:n.texture,worldDistanceThreshold:1,worldDistanceFalloff:1,worldProximityThreshold:.1,worldProximityFalloff:2,intensity:1,blendFunction:D.POSTPROCESSING.MODULE.BlendFunction.MULTIPLY,luminanceInfluence:.5});this.intensity.onValueChanged=l=>{o.intensity=l},this.falloff.onValueChanged=l=>{o.ssaoMaterial.radius=l*.1},this.samples.onValueChanged=l=>{o.ssaoMaterial.samples=l},this.color.onValueChanged=l=>{o.color||(o.color=new ae),o.color.copy(l)},this.luminanceInfluence.onValueChanged=l=>{o.luminanceInfluence=l};const r=new Array;return r.push(i),r.push(n),r.push(o),r}}jh([m(N)],qn.prototype,"intensity",2),jh([m(N)],qn.prototype,"falloff",2),jh([m(N)],qn.prototype,"samples",2),jh([m(N)],qn.prototype,"color",2),jh([m(N)],qn.prototype,"luminanceInfluence",2),rs("ScreenSpaceAmbientOcclusion",qn);var EA=Object.defineProperty,AA=Object.getOwnPropertyDescriptor,na=(s,t,i,n)=>{for(var o=n>1?void 0:n?AA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&EA(t,i,o),o},ny=(s=>(s[s.Performance=0]="Performance",s[s.Low=1]="Low",s[s.Medium=2]="Medium",s[s.High=3]="High",s[s.Ultra=4]="Ultra",s))(ny||{});class Es extends lt{constructor(){super(...arguments),a(this,"gammaCorrection",!0),a(this,"aoRadius",new N(1)),a(this,"falloff",new N(1)),a(this,"intensity",new N(1)),a(this,"color",new N(new ae(0,0,0))),a(this,"screenspaceRadius",!1),a(this,"quality",2),a(this,"_ssao")}get typeName(){return"ScreenSpaceAmbientOcclusionN8"}onValidate(){this._ssao&&(this._ssao.setQualityMode(ny[this.quality]),this._ssao.configuration.gammaCorrection=this.gammaCorrection,this._ssao.configuration.screenSpaceRadius=this.screenspaceRadius)}onCreateEffect(){const t=this.context.mainCamera,i=this._ssao=new D.POSTPROCESSING_AO.MODULE.N8AOPostPass(this.context.scene,t,this.context.domWidth,this.context.domHeight),n=ny[this.quality];i.setQualityMode(n),i.configuration.gammaCorrection=this.gammaCorrection,i.configuration.screenSpaceRadius=this.screenspaceRadius,this.intensity.onValueChanged=r=>{i.configuration.intensity=r},this.falloff.onValueChanged=r=>{i.configuration.distanceFalloff=r},this.aoRadius.onValueChanged=r=>{i.configuration.aoRadius=r},this.color.onValueChanged=r=>{i.color||(i.color=new ae),i.configuration.color.copy(r)};const o=new Array;return o.push(i),o}}na([Mt(),m()],Es.prototype,"gammaCorrection",2),na([m(N)],Es.prototype,"aoRadius",2),na([m(N)],Es.prototype,"falloff",2),na([m(N)],Es.prototype,"intensity",2),na([m(N)],Es.prototype,"color",2),na([Mt(),m()],Es.prototype,"screenspaceRadius",2),na([Mt(),m()],Es.prototype,"quality",2),rs("ScreenSpaceAmbientOcclusionN8",Es);var IA=Object.defineProperty,jA=Object.getOwnPropertyDescriptor,y1=(s,t,i,n)=>{for(var o=n>1?void 0:n?jA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&IA(t,i,o),o};class Lh extends lt{constructor(){super(...arguments),a(this,"_effect"),a(this,"_amount",1),a(this,"_radius",1)}get typeName(){return"Sharpening"}onCreateEffect(){return this._effect??(this._effect=new(LA())),this.effect}get effect(){return this._effect}set amount(t){this._amount=t,this._effect&&(this._effect.uniforms.get("amount").value=t)}get amount(){return this._effect?this._effect.uniforms.get("amount").value:this._amount}set radius(t){this._radius=t,this._effect&&(this._effect.uniforms.get("radius").value=t)}get radius(){return this._effect?this._effect.uniforms.get("radius").value:this._radius}}y1([m()],Lh.prototype,"amount",1),y1([m()],Lh.prototype,"radius",1);function LA(){const s=`
|
|
1201
|
+
`)}l&&console.log(p);const f=new Set;for(const w of y){w.getPath||console.error("USDZExporter: Animation target object has no getPath method. This is likely a bug",w);let _=w.getPath();_.startsWith("<")&&(_=_.substring(1)),_.endsWith(">")&&(_=_.substring(0,_.length-1)),f.add({path:_,obj:w})}const v=Array.from(f).sort((w,_)=>w.path.length-_.path.length),b=new Array;for(let w=0;w<v.length;w++)for(let _=w+1;_<v.length;_++)if(v[_].path.startsWith(v[w].path)){const C=v[_],R=v[w];b.push({child:C.obj.displayName+" ("+C.path+")",parent:R.obj.displayName+" ("+R.path+")"})}b.length&&console.warn("USDZExporter: There are overlapping PlayAnimation actions. This can lead to undefined runtime behaviour when playing multiple animations. Please restructure the hierarchy so that animations don't overlap.",{overlappingTargets:b,playAnimationActions:r})}for(const p of new Set([...i,...n]))if(Array.isArray(p))for(const g of p)o.add(g.uuid);else o.add(p.uuid);cp&&console.log("All Behavior trigger sources and action targets",i,n,o),this.targetUuids=new Set(o)}onAfterHierarchy(t,i){var n;if((n=this.behaviours)!=null&&n.length){i.beginBlock('def Scope "Behaviors"');for(const o of this.behaviours)o.writeTo(this,t.document,i);i.closeBlock()}}async onAfterSerialize(t){cp&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const i of this.behaviourComponentsCopy)typeof i.afterSerialize=="function"&&(i.afterSerialize.constructor.name==="AsyncFunction"?await i.afterSerialize(this,t):i.afterSerialize(this,t));for(const{clipUrl:i,filesKey:n}of this.audioClipsCopy){if(t.files[n])return;const o=await(await(await fetch(i)).blob()).arrayBuffer(),r=new Uint8Array(o);t.files[n]=r}this.behaviourComponentsCopy.length=0,this.audioClipsCopy.length=0}}var pT=Object.defineProperty,mT=Object.getOwnPropertyDescriptor,$e=(s,t,i,n)=>{for(var o=n>1?void 0:n?mT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&pT(t,i,o),o};const zx=O("debugusdzbehaviours");function rh(s){s&&(s.getComponentInParent(zc)||(F()&&console.debug('Raycaster on "'+s.name+'" was automatically added, because no raycaster was found in the parent hierarchy.'),s.addComponent(Ti)))}class $r extends A{constructor(){super(...arguments),a(this,"object"),a(this,"target"),a(this,"duration",1),a(this,"relativeMotion",!1),a(this,"coroutine",null),a(this,"targetPos",new x),a(this,"targetRot",new V),a(this,"targetScale",new x)}start(){rh(this.gameObject)}onPointerClick(t){t.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}*moveToTarget(){if(!this.target||!this.object)return;const t=ee(this.object).clone(),i=ee(this.target).clone(),n=Se(this.object).clone(),o=Se(this.target).clone(),r=Ke(this.object).clone(),l=Ke(this.target).clone(),c=t.distanceTo(i),h=n.angleTo(o),d=r.distanceTo(l);if(c<.01&&h<.01&&d<.01){ct(this.object,i),qi(this.object,o),Oa(this.object,l),this.coroutine=null;return}let u=0,p=0;for(;u<1;)u+=this.context.time.deltaTime/this.duration,u>1&&(u=1),p=u<.5?4*u*u*u:1-Math.pow(-2*u+2,3)/2,this.targetPos.lerpVectors(t,i,p),this.targetRot.slerpQuaternions(n,o,p),this.targetScale.lerpVectors(r,l,p),ct(this.object,this.targetPos),qi(this.object,this.targetRot),Oa(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const t=this.object.position.clone(),i=this.object.quaternion.clone(),n=this.object.scale.clone(),o=this.target.position.clone(),r=this.target.quaternion.clone(),l=this.target.scale.clone();o.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(o),this.targetRot.copy(this.object.quaternion).multiply(r),this.targetScale.copy(this.object.scale).multiply(l);let c=0,h=0;for(;c<1;)c+=this.context.time.deltaTime/this.duration,c>1&&(c=1),h=c<.5?4*c*c*c:1-Math.pow(-2*c+2,3)/2,this.object.position.lerpVectors(t,this.targetPos,h),this.object.quaternion.slerpQuaternions(i,this.targetRot,h),this.object.scale.lerpVectors(n,this.targetScale,h),yield;this.coroutine=null}beforeCreateDocument(t){var i;if(this.target&&this.object&&this.gameObject){const n=new _t("Move to "+((i=this.target)==null?void 0:i.name),wt.tapTrigger(this.gameObject),ue.transformAction(this.object,this.target,this.duration,this.relativeMotion?"relative":"absolute"));t.addBehavior(n)}}}$e([m(j)],$r.prototype,"object",2),$e([m(j)],$r.prototype,"target",2),$e([m()],$r.prototype,"duration",2),$e([m()],$r.prototype,"relativeMotion",2);var dp;const sn=(dp=class extends A{constructor(){super(...arguments),a(this,"materialToSwitch"),a(this,"variantMaterial"),a(this,"fadeDuration",0),a(this,"_objectsWithThisMaterial",null),a(this,"selfModel"),a(this,"targetModels")}start(){var s;this._objectsWithThisMaterial=this.objectsWithThisMaterial,rh(this.gameObject),F()&&this._objectsWithThisMaterial.length<=0&&console.warn('ChangeMaterialOnClick: No objects found with material "'+((s=this.materialToSwitch)==null?void 0:s.name)+'"')}onPointerEnter(s){this.context.input.setCursorPointer()}onPointerExit(s){this.context.input.setCursorNormal()}onPointerClick(s){if(s.use(),!!this.variantMaterial)for(let t=0;t<this.objectsWithThisMaterial.length;t++){const i=this.objectsWithThisMaterial[t];i.material=this.variantMaterial}}get objectsWithThisMaterial(){return this._objectsWithThisMaterial!=null?this._objectsWithThisMaterial:(this._objectsWithThisMaterial=[],this.variantMaterial&&this.materialToSwitch&&this.context.scene.traverse(s=>{if(s instanceof Q)if(Array.isArray(s.material)){for(const t of s.material)if(t===this.materialToSwitch){this.objectsWithThisMaterial.push(s);break}}else s.material===this.materialToSwitch?this.objectsWithThisMaterial.push(s):g_(s.material,this.materialToSwitch)&&this.objectsWithThisMaterial.push(s)}),this._objectsWithThisMaterial)}async beforeCreateDocument(s,t){this.targetModels=[],sn._materialTriggersPerId={},sn.variantSwitchIndex=0,this.materialToSwitch&&await et.assignTextureLOD(this.materialToSwitch,0),this.variantMaterial&&await et.assignTextureLOD(this.variantMaterial,0)}createBehaviours(s,t,i){this.objectsWithThisMaterial.find(n=>n.uuid===t.uuid)&&this.targetModels.push(t),this.gameObject.uuid===t.uuid&&(this.selfModel=t,this.materialToSwitch&&(sn._materialTriggersPerId[this.materialToSwitch.uuid]||(sn._materialTriggersPerId[this.materialToSwitch.uuid]=[]),sn._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(s,t){if(!this.materialToSwitch)return;const i=sn._materialTriggersPerId[this.materialToSwitch.uuid];if(i){const n={};for(const o of i){const r=o.createVariants();r&&r.length>0&&(n[o.selfModel.uuid]=r)}for(const o of i){const r=[];for(const l in n)l!==o.selfModel.uuid&&r.push(...n[l]);o.createAndAttachBehaviors(s,n[o.selfModel.uuid],r)}}delete sn._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(s,t,i){const n=[],o=[],r=Math.max(0,this.fadeDuration);o.push(ue.fadeAction([...this.targetModels,...i],r,!1)),n.push(ue.fadeAction(t,r,!1)),o.push(ue.fadeAction(t,r,!0)),s.addBehavior(new _t("Select_"+this.selfModel.name,wt.tapTrigger(this.selfModel),ue.parallel(...o))),s.addBehavior(new _t("StartHidden_"+this.selfModel.name,wt.sceneStartTrigger(),ue.parallel(...n)))}static getMaterialName(s){return Ms(s.name||"Material")+"_"+s.id}createVariants(){if(!this.variantMaterial)return null;const s=[];for(const t of this.targetModels){const i=t.clone();i.name+="_Variant_"+sn.variantSwitchIndex+++"_"+sn.getMaterialName(this.variantMaterial),i.displayName=i.displayName+": Variant with material "+this.variantMaterial.name,i.material=this.variantMaterial,i.geometry=t.geometry,i.transform=t.transform,(!t.parent||!t.parent.isEmpty())&&Zt.createEmptyParent(t),t.parent&&t.parent.add(i),s.push(i)}return s}},a(dp,"_materialTriggersPerId",{}),a(dp,"variantSwitchIndex",0),dp);let ml=sn;$e([m(Oe)],ml.prototype,"materialToSwitch",2),$e([m(Oe)],ml.prototype,"variantMaterial",2),$e([m()],ml.prototype,"fadeDuration",2);var gl;const qe=(gl=class extends A{constructor(){super(...arguments),a(this,"target"),a(this,"toggleOnClick",!1),a(this,"targetState",!0),a(this,"hideSelf",!0),a(this,"selfModel"),a(this,"selfModelClone"),a(this,"targetModel"),a(this,"toggleModel"),a(this,"stateBeforeCreatingDocument",!1),a(this,"targetStateBeforeCreatingDocument",!1)}start(){rh(this.gameObject)}onPointerClick(s){s.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(s,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t,this.selfModelClone=t.clone())}beforeCreateDocument(){this.target&&(this.gameObject[qe.wasVisible]===void 0&&(this.gameObject[qe.wasVisible]=this.gameObject.activeSelf),this.target[qe.wasVisible]===void 0&&(this.target[qe.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[qe.wasVisible],this.targetStateBeforeCreatingDocument=this.target[qe.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(s,t){if(!this.target)return;this.targetModel=t.document.findById(this.target.uuid);const i=this.selfModel;if(this.selfModel&&this.targetModel){let n=this.selfModel,o=this.targetState;if(this.toggleOnClick)if(o=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&Jf.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[qe.toggleClone]){const c=this.selfModelClone.clone();c.setMatrix(new ne),c.name+="_toggle"+qe.clonedToggleIndex++,i.add(c),this.gameObject[qe.toggleClone]=c,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const l=this.gameObject[qe.toggleClone];if(!this.gameObject[qe.reverseToggleClone]){const c=this.selfModelClone.clone();c.setMatrix(new ne),c.name+="_toggleReverse"+qe.clonedToggleIndex++,i.add(c),this.gameObject[qe.reverseToggleClone]=c}this.toggleModel=this.gameObject[qe.reverseToggleClone],(!this.toggleModel.geometry||!l.geometry)&&console.error("triggers without childs and without geometry won't work!",this,i.geometry),n=l,i.geometry=null,i.material=null}if(this.toggleModel){if(this.toggleOnClick){const l=[];l.push(ue.fadeAction(n,0,!1)),l.push(ue.fadeAction(this.toggleModel,0,!0)),l.push(ue.fadeAction(this.targetModel,0,o)),s.addBehavior(new _t("Toggle_"+n.name+"_toggleTo"+(o?"On":"Off"),wt.tapTrigger(n),ue.parallel(...l)));const c=[];c.push(ue.fadeAction(this.toggleModel,0,!1)),c.push(ue.fadeAction(n,0,!0)),c.push(ue.fadeAction(this.targetModel,0,!o)),s.addBehavior(new _t("Toggle_"+n.name+"_toggleTo"+(o?"Off":"On"),wt.tapTrigger(this.toggleModel),ue.parallel(...c)))}}else{const l=[];this.hideSelf&&l.push(ue.fadeAction(n,0,!1)),l.push(ue.fadeAction(this.targetModel,0,o)),s.addBehavior(new _t("Toggle_"+n.name+"_toggleTo"+(o?"On":"Off"),wt.tapTrigger(n),ue.parallel(...l)))}const r=new Array;this.targetStateBeforeCreatingDocument||r.push(this.targetModel),this.stateBeforeCreatingDocument||r.push(i),this.toggleModel&&r.push(this.toggleModel),s.addBehavior(new _t("HideOnStart_"+this.gameObject.name,wt.sceneStartTrigger(),ue.fadeAction(r,0,!1)))}}afterSerialize(s,t){this.gameObject[qe.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[qe.wasVisible],delete this.gameObject[qe.wasVisible]),this.target&&this.target[qe.wasVisible]!==void 0&&(this.target.visible=this.target[qe.wasVisible],delete this.target[qe.wasVisible]),delete this.gameObject[qe.toggleClone],delete this.gameObject[qe.reverseToggleClone]}},a(gl,"clonedToggleIndex",0),a(gl,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),a(gl,"toggleClone",Symbol("clone for toggling")),a(gl,"reverseToggleClone",Symbol("clone for reverse toggling")),gl);let qr=qe;$e([m(j)],qr.prototype,"target",2),$e([m()],qr.prototype,"toggleOnClick",2),$e([m()],qr.prototype,"targetState",2),$e([m()],qr.prototype,"hideSelf",2);class u0 extends A{constructor(){super(...arguments),a(this,"wasVisible",!1)}start(){P.setActive(this.gameObject,!1)}createBehaviours(t,i,n){i.uuid===this.gameObject.uuid&&(this.wasVisible||t.addBehavior(new _t("HideOnStart_"+this.gameObject.name,wt.sceneStartTrigger(),ue.fadeAction(i,0,!1))))}beforeCreateDocument(){this.wasVisible=P.isActiveSelf(this.gameObject)}}class fl extends A{constructor(){super(...arguments),a(this,"target"),a(this,"duration",.5),a(this,"motionType","bounce")}beforeCreateDocument(){}createBehaviours(t,i,n){if(this.target&&i.uuid===this.gameObject.uuid){const o=new _t("emphasize "+this.name,wt.tapTrigger(this.gameObject),ue.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));t.addBehavior(o)}}afterCreateDocument(t,i){}}$e([m()],fl.prototype,"target",2),$e([m()],fl.prototype,"duration",2),$e([m()],fl.prototype,"motionType",2);class Io extends A{constructor(){super(...arguments),a(this,"target"),a(this,"clip",""),a(this,"toggleOnClick",!1),a(this,"trigger","tap")}start(){rh(this.gameObject)}ensureAudioSource(){if(!this.target){const t=this.gameObject.addComponent(We);t&&(this.target=t,t.spatialBlend=1,t.volume=1,t.loop=!1,t.preload=!0)}}onPointerClick(t){var i;t.use(),!(!((i=this.target)!=null&&i.clip)&&!this.clip)&&(this.ensureAudioSource(),this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play())))}createBehaviours(t,i,n){if(!(!this.target&&!this.clip)&&i.uuid===this.gameObject.uuid){const o=this.clip?this.clip:this.target?this.target.clip:void 0;if(!o||typeof o!="string")return;const r=this.target?this.target.gameObject:this.gameObject;lr.getName(o);const l=this.target?this.target.volume:1,c=this.target&&this.target.spatialBlend==0?"nonSpatial":"spatial";let h=!1;this.gameObject.traverse(g=>{g instanceof Q&&g.visible&&(h=!0)}),h=!0;const d=t.addAudioClip(o);let u=ue.playAudioAction(r,d,"play",l,c);this.target&&this.target.loop&&(u=ue.sequence(u).makeLooping());const p=this.name?"_"+this.name:"";if(h&&this.trigger==="tap"){this.toggleOnClick&&(u.multiplePerformOperation="stop");const g=new _t("playAudio"+p,wt.tapTrigger(i),u);t.addBehavior(g)}if(this.target&&this.target.playOnAwake&&this.target.enabled)if(h&&this.trigger==="tap")console.warn("USDZExport: Audio sources that are played on tap can't also auto-play at scene start due to a QuickLook bug.");else{const g=new _t("playAudioOnStart"+p,wt.sceneStartTrigger(),u);t.addBehavior(g)}}}}$e([m(We)],Io.prototype,"target",2),$e([m(URL)],Io.prototype,"clip",2),$e([m()],Io.prototype,"toggleOnClick",2);var up;const nn=(up=class extends A{constructor(){super(...arguments),a(this,"animator"),a(this,"stateName"),a(this,"trigger","tap"),a(this,"animation"),a(this,"selfModel"),a(this,"stateAnimationModel"),a(this,"animationSequence",new Array),a(this,"animationLoopAfterSequence",new Array),a(this,"randomOffsetNormalized",0)}get target(){var s,t;return((s=this.animator)==null?void 0:s.gameObject)||((t=this.animation)==null?void 0:t.gameObject)}start(){rh(this.gameObject)}onPointerClick(s){var t;s.use(),this.target&&this.stateName&&((t=this.animator)==null||t.play(this.stateName,0,0,.1))}createBehaviours(s,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}afterSerialize(){if(nn.rootsWithExclusivePlayback.size>1){const s='Multiple root objects targeted by more than one animation. To work around QuickLook bug FB13410767, animations will be set as "exclusive" and activating them will stop other animations being marked as exclusive.';F()&&_e(s),console.warn(s,...nn.rootsWithExclusivePlayback)}nn.animationActions=[],nn.rootsWithExclusivePlayback=new Set}afterCreateDocument(s,t){if(this.animationSequence===void 0&&this.animationLoopAfterSequence===void 0||!this.stateAnimationModel||!this.target)return;const i=t.document,n=t.extensions.find(l=>l instanceof oh);if(!n)return;const o=n.getClipCount(this.target)>1;o&&(F()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+n.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),nn.rootsWithExclusivePlayback.add(this.target));const r=this.name?this.name:"";i.traverse(l=>{var c,h;if(l.uuid===((c=this.target)==null?void 0:c.uuid)){const d=nn.getActionForSequences(i,l,this.animationSequence,this.animationLoopAfterSequence,this.randomOffsetNormalized),u=new _t(this.trigger+"_"+r+"_toPlayAnimation_"+this.stateName+"_on_"+((h=this.target)==null?void 0:h.name),this.trigger=="tap"?wt.tapTrigger(this.selfModel):wt.sceneStartTrigger(),d);o&&u.makeExclusive(!0),s.addBehavior(u)}})}static getActionForSequences(s,t,i,n,o){const r=(c,h)=>{let d=nn.animationActions.find(u=>u.affectedObjects==c&&u.start==h.start&&u.duration==h.duration&&u.animationSpeed==h.speed);return d||(d=ue.startAnimationAction(c,h),nn.animationActions.push(d)),d},l=ue.sequence();if(i&&i.length>0)for(const c of i)l.addAction(r(t,c));if(n&&n.length>0){const c=l.actions.length==0?l:ue.sequence();for(const h of n)c.addAction(r(t,h));c.makeLooping(),l!==c&&l.addAction(c)}return o&&o>0&&l.actions.unshift(ue.waitAction(o)),l}static getAndRegisterAnimationSequences(s,t,i){var n,o,r,l,c,h,d,u;if(!t)return;const p=t.getComponent(kt),g=t.getComponent(Ut);if(!p&&!g)return;if(p&&!i)throw new Error("PlayAnimationOnClick: No stateName specified for animator "+p.name+" on "+t.name);let y=[],f=[];if(g){const M=s.registerAnimation(t,g.clip);M&&(g.loop?f.push(M):y.push(M));let E=0;if(g.minMaxOffsetNormalized){const B=g.minMaxOffsetNormalized.x,L=g.minMaxOffsetNormalized.y;E=(((n=g.clip)==null?void 0:n.duration)||1)*(B+Math.random()*(L-B))}return{animationSequence:y,animationLoopAfterSequence:f,randomTimeOffset:E}}const v=p?.runtimeAnimatorController;let b=v?.findState(i),w=[],_=[];if(v&&b){const M=new Array;M.push(b);let E=!1;for(;M.length<100;){if(!b||b===null||!b.transitions||b.transitions.length===0){(o=b.motion)!=null&&o.isLooping&&(E=!0);break}const B=b.transitions.find(U=>U.conditions.length===0),L=B?v.getState(B.destinationState,0):null;if(L&&M.includes(L)){b=L,E=!0;break}else if(B){if(b=L,!b)break;M.push(b)}else{E=((r=b.motion)==null?void 0:r.isLooping)??!1;break}}if(E&&b){const B=M.indexOf(b);w=M.slice(0,B),_=M.slice(B),zx&&console.log("found loop from "+i,"states until loop",w,"states looping",_)}else w=M,_=[],zx&&console.log("found no loop from "+i,"states",w);if(!_.length){const B=w[w.length-1],L=(l=B.motion)==null?void 0:l.clip;if(L){let U;if(s.holdClipMap.has(L))U=s.holdClipMap.get(L);else{const z=B.name+"_hold";U=L.clone(),U.duration=1,U.name=z;const H=L.duration;U.tracks=L.tracks.map(T=>{const I=T.clone();I.times=new Float32Array([0,H]);const G=T.values.length,J=T.getValueSize(),se=T.values.slice(G-J,G);return I.values=new Float32Array(2*J),I.values.set(se,0),I.values.set(se,J),I}),U.name=z,s.holdClipMap.set(L,U)}if(U){const z={name:U.name,motion:{clip:U,isLooping:!1,name:U.name},speed:1,transitions:[],behaviours:[],hash:B.hash+1};_.push(z)}}}}if(w.length===1&&(!((c=w[0].motion)!=null&&c.clip)||((d=(h=w[0].motion)==null?void 0:h.clip.tracks)==null?void 0:d.length)===0)){y=new Array;const M=s.registerAnimation(t,null);M&&y.push(M);return}if(w=w.filter(M=>{var E,B,L;return((E=M.motion)==null?void 0:E.clip)&&((L=(B=M.motion)==null?void 0:B.clip.tracks)==null?void 0:L.length)>0}),_=_.filter(M=>{var E,B,L;return((E=M.motion)==null?void 0:E.clip)&&((L=(B=M.motion)==null?void 0:B.clip.tracks)==null?void 0:L.length)>0}),w.length===0&&_.length===0){console.warn("No clips found for state "+i+" on "+p?.name+", can't export animation data");return}const C=(M,E)=>{if(!t)return;const B=s.registerAnimation(t,M.motion.clip??null);B?(B.speed=M.speed,E.push(B)):console.warn("Couldn't register animation for state "+M.name+" on "+p?.name)};if(w.length>0){y=new Array;for(const M of w)C(M,y)}if(_.length>0){f=new Array;for(const M of _)C(M,f)}let R=0;if(p&&v&&p.minMaxOffsetNormalized){const M=p.minMaxOffsetNormalized.x,E=p.minMaxOffsetNormalized.y,B=w.length?w[0]:_.length?_[0]:null;R=(((u=B?.motion.clip)==null?void 0:u.duration)||1)*(M+Math.random()*(E-M))}return{animationSequence:y,animationLoopAfterSequence:f,randomTimeOffset:R}}createAnimation(s,t,i){if(!this.target||!this.animator&&!this.animation)return;const n=nn.getAndRegisterAnimationSequences(s,this.target,this.stateName);n&&(this.animationSequence=n.animationSequence,this.animationLoopAfterSequence=n.animationLoopAfterSequence,this.randomOffsetNormalized=n.randomTimeOffset,this.stateAnimationModel=t)}},a(up,"animationActions",[]),a(up,"rootsWithExclusivePlayback",new Set),up);let Gr=nn;$e([m(kt)],Gr.prototype,"animator",2),$e([m()],Gr.prototype,"stateName",2);class yl extends A{constructor(){super(...arguments),a(this,"target")}getType(){}getDuration(){}}$e([m(j)],yl.prototype,"target",2);class ah extends A{constructor(){super(...arguments),a(this,"target")}}$e([m(yl)],ah.prototype,"target",2);class lh extends yl{constructor(){super(...arguments),a(this,"type",1),a(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}$e([m()],lh.prototype,"type",2),$e([m()],lh.prototype,"duration",2);class p0 extends ah{}class pp{get extensionName(){return"Physics"}onExportObject(t,i,n){const o=P.getComponents(t,ye).filter(h=>h.enabled),r=P.getComponents(t,hi).filter(h=>h.enabled&&!h.isTrigger);let l=o.length>0?o[0]:null;const c=r.length>0?r[0]:null;c&&!l&&(l=new ye,l.isKinematic=!0),l&&i.addEventListener("serialize",(h,d)=>{var u,p,g;if(l){if(h.appendLine(),h.beginBlock('def RealityKitComponent "RigidBody"',"{",!0),l.useGravity||h.appendLine("bool gravityEnabled = 0"),h.appendLine('uniform token info:id = "RealityKit.RigidBody"'),l.isKinematic&&h.appendLine('token motionType = "Kinematic"'),h.beginBlock('def RealityKitStruct "massFrame"',"{",!0),h.appendLine(`float m_mass = ${l.mass}`),h.beginBlock('def RealityKitStruct "m_pose"',"{",!0),h.appendLine(`float3 position = (${l.centerOfMass.x}, ${l.centerOfMass.y}, ${l.centerOfMass.z})`),h.closeBlock("}"),h.closeBlock("}"),r.length>0){const y=r[0];h.beginBlock('def RealityKitStruct "material"',"{",!0);const f=y.sharedMaterial;f&&f.dynamicFriction!==void 0&&h.appendLine(`double dynamicFriction = ${(u=y.sharedMaterial)==null?void 0:u.dynamicFriction}`),f&&f.bounciness!==void 0&&h.appendLine(`double restitution = ${(p=y.sharedMaterial)==null?void 0:p.bounciness}`),f&&f.staticFriction!==void 0&&h.appendLine(`double staticFriction = ${(g=y.sharedMaterial)==null?void 0:g.staticFriction}`),h.closeBlock("}")}h.closeBlock("}")}}),c&&(i.addEventListener("serialize",(h,d)=>{var u;h.beginBlock('def RealityKitComponent "Collider"',"{",!0),h.appendLine("uint group = 1"),h.appendLine('uniform token info:id = "RealityKit.Collider"'),h.appendLine("uint mask = 4294967295");const p=c.isTrigger?"Trigger":"Default";if(h.appendLine(`token type = "${p}"`),h.beginBlock('def RealityKitStruct "Shape"',"{",!0),c instanceof Za){const g=c;h.appendLine('token shapeType = "Sphere"'),h.appendLine(`float radius = ${g.radius}`)}else if(c instanceof Ja){const g=c;h.appendLine('token shapeType = "Box"'),h.appendLine(`float3 extent = (${g.size.x}, ${g.size.y}, ${g.size.z})`)}else if(c instanceof In){const g=c;h.appendLine('token shapeType = "Capsule"'),h.appendLine(`float radius = ${g.radius}`),h.appendLine(`float height = ${g.height}`)}else if(c instanceof To&&(u=c.sharedMesh)!=null&&u.geometry){const g=c.sharedMesh.geometry;g.boundingBox||g.computeBoundingBox();const y=c.sharedMesh.geometry.boundingBox;y&&(h.appendLine('token shapeType = "Box"'),h.appendLine(`float3 extent = (${y.max.x-y.min.x}, ${y.max.y-y.min.y}, ${y.max.z-y.min.z})`),console.log("[USDZ] Only Box, Sphere, and Capsule colliders are supported in visionOS/iOS. MeshCollider will be exported as Box",c))}else console.warn("[USDZ] Only Box, Sphere, and Capsule colliders are supported in visionOS/iOS. Ignoring collider:",c);h.beginBlock('def RealityKitStruct "pose"',"{",!0),h.closeBlock("}"),h.closeBlock("}"),h.closeBlock("}")}),r.length>1&&console.log("WARNING: Multiple colliders detected. visionOS / iOS can only support objects with a single collider, only exporting the first collider: ",c))}}class m0{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(t){}}var gT=Object.defineProperty,fT=Object.getOwnPropertyDescriptor,ch=(s,t,i,n)=>{for(var o=n>1?void 0:n?fT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&gT(t,i,o),o};const g0=O("debugui"),f0=O("debuguilayout");class y0{constructor(){a(this,"width"),a(this,"height")}}class v0{constructor(){a(this,"x"),a(this,"y"),a(this,"width"),a(this,"height")}}const Rs=new x,hh=new ne,mp=new V,Ux=class extends ls{constructor(){super(...arguments),a(this,"_anchoredPosition"),a(this,"sizeDelta",new oe(100,100)),a(this,"pivot",new oe(.5,.5)),a(this,"anchorMin",new oe(0,0)),a(this,"anchorMax",new oe(1,1)),a(this,"minWidth"),a(this,"minHeight"),a(this,"lastMatrix"),a(this,"rectBlock"),a(this,"_transformNeedsUpdate",!1),a(this,"_initialPosition"),a(this,"_parentRectTransform"),a(this,"_lastUpdateFrame",-1),a(this,"_lastAnchoring"),a(this,"_createdBlocks",[]),a(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new oe),this._anchoredPosition}set anchoredPosition(s){this._anchoredPosition=s}get width(){let s=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const t=this._parentRectTransform.width,i=this.anchorMax.x-this.anchorMin.x;s=t*i,s+=this.sizeDelta.x}return this.minWidth!==void 0&&s<this.minWidth?this.minWidth:s}get height(){let s=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const t=this._parentRectTransform.height,i=this.anchorMax.y-this.anchorMin.y;s=t*i,s+=this.sizeDelta.y}return this.minHeight!==void 0&&s<this.minHeight?this.minHeight:s}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new oe),this.lastMatrix=new ne,this.rectBlock=new j,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,Xa(this,"_anchoredPosition",()=>{this.markDirty()}),Xa(this,"sizeDelta",()=>{this.markDirty()}),Xa(this,"pivot",()=>{this.markDirty()}),Xa(this,"anchorMin",()=>{this.markDirty()}),Xa(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var s;super.onEnable(),this.rectBlock||(this.rectBlock=new j),this.lastMatrix||(this.lastMatrix=new ne),this._lastAnchoring||(this._lastAnchoring=new oe),this._initialPosition||(this._initialPosition=new x),this._anchoredPosition||(this._anchoredPosition=new oe),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(s=this.canvas)==null||s.registerTransform(this)}onDisable(){var s;super.onDisable(),this.removeShadowComponent(),(s=this.canvas)==null||s.unregisterTransform(this)}onParentRectTransformChanged(s){this._transformNeedsUpdate||this.onApplyTransform(f0?`${s.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(f0&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(s){var t;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const i=this.shadowComponent;if(!i)return;this.gameObject.parent?this._parentRectTransform=P.getComponentInParent(this.gameObject.parent,Ux):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,f0&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+s),this.isRoot()?this.Root.screenspace||(i.rotation.y=Math.PI):(i.matrix.identity(),i.matrixAutoUpdate=!1,Rs.set(0,0,0),this.applyPivot(Rs),i.matrix.setPosition(Rs.x,Rs.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(mp.copy(this.gameObject.quaternion),mp.x*=-1,mp.z*=-1,hh.makeRotationFromQuaternion(mp),i.matrix.premultiply(hh)),Rs.set(0,0,0),this.applyAnchoring(Rs),(t=this.canvas)!=null&&t.screenspace?Rs.z+=.1:Rs.z+=.01,hh.identity(),hh.setPosition(Rs.x,Rs.y,Rs.z),i.matrix.premultiply(hh),i.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const n=!0;for(const o of eu(this.gameObject,ls,n,1)){if(o===this||!o.activeAndEnabled)continue;const r=o;r.onParentRectTransformChanged&&r.onParentRectTransformChanged(this)}}applyAnchoring(s){this._lastAnchoring||(this._lastAnchoring=new oe);const t=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=t.x,this.gameObject.position.y+=t.y,this._lastAnchoring.copy(this._anchoredPosition),s.x+=this._initialPosition.x-this.gameObject.position.x,s.y+=this._initialPosition.y-this.gameObject.position.y,s.z+=this._initialPosition.z-this.gameObject.position.z;const i=this._parentRectTransform;if(i){let n=0;const o=1-this.anchorMax.y-this.anchorMin.y;n-=i.height*.5*o,s.y+=n;let r=0;const l=1-this.anchorMax.x-this.anchorMin.x;r-=i.width*.5*l,s.x+=r}}applyPivot(s){if(this.pivot&&!this.isRoot()){const t=this.pivot.x-.5;s.x-=t*this.sizeDelta.x*this.gameObject.scale.x;const i=this.pivot.y-.5;s.y-=i*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const s={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(s),s}ensureValidSize(s,t=1e-4){return s.width<=0&&(s.width=t),s.height<=0&&(s.height=1e-4),s}createNewBlock(s){s={...this.getBasicOptions(),...s},g0&&console.log(this.name,s);const t=new bv(s);return this._createdBlocks.push(t),t}createNewText(s){g0&&console.log(s),s={...this.getBasicOptions(),...s},g0&&console.log(this.name,s);const t=new vv(s);return this._createdTextBlocks.push(t),t}};let Wt=Ux;ch([m(oe)],Wt.prototype,"anchoredPosition",1),ch([m(oe)],Wt.prototype,"sizeDelta",2),ch([m(oe)],Wt.prototype,"pivot",2),ch([m(oe)],Wt.prototype,"anchorMin",2),ch([m(oe)],Wt.prototype,"anchorMax",2);var yT=Object.defineProperty,vT=Object.getOwnPropertyDescriptor,Nx=(s,t,i,n)=>{for(var o=n>1?void 0:n?vT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&yT(t,i,o),o};class vl extends A{constructor(){super(...arguments),a(this,"effectColor"),a(this,"effectDistance")}}Nx([m(we)],vl.prototype,"effectColor",2),Nx([m(oe)],vl.prototype,"effectDistance",2);var bT=Object.defineProperty,_T=Object.getOwnPropertyDescriptor,Wx=(s,t,i,n)=>{for(var o=n>1?void 0:n?_T(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&bT(t,i,o),o};const gp={backgroundColor:new ae(1,1,1),backgroundOpacity:1,borderColor:new ae(1,1,1),borderOpacity:1};var b0;const dh=(b0=class extends ls{constructor(){super(...arguments),a(this,"_alphaFactor",1),a(this,"sRGBColor",new ae(1,0,1)),a(this,"raycastTarget",!0),a(this,"uiObject",null),a(this,"_color",null),a(this,"_rect",null),a(this,"_stateManager",null),a(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new we(1,1,1,1)),this._color}set color(s){(!this._color||this._color.r!==s.r||this._color.g!==s.g||this._color.b!==s.b||this._color.alpha!==s.alpha)&&(this._color||(this._color=new we(1,1,1,1)),this._color.copy(s),this.onColorChanged())}setAlphaFactor(s){this._alphaFactor=s,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),gp.backgroundColor=this.sRGBColor,gp.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(gp,this._alphaFactor),this.uiObject.set(gp),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=P.getComponent(this.gameObject,Wt)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var s;(s=this.uiObject)==null||s.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(s){return super.__internalNewInstanceCreated(s),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone()),this}setState(s){this.makePanel(),this.uiObject&&(this.uiObject.setState(s),this==null||this.markDirty())}setupState(s){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new lO(this.uiObject)),this.uiObject.setupState(s.state,s.attributes))}setOptions(s){this.makePanel(),this.uiObject&&this.uiObject.set(s)}awake(){super.awake(),this.makePanel(),Xa(this,"_color",()=>yM(this,this.onColorChanged))}onEnable(){var s;super.onEnable(),this.uiObject&&((s=this.rectTransform.shadowComponent)==null||s.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const s=.015,t={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:s};this.onBeforeCreate(t),this.applyEffects(t),this.onCreate(t),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(s){}onCreate(s){this.uiObject=this.rectTransform.createNewBlock(s),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(s,t=1){var i;const n=(i=this.gameObject)==null?void 0:i.getComponent(vl);n&&(n.effectDistance&&(s.borderWidth=Math.max(Math.abs(n.effectDistance.x),Math.abs(n.effectDistance.y))),n.effectColor&&(s.borderColor=n.effectColor,s.borderOpacity=n.effectColor.alpha*t))}async setTexture(s){if(this.setOptions({backgroundOpacity:0}),s){if(dh.textureCache.has(s))s=dh.textureCache.get(s);else if(!s.isRenderTargetTexture){const t=s.clone();t.colorSpace=pr,dh.textureCache.set(s,t),s=t}this.setOptions({backgroundImage:s,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"}),et.assignTextureLOD(s,0).then(t=>{t instanceof Ne&&(s&&dh.textureCache.set(s,t),this.setOptions({backgroundImage:t}),this.markDirty())})}else this.setOptions({backgroundImage:void 0,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},a(b0,"textureCache",new Map),b0);let Xr=dh;Wx([m(we)],Xr.prototype,"color",1),Wx([m()],Xr.prototype,"raycastTarget",2);class uh extends Xr{constructor(){super(...arguments),a(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var wT=Object.defineProperty,xT=Object.getOwnPropertyDescriptor,Nn=(s,t,i,n)=>{for(var o=n>1?void 0:n?xT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&wT(t,i,o),o};const Qr=O("debugtext");var ut=(s=>(s[s.UpperLeft=0]="UpperLeft",s[s.UpperCenter=1]="UpperCenter",s[s.UpperRight=2]="UpperRight",s[s.MiddleLeft=3]="MiddleLeft",s[s.MiddleCenter=4]="MiddleCenter",s[s.MiddleRight=5]="MiddleRight",s[s.LowerLeft=6]="LowerLeft",s[s.LowerCenter=7]="LowerCenter",s[s.LowerRight=8]="LowerRight",s))(ut||{}),Vx=(s=>(s[s.Normal=0]="Normal",s[s.Bold=1]="Bold",s[s.Italic=2]="Italic",s[s.BoldAndItalic=3]="BoldAndItalic",s))(Vx||{});class Vt extends Xr{constructor(){super(...arguments),a(this,"alignment",0),a(this,"verticalOverflow",0),a(this,"horizontalOverflow",0),a(this,"lineSpacing",1),a(this,"supportRichText",!1),a(this,"font"),a(this,"fontStyle",0),a(this,"sRGBTextColor",new ae(1,0,1)),a(this,"_text",""),a(this,"_fontSize",12),a(this,"_textMeshUi",null),a(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(t){var i;super.setAlphaFactor(t),(i=this.uiObject)==null||i.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(t){t!==this._text&&(this._text=t,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(t){this.text=t}get fontSize(){return this._fontSize}set fontSize(t){var i;this._fontSize=t,(i=this.uiObject)==null||i.set({fontSize:t})}onColorChanged(){var t;this.sRGBTextColor.copy(this.color),this.sRGBTextColor.convertLinearToSRGB(),(t=this.uiObject)==null||t.set({color:this.sRGBTextColor,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeCanvasRender(t){this.updateOverflow()}updateOverflow(){var t;const i=(t=this.uiObject)==null?void 0:t._overflow;i&&(i._needsUpdate=!0)}onCreate(t){Qr&&console.log(this),this.horizontalOverflow==1&&(t.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,t.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,t.lineHeight=this.lineSpacing,delete t.backgroundOpacity,delete t.backgroundColor,Qr&&(t.backgroundColor=16750848,t.backgroundOpacity=.5);const i=this.rectTransform;t={...t,...this.getTextOpts()},this.getAlignment(t),Qr&&(t.backgroundColor=Math.random()*16777215,t.backgroundOpacity=.1),this.uiObject=i.createNewText(t),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const t=this.fontSize,i={color:this.color,fontOpacity:this.color.alpha,fontSize:t,fontKerning:"normal"};return this.setFont(i,this.fontStyle),i}onEnable(){var t;super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10),(t=this.canvas)==null||t.registerEventReceiver(this)}onDisable(){var t;super.onDisable(),(t=this.canvas)==null||t.unregisterEventReceiver(this)}getAlignment(t){switch(t.flexDirection="column",this.alignment){case 0:case 3:case 6:t.textAlign="left";break;case 1:case 4:case 7:t.textAlign="center";break;case 2:case 5:case 8:t.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:t.alignItems="start";break;case 3:case 4:case 5:t.alignItems="center";break;case 6:case 7:case 8:t.alignItems="end";break}return t}feedText(t,i){var n,o,r;if(Qr&&console.log("feedText",this.uiObject,t,i),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!i||t.length===0)this.uiObject.textContent=t;else{let l=this.getNextTag(t);if(l){if(l.startIndex>0){for(let d=this.uiObject.children.length-1;d>=0;d--){const u=this.uiObject.children[d];u.isUI&&(this.uiObject.remove(u),u.clear())}const h=new Om({textContent:t.substring(0,l.startIndex),color:"inherit"});this.uiObject.add(h)}}else{this.uiObject.textContent="",this.setOptions({textContent:t});return}const c=[];for(;l;){const h=this.getNextTag(t,l.endIndex),d={fontFamily:(n=this.uiObject)==null?void 0:n.get("fontFamily"),color:"inherit",textContent:""};if(h){d.textContent=this.getText(t,l,h),this.handleTag(l,d,c);const u=new Om(d);(o=this.uiObject)==null||o.add(u)}else{d.textContent=t.substring(l.endIndex),this.handleTag(l,d,c);const u=new Om(d);(r=this.uiObject)==null||r.add(u)}l=h}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const t=[],i=this.canvas,n={renderOnTop:i.renderOnTop,depthWrite:i.depthWrite,doubleSided:i.doubleSided};for(;;){let o=!1;if(this._textMeshUi)for(let r=0;r<this._textMeshUi.length;r++){if(t[r]===!0)continue;o=!0;const l=this._textMeshUi[r];l.textContent&&(Au(l,n),t[r]=!0)}if(!o)break;yield}}handleTag(t,i,n){if(!t.isEndTag){if(t.type.includes("color")){const o=new _0(t,{color:i.color});if(n.push(o),t.type.length>6){const r=parseInt("0x"+t.type.substring(7));i.color=r}else i.color=new ae(1,1,1)}else if(t.type=="b"){this.setFont(i,1);const o=new _0(t,{fontWeight:700});n.push(o)}else if(t.type=="i"){this.setFont(i,2);const o=new _0(t,{fontStyle:"italic"});n.push(o)}}}getText(t,i,n){return t.substring(i.endIndex,n.startIndex)}getNextTag(t,i=0){const n=t.indexOf("<",i),o=t.indexOf(">",n);if(n>=0&&o>=0){const r=t.substring(n+1,o);return{type:r,startIndex:n,endIndex:o+1,isEndTag:r.startsWith("/")}}return null}setFont(t,i){if(!this.font)return;const n=this.font,o=this.getFamilyNameWithCorrectSuffix(n,i);Qr&&console.log("Selected font family:"+o);let r=_v.getFontFamily(o);switch(r||(r=_v.addFontFamily(o)),t.fontFamily=r,i){default:case 0:t.fontWeight=400,t.fontStyle="normal";break;case 1:t.fontWeight=700,t.fontStyle="normal";break;case 2:t.fontWeight=400,t.fontStyle="italic";break;case 3:t.fontStyle="italic",t.fontWeight=400}let l=r.getVariant(t.fontWeight,t.fontStyle);if(!l){let c=o;c!=null&&c.endsWith("-msdf.json")||(c+="-msdf.json");let h=o;h!=null&&h.endsWith(".png")||(h+=".png"),l=r.addVariant(t.fontWeight,t.fontStyle,c,h),l?.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(t,i){var n;const o=t.lastIndexOf("-");if(o<0)return t;const r=(n=t.substring(o+1))==null?void 0:n.toLowerCase();if(ST.includes(r))return Qr&&console.warn("Unsupported font style: "+r),t;const l=t.lastIndexOf("/");let c=t;l>=0&&(c=c.substring(l+1));const h=c[0]===c[0].toUpperCase(),d=t.substring(0,o);switch(Qr&&console.log("Select font: ",t,Vx[i],c,h,d),i){case 0:return h?d+"-Regular":d+"-regular";case 1:return h?d+"-Bold":d+"-bold";case 2:return h?d+"-Italic":d+"-italic";case 3:return h?d+"-BoldItalic":d+"-bolditalic";default:return t}}}Nn([m()],Vt.prototype,"alignment",2),Nn([m()],Vt.prototype,"verticalOverflow",2),Nn([m()],Vt.prototype,"horizontalOverflow",2),Nn([m()],Vt.prototype,"lineSpacing",2),Nn([m()],Vt.prototype,"supportRichText",2),Nn([m(URL)],Vt.prototype,"font",2),Nn([m()],Vt.prototype,"fontStyle",2),Nn([m()],Vt.prototype,"text",1),Nn([m()],Vt.prototype,"fontSize",1);class _0{constructor(t,i){a(this,"tag"),a(this,"previousValues"),this.tag=t,this.previousValues=i}}const ST=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class jo{constructor(t){a(this,"id"),a(this,"content",""),a(this,"font",[]),a(this,"pointSize",144),a(this,"width"),a(this,"height"),a(this,"depth"),a(this,"wrapMode"),a(this,"horizontalAlignment"),a(this,"verticalAlignment"),a(this,"material"),this.id=t}static getId(){return this.global_id++}setDepth(t){return this.depth=t,this}setPointSize(t){return this.pointSize=t,this}setHorizontalAlignment(t){return this.horizontalAlignment=t,this}setVerticalAlignment(t){return this.verticalAlignment=t,this}writeTo(t,i){var n;i.beginBlock(`def Preliminary_Text "${this.id}"`,"(",!1),i.appendLine('prepend apiSchemas = ["MaterialBindingAPI"]'),i.closeBlock(")"),i.beginBlock(),this.content&&i.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(n=this.font)==null||n.push("sans-serif"));const o=this.font.map(r=>`"${r}"`).join(", ");i.appendLine(`string[] font = [ ${o} ]`),i.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&i.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&i.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&i.appendLine(`double depth = ${this.depth}`),this.wrapMode&&i.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&i.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&i.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&i.appendLine(`rel material:binding = </StageRoot/Materials/${s0(this.material)}>`),i.closeBlock()}}a(jo,"global_id",0);class fp{static singleLine(t,i,n){const o=new jo("text_"+jo.getId());return o.content=t,i&&(o.pointSize=i),n&&(o.depth=n),o}static multiLine(t,i,n,o,r,l){const c=new jo("text_"+jo.getId());return c.content=t,c.width=i,c.height=n,c.horizontalAlignment=o,c.verticalAlignment=r,l!==void 0&&(c.wrapMode=l),c}}const CT=new ne().makeRotationY(Math.PI),OT=new ne().makeScale(-1,1,-1);class ph{get extensionName(){return"text"}exportText(t,i,n){const o=P.getComponent(t,Vt);if(!o)return;const r=P.getComponent(t,Wt);let l=100,c=100;r&&(l=r.width,c=r.height);const h=CT.clone();r&&h.premultiply(OT),i.setMatrix(h);const d=o.color.clone();i.material=new ri({color:d,emissive:d}),i.addEventListener("serialize",(u,p)=>{let g=o.text;g=g.replace(/\r/g,""),g=g.replace(/\n/g,"\\n");const y=fp.multiLine(g,l,c,"center","bottom","flowing");this.setTextAlignment(y,o.alignment),this.setOverflow(y,o),i.material&&(y.material=i.material),y.pointSize=this.convertToTextSize(o.fontSize),y.depth=.001,y.writeTo(void 0,u)})}convertToTextSize(t){return 1/.0502*144*t}setOverflow(t,i){i.horizontalOverflow?t.wrapMode="singleLine":t.wrapMode="flowing"}setTextAlignment(t,i){switch(i){case ut.LowerLeft:case ut.MiddleLeft:case ut.UpperLeft:t.horizontalAlignment="left";break;case ut.LowerCenter:case ut.MiddleCenter:case ut.UpperCenter:t.horizontalAlignment="center";break;case ut.LowerRight:case ut.MiddleRight:case ut.UpperRight:t.horizontalAlignment="right";break}switch(i){case ut.LowerLeft:case ut.LowerCenter:case ut.LowerRight:t.verticalAlignment="bottom";break;case ut.MiddleLeft:case ut.MiddleCenter:case ut.MiddleRight:t.verticalAlignment="middle";break;case ut.UpperLeft:case ut.UpperCenter:case ut.UpperRight:t.verticalAlignment="top";break}}}var PT=Object.defineProperty,kT=Object.getOwnPropertyDescriptor,ot=(s,t,i,n)=>{for(var o=n>1?void 0:n?kT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&PT(t,i,o),o};const Hx=O("debuguilayout");class Lo{constructor(){a(this,"left",0),a(this,"right",0),a(this,"top",0),a(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}ot([m()],Lo.prototype,"left",2),ot([m()],Lo.prototype,"right",2),ot([m()],Lo.prototype,"top",2),ot([m()],Lo.prototype,"bottom",2);class Ii extends A{constructor(){super(...arguments),a(this,"_rectTransform",null),a(this,"_needsUpdate",!1),a(this,"childAlignment",0),a(this,"reverseArrangement",!1),a(this,"spacing",0),a(this,"padding"),a(this,"minWidth",0),a(this,"minHeight",0),a(this,"flexibleHeight",0),a(this,"flexibleWidth",0),a(this,"preferredHeight",0),a(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(t){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(Hx&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){Hx&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(Wt);const t=this.gameObject.getComponentInParent(Tt);t&&t.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const t=this.gameObject.getComponentInParent(Tt);t&&t.unregisterLayoutGroup(this)}set m_Spacing(t){t!==this.spacing&&(this._needsUpdate=!0,this.spacing=t)}get m_Spacing(){return this.spacing}}ot([m()],Ii.prototype,"childAlignment",2),ot([m()],Ii.prototype,"reverseArrangement",2),ot([m()],Ii.prototype,"spacing",2),ot([m(Lo)],Ii.prototype,"padding",2),ot([m()],Ii.prototype,"minWidth",2),ot([m()],Ii.prototype,"minHeight",2),ot([m()],Ii.prototype,"flexibleHeight",2),ot([m()],Ii.prototype,"flexibleWidth",2),ot([m()],Ii.prototype,"preferredHeight",2),ot([m()],Ii.prototype,"preferredWidth",2);class Do extends Ii{constructor(){super(...arguments),a(this,"childControlHeight",!0),a(this,"childControlWidth",!0),a(this,"childForceExpandHeight",!1),a(this,"childForceExpandWidth",!1),a(this,"childScaleHeight",!1),a(this,"childScaleWidth",!1)}onCalculateLayout(t){var i;const n=this.primaryAxis,o=t.width;let r=o;const l=t.height;let c=l;r-=this.padding.horizontal,c-=this.padding.vertical,n==="x"?this.padding.horizontal:this.padding.vertical;const h=n==="x",d=h?"y":"x",u=h?this.childControlWidth:this.childControlHeight,p=h?this.childControlHeight:this.childControlWidth,g=h?this.childForceExpandWidth:this.childForceExpandHeight,y=h?this.childForceExpandHeight:this.childForceExpandWidth,f=h?c:r,v=h?o:l,b=.5*(h?this.childAlignment%3:Math.floor(this.childAlignment/3));let w=0;h?w+=this.padding.left:w+=this.padding.top;let _=0,C=0;for(let L=0;L<this.gameObject.children.length;L++){const U=this.gameObject.children[L],z=P.getComponent(U,Wt);z!=null&&z.activeAndEnabled&&(C+=1,h?_+=z.width:_+=z.height)}let R=0;const M=this.spacing*(C-1);if(g||u){let L=0;h?L=r-=M:L=c-=M,C>0&&(R=L/C)}let E=0;E+=this.padding.left,E-=this.padding.right,b!==0&&(w=v-_,w*=b,w-=M*b,h?(w-=this.padding.right*b,w+=this.padding.left*(1-b),w<this.padding.left&&(w=this.padding.left)):(w-=this.padding.bottom*b,w+=this.padding.top*(1-b),w<this.padding.top&&(w=this.padding.top)));let B=1;for(let L=0;L<this.gameObject.children.length;L++){const U=this.gameObject.children[L],z=P.getComponent(U,Wt);if(z!=null&&z.activeAndEnabled){(i=z.pivot)==null||i.set(.5,.5),z.anchorMin.set(0,1),z.anchorMax.set(0,1);const H=o*.5+E*.5;z.anchoredPosition.x!==H&&(z.anchoredPosition.x=H);const T=l*-.5;z.anchoredPosition.y!==T&&(z.anchoredPosition.y=T),y&&p&&z.sizeDelta[d]!==f&&(z.sizeDelta[d]=f),g&&u&&z.sizeDelta[n]!==R&&(z.sizeDelta[n]=R);const I=h?z.width:z.height,G=I*.5;if(w+=G,g){const se=R*B-R*.5;se>w&&(w=se-R*.5+I+this.padding.left,w-=G)}let J=w;n==="y"&&(J=-J),z.anchoredPosition[n]!==J&&(z.anchoredPosition[n]=J),w+=G,w+=this.spacing,B+=1}}}}ot([m()],Do.prototype,"childControlHeight",2),ot([m()],Do.prototype,"childControlWidth",2),ot([m()],Do.prototype,"childForceExpandHeight",2),ot([m()],Do.prototype,"childForceExpandWidth",2),ot([m()],Do.prototype,"childScaleHeight",2),ot([m()],Do.prototype,"childScaleWidth",2);class w0 extends Do{get primaryAxis(){return"y"}}class x0 extends Do{get primaryAxis(){return"x"}}class S0 extends Ii{onCalculateLayout(){}}var MT=Object.defineProperty,RT=Object.getOwnPropertyDescriptor,on=(s,t,i,n)=>{for(var o=n>1?void 0:n?RT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&MT(t,i,o),o},$x=(s=>(s[s.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",s[s.ScreenSpaceCamera=1]="ScreenSpaceCamera",s[s.WorldSpace=2]="WorldSpace",s[s.Undefined=-1]="Undefined",s))($x||{});const C0=O("debuguilayout"),qx=class extends Fc{constructor(){super(...arguments),a(this,"_renderOnTop"),a(this,"_depthWrite",!1),a(this,"_doubleSided",!0),a(this,"_castShadows",!1),a(this,"_receiveShadows",!1),a(this,"_renderMode",-1),a(this,"_rootCanvas"),a(this,"_scaleFactor",1),a(this,"worldCamera"),a(this,"planeDistance",-1),a(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this)),a(this,"previousParent",null),a(this,"_lastMatrixWorld",null),a(this,"_rectTransforms",[]),a(this,"_layoutGroups",new Map),a(this,"_receivers",[]),a(this,"onBeforeRenderRoutine",()=>{var s,t,i,n;if(this.previousParent=this.gameObject.parent,((s=this.context.xr)!=null&&s.isVR||(t=this.context.xr)!=null&&t.isPassThrough)&&this.screenspace){this.gameObject.visible=!1,this.gameObject.removeFromParent();return}this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(n=this.shadowComponent)==null||n.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),ts.ensureUpdateMeshUI(wv,this.context))}),a(this,"onAfterRenderRoutine",()=>{var s,t,i,n,o;if(((s=this.context.xr)!=null&&s.isVR||(t=this.context.xr)!=null&&t.isPassThrough)&&this.screenspace){(i=this.previousParent)==null||i.add(this.gameObject);return}if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const c=this.context.mainCamera;c?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const r=this.context.renderer.autoClear,l=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(n=this.shadowComponent)==null||n.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),ts.ensureUpdateMeshUI(wv,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=r,this.context.renderer.autoClearColor=l,this.previousParent.add(this.gameObject)}(o=this._lastMatrixWorld)==null||o.copy(this.gameObject.matrixWorld)}),a(this,"_updateRenderSettingsRoutine"),a(this,"_activeRenderMode",-1),a(this,"_lastWidth",-1),a(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(s){s!==this._renderOnTop&&(this._renderOnTop=s,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(s){this._depthWrite!==s&&(this._depthWrite=s,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(s){this._doubleSided!==s&&(this._doubleSided=s,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(s){this._castShadows!==s&&(this._castShadows=s,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(s){this._receiveShadows!==s&&(this._receiveShadows=s,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(s){this._renderMode!==s&&(this._renderMode=s,this.onRenderSettingsChanged())}set rootCanvas(s){this._rootCanvas instanceof qx||(this._rootCanvas=s)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(s){this._scaleFactor=s}awake(){var s;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,C0&&console.log("Canvas.Awake()",((s=this.previousParent)==null?void 0:s.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new ne,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const s=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);s!==-1&&this.context.pre_render_callbacks.splice(s,1);const t=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);t!==-1&&this.context.post_render_callbacks.splice(t,1)}registerTransform(s){this._rectTransforms.push(s)}unregisterTransform(s){const t=this._rectTransforms.indexOf(s);t!==-1&&this._rectTransforms.splice(t,1)}registerLayoutGroup(s){const t=s.gameObject;this._layoutGroups.set(t,s)}unregisterLayoutGroup(s){const t=s.gameObject;this._layoutGroups.delete(t)}registerEventReceiver(s){this._receivers.push(s)}unregisterEventReceiver(s){const t=this._receivers.indexOf(s);t!==-1&&this._receivers.splice(t,1)}async onEnterXR(s){this.screenspace?(s.xr.isVR||s.xr.isPassThrough)&&(this.gameObject.visible=!1):(this.gameObject.visible=!1,await Ql(1).then(()=>{this.gameObject.visible=!0}))}onLeaveXR(s){this.screenspace&&(s.xr.isVR||s.xr.isPassThrough)&&(this.gameObject.visible=!0)}invokeBeforeRenderEvents(){var s;for(const t of this._receivers)(s=t.onBeforeCanvasRender)==null||s.call(t,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new ne);const s=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);C0&&s&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const t=!1;for(const i of this._rectTransforms){s&&i.markDirty();let n=this._layoutGroups.get(i.gameObject);i.isDirty&&!n&&(n=i.gameObject.getComponentInParent(Ii)),(i.isDirty||n!=null&&n.isDirty)&&(C0&&!t&&console.log("CANVAS UPDATE ### "+i.name+" ##################################### "+this.context.time.frame),n?.updateLayout(),i.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),Ce.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),Au(this.shadowComponent,this);for(const s of P.getComponentsInChildren(this.gameObject,ls))Au(s.shadowComponent,this)}}onUpdateRenderMode(s=!1){if(!s&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let t=this.context.mainCameraComponent,i=10;switch(t&&t.nearClipPlane>0&&t.farClipPlane>0&&(i=W.lerp(t.nearClipPlane,t.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(t=this.worldCamera),this.planeDistance>0&&(i=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!t)return;const n=i+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-n,this.gameObject.quaternion.identity();const o=this.gameObject.getComponent(Wt);let r=!1;o.sizeDelta.x!==this.context.domWidth&&(r=!0),o.sizeDelta.y!==this.context.domHeight&&(r=!0);const l=t.fieldOfView*Math.PI/180,c=2*Math.tan(l/2)*Math.abs(n);this.gameObject.scale.x=c/this.context.domHeight,this.gameObject.scale.y=c/this.context.domHeight,this.gameObject.scale.z=.01,r&&(o.sizeDelta.x=this.context.domWidth,o.sizeDelta.y=this.context.domHeight,o?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let Tt=qx;on([m()],Tt.prototype,"renderOnTop",1),on([m()],Tt.prototype,"depthWrite",1),on([m()],Tt.prototype,"doubleSided",1),on([m()],Tt.prototype,"castShadows",1),on([m()],Tt.prototype,"receiveShadows",1),on([m()],Tt.prototype,"renderMode",1),on([m(Tt)],Tt.prototype,"rootCanvas",1),on([m()],Tt.prototype,"scaleFactor",1),on([m(Pe)],Tt.prototype,"worldCamera",2),on([m()],Tt.prototype,"planeDistance",2);var TT=Object.defineProperty,ET=Object.getOwnPropertyDescriptor,O0=(s,t,i,n)=>{for(var o=n>1?void 0:n?ET(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&TT(t,i,o),o};class Bo extends A{constructor(){super(...arguments),a(this,"_alpha",1),a(this,"interactable",!0),a(this,"blocksRaycasts",!0),a(this,"_isDirty",!1),a(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(t){t!==this._alpha&&(this._alpha=t,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),Ce.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){this._buffer.length=0;for(const t of P.getComponentsInChildren(this.gameObject,ls,this._buffer)){const i=t;i.setAlphaFactor&&i.setAlphaFactor(this._alpha)}}}O0([m()],Bo.prototype,"alpha",1),O0([m()],Bo.prototype,"interactable",2),O0([m()],Bo.prototype,"blocksRaycasts",2);class yp{get extensionName(){return"tmui"}onExportObject(t,i,n){const o=P.getComponent(t,Tt);if(o&&o.enabled&&o.renderMode===$x.WorldSpace){const r=new ph,l=P.getComponent(t,Wt),c=P.getComponent(t,Bo),h=new Array;if(l){if(!P.isActiveSelf(t)){const p=P.isActiveSelf(t);P.setActive(t,!0),l.onEnable(),l.updateTransform(),h.push(()=>{l.onDisable(),P.setActive(t,p)})}t.traverse(p=>{if(!P.isActiveInHierarchy(p)){const g=P.isActiveSelf(p);P.setActive(p,!0);const y=P.getComponent(p,ls);y&&(y.onEnable(),h.push(()=>{y.onDisable()}));const f=P.getComponent(p,Wt);f&&(f.onEnable(),f.updateTransform(),f.onApplyTransform(),h.push(()=>{f.onDisable()}));const v=P.getComponent(p,Vt);v&&(v.onEnable(),h.push(()=>{v.onDisable()})),h.push(()=>{P.setActive(p,g)})}}),l.width,l.height;const d=Zt.createEmpty(),u=l.shadowComponent;if(i.add(d),u){const p=u.matrix;d.setMatrix(p);const g=new Map,y=new Map;g.set(u,d),y.set(u,c?c.alpha:1),u.traverse(f=>{if(f===u)return;const v=Zt.createEmpty();v.setMatrix(f.matrix);const b=f.parent,w=!!b&&typeof b.textContent=="string"&&b.textContent.length>0;let _=y.get(b)||1;const C=P.getComponent(f,Bo);if(C&&(_*=C.alpha),f instanceof Q&&w){const M=f[es];M?r.exportText(M.gameObject,v,n):console.error("Error when exporting UI: shadow component owner not found. This is likely a bug.",f)}if(f instanceof Q&&!w){const M=f.geometry.clone();M.scale(1,1,-1),this.flipWindingOrder(M),v.geometry=M;const E=new ae,B=f.material.opacity;E.copy(f.material.color),v.material=new Me({color:E,opacity:B*_,map:f.material.map,transparent:!0})}g.set(f,v),y.set(f,_);const R=g.get(b);if(!R){console.error("Error when exporting UI: shadow component parent not found!",f,f.parent);return}R.add(v)})}}for(const d of h)d()}}flipWindingOrder(t){const i=t.index.array;for(let n=0,o=i.length/3;n<o;n++){const r=i[n*3];i[n*3]=i[n*3+2],i[n*3+2]=r}t.index.needsUpdate=!0}}const Gx=class{constructor(){a(this,"_quicklookButton"),a(this,"_arButton"),a(this,"_vrButton"),a(this,"_sendToQuestButton")}static create(){return new Gx}static getOrCreate(){return this._instance||(this._instance=this.create()),this._instance}get isSecureConnection(){return window.location.protocol==="https:"}get quicklookButton(){return this._quicklookButton}get arButton(){return this._arButton}get vrButton(){return this._vrButton}get sendToQuestButton(){return this._sendToQuestButton}get qrButton(){return Mn.getOrCreate().createQRCode()}createQuicklookButton(){if(this._quicklookButton)return this._quicklookButton;const s=document.createElement("button");this._quicklookButton=s,s.dataset.needle="quicklook-button";const t=Y.supportsQuickLookAR();s.innerText="View in AR",s.prepend(Pt("view_in_ar"));let i=!1,n=null;return s.addEventListener("click",()=>{n=Gd(Ge),n||(i=!0,n=new Ge),i&&(n.objectToExport=te.Current.scene),n?(s.classList.add("this-mode-is-requested"),n.exportAndOpen().then(()=>{s.classList.remove("this-mode-is-requested")}).catch(o=>{s.classList.remove("this-mode-is-requested"),console.error(o)})):console.warn("No USDZExporter component found in the scene")}),this.hideElementDuringXRSession(s),s}createARButton(s){var t;if(this._arButton)return this._arButton;const i="immersive-ar",n=document.createElement("button");return this._arButton=n,n.classList.add("webxr-button"),n.dataset.needle="webxr-ar-button",n.innerText="Enter AR",n.prepend(Pt("view_in_ar")),n.title="Click to start an AR session",n.addEventListener("click",()=>Z.start(i,s)),this.updateSessionSupported(n,i),this.listenToXRSessionState(n,i),this.hideElementDuringXRSession(n),this.isSecureConnection||(n.disabled=!0,n.title="WebXR requires a secure connection (HTTPS)"),Y.isMozillaXR()||(t=navigator.xr)==null||t.addEventListener("devicechange",()=>this.updateSessionSupported(n,i)),n}createVRButton(s){var t;if(this._vrButton)return this._vrButton;const i="immersive-vr",n=document.createElement("button");return this._vrButton=n,n.classList.add("webxr-button"),n.dataset.needle="webxr-vr-button",n.innerText="Enter VR",n.prepend(Pt("panorama_photosphere")),n.title="Click to start a VR session",n.addEventListener("click",()=>Z.start(i,s)),this.updateSessionSupported(n,i),this.listenToXRSessionState(n,i),this.hideElementDuringXRSession(n),this.isSecureConnection||(n.disabled=!0,n.title="WebXR requires a secure connection (HTTPS)"),Y.isMozillaXR()||(t=navigator.xr)==null||t.addEventListener("devicechange",()=>this.updateSessionSupported(n,i)),n}createSendToQuestButton(){var s;if(this._sendToQuestButton)return this._sendToQuestButton;const t="https://oculus.com/open_url/?url=",i=document.createElement("button");return this._sendToQuestButton=i,i.dataset.needle="webxr-sendtoquest-button",i.innerText="Open on Quest",i.prepend(Pt("share_windows")),i.title="Click to send this page to the Oculus Browser on your Quest",i.addEventListener("click",()=>{const n=encodeURIComponent(window.location.href),o=t+n;window.open(o)==null&&Le("This page doesn't allow popups. Please paste "+o+" into your browser.")}),this.listenToXRSessionState(i),this.hideElementDuringXRSession(i),Y.isMozillaXR()||(s=navigator.xr)==null||s.addEventListener("devicechange",()=>{var n;(n=navigator.xr)!=null&&n.isSessionSupported("immersive-vr")?i.style.display="none":i.style.display=""}),i}createQRCode(){return Mn.getOrCreate().createQRCode()}updateSessionSupported(s,t){if(!("xr"in navigator)){s.style.display="none";return}Z.isSessionSupported(t).then(i=>{s.style.display=i?"":"none",F()&&!i&&console.log('[WebXR] "'+t+'" is not supported on this device \u2013 make sure your server runs using HTTPS and you have a device connected that supports '+t)})}hideElementDuringXRSession(s){kd(t=>{s["previous-display"]=s.style.display,s.style.display="none"}),og(t=>{s["previous-display"]!=null&&(s.style.display=s["previous-display"])})}listenToXRSessionState(s,t){t&&(Z.onSessionRequestStart(i=>{i.mode===t?s.classList.add("this-mode-is-requested"):(s["was-disabled"]=s.disabled,s.disabled=!0,s.classList.add("other-mode-is-requested"))}),Z.onSessionRequestEnd(i=>{s.classList.remove("this-mode-is-requested"),s.classList.remove("other-mode-is-requested"),s.disabled=s["was-disabled"]}))}};let Yr=Gx;a(Yr,"_instance");var AT=Object.defineProperty,IT=Object.getOwnPropertyDescriptor,xt=(s,t,i,n)=>{for(var o=n>1?void 0:n?IT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&AT(t,i,o),o};const vp=O("debugspriterenderer"),jT=O("wireframe"),P0=class{static getOrCreateGeometry(s){if(s.__cached_geometry)return s.__cached_geometry;if(s.guid&&P0.cache[s.guid])return vp&&console.log("Take cached geometry for sprite",s.guid),P0.cache[s.guid];const t=new no;s.__cached_geometry=t;const i=new Float32Array(s.triangles.length*3),n=new Float32Array(s.triangles.length*2);for(let o=0;o<s.triangles.length;o+=1){const r=s.triangles[o];i[o*3]=-s.vertices[r].x,i[o*3+1]=s.vertices[r].y,i[o*3+2]=0;const l=s.uv[r];n[o*2]=l.x,n[o*2+1]=1-l.y}return t.setAttribute("position",new gt(i,3)),t.setAttribute("uv",new gt(n,2)),s.guid&&(this.cache[s.guid]=t),vp&&console.log("Built sprite geometry",s,t),t}};let mh=P0;a(mh,"cache",{});class LT{constructor(){a(this,"x"),a(this,"y")}}function Xx(s){s&&(s.colorSpace!=ps&&(s.colorSpace=ps,s.needsUpdate=!0),s.minFilter==hd&&s.magFilter==hd&&(s.anisotropy=1,s.needsUpdate=!0))}let rn=class{constructor(s){a(this,"guid"),a(this,"texture"),a(this,"triangles"),a(this,"uv"),a(this,"vertices"),a(this,"__cached_geometry"),a(this,"_mesh"),a(this,"_material"),s&&(this.texture=s,this.triangles=[0,1,2,0,2,3],this.uv=[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}],this.vertices=[{x:-.5,y:-.5},{x:.5,y:-.5},{x:.5,y:.5},{x:-.5,y:.5}])}get mesh(){return this._mesh||(this._mesh=new Q(mh.getOrCreateGeometry(this),this.material)),this._mesh}get material(){return this._material||(this.texture&&Xx(this.texture),this._material=new Me({map:this.texture,color:16777215,side:_i,transparent:!0})),this._material}getGeometry(){return mh.getOrCreateGeometry(this)}};xt([m()],rn.prototype,"guid",2),xt([m(Ne)],rn.prototype,"texture",2),xt([Ha()],rn.prototype,"triangles",2),xt([Ha()],rn.prototype,"uv",2),xt([Ha()],rn.prototype,"vertices",2);const k0=Symbol("spriteOwner");class Fo{constructor(){a(this,"sprites")}}xt([m(rn)],Fo.prototype,"sprites",2);const Qx=class{constructor(){a(this,"spriteSheet"),a(this,"index",0)}static create(){const s=new Qx;return s.spriteSheet=new Fo,s}set sprite(s){s&&(this.spriteSheet?((this.index===null||this.index===void 0)&&(this.index=0),this.spriteSheet.sprites[this.index]=s):(this.spriteSheet=new Fo,this.spriteSheet.sprites=[s],this.index=0))}get sprite(){if(this.spriteSheet)return this.spriteSheet.sprites[this.index]}update(s){if(!this.spriteSheet)return;const t=this.index;if(t<0||t>=this.spriteSheet.sprites.length)return;const i=this.spriteSheet.sprites[t],n=i?.texture;if(n&&(Xx(n),!i.__hasLoadedProgressive)){i.__hasLoadedProgressive=!0;const o=n;et.assignTextureLOD(n,0).then(r=>{r instanceof Ne&&(i.texture=r,s?.map===o&&(s.map=r,s.needsUpdate=!0))})}}};let Wn=Qx;xt([m(Fo)],Wn.prototype,"spriteSheet",2),xt([m()],Wn.prototype,"index",2);class pi extends A{constructor(){super(...arguments),a(this,"drawMode",0),a(this,"size",{x:1,y:1}),a(this,"color"),a(this,"sharedMaterial"),a(this,"transparent",!0),a(this,"cutoutThreshold",0),a(this,"castShadows",!1),a(this,"renderOrder",0),a(this,"toneMapped",!0),a(this,"_spriteSheet"),a(this,"_currentSprite")}set texture(t){var i;if(!this._spriteSheet)return;const n=(i=this._spriteSheet.spriteSheet)==null?void 0:i.sprites[this.spriteIndex];n&&(n.texture=t,this.updateSprite())}addSprite(t,i=!1){var n,o;if(this._spriteSheet||(this._spriteSheet=Wn.create()),!this._spriteSheet.spriteSheet)return-1;(n=this._spriteSheet.spriteSheet)==null||n.sprites.push(t);const r=((o=this._spriteSheet.spriteSheet)==null?void 0:o.sprites.length)-1;return i&&(this.spriteIndex=r),r}get sprite(){return this._spriteSheet}set sprite(t){if(t!==this._spriteSheet)if(typeof t=="number"){const i=Math.floor(t);this.spriteIndex=i;return}else t instanceof rn?(this._spriteSheet||(this._spriteSheet=Wn.create()),this._spriteSheet.sprite!=t&&(this._spriteSheet.sprite=t,this.updateSprite())):t!=this._spriteSheet&&(this._spriteSheet=t,this.updateSprite())}set spriteIndex(t){this._spriteSheet&&t!==this.spriteIndex&&(this._spriteSheet.index=t,this.updateSprite())}get spriteIndex(){var t;return((t=this._spriteSheet)==null?void 0:t.index)??0}get spriteFrames(){var t,i;return((i=(t=this._spriteSheet)==null?void 0:t.spriteSheet)==null?void 0:i.sprites.length)??0}awake(){this._currentSprite=void 0,this._spriteSheet||(this._spriteSheet=new Wn,this._spriteSheet.spriteSheet=new Fo),vp&&console.log("Awake",this.name,this,this.sprite)}start(){this._currentSprite?this.gameObject&&this.gameObject.add(this._currentSprite):this.updateSprite()}updateSprite(t=!1){var i;if(!this.__didAwake&&!t)return!1;const n=this._spriteSheet;if(!((i=n?.spriteSheet)!=null&&i.sprites))return console.warn("SpriteRenderer has no data or spritesheet assigned..."),!1;const o=n.spriteSheet.sprites[this.spriteIndex];if(!o)return vp&&console.warn("Sprite not found",this.spriteIndex,n.spriteSheet.sprites),!1;if(this._currentSprite)this._currentSprite.geometry=mh.getOrCreateGeometry(o),this._currentSprite.material.map=o.texture;else{const r=new Me({color:16777215,side:_i});if(jT&&(r.wireframe=!0),this.color&&(r.color||(r.color=new ae),r.color.copy(this.color),r.opacity=this.color.alpha),r.transparent=!0,r.toneMapped=this.toneMapped,o.texture&&!r.wireframe){let l=o.texture;l[k0]!==void 0&&l[k0]!==this&&this.spriteFrames>1&&(l=o.texture=l.clone()),l[k0]=this,r.map=l}this.sharedMaterial=r,this._currentSprite=new Q(mh.getOrCreateGeometry(o),r),this._currentSprite.renderOrder=Math.round(this.renderOrder),et.assignTextureLOD(r,0)}return this._currentSprite.parent!==this.gameObject&&(this.drawMode===2&&this._currentSprite.scale.set(this.size.x,this.size.y,1),this.gameObject&&this.gameObject.add(this._currentSprite)),this._currentSprite&&this._currentSprite.layers.set(this.layer),this.sharedMaterial&&(this.sharedMaterial.alphaTest=this.cutoutThreshold,this.sharedMaterial.transparent=this.transparent),this._currentSprite.castShadow=this.castShadows,n?.update(this.sharedMaterial),!0}}xt([m()],pi.prototype,"drawMode",2),xt([m(LT)],pi.prototype,"size",2),xt([m(we)],pi.prototype,"color",2),xt([m(Oe)],pi.prototype,"sharedMaterial",2),xt([m()],pi.prototype,"transparent",2),xt([m()],pi.prototype,"cutoutThreshold",2),xt([m()],pi.prototype,"castShadows",2),xt([m()],pi.prototype,"renderOrder",2),xt([m()],pi.prototype,"toneMapped",2),xt([m(Wn)],pi.prototype,"sprite",1);const Yx=O("debugwebxr"),DT=new ne().makeRotationY(Math.PI);class Vn extends A{constructor(){super(...arguments),a(this,"_arScale",1),a(this,"invertForward",!1),a(this,"customReticle"),a(this,"arTouchTransform",!0),a(this,"autoPlace",!1),a(this,"autoCenter",!1),a(this,"useXRAnchor",!1),a(this,"_isPlacing",!0),a(this,"_startOffset",new ne),a(this,"_createdPlacementObject",null),a(this,"_reparentedComponents",[]),a(this,"_placementScene",new $i),a(this,"_reticle",[]),a(this,"_hits",[]),a(this,"_placementStartTime",-1),a(this,"_rigPlacementMatrix"),a(this,"_anchor",null),a(this,"userInput"),a(this,"onPlaceScene",t=>{var i;if(this._isPlacing==!1||t!=null&&t.used)return;let n=this._reticle[0];if(!n){console.warn("No reticle to place...");return}if(!n.visible&&!this.autoPlace){console.warn("Reticle is not visible (can not place)");return}if((i=Z.active)!=null&&i.isTrackingImages){console.warn("Scene Placement is disabled while images are being tracked");return}let o=this._hits[0];if(t&&t.origin instanceof rg){const r=this._reticle[t.origin.index];r&&(n=r,o=this._hits[t.origin.index])}if(t&&(t.stopImmediatePropagation(),t.stopPropagation(),t.use()),this._isPlacing=!1,this.context.input.removeEventListener("pointerup",this.onPlaceScene),this.onRevertSceneChanges(),n.position.copy(n.lastPos),n.quaternion.copy(n.lastQuat),this.onApplyPose(n),this.useXRAnchor&&this.onCreateAnchor(Z.active,o),this.context.xr)for(const r of this.context.xr.controllers)r.cancelHitTestSource()}),a(this,"upVec",new x(0,1,0)),a(this,"lookPoint",new x),a(this,"worldUpVec",new x(0,1,0))}static onPlaced(t){const i="placed";return this._eventListeners[i]||(this._eventListeners[i]=[]),this._eventListeners[i].push(t),()=>{const n=this._eventListeners[i].indexOf(t);n>=0&&this._eventListeners[i].splice(n,1)}}get arScale(){return this._arScale}set arScale(t){t!==this._arScale&&(this._arScale=t,this.onScaleChanged())}onEnable(){var t;(t=this.customReticle)==null||t.preload()}supportsXR(t){return t==="immersive-ar"}onEnterXR(t){Yx&&console.log("ENTER WEBXR: SessionRoot start..."),this._anchor=null,this.gameObject.updateMatrixWorld(),this._startOffset.copy(this.gameObject.matrixWorld);const i=new j;this._createdPlacementObject=i,i.name="AR Session Root",this._placementScene.name="AR Placement Scene",this._placementScene.children.length=0;for(let n=this.context.scene.children.length-1;n>=0;n--){const o=this.context.scene.children[n];this._placementScene.add(o)}if(this.context.scene.add(i),this.autoCenter){const n=Si(this._placementScene.children),o=n.getCenter(new x),r=n.getSize(new x),l=new ne;l.makeTranslation(o.x,o.y-r.y*.5,o.z),this._startOffset.multiply(l)}this._reparentedComponents.length=0,this._reparentedComponents.push({comp:this,originalObject:this.gameObject}),P.addComponent(i,this);for(const n of this._reticle)Mi(n);this._reticle.length=0,this._isPlacing=!0,this.context.input.addEventListener("pointerup",this.onPlaceScene,{queue:Ci.Early})}onLeaveXR(){this.context.input.removeEventListener("pointerup",this.onPlaceScene,{queue:Ci.Early}),this.onRevertSceneChanges(),this._anchor=null,this._rigPlacementMatrix=void 0}onUpdateXR(t){var i,n,o,r;if(t.xr.isTrackingImages){for(const l of this._reticle)l.visible=!1;return}if(this._isPlacing){const l=(i=t.xr.rig)==null?void 0:i.gameObject;l&&l.parent!==this.context.scene&&this.context.scene.add(l);let c=!1;if(t.xr.isPassThrough&&t.xr.controllers.length>0&&!this.autoPlace)for(const h of t.xr.controllers){const d=h.getHitTest();d&&(c=!0,this.updateReticleAndHits(t.xr,h.index,d,t.xr.rigScale))}if(!c){const h=t.xr.getHitTest();h&&this.updateReticleAndHits(t.xr,0,h,t.xr.rigScale)}}else{if(this._anchor&&t.xr.referenceSpace){const l=t.xr.frame.getPose(this._anchor.anchorSpace,t.xr.referenceSpace);if(l&&this.context.time.frame%20===0){const c=t.xr.convertSpace(l.transform),h=this._reticle[0];h&&(h.position.copy(c.position),h.quaternion.copy(c.quaternion),this.onApplyPose(h))}}if(this.arTouchTransform?(this.userInput||(this.userInput=new bp(this.context)),(n=this.userInput)==null||n.enable()):(o=this.userInput)==null||o.disable(),this.arTouchTransform&&(r=this.userInput)!=null&&r.hasChanged){if(t.xr.rig){const l=t.xr.rig.gameObject;this.userInput.applyMatrixTo(l.matrix,!0),l.matrix.decompose(l.position,l.quaternion,l.scale),this.userInput.factor=l.scale.x}this.userInput.reset()}}}updateReticleAndHits(t,i,n,o){this._hits[i]=n.hit;let r=this._reticle[i];if(!r){if(this.customReticle)if(this.customReticle.asset)r=za(this.customReticle.asset);else{this.customReticle.loadAssetAsync();return}else r=new Q(new rC(.07,.09,32).rotateX(-Math.PI/2),new Me({side:_i,depthTest:!1,depthWrite:!1,transparent:!0,opacity:1,color:15658734})),r.name="AR Placement Reticle";if(Yx){const l=new bi(1);l.position.y+=.01,r.add(l)}this._reticle[i]=r,r.matrixAutoUpdate=!1,r.visible=!1}if(r.lastPos=r.lastPos||n.position.clone(),r.lastQuat=r.lastQuat||n.quaternion.clone(),r.position.copy(r.lastPos.lerp(n.position,this.context.time.deltaTime/.1)),r.lastPos.copy(r.position),r.quaternion.copy(r.lastQuat.slerp(n.quaternion,this.context.time.deltaTime/.05)),r.lastQuat.copy(r.quaternion),r.scale.set(o,o,o),this.customReticle&&this.applyViewBasedTransform(r),r.updateMatrix(),r.visible=!0,r.parent!==this.context.scene&&this.context.scene.add(r),this._placementStartTime<0&&(this._placementStartTime=this.context.time.realtimeSinceStartup),this.autoPlace)if(this.upVec.set(0,1,0).applyQuaternion(r.quaternion),this.upVec.dot($(0,1,0))>.9){let l=r["autoplace:timer"]||0;l>=1?(r.visible=!1,this.onPlaceScene(null)):(l+=this.context.time.deltaTime,r["autoplace:timer"]=l)}else r["autoplace:timer"]=0}onScaleChanged(){}onRevertSceneChanges(){var t;for(const i of this._reticle)i&&(i.visible=!1,i?.removeFromParent());this._reticle.length=0;for(let i=this._placementScene.children.length-1;i>=0;i--){const n=this._placementScene.children[i];this.context.scene.add(n)}(t=this._createdPlacementObject)==null||t.removeFromParent();for(const i of this._reparentedComponents)P.addComponent(i.originalObject,i.comp)}async onCreateAnchor(t,i){if(i.createAnchor===void 0){console.warn("Hit does not support creating an anchor",i),F()&&_e("Hit does not support creating an anchor");return}else{const n=await i.createAnchor(t.viewerPose.transform);t.running&&n&&(this._anchor=n)}}applyViewBasedTransform(t){const i=this.context.mainCamera,n=t,o=i.worldPosition,r=n.worldPosition;this.upVec.set(0,1,0).applyQuaternion(t.quaternion);const l=i.worldPosition;l&&t.position.clone().sub(l).angleTo(this.upVec)<Math.PI/2&&this.upVec.negate();const c=this.upVec.angleTo(this.worldUpVec)*180/Math.PI,h=30;c>h&&c<180-h||c<-h&&c>-180+h?(this.lookPoint.copy(t.position).add(this.upVec),this.lookPoint.y=t.position.y,t.lookAt(this.lookPoint)):(o.y=r.y,t.lookAt(o))}onApplyPose(t){var i,n,o,r;const l=(n=(i=Z.active)==null?void 0:i.rig)==null?void 0:n.gameObject;if(!l){console.warn("No rig object to place");return}(o=Z.active)!=null&&o.rigScale;const c=l.parent||this.context.scene;this._rigPlacementMatrix?(r=this._rigPlacementMatrix)==null||r.decompose(l.position,l.quaternion,l.scale):this._rigPlacementMatrix=l.matrix.clone(),this.applyViewBasedTransform(t),t.updateMatrix(),this.context.scene.add(t),t.attach(l),t.removeFromParent(),l.scale.set(this.arScale,this.arScale,this.arScale),l.position.multiplyScalar(this.arScale),l.updateMatrix(),this.invertForward&&l.matrix.premultiply(DT),l.matrix.premultiply(this._startOffset),l.matrix.decompose(l.position,l.quaternion,l.scale),c.add(l)}}a(Vn,"_eventListeners",{});const M0=class{constructor(s){a(this,"oneFingerDrag",!0),a(this,"twoFingerRotate",!0),a(this,"twoFingerScale",!0),a(this,"factor",1),a(this,"context"),a(this,"offset"),a(this,"plane"),a(this,"_scale",1),a(this,"_hasChanged",!1),a(this,"_enabled",!1),a(this,"currentlyUsedPointerIds",new Set),a(this,"currentlyUnusedPointerIds",new Set),a(this,"onPointerDownEarly",t=>{this.isActive&&t.stopPropagation()}),a(this,"onPointerDownLate",t=>{t.used?this.currentlyUsedPointerIds.add(t.pointerId):this.currentlyUsedPointerIds.size<=0&&this.currentlyUnusedPointerIds.add(t.pointerId)}),a(this,"onPointerUpEarly",t=>{this.currentlyUsedPointerIds.delete(t.pointerId),this.currentlyUnusedPointerIds.delete(t.pointerId)}),a(this,"prev",new Map),a(this,"_didMultitouch",!1),a(this,"touchStart",t=>{if(!t.defaultPrevented)for(let i=0;i<t.changedTouches.length;i++){const n=t.changedTouches[i],o=Y.isAndroidDevice()&&n.clientY<window.innerHeight*.1;this.prev.has(n.identifier)||this.prev.set(n.identifier,{ignore:o,x:0,z:0,screenx:0,screeny:0});const r=this.prev.get(n.identifier);if(r){const l=this.getPositionOnPlane(n.clientX,n.clientY);r.x=l.x,r.z=l.z,r.screenx=n.clientX,r.screeny=n.clientY}}}),a(this,"touchEnd",t=>{t.touches.length<=0&&(this._didMultitouch=!1);for(let i=0;i<t.changedTouches.length;i++){const n=t.changedTouches[i];this.prev.delete(n.identifier)}}),a(this,"touchMove",t=>{if(!t.defaultPrevented&&this.isActive){if(t.touches.length===1){if(this._didMultitouch)return;const i=t.touches[0],n=this.prev.get(i.identifier);if(!n||n.ignore)return;const o=this.getPositionOnPlane(i.clientX,i.clientY),r=o.x-n.x,l=o.z-n.z;if(r===0&&l===0)return;this.oneFingerDrag&&this.addMovement(r,l),n.x=o.x,n.z=o.z,n.screenx=i.clientX,n.screeny=i.clientY;return}else if(t.touches.length===2){this._didMultitouch=!0;const i=t.touches[0],n=t.touches[1],o=this.prev.get(i.identifier),r=this.prev.get(n.identifier);if(!o||!r)return;if(this.twoFingerRotate){const l=Math.atan2(i.clientY-n.clientY,i.clientX-n.clientX),c=Math.atan2(o.screeny-r.screeny,o.screenx-r.screenx),h=l-c;Math.abs(h)>.001&&this.addRotation(h)}if(this.twoFingerScale){const l=i.clientX-n.clientX,c=i.clientY-n.clientY,h=Math.sqrt(l*l+c*c),d=o.screenx-r.screenx,u=o.screeny-r.screeny,p=Math.sqrt(d*d+u*u),g=h-p;Math.abs(g)>2&&this.addScale(g)}o.screenx=i.clientX,o.screeny=i.clientY,r.screenx=n.clientX,r.screeny=n.clientY}}}),a(this,"_raycaster",new ld),a(this,"_intersection",new x),a(this,"_screenPos",new x),a(this,"_tempMatrix",new ne),this.context=s,this.offset=new ne,this.plane=new dr,this.plane.setFromNormalAndCoplanarPoint(M0.up,M0.zero)}reset(){this._scale=1,this.offset.identity()}get hasChanged(){return this._hasChanged}applyMatrixTo(s,t){this._hasChanged=!1,t?(this.offset.invert(),s.premultiply(this.offset)):s.multiply(this.offset)}get isActive(){return this.currentlyUsedPointerIds.size<=0&&this.currentlyUnusedPointerIds.size>0}enable(){this._enabled||(this._enabled=!0,this.context.input.addEventListener("pointerdown",this.onPointerDownEarly,{queue:Ci.Early}),this.context.input.addEventListener("pointerdown",this.onPointerDownLate,{queue:Ci.Late}),this.context.input.addEventListener("pointerup",this.onPointerUpEarly,{queue:Ci.Early}),window.addEventListener("touchstart",this.touchStart,{passive:!1}),window.addEventListener("touchmove",this.touchMove,{passive:!1}),window.addEventListener("touchend",this.touchEnd,{passive:!1}))}disable(){this._enabled&&(this._enabled=!1,this.context.input.removeEventListener("pointerdown",this.onPointerDownEarly,{queue:Ci.Early}),this.context.input.removeEventListener("pointerdown",this.onPointerDownLate,{queue:Ci.Late}),this.context.input.removeEventListener("pointerup",this.onPointerUpEarly,{queue:Ci.Early}),window.removeEventListener("touchstart",this.touchStart),window.removeEventListener("touchmove",this.touchMove),window.removeEventListener("touchend",this.touchEnd))}getPositionOnPlane(s,t){const i=this.context.mainCamera;return this._screenPos.x=s/window.innerWidth*2-1,this._screenPos.y=-(t/window.innerHeight)*2+1,this._screenPos.z=1,this._screenPos.unproject(i),this._raycaster.set(i.position,this._screenPos.sub(i.position)),this._raycaster.ray.intersectPlane(this.plane,this._intersection),this._intersection}addMovement(s,t){s/=this._scale,t/=this._scale,s*=this.factor,t*=this.factor,this.offset.elements[12]+=s,this.offset.elements[14]+=t,(s!==0||t!==0)&&(this._hasChanged=!0)}addScale(s){s/=window.innerWidth,s*=-1,this._scale*=1+s,this._tempMatrix.makeScale(1-s,1-s,1-s),this.offset.premultiply(this._tempMatrix),s!==0&&(this._hasChanged=!0)}addRotation(s){s*=-1,this._tempMatrix.makeRotationY(s),this.offset.premultiply(this._tempMatrix),s!==0&&(this._hasChanged=!0)}};let bp=M0;a(bp,"up",new x(0,1,0)),a(bp,"zero",new x(0,0,0)),a(bp,"one",new x(1,1,1));const zo=O("debugautosync"),R0=Symbol("syncerId");class BT{constructor(){a(this,"_syncers",{})}getOrCreateSyncer(t){if(!t.guid)return null;if(this._syncers[t.guid])return this._syncers[t.guid];const i=new FT(t);return i[R0]=t.guid,this._syncers[i[R0]]=i,i}removeSyncer(t){delete this._syncers[t[R0]]}}const T0=new BT;class FT{constructor(t){a(this,"comp"),a(this,"hasChanges",!1),a(this,"changedProperties",{}),a(this,"_isReceiving",!1),a(this,"_isInit",!1),a(this,"onHandleSending",()=>{if(!this.hasChanges)return;this.hasChanges=!1;const i=this.comp.context.connection;if(!i||!i.isConnected||!i.isInRoom){for(const n in this.changedProperties)delete this.changedProperties[n];return}for(const n in this.changedProperties){const o=this.changedProperties[n];zo&&console.log("SEND",this.comp.guid,this.networkingKey),i.send(this.networkingKey,{guid:this.comp.guid,property:n,data:o},bs.Queued),delete this.changedProperties[n]}}),a(this,"onHandleReceiving",i=>{if(zo&&console.log("SYNCFIELD RECEIVE",this.comp.name,this.comp.guid,i),!!this._isInit&&this.comp&&i.guid===this.comp.guid)try{this._isReceiving=!0,this.comp[i.property]=i.data}catch(n){console.error(n)}finally{this._isReceiving=!1}}),this.comp=t}get networkingKey(){return this.comp.guid}init(t){if(this._isInit)return;this._isInit=!0,this.comp=t,this.comp.context.post_render_callbacks.push(this.onHandleSending),this.comp.context.connection.beginListen(this.networkingKey,this.onHandleReceiving);const i=this.comp.context.connection.tryGetState(this.comp.guid);i&&this.onHandleReceiving(i)}destroy(){this._isInit&&(this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this.onHandleSending),1),this.comp.context.connection.stopListen(this.networkingKey,this.onHandleReceiving),this.comp=null,this._isInit=!1)}notifyChanged(t,i){this._isReceiving||(zo&&console.log("Property changed: "+t,i),this.hasChanges=!0,this.changedProperties[t]=i)}}function zT(s,t){let i=t!==s;return!i&&s&&t&&(Array.isArray(s)&&Array.isArray(t)||typeof s=="object"&&typeof t=="object")&&(i=!0),i}const gh=Symbol("AutoSyncHandler");function UT(s){if(s[gh])return s[gh];const t=T0.getOrCreateSyncer(s);return t?.init(s),s[gh]=t,t}function NT(s){const t=s[gh];t&&(T0.removeSyncer(t),t.destroy(),delete s[gh])}const E0=function(s=null){return function(t,i){var n;let o="";typeof i=="string"?o=i:o=i.name;let r=null,l;typeof s=="string"?l=t[s]:typeof s=="function"&&(l=s),l==null&&(F()||zo)&&s!=null&&console.warn('syncField: no callback function found for property "'+o+'"','"'+s+'"');const c=t,h=c.__internalAwake;if(typeof h!="function"){(zo||F())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((n=t?.constructor)==null?void 0:n.name)+'" is not supported',t);return}zo&&console.log(o);const d=Symbol(o);c.__internalAwake=function(){if(this[d]!==void 0)return;this[d]=this[o],r=T0.getOrCreateSyncer(this);const p=Object.getOwnPropertyDescriptor(this,o);if(p?.set===void 0){let g=!1;Object.defineProperty(this,o,{set:function(y){var f;const v=this[d];if(this[d]=y,g){(F()||zo)&&console.warn("Recursive call detected",o);return}g=!0;try{const b=zT(y,v);zo&&console.log("SyncField assignment",o,"changed?",b,y,l),b&&l?.call(this,y,v)!==!1&&((f=UT(this))==null||f.notifyChanged(o,y))}finally{g=!1}},get:function(){return this[d]},configurable:!0,enumerable:!0})}r?.init(this),h.call(this)};const u=c.__internalDestroy;c.__internalDestroy=function(){NT(this),u.call(this)}}};var WT=Object.defineProperty,VT=Object.getOwnPropertyDescriptor,_p=(s,t,i,n)=>{for(var o=n>1?void 0:n?VT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&WT(t,i,o),o};const ti=O("debugplayersync"),Kx=class extends A{constructor(){super(...arguments),a(this,"autoSync",!0),a(this,"asset"),a(this,"onPlayerSpawned"),a(this,"_localInstance"),a(this,"onJoinedRoom",()=>{ti&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()}),a(this,"destroyInstance",()=>{var s;(s=this._localInstance)==null||s.then(t=>{ti&&console.log("PlayerSync.destroyInstance",t),vc(t,this.context.connection,!0,{saveInRoom:!1})}),this._localInstance=void 0})}static async setupFrom(s,t){const i=le.getOrCreateFromUrl(s);if(!i.asset){const r=await i.loadAssetAsync();r&&P.getOrAddComponent(r,ji)}const n=new Kx;n._internalInit(t),n.asset=i;const o=new j;return o.guid=s,P.addComponent(o,n),n}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new ke)}onEnable(){this.context.connection.beginListen(ie.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(ie.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(ie.LeftRoom,this.destroyInstance),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(ie.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(ie.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(ie.LeftRoom,this.destroyInstance)}async getInstance(){var s,t,i,n,o,r;if(this._localInstance)return this._localInstance;if(ti&&console.log("PlayerSync.createInstance",(s=this.asset)==null?void 0:s.url),!((t=this.asset)!=null&&t.asset)&&!((i=this.asset)!=null&&i.url))return console.error('PlayerSync: can not create an instance because "asset" is not set and or has no URL!'),null;this.gameObject.guid||console.warn("PlayerSync: gameObject has no guid! This might cause issues with syncing the player state."),this._localInstance=(n=this.asset)==null?void 0:n.instantiateSynced({parent:this.gameObject,deleteOnDisconnect:!0},!0);const l=await this._localInstance;if(l){const c=P.getComponentsInChildren(l,ji);if(ti&&console.log(`PlayerSync.createInstance: found ${c?.length} PlayerState components. Owner: ${this.context.connection.connectionId}`),c!=null&&c.length){for(const h of c)h.owner=this.context.connection.connectionId;(o=this.onPlayerSpawned)==null||o.invoke(l)}else this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((r=this.asset)==null?void 0:r.url)+"</strong>: please make sure the asset has a PlayerState component!"),P.destroySynced(l)}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}watchTabVisible(){window.addEventListener("visibilitychange",s=>{if(document.visibilityState==="visible")for(let t=ji.all.length-1;t>=0;t--){const i=ji.all[t];(!i.owner||!this.context.connection.userIsInRoom(i.owner))&&i.doDestroy()}})}};let bl=Kx;_p([m()],bl.prototype,"autoSync",2),_p([m(le)],bl.prototype,"asset",2),_p([m(ke)],bl.prototype,"onPlayerSpawned",2);var Zx=(s=>(s.OwnerChanged="ownerChanged",s))(Zx||{}),fh;const Et=(fh=class extends A{constructor(){super(...arguments),a(this,"onOwnerChangeEvent",new ke),a(this,"onFirstOwnerChangeEvent",new ke),a(this,"hasOwner",!1),a(this,"owner"),a(this,"dontDestroy",!1),a(this,"onUserLeftRoom",s=>{if(s.userId===this.owner){ti&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return Et._all}static get local(){return Et._local}static getFor(s){if(s instanceof j)return P.getComponentInParent(s,Et);if(s instanceof A)return P.getComponentInParent(s.gameObject,Et)}static isLocalPlayer(s){const t=Et.getFor(s);return t?.isLocalPlayer??!1}static addEventListener(s,t){return this._callbacks[s]||(this._callbacks[s]=[]),this._callbacks[s].push(t),t}static removeEventListener(s,t){if(!this._callbacks[s])return;const i=this._callbacks[s].indexOf(t);i>=0&&this._callbacks[s].splice(i,1)}static dispatchEvent(s,t){if(this._callbacks[s])for(const i of this._callbacks[s])i(t)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(s,t){var i,n;ti&&console.log(`PlayerSync.onOwnerChange: ${t} \u2192 ${s} (me: ${this.context.connection.connectionId})`);const o=Et._local.indexOf(this);o>=0&&Et._local.splice(o,1);const r={playerState:this,oldValue:t,newValue:s};if(this.hasOwner||(this.hasOwner=!0,(i=this.onFirstOwnerChangeEvent)==null||i.invoke(r)),(n=this.onOwnerChangeEvent)==null||n.invoke(r),this.owner===this.context.connection.connectionId){Et._local.push(this);const c=new CustomEvent("local-owner-changed",{detail:r});this.dispatchEvent(c)}const l=new CustomEvent("owner-changed",{detail:r});this.dispatchEvent(l),Et.dispatchEvent("ownerChanged",l)}awake(){Et.all.push(this),ti&&console.log("Registered new PlayerState",this.guid,Et.all.length-1,Et.all),this.context.connection.beginListen(ie.UserLeftRoom,this.onUserLeftRoom)}async start(){ti&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await gs(300),this.context.connection.userIsInRoom(this.owner)==!1&&(ti&&console.log(`PlayerSync.start \u2192 doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(ti&&console.warn("PlayerState.start \u2192 owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?ti&&console.warn("PlayerState.start \u2192 owner is still undefined but dontDestroy is set to true",this.name):(ti&&console.warn(`PlayerState.start \u2192 owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):ti&&console.log("PlayerState.start \u2192 owner is assigned",this.owner)},2e3))}doDestroy(){ti&&console.log("PlayerSync.doDestroy \u2192 syncDestroy",this.name),vc(this.gameObject,this.context.connection,!0,{saveInRoom:!1})}onDestroy(){if(ti&&console.warn("PlayerState.onDestroy",this.owner),this.context.connection.stopListen(ie.UserLeftRoom,this.onUserLeftRoom),Et.all.splice(Et.all.indexOf(this),1),this.isLocalPlayer){const s=Et._local.indexOf(this);s>=0&&Et._local.splice(s,1)}}},a(fh,"_all",[]),a(fh,"_local",[]),a(fh,"_callbacks",{}),fh);let ji=Et;_p([E0(ji.prototype.onOwnerChange)],ji.prototype,"owner",2);var HT=Object.defineProperty,$T=Object.getOwnPropertyDescriptor,_l=(s,t,i,n)=>{for(var o=n>1?void 0:n?$T(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&HT(t,i,o),o};class an extends A{constructor(){super(...arguments),a(this,"position","bottom"),a(this,"showNeedleLogo",!0),a(this,"showSpatialMenu"),a(this,"createFullscreenButton"),a(this,"createMuteButton"),a(this,"createQRCodeButton")}onEnable(){this.applyOptions()}applyOptions(){this.context.menu.setPosition(this.position),this.context.menu.showNeedleLogo(this.showNeedleLogo),this.createFullscreenButton===!0&&this.context.menu.showFullscreenOption(!0),this.createMuteButton===!0&&this.context.menu.showAudioPlaybackOption(!0),this.showSpatialMenu===!0&&this.context.menu.showSpatialMenu(this.showSpatialMenu),this.createQRCodeButton===!0&&(Y.isMobileDevice()||this.context.menu.showQRCodeButton(!0))}}_l([m()],an.prototype,"position",2),_l([m()],an.prototype,"showNeedleLogo",2),_l([m()],an.prototype,"showSpatialMenu",2),_l([m()],an.prototype,"createFullscreenButton",2),_l([m()],an.prototype,"createMuteButton",2),_l([m()],an.prototype,"createQRCodeButton",2);var qT=Object.defineProperty,GT=Object.getOwnPropertyDescriptor,A0=(s,t,i,n)=>{for(var o=n>1?void 0:n?GT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&qT(t,i,o),o};const yh=O("debugwebxr"),Jx=new V().setFromAxisAngle(new x(0,1,0),Math.PI);class Uo extends A{constructor(){super(...arguments),a(this,"head"),a(this,"leftHand"),a(this,"rightHand"),a(this,"_leftHandMeshes"),a(this,"_rightHandMeshes"),a(this,"_syncTransforms")}async onEnterXR(t){if(!this.activeAndEnabled)return;yh&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const i=ji.getFor(this);if(i!=null&&i.owner){const n=this.gameObject.addComponent(Rt);n.avatar=this.gameObject,n.connectionId=i.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):i&&!this.context.connection.isConnected&&(i.dontDestroy=!0)}onLeaveXR(t){const i=this.gameObject.getComponent(Rt);i&&i.destroy()}onUpdateXR(t){var i,n;if(!this.activeAndEnabled)return;const o=ji.isLocalPlayer(this);if(!o)return;const r=t.xr;if(r.rig&&r.rig.gameObject!==this.gameObject.parent&&(this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),this.gameObject.scale.set(1,1,1),r.rig.gameObject.add(this.gameObject)),this._syncTransforms&&o)for(const u of this._syncTransforms)u.fastMode=!0,u.isOwned()||u.requestOwnership();if(this.head&&this.context.mainCamera){const u=this.head.asset;if(u.position.copy(this.context.mainCamera.position),u.position.x*=-1,u.position.z*=-1,u.quaternion.copy(this.context.mainCamera.quaternion),u.quaternion.x*=-1,this.context.time.frameCount%10===0&&this.head.asset){const p=P.getComponentsInChildren(this.head.asset,Ei);for(const g of p)g.enabled=!1,g.gameObject.visible=!1}}const l=t.xr.leftController,c=(i=this.leftHand)==null?void 0:i.asset;l&&c?(c.position.copy(l.gripPosition),c.quaternion.copy(l.gripQuaternion),c.quaternion.multiply(Jx),c.visible=l.isTracking,this.updateHandVisibility(l,c,this._leftHandMeshes)):c&&c.visible&&(c.visible=!1);const h=t.xr.rightController,d=(n=this.rightHand)==null?void 0:n.asset;h&&d?(d.position.copy(h.gripPosition),d.quaternion.copy(h.gripQuaternion),d.quaternion.multiply(Jx),d.visible=h.isTracking,this.updateHandVisibility(h,d,this._rightHandMeshes)):d&&d.visible&&(d.visible=!1)}onBeforeRender(){this.context.xr&&this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateHandVisibility(t,i,n){if(n){const o=t.model&&t.model.visible&&t.model!==i;n.forEach(r=>{Pn(r,!o)})}}updateRemoteAvatarVisibility(){var t,i,n;if(this.context.connection.isConnected){const o=ji.getFor(this);if(o&&o.isLocalPlayer==!1){const r=Z.getXRSync(this.context);if(r&&r.hasState(o.owner)){this.tryFindAvatarObjectsIfMissing();const l=(t=this.leftHand)==null?void 0:t.asset;l&&(l.visible=r?.isTracking(o.owner,"left")??!1);const c=(i=this.rightHand)==null?void 0:i.asset;c&&(c.visible=r?.isTracking(o.owner,"right")??!1)}if((n=this.head)!=null&&n.asset){const l=P.getComponentsInChildren(this.head.asset,Ei);for(const c of l)c.enabled=!1,c.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const t={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};Wb.tryFindAvatarObjects(this.gameObject,this.sourceId||"",t),t.head&&(this.head=t.head),t.leftHand&&(this.leftHand=t.leftHand),t.rightHand&&(this.rightHand=t.rightHand)}}async prepareAvatar(){var t,i;if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof j&&(this.head=new le("",this.sourceId,this.head));else{const n=new j;n.name="Head";const o=po.createPrimitive(_r.Cube);n.add(o),this.gameObject.add(n),this.head=new le("",this.sourceId,n),yh&&console.log("Create head",n)}if(this.rightHand)this.rightHand instanceof j&&(this.rightHand=new le("",this.sourceId,this.rightHand));else{const n=new j;n.name="Right Hand",this.gameObject.add(n),this.rightHand=new le("",this.sourceId,n),yh&&console.log("Create right hand",n)}if(this.leftHand)this.leftHand instanceof j&&(this.leftHand=new le("",this.sourceId,this.leftHand));else{const n=new j;n.name="Left Hand",this.gameObject.add(n),this.leftHand=new le("",this.sourceId,n),yh&&console.log("Create left hand",n)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),this._leftHandMeshes=[],(t=this.leftHand.asset)==null||t.traverse(n=>{n!=null&&n.isMesh&&this._leftHandMeshes.push(n)}),this._rightHandMeshes=[],(i=this.rightHand.asset)==null||i.traverse(n=>{n!=null&&n.isMesh&&this._rightHandMeshes.push(n)}),ji.isLocalPlayer(this.gameObject)&&(this._syncTransforms=P.getComponentsInChildren(this.gameObject,$s))}async loadAvatarObjects(t,i,n){const o=t.loadAssetAsync(),r=i.loadAssetAsync(),l=n.loadAssetAsync(),c=new Array;o&&c.push(o),r&&c.push(r),l&&c.push(l);const h=await yd(c);yh&&console.log("Avatar loaded results:",h)}}A0([m(le)],Uo.prototype,"head",2),A0([m(le)],Uo.prototype,"leftHand",2),A0([m(le)],Uo.prototype,"rightHand",2);var XT=Object.defineProperty,QT=Object.getOwnPropertyDescriptor,wp=(s,t,i,n)=>{for(var o=n>1?void 0:n?QT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&XT(t,i,o),o};const Hn=O("debugwebxr"),No=new Array;class ln extends A{constructor(){super(...arguments),a(this,"createControllerModel",!0),a(this,"createHandModel",!0),a(this,"customLeftHand"),a(this,"customRightHand"),a(this,"_models",new Array)}supportsXR(t){return t==="immersive-vr"||t==="immersive-ar"}async onXRControllerAdded(t){var i;if(!(t.xr.isVR||t.xr.isPassThrough))return;const{controller:n}=t;if(Hn&&console.warn("Add Controller Model for",n.side,n.index),this.createControllerModel||this.createHandModel){if(n.hand){if(this.createHandModel){const o=await this.loadHandModel(this,n);if(!o||!n.connected||!n.isHand){o!=null&&o.handObject&&Fa(o.handObject,!1),(i=o?.handObject)==null||i.destroy();return}this._models.push({controller:n,model:o.handObject,handmesh:o.handmesh}),this._models.sort((r,l)=>r.controller.index-l.controller.index),this.scene.add(o.handObject),n.model=o.handObject}}else if(this.createControllerModel){const o=await n.getModelUrl();if(o){const r=await this.loadModel(n,o);if(!r||!n.connected||n.isHand)return;this._models.push({controller:n,model:r}),this._models.sort((l,c)=>l.controller.index-c.controller.index),this.scene.add(r),r.traverse(l=>{l.layers.set(2),l.matrixAutoUpdate=!1,l.updateMatrix()}),n.model=r}else n.targetRayMode!=="transient-pointer"&&console.warn("XRControllerModel: no model found for "+n.side)}}}onXRControllerRemoved(t){console.debug("XR Controller Removed",t.controller.side,t.controller.index);const i=this._models.findIndex(o=>o.controller===t.controller),n=this._models[i];n&&(this._models.splice(i,1),n.model&&(Fa(n.model,!1),n.model.destroy(),n.model=void 0))}onLeaveXR(t){for(const i of this._models)i&&(i.model&&(Fa(i.model,!1),i.model.destroy(),i.model=void 0),i.controller.model===i.model&&(i.controller.model=null));this._models.length=0}onBeforeRender(){if(Z.active&&(Hn&&(No[0]=Date.now()),this.updateRendering(Z.active),Hn)){const t=Date.now()-No[0];No.push(t),No.length>=30&&(No[0]=0,No.reduce((i,n)=>i+n,0)/No.length,No.length=0)}}updateRendering(t){var i,n,o,r,l;for(let c=0;c<this._models.length;c++){const h=this._models[c];if(!h)continue;const d=h.controller;if(!d.connected){Hn&&console.warn("XRControllerModel.onUpdateXR: controller is not connected anymore",d.side,d.hand);continue}if(h.model&&!h.handmesh)h.model.matrixAutoUpdate=!1,h.model.matrix.copy(d.gripMatrix),h.model.visible=d.isTracking,(i=t.rig)==null||i.gameObject.add(h.model);else if(d.inputSource.hand&&h.handmesh){const u=t.referenceSpace,p=this.context.renderer.xr.getHand(d.index);if(u&&t.frame.getJointPose){for(const g of d.inputSource.hand.values()){const y=p.joints[g.jointName];if(y){const f=d.getHandJointPose(g);if(f){const v=f.transform.position,b=f.transform.orientation;y.position.copy(v),y.quaternion.copy(b),y.matrixAutoUpdate=!1}y.visible=f!=null}}h.model&&(h.model.visible=d.isTracking,h.model.visible&&h.model.parent!==((n=t.rig)==null?void 0:n.gameObject)&&((o=t.rig)==null||o.gameObject.add(h.model))),(r=h.model)!=null&&r.visible&&((l=h.handmesh)==null||l.updateMesh(),h.model.matrixAutoUpdate=!1,h.model.matrix.identity(),h.model.applyMatrix4(Ma))}}}}async loadModel(t,i){var n;if(!t.connected)return console.warn("XRControllerModel.onXRControllerAdded: controller is not connected anymore",t.side),null;const o=await le.getOrCreate("",i).instantiate();return Fa(o),(n=Z.active)!=null&&n.isPassThrough&&o.traverseVisible(r=>{this.makeOccluder(r)}),o}async loadHandModel(t,i){const n=this.context,o=n.renderer.xr.getHand(i.index);o||(Hn?q.DrawLabel(i.rayWorldPosition,"No hand found for index "+i.index,.05,5):console.warn("No hand found for index "+i.index));const r=new mr;bu(r,n),await Yu(r,n,this.sourceId??"");const l=Qu(r);let c="";const h=i.side==="left"?this.customLeftHand:this.customRightHand;h?(c=h.url.split(".").slice(0,-1).join("."),r.setPath("")):(c=i.inputSource.handedness==="left"?"left":"right",r.setPath("https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles/generic-hand/"));const d=new j;Fa(d);const u=new zC(d,o,r.path,c,r,p=>{var g;const y=l.gltf;((g=y?.scene.children)==null?void 0:g.length)===0&&(y.scene.children[0]=p),ms().createBuiltinComponents(t.context,t.sourceId||c,l.gltf,null,l),p.traverse(f=>{var v;f.layers.set(2),(v=Z.active)!=null&&v.isPassThrough&&!h&&this.makeOccluder(f),f instanceof Q&&et.assignMeshLOD(f,0)}),i.connected||(Hn&&q.DrawLabel(i.rayWorldPosition,"Hand is loaded but not connected anymore",.05,5),p.removeFromParent())});if(Hn&&d.add(new bi(.5)),i.inputSource.hand){Hn&&console.log(i.inputSource.hand);for(const p of i.inputSource.hand.values())if(o.joints[p.jointName]===void 0){const g=new oo;g.matrixAutoUpdate=!1,g.visible=!0,o.joints[p.jointName]=g,o.add(g)}}else Hn&&q.DrawLabel(i.rayWorldPosition,"No inputSource.hand found for index "+i.index,.05,5);return{handObject:d,handmesh:u}}makeOccluder(t){if(t instanceof Q){let i=t.material;i instanceof Oe&&(i=t.material=i.clone(),i.depthWrite=!0,i.depthTest=!0,i.colorWrite=!1,t.receiveShadow=!1,t.renderOrder=-100)}}}a(ln,"factory",new FC),wp([m()],ln.prototype,"createControllerModel",2),wp([m()],ln.prototype,"createHandModel",2),wp([m(le)],ln.prototype,"customLeftHand",2),wp([m(le)],ln.prototype,"customRightHand",2);class xp extends A{}var YT=Object.defineProperty,KT=Object.getOwnPropertyDescriptor,Wo=(s,t,i,n)=>{for(var o=n>1?void 0:n?KT(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&YT(t,i,o),o};const I0=O("debugwebxr");class Li extends A{constructor(){super(...arguments),a(this,"movementSpeed",1.5),a(this,"rotationStep",30),a(this,"useTeleport",!0),a(this,"usePinchToTeleport",!0),a(this,"useTeleportTarget",!1),a(this,"useTeleportFade",!1),a(this,"showRays",!0),a(this,"showHits",!0),a(this,"isXRMovementHandler",!0),a(this,"xrSessionMode","immersive-vr"),a(this,"_didApplyRotation",!1),a(this,"_didTeleport",!1),a(this,"_teleportBuffer",new Array),a(this,"_plane",null),a(this,"_lines",[]),a(this,"_hitDiscs",[]),a(this,"_hitDistances",[]),a(this,"_lastHitDistances",[]),a(this,"hitPointRaycastFilter",t=>t.type==="SkinnedMesh"?"continue in children":!0)}onUpdateXR(t){const i=t.xr.rig;if(!(i!=null&&i.gameObject)||t.xr.isPassThrough)return;const n=t.xr.leftController,o=t.xr.rightController;n&&this.onHandleMovement(n,i.gameObject),o&&(this.onHandleRotation(o,i.gameObject),this.useTeleport&&this.onHandleTeleport(o,i.gameObject))}onLeaveXR(t){for(const i of this._lines)i.removeFromParent();for(const i of this._hitDiscs)i?.removeFromParent()}onBeforeRender(){var t;(t=this.context.xr)!=null&&t.running&&(this.showRays&&this.renderRays(this.context.xr),this.showHits&&this.renderHits(this.context.xr))}onHandleMovement(t,i){const n=t.getStick("xr-standard-thumbstick");if(n.x!=0||n.y!=0){const o=$(n.x,0,n.y);o.multiplyScalar(this.context.time.deltaTimeUnscaled*this.movementSpeed);const r=Ke(i);o.multiplyScalar(r.x),o.applyQuaternion(t.xr.poseOrientation),o.y=0,o.applyQuaternion(i.worldQuaternion),i.position.add(o),i.updateWorldMatrix(!1,!1);for(const l of i.children)l.updateWorldMatrix(!1,!1)}}onHandleRotation(t,i){if(t._isMxInk)return;const n=t.getStick("xr-standard-thumbstick").x;if(this._didApplyRotation)Math.abs(n)<.3&&(this._didApplyRotation=!1);else if(Math.abs(n)>.5){this._didApplyRotation=!0;const o=n>0?1:-1,r=ee(this.context.mainCamera).clone();i.rotateY(o*W.toRadians(this.rotationStep));const l=ee(this.context.mainCamera).clone().sub(r);l.y=0,i.position.sub(l)}}onHandleTeleport(t,i){var n,o,r,l,c;let h=0;if(t.hand&&this.usePinchToTeleport&&t.isTeleportGesture){const d=t.getPointerId("primary");if(d!=null&&this.context.input.getIsPointerIdInUse(d))return;const u=t.getGesture("pinch");u&&(h=u.value)}else h=(n=t.getStick("xr-standard-thumbstick"))==null?void 0:n.y;if(this._didTeleport)h>=0&&h<.4?this._didTeleport=!1:h<0&&h>-.4&&(this._didTeleport=!1);else if(h>.8){this._didTeleport=!0;const d=this.context.physics.raycastFromRay(t.ray)[0];if(d&&d.object instanceof xa){const p=(o=d.normal)==null?void 0:o.dot($(0,1,0));if(p!==void 0&&p<.4)return}let u=d?.point;if(!u&&!this.useTeleportTarget){this._plane||(this._plane=new dr(new x(0,1,0),0));const p=i.worldPosition;this._plane.setFromNormalAndCoplanarPoint(new x(0,1,0),p);const g=t.ray;u=p.clone(),this._plane.intersectLine(new aC(g.origin,$(g.direction).multiplyScalar(1e4).add(g.origin)),u),u.distanceTo(p)>i.scale.x*10&&(u=null)}if(u){if(this.useTeleportTarget&&!P.getComponentInParent(d.object,xp))return;const p=u.clone();if(I0&&q.DrawSphere(u,.025,16711680,5),(r=this.context.mainCamera)==null?void 0:r.position){const g=(l=this.context.xr)==null?void 0:l.getUserOffsetInRig();g&&(g.y=0,p.sub(g),I0&&q.DrawWireSphere(g.add(p),.025,65280,5))}this._teleportBuffer.push(i.matrix.clone()),this._teleportBuffer.length>10&&this._teleportBuffer.shift(),this.useTeleportFade?(c=t.xr.fadeTransition())==null||c.then(()=>{i.worldPosition=p}):i.worldPosition=p}}else if(h<-.8&&(this._didTeleport=!0,this._teleportBuffer.length>0)){const d=this._teleportBuffer.pop();d&&d.decompose(i.position,i.quaternion,i.scale)}}renderRays(t){var i;for(let n=0;n<this._lines.length;n++){const o=this._lines[n];o&&(o.visible=!1)}for(let n=0;n<t.controllers.length;n++){const o=t.controllers[n];let r=this._lines[n];if(!o.connected||!o.isTracking||!o.ray||o.targetRayMode==="transient-pointer"||!o.hasSelectEvent){r&&(r.visible=!1);continue}r||(r=this.createRayLineObject(),r.scale.z=.5,this._lines[n]=r),o.updateRayWorldPosition(),o.updateRayWorldQuaternion();const l=o.rayWorldPosition,c=o.rayWorldQuaternion;r.position.copy(l),r.quaternion.copy(c);const h=t.rigScale,d=this.usePinchToTeleport&&o.isTeleportGesture,u=this._lastHitDistances[n],p=this._hitDistances[n]!=null,g=u??h;r.scale.set(h,h,g),r.visible=!0,r.layers.disableAll(),r.layers.enable(2);let y=r.material.opacity;d?y=1:this.showHits&&g<t.rigScale*.5?y=0:(i=o.getButton("primary"))!=null&&i.pressed?y=.5:y=p?.2:.1,r.material.opacity=W.lerp(r.material.opacity,y,this.context.time.deltaTimeUnscaled/.1),r.parent!==this.context.scene&&this.context.scene.add(r)}}renderHits(t){var i;for(const n of this._hitDiscs){if(!n)continue;const o=n.controller;if(!o||!o.connected||!o.isTracking){n.visible=!1;continue}}for(let n=0;n<t.controllers.length;n++){const o=t.controllers[n];if(!o.connected||!o.isTracking||!o.ray||!o.hasSelectEvent)continue;let r=this._hitDiscs[n],l=!0;const c=o.getPointerId("primary");c!=null&&this.context.input.getIsPointerIdInUse(c)&&(r&&(r.visible=!1),this._hitDistances[n]=null,this._lastHitDistances[n]=0,l=!1);const h=this.context.time.smoothedFps>=59?1:10;if((this.context.time.frame+o.index)%h!==0&&(l=!1),!l){const p=this._hitDiscs[n];p&&p.visible&&p.hit&&this.updateHitPointerPosition(o,p,p.hit.distance);continue}const d=this.context.physics.raycastFromRay(o.ray,{testObject:this.hitPointRaycastFilter,precise:!1});let u=d.find(p=>this.usePinchToTeleport&&o.isTeleportGesture?!0:this.isObjectWithInteractiveComponent(p.object));if(u||(u=d[0]),r&&(r.controller=o,r.hit=u),this._hitDistances[n]=u?.distance||null,u){this._lastHitDistances[n]=u.distance;const p=t.rigScale??1;I0&&(q.DrawWireSphere(u.point,.025*p,16711680),q.DrawLabel($(0,.2,0).add(u.point),u.object.name,.02,0)),r||(r=this.createHitPointObject(),this._hitDiscs[n]=r),r.hit=u,r.visible=u.distance>p*.05;let g=.01*(p+u.distance);const y=(i=o.getButton("primary"))==null?void 0:i.pressed;y&&(g*=1.1),r.scale.set(g,g,g),r.layers.set(2);let f=r.material.opacity;if(y?f=1:f=u.distance<.15*p?.2:.6,r.material.opacity=W.lerp(r.material.opacity,f,this.context.time.deltaTimeUnscaled/.1),r.visible){if(u.normal){this.updateHitPointerPosition(o,r,u.distance);const v=u.normal.applyQuaternion(Se(u.object));r.quaternion.setFromUnitVectors(ZT,v)}else this.updateHitPointerPosition(o,r,u.distance);r.parent!==this.context.scene&&this.context.scene.add(r)}}else this._hitDiscs[n]&&(this._hitDiscs[n].visible=!1)}}isObjectWithInteractiveComponent(t,i=0){return Pu(t)||t.isUI===!0?!0:t.isScene?!1:t.parent?this.isObjectWithInteractiveComponent(t.parent,i+1):!1}updateHitPointerPosition(t,i,n){const o=$(t.rayWorldPosition);o.add($(0,0,n-.01).applyQuaternion(t.rayWorldQuaternion)),i.position.lerp(o,this.context.time.deltaTimeUnscaled/.05)}createHitPointObject(){const t=new Q(new rd(.3,6,6),new Me({color:15658734,opacity:.7,transparent:!0,depthTest:!1,depthWrite:!1,side:_i}));return t.layers.disableAll(),t.layers.enable(2),t}createRayLineObject(){const t=new UC;t.layers.disableAll(),t.layers.enable(2);const i=new NC;t.geometry=i;const n=new Float32Array(9);n.set([0,0,.02,0,0,.4,0,0,1]),i.setPositions(n);const o=new Float32Array(9);o.set([1,1,1,.1,.1,.1,0,0,0]),i.setColors(o);const r=new WC({color:16777215,vertexColors:!0,worldUnits:!0,linewidth:.004,transparent:!0,depthWrite:!1,blending:nv,dashed:!1});return t.material=r,t}}Wo([m()],Li.prototype,"movementSpeed",2),Wo([m()],Li.prototype,"rotationStep",2),Wo([m()],Li.prototype,"useTeleport",2),Wo([m()],Li.prototype,"usePinchToTeleport",2),Wo([m()],Li.prototype,"useTeleportTarget",2),Wo([m()],Li.prototype,"useTeleportFade",2),Wo([m()],Li.prototype,"showRays",2),Wo([m()],Li.prototype,"showHits",2);const ZT=new x(0,1,0);var JT=Object.defineProperty,eE=Object.getOwnPropertyDescriptor,St=(s,t,i,n)=>{for(var o=n>1?void 0:n?eE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&JT(t,i,o),o};const vh=O("debugwebxr"),tE=O("debugusdz");var j0;const wl=(j0=class extends A{constructor(){super(...arguments),a(this,"createVRButton",!0),a(this,"createARButton",!0),a(this,"createSendToQuestButton",!0),a(this,"createQRCode",!0),a(this,"useDefaultControls",!0),a(this,"showControllerModels",!0),a(this,"showHandModels",!0),a(this,"usePlacementReticle",!0),a(this,"customARPlacementReticle"),a(this,"usePlacementAdjustment",!0),a(this,"arScale",1),a(this,"useXRAnchor",!1),a(this,"autoPlace",!0),a(this,"autoCenter",!1),a(this,"useQuicklookExport",!1),a(this,"useDepthSensing",!1),a(this,"useSpatialGrab",!0),a(this,"defaultAvatar"),a(this,"_playerSync"),a(this,"_createdComponentsInSession",[]),a(this,"_usdzExporter"),a(this,"_exitXRMenuButton"),a(this,"_previousXRState",0),a(this,"_spatialGrabRaycaster"),a(this,"onAvatarSpawned",s=>{vh&&console.log("WebXR.onAvatarSpawned",s),P.getComponentInChildren(s,Uo)??(e=P.addComponent(s,Uo))}),a(this,"_buttonFactory"),a(this,"_buttons",[])}awake(){Z.getXRSync(this.context)}onEnable(){var s,t;window.location.protocol!=="https:"&&_e('<a href="https://developer.mozilla.org/en-US/docs/Web/API/WebXR_Device_API" target="_blank">WebXR</a> only works on secure connections (https).'),this.useQuicklookExport&&(P.findObjectOfType(Ge)||(vh&&console.log("WebXR: Adding USDZExporter"),this._usdzExporter=P.addComponent(this.gameObject,Ge),this._usdzExporter.objectToExport=this.context.scene,this._usdzExporter.autoExportAnimations=!0,this._usdzExporter.autoExportAudioSources=!0)),this.handleCreatingHTML(),this.handleOfferSession(),this.defaultAvatar===!0&&(vh&&console.warn("WebXR: No default avatar set, using static default avatar"),this.defaultAvatar=new le("https://cdn.needle.tools/static/avatars/DefaultAvatar.glb")),this.defaultAvatar&&(this._playerSync=this.gameObject.getOrAddComponent(bl),this._playerSync.autoSync=!1),this._playerSync&&typeof this.defaultAvatar!="boolean"&&(this._playerSync.asset=this.defaultAvatar,(s=this._playerSync.onPlayerSpawned)==null||s.removeEventListener(this.onAvatarSpawned),(t=this._playerSync.onPlayerSpawned)==null||t.addEventListener(this.onAvatarSpawned))}onDisable(){var s;(s=this._usdzExporter)==null||s.destroy(),this.removeButtons()}async handleOfferSession(){return this.createVRButton&&await Z.isVRSupported()&&this.createVRButton?Z.offerSession("immersive-vr","default",this.context):this.createARButton&&await Z.isARSupported()&&this.createARButton?Z.offerSession("immersive-ar","default",this.context):!1}get session(){return Z.active??null}get sessionMode(){return Z.activeMode??null}async enterVR(s){return Z.start("immersive-vr",s,this.context)}async enterAR(s){return Z.start("immersive-ar",s,this.context)}exitXR(){Z.stop()}get isActiveWebXR(){return!wl.activeWebXRComponent||wl.activeWebXRComponent===this}onBeforeXR(s,t){var i;if(!this.isActiveWebXR){console.warn(`WebXR: another WebXR component is already active (${(i=wl.activeWebXRComponent)==null?void 0:i.name}). This is ignored: ${this.name}`);return}wl.activeWebXRComponent=this,s=="immersive-ar"&&this.useDepthSensing&&(t.optionalFeatures=t.optionalFeatures||[],t.optionalFeatures.push("depth-sensing"))}async onEnterXR(s){if(!this.isActiveWebXR)return;vh&&console.log("WebXR onEnterXR"),this._previousXRState=Kt.Global.Mask;const t=s.xr.isVR;if(Kt.Global.Set(t?Ks.VR:Ks.AR),s.xr.isAR){let i=P.findObjectOfType(Vn);if(!i)if(this.usePlacementReticle){const n=new j;for(const o of this.context.scene.children)n.add(o);this.context.scene.add(n),i=P.addComponent(n,Vn),this._createdComponentsInSession.push(i)}else(vh||F())&&console.warn("WebXR: No WebARSessionRoot found in scene and usePlacementReticle is disabled in WebXR component.");i&&(i.customReticle=this.customARPlacementReticle,i.arScale=this.arScale,i.arTouchTransform=this.usePlacementAdjustment,i.autoPlace=this.autoPlace,i.autoCenter=this.autoCenter,i.useXRAnchor=this.useXRAnchor)}this.useDefaultControls&&this.setDefaultMovementEnabled(!0),(this.showControllerModels||this.showHandModels)&&this.setDefaultControllerRenderingEnabled(!0),this.useSpatialGrab&&(this._spatialGrabRaycaster=P.findObjectOfType(Ga)??void 0,this._spatialGrabRaycaster||(this._spatialGrabRaycaster=this.gameObject.addComponent(Ga))),this.createLocalAvatar(s.xr),s.xr.isScreenBasedAR||(this._exitXRMenuButton=this.context.menu.appendChild({label:"Quit XR",onClick:()=>this.exitXR(),icon:"exit_to_app",priority:2e4}))}onUpdateXR(s){this.isActiveWebXR&&this._spatialGrabRaycaster&&(this._spatialGrabRaycaster.enabled=this.useSpatialGrab)}onLeaveXR(s){var t,i;if((t=this._exitXRMenuButton)==null||t.remove(),!!this.isActiveWebXR){Kt.Global.Set(this._previousXRState),(i=this._playerSync)==null||i.destroyInstance();for(const n of this._createdComponentsInSession)n.destroy();this._createdComponentsInSession.length=0,this.handleOfferSession(),Ql(1).then(()=>wl.activeWebXRComponent=null)}}setDefaultMovementEnabled(s){let t=this.gameObject.getComponent(Li);return!t&&s&&(t=this.gameObject.addComponent(Li),this._createdComponentsInSession.push(t)),t&&(t.enabled=s),t}setDefaultControllerRenderingEnabled(s){let t=this.gameObject.getComponent(ln);return!t&&s&&(t=this.gameObject.addComponent(ln),this._createdComponentsInSession.push(t),t.createControllerModel=this.showControllerModels,t.createHandModel==this.showHandModels),t&&(t.enabled=s),t}async createLocalAvatar(s){this._playerSync&&s.running&&typeof this.defaultAvatar!="boolean"&&(this._playerSync.asset=this.defaultAvatar,await this._playerSync.getInstance())}getButtonsContainer(){return this.getButtonsFactory()}getButtonsFactory(){return this._buttonFactory||(this._buttonFactory=Yr.getOrCreate()),this._buttonFactory}handleCreatingHTML(){if(this.createARButton||this.createVRButton||this.useQuicklookExport){if((Y.isiOS()&&Y.isSafari()||tE)&&this.useQuicklookExport){const s=P.findObjectOfType(Ge);if(!s||s&&s.allowCreateQuicklookButton){const t=this.getButtonsFactory().createQuicklookButton();this.addButton(t,50)}}if(this.createARButton){const s=this.getButtonsFactory().createARButton();this.addButton(s,50)}if(this.createVRButton){const s=this.getButtonsFactory().createVRButton();this.addButton(s,50)}}if(this.createSendToQuestButton&&!Y.isQuest()&&Z.isVRSupported().then(s=>{if(!s){const t=this.getButtonsFactory().createSendToQuestButton();this.addButton(t,50)}}),this.createQRCode){const s=Gd(an);if(s&&s.createQRCodeButton===!1)F()&&console.warn("WebXR: QRCode button is disabled in the Needle Menu component");else if(!Y.isMobileDevice()){const t=Mn.getOrCreate().createQRCode();this.addButton(t,50)}}}addButton(s,t){this._buttons.push(s),s.setAttribute("priority",t.toString()),this.context.menu.appendChild(s)}removeButtons(){for(const s of this._buttons)s.remove();this._buttons.length=0}},a(j0,"activeWebXRComponent",null),j0);let Je=wl;St([m()],Je.prototype,"createVRButton",2),St([m()],Je.prototype,"createARButton",2),St([m()],Je.prototype,"createSendToQuestButton",2),St([m()],Je.prototype,"createQRCode",2),St([m()],Je.prototype,"useDefaultControls",2),St([m()],Je.prototype,"showControllerModels",2),St([m()],Je.prototype,"showHandModels",2),St([m()],Je.prototype,"usePlacementReticle",2),St([m(le)],Je.prototype,"customARPlacementReticle",2),St([m()],Je.prototype,"usePlacementAdjustment",2),St([m()],Je.prototype,"arScale",2),St([m()],Je.prototype,"useXRAnchor",2),St([m()],Je.prototype,"autoPlace",2),St([m()],Je.prototype,"autoCenter",2),St([m()],Je.prototype,"useQuicklookExport",2),St([m()],Je.prototype,"useDepthSensing",2),St([m()],Je.prototype,"useSpatialGrab",2),St([m(le)],Je.prototype,"defaultAvatar",2);const bh=O("debugusdz");function iE(s,t){var i;const n=[],o=P.getComponentsInChildren(s,kt),r=P.getComponentsInChildren(s,Ut),l=new Array,c=new Array;if(t.injectImplicitBehaviours)for(const h of o){if(!h||!h.runtimeAnimatorController||!h.enabled)continue;const d=h.runtimeAnimatorController.activeState;if(!d||!d.motion||!d.motion.clip||((i=d.motion.clip.tracks)==null?void 0:i.length)<1||l.includes(h))continue;const u=new Gr;u.animator=h,u.stateName=d.name,u.trigger="start",u.name="PlayAnimationOnClick_implicitAtStart_"+u.stateName;const p=new j;P.addComponent(p,u),c.push(p),l.push(h),s.add(p)}else for(const h of o){if(!h||!h.runtimeAnimatorController||!h.enabled)continue;bh&&console.log(h);const d=[];for(const u of h.runtimeAnimatorController.enumerateActions()){bh&&console.log(u);const p=u.getClip();d.includes(p)||d.push(p)}n.push({root:h.gameObject,clips:d})}if(t.injectImplicitBehaviours)for(const h of r){if(!h||!h.clip||!h.enabled||!h.playAutomatically||l.includes(h))continue;const d=new Gr;d.animation=h,d.stateName=h.clip.name,d.trigger="start",d.name="PlayAnimationOnClick_implicitAtStart_"+d.stateName;const u=new j;P.addComponent(u,d),c.push(u),l.push(h),s.add(u)}else for(const h of r){bh&&console.log(h);const d=[];for(const u of h.animations)d.includes(u)||d.push(u);n.push({root:h.gameObject,clips:d})}bh&&n?.length>0&&console.log("USDZ Animation Clips without behaviours",n);for(const h of n)for(const d of h.clips)t.registerAnimation(h.root,d);return c}function sE(s,t){const i=P.getComponentsInChildren(s,We),n=P.getComponentsInChildren(s,Io),o=new Array,r=new Array;bh&&console.log({audioSources:i,playAudioOnClicks:n});for(const l of n){if(!l.target)continue;const c=i.indexOf(l.target);c>-1&&i.splice(c,1)}for(const l of i){if(!l||!l.clip||l.volume<=0||o.includes(l))continue;const c=new Io;c.target=l,c.name="PlayAudioOnClick_implicitAtStart_",c.trigger="start";const h=new j;P.addComponent(h,c),console.log("implicit PlayAudioOnStart",h,c),r.push(h),o.push(l),s.add(h)}return r}function nE(s){return new _t("DisableAtStart",wt.sceneStartTrigger(),ue.fadeAction(s,0,!1))}function e1(s,t){const i=s.domElement.shadowRoot.querySelector("link[rel='ar']");if(i)return i;const n=document.createElement("div");n.classList.add("menu"),n.classList.add("quicklook-menu"),n.style.display="none",n.style.visibility="hidden";const o=document.createElement("button");o.id="open-in-ar",t?(o.innerText="View in AR",o.title="View this scene in AR. The scene will be exported to USDZ and opened with Apple's QuickLook."):(o.innerText="View in AR",o.title="Download this scene for AR. Open the downloaded USDZ file to view it in AR using Apple's QuickLook."),n.appendChild(o);const r=document.createElement("a");r.id="needle-usdz-link",r.style.display="none",r.rel="ar",r.href="",r.target="_blank",n.appendChild(r);const l=document.createElement("img");return l.id="button",r.appendChild(l),s.domElement.shadowRoot.appendChild(n),r}var oE=Object.defineProperty,rE=Object.getOwnPropertyDescriptor,At=(s,t,i,n)=>{for(var o=n>1?void 0:n?rE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&oE(t,i,o),o};const Di=O("debugusdz"),aE=O("debugusdzpruning");class Vo{constructor(){a(this,"callToAction"),a(this,"checkoutTitle"),a(this,"checkoutSubtitle"),a(this,"callToActionURL")}}At([m()],Vo.prototype,"callToAction",2),At([m()],Vo.prototype,"checkoutTitle",2),At([m()],Vo.prototype,"checkoutSubtitle",2),At([m()],Vo.prototype,"callToActionURL",2);var Sp;const L0=(Sp=class extends A{constructor(){super(...arguments),a(this,"objectToExport"),a(this,"autoExportAnimations",!0),a(this,"autoExportAudioSources",!0),a(this,"exportFileName"),a(this,"customUsdzFile"),a(this,"customBranding"),a(this,"anchoringType","plane"),a(this,"maxTextureSize",2048),a(this,"planeAnchoringAlignment","horizontal"),a(this,"interactive",!0),a(this,"physics",!0),a(this,"allowCreateQuicklookButton",!0),a(this,"quickLookCompatible",!0),a(this,"extensions",[]),a(this,"link"),a(this,"button"),a(this,"onClickedOpenInARElement",s=>{s.preventDefault(),this.exportAndOpen()}),a(this,"_currentExportTasks",new Map),a(this,"_previousTimeScale",1),a(this,"lastCallback"),a(this,"_rootSessionRootWasAppliedTo",null),a(this,"_rootPositionBeforeExport",new x),a(this,"_rootRotationBeforeExport",new V),a(this,"_rootScaleBeforeExport",new x)}start(){var s,t,i;Di&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",n=>{switch(n.key){case"t":this.exportAndOpen();break}})),this.objectToExport||(this.objectToExport=this.gameObject),!((t=(s=this.objectToExport)==null?void 0:s.children)!=null&&t.length)&&!((i=this.objectToExport)!=null&&i.isMesh)&&(this.objectToExport=this.context.scene)}onEnable(){var s;const t=Y.supportsQuickLookAR(),i=Y.isiOS()||Y.isiPad();!this.button&&(Di||t||i)&&(this.allowCreateQuicklookButton&&(this.button=this.createQuicklookButton()),this.lastCallback=this.quicklookCallback.bind(this),this.link=e1(this.context,t),this.link.addEventListener("message",this.lastCallback)),Di&&Le("USDZ Exporter enabled: "+this.name),(s=document.getElementById("open-in-ar"))==null||s.addEventListener("click",this.onClickedOpenInARElement),dc.registerExporter(this)}onDisable(){var s,t,i;(s=this.button)==null||s.remove(),(t=this.link)==null||t.removeEventListener("message",this.lastCallback),Di&&Le("USDZ Exporter disabled: "+this.name),(i=document.getElementById("open-in-ar"))==null||i.removeEventListener("click",this.onClickedOpenInARElement),dc.unregisterExporter(this)}async exportAsync(){return this.exportAndOpen()}async exportAndOpen(){var s;let t=this.exportFileName??((s=this.objectToExport)==null?void 0:s.name)??this.name;if(t+="-"+fx(),vo()||(t!==""&&(t+="-"),t+="MadeWithNeedle"),this.link||(this.link=e1(this.context,Y.supportsQuickLookAR())),this.customUsdzFile)return Di&&console.log("Exporting custom usdz",this.customUsdzFile),this.openInQuickLook(this.customUsdzFile,t),null;if(!this.objectToExport)return console.warn("No object to export",this),null;const i=await this.export(this.objectToExport);return i?(Di&&console.log("USDZ generation done. Downloading as "+t),this.openInQuickLook(i,t),i):(console.error("USDZ generation failed. Please report a bug",this),null)}async export(s){if(!s)return console.warn("No object to export"),null;const t=this._currentExportTasks.get(s);if(t)return t;const i=this.internalExport(s);return i instanceof Promise?(this._currentExportTasks.set(s,i),i.then(n=>(this._currentExportTasks.delete(s),n)).catch(n=>(this._currentExportTasks.delete(s),console.error("Error during USDZ export \u2013 please report a bug!",n),null))):i}async internalExport(s){ce.start("export-usdz",{onProgress:C=>{this.dispatchEvent(new CustomEvent("export-progress",{detail:{progress:C}}))}}),ce.report("export-usdz",{message:"Starting export",totalSteps:40,currentStep:0}),ce.report("export-usdz",{message:"Load progressive textures",autoStep:5}),ce.start("export-usdz-textures","export-usdz");const t=P.getComponentsInChildren(s,pi);for(const C of t)C&&C.enabled&&C.updateSprite(!0);const i=P.getComponentsInChildren(s,Ze),n=new Array;let o=0;for(const C of i){for(const R of C.sharedMeshes)if(R){const M=et.assignMeshLOD(R,0);M instanceof Promise&&n.push(new Promise((E,B)=>{M.then(()=>{o++,ce.report("export-usdz-textures",{message:"Loaded progressive mesh",currentStep:o,totalSteps:n.length}),E()}).catch(L=>B(L))}))}for(const R of C.sharedMaterials)if(R){const M=et.assignTextureLOD(R,0);M instanceof Promise&&n.push(new Promise((E,B)=>{M.then(()=>{o++,ce.report("export-usdz-textures",{message:"Loaded progressive texture",currentStep:o,totalSteps:n.length}),E()}).catch(L=>B(L))}))}}Di&&Le("Progressive Loading: "+n.length),await Promise.all(n),Di&&Le("Progressive Loading: done"),ce.end("export-usdz-textures");const r=Kt.Global.Mask;Kt.Global.Set(Ks.AR);const l=new wx,c=new oh(this.quickLookCompatible);let h;const d=[];this.interactive&&(d.push(new hp),d.push(new lr),globalThis.true&&P.getComponentsInChildren(s,ye).length>0&&(this.physics?(h=new pp,d.push(h)):F()&&console.warn("USDZExporter: Physics export is disabled, but there are active Rigidbody components in the scene. They will not be exported.")),d.push(new ph),d.push(new yp));const u=[c,...d,...this.extensions],p={self:this,exporter:l,extensions:u,object:s};ce.report("export-usdz","Invoking before-export"),this.dispatchEvent(new CustomEvent("before-export",{detail:p})),this.applyWebARSessionRoot(),this._previousTimeScale=this.context.time.timeScale,this.context.time.timeScale=0,ce.report("export-usdz","auto export animations and audio sources");const g=new Array;this.autoExportAnimations&&g.push(...iE(s,c)),this.extensions.find(C=>C.extensionName==="Audio")&&this.autoExportAudioSources&&g.push(...sE(s)),l.debug=Di,l.pruneUnusedNodes=!aE;const y=Vr.instance.objs.map(C=>C.batchedMesh);l.keepObject=C=>{let R=!0;const M=P.getComponent(C,Ze);return M&&!M.enabled&&(R=!1),R&&y.includes(C)&&(R=!1),R&&P.getComponentInParent(C,Os)&&(R=!1),R&&P.getComponentInParent(C,Vs)&&(R=!1),Di&&!R&&console.log("USDZExporter: Discarding object",C),R},l.beforeWritingDocument=()=>{if(F()&&c&&h){const C=c.animatedRoots;for(const R of C){const M=P.getComponentsInChildren(R,ye).filter(B=>B.enabled),E=P.getComponents(R,hi).filter(B=>B.enabled&&!B.isTrigger);(M.length>0||E.length>0)&&console.error("An animated object has physics components in its child hierarchy. This can lead to undefined behaviour due to a bug in Apple's QuickLook (FB15925487). Remove the physics components from child objects or verify that you get the expected results.",R)}}};const f=new Array;this.objectToExport&&this.quickLookCompatible&&this.interactive&&this.objectToExport.traverse(C=>{C.visible||f.push(C)});const v=this.extensions.find(C=>C.extensionName==="Behaviour");this.interactive&&v&&f.length>0&&v.addBehavior(nE(f));let b=!0;this.quickLookCompatible&&!this.interactive&&(b=!1),this.anchoringType!=="plane"&&this.anchoringType!=="none"&&this.anchoringType!=="image"&&this.anchoringType!=="face"&&(this.anchoringType="plane"),this.planeAnchoringAlignment!=="horizontal"&&this.planeAnchoringAlignment!=="vertical"&&this.planeAnchoringAlignment!=="any"&&(this.planeAnchoringAlignment="horizontal"),ce.report("export-usdz","Invoking exporter.parse");const w=await l.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:u,quickLookCompatible:this.quickLookCompatible,maxTextureSize:this.maxTextureSize,exportInvisible:b}),_=new Blob([w],{type:"model/vnd.usdz+zip"});this.revertWebARSessionRoot(),this.context.time.timeScale=this._previousTimeScale,ce.report("export-usdz","Invoking after-export"),this.dispatchEvent(new CustomEvent("after-export",{detail:p}));for(const C of g)P.destroy(C);return Kt.Global.Set(r),ce.end("export-usdz"),_}openInQuickLook(s,t){const i=s instanceof Blob?URL.createObjectURL(s):s,n=this.buildQuicklookOverlay();Di&&console.log("QuickLook Overlay",n);const o=n.callToAction?encodeURIComponent(n.callToAction):"",r=n.checkoutTitle?encodeURIComponent(n.checkoutTitle):"",l=n.checkoutSubtitle?encodeURIComponent(n.checkoutSubtitle):"";this.link.href=i+`#callToAction=${o}&checkoutTitle=${r}&checkoutSubtitle=${l}&callToActionURL=${n.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click()}download(s,t){L0.save(s,t)}static save(s,t){const i=document.createElement("a");i.style.display="none",document.body.appendChild(i),typeof s=="string"?i.href=s:i.href=URL.createObjectURL(s),i.download=t,i.click(),i.remove()}quicklookCallback(s){if(s?.data=="_apple_ar_quicklook_button_tapped"){Di&&_e("Quicklook closed via call to action button");var t=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(t),!t.defaultPrevented){const i=new URLSearchParams(this.link.href);if(i){const n=i.get("callToActionURL");Di&&Le("Quicklook url: "+n),n&&(vo()?globalThis.open(n,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",n))}}}}buildQuicklookOverlay(){var s,t,i,n,o,r;const l={};return this.customBranding&&Object.assign(l,this.customBranding),vo()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),l.callToAction="Close",l.checkoutTitle="\u{1F335} Made with Needle",l.checkoutSubtitle="_"),(((s=l.callToAction)==null?void 0:s.length)||((t=l.checkoutTitle)==null?void 0:t.length)||((i=l.checkoutSubtitle)==null?void 0:i.length))&&((n=l.callToAction)!=null&&n.length||(l.callToAction="\0"),(o=l.checkoutTitle)!=null&&o.length||(l.checkoutTitle="\0"),(r=l.checkoutSubtitle)!=null&&r.length||(l.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:l})),l}getARScaleAndTarget(){if(!this.objectToExport)return{scale:1,_invertForward:!1,target:this.gameObject,sessionRoot:null};const s=P.findObjectOfType(Je);let t=P.getComponentInParent(this.objectToExport,Vn);t||(t=P.getComponentInChildren(this.objectToExport,Vn));let i=1,n=!1;const o=this.objectToExport;return s?i=s.arScale:t&&(i=t.arScale,n=t.invertForward),{scale:1/i,_invertForward:n,target:o,sessionRoot:t?.gameObject??null}}applyWebARSessionRoot(){if(!this.objectToExport)return;const{scale:s,_invertForward:t,target:i,sessionRoot:n}=this.getARScaleAndTarget(),o=n?.matrixWorld.clone().invert();this._rootSessionRootWasAppliedTo=i,this._rootPositionBeforeExport.copy(i.position),this._rootRotationBeforeExport.copy(i.quaternion),this._rootScaleBeforeExport.copy(i.scale),i.scale.multiplyScalar(s),t&&i.quaternion.multiply(L0.invertForwardQuaternion),i.updateMatrix(),i.updateMatrixWorld(!0),n&&o&&i.matrix.premultiply(o)}revertWebARSessionRoot(){if(!this.objectToExport||!this._rootSessionRootWasAppliedTo)return;const s=this._rootSessionRootWasAppliedTo;s.position.copy(this._rootPositionBeforeExport),s.quaternion.copy(this._rootRotationBeforeExport),s.scale.copy(this._rootScaleBeforeExport),s.updateMatrix(),s.updateMatrixWorld(!0),this._rootSessionRootWasAppliedTo=null}createQuicklookButton(){const s=Yr.getOrCreate().createQuicklookButton();return s.parentNode||this.context.menu.appendChild(s),s}},a(Sp,"invertForwardMatrix",new ne().makeRotationY(Math.PI)),a(Sp,"invertForwardQuaternion",new V().setFromEuler(new Ft(0,Math.PI,0))),Sp);let Ge=L0;At([m(j)],Ge.prototype,"objectToExport",2),At([m()],Ge.prototype,"autoExportAnimations",2),At([m()],Ge.prototype,"autoExportAudioSources",2),At([m()],Ge.prototype,"exportFileName",2),At([m(URL)],Ge.prototype,"customUsdzFile",2),At([m(Vo)],Ge.prototype,"customBranding",2),At([m()],Ge.prototype,"anchoringType",2),At([m()],Ge.prototype,"maxTextureSize",2),At([m()],Ge.prototype,"planeAnchoringAlignment",2),At([m()],Ge.prototype,"interactive",2),At([m()],Ge.prototype,"physics",2),At([m()],Ge.prototype,"allowCreateQuicklookButton",2),At([m()],Ge.prototype,"quickLookCompatible",2);var lE=Object.defineProperty,cE=Object.getOwnPropertyDescriptor,D0=(s,t,i,n)=>{for(var o=n>1?void 0:n?cE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&lE(t,i,o),o};class xl extends A{constructor(){super(...arguments),a(this,"_fog")}get fog(){return this._fog||(this._fog=new Gy(0,0,50)),this._fog}get mode(){return 1}set near(t){this.fog.near=t}get near(){return this.fog.near}set far(t){this.fog.far=t}get far(){return this.fog.far}set color(t){this.fog.color.copy(t)}get color(){return this.fog.color}onEnable(){this.scene.fog=this.fog}onDisable(){this.scene.fog===this._fog&&(this.scene.fog=null)}}D0([m()],xl.prototype,"near",1),D0([m()],xl.prototype,"far",1),D0([m(ae)],xl.prototype,"color",1);var hE=Object.defineProperty,dE=Object.getOwnPropertyDescriptor,B0=(s,t,i,n)=>{for(var o=n>1?void 0:n?dE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&hE(t,i,o),o};class Kr extends A{constructor(){super(...arguments),a(this,"objectBounds",!1),a(this,"color"),a(this,"isGizmo",!0),a(this,"_gizmoObject",null),a(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!bc||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new lC(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=wg(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),Ce.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){for(var t;this._boxHelper;)(t=this._boxHelper)==null||t.update(),yield}}B0([m()],Kr.prototype,"objectBounds",2),B0([m(ae)],Kr.prototype,"color",2),B0([m()],Kr.prototype,"isGizmo",2);var uE=Object.defineProperty,pE=Object.getOwnPropertyDescriptor,F0=(s,t,i,n)=>{for(var o=n>1?void 0:n?pE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&uE(t,i,o),o};class Sl extends A{constructor(){super(...arguments),a(this,"isGizmo",!1),a(this,"color0"),a(this,"color1"),a(this,"gridHelper"),a(this,"size"),a(this,"divisions"),a(this,"offset")}onEnable(){if(this.isGizmo&&!bc)return;const t=this.size,i=this.divisions;this.gridHelper||(this.gridHelper=new lm(t,i,this.color0??new ae(.4,.4,.4),this.color1??new ae(.6,.6,.6)),this.offset!==void 0&&(this.gridHelper.position.y+=this.offset)),this.gridHelper&&this.gameObject.add(this.gridHelper)}onDisable(){this.gridHelper&&(this.gameObject.remove(this.gridHelper),this.gridHelper=null)}}F0([m()],Sl.prototype,"isGizmo",2),F0([m(ae)],Sl.prototype,"color0",2),F0([m(ae)],Sl.prototype,"color1",2);var mE=Object.defineProperty,gE=Object.getOwnPropertyDescriptor,z0=(s,t,i,n)=>{for(var o=n>1?void 0:n?gE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&mE(t,i,o),o};class U0 extends A{constructor(){super(...arguments),a(this,"connectedBody"),a(this,"_rigidBody",null)}get rigidBody(){return this._rigidBody}onEnable(){this._rigidBody||(this._rigidBody=this.gameObject.getComponent(ye)),this.rigidBody&&this.connectedBody&&this.startCoroutine(this.create())}*create(){yield,this.rigidBody&&this.connectedBody&&this.activeAndEnabled&&this.createJoint(this.rigidBody,this.connectedBody)}}z0([m(ye)],U0.prototype,"connectedBody",2);class N0 extends U0{createJoint(t,i){var n;(n=this.context.physics.engine)==null||n.addFixedJoint(t,i)}}class _h extends U0{constructor(){super(...arguments),a(this,"anchor"),a(this,"axis")}createJoint(t,i){var n;this.axis&&this.anchor&&((n=this.context.physics.engine)==null||n.addHingeJoint(t,i,this.anchor,this.axis))}}z0([m(x)],_h.prototype,"anchor",2),z0([m(x)],_h.prototype,"axis",2);var fE=Object.defineProperty,yE=Object.getOwnPropertyDescriptor,cn=(s,t,i,n)=>{for(var o=n>1?void 0:n?yE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&fE(t,i,o),o};function W0(s){return s*Math.PI/180}const t1=300,Ho=O("debuglights");class mi extends A{constructor(){super(...arguments),a(this,"type",0),a(this,"range",1),a(this,"spotAngle",1),a(this,"innerSpotAngle",1),a(this,"_color",new ae(16777215)),a(this,"_shadowNearPlane",.1),a(this,"_shadowBias",0),a(this,"_shadowNormalBias",0),a(this,"_overrideShadowBiasSettings",!1),a(this,"_shadows",1),a(this,"lightmapBakeType",4),a(this,"_intensity",-1),a(this,"_shadowDistance"),a(this,"shadowWidth"),a(this,"shadowHeight"),a(this,"_shadowResolution"),a(this,"light"),a(this,"_webXRStartedListener"),a(this,"_webXREndedListener"),a(this,"_webARRoot")}set color(t){this._color=t,this.light!==void 0&&(this.light.color=t)}get color(){return this.light?this.light.color:this._color}set shadowNearPlane(t){var i,n;if(t!==this._shadowNearPlane&&(this._shadowNearPlane=t,((n=(i=this.light)==null?void 0:i.shadow)==null?void 0:n.camera)!==void 0)){const o=this.light.shadow.camera;o.near=t}}get shadowNearPlane(){return this._shadowNearPlane}set shadowBias(t){var i,n;t!==this._shadowBias&&(this._shadowBias=t,((n=(i=this.light)==null?void 0:i.shadow)==null?void 0:n.bias)!==void 0&&(this.light.shadow.bias=t,this.light.shadow.needsUpdate=!0))}get shadowBias(){return this._shadowBias}set shadowNormalBias(t){var i,n;t!==this._shadowNormalBias&&(this._shadowNormalBias=t,((n=(i=this.light)==null?void 0:i.shadow)==null?void 0:n.normalBias)!==void 0&&(this.light.shadow.normalBias=t,this.light.shadow.needsUpdate=!0))}get shadowNormalBias(){return this._shadowNormalBias}set shadows(t){this._shadows=t,this.light&&(this.light.castShadow=t!==0,this.updateShadowSoftHard())}get shadows(){return this._shadows}set intensity(t){var i;if(this._intensity=t,this.light){let n=1;if(this.context.isInXR&&this._webARRoot){const o=(i=this._webARRoot)==null?void 0:i.arScale;typeof o=="number"&&o>0&&(n/=o)}this.light.intensity=t*n}Ho&&console.log("Set light intensity to "+this._intensity,t,this)}get intensity(){return this._intensity}get shadowDistance(){const t=this.light;return t!=null&&t.shadow?t.shadow.camera.far:-1}set shadowDistance(t){this._shadowDistance=t;const i=this.light;if(i!=null&&i.shadow){const n=i.shadow.camera;n.far=t,n.updateProjectionMatrix()}}get shadowResolution(){const t=this.light;return t!=null&&t.shadow?t.shadow.mapSize.x:-1}set shadowResolution(t){if(t===this._shadowResolution)return;this._shadowResolution=t;const i=this.light;i!=null&&i.shadow&&(i.shadow.mapSize.set(t,t),i.shadow.needsUpdate=!0)}get isBaked(){return this.lightmapBakeType===2}get selfIsLight(){if(this.gameObject.isLight===!0)return!0;switch(this.gameObject.type){case"SpotLight":case"PointLight":case"DirectionalLight":return!0}return!1}getWorldPosition(t){return this.light?this.type===1?this.light.getWorldPosition(t).multiplyScalar(1):this.light.getWorldPosition(t):t}awake(){this.color=new ae(this.color??16777215),Ho&&console.log(this.name,this)}onEnable(){Ho&&console.log("ENABLE LIGHT",this.name),this.createLight(),!this.isBaked&&(this.light&&(this.light.visible=!0,this.light.intensity=this._intensity,Ho&&console.log("Set light intensity to "+this.light.intensity,this.name),this.selfIsLight||this.light.parent!==this.gameObject&&this.gameObject.add(this.light)),this.type===1&&this.startCoroutine(this.updateMainLightRoutine(),Ce.LateUpdate))}onDisable(){Ho&&console.log("DISABLE LIGHT",this.name),this.light&&(this.selfIsLight?this.light.intensity=0:this.light.visible=!1)}onEnterXR(t){this._webARRoot=P.getComponentInParent(this.gameObject,Vn)??void 0}onLeaveXR(t){}createLight(){const t=this.selfIsLight;if(t&&!this.light)switch(this.light=this.gameObject,this.light.name=this.name,this._intensity=this.light.intensity,this.type){case 1:this.setDirectionalLight(this.light);break}else if(!this.light)switch(this.type){case 1:const i=new cm(this.color,this.intensity*Math.PI);if(i.position.set(0,0,-t1*.5).applyQuaternion(this.gameObject.quaternion),this.gameObject.add(i.target),fr(i.target,0,0,0),this.light=i,this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),Ho){const l=new hC(this.light,.2,this.color);this.context.scene.add(l)}break;case 0:const n=new cC(this.color,this.intensity*Math.PI,this.range,W0(this.spotAngle/2),1-W0(this.innerSpotAngle/2)/W0(this.spotAngle/2),2);n.position.set(0,0,0),n.rotation.set(0,0,0),this.light=n;const o=n.target;n.add(o),o.position.set(0,0,this.range),o.rotation.set(0,0,0);break;case 2:const r=new Xy(this.color,this.intensity*Math.PI,this.range);this.light=r;break}if(this.light){if(this._intensity>=0?this.light.intensity=this._intensity:this._intensity=this.light.intensity,this.shadows!==0?this.light.castShadow=!0:this.light.castShadow=!1,this.light.shadow){this._shadowResolution!==void 0&&this._shadowResolution>4?(this.light.shadow.mapSize.width=this._shadowResolution,this.light.shadow.mapSize.height=this._shadowResolution):(this.light.shadow.mapSize.width=2048,this.light.shadow.mapSize.height=2048),Ho&&console.log("Override shadow bias?",this._overrideShadowBiasSettings,this.shadowBias,this.shadowNormalBias),this.light.shadow.bias=this.shadowBias,this.light.shadow.normalBias=this.shadowNormalBias,this.updateShadowSoftHard();const i=this.light.shadow.camera;if(i.near=this.shadowNearPlane,this._shadowDistance!==void 0&&typeof this._shadowDistance=="number"?i.far=this._shadowDistance:i.far=t1*Math.abs(this.gameObject.scale.z),this.gameObject.scale.set(1,1,1),this.shadowWidth!==void 0)i.left=-this.shadowWidth/2,i.right=this.shadowWidth/2;else{const n=this.gameObject.scale.x;i.left*=n,i.right*=n}if(this.shadowHeight!==void 0)i.top=this.shadowHeight/2,i.bottom=-this.shadowHeight/2;else{const n=this.gameObject.scale.y;i.top*=n,i.bottom*=n}this.light.shadow.needsUpdate=!0,Ho&&this.context.scene.add(new dC(i))}this.isBaked?this.light.removeFromParent():t||this.gameObject.add(this.light)}}*updateMainLightRoutine(){for(;;){this.type===1&&((!this.context.mainLight||this.intensity>this.context.mainLight.intensity)&&(this.context.mainLight=this),yield);break}}updateShadowSoftHard(){this.light&&this.light.shadow&&(this.shadows===2||(this.light.shadow.radius=1,this.light.shadow.blurSamples=1))}setDirectionalLight(t){t.add(t.target),t.target.position.set(0,0,-1)}}a(mi,"allowChangingRendererShadowMapType",!0),cn([m()],mi.prototype,"type",2),cn([m(ae)],mi.prototype,"color",1),cn([m()],mi.prototype,"shadowNearPlane",1),cn([m()],mi.prototype,"shadowBias",1),cn([m()],mi.prototype,"shadowNormalBias",1),cn([m()],mi.prototype,"shadows",1),cn([m()],mi.prototype,"lightmapBakeType",2),cn([m()],mi.prototype,"intensity",1),cn([m()],mi.prototype,"shadowDistance",1),cn([m()],mi.prototype,"shadowResolution",1),new x(0,0,0);var vE=Object.defineProperty,bE=Object.getOwnPropertyDescriptor,wh=(s,t,i,n)=>{for(var o=n>1?void 0:n?bE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&vE(t,i,o),o};const V0=O("debuglods"),_E=O("nolods");class Zr{constructor(){a(this,"screenRelativeTransitionHeight"),a(this,"distance"),a(this,"renderers")}}wh([m()],Zr.prototype,"screenRelativeTransitionHeight",2),wh([m()],Zr.prototype,"distance",2),wh([m(Ze)],Zr.prototype,"renderers",2);class wE{constructor(t){a(this,"model"),this.model=t}get renderers(){return this.model.renderers}}class xh extends A{constructor(){super(...arguments),a(this,"fadeMode",0),a(this,"localReferencePoint"),a(this,"lodCount",0),a(this,"size",0),a(this,"animateCrossFading",!1),a(this,"lodModels"),a(this,"_lods",[]),a(this,"_settings",[]),a(this,"_lodsHandler"),a(this,"_distanceFactor",1)}start(){if(V0&&console.log("LODGROUP",this.name,this.lodModels,this),!_E&&!this._lodsHandler&&this.gameObject&&this.lodModels&&Array.isArray(this.lodModels)){const t=[];for(const n of this.lodModels){const o=new wE(n);this._lods.push(o);for(const r of o.renderers)t.includes(r)||t.push(r)}this._lodsHandler=new Array;for(let n=0;n<t.length;n++){const o=new uC;this._lodsHandler.push(o),this.gameObject.add(o)}const i=new j;i.name="Cull "+this.name;for(let n=0;n<t.length;n++){const o=t[n],r=this._lodsHandler[n],l=o.gameObject;V0&&console.log(n,l.name);for(const c of this._lods){const h=c.model.distance;let d=null;if(c.renderers.includes(o)?d=l:d=i,d.type==="Group"){console.warn(`LODGroup ${this.name}: Group or MultiMaterial object's are not supported as LOD object: ${d.name}`);continue}V0&&console.log("LEVEL",d.name,h),r.autoUpdate=!1,this.onAddLodLevel(r,d,c.model.distance)}}}}onAfterRender(){if(!this.gameObject||!this._lodsHandler)return;const t=this.context.mainCamera;if(t)for(const i of this._lodsHandler){i.update(t);const n=i.getCurrentLevel(),o=i.levels[n];i.layers.mask=o.object.layers.mask}}onAddLodLevel(t,i,n){if(i===this.gameObject){console.warn("LODGroup component must be on parent object and not mesh directly at the moment",i.name,i);return}t.addLevel(i,n*this._distanceFactor,.01);const o={lod:t,levelIndex:t.levels.length-1,distance:n};this._settings.push(o)}distanceFactor(t){if(t!==this._distanceFactor){this._distanceFactor=t;for(const i of this._settings){const n=i.lod.levels[i.levelIndex];n.distance=i.distance*t}}}}wh([m(x)],xh.prototype,"localReferencePoint",2),wh([m(Zr)],xh.prototype,"lodModels",2);var xE=Object.defineProperty,SE=Object.getOwnPropertyDescriptor,CE=(s,t,i,n)=>{for(var o=n>1?void 0:n?SE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&xE(t,i,o),o};const Cp=O("debugnestedgltf");class Op extends A{constructor(){super(...arguments),a(this,"filePath"),a(this,"loadAssetInParent",!0),a(this,"_isLoadingOrDoneLoading",!1)}listenToProgress(t){var i;(i=this.filePath)==null||i.beginListenDownload(t)}preload(){var t;(t=this.filePath)==null||t.preload()}async start(){var t,i,n,o,r;if(this._isLoadingOrDoneLoading)return;Cp&&console.log(this,this.guid);const l=this.gameObject.parent;if(l){this._isLoadingOrDoneLoading=!0;const c=new js;c.idProvider=new Bt(this.hash(this.guid)),c.parent=this.loadAssetInParent!==!1?l:this.gameObject,this.gameObject.updateMatrix();const h=this.gameObject.matrix;Cp&&console.log("Load nested:",((t=this.filePath)==null?void 0:t.url)??this.filePath,this.gameObject.position);const d=await((n=(i=this.filePath)==null?void 0:i.instantiate)==null?void 0:n.call(this.filePath,c));Cp&&console.log("Nested loaded:",((o=this.filePath)==null?void 0:o.url)??this.filePath,d),d&&this.loadAssetInParent!==!1&&(d.matrixAutoUpdate=!1,d.matrix.identity(),d.applyMatrix4(h),d.matrixAutoUpdate=!0,d.layers.disableAll(),d.layers.set(this.layer),this.dispatchEvent(new CustomEvent("loaded",{detail:{instance:d,assetReference:this.filePath}}))),Cp&&console.log("Nested loading done:",((r=this.filePath)==null?void 0:r.url)??this.filePath,d)}}onDestroy(){var t;(t=this.filePath)==null||t.unload()}hash(t){let i=0;for(let n=0;n<t.length;n++)i=t.charCodeAt(n)+((i<<5)-i);return i}}CE([m(le)],Op.prototype,"filePath",2);var OE=Object.defineProperty,PE=Object.getOwnPropertyDescriptor,H0=(s,t,i,n)=>{for(var o=n>1?void 0:n?PE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&OE(t,i,o),o};const kE=O("debugnet"),$0=class extends A{constructor(){super(...arguments),a(this,"url",null),a(this,"urlParameterName",null),a(this,"localhost",null)}awake(){kE&&console.log(this),this.context.connection.registerProvider(this)}getWebsocketUrl(){let s=this.url?$0.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){const i=O(this.urlParameterName);i&&typeof i=="string"&&(s=i)}if(!s)return null;const t=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(s);return t!=null&&t.groups?t?.groups.socket_prefix?s:"wss://"+t?.groups.url:null}static GetUrl(s,t){let i=s;const n=$0.IsLocalNetwork()&&t;if(n&&(i=t),s!=null&&s.startsWith("/")){const o=n?i:window.location.origin;o!=null&&o.endsWith("/")&&s.startsWith("/")&&(s=s.substring(1)),i=o+s}return i}static IsLocalNetwork(s=window.location.hostname){return Gt(s)}};let Cl=$0;H0([m()],Cl.prototype,"url",2),H0([m()],Cl.prototype,"urlParameterName",2),H0([m()],Cl.prototype,"localhost",2);var ME=Object.defineProperty,RE=Object.getOwnPropertyDescriptor,Pp=(s,t,i,n)=>{for(var o=n>1?void 0:n?RE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&ME(t,i,o),o};class Jr extends A{constructor(){super(...arguments),a(this,"referenceSpace"),a(this,"from"),a(this,"affectPosition",!1),a(this,"affectRotation",!1),a(this,"alignLookDirection",!1),a(this,"levelLookDirection",!1),a(this,"levelPosition",!1),a(this,"positionOffset",new x(0,0,0)),a(this,"rotationOffset",new x(0,0,0)),a(this,"offset",new x(0,0,0))}update(){if(!this.from)return;var t=ee(this.from),i=Se(this.from);this.offset.copy(this.positionOffset);const n=this.offset.length();if(this.referenceSpace&&this.offset.transformDirection(this.referenceSpace.matrixWorld).multiplyScalar(n),t.add(this.offset),this.levelPosition&&this.referenceSpace){const c=new dr(this.gameObject.up,0),h=ee(this.referenceSpace);c.setFromNormalAndCoplanarPoint(this.gameObject.up,h);const d=new x(0,0,0);c.projectPoint(t,d),t.copy(d)}this.affectPosition&&ct(this.gameObject,t);const o=new Ft(this.rotationOffset.x,this.rotationOffset.y,this.rotationOffset.z),r=new V().setFromEuler(o);this.affectRotation&&qi(this.gameObject,i.multiply(r));const l=new x;this.from.getWorldDirection(l).multiplyScalar(50),this.levelLookDirection&&(l.y=0),this.alignLookDirection&&this.gameObject.lookAt(l)}}Pp([m(P)],Jr.prototype,"referenceSpace",2),Pp([m(P)],Jr.prototype,"from",2),Pp([m(x)],Jr.prototype,"positionOffset",2),Pp([m(x)],Jr.prototype,"rotationOffset",2);var TE=Object.defineProperty,EE=Object.getOwnPropertyDescriptor,k=(s,t,i,n)=>{for(var o=n>1?void 0:n?EE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&TE(t,i,o),o};const kp=O("debugparticles");var $n=(s=>(s[s.Billboard=0]="Billboard",s[s.Stretch=1]="Stretch",s[s.HorizontalBillboard=2]="HorizontalBillboard",s[s.VerticalBillboard=3]="VerticalBillboard",s[s.Mesh=4]="Mesh",s))($n||{});class $o{constructor(){a(this,"alphaKeys",[]),a(this,"colorKeys",[])}get duration(){return 1}evaluate(t,i){let n,o=0,r=null,l=0;for(let c=0;c<this.alphaKeys.length;c++){const h=this.alphaKeys[c];(h.time<t||!n)&&(n=h,o=c)}for(let c=0;c<this.colorKeys.length;c++){const h=this.colorKeys[c];(h.time<t||!r)&&(r=h,l=c)}if(r)if(l+1<this.colorKeys.length){const c=this.colorKeys[l+1],h=W.remap(t,r.time,c.time,0,1);i.r=W.lerp(r.color.r,c.color.r,h),i.g=W.lerp(r.color.g,c.color.g,h),i.b=W.lerp(r.color.b,c.color.b,h)}else i.r=r.color.r,i.g=r.color.g,i.b=r.color.b;if(n)if(o+1<this.alphaKeys.length){const c=this.alphaKeys[o+1],h=W.remap(t,n.time,c.time,0,1);i.alpha=W.lerp(n.alpha,c.alpha,h)}else i.alpha=n.alpha;return i}}k([m()],$o.prototype,"alphaKeys",2),k([m()],$o.prototype,"colorKeys",2);var Sh=(s=>(s[s.Local=0]="Local",s[s.World=1]="World",s[s.Custom=2]="Custom",s))(Sh||{}),Mp=(s=>(s[s.Sphere=0]="Sphere",s[s.SphereShell=1]="SphereShell",s[s.Hemisphere=2]="Hemisphere",s[s.HemisphereShell=3]="HemisphereShell",s[s.Cone=4]="Cone",s[s.Box=5]="Box",s[s.Mesh=6]="Mesh",s[s.ConeShell=7]="ConeShell",s[s.ConeVolume=8]="ConeVolume",s[s.ConeVolumeShell=9]="ConeVolumeShell",s[s.Circle=10]="Circle",s[s.CircleEdge=11]="CircleEdge",s[s.SingleSidedEdge=12]="SingleSidedEdge",s[s.MeshRenderer=13]="MeshRenderer",s[s.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",s[s.BoxShell=15]="BoxShell",s[s.BoxEdge=16]="BoxEdge",s[s.Donut=17]="Donut",s[s.Rectangle=18]="Rectangle",s[s.Sprite=19]="Sprite",s[s.SpriteRenderer=20]="SpriteRenderer",s))(Mp||{});const Ch=class{constructor(){a(this,"mode","Constant"),a(this,"constant"),a(this,"constantMin"),a(this,"constantMax"),a(this,"curve"),a(this,"curveMin"),a(this,"curveMax"),a(this,"curveMultiplier")}static constant(s){const t=new Ch;return t.setConstant(s),t}static betweenTwoConstants(s,t){const i=new Ch;return i.setMinMaxConstant(s,t),i}static curve(s,t=1){const i=new Ch;return i.setCurve(s,t),i}setConstant(s){this.mode=0,this.constant=s}setMinMaxConstant(s,t){this.mode=3,this.constantMin=s,this.constantMax=t}setCurve(s,t=1){this.mode=1,this.curve=s,this.curveMultiplier=t}clone(){var s,t,i;const n=new Ch;return n.mode=this.mode,n.constant=this.constant,n.constantMin=this.constantMin,n.constantMax=this.constantMax,n.curve=(s=this.curve)==null?void 0:s.clone(),n.curveMin=(t=this.curveMin)==null?void 0:t.clone(),n.curveMax=(i=this.curveMax)==null?void 0:i.clone(),n.curveMultiplier=this.curveMultiplier,n}evaluate(s,t){const i=t===void 0?Math.random():t;switch(this.mode){case 0:case"Constant":return this.constant;case 1:case"Curve":return s=W.clamp01(s),this.curve.evaluate(s)*this.curveMultiplier;case 2:case"TwoCurves":const n=s*this.curveMin.duration,o=s*this.curveMax.duration;return W.lerp(this.curveMin.evaluate(n),this.curveMax.evaluate(o),i%1)*this.curveMultiplier;case 3:case"TwoConstants":return W.lerp(this.constantMin,this.constantMax,i%1);default:this.curveMax.evaluate(s)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:case"Constant":return this.constant;case 1:case"Curve":return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:case"TwoCurves":return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:case"TwoConstants":return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(s){if(!s)return 0;let t=Number.MIN_VALUE;for(let i=0;i<s.keys.length;i++){const n=s.keys[i];n.value>t&&(t=n.value)}return t}};let X=Ch;k([m()],X.prototype,"mode",2),k([m()],X.prototype,"constant",2),k([m()],X.prototype,"constantMin",2),k([m()],X.prototype,"constantMax",2),k([m(Lr)],X.prototype,"curve",2),k([m(Lr)],X.prototype,"curveMin",2),k([m(Lr)],X.prototype,"curveMax",2),k([m()],X.prototype,"curveMultiplier",2);var Rp;const It=(Rp=class{constructor(){a(this,"mode",0),a(this,"color"),a(this,"colorMin"),a(this,"colorMax"),a(this,"gradient"),a(this,"gradientMin"),a(this,"gradientMax")}static constant(s){const t=new It;return t.constant(s),t}static betweenTwoColors(s,t){const i=new It;return i.betweenTwoColors(s,t),i}constant(s){return this.mode=0,this.color=s,this}betweenTwoColors(s,t){return this.mode=2,this.colorMin=s,this.colorMax=t,this}evaluate(s,t){const i=t===void 0?Math.random():t;switch(this.mode){case 0:case"Color":return this.color;case 1:case"Gradient":return this.gradient.evaluate(s,It._temp),It._temp;case 2:case"TwoColors":return It._temp.lerpColors(this.colorMin,this.colorMax,i);case 3:case"TwoGradients":return this.gradientMin.evaluate(s,It._temp),this.gradientMax.evaluate(s,It._temp2),It._temp.lerp(It._temp2,i);case 4:case"RandomColor":const n=Math.random();return this.gradientMin.evaluate(s,It._temp),this.gradientMax.evaluate(s,It._temp2),It._temp.lerp(It._temp2,n)}return It._temp.set(16777215),It._temp.alpha=1,It._temp}},a(Rp,"_temp",new we(0,0,0,1)),a(Rp,"_temp2",new we(0,0,0,1)),Rp);let ii=It;k([m()],ii.prototype,"mode",2),k([m(we)],ii.prototype,"color",2),k([m(we)],ii.prototype,"colorMin",2),k([m(we)],ii.prototype,"colorMax",2),k([m($o)],ii.prototype,"gradient",2),k([m($o)],ii.prototype,"gradientMin",2),k([m($o)],ii.prototype,"gradientMax",2);var q0=(s=>(s[s.Hierarchy=0]="Hierarchy",s[s.Local=1]="Local",s[s.Shape=2]="Shape",s))(q0||{});class jt{constructor(){a(this,"cullingMode"),a(this,"duration"),a(this,"emitterVelocityMode"),a(this,"flipRotation"),a(this,"gravityModifier"),a(this,"gravityModifierMultiplier"),a(this,"loop"),a(this,"maxParticles"),a(this,"playOnAwake"),a(this,"prewarm"),a(this,"ringBufferLoopRange"),a(this,"ringBufferMode"),a(this,"scalingMode"),a(this,"simulationSpace"),a(this,"simulationSpeed"),a(this,"startColor"),a(this,"startDelay"),a(this,"startDelayMultiplier"),a(this,"startLifetime"),a(this,"startLifetimeMultiplier"),a(this,"startRotation"),a(this,"startRotationMultiplier"),a(this,"startRotation3D"),a(this,"startRotationX"),a(this,"startRotationXMultiplier"),a(this,"startRotationY"),a(this,"startRotationYMultiplier"),a(this,"startRotationZ"),a(this,"startRotationZMultiplier"),a(this,"startSize"),a(this,"startSize3D"),a(this,"startSizeMultiplier"),a(this,"startSizeX"),a(this,"startSizeXMultiplier"),a(this,"startSizeY"),a(this,"startSizeYMultiplier"),a(this,"startSizeZ"),a(this,"startSizeZMultiplier"),a(this,"startSpeed"),a(this,"startSpeedMultiplier"),a(this,"stopAction"),a(this,"useUnscaledTime")}}k([m(X)],jt.prototype,"gravityModifier",2),k([m(ii)],jt.prototype,"startColor",2),k([m(X)],jt.prototype,"startDelay",2),k([m(X)],jt.prototype,"startLifetime",2),k([m(X)],jt.prototype,"startRotation",2),k([m(X)],jt.prototype,"startRotationX",2),k([m(X)],jt.prototype,"startRotationY",2),k([m(X)],jt.prototype,"startRotationZ",2),k([m(X)],jt.prototype,"startSize",2),k([m(X)],jt.prototype,"startSizeX",2),k([m(X)],jt.prototype,"startSizeY",2),k([m(X)],jt.prototype,"startSizeZ",2),k([m(X)],jt.prototype,"startSpeed",2);class Oh{constructor(){a(this,"cycleCount"),a(this,"maxCount"),a(this,"minCount"),a(this,"probability"),a(this,"repeatInterval"),a(this,"time"),a(this,"count"),a(this,"_performed",0)}reset(){this._performed=0}run(t){if(t<=this.time)return 0;let i=0;if(this.cycleCount===0||this._performed<this.cycleCount){const n=this.time+this.repeatInterval*this._performed;if(t>=n&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:i=this.count.constant;break;case 3:i=W.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:i=this.count.curve.evaluate(Math.random());break;case 2:const o=Math.random();i=W.lerp(this.count.curveMin.evaluate(o),this.count.curveMax.evaluate(o),Math.random());break}}return i}}class hn{constructor(){a(this,"enabled"),a(this,"bursts"),a(this,"rateOverTime"),a(this,"rateOverTimeMultiplier"),a(this,"rateOverDistance"),a(this,"rateOverDistanceMultiplier"),a(this,"system")}get burstCount(){var t;return((t=this.bursts)==null?void 0:t.length)??0}reset(){var t;(t=this.bursts)==null||t.forEach(i=>i.reset())}getBurst(){let t=0;if(this.burstCount>0)for(let i=0;i<this.burstCount;i++){const n=this.bursts[i];this.system.main.loop&&n.time>=this.system.time&&n.reset(),t+=Math.round(n.run(this.system.time))}return t}}k([m()],hn.prototype,"enabled",2),k([m()],hn.prototype,"bursts",2),k([m(X)],hn.prototype,"rateOverTime",2),k([m()],hn.prototype,"rateOverTimeMultiplier",2),k([m(X)],hn.prototype,"rateOverDistance",2),k([m()],hn.prototype,"rateOverDistanceMultiplier",2);class Ph{constructor(){a(this,"enabled"),a(this,"color")}}k([m(ii)],Ph.prototype,"color",2);class qo{constructor(){a(this,"enabled"),a(this,"separateAxes"),a(this,"size"),a(this,"sizeMultiplier"),a(this,"x"),a(this,"xMultiplier"),a(this,"y"),a(this,"yMultiplier"),a(this,"z"),a(this,"zMultiplier"),a(this,"_time",0),a(this,"_temp",new x)}evaluate(t,i,n){if(i||(i=this._temp),!this.enabled)return i.x=i.y=i.z=1,i;if(this.separateAxes)i.x=this.x.evaluate(t,n)*this.xMultiplier,i.y=this.y.evaluate(t,n)*this.yMultiplier,i.z=this.z.evaluate(t,n)*this.zMultiplier;else{const o=this.size.evaluate(t,n)*this.sizeMultiplier;i.x=o}return i}}k([m(X)],qo.prototype,"size",2),k([m(X)],qo.prototype,"x",2),k([m(X)],qo.prototype,"y",2),k([m(X)],qo.prototype,"z",2);var Tp;const kh=(Tp=class{constructor(){a(this,"shapeType",5),a(this,"enabled",!0),a(this,"alignToDirection",!1),a(this,"angle",0),a(this,"arc",360),a(this,"arcSpread"),a(this,"arcSpeedMultiplier"),a(this,"arcMode"),a(this,"boxThickness"),a(this,"position"),a(this,"rotation"),a(this,"_rotation",new Ft),a(this,"scale"),a(this,"radius"),a(this,"radiusThickness"),a(this,"sphericalDirectionAmount"),a(this,"randomDirectionAmount"),a(this,"randomPositionAmount"),a(this,"meshShapeType"),a(this,"meshRenderer"),a(this,"_meshObj"),a(this,"_meshGeometry"),a(this,"system"),a(this,"_space"),a(this,"_worldSpaceMatrix",new ne),a(this,"_worldSpaceMatrixInverse",new ne),a(this,"_vector",new x(0,0,0)),a(this,"_temp",new x(0,0,0)),a(this,"_triangle",new pC),a(this,"_dir",new x),a(this,"_loopTime",0),a(this,"_loopDirection",1),kp&&console.log(this)}get type(){return Mp[this.shapeType]}initialize(s){this.onInitialize(s),s.position.x=this._vector.x,s.position.y=this._vector.y,s.position.z=this._vector.z}toJSON(){return this}clone(){return new kh}setMesh(s){this.meshRenderer=s,s?(this._meshObj=s.sharedMeshes[Math.floor(Math.random()*s.sharedMeshes.length)],this._meshGeometry=this._meshObj.geometry):(this._meshObj=void 0,this._meshGeometry=void 0)}update(s,t){}onUpdate(s,t,i,n){this.system=s,this._space=i,i===1&&(this._worldSpaceMatrix.copy(n.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(s){const t=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return t&&(this._rotation.x=W.toRadians(this.rotation.x),this._rotation.y=W.toRadians(this.rotation.y),this._rotation.z=W.toRadians(this.rotation.z),this._rotation.order="ZYX",s.applyEuler(this._rotation)),t}onInitialize(s){this._vector.set(0,0,0),s.mesh=void 0,s.mesh_geometry=void 0;const t=this._temp.copy(this.position),i=this._space===1;i&&t.applyQuaternion(this.system.worldQuaternion);let n=this.radius;if(i&&(n*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:kp&&q.DrawWireBox(this.position,this.scale,14540253,1),this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(t);break;case 4:this.randomConePoint(this.position,this.angle,n,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,n,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,n,this.radiusThickness,this.arc,this._vector);break;case 13:const o=this.meshRenderer;o?.destroyed==!1&&this.setMesh(o);const r=s.mesh=this._meshObj,l=s.mesh_geometry=this._meshGeometry;if(r&&l)switch(this.meshShapeType){case 0:{const c=l.getAttribute("position"),h=Math.floor(Math.random()*c.count);this._vector.fromBufferAttribute(c,h),this._vector.applyMatrix4(r.matrixWorld),s.mesh_normal=h}break;case 1:break;case 2:{const c=l.index;if(c){let h=Math.random(),d=Math.random();h+d>1&&(h=1-h,d=1-d);const u=Math.floor(Math.random()*(c.count/3));let p=u*3,g=u*3+1,y=u*3+2;p=c.getX(p),g=c.getX(g),y=c.getX(y);const f=l.getAttribute("position");this._triangle.a.fromBufferAttribute(f,p),this._triangle.b.fromBufferAttribute(f,g),this._triangle.c.fromBufferAttribute(f,y),this._vector.set(0,0,0).addScaledVector(this._triangle.a,h).addScaledVector(this._triangle.b,d).addScaledVector(this._triangle.c,1-(h+d)),this._vector.applyMatrix4(r.matrixWorld),s.mesh_normal=u}}break}break;default:this._vector.set(0,0,0),F()&&!globalThis.__particlesystem_shapetype_unsupported&&(console.warn("ParticleSystem ShapeType is not supported:",Mp[this.shapeType]),globalThis.__particlesystem_shapetype_unsupported=!0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),i&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),kp&&q.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(s,t){var i;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const n=t.x,o=t.y,r=t.z;this._dir.set(n,o,r),(i=this.system)!=null&&i.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;case 13:const l=s.mesh,c=s.mesh_geometry;if(l&&c)switch(this.meshShapeType){case 0:{const h=c.getAttribute("normal"),d=s.mesh_normal;this._dir.fromBufferAttribute(h,d)}break;case 1:break;case 2:{const h=c.index;if(h){const d=s.mesh_normal,u=h.getX(d*3),p=h.getX(d*3+1),g=h.getX(d*3+2),y=c.getAttribute("position"),f=$(),v=$(),b=$();f.fromBufferAttribute(y,u),v.fromBufferAttribute(y,p),b.fromBufferAttribute(y,g),f.sub(v),b.sub(v),f.cross(b),this._dir.copy(f).multiplyScalar(-1);const w=Se(l);this._dir.applyQuaternion(w)}}break}break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),kp&&(q.DrawSphere(t,.01,8925952,.5,!0),q.DrawDirection(t,this._dir,8925952,.5,!0)),this._dir}randomizePosition(s,t){if(t<=0)return;const i=kh._tempVec;i.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),i.x*=t*this.scale.x,i.y*=t*this.scale.y,i.z*=t*this.scale.z,s.add(i)}randomizeDirection(s,t){if(t===0)return;const i=kh._randomQuat,n=kh._tempVec;n.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),i.setFromAxisAngle(n,t*Math.random()*Math.PI),s.applyQuaternion(i)}spherizeDirection(s,t){if(t===0)return;const i=Math.random()*Math.PI*2,n=Math.acos(1-Math.random()*2),o=Math.sin(n)*Math.cos(i),r=Math.sin(n)*Math.sin(i),l=Math.cos(n),c=new x(o,r,l);s.lerp(c,t)}randomSpherePoint(s,t,i,n,o){const r=Math.random(),l=Math.random(),c=2*Math.PI*r*(n/360),h=Math.acos(2*l-1),d=W.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*t,u=s.x+this.scale.x*(-d*Math.sin(h)*Math.cos(c)),p=s.y+this.scale.y*(d*Math.sin(h)*Math.sin(c)),g=s.z+this.scale.z*(d*Math.cos(h));o.x=u,o.y=p,o.z=g}randomCirclePoint(s,t,i,n,o){const r=Math.random(),l=2*Math.PI*r*(n/360),c=W.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*t,h=s.x+this.scale.x*c*Math.cos(l),d=s.y+this.scale.y*c*Math.sin(l),u=s.z;o.x=h,o.y=d,o.z=u}randomConePoint(s,t,i,n,o,r,l){let c=0,h=0;switch(r){case 0:c=Math.random(),h=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:c=.5,h=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let d=2*Math.PI*c*(o/360);switch(r){case 2:case 1:d+=Math.PI+.5,d+=this._loopTime*Math.PI*2,d%=W.toRadians(o);break}const u=Math.acos(2*h-1),p=W.lerp(1,1-Math.pow(1-Math.random(),Math.PI),n)*i,g=s.x+-p*Math.sin(u)*Math.cos(d),y=s.y+p*Math.sin(u)*Math.sin(d),f=s.z;l.x=g*this.scale.x,l.y=y*this.scale.y,l.z=f*this.scale.z}},a(Tp,"_randomQuat",new V),a(Tp,"_tempVec",new x),Tp);let Xe=kh;k([m()],Xe.prototype,"shapeType",2),k([m()],Xe.prototype,"enabled",2),k([m()],Xe.prototype,"alignToDirection",2),k([m()],Xe.prototype,"angle",2),k([m()],Xe.prototype,"arc",2),k([m()],Xe.prototype,"arcSpread",2),k([m()],Xe.prototype,"arcSpeedMultiplier",2),k([m()],Xe.prototype,"arcMode",2),k([m(x)],Xe.prototype,"boxThickness",2),k([m(x)],Xe.prototype,"position",2),k([m(x)],Xe.prototype,"rotation",2),k([m(x)],Xe.prototype,"scale",2),k([m()],Xe.prototype,"radius",2),k([m()],Xe.prototype,"radiusThickness",2),k([m()],Xe.prototype,"sphericalDirectionAmount",2),k([m()],Xe.prototype,"randomDirectionAmount",2),k([m()],Xe.prototype,"randomPositionAmount",2),k([m()],Xe.prototype,"meshShapeType",2),k([m(ih)],Xe.prototype,"meshRenderer",2);class xe{constructor(){a(this,"damping"),a(this,"enabled"),a(this,"frequency"),a(this,"octaveCount"),a(this,"octaveMultiplier"),a(this,"octaveScale"),a(this,"positionAmount"),a(this,"quality"),a(this,"remap"),a(this,"remapEnabled"),a(this,"remapMultiplier"),a(this,"remapX"),a(this,"remapXMultiplier"),a(this,"remapY"),a(this,"remapYMultiplier"),a(this,"remapZ"),a(this,"remapZMultiplier"),a(this,"scrollSpeedMultiplier"),a(this,"separateAxes"),a(this,"strengthMultiplier"),a(this,"strengthX"),a(this,"strengthXMultiplier"),a(this,"strengthY"),a(this,"strengthYMultiplier"),a(this,"strengthZ"),a(this,"strengthZMultiplier"),a(this,"_noise"),a(this,"_time",0),a(this,"_temp",new x)}update(t){this._time+=t.time.deltaTime*this.scrollSpeedMultiplier}apply(t,i,n,o,r,l){if(!this.enabled)return;this._noise||(this._noise=ZC(()=>0));const c=this._temp.set(i.x,i.y,i.z).multiplyScalar(this.frequency),h=this._noise(c.x,c.y,c.z,this._time),d=this._noise(c.x,c.y,c.z,this._time+1e3*this.frequency),u=this._noise(c.x,c.y,c.z,this._time+2e3*this.frequency);this._temp.set(h,d,u).normalize();const p=r/l;let g=this.positionAmount.evaluate(p);this.separateAxes?(this._temp.x*=g*this.strengthXMultiplier,this._temp.y*=g*this.strengthYMultiplier,this._temp.z*=g*this.strengthZMultiplier):(this.strengthX&&(g*=this.strengthX.evaluate(p)*1.5),this._temp.multiplyScalar(g)),n.x+=this._temp.x,n.y+=this._temp.y,n.z+=this._temp.z}}k([m()],xe.prototype,"damping",2),k([m()],xe.prototype,"enabled",2),k([m()],xe.prototype,"frequency",2),k([m()],xe.prototype,"octaveCount",2),k([m()],xe.prototype,"octaveMultiplier",2),k([m()],xe.prototype,"octaveScale",2),k([m(X)],xe.prototype,"positionAmount",2),k([m()],xe.prototype,"quality",2),k([m(X)],xe.prototype,"remap",2),k([m()],xe.prototype,"remapEnabled",2),k([m()],xe.prototype,"remapMultiplier",2),k([m(X)],xe.prototype,"remapX",2),k([m()],xe.prototype,"remapXMultiplier",2),k([m(X)],xe.prototype,"remapY",2),k([m()],xe.prototype,"remapYMultiplier",2),k([m(X)],xe.prototype,"remapZ",2),k([m()],xe.prototype,"remapZMultiplier",2),k([m()],xe.prototype,"scrollSpeedMultiplier",2),k([m()],xe.prototype,"separateAxes",2),k([m()],xe.prototype,"strengthMultiplier",2),k([m(X)],xe.prototype,"strengthX",2),k([m()],xe.prototype,"strengthXMultiplier",2),k([m(X)],xe.prototype,"strengthY",2),k([m()],xe.prototype,"strengthYMultiplier",2),k([m(X)],xe.prototype,"strengthZ",2),k([m()],xe.prototype,"strengthZMultiplier",2);class ze{constructor(){a(this,"enabled"),a(this,"attachRibbonToTransform",!1),a(this,"colorOverLifetime"),a(this,"colorOverTrail"),a(this,"dieWithParticles",!0),a(this,"inheritParticleColor",!0),a(this,"lifetime"),a(this,"lifetimeMultiplier"),a(this,"minVertexDistance",.2),a(this,"mode",0),a(this,"ratio",1),a(this,"ribbonCount",1),a(this,"shadowBias",0),a(this,"sizeAffectsLifetime",!1),a(this,"sizeAffectsWidth",!1),a(this,"splitSubEmitterRibbons",!1),a(this,"textureMode",0),a(this,"widthOverTrail"),a(this,"widthOverTrailMultiplier"),a(this,"worldSpace",!1)}getWidth(t,i,n,o){const r=this.widthOverTrail.evaluate(n,o);return t*=r,t}getColor(t,i,n){const o=this.colorOverTrail.evaluate(n),r=this.colorOverLifetime.evaluate(i);t.x*=o.r*r.r,t.y*=o.g*r.g,t.z*=o.b*r.b,"alpha"in o&&"alpha"in r&&(t.w*=o.alpha*r.alpha)}}k([m()],ze.prototype,"enabled",2),k([m()],ze.prototype,"attachRibbonToTransform",2),k([m(ii)],ze.prototype,"colorOverLifetime",2),k([m(ii)],ze.prototype,"colorOverTrail",2),k([m()],ze.prototype,"dieWithParticles",2),k([m()],ze.prototype,"inheritParticleColor",2),k([m(X)],ze.prototype,"lifetime",2),k([m()],ze.prototype,"lifetimeMultiplier",2),k([m()],ze.prototype,"minVertexDistance",2),k([m()],ze.prototype,"mode",2),k([m()],ze.prototype,"ratio",2),k([m()],ze.prototype,"ribbonCount",2),k([m()],ze.prototype,"shadowBias",2),k([m()],ze.prototype,"sizeAffectsLifetime",2),k([m()],ze.prototype,"sizeAffectsWidth",2),k([m()],ze.prototype,"splitSubEmitterRibbons",2),k([m()],ze.prototype,"textureMode",2),k([m(X)],ze.prototype,"widthOverTrail",2),k([m()],ze.prototype,"widthOverTrailMultiplier",2),k([m()],ze.prototype,"worldSpace",2);class Qe{constructor(){a(this,"enabled"),a(this,"space",0),a(this,"orbitalX"),a(this,"orbitalY"),a(this,"orbitalZ"),a(this,"orbitalXMultiplier"),a(this,"orbitalYMultiplier"),a(this,"orbitalZMultiplier"),a(this,"orbitalOffsetX"),a(this,"orbitalOffsetY"),a(this,"orbitalOffsetZ"),a(this,"speedModifier"),a(this,"speedModifierMultiplier"),a(this,"x"),a(this,"xMultiplier"),a(this,"y"),a(this,"yMultiplier"),a(this,"z"),a(this,"zMultiplier"),a(this,"_system"),a(this,"_temp",new x),a(this,"_temp2",new x),a(this,"_temp3",new x),a(this,"_hasOrbital",!1),a(this,"_index",0),a(this,"_orbitalMatrix",new ne)}update(t){this._system=t}init(t){this._index==0&&(t.debug=!0),this._index+=1,t.orbitx=this.orbitalX.evaluate(Math.random()),t.orbity=this.orbitalY.evaluate(Math.random()),t.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=t.orbitx!=0||t.orbity!=0||t.orbitz!=0}apply(t,i,n,o,r,l,c){var h;if(!this.enabled)return;const d=l/c,u=this.speedModifier.evaluate(d)*this.speedModifierMultiplier,p=this.x.evaluate(d),g=this.y.evaluate(d),y=this.z.evaluate(d);if(this._temp.set(-p,g,y),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((h=this._system)==null?void 0:h.worldPos)){const f=this._temp2.set(n.x,n.y,n.z),v=this.orbitalXMultiplier,b=this.orbitalYMultiplier,w=this.orbitalZMultiplier,_=u*Math.PI*2*10,C=Math.cos(_*v),R=Math.sin(_*v),M=Math.cos(_*b),E=Math.sin(_*b),B=Math.cos(_*w),L=Math.sin(_*w),U=f.x*(M*B)+f.y*(M*L)+f.z*-E,z=f.x*(R*E*B-C*L)+f.y*(R*E*L+C*B)+f.z*(R*M),H=f.x*(C*E*B+R*L)+f.y*(C*E*L-R*B)+f.z*(C*M),T=this._temp3.set(f.x-U,f.y-z,f.z-H);T.normalize(),T.multiplyScalar(.2/r*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),o.x+=T.x,o.y+=T.y,o.z+=T.z}o.x+=this._temp.x,o.y+=this._temp.y,o.z+=this._temp.z,o.x*=u,o.y*=u,o.z*=u}}k([m()],Qe.prototype,"enabled",2),k([m()],Qe.prototype,"space",2),k([m(X)],Qe.prototype,"orbitalX",2),k([m(X)],Qe.prototype,"orbitalY",2),k([m(X)],Qe.prototype,"orbitalZ",2),k([m()],Qe.prototype,"orbitalXMultiplier",2),k([m()],Qe.prototype,"orbitalYMultiplier",2),k([m()],Qe.prototype,"orbitalZMultiplier",2),k([m()],Qe.prototype,"orbitalOffsetX",2),k([m()],Qe.prototype,"orbitalOffsetY",2),k([m()],Qe.prototype,"orbitalOffsetZ",2),k([m(X)],Qe.prototype,"speedModifier",2),k([m()],Qe.prototype,"speedModifierMultiplier",2),k([m(X)],Qe.prototype,"x",2),k([m()],Qe.prototype,"xMultiplier",2),k([m(X)],Qe.prototype,"y",2),k([m()],Qe.prototype,"yMultiplier",2),k([m(X)],Qe.prototype,"z",2),k([m()],Qe.prototype,"zMultiplier",2);class Lt{constructor(){a(this,"animation"),a(this,"enabled"),a(this,"cycleCount"),a(this,"frameOverTime"),a(this,"frameOverTimeMultiplier"),a(this,"numTilesX"),a(this,"numTilesY"),a(this,"startFrame"),a(this,"startFrameMultiplier"),a(this,"rowMode"),a(this,"rowIndex"),a(this,"spriteCount"),a(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(t){if(!this.sampleOnceAtStart())return this.getIndex(t)}getIndex(t){const i=this.numTilesX*this.numTilesY;t=t*this.cycleCount;let n=this.frameOverTime.evaluate(t%1);return n*=this.frameOverTimeMultiplier,n*=i,n=n%i,n=Math.floor(n),n}}k([m()],Lt.prototype,"animation",2),k([m()],Lt.prototype,"enabled",2),k([m()],Lt.prototype,"cycleCount",2),k([m(X)],Lt.prototype,"frameOverTime",2),k([m()],Lt.prototype,"frameOverTimeMultiplier",2),k([m()],Lt.prototype,"numTilesX",2),k([m()],Lt.prototype,"numTilesY",2),k([m(X)],Lt.prototype,"startFrame",2),k([m()],Lt.prototype,"startFrameMultiplier",2),k([m()],Lt.prototype,"rowMode",2),k([m()],Lt.prototype,"rowIndex",2),k([m()],Lt.prototype,"spriteCount",2),k([m()],Lt.prototype,"timeMode",2);class ns{constructor(){a(this,"enabled"),a(this,"separateAxes"),a(this,"x"),a(this,"xMultiplier"),a(this,"y"),a(this,"yMultiplier"),a(this,"z"),a(this,"zMultiplier")}evaluate(t,i){return this.enabled?this.separateAxes?0:this.z.evaluate(t,i)*-1:0}}k([m()],ns.prototype,"enabled",2),k([m()],ns.prototype,"separateAxes",2),k([m(X)],ns.prototype,"x",2),k([m()],ns.prototype,"xMultiplier",2),k([m(X)],ns.prototype,"y",2),k([m()],ns.prototype,"yMultiplier",2),k([m(X)],ns.prototype,"z",2),k([m()],ns.prototype,"zMultiplier",2);class Bi{constructor(){a(this,"enabled"),a(this,"range"),a(this,"separateAxes"),a(this,"x"),a(this,"xMultiplier"),a(this,"y"),a(this,"yMultiplier"),a(this,"z"),a(this,"zMultiplier")}evaluate(t,i){if(!this.enabled)return 0;if(!this.separateAxes){const n=W.lerp(this.range.x,this.range.y,i);return this.z.evaluate(n)*-1}return 0}}k([m()],Bi.prototype,"enabled",2),k([m()],Bi.prototype,"range",2),k([m()],Bi.prototype,"separateAxes",2),k([m(X)],Bi.prototype,"x",2),k([m()],Bi.prototype,"xMultiplier",2),k([m(X)],Bi.prototype,"y",2),k([m()],Bi.prototype,"yMultiplier",2),k([m(X)],Bi.prototype,"z",2),k([m()],Bi.prototype,"zMultiplier",2);class rt{constructor(){a(this,"enabled"),a(this,"dampen"),a(this,"drag"),a(this,"dragMultiplier"),a(this,"limit"),a(this,"limitMultiplier"),a(this,"separateAxes"),a(this,"limitX"),a(this,"limitXMultiplier"),a(this,"limitY"),a(this,"limitYMultiplier"),a(this,"limitZ"),a(this,"limitZMultiplier"),a(this,"multiplyDragByParticleSize",!1),a(this,"multiplyDragByParticleVelocity",!1),a(this,"space"),a(this,"_temp",new x),a(this,"_temp2",new x)}apply(t,i,n,o,r,l,c){if(this.enabled){const h=this.limit.evaluate(r)*this.limitMultiplier;if(i.length()>h){this._temp.copy(i).normalize().multiplyScalar(h);const d=this.dampen*.5;i.x=W.lerp(i.x,this._temp.x,d),i.y=W.lerp(i.y,this._temp.y,d),i.z=W.lerp(i.z,this._temp.z,d),n.x=W.lerp(n.x,this._temp.x,d),n.y=W.lerp(n.y,this._temp.y,d),n.z=W.lerp(n.z,this._temp.z,d)}}}}k([m()],rt.prototype,"enabled",2),k([m()],rt.prototype,"dampen",2),k([m(X)],rt.prototype,"drag",2),k([m()],rt.prototype,"dragMultiplier",2),k([m(X)],rt.prototype,"limit",2),k([m()],rt.prototype,"limitMultiplier",2),k([m()],rt.prototype,"separateAxes",2),k([m(X)],rt.prototype,"limitX",2),k([m()],rt.prototype,"limitXMultiplier",2),k([m(X)],rt.prototype,"limitY",2),k([m()],rt.prototype,"limitYMultiplier",2),k([m(X)],rt.prototype,"limitZ",2),k([m()],rt.prototype,"limitZMultiplier",2),k([m()],rt.prototype,"multiplyDragByParticleSize",2),k([m()],rt.prototype,"multiplyDragByParticleVelocity",2),k([m()],rt.prototype,"space",2);const i1=class{constructor(){a(this,"enabled"),a(this,"curve"),a(this,"curveMultiplier"),a(this,"mode"),a(this,"system"),a(this,"_temp",new x),a(this,"_firstUpdate",!0),a(this,"_frames",0)}clone(){var s;const t=new i1;return t.enabled=this.enabled,t.curve=(s=this.curve)==null?void 0:s.clone(),t.curveMultiplier=this.curveMultiplier,t.mode=this.mode,t}get _lastWorldPosition(){return this.system._iv_lastWorldPosition||(this.system._iv_lastWorldPosition=new x),this.system._iv_lastWorldPosition}get _velocity(){return this.system._iv_velocity||(this.system._iv_velocity=new x),this.system._iv_velocity}awake(s){this.system=s,this.reset()}reset(){this._firstUpdate=!0}update(s){this.enabled&&this.system.worldspace!==!1&&(this._firstUpdate?(this._firstUpdate=!1,this._velocity.set(0,0,0),this._lastWorldPosition.copy(this.system.worldPos)):this._lastWorldPosition&&(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)))}applyInitial(s){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const t=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(t),s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z}}applyCurrent(s,t,i){if(this.enabled&&this.system&&this.system.worldspace!==!1&&this.mode===1){const n=this.curve.evaluate(t,i);this._temp.copy(this._velocity).multiplyScalar(n),s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z}}};let Go=i1;k([m()],Go.prototype,"enabled",2),k([m(X)],Go.prototype,"curve",2),k([m()],Go.prototype,"curveMultiplier",2),k([m()],Go.prototype,"mode",2);class si{constructor(){a(this,"enabled"),a(this,"range"),a(this,"separateAxes"),a(this,"size"),a(this,"sizeMultiplier"),a(this,"x"),a(this,"xMultiplier"),a(this,"y"),a(this,"yMultiplier"),a(this,"z"),a(this,"zMultiplier")}evaluate(t,i,n,o){const r=t.length(),l=W.remap(r,this.range.x,this.range.y,0,1),c=this.size.evaluate(l,n);return o.x*=c,o.y*=c,o.z*=c,o}}k([m()],si.prototype,"enabled",2),k([m(oe)],si.prototype,"range",2),k([m()],si.prototype,"separateAxes",2),k([m(X)],si.prototype,"size",2),k([m()],si.prototype,"sizeMultiplier",2),k([m(X)],si.prototype,"x",2),k([m()],si.prototype,"xMultiplier",2),k([m(X)],si.prototype,"y",2),k([m()],si.prototype,"yMultiplier",2),k([m(X)],si.prototype,"z",2),k([m()],si.prototype,"zMultiplier",2);class ea{constructor(){a(this,"enabled"),a(this,"range"),a(this,"color")}evaluate(t,i,n){const o=t.length(),r=W.remap(o,this.range.x,this.range.y,0,1),l=this.color.evaluate(r,i);n.x*=l.r,n.y*=l.g,n.z*=l.b,"alpha"in l&&(n.w*=l.alpha)}}k([m()],ea.prototype,"enabled",2),k([m(oe)],ea.prototype,"range",2),k([m(ii)],ea.prototype,"color",2),new x(1,1,1),new x(0,0,1);class Ep{constructor(t,i,n,o){a(this,"type","NeedleParticleSubEmitter"),a(this,"emitterType"),a(this,"emitterProbability"),a(this,"q_",new V),a(this,"v_",new x),a(this,"v2_",new x),a(this,"_emitterMatrix",new Cm),a(this,"_circularBuffer"),this.system=t,this.particleSystem=i,this.subSystem=n,this.subParticleSystem=o,this.subParticleSystem&&this.subParticleSystem&&(this.subParticleSystem.onlyUsedByOther=!0);const r=1e3;this._circularBuffer=new wi(()=>new Cm,r)}clone(){throw new Error("Method not implemented.")}initialize(t){t.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0},this._emitterMatrix.copy(this.subSystem.matrixWorld).invert().premultiply(this.system.matrixWorld),this._emitterMatrix.setPosition(0,0,0),this.emitterType===G0.Birth&&this.run(t)}update(t,i){this.run(t)}frameUpdate(t){}toJSON(){}reset(){}run(t){if(this.subSystem.currentParticles>=this.subSystem.main.maxParticles||!this.subParticleSystem||!t.emissionState||this.emitterProbability&&Math.random()>this.emitterProbability)return;const i=this.system.deltaTime;if(this.emitterType===G0.Death){let o=t.life;if(t[Ol]!==void 0&&(o=t[Ol]),!(t.age+i*1.2>=o))return;const r=this.subSystem.main.maxParticles-this.subSystem.currentParticles;t.emissionState.waitEmiting=r}const n=new Cm;n.set(1,0,0,t.position.x,0,1,0,t.position.y,0,0,1,t.position.z,0,0,0,1),this.particleSystem.worldSpace||n.multiplyMatrices(this._emitterMatrix,n),this.subParticleSystem.emit(i,t.emissionState,n)}}var AE=Object.defineProperty,IE=Object.getOwnPropertyDescriptor,Ye=(s,t,i,n)=>{for(var o=n>1?void 0:n?IE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&AE(t,i,o),o};const Xo=O("debugparticles"),jE=O("noprogressive"),LE=O("debugprogressive");var G0=(s=>(s[s.Birth=0]="Birth",s[s.Collision=1]="Collision",s[s.Death=2]="Death",s[s.Trigger=3]="Trigger",s[s.Manual=4]="Manual",s))(G0||{});class os extends A{constructor(){super(...arguments),a(this,"renderMode"),a(this,"particleMaterial"),a(this,"trailMaterial"),a(this,"particleMesh"),a(this,"maxParticleSize"),a(this,"minParticleSize"),a(this,"velocityScale"),a(this,"cameraVelocityScale"),a(this,"lengthScale")}start(){if(this.maxParticleSize!==.5&&this.minParticleSize!==0&&F()){const t=`ParticleSystem "${this.name}" has non-default min/max particle size. This may not render correctly. Please set min size to 0 and the max size to 0.5 and use the "StartSize" setting instead`;console.warn(t)}}get transparent(){var t;return((t=this.particleMaterial)==null?void 0:t.transparent)??!1}getMaterial(t=!1){let i=t===!0&&this.trailMaterial?this.trailMaterial:this.particleMaterial;if(i){if(i.type==="MeshStandardMaterial"){Xo&&console.debug("ParticleSystemRenderer.getMaterial: MeshStandardMaterial detected, converting to MeshBasicMaterial. See https://github.com/Alchemist0823/three.quarks/issues/101"),"map"in i&&i.map&&(i.map.colorSpace=pr,i.map.premultiplyAlpha=!1);const n=new Me;n.copy(i),t?this.trailMaterial=n:this.particleMaterial=n}i.map&&(i.map.colorSpace=pr,i.map.premultiplyAlpha=!1),t&&i.side===ao&&(i=i.clone(),i.side=fm,t?this.trailMaterial=i:this.particleMaterial=i)}return i&&!jE&&i._didRequestTextureLOD===void 0&&(i._didRequestTextureLOD=0,LE&&console.log("Load material LOD",i.name),et.assignTextureLOD(i,0)),i}getMesh(t){let i=null;if(!i&&(this.particleMesh instanceof Q&&(i=this.particleMesh.geometry),i===null)){i=new Ds(1,1);const n=i.attributes.uv;for(let o=0;o<n.count;o++)n.setX(o,1-n.getX(o))}return new Q(i,this.getMaterial())}}Ye([m()],os.prototype,"renderMode",2),Ye([m(Oe)],os.prototype,"particleMaterial",2),Ye([m(Oe)],os.prototype,"trailMaterial",2),Ye([m()],os.prototype,"maxParticleSize",2),Ye([m()],os.prototype,"minParticleSize",2),Ye([m()],os.prototype,"velocityScale",2),Ye([m()],os.prototype,"cameraVelocityScale",2),Ye([m()],os.prototype,"lengthScale",2);class Ap{constructor(t,i=1){a(this,"_curve"),a(this,"_factor"),a(this,"type","function"),this._curve=t,this._factor=i}startGen(t){}genValue(t,i){return this._curve.evaluate(i,Math.random())*this._factor}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class X0{constructor(t){a(this,"type","value"),a(this,"system"),this.system=t}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}startGen(t){}}class DE extends X0{genValue(){return this.system.textureSheetAnimation.getStartIndex()}}class BE extends X0{constructor(){super(...arguments),a(this,"_lastPosition",new x),a(this,"_lastDistance",0)}update(){const t=ee(this.system.gameObject);this._lastDistance=this._lastPosition.distanceTo(t),this._lastPosition.copy(t)}genValue(){if(!this.system.isPlaying||!this.system.emission.enabled||this.system.currentParticles>=this.system.maxParticles)return 0;let t=this.system.emission.rateOverTime.evaluate(this.system.time/this.system.duration,Math.random());if(this.system.deltaTime>0){const o=this.system.emission.rateOverDistance.evaluate(this.system.time/this.system.duration,Math.random());let r=this._lastDistance/this.system.deltaTime*o;Number.isFinite(r)||(r=0),t+=r}const i=this.system.emission.getBurst();i>0&&(t+=i/this.system.deltaTime);const n=this.system.maxParticles-this.system.currentParticles;return W.clamp(t,0,n/this.system.deltaTime)}}class FE extends X0{genValue(){return this.system.isPlaying,0}}class Qo{constructor(t){a(this,"system"),a(this,"type"),this.type=Object.getPrototypeOf(this).constructor.name||"ParticleSystemBaseBehaviour",t&&(this.system=t)}get context(){return this.system.context}initialize(t){}update(t,i){}frameUpdate(t){}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}reset(){}}class zE extends Qo{constructor(){super(...arguments),a(this,"type","NeedleTextureSheet")}update(t,i){const n=this.system.textureSheetAnimation;if(n.enabled){const o=t.age/t.life,r=n.evaluate(o);r!==void 0&&(t.uvTile=r)}}}const s1=Symbol("particleRotation");class UE extends Qo{constructor(){super(...arguments),a(this,"type","NeedleRotation")}initialize(t){t[s1]=Math.random()}update(t,i){if(t.rotation===void 0)return;const n=t.age/t.life;if(typeof t.rotation=="number"&&(this.system.rotationOverLifetime.enabled?t.rotation+=this.system.rotationOverLifetime.evaluate(n,t[s1])*i:this.system.renderer.renderMode===$n.Billboard&&(t.rotation=Math.PI),this.system.rotationBySpeed.enabled)){const o=t.velocity.length();t.rotation+=this.system.rotationBySpeed.evaluate(n,o)*i}}}const n1=Symbol("sizeLerpFactor"),NE=new x;class WE extends Qo{constructor(){super(...arguments),a(this,"type","NeedleSize"),a(this,"_minSize",0),a(this,"_maxSize",1)}initialize(t){t[n1]=Math.random(),this._minSize=this.system.renderer.minParticleSize,this._maxSize=this.system.renderer.maxParticleSize}update(t,i){const n=t.age/t.life;let o=1;this.system.sizeOverLifetime.enabled&&(o*=this.system.sizeOverLifetime.evaluate(n,void 0,t[n1]).x);let r=1;this.system.renderer.renderMode!==$n.Mesh&&(r=this.system.worldScale.x/this.system.cameraScale);const l=$(t.startSize).multiplyScalar(o*r);if(t.size.set(l.x,l.y,l.z),this.system.localspace){const c=c1(this.system,NE);t.size.x*=c.x,t.size.y*=c.y,t.size.z*=c.z}}}const Ol=Symbol("particleLife"),Q0=Symbol("trailLifetime"),o1=Symbol("trailStartLength"),Y0=Symbol("trailWidthRandom");class VE extends Qo{constructor(){super(...arguments),a(this,"type","NeedleTrail")}initialize(t){t instanceof yv&&(t[Ol]=t.life,this.system.trails.enabled&&this.system.trails.dieWithParticles===!1&&(t[Q0]=this.system.trails.lifetime.evaluate(Math.random(),Math.random()),t.life+=t[Q0]),t[o1]=t.length,t[Y0]=Math.random())}update(t){var i;if((i=this.system.trails)!=null&&i.enabled&&t instanceof yv){const n=t,o=t.age/t[Ol],r=t.previous.values(),l=t.previous.length;for(let c=0;c<l;c++){const h=r.next().value,d=1-c/(l-1),u=t.size;if(u.x<=0&&!this.system.trails.sizeAffectsWidth){const p=20*this.system.trails.widthOverTrail.evaluate(.5,n[Y0]);u.x=p,u.y=p,u.z=p}h.size=this.system.trails.getWidth(u.x,o,d,n[Y0]),h.color.copy(t.color),this.system.trails.getColor(h.color,o,d)}if(t.age>t[Ol]){t.velocity.set(0,0,0);const c=(t.age-t[Ol])/t[Q0];n.length=W.lerp(t[o1],0,c)}}}}const Ip=Symbol("startVelocity"),r1=Symbol("gravityModifier"),K0=Symbol("gravitySpeed"),jp=Symbol("velocity lerp factor"),Z0=new x;class HE extends Qo{constructor(){super(...arguments),a(this,"type","NeedleVelocity"),a(this,"_gravityDirection",new x)}initialize(t){var i,n;const o=this.system.main.simulationSpeed;t.startSpeed=this.system.main.startSpeed.evaluate(Math.random(),Math.random());const r=this.system.shape.getDirection(t,t.position);t.velocity.x=r.x*t.startSpeed,t.velocity.y=r.y*t.startSpeed,t.velocity.z=r.z*t.startSpeed,(i=this.system.inheritVelocity)!=null&&i.enabled&&this.system.inheritVelocity.applyInitial(t.velocity),t[Ip]?t[Ip].copy(t.velocity):t[Ip]=t.velocity.clone();const l=this.system.main.gravityModifier.evaluate(Math.random(),Math.random());t[r1]=l*o,t[K0]=l*o*.5,t[jp]=Math.random(),(n=this.system.velocityOverLifetime)==null||n.init(t),this._gravityDirection.set(0,-1,0),this.system.main.simulationSpace===Sh.Local&&this._gravityDirection.applyQuaternion(this.system.worldQuaternionInverted).normalize()}update(t,i){var n;const o=t[Ip],r=t[r1];if(r!==0){const g=r*t[K0];Z0.copy(this._gravityDirection).multiplyScalar(g),t[K0]+=i*.05,o.add(Z0)}t.velocity.copy(o);const l=t.age/t.life;(n=this.system.inheritVelocity)!=null&&n.enabled&&this.system.inheritVelocity.applyCurrent(t.velocity,l,t[jp]);const c=this.system.noise;c.enabled&&c.apply(0,t.position,t.velocity,i,t.age,t.life);const h=this.system.sizeBySpeed;h!=null&&h.enabled&&(t.size=h.evaluate(t.velocity,l,t[jp],t.size));const d=this.system.colorBySpeed;d!=null&&d.enabled&&d.evaluate(t.velocity,t[jp],t.color);const u=this.system.velocityOverLifetime;u.enabled&&u.apply(t,0,t.position,t.velocity,i,t.age,t.life);const p=this.system.limitVelocityOverLifetime;if(p.enabled&&p.apply(t.position,o,t.velocity,t.size,l,i,1),this.system.worldspace){const g=this.system.worldScale;t.velocity.x*=g.x,t.velocity.y*=g.y,t.velocity.z*=g.z}}}const a1=Symbol("colorLerpFactor"),l1=new we(1,1,1,1),ta=new we(1,1,1,1);class $E extends Qo{constructor(){super(...arguments),a(this,"type","NeedleColor")}initialize(t){}_init(t){const i=this.system.renderer.particleMaterial;ta.copy(this.system.main.startColor.evaluate(Math.random())),i!=null&&i.color&&(l1.copy(i.color),ta.multiply(l1)),ta.convertLinearToSRGB(),t.startColor.set(ta.r,ta.g,ta.b,ta.alpha),t.color.copy(t.startColor),t[a1]=Math.random()}update(t,i){if(t.age===0&&this._init(t),this.system.colorOverLifetime.enabled){const n=t.age/t.life,o=this.system.colorOverLifetime.color.evaluate(n,t[a1]);t.color.set(o.r,o.g,o.b,"alpha"in o?o.alpha:1).multiply(t.startColor)}else t.color.copy(t.startColor)}}class qE{constructor(t){a(this,"system"),a(this,"emission"),a(this,"autoDestroy"),a(this,"startLength"),a(this,"emissionBursts"),a(this,"onlyUsedByOther"),a(this,"behaviors",[]),a(this,"rendererEmitterSettings",{startLength:new sO(220),followLocalOrigin:!1}),a(this,"flatWhiteTexture"),a(this,"clonedTexture",{original:void 0,clone:void 0}),this.system=t,this.emission=new BE(this.system)}get anim(){return this.system.textureSheetAnimation}get prewarm(){return!1}get material(){return this.system.renderer.getMaterial(this.system.trails.enabled)}get layers(){return this.system.gameObject.layers}update(){this.emission.update()}get looping(){return this.system.main.loop}get duration(){return this.system.duration}get shape(){return this.system.shape}get startLife(){return new Ap(this.system.main.startLifetime)}get startSpeed(){return new Ap(this.system.main.startSpeed)}get startRotation(){return new Ap(this.system.main.startRotation)}get startSize(){return new Ap(this.system.main.startSize)}get startColor(){return new tO(new iO(1,1,1,1))}get emissionOverTime(){return this.emission}get emissionOverDistance(){return new FE(this.system)}get instancingGeometry(){return this.system.renderer.getMesh(this.system.renderer.renderMode).geometry}get renderMode(){if(this.system.trails.enabled===!0)return wn.Trail;switch(this.system.renderer.renderMode){case $n.Billboard:return wn.BillBoard;case $n.Stretch:return wn.StretchedBillBoard;case $n.HorizontalBillboard:return wn.HorizontalBillBoard;case $n.VerticalBillboard:return wn.VerticalBillBoard;case $n.Mesh:return wn.Mesh}return wn.BillBoard}get speedFactor(){var t;let i=this.system.main.simulationSpeed;return((t=this.system.renderer)==null?void 0:t.renderMode)===$n.Stretch&&(i*=this.system.renderer.velocityScale??1),i}get texture(){const t=this.material;if(t&&t.map){const i=t.map;if(this.clonedTexture.original!==i||!this.clonedTexture.clone){const n=i.clone();n.premultiplyAlpha=!1,n.colorSpace=pr,this.clonedTexture.original=i,this.clonedTexture.clone=n}return this.clonedTexture.clone}return this.flatWhiteTexture||(this.flatWhiteTexture=Zg(new we(1,1,1,1),1)),this.flatWhiteTexture}get startTileIndex(){return new DE(this.system)}get uTileCount(){var t;return this.anim.enabled?(t=this.anim)==null?void 0:t.numTilesX:void 0}get vTileCount(){var t;return this.anim.enabled?(t=this.anim)==null?void 0:t.numTilesY:void 0}get renderOrder(){return 1}get blending(){var t;return((t=this.system.renderer.particleMaterial)==null?void 0:t.blending)??mC}get transparent(){return this.system.renderer.transparent}get worldSpace(){return this.system.main.simulationSpace===Sh.World}}class GE{constructor(){a(this,"burstParticleIndex",0),a(this,"burstParticleCount",0),a(this,"isBursting",!1),a(this,"travelDistance",0),a(this,"previousWorldPos"),a(this,"burstIndex",0),a(this,"burstWaveIndex",0),a(this,"time",0),a(this,"waitEmiting",0)}}const Lp=class extends A{constructor(){super(...arguments),a(this,"_state"),a(this,"colorOverLifetime"),a(this,"main"),a(this,"emission"),a(this,"sizeOverLifetime"),a(this,"shape"),a(this,"noise"),a(this,"trails"),a(this,"velocityOverLifetime"),a(this,"limitVelocityOverLifetime"),a(this,"inheritVelocity"),a(this,"colorBySpeed"),a(this,"textureSheetAnimation"),a(this,"rotationOverLifetime"),a(this,"rotationBySpeed"),a(this,"sizeBySpeed"),a(this,"_cameraScale",1),a(this,"__worldQuaternion",new V),a(this,"_worldQuaternionInverted",new V),a(this,"_worldScale",new x),a(this,"_worldPositionFrame",-1),a(this,"_worldPos",new x),a(this,"_renderer"),a(this,"_batchSystem"),a(this,"_particleSystem"),a(this,"_interface"),a(this,"_container"),a(this,"_time",0),a(this,"_isPlaying",!0),a(this,"_isUsedAsSubsystem",!1),a(this,"_didPreWarm",!1),a(this,"_bursts"),a(this,"_subEmitterSystems"),a(this,"_lastBatchesCount",-1)}play(s=!1){var t;s&&P.foreachComponent(this.gameObject,i=>{i instanceof Lp&&i!==this&&i.play(!1)},!0),this._isPlaying=!0,this._particleSystem&&(this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1),(t=this.emission)==null||t.reset()}pause(s=!0){s&&P.foreachComponent(this.gameObject,t=>{t instanceof Lp&&t!==this&&t.pause(!1)},!0),this._isPlaying=!1}stop(s=!0,t=!1){s&&P.foreachComponent(this.gameObject,i=>{i instanceof Lp&&i!==this&&i.stop(!1,t)},!0),this._isPlaying=!1,this._time=0,t&&this.reset()}reset(){var s;this._time=0,this._particleSystem&&(this._particleSystem.particleNum=0,this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1,(s=this.emission)==null||s.reset())}emit(s){if(this._particleSystem){this.onUpdate(),s=Math.min(s,this.maxParticles-this.currentParticles),this._state||(this._state=new GE),this._state.waitEmiting=s,this._state.time=0;const t=this._particleSystem.emitEnded;this._particleSystem.emitEnded=!1,this._particleSystem.emit(this.deltaTime,this._state,this._particleSystem.emitter.matrixWorld),this._particleSystem.emitEnded=t}}get playOnAwake(){return this.main.playOnAwake}set playOnAwake(s){this.main.playOnAwake=s}get renderer(){return this._renderer}get isPlaying(){return this._isPlaying}get currentParticles(){var s;return((s=this._particleSystem)==null?void 0:s.particleNum)??0}get maxParticles(){return this.main.maxParticles}get time(){return this._time}get duration(){return this.main.duration}get deltaTime(){return this.context.time.deltaTime*this.main.simulationSpeed}get scale(){return this.gameObject.scale.x}get cameraScale(){return this._cameraScale}get container(){return this._container}get worldspace(){return this.main.simulationSpace===Sh.World}get localspace(){return this.main.simulationSpace===Sh.Local}get worldQuaternion(){return this.__worldQuaternion}get worldQuaternionInverted(){return this._worldQuaternionInverted}get worldScale(){return this._worldScale}get worldPos(){return this._worldPositionFrame!==this.context.time.frame&&(this._worldPositionFrame=this.context.time.frame,ee(this.gameObject,this._worldPos)),this._worldPos}get matrixWorld(){return this._container.matrixWorld}get isSubsystem(){return this._isUsedAsSubsystem}addBehaviour(s){return this._particleSystem?(s instanceof Qo&&(s.system=this),(F()||Xo)&&console.debug("Add custom ParticleSystem Behaviour",s),this._particleSystem.addBehavior(s),!0):!1}removeBehaviour(s){if(!this._particleSystem)return!1;const t=this._particleSystem.behaviors,i=t.indexOf(s);return i!==-1&&((F()||Xo)&&console.debug("Remove custom ParticleSystem Behaviour",i,s),t.splice(i,1)),!0}removeAllBehaviours(){return this._particleSystem?(this._particleSystem.behaviors.length=0,!0):!1}get behaviours(){return this._particleSystem?this._particleSystem.behaviors:null}get particleSystem(){return this._particleSystem??null}set bursts(s){for(let t=0;t<s.length;t++){const i=s[t];if(!(i instanceof Oh)){const n=new Oh;La(n,i),s[t]=n}}this._bursts=s}set subEmitterSystems(s){for(let t=0;t<s.length;t++){const i=s[t];if(!(i instanceof Mh)){const n=new Mh;La(n,i),s[t]=n}}Xo&&s.length>0&&console.log("SubEmitters: ",s,this),this._subEmitterSystems=s}onAfterDeserialize(s){if(this._subEmitterSystems&&Array.isArray(this._subEmitterSystems))for(const t of this._subEmitterSystems)t._deserialize(this.context,this.gameObject)}awake(){if(this._worldPositionFrame=-1,this._renderer=this.gameObject.getComponent(os),!this.main)throw new Error("Not Supported: ParticleSystem needs a serialized MainModule. Creating new particle systems at runtime is currently not supported.");this._container=new j,this._container.matrixAutoUpdate=!1,this.context.scene.add(this._container),this._batchSystem=new JC,this._batchSystem.name=this.gameObject.name,this._container.add(this._batchSystem),this._interface=new qE(this),this._particleSystem=new eO(this._interface),this._particleSystem.addBehavior(new WE(this)),this._particleSystem.addBehavior(new $E(this)),this._particleSystem.addBehavior(new zE(this)),this._particleSystem.addBehavior(new UE(this)),this._particleSystem.addBehavior(new HE(this)),this._particleSystem.addBehavior(new VE(this)),this._batchSystem.addSystem(this._particleSystem);const s=this._particleSystem.emitter;this.context.scene.add(s),this.inheritVelocity.system&&this.inheritVelocity.system!==this&&(this.inheritVelocity=this.inheritVelocity.clone()),this.inheritVelocity.awake(this),Xo&&(console.log(this),this.gameObject.add(new bi(1)))}start(){this.addSubParticleSystems(),this.updateLayers(),this.renderer.particleMesh instanceof Q&&this._interface.renderMode==wn.Mesh&&et.assignMeshLOD(this.renderer.particleMesh,0).then(s=>{s&&this.particleSystem&&this._interface.renderMode==wn.Mesh&&(this.particleSystem.instancingGeometry=s)})}onDestroy(){var s,t,i,n;(s=this._container)==null||s.removeFromParent(),(t=this._batchSystem)==null||t.removeFromParent(),(i=this._particleSystem)==null||i.emitter.removeFromParent(),(n=this._particleSystem)==null||n.dispose()}onEnable(){this.main&&(this.inheritVelocity&&(this.inheritVelocity.system=this),this._batchSystem&&(this._batchSystem.visible=!0),this.playOnAwake&&this.play(),this._isPlaying=this.playOnAwake)}onDisable(){this._batchSystem&&(this._batchSystem.visible=!1)}onBeforeRender(){var s;this.main&&(this._didPreWarm===!1&&((s=this.main)==null?void 0:s.prewarm)===!0&&(this._didPreWarm=!0,this.preWarm()),this.onUpdate(),this.onSimulate(this.deltaTime))}preWarm(){var s;if(!((s=this.emission)!=null&&s.enabled)||this.emission.rateOverTime.getMax()<=0)return;const t=1/60,i=this.main.duration,n=this.main.startLifetime.getMax(),o=1e3,r=Math.min(Math.max(i,n)/Math.max(.01,this.main.simulationSpeed),o),l=Math.ceil(r/t),c=Date.now();Xo&&console.log(`Particles ${this.name} - Prewarm for ${l} frames (${r} sec). Duration: ${i}, Lifetime: ${n}`);for(let h=0;h<l&&!(this.currentParticles>=this.maxParticles);h++){const d=Date.now()-c;if(d>2e3){console.warn(`Particles ${this.name} - Prewarm took too long. Aborting: ${d}`);break}this.onUpdate(),this.onSimulate(t)}}onSimulate(s){if(this._batchSystem){let t=this.context.time.frameCount%60===0;this._lastBatchesCount!==this._batchSystem.batches.length&&(this._lastBatchesCount=this._batchSystem.batches.length,t=!0),t&&this.updateLayers(),this._batchSystem.update(s)}this._time+=s,this._time>this.duration&&(this._time=0)}updateLayers(){if(this._batchSystem)for(let s=0;s<this._batchSystem.batches.length;s++){const t=this._batchSystem.batches[s];t.layers.disableAll();const i=this.layer;t.layers.mask=1<<i}}onUpdate(){var s,t;if(this._bursts&&(this.emission.bursts=this._bursts,delete this._bursts),!this._isPlaying)return;const i=this.context.mainCamera;if(i){const r=Ke(i);this._cameraScale=r.x}const n=!this.worldspace,o=this.gameObject;if(Se(o,this.__worldQuaternion),this._worldQuaternionInverted.copy(this.__worldQuaternion).invert(),Ke(this.gameObject,this._worldScale),n&&this._container&&(s=this.gameObject)!=null&&s.parent){const r=c1(this,Z0);this._container.matrix.makeScale(r.x,r.y,r.z),this._container.matrix.makeRotationFromQuaternion(this.__worldQuaternion),this._container.matrix.setPosition(this.worldPos),this._container.matrix.scale(this.gameObject.scale)}this.emission.system=this,this._interface.update(),this.shape.onUpdate(this,this.context,this.main.simulationSpace,this.gameObject),this.noise.update(this.context),(t=this.inheritVelocity)==null||t.update(this.context),this.velocityOverLifetime.update(this)}addSubParticleSystems(){var s;if(this._subEmitterSystems&&this._particleSystem)for(const t of this._subEmitterSystems){t.particleSystem&&(t.particleSystem.__internalAwake?t.particleSystem.__internalAwake():F()&&console.warn("SubParticleSystem serialization issue(?)",t.particleSystem,t));const i=(s=t.particleSystem)==null?void 0:s._particleSystem;if(i){t.particleSystem._isUsedAsSubsystem=!0;const n=new Ep(this,this._particleSystem,t.particleSystem,i);n.emitterType=t.type,n.emitterProbability=t.emitProbability,this._particleSystem.addBehavior(n)}else Xo&&console.warn("Could not add SubParticleSystem",t,this)}}};let at=Lp;Ye([m(Ph)],at.prototype,"colorOverLifetime",2),Ye([m(jt)],at.prototype,"main",2),Ye([m(hn)],at.prototype,"emission",2),Ye([m(qo)],at.prototype,"sizeOverLifetime",2),Ye([m(Xe)],at.prototype,"shape",2),Ye([m(xe)],at.prototype,"noise",2),Ye([m(ze)],at.prototype,"trails",2),Ye([m(Qe)],at.prototype,"velocityOverLifetime",2),Ye([m(rt)],at.prototype,"limitVelocityOverLifetime",2),Ye([m(Go)],at.prototype,"inheritVelocity",2),Ye([m(ea)],at.prototype,"colorBySpeed",2),Ye([m(Lt)],at.prototype,"textureSheetAnimation",2),Ye([m(ns)],at.prototype,"rotationOverLifetime",2),Ye([m(Bi)],at.prototype,"rotationBySpeed",2),Ye([m(si)],at.prototype,"sizeBySpeed",2);class Mh{constructor(){a(this,"particleSystem"),a(this,"emitProbability",1),a(this,"properties"),a(this,"type")}_deserialize(t,i){const n=this.particleSystem;if(n instanceof at)return;let o="";n&&typeof n.guid=="string"&&(o=n.guid,this.particleSystem=P.findByGuid(o,i)),Xo&&!(this.particleSystem instanceof at)&&console.warn("Could not find particle system for sub emitter",o,i,this)}}function c1(s,t){if(t.set(1,1,1),s.gameObject.parent&&s.localspace)switch(s.main.scalingMode){case q0.Local:t=Ke(s.gameObject.parent,t),t.x=1/t.x,t.y=1/t.y,t.z=1/t.z;break;default:if(!s.unsupported_scaling_mode){s.unsupported_scaling_mode=!0;const i="ParticleSystem scale mode "+q0[s.main.scalingMode]+" is not supported";F()&&_e(i),console.warn(i,s.name,s)}t=Ke(s.gameObject,t);break}return t}class Ul extends A{constructor(){super(...arguments),a(this,"_didAssignPlayerColor",!1),a(this,"tryAssignColor",()=>{const t=P.getComponentInParent(this.gameObject,ji);if(t&&t.owner)return this._didAssignPlayerColor=!0,this.assignUserColor(t.owner),!0;const i=P.getComponentInParent(this.gameObject,Rt);return i!=null&&i.connectionId?(this._didAssignPlayerColor=!0,this.assignUserColor(i.connectionId),!0):!1})}onEnable(){this.context.connection.beginListen(ie.JoinedRoom,this.tryAssignColor),this._didAssignPlayerColor||this.startCoroutine(this.waitForConnection())}onDisable(){this.context.connection.stopListen(ie.JoinedRoom,this.tryAssignColor)}*waitForConnection(){for(;!this.destroyed&&this.activeAndEnabled&&(yield H_(.2),!this.tryAssignColor()););}assignUserColor(t){const i=Ul.hashCode(t),n=Ul.colorFromHashCode(i);if(this.gameObject.type==="Mesh"){const o=this.gameObject;this.assignColor(n,t,o)}else if(this.gameObject.children)for(const o of this.gameObject.children){const r=o;r.material&&r.material.color&&this.assignColor(n,t,r)}}assignColor(t,i,n){let o=n.material;o&&(o._playerMaterial!==i&&(o=o.clone(),o._playerMaterial=i,n.material=o),o.color=t)}static hashCode(t){var i=0,n,o;if(t.length===0)return i;for(n=0;n<t.length;n++)o=t.charCodeAt(n),i=(i<<5)-i+o,i|=0;return i}static colorFromHashCode(t){const i=(t&16711680)>>16,n=(t&65280)>>8,o=t&255;return new ae(i/255,n/255,o/255)}}const XE=O("debugpost");let J0=null;function QE(s){J0=s}function h1(s){let t=s.gameObject;for(;t;){for(const i of eu(t))if(i.isPostProcessingManager===!0)return i;t=t.parent}return null}function YE(s){let t=h1(s);if(!t)if(J0){XE&&console.warn("Adding postprocessing manager to the scene.");const i=s.scene;t=ki(i,J0)}else F()&&console.warn("No post processing manager found");return t}var KE=Object.defineProperty,ZE=Object.getOwnPropertyDescriptor,d1=(s,t,i,n)=>{for(var o=n>1?void 0:n?ZE(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&KE(t,i,o),o};const JE=O("debugpost");class N{constructor(t){a(this,"isVolumeParameter",!0),a(this,"_isInitialized",!1),a(this,"_active",!0),a(this,"_value"),a(this,"_valueRaw"),a(this,"_defaultValue"),a(this,"valueProcessor"),a(this,"onValueChanged"),t!==void 0&&this.initialize(t)}get isInitialized(){return this._isInitialized}initialize(t){t!==void 0&&(this._value=t,this._defaultValue=t,this._valueRaw=t,this._isInitialized=!0)}get overrideState(){return this._active}set overrideState(t){if(this._active===t)return;this._active=t;const i=t?this._valueRaw:this._defaultValue;this.processValue(i,!0)}get value(){return this._valueRaw}set value(t){this.isInitialized||this.initialize(t),this.processValue(t,!1)}set defaultValue(t){this._defaultValue=t}__init(){this.processValue(this._valueRaw,!0)}processValue(t,i){if(t==null||!i&&this.testIfValueChanged(t)===!1)return;const n=this._value;JE&&typeof n=="number"&&typeof t=="number"&&(n?.toFixed(4),t?.toFixed(4)),!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,t=this._defaultValue,this._valueRaw=t):(this._valueRaw=t,this._active&&this.valueProcessor&&(t=this.valueProcessor(t)),this._value=t),this.onValueChanged&&this.onValueChanged(t,n,this)}testIfValueChanged(t){return this._valueRaw!==t}}d1([m()],N.prototype,"overrideState",1),d1([m()],N.prototype,"value",1);class eA extends Ki{constructor(){super([N])}onSerialize(t,i){}onDeserialize(t,i){const n=i.target,o=i.path;let r;if(n&&o&&(r=n[o]),(typeof r!="object"||typeof r=="object"&&r.isVolumeParameter!==!0)&&(r=new N),typeof t=="object"&&"value"in t){const l=t.value;r.initialize(l),r.overrideState=t.overrideState}else r.value=t;return r}}new eA;var tA=Object.defineProperty,iA=Object.getOwnPropertyDescriptor,sA=(s,t,i,n)=>{for(var o=n>1?void 0:n?iA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&tA(t,i,o),o};const nA=O("debugpost");class lt extends A{constructor(t=void 0){if(super(),a(this,"active",!0),a(this,"_manager",null),a(this,"_result"),a(this,"_postprocessingContext",null),t)for(const i of Object.keys(t)){const n=t[i],o=this[i];o instanceof N?o.initialize(n):o!==void 0&&(this[i]=n)}}get isPostProcessingEffect(){return!0}onEnable(){super.onEnable(),this.onEffectEnabled(),this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){var t;super.onDisable(),(t=this._manager)==null||t.removeEffect(this),this.active=!1}onEffectEnabled(t){var i;t&&t.isPostProcessingManager===!0?this._manager=t:this._manager||(this._manager=YE(this)),(i=this._manager)==null||i.addEffect(this)}init(){}get postprocessingContext(){return this._postprocessingContext}apply(t){var i;return this._postprocessingContext=t,this._result||(this.initParameters(),this._result=(i=this.onCreateEffect)==null?void 0:i.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){nA&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(t=>t.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const t=Object.keys(this);for(const i of t){const n=this[i];n instanceof N&&n.__init()}}onEditorModification(t){const i=t.propertyName;if(this[i]instanceof N){const n=t.value;return this[i].value=n,!0}}}sA([m()],lt.prototype,"active",2);var oA=Object.defineProperty,rA=Object.getOwnPropertyDescriptor,aA=(s,t,i,n)=>{for(var o=n>1?void 0:n?rA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&oA(t,i,o),o};const lA=O("debugpost"),ey={};function rs(s,t){ey[s]=t}function cA(s){return s.__type in ey?ey[s.__type]:(lA&&s.__type&&console.warn("Unknown postprocessing type",s.__type,s),lt)}class Rh{constructor(){a(this,"components",[])}init(){var t;(t=this.components)==null||t.forEach(i=>i.init())}addEffect(t){this.components.push(t)}removeEffect(t){const i=this.components.indexOf(t);i>=0&&this.components.splice(i,1)}}aA([Ha([s=>cA(s),lt])],Rh.prototype,"components",2);var hA=Object.defineProperty,dA=Object.getOwnPropertyDescriptor,uA=(s,t,i,n)=>{for(var o=n>1?void 0:n?dA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&hA(t,i,o),o};class Th extends lt{constructor(){super(...arguments),a(this,"preset",new N(2))}get typeName(){return"Antialiasing"}onCreateEffect(){const t=new D.POSTPROCESSING.MODULE.SMAAEffect({preset:D.POSTPROCESSING.MODULE.SMAAPreset.HIGH,edgeDetectionMode:D.POSTPROCESSING.MODULE.EdgeDetectionMode.DEPTH});return this.preset.onValueChanged=i=>{t.applyPreset(i)},t}}uA([m(N)],Th.prototype,"preset",2),rs("Antialiasing",Th);var pA=Object.defineProperty,mA=Object.getOwnPropertyDescriptor,ty=(s,t,i,n)=>{for(var o=n>1?void 0:n?mA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&pA(t,i,o),o},iy;const u1=(iy=class extends lt{constructor(){super(...arguments),a(this,"threshold",new N(.9)),a(this,"intensity",new N(1)),a(this,"scatter",new N(.3)),a(this,"selectiveBloom")}get typeName(){return"Bloom"}init(){this.threshold.valueProcessor=s=>s,this.intensity.valueProcessor=s=>s,this.scatter.valueProcessor=s=>s}onCreateEffect(){let s;if(this.selectiveBloom==null&&(this.selectiveBloom=u1.useSelectiveBloom),this.selectiveBloom){const t=s=new D.POSTPROCESSING.MODULE.SelectiveBloomEffect(this.context.scene,this.context.mainCamera,{blendFunction:D.POSTPROCESSING.MODULE.BlendFunction.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,radius:.85,intensity:this.intensity.value});t.inverted=!0}else s=new D.POSTPROCESSING.MODULE.BloomEffect({blendFunction:D.POSTPROCESSING.MODULE.BlendFunction.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,radius:.85,intensity:this.intensity.value});return this.intensity.onValueChanged=t=>{s.intensity=t},this.threshold.onValueChanged=t=>{s.luminanceMaterial.threshold=Math.pow(t,2.2)},this.scatter.onValueChanged=t=>{s.luminancePass.enabled=!0,s.luminanceMaterial.smoothing=t,s.mipmapBlurPass&&(s.mipmapBlurPass.radius=vn.lerp(.1,.9,t))},s}},a(iy,"useSelectiveBloom",!1),iy);let ia=u1;ty([m(N)],ia.prototype,"threshold",2),ty([m(N)],ia.prototype,"intensity",2),ty([m(N)],ia.prototype,"scatter",2),rs("Bloom",ia);var gA=Object.defineProperty,fA=Object.getOwnPropertyDescriptor,yA=(s,t,i,n)=>{for(var o=n>1?void 0:n?fA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&gA(t,i,o),o};class Eh extends lt{constructor(){super(...arguments),a(this,"intensity",new N(0))}get typeName(){return"ChromaticAberration"}onCreateEffect(){const t=new D.POSTPROCESSING.MODULE.ChromaticAberrationEffect;return t.offset=new oe(0,0),t.radialModulation=!0,t.modulationOffset=.15,this.intensity.valueProcessor=i=>i*.02,this.intensity.onValueChanged=i=>{t.offset.x=-i,t.offset.y=i},t}}yA([m(N)],Eh.prototype,"intensity",2),rs("ChromaticAberration",Eh);var vA=Object.defineProperty,bA=Object.getOwnPropertyDescriptor,p1=(s,t,i,n)=>{for(var o=n>1?void 0:n?bA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&vA(t,i,o),o};const m1=O("debugpost");var Dp=(s=>(s[s.None=0]="None",s[s.Neutral=1]="Neutral",s[s.ACES=2]="ACES",s[s.AgX=3]="AgX",s[s.KhronosNeutral=4]="KhronosNeutral",s))(Dp||{});function sy(s){switch(s){case 0:return ud;case 1:return bm;case 2:return vm;case 3:return dd;case 4:return $l;default:return $l}}function _A(s){switch(s){case ud:return 0;case vm:return 2;case dd:return 3;case $l:return 1;case bm:return 1;default:return 0}}function g1(s){switch(s){case ud:return D.POSTPROCESSING.MODULE.ToneMappingMode.LINEAR;case vm:return D.POSTPROCESSING.MODULE.ToneMappingMode.ACES_FILMIC;case dd:return D.POSTPROCESSING.MODULE.ToneMappingMode.AGX;case $l:return D.POSTPROCESSING.MODULE.ToneMappingMode.NEUTRAL;case bm:return D.POSTPROCESSING.MODULE.ToneMappingMode.REINHARD;default:return D.POSTPROCESSING.MODULE.ToneMappingMode.LINEAR}}const f1=class extends lt{constructor(){super(...arguments),a(this,"mode",new N(void 0)),a(this,"exposure",new N(1))}get typeName(){return"ToneMapping"}setMode(s){const t=Dp[s];return t===void 0?(console.error("Invalid ToneMapping mode",s),this):(this.mode.value=t,this)}get isToneMapping(){return!0}onEffectEnabled(){const s=h1(this);s&&super.onEffectEnabled(s)}onCreateEffect(){if(this.postprocessingContext)for(const i of this.postprocessingContext.components){if(i===this)break;if(i!=this&&i instanceof f1){console.warn("Multiple tonemapping effects found in the same postprocessing stack: Please check your scene setup.",{activeEffect:i,ignoredEffect:this});return}}if(this.mode.isInitialized==!1){const i=_A(this.context.renderer.toneMapping);this.mode.initialize(i)}const s=sy(this.mode.value),t=new D.POSTPROCESSING.MODULE.ToneMappingEffect({mode:g1(s)});return this.mode.onValueChanged=i=>{const n=sy(i);t.mode=g1(n),m1&&console.log("ToneMapping mode changed to",Dp[i],n,t.mode)},m1&&console.log("Use ToneMapping",Dp[this.mode.value],s,t.mode,"renderer.tonemapping: "+this.context.renderer.toneMapping),this.exposure.onValueChanged=i=>{this.context.renderer.toneMappingExposure=i},t}onBeforeRender(){this.mode.overrideState&&(this.context.renderer.toneMapping=sy(this.mode.value)),this.exposure.overrideState&&(this.context.renderer.toneMappingExposure=this.exposure.value)}};let Yo=f1;p1([m(N)],Yo.prototype,"mode",2),p1([m(N)],Yo.prototype,"exposure",2),rs("Tonemapping",Yo);var wA=Object.defineProperty,xA=Object.getOwnPropertyDescriptor,Bp=(s,t,i,n)=>{for(var o=n>1?void 0:n?xA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&wA(t,i,o),o};class Ko extends lt{constructor(){super(...arguments),a(this,"postExposure",new N(0)),a(this,"contrast",new N(0)),a(this,"hueShift",new N(0)),a(this,"saturation",new N(0))}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=t=>(t=Math.pow(2,t),t),this.contrast.valueProcessor=t=>{let i=1;return t>0?i=200:t<0&&(i=100),t/i},this.contrast.defaultValue=0,this.hueShift.valueProcessor=t=>Math.PI*t/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=t=>t<0?t/100:t/(100*Math.PI),this.saturation.defaultValue=0}onCreateEffect(){var t,i;const n=[];this.context.renderer.toneMapping!==_a&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=_a);let o=(t=this.postprocessingContext)==null?void 0:t.components.find(c=>c instanceof Yo);o||(o=new Yo,(i=this.postprocessingContext)==null||i.components.push(o)),this.postExposure.onValueChanged=c=>{this.postExposure.overrideState&&(o.exposure.value=c)};const r=new D.POSTPROCESSING.MODULE.BrightnessContrastEffect;this.contrast.onValueChanged=c=>r.contrast=c;const l=new D.POSTPROCESSING.MODULE.HueSaturationEffect;return n.push(r),n.push(l),this.hueShift.onValueChanged=c=>l.hue=c,this.saturation.onValueChanged=c=>l.saturation=c,n}}Bp([m(N)],Ko.prototype,"postExposure",2),Bp([m(N)],Ko.prototype,"contrast",2),Bp([m(N)],Ko.prototype,"hueShift",2),Bp([m(N)],Ko.prototype,"saturation",2),rs("ColorAdjustments",Ko);var SA=Object.defineProperty,CA=Object.getOwnPropertyDescriptor,sa=(s,t,i,n)=>{for(var o=n>1?void 0:n?CA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&SA(t,i,o),o};const OA=O("debugpost");class Ts extends lt{constructor(){super(...arguments),a(this,"mode"),a(this,"focusDistance",new N(1)),a(this,"focalLength",new N(.2)),a(this,"aperture",new N(20)),a(this,"gaussianMaxRadius",new N),a(this,"resolutionScale",new N(1*1/window.devicePixelRatio)),a(this,"bokehScale",new N)}get typeName(){return"DepthOfField"}init(){this.focalLength.valueProcessor=i=>{const n=i/300,o=2;return W.lerp(o,.01,n)};const t=20;this.aperture.valueProcessor=i=>{const n=1-i/32;return W.lerp(1,t,n)}}onCreateEffect(){if(this.mode===0){OA&&console.warn("DepthOfField: Mode is set to Off");return}const t=new D.POSTPROCESSING.MODULE.DepthOfFieldEffect(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=i=>{t.cocMaterial.worldFocusDistance=i},this.focalLength.onValueChanged=i=>t.cocMaterial.worldFocusRange=i,this.aperture.onValueChanged=i=>t.bokehScale=i,this.resolutionScale&&(this.resolutionScale.onValueChanged=i=>t.resolution.scale=i),[t]}unapply(){}}sa([m()],Ts.prototype,"mode",2),sa([m(N)],Ts.prototype,"focusDistance",2),sa([m(N)],Ts.prototype,"focalLength",2),sa([m(N)],Ts.prototype,"aperture",2),sa([m(N)],Ts.prototype,"gaussianMaxRadius",2),sa([m(N)],Ts.prototype,"resolutionScale",2),sa([m(N)],Ts.prototype,"bokehScale",2),rs("DepthOfField",Ts);class Ah extends lt{constructor(t){super(),a(this,"effect"),this.effect=t}get typeName(){return this.effect.constructor.name}onCreateEffect(){return this.effect}}var PA=Object.defineProperty,kA=Object.getOwnPropertyDescriptor,MA=(s,t,i,n)=>{for(var o=n>1?void 0:n?kA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&PA(t,i,o),o};class Ih extends lt{constructor(){super(...arguments),a(this,"granularity",new N(10))}get typeName(){return"PixelationEffect"}onCreateEffect(){const t=new D.POSTPROCESSING.MODULE.PixelationEffect;return this.granularity.onValueChanged=i=>{t.granularity=i},t}}MA([m(N)],Ih.prototype,"granularity",2),rs("PixelationEffect",Ih);var RA=Object.defineProperty,TA=Object.getOwnPropertyDescriptor,jh=(s,t,i,n)=>{for(var o=n>1?void 0:n?TA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&RA(t,i,o),o};class qn extends lt{constructor(){super(...arguments),a(this,"intensity",new N(2)),a(this,"falloff",new N(1)),a(this,"samples",new N(9)),a(this,"color",new N(new ae(0,0,0))),a(this,"luminanceInfluence",new N(.7)),a(this,"_ssao")}get typeName(){return"ScreenSpaceAmbientOcclusion"}onBeforeRender(){if(this._ssao&&this.context.mainCamera instanceof be){const t=this.context.mainCamera.far-this.context.mainCamera.near;this._ssao.ssaoMaterial.worldDistanceFalloff=t*.01,this._ssao.ssaoMaterial.worldDistanceThreshold=this.context.mainCamera.far}}onCreateEffect(){const t=this.context.mainCamera,i=new D.POSTPROCESSING.MODULE.NormalPass(this.context.scene,t),n=new D.POSTPROCESSING.MODULE.DepthDownsamplingPass({normalBuffer:i.texture,resolutionScale:.5}),o=this._ssao=new D.POSTPROCESSING.MODULE.SSAOEffect(t,i.texture,{normalDepthBuffer:n.texture,worldDistanceThreshold:1,worldDistanceFalloff:1,worldProximityThreshold:.1,worldProximityFalloff:2,intensity:1,blendFunction:D.POSTPROCESSING.MODULE.BlendFunction.MULTIPLY,luminanceInfluence:.5});this.intensity.onValueChanged=l=>{o.intensity=l},this.falloff.onValueChanged=l=>{o.ssaoMaterial.radius=l*.1},this.samples.onValueChanged=l=>{o.ssaoMaterial.samples=l},this.color.onValueChanged=l=>{o.color||(o.color=new ae),o.color.copy(l)},this.luminanceInfluence.onValueChanged=l=>{o.luminanceInfluence=l};const r=new Array;return r.push(i),r.push(n),r.push(o),r}}jh([m(N)],qn.prototype,"intensity",2),jh([m(N)],qn.prototype,"falloff",2),jh([m(N)],qn.prototype,"samples",2),jh([m(N)],qn.prototype,"color",2),jh([m(N)],qn.prototype,"luminanceInfluence",2),rs("ScreenSpaceAmbientOcclusion",qn);var EA=Object.defineProperty,AA=Object.getOwnPropertyDescriptor,na=(s,t,i,n)=>{for(var o=n>1?void 0:n?AA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&EA(t,i,o),o},ny=(s=>(s[s.Performance=0]="Performance",s[s.Low=1]="Low",s[s.Medium=2]="Medium",s[s.High=3]="High",s[s.Ultra=4]="Ultra",s))(ny||{});class Es extends lt{constructor(){super(...arguments),a(this,"gammaCorrection",!0),a(this,"aoRadius",new N(1)),a(this,"falloff",new N(1)),a(this,"intensity",new N(1)),a(this,"color",new N(new ae(0,0,0))),a(this,"screenspaceRadius",!1),a(this,"quality",2),a(this,"_ssao")}get typeName(){return"ScreenSpaceAmbientOcclusionN8"}onValidate(){this._ssao&&(this._ssao.setQualityMode(ny[this.quality]),this._ssao.configuration.gammaCorrection=this.gammaCorrection,this._ssao.configuration.screenSpaceRadius=this.screenspaceRadius)}onCreateEffect(){const t=this.context.mainCamera,i=this._ssao=new D.POSTPROCESSING_AO.MODULE.N8AOPostPass(this.context.scene,t,this.context.domWidth,this.context.domHeight),n=ny[this.quality];i.setQualityMode(n),i.configuration.gammaCorrection=this.gammaCorrection,i.configuration.screenSpaceRadius=this.screenspaceRadius,this.intensity.onValueChanged=r=>{i.configuration.intensity=r},this.falloff.onValueChanged=r=>{i.configuration.distanceFalloff=r},this.aoRadius.onValueChanged=r=>{i.configuration.aoRadius=r},this.color.onValueChanged=r=>{i.color||(i.color=new ae),i.configuration.color.copy(r)};const o=new Array;return o.push(i),o}}na([Mt(),m()],Es.prototype,"gammaCorrection",2),na([m(N)],Es.prototype,"aoRadius",2),na([m(N)],Es.prototype,"falloff",2),na([m(N)],Es.prototype,"intensity",2),na([m(N)],Es.prototype,"color",2),na([Mt(),m()],Es.prototype,"screenspaceRadius",2),na([Mt(),m()],Es.prototype,"quality",2),rs("ScreenSpaceAmbientOcclusionN8",Es);var IA=Object.defineProperty,jA=Object.getOwnPropertyDescriptor,y1=(s,t,i,n)=>{for(var o=n>1?void 0:n?jA(t,i):t,r=s.length-1,l;r>=0;r--)(l=s[r])&&(o=(n?l(t,i,o):l(o))||o);return n&&o&&IA(t,i,o),o};class Lh extends lt{constructor(){super(...arguments),a(this,"_effect"),a(this,"_amount",1),a(this,"_radius",1)}get typeName(){return"Sharpening"}onCreateEffect(){return this._effect??(this._effect=new(LA())),this.effect}get effect(){return this._effect}set amount(t){this._amount=t,this._effect&&(this._effect.uniforms.get("amount").value=t)}get amount(){return this._effect?this._effect.uniforms.get("amount").value:this._amount}set radius(t){this._radius=t,this._effect&&(this._effect.uniforms.get("radius").value=t)}get radius(){return this._effect?this._effect.uniforms.get("radius").value:this._radius}}y1([m()],Lh.prototype,"amount",1),y1([m()],Lh.prototype,"radius",1);function LA(){const s=`
|
|
1202
1202
|
void mainSupport() {
|
|
1203
1203
|
vUv = uv;
|
|
1204
1204
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|