@needle-tools/engine 4.0.2-alpha → 4.0.2-alpha.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.
@@ -4345,7 +4345,7 @@ Open this page to get the console: `+A.toString())}const g=exports.DeviceUtiliti
4345
4345
  #__vconsole .vc-mask {
4346
4346
  overflow: hidden;
4347
4347
  }
4348
- `,Ds==null||Ds.prepend(t),g===!0&&qv()<=0&&GV(),console.log("🌵 Debug console has loaded")}},A.onerror=()=>{console.warn("🌵 Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),ip=!1,yI=null},A.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(A)}function EnA(){if(!globalThis.VConsole)return;const g=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),A=()=>document.querySelector("#__vc_plug_"+g._id+" iframe");return g.on("renderTab",function(e){const t=globalThis["needle:codegen_files"];if(!t||t.length===0)return;let i=globalThis["needle:codegen_files"][0];const o=i.indexOf("?");o>-1&&(i=i.substring(0,o));const s=location.protocol+"//"+location.host+location.pathname+"/"+i,n=encodeURIComponent(s);g.fullUrl="https://viewer.needle.tools?inspect&file="+n;var a='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';e(a)}),g.on("show",function(){const e=A();e&&e.src!==g.fullUrl&&(e.src=g.fullUrl)}),g.on("hide",function(){const e=A();e&&(e.src="")}),g.on("addTopBar",function(e){var t=new Array;t.push({name:"Open in new window ↗",onClick:function(i){window.open(g.fullUrl,"_blank"),yI==null||yI.hide()}}),t.push({name:"Reload",onClick:function(i){const o=A();o&&(o.src=g.fullUrl)}}),t.push({name:"Fullscreen",onClick:function(i){const o=A();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),e(t)}),g}function dnA(){const g=document.querySelector("#__vconsole .vc-switch");return g||null}function unA(){const g=document.querySelector("#__vconsole");return g||null}const RV=gA("debugdefines");Rc('if(!globalThis[""4.0.2-alpha""]) globalThis[""4.0.2-alpha""] = "0.0.0";');Rc('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');Rc('if(!globalThis[""Thu Dec 12 2024 16:46:09 GMT+0100 (Central European Standard Time)""]) globalThis[""Thu Dec 12 2024 16:46:09 GMT+0100 (Central European Standard Time)""] = "unknown";');Rc('if(!globalThis[""npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9""]) globalThis[""npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9""] = "unknown";');Rc('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.0.2-alpha";');Rc('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');Rc('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Thu Dec 12 2024 16:46:09 GMT+0100 (Central European Standard Time)";');Rc('globalThis["__NEEDLE_PUBLIC_KEY__"] = "npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9";');const oa="4.0.2-alpha",FM="undefined",fL="Thu Dec 12 2024 16:46:09 GMT+0100 (Central European Standard Time)";RV&&console.log(`Engine version: ${oa} (generator: ${FM})
4348
+ `,Ds==null||Ds.prepend(t),g===!0&&qv()<=0&&GV(),console.log("🌵 Debug console has loaded")}},A.onerror=()=>{console.warn("🌵 Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),ip=!1,yI=null},A.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(A)}function EnA(){if(!globalThis.VConsole)return;const g=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),A=()=>document.querySelector("#__vc_plug_"+g._id+" iframe");return g.on("renderTab",function(e){const t=globalThis["needle:codegen_files"];if(!t||t.length===0)return;let i=globalThis["needle:codegen_files"][0];const o=i.indexOf("?");o>-1&&(i=i.substring(0,o));const s=location.protocol+"//"+location.host+location.pathname+"/"+i,n=encodeURIComponent(s);g.fullUrl="https://viewer.needle.tools?inspect&file="+n;var a='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';e(a)}),g.on("show",function(){const e=A();e&&e.src!==g.fullUrl&&(e.src=g.fullUrl)}),g.on("hide",function(){const e=A();e&&(e.src="")}),g.on("addTopBar",function(e){var t=new Array;t.push({name:"Open in new window ↗",onClick:function(i){window.open(g.fullUrl,"_blank"),yI==null||yI.hide()}}),t.push({name:"Reload",onClick:function(i){const o=A();o&&(o.src=g.fullUrl)}}),t.push({name:"Fullscreen",onClick:function(i){const o=A();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),e(t)}),g}function dnA(){const g=document.querySelector("#__vconsole .vc-switch");return g||null}function unA(){const g=document.querySelector("#__vconsole");return g||null}const RV=gA("debugdefines");Rc('if(!globalThis[""4.0.2-alpha.1""]) globalThis[""4.0.2-alpha.1""] = "0.0.0";');Rc('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');Rc('if(!globalThis[""Thu Dec 12 2024 16:54:42 GMT+0100 (Central European Standard Time)""]) globalThis[""Thu Dec 12 2024 16:54:42 GMT+0100 (Central European Standard Time)""] = "unknown";');Rc('if(!globalThis[""npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9""]) globalThis[""npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9""] = "unknown";');Rc('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.0.2-alpha.1";');Rc('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');Rc('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Thu Dec 12 2024 16:54:42 GMT+0100 (Central European Standard Time)";');Rc('globalThis["__NEEDLE_PUBLIC_KEY__"] = "npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9";');const oa="4.0.2-alpha.1",FM="undefined",fL="Thu Dec 12 2024 16:54:42 GMT+0100 (Central European Standard Time)";RV&&console.log(`Engine version: ${oa} (generator: ${FM})
4349
4349
  Project built at ${fL}`);const vf="npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9",mC="needle_isActiveInHierarchy",vl="builtin_components",Lf="needle_editor_guid";function Rc(g){try{(0,eval)(g)}catch(A){RV&&console.error(A)}}const pnA='<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>',fnA=btoa(pnA),DnA="data:image/svg+xml;base64,"+fnA,ynA=DnA,wnA=`<?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(wnA);const mnA='<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>',SnA=btoa(mnA),GnA="data:image/svg+xml;charset=utf-8;base64,"+SnA,knA=GnA;/**
4350
4350
  * postprocessing v6.36.2 build Tue Sep 10 2024
4351
4351
  * https://github.com/pmndrs/postprocessing
@@ -5953,7 +5953,7 @@ ${e.path}! : AssetReference;
5953
5953
  Could not find method ${a.method} on object ${C.name}. Please rename ${a.method} to ${d}?
5954
5954
  `,C[d],`
5955
5955
  in script: `,C),Pt("EventList methods must start with lowercase letter, see console for details");return}else console.warn(`EventList method:
5956
- Could not find method ${a.method} on object ${C.name}`,C,typeof C[a.method])};if(typeof C[a.method]!="function"){let d=!1,h=C;for(;h;){const E=Object.getOwnPropertyDescriptor(h,a.method);if(E&&(E.writable===!0||E.set)){d=!0;break}h=Object.getPrototypeOf(h)}!d&&(VA()||io)&&l()}}if(C){let l=a.argument;if(l!==void 0?l=r(l):a.arguments!==void 0&&(l=a.arguments.map(r)),!C[a.method])console.warn(`EventList method not found: "${a.method}" on ${C==null?void 0:C.name}`);else{l!==void 0&&!Array.isArray(l)&&(l=[l]);const d=new Oa(C,a.method,l,a.enabled);I.push(d)}}else VA()&&console.warn("[Debug] EventList: Could not find event listener in scene",a,e.object,A)}const s=new ti(I);io&&console.log(s);const n=e.target;return n!==void 0&&e.path!==void 0&&s.setEventTarget(e.path,n),s}}}const huA=new QuA,ak=new WeakMap,EuA=Pe.prototype.clone;Pe.prototype.clone=function(){const g=EuA.call(this);return ak.has(g)||ak.set(g,this),g};class fj extends Sn{constructor(){super([Ic,et])}onSerialize(A,e){}onDeserialize(A,e){if(A instanceof Pe&&e.type===Ic){let t=A;ak.has(t)&&(t=ak.get(t)),t.isRenderTargetTexture=!0,t.flipY=!0,t.offset.y=1,t.repeat.y=-1,t.needsUpdate=!0,t.mipmaps=[],t instanceof $B&&(t.isCompressedTexture=!1,t.format=Ut);const i=new Ic(t.image.width,t.image.height,{colorSpace:Zt});return i.texture=t,i}}}new fj;class Dj extends Sn{constructor(){super([URL])}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"&&A.length>0)return Mc(e.gltfId,A)}}new Dj;var duA=Object.defineProperty,uuA=Object.getOwnPropertyDescriptor,puA=(g,A,e,t)=>{for(var i=t>1?void 0:t?uuA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&duA(A,e,i),i};class gw extends NA{awake(){VI.createIfNoneExists(this.context)}onEnable(){var A;(A=VI.get(this.context))==null||A.register(this)}onDisable(){var A;(A=VI.get(this.context))==null||A.unregister(this)}}class Ts extends gw{constructor(){super(...arguments);c(this,"targets",null);c(this,"raycastHits",[]);c(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(e=null){if(!this.targets)return null;e??(e=new Cr),e.targets=this.targets,e.results=this.raycastHits,e.useAcceleratedRaycast=!0;const t=e.testObject;this.ignoreSkinnedMeshes&&(e.testObject=o=>o instanceof jI?"continue in children":t?t(o):!0);const i=this.context.physics.raycast(e);return e.testObject=t,i}}puA([G()],Ts.prototype,"ignoreSkinnedMeshes",2);class IR extends Ts{constructor(){super(),this.ignoreSkinnedMeshes=!0}}const U_=class extends gw{performRaycast(A){if(!ke.active||!U_.allow||!(A!=null&&A.ray))return null;const e=A.ray.origin,t=.015;return this.context.physics.sphereOverlap(e,t,!1,!0)}};let sc=U_;c(sc,"allow",!0);class sR{static getObject(A){const e=A[hn];return e&&(e.isComponent===!0?A=e.gameObject:A=e),A}static isInteractable(A,e){if(e&&(e.canvasGroup=void 0,e.graphic=void 0),A==null||!A.visible||(A=this.getObject(A),!A.visible))return!1;const t=this.tryFindCanvasGroup(A);if((t==null?void 0:t.isCanvasGroup)===!0&&(e&&(e.canvasGroup=t),t.blocksRaycasts===!1||t.interactable===!1))return!1;const i=RQ(A,o=>{if(o.isGraphic===!0)return o},!1);return e&&(i==null?void 0:i.isGraphic)===!0&&(e.graphic=i),!((i==null?void 0:i.raycastTarget)===!1||(i==null?void 0:i.layer)===2)}static tryFindCanvasGroup(A){if(!A)return null;const e=RQ(A,t=>{const i=t;if(i.blocksRaycasts!==void 0&&i.interactable!==void 0)return i},!1);return e!==void 0?e:this.tryFindCanvasGroup(A.parent)}}function Mq(g){const A=g[hn];return A||(g.parent?Mq(g.parent):null)}function fuA(g){return g.isUI===!0||typeof g[hn]=="object"}function rk(g,A){if(!g)return;const e=g.material;if((e==null?void 0:e.isMaterial)===!0){const t=g.parent;t&&t.isText,e.side=A.doubleSided??!0?St:lg,e.shadowSide=A.doubleSided?St:lg,g.castShadow=A.castShadows?A.castShadows:!1,g.receiveShadow=A.receiveShadows?A.receiveShadows:!1}for(const t of g.children)rk(t,A)}function FE(g,A,e){g[A]===void 0&&console.warn("Field",A,"is undefined on",g);const t=Proxy.revocable(g[A],{set(I,s,n,a){const r=I[s],C=Reflect.set(I,s,n,a);return e(n,r),C}}),i=t.revoke,o=g[A];return t.revoke=()=>{g[A]=o,i()},g[A]=t.proxy,t}const oP=Symbol("Scheduled action");function DuA(g,A,e=Ci.OnBeforeRender){let t=g[oP];t||(t=g[oP]={});const i=A.name;t[e]||(t[e]={});const o=t[e];if(o[i])return;function*s(){A==null||A.call(g),o[i]=null}const n=g.startCoroutine(s(),e);o[i]=n}const Xr=gA("debugeventsystem");var rJ=(g=>(g.BeforeHandleInput="BeforeHandleInput",g.AfterHandleInput="AfterHandleInput",g))(rJ||{});const Ja=class extends NA{constructor(){super();c(this,"raycaster",[]);c(this,"pressedByID",new Map);c(this,"hoveredByID",new Map);c(this,"onPointerEvent",e=>{if(e===void 0||e.propagationStopped||e.defaultPrevented||e.used)return;const t=new Cu(this.context.input,e);this._currentPointerEventName=e.type,t.inputSource=this.context.input,t.isClick=e.isClick,t.isDoubleClick=e.isDoubleClick,t.isDown=e.type==ki.PointerDown,t.isUp=e.type==ki.PointerUp,t.isPressed=this.context.input.getPointerPressed(e.pointerId),Xr&&(t.isDown?console.log("DOWN",t.pointerId):t.isUp&&console.log("UP",t.pointerId),t.isClick&&console.log("CLICK",t.pointerId));const i=new Cr;e.hasRay?i.ray=e.ray:i.screenPoint=this.context.input.getPointerPositionRC(e.pointerId);const o=this.performRaycast(i);if(o){for(const s of o)s.event=e,e.intersections.push(s);e.origin.onPointerHits&&e.origin.onPointerHits({sender:this,event:e,hits:o})}Xr&&t.isClick&&Ri("EventSystem: "+t.pointerId+" - "+this.context.time.frame+" - Up:"+t.isUp+", Down:"+t.isDown);const I={sender:this,args:t,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:I})),this.handleIntersections(o,t),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:I}))});c(this,"_sortedHits",[]);c(this,"_testObjectsCache",new Map);c(this,"_currentlyActiveRaycaster",null);c(this,"_currentPointerEventName",null);c(this,"shouldRaycastObject",e=>{var o;let t=null;if(fuA(e)&&(t=(o=e[hn])==null?void 0:o.gameObject),this._testObjectsCache.has(e)||t&&this._testObjectsCache.has(t))return this._testObjectsCache.get(e)===!1?"continue in children":!0;{let I=nk(e,this._currentPointerEventName);if(!I&&t&&(I=nk(t,this._currentPointerEventName)),I){this._testObjectsCache.set(e,!0);for(const s of e.children)this.shouldRaycastObject_AddToYesCache(s);return!0}return this._testObjectsCache.set(e,!1),"continue in children"}});c(this,"_sortingBuffer",[]);c(this,"_noDepthTestingResults",[]);c(this,"out",{});c(this,"_capturedPointer",{});c(this,"pointerEnterSymbol",Symbol("pointerEnter"));c(this,"pointerExitSymbol",Symbol("pointerExit"));c(this,"currentActiveMeshUIComponents",[]);Ja.systems.push(this)}static createIfNoneExists(e){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Ja.systems.length<=0&&Ja.systems.push(...oA.findObjectsOfType(Ja,e)));for(const i of Ja.systems)if(i.context===e)return;const t=new uA;oA.addComponent(t,Ja),e.scene.add(t)}static get systems(){const e=Ue.Current;return this._eventSystemMap.has(e)||this._eventSystemMap.set(e,[]),this._eventSystemMap.get(e)}static get(e){const t=this._eventSystemMap.get(e);return t&&t.length>0?t[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(e,t,i=!1){qB.update(e,t,i)}static markUIDirty(e){qB.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){Ja.systems.splice(Ja.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!oA.findObjectOfType(gw,this.context)){const t=oA.addComponent(this.context.scene,Ts);this.raycaster.push(t),(VA()||Xr)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(e){var t;e&&this.raycaster&&!this.raycaster.includes(e)&&((t=this.raycaster)==null||t.push(e))}unregister(e){var i,o;const t=(i=this.raycaster)==null?void 0:i.indexOf(e);t!==void 0&&t!==-1&&((o=this.raycaster)==null||o.splice(t,1))}onEnable(){this.context.input.addEventListener(ki.PointerDown,this.onPointerEvent),this.context.input.addEventListener(ki.PointerUp,this.onPointerEvent),this.context.input.addEventListener(ki.PointerMove,this.onPointerEvent)}onDisable(){this.context.input.removeEventListener(ki.PointerDown,this.onPointerEvent),this.context.input.removeEventListener(ki.PointerUp,this.onPointerEvent),this.context.input.removeEventListener(ki.PointerMove,this.onPointerEvent)}onBeforeRender(){this.resetMeshUIStates()}shouldRaycastObject_AddToYesCache(e){this._testObjectsCache.set(e,!0);for(const t of e.children)this.shouldRaycastObject_AddToYesCache(t)}performRaycast(e){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,e||(e=new Cr),e.testObject=this.shouldRaycastObject;for(const t of this.raycaster){if(!t.activeAndEnabled)continue;this._currentlyActiveRaycaster=t;const i=t.performRaycast(e);this._currentlyActiveRaycaster=null,i&&i.length>0&&this._sortedHits.push(...i)}return this._sortedHits.sort((t,i)=>t.distance-i.distance),this._sortedHits}assignHitInformation(e,t){t?(e.intersection=t,e.point=t.point,e.normal=t.normal,e.face=t.face,e.distance=t.distance,e.instanceId=t.instanceId):(e.intersection=void 0,e.point=void 0,e.normal=void 0,e.face=void 0,e.distance=void 0,e.instanceId=void 0)}handleIntersections(e,t){var o;if(e!=null&&e.length){e=this.sortCandidates(e);for(const I of e){if(t.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(t,I),this.handleEventOnObject(I.object,t))return!0}}this.assignHitInformation(t,e==null?void 0:e[0]),this.invokePointerCapture(t);const i=this.hoveredByID.get(t.pointerId);return i&&this.propagatePointerExit(i.obj,i.data,null),this.hoveredByID.delete(t.pointerId),t.isUp&&((o=this.pressedByID.get(t.pointerId))==null||o.handlers.forEach(I=>this.invokeOnPointerUp(t,I)),this.pressedByID.delete(t.pointerId)),!1}sortCandidates(e){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let t=0;t<e.length;t++){const i=e[t],o=i.object;if(o.material&&o.material.depthTest===!1){this._noDepthTestingResults.push(i);continue}this._sortingBuffer.push(i)}for(const t of this._sortingBuffer)this._noDepthTestingResults.push(t);return this._noDepthTestingResults}handleEventOnObject(e,t){if(!this.testIsVisible(e))return t.isClick&&Xr&&console.log("not allowed",e),!1;if(t.pointerId===void 0)return Xr&&console.error("Event without pointer can't be handled",t),!1;t.object=e;const i=e.parent,o=t.isClick??!1;let I=null;if(i&&i.isUI){const C=(t.isPressed||t.isClick)??!1;if(i[hn]){const B=i[hn].gameObject;if(B){if(!sR.isInteractable(B,this.out))return!1;I=this.out.canvasGroup??null,this.handleMeshUIIntersection(e,C),e=B}}}o&&Xr&&console.log(this.context.time.frame,e);const s=this.hoveredByID.get(t.pointerId),n=s==null?void 0:s.obj;n!==e&&n&&this.propagatePointerExit(n,s.data,e);const r=this.hoveredByID.get(t.pointerId);if(r?(r.obj=e,r.data=t):this.hoveredByID.set(t.pointerId,{obj:e,data:t}),t.isDown){const C=this.pressedByID.get(t.pointerId);C?(C.obj=e,C.data=t):this.pressedByID.set(t.pointerId,{obj:e,data:t,handlers:new Set})}return(I===null||I.interactable)&&this.handleMainInteraction(e,t,n??null),!0}propagate(e,t){for(;e;)oA.foreachComponent(e,i=>{t(i)},!1),e=e.parent}handleMainInteraction(e,t,i){const o=this.pressedByID.get(t.pointerId),I=i!==e;let s=!0;switch(t.event.pointerType){case"mouse":case"touch":const n=this.context.input.getPointerPositionLastFrame(t.pointerId),a=this.context.input.getPointerPosition(t.pointerId);s=n&&!ie.approximately(n,a);break}this.propagate(e,n=>{var r;const a=n;a.interactable!==!1&&(!a.activeAndEnabled||!a.enabled||(a.onPointerEnter&&I&&this.handlePointerEnter(a,t),t.isDown&&a.onPointerDown&&(a.onPointerDown(t),o==null||o.handlers.add(a),this.handlePointerCapture(t,a)),a.onPointerMove&&(s&&a.onPointerMove(t),this.handlePointerCapture(t,a)),t.isUp&&(a.onPointerUp&&(this.invokeOnPointerUp(t,a),o==null||o.handlers.delete(a)),a.onPointerExit&&((r=t.event)==null?void 0:r.pointerType)===HM.Touch&&(this.handlePointerExit(a,t),this.hoveredByID.delete(t.pointerId))),t.isClick&&a.onPointerClick&&a.onPointerClick(t)))}),t.isUp&&(o==null||o.handlers.forEach(n=>{this.invokeOnPointerUp(t,n)}),this.pressedByID.delete(t.pointerId))}propagatePointerExit(e,t,i){this.propagate(e,o=>{if(!o.gameObject||o.destroyed)return;const I=o;if(I.onPointerExit||I.onPointerEnter){if(i&&this.isChild(i,o.gameObject))return;this.handlePointerExit(I,t)}})}invokeOnPointerUp(e,t){var i;(i=t.onPointerUp)==null||i.call(t,e),this.releasePointerCapture(e,t)}handlePointerEnter(e,t){e.onPointerEnter&&this.updatePointerState(e,t.pointerId,this.pointerEnterSymbol,!0)&&e.onPointerEnter(t),this.updatePointerState(e,t.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(e,t){e.onPointerExit&&this.updatePointerState(e,t.pointerId,this.pointerExitSymbol,!0)&&e.onPointerExit(t),this.updatePointerState(e,t.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(e,t,i,o){let I=e[i];if(o)return I&&I.includes(t)?!1:(I=I||[],I.push(t),e[i]=I,!0);{if(!I||!I.includes(t))return!1;const s=I.indexOf(t);return s!==-1&&I.splice(s,1),!0}}handlePointerCapture(e,t){if(e.z__pointer_ctured){e.z__pointer_ctured=!1;const i=e.pointerId;if(t.onPointerMove){const o=this._capturedPointer[i]||[];o.push(t),this._capturedPointer[i]=o}else VA()&&!t.z__warned_no_pointermove&&(t.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else e.z__pointer_cture_rleased&&(e.z__pointer_cture_rleased=!1,this.releasePointerCapture(e,t))}releasePointerCapture(e,t){const i=e.pointerId;if(this._capturedPointer[i]){const o=this._capturedPointer[i].indexOf(t);o!==-1&&(this._capturedPointer[i].splice(o,1),Xr&&console.log("released pointer capture",i,t,this._capturedPointer))}}invokePointerCapture(e){var t;if(e.event.type===ki.PointerMove){const i=e.pointerId,o=this._capturedPointer[i];if(o){Xr&&console.log("Captured",i,o);for(let I=0;I<o.length;I++){const s=o[I];if(s.destroyed){o.splice(I,1),I--;continue}(t=s.onPointerMove)==null||t.call(s,e)}}}}isChild(e,t){return!e||!t?!1:e===t?!0:e.parent?this.isChild(e.parent,t):!1}handleMeshUiObjectWithoutShadowDom(e,t){return!e||!e.isUI?!0:this.handleMeshUIIntersection(e,t)}handleMeshUIIntersection(e,t){const i=qB.updateState(e,t);return i&&this.currentActiveMeshUIComponents.push(i),i!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&qB.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let e=0;e<this.currentActiveMeshUIComponents.length;e++){const t=this.currentActiveMeshUIComponents[e];qB.resetState(t)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(e){return e?oA.isActiveSelf(e)?this.testIsVisible(e.parent):!1:!0}};let VI=Ja;c(VI,"_eventSystemMap",new Map),c(VI,"didSearchEventSystem",!1);class qB{static markDirty(){this.needsUpdate=!0}static update(A,e,t=!1){if(t){A.update();return}const i=e.time.frameCount;for(const o of this.lastUpdateFrame)if(o.context===e){if(i===o.frame)return;o.frame=i;let I=this.needsUpdate||i<1;o.nextUpdate<=i&&(I=!0),I&&(Xr&&console.log("Update threemeshui"),this.needsUpdate=!1,o.nextUpdate=i+60,A.update());return}this.lastUpdateFrame=[{context:e,frame:i,nextUpdate:i+60}],A.update(),this.needsUpdate=!1}static updateState(A,e){let t=null;if(A&&(t=this.findBlockInParent(A),t&&t!==this.lastSelected)){if(t.interactable===!1)return null;this.needsUpdate=!0}return t}static resetLastSelected(){const A=this.lastSelected;A&&(this.lastSelected=null,this.resetState(A))}static resetState(A){A&&(this.needsUpdate=!0)}static findBlockInParent(A){return A?A.isBlock?A:this.findBlockInParent(A.parent):null}}c(qB,"lastSelected",null),c(qB,"lastUpdateFrame",[]),c(qB,"needsUpdate",!1);var yuA=Object.defineProperty,wuA=Object.getOwnPropertyDescriptor,Ki=(g,A,e,t)=>{for(var i=t>1?void 0:t?wuA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&yuA(A,e,i),i};const HF=gA("debugorbit"),YF=gA("freecam"),Nm=gA("debugcamerafit"),Fm=gA("smoothcam"),muA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let OF;class zD extends CustomEvent{constructor(A,e){super("target-reached",{detail:{controls:A,type:e}})}}class Kt extends NA{constructor(){super(...arguments);c(this,"autoTarget",!0);c(this,"autoFit",!1);c(this,"enableRotate",!0);c(this,"autoRotate",!1);c(this,"autoRotateSpeed",1);c(this,"minAzimuthAngle",1/0);c(this,"maxAzimuthAngle",1/0);c(this,"minPolarAngle",0);c(this,"maxPolarAngle",Math.PI);c(this,"enableKeys",!1);c(this,"enableDamping",!0);c(this,"dampingFactor",.1);c(this,"enableZoom",!0);c(this,"minZoom",0);c(this,"maxZoom",1/0);c(this,"zoomSpeed",1);c(this,"zoomToCursor",!1);c(this,"enablePan",!0);c(this,"lookAtConstraint",null);c(this,"lookAtConstraint01",1);c(this,"allowInterrupt",!0);c(this,"middleClickToFocus",!0);c(this,"doubleClickToFocus",!0);c(this,"clickBackgroundToFitScene",2);c(this,"debugLog",!1);c(this,"targetLerpDuration",1);c(this,"_controls",null);c(this,"_cameraObject",null);c(this,"_lookTargetLerpActive",!1);c(this,"_lookTargetStartPosition",new S);c(this,"_lookTargetEndPosition",new S);c(this,"_lookTargetLerp01",0);c(this,"_lookTargetLerpDuration",0);c(this,"_cameraLerpActive",!1);c(this,"_cameraStartPosition",new S);c(this,"_cameraEndPosition",new S);c(this,"_cameraLerp01",0);c(this,"_cameraLerpDuration",0);c(this,"_fovLerpActive",!1);c(this,"_fovLerpStartValue",0);c(this,"_fovLerpEndValue",0);c(this,"_fovLerp01",0);c(this,"_fovLerpDuration",0);c(this,"_inputs",0);c(this,"_enableTime",0);c(this,"_startedListeningToKeyEvents",!1);c(this,"_eventSystem");c(this,"_afterHandleInputFn");c(this,"_camera",null);c(this,"_syncedTransform");c(this,"_didSetTarget",0);c(this,"targetElement",null);c(this,"_activePointerEvents");c(this,"_lastTimeClickOnBackground",-1);c(this,"_clickOnBackgroundCount",0);c(this,"_onPointerDown",e=>{this._activePointerEvents.push(e)});c(this,"_onPointerUp",e=>{for(let t=this._activePointerEvents.length-1;t>=0;t--){const i=this._activePointerEvents[t];if(i.pointerId===e.pointerId&&i.button===e.button){this._activePointerEvents.splice(t,1);break}}if(this.clickBackgroundToFitScene>0&&e.isClick&&e.button===0){if(e.hasRay||e.intersections.push(...this.context.physics.raycast()),e.intersections.length<=0){const t=this.context.time.time-this._lastTimeClickOnBackground;this._lastTimeClickOnBackground=this.context.time.time,this.clickBackgroundToFitScene<=1||t<this.clickBackgroundToFitScene*.15?(this._clickOnBackgroundCount+=1,this._clickOnBackgroundCount>=this.clickBackgroundToFitScene-1&&this.fitCamera(this.context.scene.children,{immediate:!1})):this._clickOnBackgroundCount=0}HF&&console.log(this.clickBackgroundToFitScene,e.intersections.length,this._clickOnBackgroundCount)}});c(this,"_onPointerUpLate",e=>{this.doubleClickToFocus&&e.isDoubleClick&&!e.used&&this.setTargetFromRaycast()});c(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});c(this,"_shouldDisable",!1);c(this,"__onPreRender",()=>{const e=this.context.pre_render_callbacks.indexOf(this.__onPreRender);e>=0&&this.context.pre_render_callbacks.splice(e,1),this.autoFit&&(this.autoFit=!1,this.fitCamera({centerCamera:"y",immediate:!0,objects:this.scene.children}))});c(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var t;(t=this.controls)==null||t.addEventListener("start",e)}get targetLerpSpeed(){return 5}set targetLerpSpeed(e){this.targetLerpDuration=1/e}awake(){this._didSetTarget=0,this._startedListeningToKeyEvents=!1}start(){this._eventSystem=VI.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(rJ.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(rJ.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._didSetTarget=0,this._enableTime=this.context.time.time;const e=oA.getComponent(this.gameObject,Vt);this._camera=e;let t=e==null?void 0:e.threeCamera;if(!t&&this.gameObject instanceof Ke&&(t=this.gameObject),t&&Ax(t,this,!0),!this._controls&&t instanceof Ke){this._cameraObject=t;const i=this.targetElement??this.context.renderer.domElement,o=t==null?void 0:t.quaternion.clone();this._controls=new hj(t,i),t==null||t.quaternion.copy(o),OF===void 0&&(OF={...this._controls.keys})}this._controls&&(YF&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,exports.DeviceUtilities.isMobileDevice()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),!this._startedListeningToKeyEvents&&this.enableKeys?(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(this.context.domElement)):this._controls.stopListenToKeyEvents()),this._syncedTransform=oA.getComponent(this.gameObject,Br)??void 0,this.context.pre_render_callbacks.push(this.__onPreRender),this._activePointerEvents=[],this.context.input.addEventListener("pointerdown",this._onPointerDown,{queue:ys.Early}),this.context.input.addEventListener("pointerup",this._onPointerUp,{queue:ys.Early}),this.context.input.addEventListener("pointerup",this._onPointerUpLate,{queue:ys.Late})}onDisable(){var e;(e=this._camera)!=null&&e.threeCamera&&Ax(this._camera.threeCamera,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted),this._controls.stopListenToKeyEvents(),this._startedListeningToKeyEvents=!1),this._activePointerEvents.length=0,this.context.input.removeEventListener("pointerdown",this._onPointerDown),this.context.input.removeEventListener("pointerup",this._onPointerUp),this.context.input.removeEventListener("pointerup",this._onPointerUpLate)}afterHandleInput(e){e.detail.args.pointerId===0&&(e.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!e.detail.args.isPressed||e.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var t,i,o,I;if(!this._controls)return;if(this._cameraObject!==this.context.mainCamera){this._controls.enabled=!1;return}if(this._controls.enabled=!0,(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&((t=this.context.input.getPointerPositionDelta(0))!=null&&t.length())||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!1),this._inputs=0,this.autoTarget&&this._didSetTarget++===0){const s=oA.getComponent(this.gameObject,Vt);if(s&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const n=_e(s.threeCamera),a=Math.max(.01,n.length()),r=new S(0,0,-a).applyMatrix4(s.threeCamera.matrixWorld);this.setLookTargetPosition(r,!0)}if(!this.setLookTargetFromConstraint()){const n=new Cr;n.screenPoint=new eA(0,0),n.lineThreshold=.1;const a=this.context.physics.raycast(n);a.length>0&&this.setLookTargetPosition(a[0].point,!0),Nm&&console.log("OrbitControls hits",...a)}}if(this.middleClickToFocus&&this.context.input.getPointerClicked(1)&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive||this._fovLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new zD(this,"camera"));else{const s=ie.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,s)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new zD(this,"lookat"));else{const s=ie.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,s)}if(this._fovLerpActive&&this._cameraObject){const s=this._cameraObject;if(this._fovLerp01+=this.context.time.deltaTime/this._fovLerpDuration,this._fovLerp01>=1)s.fov=this._fovLerpEndValue,this._fovLerpActive=!1;else{const n=ie.easeInOutCubic(this._fovLerp01);s.fov=ie.lerp(this._fovLerpStartValue,this._fovLerpEndValue,n)}s.updateProjectionMatrix()}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR&&!this._activePointerEvents.some(s=>s.used),this._controls.keys=this.enableKeys?OF:muA,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.zoomSpeed=this.zoomSpeed,this._controls.zoomToCursor=this.zoomToCursor,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,this._controls.minAzimuthAngle=this.minAzimuthAngle,this._controls.maxAzimuthAngle=this.maxAzimuthAngle,this._controls.minPolarAngle=this.minPolarAngle,this._controls.maxPolarAngle=this.maxPolarAngle,YF||(((o=(i=this._camera)==null?void 0:i.threeCamera)==null?void 0:o.type)==="PerspectiveCamera"?(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom,this._controls.minZoom=0,this._controls.maxZoom=1/0):(this._controls.minDistance=0,this._controls.maxDistance=1/0,this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom)),typeof Fm=="number"||Fm===!0){this._controls.enableDamping=!0;const s=typeof Fm=="number"?Fm:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,s))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!YF&&((I=this.lookAtConstraint)!=null&&I.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(this.context.time.deltaTime),HF&&le.DrawWireSphere(this._controls.target,.1,65280))}}setCameraAndLookTarget(e){if(!e||!(e instanceof uA))return;const t=_e(e),i=lL(e);this.setTargetFromRaycast(new bI(t,i)),this.setCameraTargetPosition(t)}setCameraTargetPosition(e,t=!1){var i;e&&(e instanceof uA&&(e=_e(e)),this._cameraEndPosition||(this._cameraEndPosition=new S),this._cameraEndPosition.copy(e),t===!0?(this._cameraLerpActive=!1,this._cameraObject&&this._cameraObject.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((i=this._cameraObject)==null?void 0:i.position),typeof t=="number"?this._cameraLerpDuration=t:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setFieldOfView(e,t=!1){var o;if(!this._controls||typeof e!="number")return;const i=(o=this._camera)==null?void 0:o.threeCamera;i&&(t===!0?i.fov=e:(this._fovLerpActive=!0,this._fovLerp01=0,this._fovLerpStartValue=i.fov,this._fovLerpEndValue=e,typeof t=="number"?this._fovLerpDuration=t:this._fovLerpDuration=this.targetLerpDuration))}setLookTargetPosition(e=null,t=!1){this._controls&&e&&(e instanceof uA&&(e=_e(e)),this._lookTargetEndPosition.copy(e),this._didSetTarget++,HF&&(console.warn("OrbitControls: setLookTargetPosition",e,t),le.DrawWireSphere(this._lookTargetEndPosition,.2,16711680,2)),t===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof t=="number"?this._lookTargetLerpDuration=t:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(e=0,t=1){var o;if(!this._controls)return!1;const i=(o=this.lookAtConstraint)==null?void 0:o.sources;if(i&&i.length>0){const I=i[e];if(I)return I.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,t),!0}return!1}lerpTarget(e,t){return this.lerpLookTarget(e,t)}lerpLookTarget(e,t){this._controls&&(t>=1?this._controls.target.copy(e):this._controls.target.lerp(e,t))}setTargetFromRaycast(e){if(!this.controls)return;const t=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const i of t)if(i.distance>0&&oA.isActiveInHierarchy(i.object)){const o=Mq(i.object);if(o){const I=o.canvas;if(I!=null&&I.screenspace)break}this.setLookTargetPosition(i.point);break}}fitCamera(e,t){var N,K;if(this.context.isInXR)return;let i;if(Array.isArray(e)?i=e:e&&"type"in e?i=e.children:e&&"objects"in e&&(i=e==null?void 0:e.objects,t=e),i&&!Array.isArray(i)&&(i=i.children),(!Array.isArray(i)||i&&i.length<=0)&&(i=this.context.scene.children),!Array.isArray(i)||i.length<=0){console.warn("No objects to fit camera to...");return}const o=this._cameraObject,I=this._controls;if(!o||!I){console.warn("No camera or controls found to fit camera to objects...");return}t||(t={});const{immediate:s=!1,centerCamera:n="y",cameraNearFar:a="auto",fitOffset:r=1.1,fov:C=o==null?void 0:o.fov}=t,B=new S,l=new S,Q=Ls(i,void 0,(K=(N=this._camera)==null?void 0:N.threeCamera)==null?void 0:K.layers),d=Q.clone();o.updateMatrixWorld(),o.updateProjectionMatrix(),Q.getCenter(l);const h=new S;if(Q.getSize(h),Q.applyMatrix4(o.matrixWorldInverse),Q.getSize(B),Q.setFromCenterAndSize(l,B),Number.isNaN(B.x)||Number.isNaN(B.y)||Number.isNaN(B.z)){console.warn("Camera fit size resultet in NaN",o,Q,[...i]);return}if(B.length()<=1e-10){Nm&&console.warn("Camera fit size is zero",Q,[...i]);return}const E=t.fov||o.fov,p=2*Math.atan(Math.tan(E*Math.PI/360/2)*o.aspect)/Math.PI*360,u=B.y/(2*Math.atan(Math.PI*E/360)),f=B.x/(2*Math.atan(Math.PI*p/360)),D=r*Math.max(u,f)+B.z/2;Nm&&console.log("Fit camera to objects",{fitHeightDistance:u,fitWidthDistance:f,distance:D,verticalFov:E,horizontalFov:p}),this.maxZoom=D*10,this.minZoom=D*.01;const y=.05,w=l.clone();if(w.y-=B.y*y,this.setLookTargetPosition(w,s),this.setFieldOfView(t.fov,s),this.autoTarget=!1,a==null||a=="auto"){const F=oA.findObjectOfType(ur),_=F?F.radius:0,J=Math.max(h.x,h.y,h.z,_);o.near=D/100,o.far=J+D*10,F&&(this.maxZoom=Math.max(Math.min(this.maxZoom,_*.5),D))}const k=I.getDistance();k<this.minZoom&&(this.minZoom=k*.9),k>this.maxZoom&&(this.maxZoom=k*1.1),o.updateMatrixWorld(),o.updateProjectionMatrix();const M=_e(o),m=l.clone();m.sub(M),n==="y"&&(m.y=0),m.normalize(),m.multiplyScalar(D),n==="y"&&(m.y+=-y*4*D);let U=l.clone().sub(m);if(o.parent&&(U=o.parent.worldToLocal(U)),this.setCameraTargetPosition(U,s),Nm){const F=new xv(Q);this.context.scene.add(F),EL(F,qy(o)),setTimeout(()=>{this.context.scene.remove(F)},1e4),le.DrawWireBox3(d,65280,10),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",_=>{if(_.code==="KeyF"){let J;this._cameraObject instanceof Ke&&(J=Math.random()*Math.random()*170+10),this.fitCamera({objects:i,fitOffset:r,immediate:!1,fov:J})}_.code==="KeyV"&&this._cameraObject instanceof Ke&&(this._cameraObject.fov=60)}))}I.update()}}Ki([G()],Kt.prototype,"autoTarget",2);Ki([G()],Kt.prototype,"autoFit",2);Ki([G()],Kt.prototype,"enableRotate",2);Ki([G()],Kt.prototype,"autoRotate",2);Ki([G()],Kt.prototype,"autoRotateSpeed",2);Ki([G()],Kt.prototype,"minAzimuthAngle",2);Ki([G()],Kt.prototype,"maxAzimuthAngle",2);Ki([G()],Kt.prototype,"minPolarAngle",2);Ki([G()],Kt.prototype,"maxPolarAngle",2);Ki([G()],Kt.prototype,"enableKeys",2);Ki([G()],Kt.prototype,"enableDamping",2);Ki([G()],Kt.prototype,"dampingFactor",2);Ki([G()],Kt.prototype,"enableZoom",2);Ki([G()],Kt.prototype,"minZoom",2);Ki([G()],Kt.prototype,"maxZoom",2);Ki([G()],Kt.prototype,"zoomSpeed",2);Ki([G()],Kt.prototype,"enablePan",2);Ki([G(ZQ)],Kt.prototype,"lookAtConstraint",2);Ki([G()],Kt.prototype,"lookAtConstraint01",2);Ki([G()],Kt.prototype,"allowInterrupt",2);Ki([G()],Kt.prototype,"middleClickToFocus",2);Ki([G()],Kt.prototype,"doubleClickToFocus",2);Ki([G()],Kt.prototype,"clickBackgroundToFitScene",2);Ki([G()],Kt.prototype,"targetLerpDuration",2);var SuA=Object.defineProperty,GuA=Object.getOwnPropertyDescriptor,KI=(g,A,e,t)=>{for(var i=t>1?void 0:t?GuA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&SuA(A,e,i),i},nc=(g=>(g[g.None=0]="None",g[g.Skybox=1]="Skybox",g[g.SolidColor=2]="SolidColor",g[g.Uninitialized=4]="Uninitialized",g))(nc||{});const RB=gA("debugcam"),IP=gA("debugscreenpointtoray");var yS;const Ef=(yS=class extends NA{constructor(){super(...arguments);c(this,"_nearClipPlane",.1);c(this,"_farClipPlane",1e3);c(this,"orthographic",!1);c(this,"orthographicSize",5);c(this,"ARBackgroundAlpha",0);c(this,"_cullingMask",4294967295);c(this,"_backgroundBlurriness");c(this,"_backgroundIntensity");c(this,"_backgroundRotation");c(this,"_environmentIntensity");c(this,"_targetTexture",null);c(this,"_backgroundColor");c(this,"_fov");c(this,"_cam",null);c(this,"_clearFlags",2);c(this,"_skybox");c(this,"_frustum");c(this,"_projScreenMatrix",new lA)}get isCamera(){return!0}get aspect(){return this._cam instanceof Ke?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(A){this._cam instanceof Ke&&this._cam.aspect!==A&&(this._cam.aspect=A,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof Ke?this._cam.fov:this._fov}set fieldOfView(A){const e=this.fieldOfView!=A;if(this._fov=A,e&&this._cam&&this._cam instanceof Ke){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(A){const e=this._nearClipPlane!=A;this._nearClipPlane=A,this._cam&&(e||this._cam.near!=A)&&(this._cam.near=A,this._cam.updateProjectionMatrix())}applyClippingPlane(){this._cam&&(this._cam.near=this._nearClipPlane,this._cam.far=this._farClipPlane,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(A){const e=this._farClipPlane!=A;this._farClipPlane=A,this._cam&&(e||this._cam.far!=A)&&(this._cam.far=A,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(A){A!==this._clearFlags&&(this._clearFlags=A,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(A){this._cullingMask=A,this._cam&&(this._cam.layers.mask=A)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(A){this.cullingMask=(1<<A|0)>>>0}set backgroundBlurriness(A){A!==this._backgroundBlurriness&&(A===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(A,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(A){A!==this._backgroundIntensity&&(A===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(A,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set backgroundRotation(A){A!==this._backgroundRotation&&(A===void 0?this._backgroundRotation=void 0:this._backgroundRotation=A,this.applyClearFlagsIfIsActiveCamera())}get backgroundRotation(){return this._backgroundRotation}set environmentIntensity(A){this._environmentIntensity=A}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(A){if(A){if(this._backgroundColor)this._backgroundColor.copy(A);else{if(!A.clone)return;this._backgroundColor=A.clone()}A.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(A){this._targetTexture=A}get targetTexture(){return this._targetTexture}get cam(){return this.threeCamera}get threeCamera(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(A,e,t){const i=this.threeCamera,o=Ef._origin;o.set(A,e,-1),this.context.input.convertScreenspaceToRaycastSpace(o),IP&&console.log("screenPointToRay",A.toFixed(2),e.toFixed(2),"now:",o.x.toFixed(2),o.y.toFixed(2),"isInXR:"+this.context.isInXR),o.z=-1,o.unproject(i);const I=Ef._direction.set(o.x,o.y,o.z),s=_e(i);return I.sub(s),I.normalize(),t?(t.set(s,I),t):new bI(s.clone(),I.clone())}getFrustum(){return this._frustum||(this._frustum=new fQ,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new fQ),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(A,e){return e&&this._projScreenMatrix.multiplyMatrices(this.threeCamera.projectionMatrix,this.threeCamera.matrixWorldInverse),A===this._projScreenMatrix?A:A.copy(this._projScreenMatrix)}awake(){IP&&window.addEventListener("pointerdown",A=>{const e=A.clientX,t=A.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const i=this.screenPointToRay(e,t),o="#"+Math.floor(Math.random()*16777215).toString(16);le.DrawRay(i.origin,i.direction,o,10)})}onEnable(){RB&&console.log(`Camera enabled: "${this.name}". ClearFlags=${nc[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),MuA(this)),this.applyClearFlagsIfIsActiveCamera({applySkybox:!0})}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._frustum&&this.updateFrustum(),this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),this._targetTexture)){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const A=this.context.renderer;if(A){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,A),e==null||e.applyClearFlags()}}}buildCamera(){if(this._cam)return;const A=this.gameObject.isCamera;let e=null;if(A?(e=this.gameObject,e==null||e.layers.enableAll(),e instanceof Ke&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof Ke&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new Ke(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const t=this.orthographicSize*100;e=new Qr(window.innerWidth/-t,window.innerWidth/t,window.innerHeight/t,window.innerHeight/-t,this._nearClipPlane,this._farClipPlane),this.gameObject.add(e)}this._cam=e,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(A){this.context.mainCameraComponent===this&&this.applyClearFlags(A)}applyClearFlags(A){var e;if(!this._cam){RB&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,RB){const t=`Camera "${this.name}" clear flags: ${nc[this._clearFlags]}`;console.debug(t)}switch(this._clearFlags){case 0:return;case 1:if(Ef.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}(!this.scene.background||!this._skybox||(A==null?void 0:A.applySkybox)===!0)&&this.applySceneSkybox(),this._backgroundBlurriness!==void 0?this.context.scene.backgroundBlurriness=this._backgroundBlurriness:RB&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity),this._backgroundRotation!==void 0?this.context.scene.backgroundRotation=this._backgroundRotation:RB&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let t=this._backgroundColor.alpha;Ef.backgroundShouldBeTransparent(this.context)&&(t=this.ARBackgroundAlpha??0),this.context.scene.background=null,(e=this.context.xr)!=null&&e.isVR?this.context.renderer.setClearColor(uV(this._backgroundColor).convertLinearToSRGB()):this.context.renderer.setClearColor(this._backgroundColor,t)}else RB&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}applySceneSkybox(){this._skybox||(this._skybox=new kuA(this)),this._skybox.apply()}static backgroundShouldBeTransparent(A){var o,I,s,n;const e=(o=A.renderer.xr)==null?void 0:o.getSession();if(!e)return!1;if(typeof e._transparent=="boolean")return e._transparent;const t=e.environmentBlendMode;RB&&Ri("Environment blend mode: "+t+" on "+navigator.userAgent);let i=t==="additive"||t==="alpha-blend";return A.isInAR&&t==="opaque"&&((I=navigator.userAgent)!=null&&I.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&((n=navigator.userAgent)!=null&&n.includes("Mobile WebXRViewer/v2")))&&(i=!0),e._transparent=i,i}},c(yS,"_origin",new S),c(yS,"_direction",new S),yS);let Vt=Ef;KI([G()],Vt.prototype,"aspect",1);KI([G()],Vt.prototype,"fieldOfView",1);KI([G()],Vt.prototype,"nearClipPlane",1);KI([G()],Vt.prototype,"farClipPlane",1);KI([G()],Vt.prototype,"clearFlags",1);KI([G()],Vt.prototype,"orthographic",2);KI([G()],Vt.prototype,"orthographicSize",2);KI([G()],Vt.prototype,"ARBackgroundAlpha",2);KI([G()],Vt.prototype,"cullingMask",1);KI([G()],Vt.prototype,"backgroundBlurriness",1);KI([G()],Vt.prototype,"backgroundIntensity",1);KI([G(at)],Vt.prototype,"backgroundRotation",1);KI([G()],Vt.prototype,"environmentIntensity",1);KI([G(Lt)],Vt.prototype,"backgroundColor",1);KI([G(Ic)],Vt.prototype,"targetTexture",1);class kuA{constructor(A){c(this,"_camera");c(this,"_skybox");this._camera=A}get context(){var A;return(A=this._camera)==null?void 0:A.context}apply(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(RB&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=MI,this.context.scene.background=this._skybox):this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" has no skybox texture. ${this._camera.sourceId}`))}}function MuA(g){gA("freecam")&&g.context.mainCameraComponent===g&&oA.getOrAddComponent(g.gameObject,Kt)}class ac extends NA{constructor(){super(...arguments);c(this,"_listener",null);c(this,"onInteraction",()=>{this.destroyed||this.listener==null||this.addListenerIfItExists()})}get listener(){return this._listener==null&&(this._listener=new eW),this._listener}onEnable(){sa.registerWaitForInteraction(this.onInteraction),this.addListenerIfItExists()}onDisable(){sa.unregisterWaitForInteraction(this.onInteraction),this.removeListenerIfItExists()}addListenerIfItExists(){const e=this._listener;if(!e||e!=null&&e.parent)return;const t=this.context.mainCameraComponent||oA.getComponentInParent(this.gameObject,Vt);t!=null&&t.threeCamera?t.threeCamera.add(e):this.gameObject.add(e),e.filter?(e.gain.connect(e.filter),e.filter.connect(e.context.destination)):e.gain.connect(e.context.destination)}removeListenerIfItExists(){const e=this._listener;e&&(e.removeFromParent(),e.filter&&e.filter.disconnect(),e.gain&&e.gain.disconnect())}}var RuA=Object.defineProperty,UuA=Object.getOwnPropertyDescriptor,da=(g,A,e,t)=>{for(var i=t>1?void 0:t?UuA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&RuA(A,e,i),i};const Zo=gA("debugaudio"),UB=class extends NA{constructor(){super(...arguments);c(this,"clip","");c(this,"playOnAwake",!1);c(this,"preload",!1);c(this,"playInBackground",!0);c(this,"_spatialBlend",0);c(this,"_minDistance",1);c(this,"_maxDistance",100);c(this,"_volume",1);c(this,"rollOffMode",0);c(this,"_loop",!1);c(this,"sound",null);c(this,"helper",null);c(this,"wasPlaying",!1);c(this,"audioLoader",null);c(this,"shouldPlay",!1);c(this,"_lastClipStartedLoading",null);c(this,"_audioElement",null);c(this,"onVisibilityChanged",()=>{switch(document.visibilityState){case"hidden":(this.playInBackground===!1||exports.DeviceUtilities.isMobileDevice())&&(this.wasPlaying=this.isPlaying,this.isPlaying&&this.pause());break;case"visible":Zo&&console.log("visible",this.enabled,this.playOnAwake,!this.isPlaying,UB.userInteractionRegistered,this.wasPlaying),this.enabled&&this.playOnAwake&&!this.isPlaying&&UB.userInteractionRegistered&&this.wasPlaying&&this.play();break}});c(this,"onApplicationMuteChanged",()=>{var A,e;this.context.application.muted?(A=this.sound)==null||A.setVolume(0):(e=this.sound)==null||e.setVolume(this.volume)});c(this,"createAudio",A=>{Zo&&console.log("AudioBuffer finished loading",A);const e=this.Sound;if(!e){Zo&&console.warn("Failed getting sound?",this.name);return}e.isPlaying&&e.stop(),A&&e.setBuffer(A),e.loop=this._loop,this.context.application.muted?e.setVolume(0):e.setVolume(this.volume),e.autoplay=this.shouldPlay&&UB.userInteractionRegistered,this.applySpatialDistanceSettings(),e.isPlaying&&e.stop(),UB.registerWaitForAllowAudio(this.__onAllowAudioCallback)});c(this,"__onAllowAudioCallback",()=>{this.shouldPlay&&this.play()});c(this,"_lastContextTime",0);c(this,"_hasEnded",!0);c(this,"_needUpdateSpatialDistanceSettings",!1)}static get userInteractionRegistered(){return sa.userInteractionRegistered}static registerWaitForAllowAudio(A){sa.registerWaitForInteraction(A)}get isPlaying(){var A;return((A=this.sound)==null?void 0:A.isPlaying)??!1}get duration(){var A,e;return(e=(A=this.sound)==null?void 0:A.buffer)==null?void 0:e.duration}get time01(){var e;const A=this.duration;return A&&this.sound?((e=this.sound)==null?void 0:e.context.currentTime)/A:0}set time01(A){const e=this.duration;e&&this.sound&&(this.time=A*e)}get time(){var A,e;return(A=this.sound)!=null&&A.source?((e=this.sound.source)==null?void 0:e.context.currentTime)-this._lastContextTime+this.sound.offset:0}set time(A){if(this.sound){if(A===this.sound.offset)return;const e=this.isPlaying;this.stop(),this.sound.offset=A,e&&this.play()}}get loop(){return this.sound&&(this._loop=this.sound.getLoop()),this._loop}set loop(A){this._loop=A,this.sound&&this.sound.setLoop(A)}get spatialBlend(){return this._spatialBlend}set spatialBlend(A){A!==this._spatialBlend&&(this._spatialBlend=A,this._needUpdateSpatialDistanceSettings=!0)}get minDistance(){return this._minDistance}set minDistance(A){this._minDistance!==A&&(this._minDistance=A,this._needUpdateSpatialDistanceSettings=!0)}get maxDistance(){return this._maxDistance}set maxDistance(A){this._maxDistance!==A&&(this._maxDistance=A,this._needUpdateSpatialDistanceSettings=!0)}get volume(){return this._volume}set volume(A){this._volume=A,this.sound&&!this.context.application.muted&&(Zo&&console.log(this.name,"audio set volume",A),this.sound.setVolume(A))}set pitch(A){this.sound&&this.sound.setPlaybackRate(A)}get pitch(){return this.sound?this.sound.getPlaybackRate():1}get Sound(){var A;if(!this.sound&&UB.userInteractionRegistered){let e=oA.getComponent(this.context.mainCamera,ac)??oA.findObjectOfType(ac,this.context);!e&&this.context.mainCamera&&(e=oA.addComponent(this.context.mainCamera,ac)),e!=null&&e.listener?(this.sound=new tW(e.listener),(A=this.gameObject)==null||A.add(this.sound)):Zo&&console.warn("No audio listener found in scene - can not play audio")}return this.sound}get ShouldPlay(){return this.shouldPlay}get audioContext(){var A;return(A=this.sound)==null?void 0:A.context}awake(){Zo&&console.log(this),this.audioLoader=new UG,this.playOnAwake&&(this.shouldPlay=!0),this.preload&&typeof this.clip=="string"&&this.audioLoader.load(this.clip,this.createAudio,()=>{},console.error)}onEnable(){this.sound&&this.gameObject.add(this.sound),UB.userInteractionRegistered?this.playOnAwake&&this.context.application.isVisible&&this.play():UB.registerWaitForAllowAudio(()=>{this.enabled&&!this.destroyed&&this.shouldPlay&&this.onNewClip(this.clip)}),globalThis.addEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.addEventListener($G.MuteChanged,this.onApplicationMuteChanged)}onDisable(){globalThis.removeEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.removeEventListener($G.MuteChanged,this.onApplicationMuteChanged),this.pause()}applySpatialDistanceSettings(){const A=this.sound;if(!A)return;this._needUpdateSpatialDistanceSettings=!1;const e=ie.lerp(10*this._maxDistance/Math.max(1e-4,this.spatialBlend),this._minDistance,this.spatialBlend);switch(Zo&&console.log(this.name,this._minDistance,this._maxDistance,this.spatialBlend,"Ref distance="+e),A.setRefDistance(e),A.setMaxDistance(Math.max(.01,this._maxDistance)),this.rollOffMode){case 0:A.setDistanceModel("exponential");break;case 1:A.setDistanceModel("linear");break;case 2:console.warn("Custom rolloff for AudioSource is not supported: "+this.name);break}this.spatialBlend>0?Zo&&!this.helper&&(this.helper=new _dA(A,A.getRefDistance()),A.add(this.helper)):this.helper&&this.helper.parent&&this.helper.removeFromParent()}async onNewClip(A){if(A&&(this.clip=A),typeof A=="string")if(Zo&&console.log(A),A.endsWith(".mp3")||A.endsWith(".wav")){if(this.audioLoader||(this.audioLoader=new UG),this.shouldPlay=!0,this._lastClipStartedLoading===A){Zo&&console.log("Is currently loading:",this._lastClipStartedLoading,this);return}this._lastClipStartedLoading=A,Zo&&console.log("load audio",A);const e=await this.audioLoader.loadAsync(A).catch(console.error);this._lastClipStartedLoading=null,e&&this.createAudio(e)}else console.warn("Unsupported audio clip type",A);else this.shouldPlay=!0,this.createAudio()}play(A=void 0){var t,i,o;!A&&this.clip&&(A=this.clip),A!==void 0&&typeof A!="string"&&!(A instanceof MediaStream)&&(VA()&&console.warn("Called play on AudioSource with unknown argument type:",A+`
5956
+ Could not find method ${a.method} on object ${C.name}`,C,typeof C[a.method])};if(typeof C[a.method]!="function"){let d=!1,h=C;for(;h;){const E=Object.getOwnPropertyDescriptor(h,a.method);if(E&&(E.writable===!0||E.set)){d=!0;break}h=Object.getPrototypeOf(h)}!d&&(VA()||io)&&l()}}if(C){let l=a.argument;if(l!==void 0?l=r(l):a.arguments!==void 0&&(l=a.arguments.map(r)),!C[a.method])console.warn(`EventList method not found: "${a.method}" on ${C==null?void 0:C.name}`);else{l!==void 0&&!Array.isArray(l)&&(l=[l]);const d=new Oa(C,a.method,l,a.enabled);I.push(d)}}else VA()&&console.warn("[Debug] EventList: Could not find event listener in scene",a,e.object,A)}const s=new ti(I);io&&console.log(s);const n=e.target;return n!==void 0&&e.path!==void 0&&s.setEventTarget(e.path,n),s}}}const huA=new QuA,ak=new WeakMap,EuA=Pe.prototype.clone;Pe.prototype.clone=function(){const g=EuA.call(this);return ak.has(g)||ak.set(g,this),g};class fj extends Sn{constructor(){super([Ic,et])}onSerialize(A,e){}onDeserialize(A,e){if(A instanceof Pe&&e.type===Ic){let t=A;ak.has(t)&&(t=ak.get(t)),t.isRenderTargetTexture=!0,t.flipY=!0,t.offset.y=1,t.repeat.y=-1,t.needsUpdate=!0,t.mipmaps=[],t instanceof $B&&(t.isCompressedTexture=!1,t.format=Ut);const i=new Ic(t.image.width,t.image.height,{colorSpace:Zt});return i.texture=t,i}}}new fj;class Dj extends Sn{constructor(){super([URL])}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"&&A.length>0)return Mc(e.gltfId,A)}}new Dj;var duA=Object.defineProperty,uuA=Object.getOwnPropertyDescriptor,puA=(g,A,e,t)=>{for(var i=t>1?void 0:t?uuA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&duA(A,e,i),i};class gw extends NA{awake(){VI.createIfNoneExists(this.context)}onEnable(){var A;(A=VI.get(this.context))==null||A.register(this)}onDisable(){var A;(A=VI.get(this.context))==null||A.unregister(this)}}class Ts extends gw{constructor(){super(...arguments);c(this,"targets",null);c(this,"raycastHits",[]);c(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(e=null){if(!this.targets)return null;e??(e=new Cr),e.targets=this.targets,e.results=this.raycastHits,e.useAcceleratedRaycast=!0;const t=e.testObject;this.ignoreSkinnedMeshes&&(e.testObject=o=>o instanceof jI?"continue in children":t?t(o):!0);const i=this.context.physics.raycast(e);return e.testObject=t,i}}puA([G()],Ts.prototype,"ignoreSkinnedMeshes",2);class IR extends Ts{constructor(){super(),this.ignoreSkinnedMeshes=!0}}const U_=class extends gw{performRaycast(A){if(!ke.active||!U_.allow||!(A!=null&&A.ray))return null;const e=A.ray.origin,t=.015;return this.context.physics.sphereOverlap(e,t,!1,!0)}};let sc=U_;c(sc,"allow",!0);class sR{static getObject(A){const e=A[hn];return e&&(e.isComponent===!0?A=e.gameObject:A=e),A}static isInteractable(A,e){if(e&&(e.canvasGroup=void 0,e.graphic=void 0),A==null||!A.visible||(A=this.getObject(A),!A.visible))return!1;const t=this.tryFindCanvasGroup(A);if((t==null?void 0:t.isCanvasGroup)===!0&&(e&&(e.canvasGroup=t),t.blocksRaycasts===!1||t.interactable===!1))return!1;const i=RQ(A,o=>{if(o.isGraphic===!0)return o},!1);return e&&(i==null?void 0:i.isGraphic)===!0&&(e.graphic=i),!((i==null?void 0:i.raycastTarget)===!1||(i==null?void 0:i.layer)===2)}static tryFindCanvasGroup(A){if(!A)return null;const e=RQ(A,t=>{const i=t;if(i.blocksRaycasts!==void 0&&i.interactable!==void 0)return i},!1);return e!==void 0?e:this.tryFindCanvasGroup(A.parent)}}function Mq(g){const A=g[hn];return A||(g.parent?Mq(g.parent):null)}function fuA(g){return g.isUI===!0||typeof g[hn]=="object"}function rk(g,A){if(!g)return;const e=g.material;if((e==null?void 0:e.isMaterial)===!0){const t=g.parent;t&&t.isText,e.side=A.doubleSided??!0?St:lg,e.shadowSide=A.doubleSided?St:lg,g.castShadow=A.castShadows?A.castShadows:!1,g.receiveShadow=A.receiveShadows?A.receiveShadows:!1}for(const t of g.children)rk(t,A)}function FE(g,A,e){g[A]===void 0&&console.warn("Field",A,"is undefined on",g);const t=Proxy.revocable(g[A],{set(I,s,n,a){const r=I[s],C=Reflect.set(I,s,n,a);return e(n,r),C}}),i=t.revoke,o=g[A];return t.revoke=()=>{g[A]=o,i()},g[A]=t.proxy,t}const oP=Symbol("Scheduled action");function DuA(g,A,e=Ci.OnBeforeRender){let t=g[oP];t||(t=g[oP]={});const i=A.name;t[e]||(t[e]={});const o=t[e];if(o[i])return;function*s(){A==null||A.call(g),o[i]=null}const n=g.startCoroutine(s(),e);o[i]=n}const Xr=gA("debugeventsystem");var rJ=(g=>(g.BeforeHandleInput="BeforeHandleInput",g.AfterHandleInput="AfterHandleInput",g))(rJ||{});const Ja=class extends NA{constructor(){super();c(this,"raycaster",[]);c(this,"pressedByID",new Map);c(this,"hoveredByID",new Map);c(this,"onPointerEvent",e=>{if(e===void 0||e.propagationStopped||e.defaultPrevented||e.used)return;const t=new Cu(this.context.input,e);this._currentPointerEventName=e.type,t.inputSource=this.context.input,t.isClick=e.isClick,t.isDoubleClick=e.isDoubleClick,t.isDown=e.type==ki.PointerDown,t.isUp=e.type==ki.PointerUp,t.isPressed=this.context.input.getPointerPressed(e.pointerId),Xr&&(t.isDown?console.log("DOWN",t.pointerId):t.isUp&&console.log("UP",t.pointerId),t.isClick&&console.log("CLICK",t.pointerId));const i=new Cr;e.hasRay?i.ray=e.ray:i.screenPoint=this.context.input.getPointerPositionRC(e.pointerId);const o=this.performRaycast(i);if(o){for(const s of o)s.event=e,e.intersections.push(s);e.origin.onPointerHits&&e.origin.onPointerHits({sender:this,event:e,hits:o})}Xr&&t.isClick&&Ri("EventSystem: "+t.pointerId+" - "+this.context.time.frame+" - Up:"+t.isUp+", Down:"+t.isDown);const I={sender:this,args:t,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:I})),this.handleIntersections(o,t),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:I}))});c(this,"_sortedHits",[]);c(this,"_testObjectsCache",new Map);c(this,"_currentlyActiveRaycaster",null);c(this,"_currentPointerEventName",null);c(this,"shouldRaycastObject",e=>{var o;let t=null;if(fuA(e)&&(t=(o=e[hn])==null?void 0:o.gameObject),this._testObjectsCache.has(e)||t&&this._testObjectsCache.has(t))return this._testObjectsCache.get(e)===!1?"continue in children":!0;{let I=nk(e,this._currentPointerEventName);if(!I&&t&&(I=nk(t,this._currentPointerEventName)),I){this._testObjectsCache.set(e,!0);for(const s of e.children)this.shouldRaycastObject_AddToYesCache(s);return!0}return this._testObjectsCache.set(e,!1),"continue in children"}});c(this,"_sortingBuffer",[]);c(this,"_noDepthTestingResults",[]);c(this,"out",{});c(this,"_capturedPointer",{});c(this,"pointerEnterSymbol",Symbol("pointerEnter"));c(this,"pointerExitSymbol",Symbol("pointerExit"));c(this,"currentActiveMeshUIComponents",[]);Ja.systems.push(this)}static createIfNoneExists(e){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Ja.systems.length<=0&&Ja.systems.push(...oA.findObjectsOfType(Ja,e)));for(const i of Ja.systems)if(i.context===e)return;const t=new uA;oA.addComponent(t,Ja),e.scene.add(t)}static get systems(){const e=Ue.Current;return this._eventSystemMap.has(e)||this._eventSystemMap.set(e,[]),this._eventSystemMap.get(e)}static get(e){const t=this._eventSystemMap.get(e);return t&&t.length>0?t[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(e,t,i=!1){qB.update(e,t,i)}static markUIDirty(e){qB.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){Ja.systems.splice(Ja.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!oA.findObjectOfType(gw,this.context)){const t=oA.addComponent(this.context.scene,Ts);this.raycaster.push(t),(VA()||Xr)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(e){var t;e&&this.raycaster&&!this.raycaster.includes(e)&&((t=this.raycaster)==null||t.push(e))}unregister(e){var i,o;const t=(i=this.raycaster)==null?void 0:i.indexOf(e);t!==void 0&&t!==-1&&((o=this.raycaster)==null||o.splice(t,1))}onEnable(){this.context.input.addEventListener(ki.PointerDown,this.onPointerEvent),this.context.input.addEventListener(ki.PointerUp,this.onPointerEvent),this.context.input.addEventListener(ki.PointerMove,this.onPointerEvent)}onDisable(){this.context.input.removeEventListener(ki.PointerDown,this.onPointerEvent),this.context.input.removeEventListener(ki.PointerUp,this.onPointerEvent),this.context.input.removeEventListener(ki.PointerMove,this.onPointerEvent)}onBeforeRender(){this.resetMeshUIStates()}shouldRaycastObject_AddToYesCache(e){this._testObjectsCache.set(e,!0);for(const t of e.children)this.shouldRaycastObject_AddToYesCache(t)}performRaycast(e){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,e||(e=new Cr),e.testObject=this.shouldRaycastObject;for(const t of this.raycaster){if(!t.activeAndEnabled)continue;this._currentlyActiveRaycaster=t;const i=t.performRaycast(e);this._currentlyActiveRaycaster=null,i&&i.length>0&&this._sortedHits.push(...i)}return this._sortedHits.sort((t,i)=>t.distance-i.distance),this._sortedHits}assignHitInformation(e,t){t?(e.intersection=t,e.point=t.point,e.normal=t.normal,e.face=t.face,e.distance=t.distance,e.instanceId=t.instanceId):(e.intersection=void 0,e.point=void 0,e.normal=void 0,e.face=void 0,e.distance=void 0,e.instanceId=void 0)}handleIntersections(e,t){var o;if(e!=null&&e.length){e=this.sortCandidates(e);for(const I of e){if(t.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(t,I),this.handleEventOnObject(I.object,t))return!0}}this.assignHitInformation(t,e==null?void 0:e[0]),this.invokePointerCapture(t);const i=this.hoveredByID.get(t.pointerId);return i&&this.propagatePointerExit(i.obj,i.data,null),this.hoveredByID.delete(t.pointerId),t.isUp&&((o=this.pressedByID.get(t.pointerId))==null||o.handlers.forEach(I=>this.invokeOnPointerUp(t,I)),this.pressedByID.delete(t.pointerId)),!1}sortCandidates(e){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let t=0;t<e.length;t++){const i=e[t],o=i.object;if(o.material&&o.material.depthTest===!1){this._noDepthTestingResults.push(i);continue}this._sortingBuffer.push(i)}for(const t of this._sortingBuffer)this._noDepthTestingResults.push(t);return this._noDepthTestingResults}handleEventOnObject(e,t){if(!this.testIsVisible(e))return t.isClick&&Xr&&console.log("not allowed",e),!1;if(t.pointerId===void 0)return Xr&&console.error("Event without pointer can't be handled",t),!1;t.object=e;const i=e.parent,o=t.isClick??!1;let I=null;if(i&&i.isUI){const C=(t.isPressed||t.isClick)??!1;if(i[hn]){const B=i[hn].gameObject;if(B){if(!sR.isInteractable(B,this.out))return!1;I=this.out.canvasGroup??null,this.handleMeshUIIntersection(e,C),e=B}}}o&&Xr&&console.log(this.context.time.frame,e);const s=this.hoveredByID.get(t.pointerId),n=s==null?void 0:s.obj;n!==e&&n&&this.propagatePointerExit(n,s.data,e);const r=this.hoveredByID.get(t.pointerId);if(r?(r.obj=e,r.data=t):this.hoveredByID.set(t.pointerId,{obj:e,data:t}),t.isDown){const C=this.pressedByID.get(t.pointerId);C?(C.obj=e,C.data=t):this.pressedByID.set(t.pointerId,{obj:e,data:t,handlers:new Set})}return(I===null||I.interactable)&&this.handleMainInteraction(e,t,n??null),!0}propagate(e,t){for(;e;)oA.foreachComponent(e,i=>{t(i)},!1),e=e.parent}handleMainInteraction(e,t,i){const o=this.pressedByID.get(t.pointerId),I=i!==e;let s=!0;switch(t.event.pointerType){case"mouse":case"touch":const n=this.context.input.getPointerPositionLastFrame(t.pointerId),a=this.context.input.getPointerPosition(t.pointerId);s=n&&!ie.approximately(n,a);break}this.propagate(e,n=>{var r;const a=n;a.interactable!==!1&&(!a.activeAndEnabled||!a.enabled||(a.onPointerEnter&&I&&this.handlePointerEnter(a,t),t.isDown&&a.onPointerDown&&(a.onPointerDown(t),o==null||o.handlers.add(a),this.handlePointerCapture(t,a)),a.onPointerMove&&(s&&a.onPointerMove(t),this.handlePointerCapture(t,a)),t.isUp&&(a.onPointerUp&&(this.invokeOnPointerUp(t,a),o==null||o.handlers.delete(a)),a.onPointerExit&&((r=t.event)==null?void 0:r.pointerType)===HM.Touch&&(this.handlePointerExit(a,t),this.hoveredByID.delete(t.pointerId))),t.isClick&&a.onPointerClick&&a.onPointerClick(t)))}),t.isUp&&(o==null||o.handlers.forEach(n=>{this.invokeOnPointerUp(t,n)}),this.pressedByID.delete(t.pointerId))}propagatePointerExit(e,t,i){this.propagate(e,o=>{if(!o.gameObject||o.destroyed)return;const I=o;if(I.onPointerExit||I.onPointerEnter){if(i&&this.isChild(i,o.gameObject))return;this.handlePointerExit(I,t)}})}invokeOnPointerUp(e,t){var i;(i=t.onPointerUp)==null||i.call(t,e),this.releasePointerCapture(e,t)}handlePointerEnter(e,t){e.onPointerEnter&&this.updatePointerState(e,t.pointerId,this.pointerEnterSymbol,!0)&&e.onPointerEnter(t),this.updatePointerState(e,t.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(e,t){e.onPointerExit&&this.updatePointerState(e,t.pointerId,this.pointerExitSymbol,!0)&&e.onPointerExit(t),this.updatePointerState(e,t.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(e,t,i,o){let I=e[i];if(o)return I&&I.includes(t)?!1:(I=I||[],I.push(t),e[i]=I,!0);{if(!I||!I.includes(t))return!1;const s=I.indexOf(t);return s!==-1&&I.splice(s,1),!0}}handlePointerCapture(e,t){if(e.z__pointer_ctured){e.z__pointer_ctured=!1;const i=e.pointerId;if(t.onPointerMove){const o=this._capturedPointer[i]||[];o.push(t),this._capturedPointer[i]=o}else VA()&&!t.z__warned_no_pointermove&&(t.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else e.z__pointer_cture_rleased&&(e.z__pointer_cture_rleased=!1,this.releasePointerCapture(e,t))}releasePointerCapture(e,t){const i=e.pointerId;if(this._capturedPointer[i]){const o=this._capturedPointer[i].indexOf(t);o!==-1&&(this._capturedPointer[i].splice(o,1),Xr&&console.log("released pointer capture",i,t,this._capturedPointer))}}invokePointerCapture(e){var t;if(e.event.type===ki.PointerMove){const i=e.pointerId,o=this._capturedPointer[i];if(o){Xr&&console.log("Captured",i,o);for(let I=0;I<o.length;I++){const s=o[I];if(s.destroyed){o.splice(I,1),I--;continue}(t=s.onPointerMove)==null||t.call(s,e)}}}}isChild(e,t){return!e||!t?!1:e===t?!0:e.parent?this.isChild(e.parent,t):!1}handleMeshUiObjectWithoutShadowDom(e,t){return!e||!e.isUI?!0:this.handleMeshUIIntersection(e,t)}handleMeshUIIntersection(e,t){const i=qB.updateState(e,t);return i&&this.currentActiveMeshUIComponents.push(i),i!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&qB.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let e=0;e<this.currentActiveMeshUIComponents.length;e++){const t=this.currentActiveMeshUIComponents[e];qB.resetState(t)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(e){return e?oA.isActiveSelf(e)?this.testIsVisible(e.parent):!1:!0}};let VI=Ja;c(VI,"_eventSystemMap",new Map),c(VI,"didSearchEventSystem",!1);class qB{static markDirty(){this.needsUpdate=!0}static update(A,e,t=!1){if(t){A.update();return}const i=e.time.frameCount;for(const o of this.lastUpdateFrame)if(o.context===e){if(i===o.frame)return;o.frame=i;let I=this.needsUpdate||i<1;o.nextUpdate<=i&&(I=!0),I&&(Xr&&console.log("Update threemeshui"),this.needsUpdate=!1,o.nextUpdate=i+60,A.update());return}this.lastUpdateFrame=[{context:e,frame:i,nextUpdate:i+60}],A.update(),this.needsUpdate=!1}static updateState(A,e){let t=null;if(A&&(t=this.findBlockInParent(A),t&&t!==this.lastSelected)){if(t.interactable===!1)return null;this.needsUpdate=!0}return t}static resetLastSelected(){const A=this.lastSelected;A&&(this.lastSelected=null,this.resetState(A))}static resetState(A){A&&(this.needsUpdate=!0)}static findBlockInParent(A){return A?A.isBlock?A:this.findBlockInParent(A.parent):null}}c(qB,"lastSelected",null),c(qB,"lastUpdateFrame",[]),c(qB,"needsUpdate",!1);var yuA=Object.defineProperty,wuA=Object.getOwnPropertyDescriptor,Ki=(g,A,e,t)=>{for(var i=t>1?void 0:t?wuA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&yuA(A,e,i),i};const HF=gA("debugorbit"),YF=gA("freecam"),Nm=gA("debugcamerafit"),Fm=gA("smoothcam"),muA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let OF;class zD extends CustomEvent{constructor(A,e){super("target-reached",{detail:{controls:A,type:e}})}}class Kt extends NA{constructor(){super(...arguments);c(this,"autoTarget",!0);c(this,"autoFit",!1);c(this,"enableRotate",!0);c(this,"autoRotate",!1);c(this,"autoRotateSpeed",1);c(this,"minAzimuthAngle",1/0);c(this,"maxAzimuthAngle",1/0);c(this,"minPolarAngle",0);c(this,"maxPolarAngle",Math.PI);c(this,"enableKeys",!1);c(this,"enableDamping",!0);c(this,"dampingFactor",.1);c(this,"enableZoom",!0);c(this,"minZoom",0);c(this,"maxZoom",1/0);c(this,"zoomSpeed",1);c(this,"zoomToCursor",!1);c(this,"enablePan",!0);c(this,"lookAtConstraint",null);c(this,"lookAtConstraint01",1);c(this,"allowInterrupt",!0);c(this,"middleClickToFocus",!0);c(this,"doubleClickToFocus",!0);c(this,"clickBackgroundToFitScene",2);c(this,"debugLog",!1);c(this,"targetLerpDuration",1);c(this,"_controls",null);c(this,"_cameraObject",null);c(this,"_lookTargetLerpActive",!1);c(this,"_lookTargetStartPosition",new S);c(this,"_lookTargetEndPosition",new S);c(this,"_lookTargetLerp01",0);c(this,"_lookTargetLerpDuration",0);c(this,"_cameraLerpActive",!1);c(this,"_cameraStartPosition",new S);c(this,"_cameraEndPosition",new S);c(this,"_cameraLerp01",0);c(this,"_cameraLerpDuration",0);c(this,"_fovLerpActive",!1);c(this,"_fovLerpStartValue",0);c(this,"_fovLerpEndValue",0);c(this,"_fovLerp01",0);c(this,"_fovLerpDuration",0);c(this,"_inputs",0);c(this,"_enableTime",0);c(this,"_startedListeningToKeyEvents",!1);c(this,"_eventSystem");c(this,"_afterHandleInputFn");c(this,"_camera",null);c(this,"_syncedTransform");c(this,"_didSetTarget",0);c(this,"targetElement",null);c(this,"_activePointerEvents");c(this,"_lastTimeClickOnBackground",-1);c(this,"_clickOnBackgroundCount",0);c(this,"_onPointerDown",e=>{this._activePointerEvents.push(e)});c(this,"_onPointerUp",e=>{for(let t=this._activePointerEvents.length-1;t>=0;t--){const i=this._activePointerEvents[t];if(i.pointerId===e.pointerId&&i.button===e.button){this._activePointerEvents.splice(t,1);break}}if(this.clickBackgroundToFitScene>0&&e.isClick&&e.button===0){if(e.hasRay||e.intersections.push(...this.context.physics.raycast()),e.intersections.length<=0){const t=this.context.time.time-this._lastTimeClickOnBackground;this._lastTimeClickOnBackground=this.context.time.time,this.clickBackgroundToFitScene<=1||t<this.clickBackgroundToFitScene*.15?(this._clickOnBackgroundCount+=1,this._clickOnBackgroundCount>=this.clickBackgroundToFitScene-1&&this.fitCamera(this.context.scene.children,{immediate:!1})):this._clickOnBackgroundCount=0}HF&&console.log(this.clickBackgroundToFitScene,e.intersections.length,this._clickOnBackgroundCount)}});c(this,"_onPointerUpLate",e=>{this.doubleClickToFocus&&e.isDoubleClick&&!e.used&&this.setTargetFromRaycast()});c(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});c(this,"_shouldDisable",!1);c(this,"__onPreRender",()=>{const e=this.context.pre_render_callbacks.indexOf(this.__onPreRender);e>=0&&this.context.pre_render_callbacks.splice(e,1),this.autoFit&&(this.autoFit=!1,this.fitCamera({centerCamera:"y",immediate:!0,objects:this.scene.children}))});c(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var t;(t=this.controls)==null||t.addEventListener("start",e)}get targetLerpSpeed(){return 5}set targetLerpSpeed(e){this.targetLerpDuration=1/e}awake(){this._didSetTarget=0,this._startedListeningToKeyEvents=!1}start(){this._eventSystem=VI.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(rJ.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(rJ.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._didSetTarget=0,this._enableTime=this.context.time.time;const e=oA.getComponent(this.gameObject,Vt);this._camera=e;let t=e==null?void 0:e.threeCamera;if(!t&&this.gameObject instanceof Ke&&(t=this.gameObject),t&&Ax(t,this,!0),!this._controls&&t instanceof Ke){this._cameraObject=t;const i=this.targetElement??this.context.renderer.domElement,o=t==null?void 0:t.quaternion.clone();this._controls=new hj(t,i),t==null||t.quaternion.copy(o),OF===void 0&&(OF={...this._controls.keys})}if(this._controls)if(YF&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,exports.DeviceUtilities.isMobileDevice()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),!this._startedListeningToKeyEvents&&this.enableKeys)this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(this.context.domElement);else try{this._controls.stopListenToKeyEvents()}catch{}this._syncedTransform=oA.getComponent(this.gameObject,Br)??void 0,this.context.pre_render_callbacks.push(this.__onPreRender),this._activePointerEvents=[],this.context.input.addEventListener("pointerdown",this._onPointerDown,{queue:ys.Early}),this.context.input.addEventListener("pointerup",this._onPointerUp,{queue:ys.Early}),this.context.input.addEventListener("pointerup",this._onPointerUpLate,{queue:ys.Late})}onDisable(){var e;if((e=this._camera)!=null&&e.threeCamera&&Ax(this._camera.threeCamera,this,!1),this._controls){this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted);try{this._controls.stopListenToKeyEvents()}catch{}this._startedListeningToKeyEvents=!1}this._activePointerEvents.length=0,this.context.input.removeEventListener("pointerdown",this._onPointerDown),this.context.input.removeEventListener("pointerup",this._onPointerUp),this.context.input.removeEventListener("pointerup",this._onPointerUpLate)}afterHandleInput(e){e.detail.args.pointerId===0&&(e.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!e.detail.args.isPressed||e.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var t,i,o,I;if(!this._controls)return;if(this._cameraObject!==this.context.mainCamera){this._controls.enabled=!1;return}if(this._controls.enabled=!0,(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&((t=this.context.input.getPointerPositionDelta(0))!=null&&t.length())||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!1),this._inputs=0,this.autoTarget&&this._didSetTarget++===0){const s=oA.getComponent(this.gameObject,Vt);if(s&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const n=_e(s.threeCamera),a=Math.max(.01,n.length()),r=new S(0,0,-a).applyMatrix4(s.threeCamera.matrixWorld);this.setLookTargetPosition(r,!0)}if(!this.setLookTargetFromConstraint()){const n=new Cr;n.screenPoint=new eA(0,0),n.lineThreshold=.1;const a=this.context.physics.raycast(n);a.length>0&&this.setLookTargetPosition(a[0].point,!0),Nm&&console.log("OrbitControls hits",...a)}}if(this.middleClickToFocus&&this.context.input.getPointerClicked(1)&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive||this._fovLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new zD(this,"camera"));else{const s=ie.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,s)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new zD(this,"lookat"));else{const s=ie.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,s)}if(this._fovLerpActive&&this._cameraObject){const s=this._cameraObject;if(this._fovLerp01+=this.context.time.deltaTime/this._fovLerpDuration,this._fovLerp01>=1)s.fov=this._fovLerpEndValue,this._fovLerpActive=!1;else{const n=ie.easeInOutCubic(this._fovLerp01);s.fov=ie.lerp(this._fovLerpStartValue,this._fovLerpEndValue,n)}s.updateProjectionMatrix()}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR&&!this._activePointerEvents.some(s=>s.used),this._controls.keys=this.enableKeys?OF:muA,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.zoomSpeed=this.zoomSpeed,this._controls.zoomToCursor=this.zoomToCursor,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,this._controls.minAzimuthAngle=this.minAzimuthAngle,this._controls.maxAzimuthAngle=this.maxAzimuthAngle,this._controls.minPolarAngle=this.minPolarAngle,this._controls.maxPolarAngle=this.maxPolarAngle,YF||(((o=(i=this._camera)==null?void 0:i.threeCamera)==null?void 0:o.type)==="PerspectiveCamera"?(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom,this._controls.minZoom=0,this._controls.maxZoom=1/0):(this._controls.minDistance=0,this._controls.maxDistance=1/0,this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom)),typeof Fm=="number"||Fm===!0){this._controls.enableDamping=!0;const s=typeof Fm=="number"?Fm:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,s))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!YF&&((I=this.lookAtConstraint)!=null&&I.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(this.context.time.deltaTime),HF&&le.DrawWireSphere(this._controls.target,.1,65280))}}setCameraAndLookTarget(e){if(!e||!(e instanceof uA))return;const t=_e(e),i=lL(e);this.setTargetFromRaycast(new bI(t,i)),this.setCameraTargetPosition(t)}setCameraTargetPosition(e,t=!1){var i;e&&(e instanceof uA&&(e=_e(e)),this._cameraEndPosition||(this._cameraEndPosition=new S),this._cameraEndPosition.copy(e),t===!0?(this._cameraLerpActive=!1,this._cameraObject&&this._cameraObject.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((i=this._cameraObject)==null?void 0:i.position),typeof t=="number"?this._cameraLerpDuration=t:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setFieldOfView(e,t=!1){var o;if(!this._controls||typeof e!="number")return;const i=(o=this._camera)==null?void 0:o.threeCamera;i&&(t===!0?i.fov=e:(this._fovLerpActive=!0,this._fovLerp01=0,this._fovLerpStartValue=i.fov,this._fovLerpEndValue=e,typeof t=="number"?this._fovLerpDuration=t:this._fovLerpDuration=this.targetLerpDuration))}setLookTargetPosition(e=null,t=!1){this._controls&&e&&(e instanceof uA&&(e=_e(e)),this._lookTargetEndPosition.copy(e),this._didSetTarget++,HF&&(console.warn("OrbitControls: setLookTargetPosition",e,t),le.DrawWireSphere(this._lookTargetEndPosition,.2,16711680,2)),t===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof t=="number"?this._lookTargetLerpDuration=t:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(e=0,t=1){var o;if(!this._controls)return!1;const i=(o=this.lookAtConstraint)==null?void 0:o.sources;if(i&&i.length>0){const I=i[e];if(I)return I.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,t),!0}return!1}lerpTarget(e,t){return this.lerpLookTarget(e,t)}lerpLookTarget(e,t){this._controls&&(t>=1?this._controls.target.copy(e):this._controls.target.lerp(e,t))}setTargetFromRaycast(e){if(!this.controls)return;const t=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const i of t)if(i.distance>0&&oA.isActiveInHierarchy(i.object)){const o=Mq(i.object);if(o){const I=o.canvas;if(I!=null&&I.screenspace)break}this.setLookTargetPosition(i.point);break}}fitCamera(e,t){var N,K;if(this.context.isInXR)return;let i;if(Array.isArray(e)?i=e:e&&"type"in e?i=e.children:e&&"objects"in e&&(i=e==null?void 0:e.objects,t=e),i&&!Array.isArray(i)&&(i=i.children),(!Array.isArray(i)||i&&i.length<=0)&&(i=this.context.scene.children),!Array.isArray(i)||i.length<=0){console.warn("No objects to fit camera to...");return}const o=this._cameraObject,I=this._controls;if(!o||!I){console.warn("No camera or controls found to fit camera to objects...");return}t||(t={});const{immediate:s=!1,centerCamera:n="y",cameraNearFar:a="auto",fitOffset:r=1.1,fov:C=o==null?void 0:o.fov}=t,B=new S,l=new S,Q=Ls(i,void 0,(K=(N=this._camera)==null?void 0:N.threeCamera)==null?void 0:K.layers),d=Q.clone();o.updateMatrixWorld(),o.updateProjectionMatrix(),Q.getCenter(l);const h=new S;if(Q.getSize(h),Q.applyMatrix4(o.matrixWorldInverse),Q.getSize(B),Q.setFromCenterAndSize(l,B),Number.isNaN(B.x)||Number.isNaN(B.y)||Number.isNaN(B.z)){console.warn("Camera fit size resultet in NaN",o,Q,[...i]);return}if(B.length()<=1e-10){Nm&&console.warn("Camera fit size is zero",Q,[...i]);return}const E=t.fov||o.fov,p=2*Math.atan(Math.tan(E*Math.PI/360/2)*o.aspect)/Math.PI*360,u=B.y/(2*Math.atan(Math.PI*E/360)),f=B.x/(2*Math.atan(Math.PI*p/360)),D=r*Math.max(u,f)+B.z/2;Nm&&console.log("Fit camera to objects",{fitHeightDistance:u,fitWidthDistance:f,distance:D,verticalFov:E,horizontalFov:p}),this.maxZoom=D*10,this.minZoom=D*.01;const y=.05,w=l.clone();if(w.y-=B.y*y,this.setLookTargetPosition(w,s),this.setFieldOfView(t.fov,s),this.autoTarget=!1,a==null||a=="auto"){const F=oA.findObjectOfType(ur),_=F?F.radius:0,J=Math.max(h.x,h.y,h.z,_);o.near=D/100,o.far=J+D*10,F&&(this.maxZoom=Math.max(Math.min(this.maxZoom,_*.5),D))}const k=I.getDistance();k<this.minZoom&&(this.minZoom=k*.9),k>this.maxZoom&&(this.maxZoom=k*1.1),o.updateMatrixWorld(),o.updateProjectionMatrix();const M=_e(o),m=l.clone();m.sub(M),n==="y"&&(m.y=0),m.normalize(),m.multiplyScalar(D),n==="y"&&(m.y+=-y*4*D);let U=l.clone().sub(m);if(o.parent&&(U=o.parent.worldToLocal(U)),this.setCameraTargetPosition(U,s),Nm){const F=new xv(Q);this.context.scene.add(F),EL(F,qy(o)),setTimeout(()=>{this.context.scene.remove(F)},1e4),le.DrawWireBox3(d,65280,10),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",_=>{if(_.code==="KeyF"){let J;this._cameraObject instanceof Ke&&(J=Math.random()*Math.random()*170+10),this.fitCamera({objects:i,fitOffset:r,immediate:!1,fov:J})}_.code==="KeyV"&&this._cameraObject instanceof Ke&&(this._cameraObject.fov=60)}))}I.update()}}Ki([G()],Kt.prototype,"autoTarget",2);Ki([G()],Kt.prototype,"autoFit",2);Ki([G()],Kt.prototype,"enableRotate",2);Ki([G()],Kt.prototype,"autoRotate",2);Ki([G()],Kt.prototype,"autoRotateSpeed",2);Ki([G()],Kt.prototype,"minAzimuthAngle",2);Ki([G()],Kt.prototype,"maxAzimuthAngle",2);Ki([G()],Kt.prototype,"minPolarAngle",2);Ki([G()],Kt.prototype,"maxPolarAngle",2);Ki([G()],Kt.prototype,"enableKeys",2);Ki([G()],Kt.prototype,"enableDamping",2);Ki([G()],Kt.prototype,"dampingFactor",2);Ki([G()],Kt.prototype,"enableZoom",2);Ki([G()],Kt.prototype,"minZoom",2);Ki([G()],Kt.prototype,"maxZoom",2);Ki([G()],Kt.prototype,"zoomSpeed",2);Ki([G()],Kt.prototype,"enablePan",2);Ki([G(ZQ)],Kt.prototype,"lookAtConstraint",2);Ki([G()],Kt.prototype,"lookAtConstraint01",2);Ki([G()],Kt.prototype,"allowInterrupt",2);Ki([G()],Kt.prototype,"middleClickToFocus",2);Ki([G()],Kt.prototype,"doubleClickToFocus",2);Ki([G()],Kt.prototype,"clickBackgroundToFitScene",2);Ki([G()],Kt.prototype,"targetLerpDuration",2);var SuA=Object.defineProperty,GuA=Object.getOwnPropertyDescriptor,KI=(g,A,e,t)=>{for(var i=t>1?void 0:t?GuA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&SuA(A,e,i),i},nc=(g=>(g[g.None=0]="None",g[g.Skybox=1]="Skybox",g[g.SolidColor=2]="SolidColor",g[g.Uninitialized=4]="Uninitialized",g))(nc||{});const RB=gA("debugcam"),IP=gA("debugscreenpointtoray");var yS;const Ef=(yS=class extends NA{constructor(){super(...arguments);c(this,"_nearClipPlane",.1);c(this,"_farClipPlane",1e3);c(this,"orthographic",!1);c(this,"orthographicSize",5);c(this,"ARBackgroundAlpha",0);c(this,"_cullingMask",4294967295);c(this,"_backgroundBlurriness");c(this,"_backgroundIntensity");c(this,"_backgroundRotation");c(this,"_environmentIntensity");c(this,"_targetTexture",null);c(this,"_backgroundColor");c(this,"_fov");c(this,"_cam",null);c(this,"_clearFlags",2);c(this,"_skybox");c(this,"_frustum");c(this,"_projScreenMatrix",new lA)}get isCamera(){return!0}get aspect(){return this._cam instanceof Ke?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(A){this._cam instanceof Ke&&this._cam.aspect!==A&&(this._cam.aspect=A,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof Ke?this._cam.fov:this._fov}set fieldOfView(A){const e=this.fieldOfView!=A;if(this._fov=A,e&&this._cam&&this._cam instanceof Ke){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(A){const e=this._nearClipPlane!=A;this._nearClipPlane=A,this._cam&&(e||this._cam.near!=A)&&(this._cam.near=A,this._cam.updateProjectionMatrix())}applyClippingPlane(){this._cam&&(this._cam.near=this._nearClipPlane,this._cam.far=this._farClipPlane,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(A){const e=this._farClipPlane!=A;this._farClipPlane=A,this._cam&&(e||this._cam.far!=A)&&(this._cam.far=A,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(A){A!==this._clearFlags&&(this._clearFlags=A,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(A){this._cullingMask=A,this._cam&&(this._cam.layers.mask=A)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(A){this.cullingMask=(1<<A|0)>>>0}set backgroundBlurriness(A){A!==this._backgroundBlurriness&&(A===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(A,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(A){A!==this._backgroundIntensity&&(A===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(A,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set backgroundRotation(A){A!==this._backgroundRotation&&(A===void 0?this._backgroundRotation=void 0:this._backgroundRotation=A,this.applyClearFlagsIfIsActiveCamera())}get backgroundRotation(){return this._backgroundRotation}set environmentIntensity(A){this._environmentIntensity=A}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(A){if(A){if(this._backgroundColor)this._backgroundColor.copy(A);else{if(!A.clone)return;this._backgroundColor=A.clone()}A.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(A){this._targetTexture=A}get targetTexture(){return this._targetTexture}get cam(){return this.threeCamera}get threeCamera(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(A,e,t){const i=this.threeCamera,o=Ef._origin;o.set(A,e,-1),this.context.input.convertScreenspaceToRaycastSpace(o),IP&&console.log("screenPointToRay",A.toFixed(2),e.toFixed(2),"now:",o.x.toFixed(2),o.y.toFixed(2),"isInXR:"+this.context.isInXR),o.z=-1,o.unproject(i);const I=Ef._direction.set(o.x,o.y,o.z),s=_e(i);return I.sub(s),I.normalize(),t?(t.set(s,I),t):new bI(s.clone(),I.clone())}getFrustum(){return this._frustum||(this._frustum=new fQ,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new fQ),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(A,e){return e&&this._projScreenMatrix.multiplyMatrices(this.threeCamera.projectionMatrix,this.threeCamera.matrixWorldInverse),A===this._projScreenMatrix?A:A.copy(this._projScreenMatrix)}awake(){IP&&window.addEventListener("pointerdown",A=>{const e=A.clientX,t=A.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const i=this.screenPointToRay(e,t),o="#"+Math.floor(Math.random()*16777215).toString(16);le.DrawRay(i.origin,i.direction,o,10)})}onEnable(){RB&&console.log(`Camera enabled: "${this.name}". ClearFlags=${nc[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),MuA(this)),this.applyClearFlagsIfIsActiveCamera({applySkybox:!0})}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._frustum&&this.updateFrustum(),this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),this._targetTexture)){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const A=this.context.renderer;if(A){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,A),e==null||e.applyClearFlags()}}}buildCamera(){if(this._cam)return;const A=this.gameObject.isCamera;let e=null;if(A?(e=this.gameObject,e==null||e.layers.enableAll(),e instanceof Ke&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof Ke&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new Ke(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const t=this.orthographicSize*100;e=new Qr(window.innerWidth/-t,window.innerWidth/t,window.innerHeight/t,window.innerHeight/-t,this._nearClipPlane,this._farClipPlane),this.gameObject.add(e)}this._cam=e,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(A){this.context.mainCameraComponent===this&&this.applyClearFlags(A)}applyClearFlags(A){var e;if(!this._cam){RB&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,RB){const t=`Camera "${this.name}" clear flags: ${nc[this._clearFlags]}`;console.debug(t)}switch(this._clearFlags){case 0:return;case 1:if(Ef.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}(!this.scene.background||!this._skybox||(A==null?void 0:A.applySkybox)===!0)&&this.applySceneSkybox(),this._backgroundBlurriness!==void 0?this.context.scene.backgroundBlurriness=this._backgroundBlurriness:RB&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity),this._backgroundRotation!==void 0?this.context.scene.backgroundRotation=this._backgroundRotation:RB&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let t=this._backgroundColor.alpha;Ef.backgroundShouldBeTransparent(this.context)&&(t=this.ARBackgroundAlpha??0),this.context.scene.background=null,(e=this.context.xr)!=null&&e.isVR?this.context.renderer.setClearColor(uV(this._backgroundColor).convertLinearToSRGB()):this.context.renderer.setClearColor(this._backgroundColor,t)}else RB&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}applySceneSkybox(){this._skybox||(this._skybox=new kuA(this)),this._skybox.apply()}static backgroundShouldBeTransparent(A){var o,I,s,n;const e=(o=A.renderer.xr)==null?void 0:o.getSession();if(!e)return!1;if(typeof e._transparent=="boolean")return e._transparent;const t=e.environmentBlendMode;RB&&Ri("Environment blend mode: "+t+" on "+navigator.userAgent);let i=t==="additive"||t==="alpha-blend";return A.isInAR&&t==="opaque"&&((I=navigator.userAgent)!=null&&I.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&((n=navigator.userAgent)!=null&&n.includes("Mobile WebXRViewer/v2")))&&(i=!0),e._transparent=i,i}},c(yS,"_origin",new S),c(yS,"_direction",new S),yS);let Vt=Ef;KI([G()],Vt.prototype,"aspect",1);KI([G()],Vt.prototype,"fieldOfView",1);KI([G()],Vt.prototype,"nearClipPlane",1);KI([G()],Vt.prototype,"farClipPlane",1);KI([G()],Vt.prototype,"clearFlags",1);KI([G()],Vt.prototype,"orthographic",2);KI([G()],Vt.prototype,"orthographicSize",2);KI([G()],Vt.prototype,"ARBackgroundAlpha",2);KI([G()],Vt.prototype,"cullingMask",1);KI([G()],Vt.prototype,"backgroundBlurriness",1);KI([G()],Vt.prototype,"backgroundIntensity",1);KI([G(at)],Vt.prototype,"backgroundRotation",1);KI([G()],Vt.prototype,"environmentIntensity",1);KI([G(Lt)],Vt.prototype,"backgroundColor",1);KI([G(Ic)],Vt.prototype,"targetTexture",1);class kuA{constructor(A){c(this,"_camera");c(this,"_skybox");this._camera=A}get context(){var A;return(A=this._camera)==null?void 0:A.context}apply(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(RB&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=MI,this.context.scene.background=this._skybox):this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" has no skybox texture. ${this._camera.sourceId}`))}}function MuA(g){gA("freecam")&&g.context.mainCameraComponent===g&&oA.getOrAddComponent(g.gameObject,Kt)}class ac extends NA{constructor(){super(...arguments);c(this,"_listener",null);c(this,"onInteraction",()=>{this.destroyed||this.listener==null||this.addListenerIfItExists()})}get listener(){return this._listener==null&&(this._listener=new eW),this._listener}onEnable(){sa.registerWaitForInteraction(this.onInteraction),this.addListenerIfItExists()}onDisable(){sa.unregisterWaitForInteraction(this.onInteraction),this.removeListenerIfItExists()}addListenerIfItExists(){const e=this._listener;if(!e||e!=null&&e.parent)return;const t=this.context.mainCameraComponent||oA.getComponentInParent(this.gameObject,Vt);t!=null&&t.threeCamera?t.threeCamera.add(e):this.gameObject.add(e),e.filter?(e.gain.connect(e.filter),e.filter.connect(e.context.destination)):e.gain.connect(e.context.destination)}removeListenerIfItExists(){const e=this._listener;e&&(e.removeFromParent(),e.filter&&e.filter.disconnect(),e.gain&&e.gain.disconnect())}}var RuA=Object.defineProperty,UuA=Object.getOwnPropertyDescriptor,da=(g,A,e,t)=>{for(var i=t>1?void 0:t?UuA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&RuA(A,e,i),i};const Zo=gA("debugaudio"),UB=class extends NA{constructor(){super(...arguments);c(this,"clip","");c(this,"playOnAwake",!1);c(this,"preload",!1);c(this,"playInBackground",!0);c(this,"_spatialBlend",0);c(this,"_minDistance",1);c(this,"_maxDistance",100);c(this,"_volume",1);c(this,"rollOffMode",0);c(this,"_loop",!1);c(this,"sound",null);c(this,"helper",null);c(this,"wasPlaying",!1);c(this,"audioLoader",null);c(this,"shouldPlay",!1);c(this,"_lastClipStartedLoading",null);c(this,"_audioElement",null);c(this,"onVisibilityChanged",()=>{switch(document.visibilityState){case"hidden":(this.playInBackground===!1||exports.DeviceUtilities.isMobileDevice())&&(this.wasPlaying=this.isPlaying,this.isPlaying&&this.pause());break;case"visible":Zo&&console.log("visible",this.enabled,this.playOnAwake,!this.isPlaying,UB.userInteractionRegistered,this.wasPlaying),this.enabled&&this.playOnAwake&&!this.isPlaying&&UB.userInteractionRegistered&&this.wasPlaying&&this.play();break}});c(this,"onApplicationMuteChanged",()=>{var A,e;this.context.application.muted?(A=this.sound)==null||A.setVolume(0):(e=this.sound)==null||e.setVolume(this.volume)});c(this,"createAudio",A=>{Zo&&console.log("AudioBuffer finished loading",A);const e=this.Sound;if(!e){Zo&&console.warn("Failed getting sound?",this.name);return}e.isPlaying&&e.stop(),A&&e.setBuffer(A),e.loop=this._loop,this.context.application.muted?e.setVolume(0):e.setVolume(this.volume),e.autoplay=this.shouldPlay&&UB.userInteractionRegistered,this.applySpatialDistanceSettings(),e.isPlaying&&e.stop(),UB.registerWaitForAllowAudio(this.__onAllowAudioCallback)});c(this,"__onAllowAudioCallback",()=>{this.shouldPlay&&this.play()});c(this,"_lastContextTime",0);c(this,"_hasEnded",!0);c(this,"_needUpdateSpatialDistanceSettings",!1)}static get userInteractionRegistered(){return sa.userInteractionRegistered}static registerWaitForAllowAudio(A){sa.registerWaitForInteraction(A)}get isPlaying(){var A;return((A=this.sound)==null?void 0:A.isPlaying)??!1}get duration(){var A,e;return(e=(A=this.sound)==null?void 0:A.buffer)==null?void 0:e.duration}get time01(){var e;const A=this.duration;return A&&this.sound?((e=this.sound)==null?void 0:e.context.currentTime)/A:0}set time01(A){const e=this.duration;e&&this.sound&&(this.time=A*e)}get time(){var A,e;return(A=this.sound)!=null&&A.source?((e=this.sound.source)==null?void 0:e.context.currentTime)-this._lastContextTime+this.sound.offset:0}set time(A){if(this.sound){if(A===this.sound.offset)return;const e=this.isPlaying;this.stop(),this.sound.offset=A,e&&this.play()}}get loop(){return this.sound&&(this._loop=this.sound.getLoop()),this._loop}set loop(A){this._loop=A,this.sound&&this.sound.setLoop(A)}get spatialBlend(){return this._spatialBlend}set spatialBlend(A){A!==this._spatialBlend&&(this._spatialBlend=A,this._needUpdateSpatialDistanceSettings=!0)}get minDistance(){return this._minDistance}set minDistance(A){this._minDistance!==A&&(this._minDistance=A,this._needUpdateSpatialDistanceSettings=!0)}get maxDistance(){return this._maxDistance}set maxDistance(A){this._maxDistance!==A&&(this._maxDistance=A,this._needUpdateSpatialDistanceSettings=!0)}get volume(){return this._volume}set volume(A){this._volume=A,this.sound&&!this.context.application.muted&&(Zo&&console.log(this.name,"audio set volume",A),this.sound.setVolume(A))}set pitch(A){this.sound&&this.sound.setPlaybackRate(A)}get pitch(){return this.sound?this.sound.getPlaybackRate():1}get Sound(){var A;if(!this.sound&&UB.userInteractionRegistered){let e=oA.getComponent(this.context.mainCamera,ac)??oA.findObjectOfType(ac,this.context);!e&&this.context.mainCamera&&(e=oA.addComponent(this.context.mainCamera,ac)),e!=null&&e.listener?(this.sound=new tW(e.listener),(A=this.gameObject)==null||A.add(this.sound)):Zo&&console.warn("No audio listener found in scene - can not play audio")}return this.sound}get ShouldPlay(){return this.shouldPlay}get audioContext(){var A;return(A=this.sound)==null?void 0:A.context}awake(){Zo&&console.log(this),this.audioLoader=new UG,this.playOnAwake&&(this.shouldPlay=!0),this.preload&&typeof this.clip=="string"&&this.audioLoader.load(this.clip,this.createAudio,()=>{},console.error)}onEnable(){this.sound&&this.gameObject.add(this.sound),UB.userInteractionRegistered?this.playOnAwake&&this.context.application.isVisible&&this.play():UB.registerWaitForAllowAudio(()=>{this.enabled&&!this.destroyed&&this.shouldPlay&&this.onNewClip(this.clip)}),globalThis.addEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.addEventListener($G.MuteChanged,this.onApplicationMuteChanged)}onDisable(){globalThis.removeEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.removeEventListener($G.MuteChanged,this.onApplicationMuteChanged),this.pause()}applySpatialDistanceSettings(){const A=this.sound;if(!A)return;this._needUpdateSpatialDistanceSettings=!1;const e=ie.lerp(10*this._maxDistance/Math.max(1e-4,this.spatialBlend),this._minDistance,this.spatialBlend);switch(Zo&&console.log(this.name,this._minDistance,this._maxDistance,this.spatialBlend,"Ref distance="+e),A.setRefDistance(e),A.setMaxDistance(Math.max(.01,this._maxDistance)),this.rollOffMode){case 0:A.setDistanceModel("exponential");break;case 1:A.setDistanceModel("linear");break;case 2:console.warn("Custom rolloff for AudioSource is not supported: "+this.name);break}this.spatialBlend>0?Zo&&!this.helper&&(this.helper=new _dA(A,A.getRefDistance()),A.add(this.helper)):this.helper&&this.helper.parent&&this.helper.removeFromParent()}async onNewClip(A){if(A&&(this.clip=A),typeof A=="string")if(Zo&&console.log(A),A.endsWith(".mp3")||A.endsWith(".wav")){if(this.audioLoader||(this.audioLoader=new UG),this.shouldPlay=!0,this._lastClipStartedLoading===A){Zo&&console.log("Is currently loading:",this._lastClipStartedLoading,this);return}this._lastClipStartedLoading=A,Zo&&console.log("load audio",A);const e=await this.audioLoader.loadAsync(A).catch(console.error);this._lastClipStartedLoading=null,e&&this.createAudio(e)}else console.warn("Unsupported audio clip type",A);else this.shouldPlay=!0,this.createAudio()}play(A=void 0){var t,i,o;!A&&this.clip&&(A=this.clip),A!==void 0&&typeof A!="string"&&!(A instanceof MediaStream)&&(VA()&&console.warn("Called play on AudioSource with unknown argument type:",A+`
5957
5957
  Using the assigned clip instead:`,this.clip),A=this.clip);let e=!this.sound||A&&A!==this.clip;if(typeof A=="string"&&!this.audioLoader&&(e=!0),(A instanceof MediaStream||typeof A=="string")&&(this.clip=A),e){this.shouldPlay=!0,this.onNewClip(A);return}if(this.shouldPlay=!0,this._hasEnded=!1,Zo&&console.log("play",(t=this.sound)==null?void 0:t.getVolume(),this.sound),this.sound&&!this.sound.isPlaying){const I=this.context.application.muted;I&&this.sound.setVolume(0),(i=this.gameObject)==null||i.add(this.sound),this.clip instanceof MediaStream?(this.sound.setMediaStreamSource(this.clip),this._audioElement||(this._audioElement=document.createElement("audio"),this._audioElement.style.display="none"),this._audioElement.parentNode||(o=this.context.domElement.shadowRoot)==null||o.append(this._audioElement),this._audioElement.srcObject=this.clip,this._audioElement.autoplay=!1):(this._audioElement&&this._audioElement.remove(),this.sound.play(I?.1:0))}}pause(){var A,e;Zo&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.isPlaying&&this.sound.source&&(this._lastContextTime=(A=this.sound)==null?void 0:A.context.currentTime,this.sound.pause()),(e=this._audioElement)==null||e.remove()}stop(){var A,e;Zo&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.source&&(this._lastContextTime=(A=this.sound)==null?void 0:A.context.currentTime,Zo&&console.log(this._lastContextTime),this.sound.stop()),(e=this._audioElement)==null||e.remove()}update(){this.helper&&(this.isPlaying&&this.helper.update(),this.helper.visible=this.isPlaying),this._needUpdateSpatialDistanceSettings&&this.applySpatialDistanceSettings(),this.sound&&!this.sound.isPlaying&&this.shouldPlay&&!this._hasEnded&&(this._hasEnded=!0,Zo&&console.log("Audio clip ended",this.clip),this.dispatchEvent(new CustomEvent("ended",{detail:this})))}};let Yi=UB;da([G(URL)],Yi.prototype,"clip",2);da([G()],Yi.prototype,"playOnAwake",2);da([G()],Yi.prototype,"preload",2);da([G()],Yi.prototype,"playInBackground",2);da([G()],Yi.prototype,"loop",1);da([G()],Yi.prototype,"spatialBlend",1);da([G()],Yi.prototype,"minDistance",1);da([G()],Yi.prototype,"maxDistance",1);da([G()],Yi.prototype,"volume",1);da([G()],Yi.prototype,"pitch",1);da([G()],Yi.prototype,"rollOffMode",2);var NuA=Object.defineProperty,FuA=Object.getOwnPropertyDescriptor,nR=(g,A,e,t)=>{for(var i=t>1?void 0:t?FuA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&NuA(A,e,i),i};const buA=gA("debugsignals");class ow{constructor(){c(this,"guid")}}nR([G()],ow.prototype,"guid",2);class Bu{constructor(){c(this,"signal");c(this,"reaction")}}nR([G(ow)],Bu.prototype,"signal",2);nR([G(ti)],Bu.prototype,"reaction",2);var Pb;const zr=(Pb=class extends NA{constructor(){super(...arguments);c(this,"events")}static invoke(A){if(zr.receivers[A]){const e=zr.receivers[A];if(!e)return;for(const t of e)t.invoke(A)}}awake(){buA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const A of this.events)zr.receivers[A.signal.guid]||(zr.receivers[A.signal.guid]=[]),zr.receivers[A.signal.guid].push(this)}onDisable(){if(this.events){for(const A of this.events)if(zr.receivers[A.signal.guid]){const e=zr.receivers[A.signal.guid].indexOf(this);e>=0&&zr.receivers[A.signal.guid].splice(e,1)}}}invoke(A){if(!this.events||!Array.isArray(this.events))return;const e=typeof A=="object"?A.guid:A;for(const t of this.events)if(t.signal.guid===e)try{if(t.reaction){if(!t.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",t,this);continue}}else{console.warn("Missing reaction for signal",t,this);continue}t.reaction.invoke()}catch(i){console.error(i)}}},c(Pb,"receivers",{}),Pb);let cu=zr;nR([G(Bu)],cu.prototype,"events",2);var ds=(g=>(g.Activation="ActivationTrack",g.Animation="AnimationTrack",g.Audio="AudioTrack",g.Control="ControlTrack",g.Marker="MarkerTrack",g.Signal="SignalTrack",g))(ds||{}),Ka=(g=>(g[g.None=0]="None",g[g.Hold=1]="Hold",g[g.Loop=2]="Loop",g[g.PingPong=3]="PingPong",g[g.Continue=4]="Continue",g))(Ka||{}),Rq=(g=>(g.Signal="SignalEmitter",g))(Rq||{}),KuA=Object.defineProperty,xuA=Object.getOwnPropertyDescriptor,yj=(g,A,e,t)=>{for(var i=t>1?void 0:t?xuA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&KuA(A,e,i),i};const Yr=gA("debugtimeline");var Zb;const CJ=(Zb=class extends NA{constructor(){super(...arguments);c(this,"playableAsset");c(this,"playOnAwake");c(this,"extrapolationMode",1);c(this,"waitForAudio",!0);c(this,"_visibilityChangeEvt");c(this,"_clonedPlayableAsset",!1);c(this,"_speed",1);c(this,"_guidsMap");c(this,"_isPlaying",!1);c(this,"_internalUpdateRoutine");c(this,"_isPaused",!1);c(this,"_isStopping",!1);c(this,"_time",0);c(this,"_duration",0);c(this,"_weight",1);c(this,"_animationTracks",[]);c(this,"_audioTracks",[]);c(this,"_signalTracks",[]);c(this,"_controlTracks",[]);c(this,"_customTracks",[]);c(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]);c(this,"animationCallbackReceivers",[])}static registerCreateTrack(A,e){this.createTrackFunctions[A]=e}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(A){typeof A=="number"&&!Number.isNaN(A)?this._time=A:(Yr||UI())&&console.error("INVALID TIMELINE.TIME VALUE",A,this.name)}get duration(){return this._duration}set duration(A){this._duration=A}get weight(){return this._weight}set weight(A){this._weight=A}get speed(){return this._speed}set speed(A){this._speed=A}awake(){var A,e,t,i,o;Yr&&console.log(this,(A=this.playableAsset)==null?void 0:A.tracks),this.rebuildGraph(),!this.isValid()&&(Yr||VA())&&(Yr?console.warn("PlayableDirector is not valid","Asset?",this.playableAsset,"Tracks:",(e=this.playableAsset)==null?void 0:e.tracks,"IsArray?",Array.isArray((t=this.playableAsset)==null?void 0:t.tracks),this):(o=(i=this.playableAsset)==null?void 0:i.tracks)!=null&&o.length?console.warn("PlayableDirector is not valid"):console.warn("PlayableDirector has no tracks"))}onEnable(){var A,e,t;for(const i of this._audioTracks)(A=i.onEnable)==null||A.call(i);for(const i of this._customTracks)(e=i.onEnable)==null||e.call(i);for(const i of this._animationTracks)(t=i.onEnable)==null||t.call(i);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var A,e,t;this.stop();for(const i of this._audioTracks)(A=i.onDisable)==null||A.call(i);for(const i of this._customTracks)(e=i.onDisable)==null||e.call(i);for(const i of this._animationTracks)(t=i.onDisable)==null||t.call(i);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var A;for(const e of this._allTracks)for(const t of e)(A=t.onDestroy)==null||A.call(t)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const A=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,A&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const e=[];for(const t of this._audioTracks){const i=t.loadAudio(this._time,1,0);i&&e.push(i)}if(e.length>0&&(await Promise.all(e),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!Yi.userInteractionRegistered&&this.waitForAudio;)await Ca(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Ci.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const t of this._audioTracks)t.stop();const A=this._isPaused==!0,e=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),A&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,A&&!e&&this.invokePauseChangedMethodsOnTracks(),e&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const A of this._allTracks)for(const e of A)yield e}get animationTracks(){return this._animationTracks}get audioTracks(){return this._audioTracks}resolveGuids(A){this._guidsMap=A}invokePauseChangedMethodsOnTracks(){var A;for(const e of this.forEachTrack())(A=e.onPauseChanged)==null||A.call(e)}invokeStateChangedMethodsOnTracks(){var A;for(const e of this.forEachTrack())(A=e.onStateChanged)==null||A.call(e,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(A=!1){if(!this.isValid())return;let e=this._time;switch(this.extrapolationMode){case 0:this._speed>0?e=Math.min(e,this._duration):this._speed<0&&(e=Math.max(e,0)),this._time=e;break;case 1:e%=this._duration,this._time=e;break;case 2:if(e>this._duration){this.stop();return}break}const t=this._time;for(const i of this.playableAsset.tracks)if(!i.muted)switch(i.type){case ds.Activation:if(!A&&!this._isPlaying)continue;for(let o=0;o<i.outputs.length;o++){const I=i.outputs[o];if(typeof I=="object"){let s=!1;if(i.clips)for(const a of i.clips)a.start<=t&&t<=a.end&&(s=!0);const n=I;n.visible!==void 0&&n.visible!==s&&(n.visible=s,Yr&&console.warn(this.name,"set ActivationTrack-"+o,n.name,s,t))}}break}if(!this._isStopping)for(const i of this._animationTracks)i.evaluate(t);for(const i of this._audioTracks)i.evaluate(t);for(const i of this._signalTracks)i.evaluate(t);for(const i of this._controlTracks)i.evaluate(t);for(const i of this._customTracks)i.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=xy(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const A=this.findRoot(this.gameObject);for(const e of this.playableAsset.tracks){for(let t=e.outputs.length-1;t>=0;t--){let i=e.outputs[t];if(typeof i=="string"){this._guidsMap&&this._guidsMap[i]&&(i=this._guidsMap[i]);const o=oA.findByGuid(i,A);o===null||typeof o!="object"?(e.outputs.splice(t,1),console.warn("Failed to resolve binding",i,e.name,e.type)):(Yr&&console.log("Resolved binding",i,"to",o),e.outputs[t]=o)}else if(i===null){if(e.outputs.splice(t,1),CJ.createTrackFunctions[e.type])continue;e.type!==ds.Audio&&e.type!==ds.Control&&e.type!==ds.Marker&&e.type!==ds.Signal&&console.warn("Missing binding",i,e.name,e.type,this.name,this.playableAsset.name)}}if(e.type===ds.Control&&e.clips)for(let t=0;t<e.clips.length;t++){const i=e.clips[t];let o=i.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const I=oA.findByGuid(o,A);I===null||typeof I!="object"?console.warn("Failed to resolve sourceObject binding",o,e.name,i):(Yr&&console.log("Resolved binding",o,"to",I),i.asset.sourceObject=I)}}}}findRoot(A){return A.parent?this.findRoot(A.parent):A}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const A of this.playableAsset.tracks)if(A.muted!==!0){if(A.clips)for(const e of A.clips)e.end>this._duration&&(this._duration=e.end);if(A.markers)for(const e of A.markers)e.time>this._duration&&(this._duration=e.time+.001)}}}setupAndCreateTrackHandlers(){var e,t,i;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let A=oA.findObjectOfType(ac,this.context);for(const o of this.playableAsset.tracks){const I=o.type,s=CJ.createTrackFunctions[I];if(s!=null){const n=s(this,o);if(typeof n.evaluate=="function"){n.director=this,n.track=o,this._customTracks.push(n);continue}}if(o.type===ds.Animation){if(!o.clips||o.clips.length<=0){Yr&&console.warn("Animation track has no clips",o);continue}for(let n=o.outputs.length-1;n>=0;n--){let a=o.outputs[n];if(a instanceof uA){const C=oA.getOrAddComponent(a,No);C&&(a=C)}const r=(e=a==null?void 0:a.gameObject)==null?void 0:e.animations;if(r){const C=new aR;C.trackOffset=o.trackOffset,C.director=this,C.track=o;for(let B=0;B<o.clips.length;B++){const l=o.clips[B],Q=l.asset;if(!Q){console.error(`Timeline ${this.name}: clip #${B} on track "${o.name}" has no animation data`);continue}const d=Q.clip;let h=d;if((typeof h=="string"||typeof h=="number")&&(h=r.find(p=>p.name===d)),Yr&&console.log(Q,d,"→",h),!h){console.warn("Could not find animationClip for model",l,o.name,this.name,(t=this.playableAsset)==null?void 0:t.name,r,a);continue}a instanceof No&&a.runtimeAnimatorController&&(a.__internalDidAwakeAndStart||a.initializeRuntimeAnimatorController(),a.runtimeAnimatorController.mixer||a.runtimeAnimatorController.bind(a),C.mixer=a.runtimeAnimatorController.mixer),C.mixer||(C.mixer=new yM(a.gameObject),this.context.animations.registerAnimationMixer(C.mixer)),C.clips.push(h),C.mixer.uncacheAction(h),C.createHooks(l.asset,h);const E=C.mixer.clipAction(h);C.actions.push(E),C.models.push(l)}this._animationTracks.push(C)}}}else if(o.type===ds.Audio){if(!o.clips||o.clips.length<=0)continue;const n=new CQ;n.director=this,n.track=o,n.audioSource=o.outputs.find(a=>a instanceof Yi),this._audioTracks.push(n),A||(A=(i=this.context.mainCameraComponent)==null?void 0:i.gameObject.addComponent(ac)),n.listener=A.listener;for(let a=0;a<o.clips.length;a++){const r=o.clips[a];n.addModel(r)}}else if(o.type===ds.Marker){const n=new jD;if(n.director=this,n.track=o,o.markers)for(const a of o.markers)switch(a.type){case Rq.Signal:n.models.push(a),n.didTrigger.push(!1);break}if(n!==null&&n.models.length>0){const a=oA.getComponent(this.gameObject,cu);a&&(n.receivers.push(a),this._signalTracks.push(n))}}else if(o.type===ds.Signal){const n=new jD;if(n.director=this,n.track=o,o.markers)for(const a of o.markers)n.models.push(a),n.didTrigger.push(!1);for(const a of o.outputs)n.receivers.push(a);this._signalTracks.push(n)}else if(o.type===ds.Control){const n=new rR;if(n.director=this,n.track=o,o.clips)for(const a of o.clips)n.models.push(a);n.resolveSourceObjects(this.context),this._controlTracks.push(n)}}}setAudioTracksAllowPlaying(A){for(const e of this._audioTracks)e.onAllowAudioChanged(A)}registerAnimationCallback(A){this.animationCallbackReceivers.push(A)}unregisterAnimationCallback(A){const e=this.animationCallbackReceivers.indexOf(A);e!==-1&&this.animationCallbackReceivers.splice(e,1)}},c(Zb,"createTrackFunctions",{}),Zb);let Ec=CJ;yj([G()],Ec.prototype,"playOnAwake",2);yj([G()],Ec.prototype,"extrapolationMode",2);const $a=gA("debugtimeline");class Iw{constructor(){c(this,"director");c(this,"track")}get muted(){return this.track.muted}set muted(A){var e;A!==this.track.muted&&(this.track.muted=A,(e=this.onMuteChanged)==null||e.call(this))}*forEachClip(A=!1){var e;if((e=this.track)!=null&&e.clips)if(A)for(let t=this.track.clips.length-1;t>=0;t--)yield this.track.clips[t];else for(const t of this.track.clips)yield t}getClipTime(A,e){return e.clipIn+(A-e.start)*e.timeScale}getClipTimeNormalized(A,e){return(A-e.start)/e.duration}evaluateWeight(A,e,t,i=!0){if(e<0||e>=t.length)return 0;const o=t[e];if(i||A>=o.start&&A<=o.end){let I=1;const s=!1;if(o.easeInDuration>0){const n=Math.min((A-o.start)/o.easeInDuration,1);I*=n}if(o.easeOutDuration>0&&!s){const n=Math.min((o.end-A)/o.easeOutDuration,1);I*=n}return I}return 0}}class JuA{constructor(A){c(this,"clip");c(this,"rootPositionOffset");c(this,"rootQuaternionOffset");c(this,"rootStartPosition");c(this,"rootEndPosition");c(this,"rootStartQuaternion");c(this,"rootEndQuaternion");const e=A.getClip();this.clip=e;const t=A.getRoot(),i=t.name+".position",o=t.name+".quaternion";$a&&console.log(e.name,e.tracks,i);for(const I of e.tracks)if(!(I.times.length<=0)){if(I.name.endsWith(i))this.rootStartPosition=new S().fromArray(I.values,0),this.rootEndPosition=new S().fromArray(I.values,I.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),$a&&console.log(this.rootPositionOffset);else if(I.name.endsWith(o)&&(this.rootStartQuaternion=new GA().fromArray(I.values,0),this.rootEndQuaternion=new GA().fromArray(I.values,I.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),$a)){const s=new at().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",s)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class aR extends Iw{constructor(){super(...arguments);c(this,"models",[]);c(this,"trackOffset");c(this,"target");c(this,"mixer");c(this,"clips",[]);c(this,"actions",[]);c(this,"weight",1);c(this,"_actionOffsets",[]);c(this,"_didBind",!1);c(this,"_animator",null);c(this,"_useclipOffsets",!0);c(this,"_totalOffsetPosition",new S);c(this,"_totalOffsetRotation",new GA);c(this,"_totalOffsetPosition2",new S);c(this,"_totalOffsetRotation2",new GA);c(this,"_summedPos",new S);c(this,"_tempPos",new S);c(this,"_summedRot",new GA);c(this,"_tempRot",new GA);c(this,"_clipRotQuat",new GA)}onDisable(){var e;(e=this.mixer)==null||e.stopAllAction()}onDestroy(){this.director.context.animations.unregisterAnimationMixer(this.mixer)}onStateChanged(){this._animator&&$O(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,t){var r,C;if(((r=t.tracks)==null?void 0:r.length)<=0){console.warn("No tracks in AnimationClip",t);return}const i=t.tracks[0].name.split("."),o=i[i.length-2],I=o+".position",s=o+".quaternion";let n=!1,a=!1;for(const B of t.tracks)B.name.endsWith(I)?(n=!0,this.createPositionInterpolant(t,e,B)):B.name.endsWith(s)&&(a=!0,this.createRotationInterpolant(t,e,B));if(!n||!a){const B=(C=this.mixer)==null?void 0:C.getRoot(),l=t.tracks[0],Q=l.name.lastIndexOf("."),d=l.name.substring(0,Q),h=d.substring(d.lastIndexOf(".")+1),E=B.getObjectByName(h);if(E)if(n){if(!a){const p=t.tracks[0].name.substring(0,Q)+".quaternion";$a&&console.warn("Create quaternion track",h,E);const u=E.quaternion,f=new aa(p,[0,t.duration],[u.x,u.y,u.z,u.w,u.x,u.y,u.z,u.w]);t.tracks.push(f),this.createRotationInterpolant(t,e,f)}}else{const p=d+".position";$a&&console.warn("Create position track",h,E);const u=E.position,f=new rr(p,[0,t.duration],[u.x,u.y,u.z,u.x,u.y,u.z]);t.tracks.push(f),this.createPositionInterpolant(t,e,f)}}}bind(){if(!this._didBind){this._didBind=!0,$a&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const e of this.actions){const t=new JuA(e);this._actionOffsets.push(t)}this.target&&(this._animator=oA.getComponent(this.target,No)??null,this._animator&&$O(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,i=t.position,o=t.rotation;i&&i.x!==void 0&&(i.isVector3||(t.position=new S(i.x,i.y,i.z)),o.isQuaternion||(t.rotation=new GA(o.x,o.y,o.z,o.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new S(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new GA(t.x,t.y,t.z,t.w)))}}evaluate(e){var n,a,r,C,B,l,Q;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let t=0,i=0,o=!1,I=!1,s=0;for(let d=0;d<this.clips.length;d++){const h=this.models[d],E=this.actions[d],p=h.asset;E.weight=0;const u=e>=h.start&&e<=h.end,f=h.preExtrapolationMode,D=h.postExtrapolationMode,y=d<this.clips.length-1?this.models[d+1]:null;let w=u,k=!1;if(!w&&!o&&h.end<e&&D!==Ka.None?(!y||y.start>e)&&(w=!0,o=!0):d==0&&!w&&!I&&h.start>e&&f!==Ka.None&&(!y||y.start<e)&&(w=!0,k=!0,I=!0),w){let M=this.weight;M*=this.evaluateWeight(e,d,this.models,w),M*=this.director.weight;let m=u;if(k)switch(f){case Ka.Hold:break;case Ka.Loop:e+=h.start,m=!0;break;default:e+=h.start,m=!0;break}let U=this.getClipTime(e,h),N=0;const K=p.duration;if(k&&f===Ka.Hold&&(U=0),m){if(p.loop)for(N+=Math.floor(U/(K+1e-6));U>K;)U-=K}else if(!u&&o)switch(D){case Ka.Hold:U=this.getClipTime(h.end,h);break;case Ka.Loop:U%=K;break;case Ka.PingPong:const J=Math.floor(U/K)%2!==0;U%=K,J&&(U=K-U);break}h.reversed===!0?E.time=E.getClip().duration-U:E.time=U,E.timeScale=0;const F=Math.max(0,M);if(E.weight=F,s+=F,E.clampWhenFinished=!1,E.isRunning()||E.play(),this._useclipOffsets){const _=t==0?this._totalOffsetPosition:this._totalOffsetPosition2,J=t==0?this._totalOffsetRotation:this._totalOffsetRotation2;t<1&&(i=1-M),t+=1;const L=this._summedPos.set(0,0,0),q=this._tempPos.set(0,0,0),P=this._summedRot.identity(),j=this._tempRot.identity(),nA=p.rotation;nA&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(nA,M));const CA=this._actionOffsets[d];if(CA.hasOffsets)for(let FA=0;FA<N;FA++)CA.rootPositionOffset?q.copy(CA.rootPositionOffset):q.set(0,0,0),q.applyQuaternion(P),this._clipRotQuat&&q.applyQuaternion(this._clipRotQuat),CA.rootQuaternionOffset&&(j.copy(CA.rootQuaternionOffset),P.multiply(j)),L.add(q);this._clipRotQuat&&J.multiply(this._clipRotQuat),J.multiply(P),p.position&&L.add(p.position),_.add(L)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,i),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,i)),this.__mixerError===void 0&&($a||VA())&&((a=(n=this._animator)==null?void 0:n.runtimeAnimatorController)!=null&&a.mixer)&&this.mixer!==((C=(r=this._animator)==null?void 0:r.runtimeAnimatorController)==null?void 0:C.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(B=this._animator)!=null&&B.runtimeAnimatorController){const d=Math.max(0,1-s);(Q=(l=this._animator)==null?void 0:l.runtimeAnimatorController)==null||Q.update(d)}else this.mixer.update(e)}createRotationInterpolant(e,t,i){var n;const o=i.createInterpolant.bind(i),I=new GA;this.ensureTrackOffsets();const s=(n=this.trackOffset)==null?void 0:n.rotation;i.createInterpolant=()=>{const a=o(),r=a.evaluate.bind(a);return a.evaluate=C=>{var l;const B=r(C);if(I.set(B[0],B[1],B[2],B[3]),I.premultiply(this._totalOffsetRotation),s&&I.premultiply(s),this.director.animationCallbackReceivers)for(const Q of this.director.animationCallbackReceivers)(l=Q==null?void 0:Q.onTimelineRotation)==null||l.call(Q,this.director,this.target,C,I);return B[0]=I.x,B[1]=I.y,B[2]=I.z,B[3]=I.w,B},a}}createPositionInterpolant(e,t,i){var r,C;const o=i.createInterpolant.bind(i),I=new S;this.ensureTrackOffsets();const s=(r=this.trackOffset)==null?void 0:r.rotation,n=(C=this.trackOffset)==null?void 0:C.position;let a;i.createInterpolant=()=>{const B=o(),l=B.evaluate.bind(B);return B.evaluate=Q=>{var h,E,p;const d=l(Q);if(I.set(d[0],d[1],d[2]),t.removeStartOffset&&(a===void 0?(a=null,a=(E=(h=this._actionOffsets.find(u=>u.clip===e))==null?void 0:h.rootStartPosition)==null?void 0:E.clone()):a!=null&&a.isVector3&&I.sub(a)),I.applyQuaternion(this._totalOffsetRotation),I.add(this._totalOffsetPosition),s&&I.applyQuaternion(s),n&&(I.x-=n.x,I.y+=n.y,I.z+=n.z),this.director.animationCallbackReceivers)for(const u of this.director.animationCallbackReceivers)(p=u==null?void 0:u.onTimelinePosition)==null||p.call(u,this.director,this.target,Q,I);return d[0]=I.x,d[1]=I.y,d[2]=I.z,d},B}}}const vuA=gA("mutetimeline"),td=class extends Iw{constructor(){super(...arguments);c(this,"models",[]);c(this,"listener");c(this,"audio",[]);c(this,"audioContextTimeOffset",[]);c(this,"lastTime",0);c(this,"audioSource");c(this,"_audioLoader",null);c(this,"_playableDirectorResumed",!1)}getAudioFilePath(e){const t=this.director.sourceId;return Mc(t,e)}onAllowAudioChanged(e){for(let t=0;t<this.models.length;t++){const i=this.models[t];this.audio[t].setVolume(e?i.asset.volume:0)}}addModel(e){const t=new Fv(this.listener);this.audio.push(t);const i=e;i._didTriggerPlay=!1,this.models.push(i)}onDisable(){for(const e of this.audio)e.isPlaying&&e.stop();for(const e of this.models)e._didTriggerPlay=!1}onDestroy(){for(const e of this.audio)e.source&&(e==null||e.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}}stop(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}for(const e of this.models)e._didTriggerPlay=!1}onPauseChanged(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(e){if(vuA||this.track.muted||this.director.speed<0)return;const t=this.director.context.application.muted,i=this._playableDirectorResumed;this._playableDirectorResumed=!1;const o=t?.1:0;for(let I=0;I<this.models.length;I++){const s=this.models[I],n=this.audio[I],a=s.asset;if((!n||!n.buffer)&&this.isInTimeRange(s,e-1,e+1)&&this.handleAudioLoading(s,n),Yi.userInteractionRegistered!==!1&&!(n===null||!n.buffer))if(n.playbackRate=this.director.context.time.timeScale*this.director.speed,n.loop=a.loop,e>=s.start&&e<=s.end&&e<this.director.duration){if(!n.isPlaying||!this.director.isPlaying)(i||!s._didTriggerPlay&&this.lastTime<e)&&(s.duration*s.timeScale>.3?n.offset=s.clipIn+(e-s.start)*s.timeScale:n.offset=0,$a&&console.log("Timeline Audio ("+this.track.name+") play with offset "+n.offset+" - "+s.asset.clip),n.play(o),s._didTriggerPlay=!0);else{const C=s.clipIn+(e-s.start)*s.timeScale,B=n.context.currentTime-n._startedAt+n.offset;Math.abs(C-B)>.3&&(n.offset=C,n.stop(),n.play(o))}let r=a.volume;if(this.track.volume!==void 0&&(r*=this.track.volume),t&&(r=0),s.easeInDuration>0){const C=Math.min((e-s.start)/s.easeInDuration,1);r*=C}if(s.easeOutDuration>0){const C=Math.min((s.end-e)/s.easeOutDuration,1);r*=C}n.setVolume(r*this.director.weight)}else s._didTriggerPlay=!1,this.director.isPlaying&&n.isPlaying&&n.stop()}this.lastTime=e}loadAudio(e,t=0,i=0){let o=null;const I=e-i,s=e+t;for(const n of this.models)if(this.isInTimeRange(n,I,s)){const a=this.audio[this.models.indexOf(n)],r=this.handleAudioLoading(n,a);r!==null&&(o===null&&(o=[]),o.push(r))}return o!==null?Promise.all(o):null}isInTimeRange(e,t,i){return t<=e.start&&i>=e.end||t>=e.start&&t<=e.end||i>=e.start&&i<=e.end}static dispose(){td._audioBuffers.clear()}handleAudioLoading(e,t){this._audioLoader||(this._audioLoader=new UG);const i=this.getAudioFilePath(e.asset.clip);if(td._audioBuffers.get(i)){const I=td._audioBuffers.get(i);return I.then(s=>{s&&t.setBuffer(s)}),I}$a&&console.warn("LOAD audio track",i,this.director.sourceId);const o=new Promise((I,s)=>{this._audioLoader.load(i,n=>{t.setBuffer(n),I(n)},void 0,n=>{console.error("Error loading audio",n),I(null)})});return td._audioBuffers.set(i,o),o}};let CQ=td;c(CQ,"_audioBuffers",new Map);class jD extends Iw{constructor(){super(...arguments);c(this,"models",[]);c(this,"didTrigger",[]);c(this,"receivers",[])}evaluate(e){var i;if(this.track.muted)return;const t=this.director.context.time.deltaTime*1.5;for(let o=0;o<this.models.length;o++){const I=this.models[o],s=this.didTrigger[o],n=I.time-e;let a=!1;if(I.retroActive)a=n<=1e-6;else{const r=Math.abs(n);(r===0||r>=1e-5&&r<t)&&(a=!0)}if(a){if(!s)if($a&&console.log("Trigger signal",e,I.time,I),this.didTrigger[o]=!0,((i=this.receivers)==null?void 0:i.length)<=0)cu.invoke(I.asset);else for(const r of this.receivers)r&&r.invoke(I.asset)}else I.emitOnce||(this.didTrigger[o]=!1)}}}class rR extends Iw{constructor(){super(...arguments);c(this,"models",[]);c(this,"timelines",[]);c(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const o=this.models[t].asset;if(!o.sourceObject||typeof o.sourceObject!="object"){console.log("no source object, removing model",t,o),this.models.splice(t,1);continue}else{const I=oA.getComponent(o.sourceObject,Ec);this.timelines.push(I),I&&o.updateDirector&&(I.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let i=0;i<this.models.length;i++){const o=this.models[i],I=o.asset;if(e>=o.start&&e<=o.end){this._previousActiveModel=o;const s=this.getClipTime(e,o);if(I.controlActivation){const n=I.sourceObject;n.visible=!0}if(I.updateDirector){const n=this.timelines[i];n&&(n.isPlaying&&n.pause(),n.time=s,n.evaluate())}}else{const s=(t=this._previousActiveModel)==null?void 0:t.asset;if(I.controlActivation){const n=I.sourceObject;(s==null?void 0:s.sourceObject)!==n&&(n.visible=!1)}}}}}const LuA=gA("debugpost");let BJ=null;function quA(g){BJ=g}function wj(g){let A=g.gameObject;for(;A;){for(const e of zM(A))if(e.isPostProcessingManager===!0)return e;A=A.parent}return null}function TuA(g){let A=wj(g);if(!A)if(BJ){LuA&&console.warn("Adding postprocessing manager to the scene.");const e=g.scene;A=xs(e,BJ)}else VA()&&console.warn("No post processing manager found");return A}var _uA=Object.defineProperty,HuA=Object.getOwnPropertyDescriptor,mj=(g,A,e,t)=>{for(var i=t>1?void 0:t?HuA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&_uA(A,e,i),i};const YuA=gA("debugpost");class Ae{constructor(A){c(this,"isVolumeParameter",!0);c(this,"_isInitialized",!1);c(this,"_active",!0);c(this,"_value");c(this,"_valueRaw");c(this,"_defaultValue");c(this,"valueProcessor");c(this,"onValueChanged");A!==void 0&&this.initialize(A)}get isInitialized(){return this._isInitialized}initialize(A){A!==void 0&&(this._value=A,this._defaultValue=A,this._valueRaw=A,this._isInitialized=!0)}get overrideState(){return this._active}set overrideState(A){if(this._active===A)return;this._active=A;const e=A?this._valueRaw:this._defaultValue;this.processValue(e,!0)}get value(){return this._valueRaw}set value(A){this.isInitialized||this.initialize(A),this.processValue(A,!1)}set defaultValue(A){this._defaultValue=A}__init(){this.processValue(this._valueRaw,!0)}processValue(A,e){if(A==null||!e&&this.testIfValueChanged(A)===!1)return;const t=this._value;YuA&&typeof t=="number"&&typeof A=="number"&&(t==null||t.toFixed(4),A==null||A.toFixed(4)),!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,A=this._defaultValue,this._valueRaw=A):(this._valueRaw=A,this._active&&this.valueProcessor&&(A=this.valueProcessor(A)),this._value=A),this.onValueChanged&&this.onValueChanged(A,t,this)}testIfValueChanged(A){return this._valueRaw!==A}}mj([G()],Ae.prototype,"overrideState",1);mj([G()],Ae.prototype,"value",1);class OuA extends Sn{constructor(){super([Ae])}onSerialize(A,e){}onDeserialize(A,e){const t=e.target,i=e.path;let o;if(t&&i&&(o=t[i]),(typeof o!="object"||typeof o=="object"&&o.isVolumeParameter!==!0)&&(o=new Ae),typeof A=="object"&&"value"in A){const I=A.value;o.initialize(I),o.overrideState=A.overrideState}else o.value=A;return o}}new OuA;var PuA=Object.defineProperty,ZuA=Object.getOwnPropertyDescriptor,WuA=(g,A,e,t)=>{for(var i=t>1?void 0:t?ZuA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&PuA(A,e,i),i};const VuA=gA("debugpost");class no extends NA{constructor(e=void 0){super();c(this,"active",!0);c(this,"_manager",null);c(this,"_result");c(this,"_postprocessingContext",null);if(e)for(const t of Object.keys(e)){const i=e[t],o=this[t];o instanceof Ae?o.initialize(i):o!==void 0&&(this[t]=i)}}get isPostProcessingEffect(){return!0}onEnable(){super.onEnable(),this.onEffectEnabled(),this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){var e;super.onDisable(),(e=this._manager)==null||e.removeEffect(this),this.active=!1}onEffectEnabled(e){var t;e&&e.isPostProcessingManager===!0?this._manager=e:this._manager||(this._manager=TuA(this)),(t=this._manager)==null||t.addEffect(this)}init(){}get postprocessingContext(){return this._postprocessingContext}apply(e){var t;return this._postprocessingContext=e,this._result||(this.initParameters(),this._result=(t=this.onCreateEffect)==null?void 0:t.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){VuA&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const e=Object.keys(this);for(const t of e){const i=this[t];i instanceof Ae&&i.__init()}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof Ae){const i=e.value;return this[t].value=i,!0}}}WuA([G()],no.prototype,"active",2);var XuA=Object.defineProperty,zuA=Object.getOwnPropertyDescriptor,juA=(g,A,e,t)=>{for(var i=t>1?void 0:t?zuA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&XuA(A,e,i),i};const $uA=gA("debugpost"),cJ={};function Gn(g,A){cJ[g]=A}function ApA(g){return g.__type in cJ?cJ[g.__type]:($uA&&g.__type&&console.warn("Unknown postprocessing type",g.__type,g),no)}class sw{constructor(){c(this,"components",[])}init(){var A;(A=this.components)==null||A.forEach(e=>e.init())}addEffect(A){this.components.push(A)}removeEffect(A){const e=this.components.indexOf(A);e>=0&&this.components.splice(e,1)}}juA([ru([g=>ApA(g),no])],sw.prototype,"components",2);var epA=Object.defineProperty,tpA=Object.getOwnPropertyDescriptor,ipA=(g,A,e,t)=>{for(var i=t>1?void 0:t?tpA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&epA(A,e,i),i};class nw extends no{constructor(){super(...arguments);c(this,"preset",new Ae(Ll.HIGH))}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new HV({preset:Ll.HIGH,edgeDetectionMode:mL.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}ipA([G(Ae)],nw.prototype,"preset",2);Gn("Antialiasing",nw);const gpA=gA("debugusdz");class Jc{constructor(){c(this,"files",new Array)}static getName(A){var o;const e=A.split(".").pop();let i=(o=A.split(".").slice(0,-1).join(".").split("/").pop())==null?void 0:o.replace(".","_");return i||(i="Audio_"+Math.random().toString(36).substring(2,15)),la(i)+"."+e}get extensionName(){return"Audio"}onExportObject(A,e,t){const i=oA.getComponents(A,Yi);if(i.length)for(const o of i){if(!o.clip||typeof o.clip!="string"||!o.playOnAwake)continue;const I=o.clip.split("/").pop()||"Audio",s=Jc.getName(o.clip),n=la(s);if(!this.files.some(a=>a.path===o.clip)){this.files.push({path:o.clip,name:s});const a=s.toLowerCase();t.quickLookCompatible&&!a.endsWith(".mp3")&&!a.endsWith(".wav")&&!a.endsWith(".m4a")&&console.error("Audio file "+o.clip+" from "+o.name+" is not an MP3 or WAV file. QuickLook may not support playing it.")}t.quickLookCompatible||e.addEventListener("serialize",(a,r)=>{a.appendLine(),a.beginBlock(`def SpatialAudio "${n}"`,"(",!1),a.appendLine(`displayName = "${I}"`),a.closeBlock(")"),a.beginBlock(),a.appendLine(`uniform asset filePath = @audio/${s}@`),a.appendLine(`uniform token auralMode = "${o.spatialBlend>0?"spatial":"nonSpatial"}"`),a.appendLine(`uniform token playbackMode = "${o.loop?"loopFromStage":"onceFromStart"}"`),a.appendLine(`uniform float gain = ${o.volume}`),a.closeBlock()})}}async onAfterSerialize(A){for(const e of this.files){const t="audio/"+e.name;if(A.files[t]){gpA&&console.warn("Audio file with name "+t+" already exists in the context. Skipping.");continue}const I=await(await(await fetch(e.path)).blob()).arrayBuffer(),s=new Uint8Array(I);A.files[t]=s}}}const QC=gA("debugautosync"),PF=Symbol("syncerId");class opA{constructor(){c(this,"_syncers",{})}getOrCreateSyncer(A){if(!A.guid)return null;if(this._syncers[A.guid])return this._syncers[A.guid];const e=new IpA(A);return e[PF]=A.guid,this._syncers[e[PF]]=e,e}removeSyncer(A){delete this._syncers[A[PF]]}}const Uq=new opA;class IpA{constructor(A){c(this,"comp");c(this,"hasChanges",!1);c(this,"changedProperties",{});c(this,"_isReceiving",!1);c(this,"_isInit",!1);c(this,"onHandleSending",()=>{if(!this.hasChanges)return;this.hasChanges=!1;const A=this.comp.context.connection;if(!A||!A.isConnected||!A.isInRoom){for(const e in this.changedProperties)delete this.changedProperties[e];return}for(const e in this.changedProperties){const t=this.comp.guid+"/"+e,i=this.changedProperties[e];QC&&console.log("SEND",this.comp.name,this.networkingKey),A.send(this.networkingKey,{guid:t,data:i},Xn.Queued)}});c(this,"onHandleReceiving",A=>{if(QC&&console.log("RECEIVE",this.comp.name,this.comp.guid,A),!this._isInit||!this.comp||A.guid.startsWith(this.comp.guid)===!1)return;const[e,t]=A.guid.split("/");QC&&console.log("RECEIVED",this.comp.name,this.comp.guid,A);try{this._isReceiving=!0,this.comp[t]=A.data}catch(i){console.error(i)}finally{this._isReceiving=!1}});this.comp=A}get networkingKey(){return this.comp.guid}init(A){if(this._isInit)return;this._isInit=!0,this.comp=A,this.comp.context.post_render_callbacks.push(this.onHandleSending),this.comp.context.connection.beginListen(this.networkingKey,this.onHandleReceiving);const e=this.comp.context.connection.tryGetState(this.comp.guid);e&&this.onHandleReceiving(e)}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(A,e){this._isReceiving||(QC&&console.log("Property changed: "+A,e),this.hasChanges=!0,this.changedProperties[A]=e)}}function spA(g,A){let e=A!==g;return!e&&g&&A&&(Array.isArray(g)&&Array.isArray(A)||typeof g=="object"&&typeof A=="object")&&(e=!0),e}const AD=Symbol("AutoSyncHandler");function npA(g){if(g[AD])return g[AD];const A=Uq.getOrCreateSyncer(g);return A==null||A.init(g),g[AD]=A,A}function apA(g){const A=g[AD];A&&(Uq.removeSyncer(A),A.destroy(),delete g[AD])}const Nq=function(g=null){return function(A,e){var r;let t="";typeof e=="string"?t=e:t=e.name;let i=null,o;typeof g=="string"?o=A[g]:typeof g=="function"&&(o=g),o==null&&(VA()||QC)&&g!=null&&console.warn('syncField: no callback function found for property "'+t+'"','"'+g+'"');const I=A,s=I.__internalAwake;if(typeof s!="function"){(QC||VA())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((r=A==null?void 0:A.constructor)==null?void 0:r.name)+'" is not supported',A);return}QC&&console.log(t);const n=Symbol(t);I.__internalAwake=function(){if(this[n]!==void 0)return;this[n]=this[t],i=Uq.getOrCreateSyncer(this);const C=Object.getOwnPropertyDescriptor(this,t);if((C==null?void 0:C.set)===void 0){let B=!1;Object.defineProperty(this,t,{set:function(l){var d;const Q=this[n];if(this[n]=l,B){(VA()||QC)&&console.warn("Recursive call detected",t);return}B=!0;try{const h=spA(l,Q);QC&&console.log("SyncField assignment",t,"changed?",h,l,o),h&&(o==null?void 0:o.call(this,l,Q))!==!1&&((d=npA(this))==null||d.notifyChanged(t,l))}finally{B=!1}},get:function(){return this[n]},configurable:!0,enumerable:!0})}i==null||i.init(this),s.call(this)};const a=I.__internalDestroy;I.__internalDestroy=function(){apA(this),a.call(this)}}};var rpA=Object.defineProperty,CpA=Object.getOwnPropertyDescriptor,CR=(g,A,e,t)=>{for(var i=t>1?void 0:t?CpA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&rpA(A,e,i),i};const fs=gA("debugplayersync"),Sj=class extends NA{constructor(){super(...arguments);c(this,"autoSync",!0);c(this,"asset");c(this,"onPlayerSpawned");c(this,"_localInstance");c(this,"onJoinedRoom",()=>{fs&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()});c(this,"destroyInstance",()=>{var A;(A=this._localInstance)==null||A.then(e=>{fs&&console.log("PlayerSync.destroyInstance",e),Wy(e,this.context.connection,!0,{saveInRoom:!1})}),this._localInstance=void 0})}static async setupFrom(A,e){const t=it.getOrCreateFromUrl(A);if(!t.asset){const I=await t.loadAssetAsync();oA.getOrAddComponent(I,ks)}const i=new Sj;i._internalInit(e),i.asset=t;const o=new uA;return o.guid=A,oA.addComponent(o,i),i}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new ti)}onEnable(){this.context.connection.beginListen(Ze.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(Ze.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Ze.LeftRoom,this.destroyInstance),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(Ze.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(Ze.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Ze.LeftRoom,this.destroyInstance)}async getInstance(){var e,t,i,o,I,s;if(this._localInstance)return this._localInstance;if(fs&&console.log("PlayerSync.createInstance",(e=this.asset)==null?void 0:e.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=(o=this.asset)==null?void 0:o.instantiateSynced({parent:this.gameObject,deleteOnDisconnect:!0},!0);const A=await this._localInstance;if(A){const n=oA.getComponentsInChildren(A,ks);if(n!=null&&n.length){for(const a of n)a.owner=this.context.connection.connectionId;(I=this.onPlayerSpawned)==null||I.invoke(A)}else this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((s=this.asset)==null?void 0:s.url)+"</strong>: please make sure the asset has a PlayerState component!"),oA.destroySynced(A)}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}watchTabVisible(){window.addEventListener("visibilitychange",A=>{if(document.visibilityState==="visible")for(let e=ks.all.length-1;e>=0;e--){const t=ks.all[e];(!t.owner||!this.context.connection.userIsInRoom(t.owner))&&t.doDestroy()}})}};let lu=Sj;CR([G()],lu.prototype,"autoSync",2);CR([G(it)],lu.prototype,"asset",2);CR([G(ti)],lu.prototype,"onPlayerSpawned",2);var Gj=(g=>(g.OwnerChanged="ownerChanged",g))(Gj||{}),Vp;const po=(Vp=class extends NA{constructor(){super(...arguments);c(this,"onOwnerChangeEvent",new ti);c(this,"onFirstOwnerChangeEvent",new ti);c(this,"hasOwner",!1);c(this,"owner");c(this,"dontDestroy",!1);c(this,"onUserLeftRoom",A=>{if(A.userId===this.owner){fs&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return po._all}static get local(){return po._local}static getFor(A){if(A instanceof uA)return oA.getComponentInParent(A,po);if(A instanceof NA)return oA.getComponentInParent(A.gameObject,po)}static isLocalPlayer(A){const e=po.getFor(A);return(e==null?void 0:e.isLocalPlayer)??!1}static addEventListener(A,e){return this._callbacks[A]||(this._callbacks[A]=[]),this._callbacks[A].push(e),e}static removeEventListener(A,e){if(!this._callbacks[A])return;const t=this._callbacks[A].indexOf(e);t>=0&&this._callbacks[A].splice(t,1)}static dispatchEvent(A,e){if(this._callbacks[A])for(const t of this._callbacks[A])t(e)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(A,e){var I,s;fs&&console.log("PlayerSync.onOwnerChange",this,"newOwner",A,"oldOwner",e);const t=po._local.indexOf(this);t>=0&&po._local.splice(t,1);const i={playerState:this,oldValue:e,newValue:A};if(this.hasOwner||(this.hasOwner=!0,(I=this.onFirstOwnerChangeEvent)==null||I.invoke(i)),(s=this.onOwnerChangeEvent)==null||s.invoke(i),this.owner===this.context.connection.connectionId){po._local.push(this);const n=new CustomEvent("local-owner-changed",{detail:i});this.dispatchEvent(n)}const o=new CustomEvent("owner-changed",{detail:i});this.dispatchEvent(o),po.dispatchEvent("ownerChanged",o)}awake(){po.all.push(this),fs&&console.log("Registered new PlayerState",this.guid,po.all.length-1,po.all),this.context.connection.beginListen(Ze.UserLeftRoom,this.onUserLeftRoom)}async start(){fs&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await Ca(300),this.context.connection.userIsInRoom(this.owner)==!1&&(fs&&console.log(`PlayerSync.start → doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(fs&&console.warn("PlayerState.start → owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?fs&&console.warn("PlayerState.start → owner is still undefined but dontDestroy is set to true",this.name):(fs&&console.warn(`PlayerState.start → owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):fs&&console.log("PlayerState.start → owner is assigned",this.owner)},2e3))}doDestroy(){fs&&console.log("PlayerSync.doDestroy → syncDestroy",this.name),Wy(this.gameObject,this.context.connection,!0,{saveInRoom:!1})}onDestroy(){if(this.context.connection.stopListen(Ze.UserLeftRoom,this.onUserLeftRoom),po.all.splice(po.all.indexOf(this),1),this.isLocalPlayer){const A=po._local.indexOf(this);A>=0&&po._local.splice(A,1)}}},c(Vp,"_all",[]),c(Vp,"_local",[]),c(Vp,"_callbacks",{}),Vp);let ks=po;CR([Nq(ks.prototype.onOwnerChange)],ks.prototype,"owner",2);const BpA=gA("debugavatar"),On=class extends NA{constructor(){super(...arguments);c(this,"connectionId");c(this,"avatar")}static getAvatar(e){return e>=0&&e<On.instances.length?On.instances[e]:null}static onAvatarMarkerCreated(e){return On._onNewAvatarMarkerAdded.push(e),e}static onAvatarMarkerDestroyed(e){return On._onAvatarMarkerDestroyed.push(e),e}awake(){On.instances.push(this),BpA&&console.log(this);for(const e of On._onNewAvatarMarkerAdded)e({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){On.instances.splice(On.instances.indexOf(this),1);for(const e of On._onAvatarMarkerDestroyed)e({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let Lg=On;c(Lg,"instances",[]),c(Lg,"_onNewAvatarMarkerAdded",[]),c(Lg,"_onAvatarMarkerDestroyed",[]);var cpA=Object.defineProperty,lpA=Object.getOwnPropertyDescriptor,QpA=(g,A,e,t)=>{for(var i=t>1?void 0:t?lpA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&cpA(A,e,i),i};const bE=gA("debugxrflags"),kj=gA("disablexrflags");kj&&console.warn("XRFlags are disabled");var Pa=(g=>(g[g.Never=0]="Never",g[g.Browser=1]="Browser",g[g.AR=2]="AR",g[g.VR=4]="VR",g[g.FirstPerson=8]="FirstPerson",g[g.ThirdPerson=16]="ThirdPerson",g[g.All=4294967295]="All",g))(Pa||{});const N_=class{constructor(){c(this,"Mask",17)}Has(A){return(this.Mask&A)!==0}Set(A){bE&&console.warn("Set XR flag state to",A),this.Mask=A,ws.Apply()}Enable(A){this.Mask|=A,ws.Apply()}Disable(A){this.Mask&=~A,ws.Apply()}Toggle(A){this.Mask^=A,ws.Apply()}EnableAll(){this.Mask=-1,ws.Apply()}DisableAll(){this.Mask=0,ws.Apply()}};let So=N_;c(So,"Global",new N_);var Xp;const jr=(Xp=class extends NA{constructor(){super(...arguments);c(this,"visibleIn")}static Apply(){for(const A of this.registry)A.UpdateVisible(So.Global)}awake(){jr.registry.push(this)}onEnable(){jr.firstApply?this.UpdateVisible(So.Global):(jr.firstApply=!0,jr.Apply())}onDestroy(){const A=jr.registry.indexOf(this);A>=0&&jr.registry.splice(A,1)}get isOn(){return this.gameObject.visible}UpdateVisible(A=null){if(kj)return;let e;const t=A;if(t&&typeof t=="number"&&(console.assert(typeof t=="number","XRFlag.UpdateVisible: state must be a number",t),bE&&console.log(t),jr.buffer.Mask=t,A=jr.buffer),A instanceof So?(bE&&console.warn(this.name,"use passed in mask",A.Mask,this.visibleIn),e=A.Has(this.visibleIn)):(bE&&console.log(this.name,"use global mask"),So.Global.Has(this.visibleIn)),e!==void 0)if(e)bE&&console.log(this.name,"is visible",this.gameObject.uuid),oA.setActive(this.gameObject,!0);else{if(bE&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},c(Xp,"registry",[]),c(Xp,"firstApply"),c(Xp,"buffer",new So),Xp);let ws=jr;QpA([G()],ws.prototype,"visibleIn",2);var hpA=Object.defineProperty,EpA=Object.getOwnPropertyDescriptor,Fq=(g,A,e,t)=>{for(var i=t>1?void 0:t?EpA(A,e):A,o=g.length-1,I;o>=0;o--)(I=g[o])&&(i=(t?I(A,e,i):I(i))||i);return t&&i&&hpA(A,e,i),i};const Mp=gA("debugwebxr"),sP=new GA().setFromAxisAngle(new S(0,1,0),Math.PI);class dc extends NA{constructor(){super(...arguments);c(this,"head");c(this,"leftHand");c(this,"rightHand");c(this,"_leftHandMeshes");c(this,"_rightHandMeshes");c(this,"_syncTransforms")}async onEnterXR(e){if(!this.activeAndEnabled)return;Mp&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const t=ks.getFor(this);if(t!=null&&t.owner){const i=this.gameObject.addComponent(Lg);i.avatar=this.gameObject,i.connectionId=t.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):t&&!this.context.connection.isConnected&&(t.dontDestroy=!0)}onLeaveXR(e){const t=this.gameObject.getComponent(Lg);t&&t.destroy()}onUpdateXR(e){var a,r;if(!this.activeAndEnabled)return;const t=ks.isLocalPlayer(this);if(!t)return;const i=e.xr;if(i.rig&&i.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),i.rig.gameObject.add(this.gameObject)),this._syncTransforms&&t)for(const C of this._syncTransforms)C.fastMode=!0,C.isOwned()||C.requestOwnership();if(this.head&&this.context.mainCamera){const C=this.head.asset;if(C.position.copy(this.context.mainCamera.position),C.position.x*=-1,C.position.z*=-1,C.quaternion.copy(this.context.mainCamera.quaternion),C.quaternion.x*=-1,this.context.time.frameCount%10===0){const B=oA.getComponentsInChildren(this.head.asset,ws);for(const l of B)l.enabled=!1,l.gameObject.visible=!1}}const o=e.xr.leftController,I=(a=this.leftHand)==null?void 0:a.asset;o&&I?(I.position.copy(o.gripPosition),I.quaternion.copy(o.gripQuaternion),I.quaternion.multiply(sP),I.visible=o.isTracking,this.updateHandVisibility(o,I,this._leftHandMeshes)):I&&I.visible&&(I.visible=!1);const s=e.xr.rightController,n=(r=this.rightHand)==null?void 0:r.asset;s&&n?(n.position.copy(s.gripPosition),n.quaternion.copy(s.gripQuaternion),n.quaternion.multiply(sP),n.visible=s.isTracking,this.updateHandVisibility(s,n,this._rightHandMeshes)):n&&n.visible&&(n.visible=!1)}onBeforeRender(){this.context.xr&&this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateHandVisibility(e,t,i){if(i){const o=e.model&&e.model.visible&&e.model!==t;i.forEach(I=>{cC(I,!o)})}}updateRemoteAvatarVisibility(){var e,t,i;if(this.context.connection.isConnected){const o=ks.getFor(this);if(o&&o.isLocalPlayer==!1){const I=ke.getXRSync(this.context);if(I&&I.hasState(o.owner)){this.tryFindAvatarObjectsIfMissing();const s=(e=this.leftHand)==null?void 0:e.asset;s&&(s.visible=(I==null?void 0:I.isTracking(o.owner,"left"))??!1);const n=(t=this.rightHand)==null?void 0:t.asset;n&&(n.visible=(I==null?void 0:I.isTracking(o.owner,"right"))??!1)}if((i=this.head)!=null&&i.asset){const s=oA.getComponentsInChildren(this.head.asset,ws);for(const n of s)n.enabled=!1,n.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const e={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};vX.tryFindAvatarObjects(this.gameObject,this.sourceId||"",e),e.head&&(this.head=e.head),e.leftHand&&(this.leftHand=e.leftHand),e.rightHand&&(this.rightHand=e.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof uA&&(this.head=new it("",this.sourceId,this.head));else{const e=new uA;e.name="Head";const t=Kc.createPrimitive(kQ.Cube);e.add(t),this.gameObject.add(e),this.head=new it("",this.sourceId,e),Mp&&console.log("Create head",e)}if(this.rightHand)this.rightHand instanceof uA&&(this.rightHand=new it("",this.sourceId,this.rightHand));else{const e=new uA;e.name="Right Hand",this.gameObject.add(e),this.rightHand=new it("",this.sourceId,e),Mp&&console.log("Create right hand",e)}if(this.leftHand)this.leftHand instanceof uA&&(this.leftHand=new it("",this.sourceId,this.leftHand));else{const e=new uA;e.name="Left Hand",this.gameObject.add(e),this.leftHand=new it("",this.sourceId,e),Mp&&console.log("Create left hand",e)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),this._leftHandMeshes=[],this.leftHand.asset.traverse(e=>{e!=null&&e.isMesh&&this._leftHandMeshes.push(e)}),this._rightHandMeshes=[],this.rightHand.asset.traverse(e=>{e!=null&&e.isMesh&&this._rightHandMeshes.push(e)}),ks.isLocalPlayer(this.gameObject)&&(this._syncTransforms=oA.getComponentsInChildren(this.gameObject,Br))}async loadAvatarObjects(e,t,i){const o=e.loadAssetAsync(),I=t.loadAssetAsync(),s=i.loadAssetAsync(),n=new Array;o&&n.push(o),I&&n.push(I),s&&n.push(s);const a=await GM(n);Mp&&console.log("Avatar loaded results:",a)}}Fq([G(it)],dc.prototype,"head",2);Fq([G(it)],dc.prototype,"leftHand",2);Fq([G(it)],dc.prototype,"rightHand",2);class sr{static Add(A,e,t=null){if(e){for(const i of this.Pois)if(i.obj===e)return;this.Pois.push({obj:e,avatar:t}),this.LastChangeTime=A.time.time}}static Remove(A,e){var t;if(e){for(const i of this.Pois)if(i.obj===e){this.Pois.splice(this.Pois.indexOf(i),1),this.LastChangeTime=(A==null?void 0:A.time.time)??((t=Ue.Current)==null?void 0:t.time.time);return}}}}c(sr,"Pois",[]),c(sr,"LastChangeTime",0);class dpA{constructor(){c(this,"guid");c(this,"position",new S)}}class $D extends NA{constructor(){super(...arguments);c(this,"target",null);c(this,"avatar",null);c(this,"_model",null);c(this,"_targetModel",new dpA);c(this,"_currentTargetObject",null);c(this,"_lastUpdateTime",0);c(this,"_lookDuration",0);c(this,"_lastPoiChangedTime",0)}set controlledTarget(e){this.target=e;const t=z.get("MoveRandom");if(t&&this.target){const i=oA.getComponent(this.target,t);i&&i.destroy()}}awake(){if(this.avatar=oA.getComponentInParent(this.gameObject,Lg),this.avatar){const e=oA.getComponentInParent(this.gameObject,Lg);this._model=new jL(this.context.connection,this.guid),e!=null&&e.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",e=>{var t;this.target&&e&&e.guid===((t=this.avatar)==null?void 0:t.guid)&&Tg(this.target,e.position)})}update(){var t;if((!this.context.connection.isConnected||(t=this._model)!=null&&t.hasOwnership)&&(sr.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=sr.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const i=_e(this._currentTargetObject);Tg(this.target,i),this.context.connection.isConnected&&this.avatar&&(this.context.connection.send("avatar-look-target-changed",this._targetModel),this._targetModel.guid=this.avatar.guid,this._targetModel.position.copy(i))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const t=sr.Pois;if(t.length>0){const i=t[Math.floor(Math.random()*t.length)];if(i&&i.obj){if(i.avatar&&i.avatar===this.avatar)return;this._currentTargetObject=i.obj}}}}}function Mj(g){return g&&g.isComponent}const upA=Symbol("object"),ZF=new vs(()=>new S,20);class Rj{constructor(A,e,t,i,o,I){c(this,"_point");c(this,"_normal");c(this,"_tangentVelocity");c(this,"distance");c(this,"impulse");c(this,"friction");this._point=A,this.distance=e,this._normal=t,this.impulse=i,this.friction=o,this._tangentVelocity=I}get point(){return ZF.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return ZF.get().set(this._normal.x,this._normal.y,this._normal.z)}get tangentVelocity(){return ZF.get().set(this._tangentVelocity.x,this._tangentVelocity.y,this._tangentVelocity.z)}}class Uj{constructor(A,e,t){c(this,"contacts");c(this,"me");c(this,"_collider");c(this,"_gameObject");this.me=A,this._collider=e,this._gameObject=e.gameObject,this.contacts=t}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var A;return(A=this.collider)==null?void 0:A.attachedRigidbody}}class Nj{constructor(A,e){c(this,"object");c(this,"collider");this.object=A,this.collider=e}}const ng=gA("debugnetworkingstreams");var Ar=(g=>(g.Connected="peer-user-connected",g.StreamReceived="receive-stream",g.StreamEnded="call-ended",g.Disconnected="peer-user-disconnected",g.UserJoined="user-joined",g))(Ar||{});class bq{constructor(A,e){c(this,"type","call-ended");c(this,"userId");c(this,"direction");this.userId=A,this.direction=e}}class Fj{constructor(A,e,t){c(this,"type","receive-stream");c(this,"userId");c(this,"stream");c(this,"target");this.userId=A,this.stream=e,this.target=t}}class ppA{constructor(A,e){c(this,"guid");c(this,"peerId");c(this,"dontSave",!0);this.guid=A.id,this.peerId=e}}var bj=(g=>(g.Incoming="incoming",g.Outgoing="outgoing",g))(bj||{});class fpA extends Io{constructor(e,t,i,o=null){super();c(this,"peerId");c(this,"userId");c(this,"direction");c(this,"call");c(this,"_stream",null);c(this,"_isDisposed",!1);this.peerId=t.peer,this.userId=e,this.call=t,this.direction=i,this._stream=o,t.on("stream",I=>{if(ng&&console.log("Receive stream",`
5958
5958
  Audio:`,I.getAudioTracks(),`
5959
5959
  Video:`,I.getVideoTracks()),this._stream=I,i==="incoming"){const s=new Fj(e,I,this);this.dispatchEvent(s)}}),t.on("close",()=>{this.dispatchEvent(new bq(e,i))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),er(this._stream))}get isOpen(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connected"}get isOpening(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connecting"}get isClosed(){return!this.isOpen||this._isDisposed}}function nP(g){return g=g.replace("a=fmtp:111 minptime=10;useinbandfec=1","a=fmtp:111 ptime=5;useinbandfec=1;stereo=1;maxplaybackrate=48000;maxaveragebitrat=128000;sprop-stereo=1"),g}const id=class extends Io{constructor(e,t){super();c(this,"updateCalls",()=>{var e;for(let t=this._incomingCalls.length-1;t>=0;t--){const i=this._incomingCalls[t];i.isClosed&&!i.isOpening&&this._incomingCalls.splice(t,1)}for(let t=this._outgoingCalls.length-1;t>=0;t--){const i=this._outgoingCalls[t];let o=!1;i.isClosed&&!i.isOpening&&((e=i.stream)!=null&&e.active?ng&&console.warn("!!! Stream is still active, don't remove call",i.userId,"Your id: "+this.context.connection.connectionId):(ng&&console.warn("!!! Remove closed call",i.userId),o=!0)),this.context.connection.userIsInRoom(i.userId)===!1&&(ng&&console.warn("!!! User is not in room anymore, remove call",i.userId),o=!0),o&&(i.close(),this._outgoingCalls.splice(t,1))}});c(this,"id");c(this,"context");c(this,"_incomingCalls",[]);c(this,"_outgoingCalls",[]);c(this,"_peer");c(this,"_enabled",!1);c(this,"_enabledPeer",!1);c(this,"onConnectRoomFn",this.onConnectRoom.bind(this));c(this,"onPeerConnect",e=>{if(ng&&console.log("PEER opened as",e),e===null){console.error("Peer connection failed",e);return}this.context.connection.send("peer-user-connected",new ppA(this,e))});c(this,"onPeerClose",()=>{ng&&console.log("PEER closed"),this.updateCalls()});c(this,"onPeerDisconnected",()=>{ng&&console.log("PEER disconnected"),this.updateCalls()});c(this,"onPeerError",e=>{ng&&console.error("PEER error",e)});c(this,"onPeerReceivingCall",e=>{e.answer(void 0,{sdpTransform:t=>nP(t)}),this.registerCall(e,"incoming",null)});this.context=e,this.id=t,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(e,t){if(id.instances.has(t))return id.instances.get(t);const i=new id(e,t);return id.instances.set(t,i),i}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(e){return this.id+"-"+e}getUserIdFromPeerId(e){return e.substring(this.id.length+1)}makeCall(e,t){var I;if(!(t!=null&&t.id)){ng?console.warn("Can not make a call: mediastream has no id or is undefined"):console.debug("Can not make a call: mediastream has no id or is undefined");return}const i={metadata:{userId:this.context.connection.connectionId,streamId:t.id},sdpTransform:s=>nP(s)},o=(I=this._peer)==null?void 0:I.call(e,t,i);if(o){const s=this.registerCall(o,"outgoing",t);return ng&&console.warn(`📞 CALL ${e}`,`
@@ -263,7 +263,10 @@ export class OrbitControls extends Behaviour {
263
263
  this._controls.listenToKeyEvents(this.context.domElement);
264
264
  }
265
265
  else {
266
- this._controls.stopListenToKeyEvents();
266
+ try {
267
+ this._controls.stopListenToKeyEvents();
268
+ }
269
+ catch { /** this fails if we never listened to key events... */ }
267
270
  }
268
271
  }
269
272
  this._syncedTransform = GameObject.getComponent(this.gameObject, SyncedTransform) ?? undefined;
@@ -282,7 +285,10 @@ export class OrbitControls extends Behaviour {
282
285
  this._controls.enabled = false;
283
286
  this._controls.autoRotate = false;
284
287
  this._controls.removeEventListener("start", this.onControlsChangeStarted);
285
- this._controls.stopListenToKeyEvents();
288
+ try {
289
+ this._controls.stopListenToKeyEvents();
290
+ }
291
+ catch { /** this fails if we never listened to key events... */ }
286
292
  this._startedListeningToKeyEvents = false;
287
293
  }
288
294
  this._activePointerEvents.length = 0;