@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: `+e.toString())}const s=exports.DeviceUtiliti
4345
4345
  #__vconsole .vc-mask {
4346
4346
  overflow: hidden;
4347
4347
  }
4348
- `,da==null||da.prepend(i),s===!0&&RD()<=0&&H9(),console.log("🌵 Debug console has loaded")}},e.onerror=()=>{console.warn("🌵 Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),Sb=!1,fo=null},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function zoe(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(t){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let n=globalThis["needle:codegen_files"][0];const r=n.indexOf("?");r>-1&&(n=n.substring(0,r));const a=location.protocol+"//"+location.host+location.pathname+"/"+n,l=encodeURIComponent(a);s.fullUrl="https://viewer.needle.tools?inspect&file="+l;var c='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(c)}),s.on("show",function(){const t=e();t&&t.src!==s.fullUrl&&(t.src=s.fullUrl)}),s.on("hide",function(){const t=e();t&&(t.src="")}),s.on("addTopBar",function(t){var i=new Array;i.push({name:"Open in new window ↗",onClick:function(n){window.open(s.fullUrl,"_blank"),fo==null||fo.hide()}}),i.push({name:"Reload",onClick:function(n){const r=e();r&&(r.src=s.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const r=e();r.requestFullscreen?r.requestFullscreen():r.webkitRequestFullscreen instanceof Function&&r.webkitRequestFullscreen()}}),t(i)}),s}function Uoe(){const s=document.querySelector("#__vconsole .vc-switch");return s||null}function Voe(){const s=document.querySelector("#__vconsole");return s||null}const j9=ie("debugdefines");cf('if(!globalThis[""4.0.2-alpha""]) globalThis[""4.0.2-alpha""] = "0.0.0";');cf('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');cf('if(!globalThis[""Thu Dec 12 2024 16:46:24 GMT+0100 (Central European Standard Time)""]) globalThis[""Thu Dec 12 2024 16:46:24 GMT+0100 (Central European Standard Time)""] = "unknown";');cf('if(!globalThis[""npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9""]) globalThis[""npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9""] = "unknown";');cf('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.0.2-alpha";');cf('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');cf('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Thu Dec 12 2024 16:46:24 GMT+0100 (Central European Standard Time)";');cf('globalThis["__NEEDLE_PUBLIC_KEY__"] = "npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9";');const Wl="4.0.2-alpha",zE="undefined",hO="Thu Dec 12 2024 16:46:24 GMT+0100 (Central European Standard Time)";j9&&console.log(`Engine version: ${Wl} (generator: ${zE})
4348
+ `,da==null||da.prepend(i),s===!0&&RD()<=0&&H9(),console.log("🌵 Debug console has loaded")}},e.onerror=()=>{console.warn("🌵 Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),Sb=!1,fo=null},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function zoe(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(t){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let n=globalThis["needle:codegen_files"][0];const r=n.indexOf("?");r>-1&&(n=n.substring(0,r));const a=location.protocol+"//"+location.host+location.pathname+"/"+n,l=encodeURIComponent(a);s.fullUrl="https://viewer.needle.tools?inspect&file="+l;var c='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(c)}),s.on("show",function(){const t=e();t&&t.src!==s.fullUrl&&(t.src=s.fullUrl)}),s.on("hide",function(){const t=e();t&&(t.src="")}),s.on("addTopBar",function(t){var i=new Array;i.push({name:"Open in new window ↗",onClick:function(n){window.open(s.fullUrl,"_blank"),fo==null||fo.hide()}}),i.push({name:"Reload",onClick:function(n){const r=e();r&&(r.src=s.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const r=e();r.requestFullscreen?r.requestFullscreen():r.webkitRequestFullscreen instanceof Function&&r.webkitRequestFullscreen()}}),t(i)}),s}function Uoe(){const s=document.querySelector("#__vconsole .vc-switch");return s||null}function Voe(){const s=document.querySelector("#__vconsole");return s||null}const j9=ie("debugdefines");cf('if(!globalThis[""4.0.2-alpha.1""]) globalThis[""4.0.2-alpha.1""] = "0.0.0";');cf('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');cf('if(!globalThis[""Thu Dec 12 2024 16:54:57 GMT+0100 (Central European Standard Time)""]) globalThis[""Thu Dec 12 2024 16:54:57 GMT+0100 (Central European Standard Time)""] = "unknown";');cf('if(!globalThis[""npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9""]) globalThis[""npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9""] = "unknown";');cf('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.0.2-alpha.1";');cf('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');cf('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Thu Dec 12 2024 16:54:57 GMT+0100 (Central European Standard Time)";');cf('globalThis["__NEEDLE_PUBLIC_KEY__"] = "npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9";');const Wl="4.0.2-alpha.1",zE="undefined",hO="Thu Dec 12 2024 16:54:57 GMT+0100 (Central European Standard Time)";j9&&console.log(`Engine version: ${Wl} (generator: ${zE})
4349
4349
  Project built at ${hO}`);const $v="npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9",hu="needle_isActiveInHierarchy",vp="builtin_components",eA="needle_editor_guid";function cf(s){try{(0,eval)(s)}catch(e){j9&&console.error(e)}}const Xoe='<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>',Woe=btoa(Xoe),Hoe="data:image/svg+xml;base64,"+Woe,Qoe=Hoe,Zoe=`<?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(Zoe);const joe='<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>',Yoe=btoa(joe),Koe="data:image/svg+xml;charset=utf-8;base64,"+Yoe,Joe=Koe;/**
4350
4350
  * postprocessing v6.36.2 build Tue Sep 10 2024
4351
4351
  * https://github.com/pmndrs/postprocessing
@@ -5953,7 +5953,7 @@ ${t.path}! : AssetReference;
5953
5953
  Could not find method ${c.method} on object ${u.name}. Please rename ${c.method} to ${b}?
5954
5954
  `,u[b],`
5955
5955
  in script: `,u),zi("EventList methods must start with lowercase letter, see console for details");return}else console.warn(`EventList method:
5956
- Could not find method ${c.method} on object ${u.name}`,u,typeof u[c.method])};if(typeof u[c.method]!="function"){let b=!1,g=u;for(;g;){const y=Object.getOwnPropertyDescriptor(g,c.method);if(y&&(y.writable===!0||y.set)){b=!0;break}g=Object.getPrototypeOf(g)}!b&&(Ze()||Xs)&&p()}}if(u){let p=c.argument;if(p!==void 0?p=h(p):c.arguments!==void 0&&(p=c.arguments.map(h)),!u[c.method])console.warn(`EventList method not found: "${c.method}" on ${u==null?void 0:u.name}`);else{p!==void 0&&!Array.isArray(p)&&(p=[p]);const b=new Ic(u,c.method,p,c.enabled);o.push(b)}}else Ze()&&console.warn("[Debug] EventList: Could not find event listener in scene",c,t.object,e)}const a=new Yi(o);Xs&&console.log(a);const l=t.target;return l!==void 0&&t.path!==void 0&&a.setEventTarget(t.path,l),a}}}const N0e=new G0e,wM=new WeakMap,z0e=Wt.prototype.clone;Wt.prototype.clone=function(){const s=z0e.call(this);return wM.has(s)||wM.set(s,this),s};class NY extends pl{constructor(){super([Nd,$t])}onSerialize(e,t){}onDeserialize(e,t){if(e instanceof Wt&&t.type===Nd){let i=e;wM.has(i)&&(i=wM.get(i)),i.isRenderTargetTexture=!0,i.flipY=!0,i.offset.y=1,i.repeat.y=-1,i.needsUpdate=!0,i.mipmaps=[],i instanceof Pd&&(i.isCompressedTexture=!1,i.format=Mi);const n=new Nd(i.image.width,i.image.height,{colorSpace:Ui});return n.texture=i,n}}}new NY;class zY extends pl{constructor(){super([URL])}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"&&e.length>0)return lf(t.gltfId,e)}}new zY;var U0e=Object.defineProperty,V0e=Object.getOwnPropertyDescriptor,X0e=(s,e,t,i)=>{for(var n=i>1?void 0:i?V0e(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&U0e(e,t,n),n};class g_ extends Te{awake(){No.createIfNoneExists(this.context)}onEnable(){var e;(e=No.get(this.context))==null||e.register(this)}onDisable(){var e;(e=No.get(this.context))==null||e.unregister(this)}}class La extends g_{constructor(){super(...arguments);d(this,"targets",null);d(this,"raycastHits",[]);d(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(t=null){if(!this.targets)return null;t??(t=new Kc),t.targets=this.targets,t.results=this.raycastHits,t.useAcceleratedRaycast=!0;const i=t.testObject;this.ignoreSkinnedMeshes&&(t.testObject=r=>r instanceof Vo?"continue in children":i?i(r):!0);const n=this.context.physics.raycast(t);return t.testObject=i,n}}X0e([E()],La.prototype,"ignoreSkinnedMeshes",2);class fT extends La{constructor(){super(),this.ignoreSkinnedMeshes=!0}}const zG=class extends g_{performRaycast(e){if(!Et.active||!zG.allow||!(e!=null&&e.ray))return null;const t=e.ray.origin,i=.015;return this.context.physics.sphereOverlap(t,i,!1,!0)}};let zd=zG;d(zd,"allow",!0);class pT{static getObject(e){const t=e[rl];return t&&(t.isComponent===!0?e=t.gameObject:e=t),e}static isInteractable(e,t){if(t&&(t.canvasGroup=void 0,t.graphic=void 0),e==null||!e.visible||(e=this.getObject(e),!e.visible))return!1;const i=this.tryFindCanvasGroup(e);if((i==null?void 0:i.isCanvasGroup)===!0&&(t&&(t.canvasGroup=i),i.blocksRaycasts===!1||i.interactable===!1))return!1;const n=um(e,r=>{if(r.isGraphic===!0)return r},!1);return t&&(n==null?void 0:n.isGraphic)===!0&&(t.graphic=n),!((n==null?void 0:n.raycastTarget)===!1||(n==null?void 0:n.layer)===2)}static tryFindCanvasGroup(e){if(!e)return null;const t=um(e,i=>{const n=i;if(n.blocksRaycasts!==void 0&&n.interactable!==void 0)return n},!1);return t!==void 0?t:this.tryFindCanvasGroup(e.parent)}}function bF(s){const e=s[rl];return e||(s.parent?bF(s.parent):null)}function W0e(s){return s.isUI===!0||typeof s[rl]=="object"}function SM(s,e){if(!s)return;const t=s.material;if((t==null?void 0:t.isMaterial)===!0){const i=s.parent;i&&i.isText,t.side=e.doubleSided??!0?xi:is,t.shadowSide=e.doubleSided?xi:is,s.castShadow=e.castShadows?e.castShadows:!1,s.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const i of s.children)SM(i,e)}function c0(s,e,t){s[e]===void 0&&console.warn("Field",e,"is undefined on",s);const i=Proxy.revocable(s[e],{set(o,a,l,c){const h=o[a],u=Reflect.set(o,a,l,c);return t(l,h),u}}),n=i.revoke,r=s[e];return i.revoke=()=>{s[e]=r,n()},s[e]=i.proxy,i}const p5=Symbol("Scheduled action");function H0e(s,e,t=rn.OnBeforeRender){let i=s[p5];i||(i=s[p5]={});const n=e.name;i[t]||(i[t]={});const r=i[t];if(r[n])return;function*a(){e==null||e.call(s),r[n]=null}const l=s.startCoroutine(a(),t);r[n]=l}const kh=ie("debugeventsystem");var KB=(s=>(s.BeforeHandleInput="BeforeHandleInput",s.AfterHandleInput="AfterHandleInput",s))(KB||{});const _c=class extends Te{constructor(){super();d(this,"raycaster",[]);d(this,"pressedByID",new Map);d(this,"hoveredByID",new Map);d(this,"onPointerEvent",t=>{if(t===void 0||t.propagationStopped||t.defaultPrevented||t.used)return;const i=new Oy(this.context.input,t);this._currentPointerEventName=t.type,i.inputSource=this.context.input,i.isClick=t.isClick,i.isDoubleClick=t.isDoubleClick,i.isDown=t.type==xn.PointerDown,i.isUp=t.type==xn.PointerUp,i.isPressed=this.context.input.getPointerPressed(t.pointerId),kh&&(i.isDown?console.log("DOWN",i.pointerId):i.isUp&&console.log("UP",i.pointerId),i.isClick&&console.log("CLICK",i.pointerId));const n=new Kc;t.hasRay?n.ray=t.ray:n.screenPoint=this.context.input.getPointerPositionRC(t.pointerId);const r=this.performRaycast(n);if(r){for(const a of r)a.event=t,t.intersections.push(a);t.origin.onPointerHits&&t.origin.onPointerHits({sender:this,event:t,hits:r})}kh&&i.isClick&&wn("EventSystem: "+i.pointerId+" - "+this.context.time.frame+" - Up:"+i.isUp+", Down:"+i.isDown);const o={sender:this,args:i,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:o})),this.handleIntersections(r,i),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:o}))});d(this,"_sortedHits",[]);d(this,"_testObjectsCache",new Map);d(this,"_currentlyActiveRaycaster",null);d(this,"_currentPointerEventName",null);d(this,"shouldRaycastObject",t=>{var r;let i=null;if(W0e(t)&&(i=(r=t[rl])==null?void 0:r.gameObject),this._testObjectsCache.has(t)||i&&this._testObjectsCache.has(i))return this._testObjectsCache.get(t)===!1?"continue in children":!0;{let o=_M(t,this._currentPointerEventName);if(!o&&i&&(o=_M(i,this._currentPointerEventName)),o){this._testObjectsCache.set(t,!0);for(const a of t.children)this.shouldRaycastObject_AddToYesCache(a);return!0}return this._testObjectsCache.set(t,!1),"continue in children"}});d(this,"_sortingBuffer",[]);d(this,"_noDepthTestingResults",[]);d(this,"out",{});d(this,"_capturedPointer",{});d(this,"pointerEnterSymbol",Symbol("pointerEnter"));d(this,"pointerExitSymbol",Symbol("pointerExit"));d(this,"currentActiveMeshUIComponents",[]);_c.systems.push(this)}static createIfNoneExists(t){this.didSearchEventSystem||(this.didSearchEventSystem=!0,_c.systems.length<=0&&_c.systems.push(...ne.findObjectsOfType(_c,t)));for(const n of _c.systems)if(n.context===t)return;const i=new me;ne.addComponent(i,_c),t.scene.add(i)}static get systems(){const t=It.Current;return this._eventSystemMap.has(t)||this._eventSystemMap.set(t,[]),this._eventSystemMap.get(t)}static get(t){const i=this._eventSystemMap.get(t);return i&&i.length>0?i[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(t,i,n=!1){Ad.update(t,i,n)}static markUIDirty(t){Ad.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){_c.systems.splice(_c.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!ne.findObjectOfType(g_,this.context)){const i=ne.addComponent(this.context.scene,La);this.raycaster.push(i),(Ze()||kh)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(t){var i;t&&this.raycaster&&!this.raycaster.includes(t)&&((i=this.raycaster)==null||i.push(t))}unregister(t){var n,r;const i=(n=this.raycaster)==null?void 0:n.indexOf(t);i!==void 0&&i!==-1&&((r=this.raycaster)==null||r.splice(i,1))}onEnable(){this.context.input.addEventListener(xn.PointerDown,this.onPointerEvent),this.context.input.addEventListener(xn.PointerUp,this.onPointerEvent),this.context.input.addEventListener(xn.PointerMove,this.onPointerEvent)}onDisable(){this.context.input.removeEventListener(xn.PointerDown,this.onPointerEvent),this.context.input.removeEventListener(xn.PointerUp,this.onPointerEvent),this.context.input.removeEventListener(xn.PointerMove,this.onPointerEvent)}onBeforeRender(){this.resetMeshUIStates()}shouldRaycastObject_AddToYesCache(t){this._testObjectsCache.set(t,!0);for(const i of t.children)this.shouldRaycastObject_AddToYesCache(i)}performRaycast(t){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,t||(t=new Kc),t.testObject=this.shouldRaycastObject;for(const i of this.raycaster){if(!i.activeAndEnabled)continue;this._currentlyActiveRaycaster=i;const n=i.performRaycast(t);this._currentlyActiveRaycaster=null,n&&n.length>0&&this._sortedHits.push(...n)}return this._sortedHits.sort((i,n)=>i.distance-n.distance),this._sortedHits}assignHitInformation(t,i){i?(t.intersection=i,t.point=i.point,t.normal=i.normal,t.face=i.face,t.distance=i.distance,t.instanceId=i.instanceId):(t.intersection=void 0,t.point=void 0,t.normal=void 0,t.face=void 0,t.distance=void 0,t.instanceId=void 0)}handleIntersections(t,i){var r;if(t!=null&&t.length){t=this.sortCandidates(t);for(const o of t){if(i.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(i,o),this.handleEventOnObject(o.object,i))return!0}}this.assignHitInformation(i,t==null?void 0:t[0]),this.invokePointerCapture(i);const n=this.hoveredByID.get(i.pointerId);return n&&this.propagatePointerExit(n.obj,n.data,null),this.hoveredByID.delete(i.pointerId),i.isUp&&((r=this.pressedByID.get(i.pointerId))==null||r.handlers.forEach(o=>this.invokeOnPointerUp(i,o)),this.pressedByID.delete(i.pointerId)),!1}sortCandidates(t){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let i=0;i<t.length;i++){const n=t[i],r=n.object;if(r.material&&r.material.depthTest===!1){this._noDepthTestingResults.push(n);continue}this._sortingBuffer.push(n)}for(const i of this._sortingBuffer)this._noDepthTestingResults.push(i);return this._noDepthTestingResults}handleEventOnObject(t,i){if(!this.testIsVisible(t))return i.isClick&&kh&&console.log("not allowed",t),!1;if(i.pointerId===void 0)return kh&&console.error("Event without pointer can't be handled",i),!1;i.object=t;const n=t.parent,r=i.isClick??!1;let o=null;if(n&&n.isUI){const u=(i.isPressed||i.isClick)??!1;if(n[rl]){const f=n[rl].gameObject;if(f){if(!pT.isInteractable(f,this.out))return!1;o=this.out.canvasGroup??null,this.handleMeshUIIntersection(t,u),t=f}}}r&&kh&&console.log(this.context.time.frame,t);const a=this.hoveredByID.get(i.pointerId),l=a==null?void 0:a.obj;l!==t&&l&&this.propagatePointerExit(l,a.data,t);const h=this.hoveredByID.get(i.pointerId);if(h?(h.obj=t,h.data=i):this.hoveredByID.set(i.pointerId,{obj:t,data:i}),i.isDown){const u=this.pressedByID.get(i.pointerId);u?(u.obj=t,u.data=i):this.pressedByID.set(i.pointerId,{obj:t,data:i,handlers:new Set})}return(o===null||o.interactable)&&this.handleMainInteraction(t,i,l??null),!0}propagate(t,i){for(;t;)ne.foreachComponent(t,n=>{i(n)},!1),t=t.parent}handleMainInteraction(t,i,n){const r=this.pressedByID.get(i.pointerId),o=n!==t;let a=!0;switch(i.event.pointerType){case"mouse":case"touch":const l=this.context.input.getPointerPositionLastFrame(i.pointerId),c=this.context.input.getPointerPosition(i.pointerId);a=l&&!tt.approximately(l,c);break}this.propagate(t,l=>{var h;const c=l;c.interactable!==!1&&(!c.activeAndEnabled||!c.enabled||(c.onPointerEnter&&o&&this.handlePointerEnter(c,i),i.isDown&&c.onPointerDown&&(c.onPointerDown(i),r==null||r.handlers.add(c),this.handlePointerCapture(i,c)),c.onPointerMove&&(a&&c.onPointerMove(i),this.handlePointerCapture(i,c)),i.isUp&&(c.onPointerUp&&(this.invokeOnPointerUp(i,c),r==null||r.handlers.delete(c)),c.onPointerExit&&((h=i.event)==null?void 0:h.pointerType)===KE.Touch&&(this.handlePointerExit(c,i),this.hoveredByID.delete(i.pointerId))),i.isClick&&c.onPointerClick&&c.onPointerClick(i)))}),i.isUp&&(r==null||r.handlers.forEach(l=>{this.invokeOnPointerUp(i,l)}),this.pressedByID.delete(i.pointerId))}propagatePointerExit(t,i,n){this.propagate(t,r=>{if(!r.gameObject||r.destroyed)return;const o=r;if(o.onPointerExit||o.onPointerEnter){if(n&&this.isChild(n,r.gameObject))return;this.handlePointerExit(o,i)}})}invokeOnPointerUp(t,i){var n;(n=i.onPointerUp)==null||n.call(i,t),this.releasePointerCapture(t,i)}handlePointerEnter(t,i){t.onPointerEnter&&this.updatePointerState(t,i.pointerId,this.pointerEnterSymbol,!0)&&t.onPointerEnter(i),this.updatePointerState(t,i.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(t,i){t.onPointerExit&&this.updatePointerState(t,i.pointerId,this.pointerExitSymbol,!0)&&t.onPointerExit(i),this.updatePointerState(t,i.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(t,i,n,r){let o=t[n];if(r)return o&&o.includes(i)?!1:(o=o||[],o.push(i),t[n]=o,!0);{if(!o||!o.includes(i))return!1;const a=o.indexOf(i);return a!==-1&&o.splice(a,1),!0}}handlePointerCapture(t,i){if(t.z__pointer_ctured){t.z__pointer_ctured=!1;const n=t.pointerId;if(i.onPointerMove){const r=this._capturedPointer[n]||[];r.push(i),this._capturedPointer[n]=r}else Ze()&&!i.z__warned_no_pointermove&&(i.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 t.z__pointer_cture_rleased&&(t.z__pointer_cture_rleased=!1,this.releasePointerCapture(t,i))}releasePointerCapture(t,i){const n=t.pointerId;if(this._capturedPointer[n]){const r=this._capturedPointer[n].indexOf(i);r!==-1&&(this._capturedPointer[n].splice(r,1),kh&&console.log("released pointer capture",n,i,this._capturedPointer))}}invokePointerCapture(t){var i;if(t.event.type===xn.PointerMove){const n=t.pointerId,r=this._capturedPointer[n];if(r){kh&&console.log("Captured",n,r);for(let o=0;o<r.length;o++){const a=r[o];if(a.destroyed){r.splice(o,1),o--;continue}(i=a.onPointerMove)==null||i.call(a,t)}}}}isChild(t,i){return!t||!i?!1:t===i?!0:t.parent?this.isChild(t.parent,i):!1}handleMeshUiObjectWithoutShadowDom(t,i){return!t||!t.isUI?!0:this.handleMeshUIIntersection(t,i)}handleMeshUIIntersection(t,i){const n=Ad.updateState(t,i);return n&&this.currentActiveMeshUIComponents.push(n),n!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&Ad.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let t=0;t<this.currentActiveMeshUIComponents.length;t++){const i=this.currentActiveMeshUIComponents[t];Ad.resetState(i)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(t){return t?ne.isActiveSelf(t)?this.testIsVisible(t.parent):!1:!0}};let No=_c;d(No,"_eventSystemMap",new Map),d(No,"didSearchEventSystem",!1);class Ad{static markDirty(){this.needsUpdate=!0}static update(e,t,i=!1){if(i){e.update();return}const n=t.time.frameCount;for(const r of this.lastUpdateFrame)if(r.context===t){if(n===r.frame)return;r.frame=n;let o=this.needsUpdate||n<1;r.nextUpdate<=n&&(o=!0),o&&(kh&&console.log("Update threemeshui"),this.needsUpdate=!1,r.nextUpdate=n+60,e.update());return}this.lastUpdateFrame=[{context:t,frame:n,nextUpdate:n+60}],e.update(),this.needsUpdate=!1}static updateState(e,t){let i=null;if(e&&(i=this.findBlockInParent(e),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}static resetLastSelected(){const e=this.lastSelected;e&&(this.lastSelected=null,this.resetState(e))}static resetState(e){e&&(this.needsUpdate=!0)}static findBlockInParent(e){return e?e.isBlock?e:this.findBlockInParent(e.parent):null}}d(Ad,"lastSelected",null),d(Ad,"lastUpdateFrame",[]),d(Ad,"needsUpdate",!1);var Q0e=Object.defineProperty,Z0e=Object.getOwnPropertyDescriptor,Tn=(s,e,t,i)=>{for(var n=i>1?void 0:i?Z0e(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Q0e(e,t,n),n};const IL=ie("debugorbit"),LL=ie("freecam"),XS=ie("debugcamerafit"),WS=ie("smoothcam"),j0e={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let PL;class fx extends CustomEvent{constructor(e,t){super("target-reached",{detail:{controls:e,type:t}})}}class Ii extends Te{constructor(){super(...arguments);d(this,"autoTarget",!0);d(this,"autoFit",!1);d(this,"enableRotate",!0);d(this,"autoRotate",!1);d(this,"autoRotateSpeed",1);d(this,"minAzimuthAngle",1/0);d(this,"maxAzimuthAngle",1/0);d(this,"minPolarAngle",0);d(this,"maxPolarAngle",Math.PI);d(this,"enableKeys",!1);d(this,"enableDamping",!0);d(this,"dampingFactor",.1);d(this,"enableZoom",!0);d(this,"minZoom",0);d(this,"maxZoom",1/0);d(this,"zoomSpeed",1);d(this,"zoomToCursor",!1);d(this,"enablePan",!0);d(this,"lookAtConstraint",null);d(this,"lookAtConstraint01",1);d(this,"allowInterrupt",!0);d(this,"middleClickToFocus",!0);d(this,"doubleClickToFocus",!0);d(this,"clickBackgroundToFitScene",2);d(this,"debugLog",!1);d(this,"targetLerpDuration",1);d(this,"_controls",null);d(this,"_cameraObject",null);d(this,"_lookTargetLerpActive",!1);d(this,"_lookTargetStartPosition",new M);d(this,"_lookTargetEndPosition",new M);d(this,"_lookTargetLerp01",0);d(this,"_lookTargetLerpDuration",0);d(this,"_cameraLerpActive",!1);d(this,"_cameraStartPosition",new M);d(this,"_cameraEndPosition",new M);d(this,"_cameraLerp01",0);d(this,"_cameraLerpDuration",0);d(this,"_fovLerpActive",!1);d(this,"_fovLerpStartValue",0);d(this,"_fovLerpEndValue",0);d(this,"_fovLerp01",0);d(this,"_fovLerpDuration",0);d(this,"_inputs",0);d(this,"_enableTime",0);d(this,"_startedListeningToKeyEvents",!1);d(this,"_eventSystem");d(this,"_afterHandleInputFn");d(this,"_camera",null);d(this,"_syncedTransform");d(this,"_didSetTarget",0);d(this,"targetElement",null);d(this,"_activePointerEvents");d(this,"_lastTimeClickOnBackground",-1);d(this,"_clickOnBackgroundCount",0);d(this,"_onPointerDown",t=>{this._activePointerEvents.push(t)});d(this,"_onPointerUp",t=>{for(let i=this._activePointerEvents.length-1;i>=0;i--){const n=this._activePointerEvents[i];if(n.pointerId===t.pointerId&&n.button===t.button){this._activePointerEvents.splice(i,1);break}}if(this.clickBackgroundToFitScene>0&&t.isClick&&t.button===0){if(t.hasRay||t.intersections.push(...this.context.physics.raycast()),t.intersections.length<=0){const i=this.context.time.time-this._lastTimeClickOnBackground;this._lastTimeClickOnBackground=this.context.time.time,this.clickBackgroundToFitScene<=1||i<this.clickBackgroundToFitScene*.15?(this._clickOnBackgroundCount+=1,this._clickOnBackgroundCount>=this.clickBackgroundToFitScene-1&&this.fitCamera(this.context.scene.children,{immediate:!1})):this._clickOnBackgroundCount=0}IL&&console.log(this.clickBackgroundToFitScene,t.intersections.length,this._clickOnBackgroundCount)}});d(this,"_onPointerUpLate",t=>{this.doubleClickToFocus&&t.isDoubleClick&&!t.used&&this.setTargetFromRaycast()});d(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});d(this,"_shouldDisable",!1);d(this,"__onPreRender",()=>{const t=this.context.pre_render_callbacks.indexOf(this.__onPreRender);t>=0&&this.context.pre_render_callbacks.splice(t,1),this.autoFit&&(this.autoFit=!1,this.fitCamera({centerCamera:"y",immediate:!0,objects:this.scene.children}))});d(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(t){var i;(i=this.controls)==null||i.addEventListener("start",t)}get targetLerpSpeed(){return 5}set targetLerpSpeed(t){this.targetLerpDuration=1/t}awake(){this._didSetTarget=0,this._startedListeningToKeyEvents=!1}start(){this._eventSystem=No.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(KB.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var t,i;(t=this._controls)==null||t.dispose(),(i=this._eventSystem)==null||i.removeEventListener(KB.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._didSetTarget=0,this._enableTime=this.context.time.time;const t=ne.getComponent(this.gameObject,Xi);this._camera=t;let i=t==null?void 0:t.threeCamera;if(!i&&this.gameObject instanceof kt&&(i=this.gameObject),i&&zP(i,this,!0),!this._controls&&i instanceof kt){this._cameraObject=i;const n=this.targetElement??this.context.renderer.domElement,r=i==null?void 0:i.quaternion.clone();this._controls=new kY(i,n),i==null||i.quaternion.copy(r),PL===void 0&&(PL={...this._controls.keys})}this._controls&&(LL&&(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=ne.getComponent(this.gameObject,Jc)??void 0,this.context.pre_render_callbacks.push(this.__onPreRender),this._activePointerEvents=[],this.context.input.addEventListener("pointerdown",this._onPointerDown,{queue:fa.Early}),this.context.input.addEventListener("pointerup",this._onPointerUp,{queue:fa.Early}),this.context.input.addEventListener("pointerup",this._onPointerUpLate,{queue:fa.Late})}onDisable(){var t;(t=this._camera)!=null&&t.threeCamera&&zP(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(t){t.detail.args.pointerId===0&&(t.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!t.detail.args.isPressed||t.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var i,n,r,o;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)&&((i=this.context.input.getPointerPositionDelta(0))!=null&&i.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 a=ne.getComponent(this.gameObject,Xi);if(a&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const l=zt(a.threeCamera),c=Math.max(.01,l.length()),h=new M(0,0,-c).applyMatrix4(a.threeCamera.matrixWorld);this.setLookTargetPosition(h,!0)}if(!this.setLookTargetFromConstraint()){const l=new Kc;l.screenPoint=new ee(0,0),l.lineThreshold=.1;const c=this.context.physics.raycast(l);c.length>0&&this.setLookTargetPosition(c[0].point,!0),XS&&console.log("OrbitControls hits",...c)}}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 fx(this,"camera"));else{const a=tt.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,a)}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 fx(this,"lookat"));else{const a=tt.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,a)}if(this._fovLerpActive&&this._cameraObject){const a=this._cameraObject;if(this._fovLerp01+=this.context.time.deltaTime/this._fovLerpDuration,this._fovLerp01>=1)a.fov=this._fovLerpEndValue,this._fovLerpActive=!1;else{const l=tt.easeInOutCubic(this._fovLerp01);a.fov=tt.lerp(this._fovLerpStartValue,this._fovLerpEndValue,l)}a.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(a=>a.used),this._controls.keys=this.enableKeys?PL:j0e,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,LL||(((r=(n=this._camera)==null?void 0:n.threeCamera)==null?void 0:r.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 WS=="number"||WS===!0){this._controls.enableDamping=!0;const a=typeof WS=="number"?WS:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,a))}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||(!LL&&((o=this.lookAtConstraint)!=null&&o.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(this.context.time.deltaTime),IL&&ft.DrawWireSphere(this._controls.target,.1,65280))}}setCameraAndLookTarget(t){if(!t||!(t instanceof me))return;const i=zt(t),n=nO(t);this.setTargetFromRaycast(new So(i,n)),this.setCameraTargetPosition(i)}setCameraTargetPosition(t,i=!1){var n;t&&(t instanceof me&&(t=zt(t)),this._cameraEndPosition||(this._cameraEndPosition=new M),this._cameraEndPosition.copy(t),i===!0?(this._cameraLerpActive=!1,this._cameraObject&&this._cameraObject.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((n=this._cameraObject)==null?void 0:n.position),typeof i=="number"?this._cameraLerpDuration=i:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setFieldOfView(t,i=!1){var r;if(!this._controls||typeof t!="number")return;const n=(r=this._camera)==null?void 0:r.threeCamera;n&&(i===!0?n.fov=t:(this._fovLerpActive=!0,this._fovLerp01=0,this._fovLerpStartValue=n.fov,this._fovLerpEndValue=t,typeof i=="number"?this._fovLerpDuration=i:this._fovLerpDuration=this.targetLerpDuration))}setLookTargetPosition(t=null,i=!1){this._controls&&t&&(t instanceof me&&(t=zt(t)),this._lookTargetEndPosition.copy(t),this._didSetTarget++,IL&&(console.warn("OrbitControls: setLookTargetPosition",t,i),ft.DrawWireSphere(this._lookTargetEndPosition,.2,16711680,2)),i===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof i=="number"?this._lookTargetLerpDuration=i:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(t=0,i=1){var r;if(!this._controls)return!1;const n=(r=this.lookAtConstraint)==null?void 0:r.sources;if(n&&n.length>0){const o=n[t];if(o)return o.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,i),!0}return!1}lerpTarget(t,i){return this.lerpLookTarget(t,i)}lerpLookTarget(t,i){this._controls&&(i>=1?this._controls.target.copy(t):this._controls.target.lerp(t,i))}setTargetFromRaycast(t){if(!this.controls)return;const i=t?this.context.physics.raycastFromRay(t):this.context.physics.raycast();for(const n of i)if(n.distance>0&&ne.isActiveInHierarchy(n.object)){const r=bF(n.object);if(r){const o=r.canvas;if(o!=null&&o.screenspace)break}this.setLookTargetPosition(n.point);break}}fitCamera(t,i){var L,k;if(this.context.isInXR)return;let n;if(Array.isArray(t)?n=t:t&&"type"in t?n=t.children:t&&"objects"in t&&(n=t==null?void 0:t.objects,i=t),n&&!Array.isArray(n)&&(n=n.children),(!Array.isArray(n)||n&&n.length<=0)&&(n=this.context.scene.children),!Array.isArray(n)||n.length<=0){console.warn("No objects to fit camera to...");return}const r=this._cameraObject,o=this._controls;if(!r||!o){console.warn("No camera or controls found to fit camera to objects...");return}i||(i={});const{immediate:a=!1,centerCamera:l="y",cameraNearFar:c="auto",fitOffset:h=1.1,fov:u=r==null?void 0:r.fov}=i,f=new M,p=new M,m=Ra(n,void 0,(k=(L=this._camera)==null?void 0:L.threeCamera)==null?void 0:k.layers),b=m.clone();r.updateMatrixWorld(),r.updateProjectionMatrix(),m.getCenter(p);const g=new M;if(m.getSize(g),m.applyMatrix4(r.matrixWorldInverse),m.getSize(f),m.setFromCenterAndSize(p,f),Number.isNaN(f.x)||Number.isNaN(f.y)||Number.isNaN(f.z)){console.warn("Camera fit size resultet in NaN",r,m,[...n]);return}if(f.length()<=1e-10){XS&&console.warn("Camera fit size is zero",m,[...n]);return}const y=i.fov||r.fov,A=2*Math.atan(Math.tan(y*Math.PI/360/2)*r.aspect)/Math.PI*360,v=f.y/(2*Math.atan(Math.PI*y/360)),x=f.x/(2*Math.atan(Math.PI*A/360)),_=h*Math.max(v,x)+f.z/2;XS&&console.log("Fit camera to objects",{fitHeightDistance:v,fitWidthDistance:x,distance:_,verticalFov:y,horizontalFov:A}),this.maxZoom=_*10,this.minZoom=_*.01;const w=.05,C=p.clone();if(C.y-=f.y*w,this.setLookTargetPosition(C,a),this.setFieldOfView(i.fov,a),this.autoTarget=!1,c==null||c=="auto"){const P=ne.findObjectOfType(sh),U=P?P.radius:0,O=Math.max(g.x,g.y,g.z,U);r.near=_/100,r.far=O+_*10,P&&(this.maxZoom=Math.max(Math.min(this.maxZoom,U*.5),_))}const T=o.getDistance();T<this.minZoom&&(this.minZoom=T*.9),T>this.maxZoom&&(this.maxZoom=T*1.1),r.updateMatrixWorld(),r.updateProjectionMatrix();const R=zt(r),S=p.clone();S.sub(R),l==="y"&&(S.y=0),S.normalize(),S.multiplyScalar(_),l==="y"&&(S.y+=-w*4*_);let I=p.clone().sub(S);if(r.parent&&(I=r.parent.worldToLocal(I)),this.setCameraTargetPosition(I,a),XS){const P=new CD(m);this.context.scene.add(P),oO(P,qx(r)),setTimeout(()=>{this.context.scene.remove(P)},1e4),ft.DrawWireBox3(b,65280,10),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",U=>{if(U.code==="KeyF"){let O;this._cameraObject instanceof kt&&(O=Math.random()*Math.random()*170+10),this.fitCamera({objects:n,fitOffset:h,immediate:!1,fov:O})}U.code==="KeyV"&&this._cameraObject instanceof kt&&(this._cameraObject.fov=60)}))}o.update()}}Tn([E()],Ii.prototype,"autoTarget",2);Tn([E()],Ii.prototype,"autoFit",2);Tn([E()],Ii.prototype,"enableRotate",2);Tn([E()],Ii.prototype,"autoRotate",2);Tn([E()],Ii.prototype,"autoRotateSpeed",2);Tn([E()],Ii.prototype,"minAzimuthAngle",2);Tn([E()],Ii.prototype,"maxAzimuthAngle",2);Tn([E()],Ii.prototype,"minPolarAngle",2);Tn([E()],Ii.prototype,"maxPolarAngle",2);Tn([E()],Ii.prototype,"enableKeys",2);Tn([E()],Ii.prototype,"enableDamping",2);Tn([E()],Ii.prototype,"dampingFactor",2);Tn([E()],Ii.prototype,"enableZoom",2);Tn([E()],Ii.prototype,"minZoom",2);Tn([E()],Ii.prototype,"maxZoom",2);Tn([E()],Ii.prototype,"zoomSpeed",2);Tn([E()],Ii.prototype,"enablePan",2);Tn([E(Sm)],Ii.prototype,"lookAtConstraint",2);Tn([E()],Ii.prototype,"lookAtConstraint01",2);Tn([E()],Ii.prototype,"allowInterrupt",2);Tn([E()],Ii.prototype,"middleClickToFocus",2);Tn([E()],Ii.prototype,"doubleClickToFocus",2);Tn([E()],Ii.prototype,"clickBackgroundToFitScene",2);Tn([E()],Ii.prototype,"targetLerpDuration",2);var Y0e=Object.defineProperty,K0e=Object.getOwnPropertyDescriptor,Co=(s,e,t,i)=>{for(var n=i>1?void 0:i?K0e(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Y0e(e,t,n),n},Ud=(s=>(s[s.None=0]="None",s[s.Skybox=1]="Skybox",s[s.SolidColor=2]="SolidColor",s[s.Uninitialized=4]="Uninitialized",s))(Ud||{});const ud=ie("debugcam"),m5=ie("debugscreenpointtoray");var F1;const Fv=(F1=class extends Te{constructor(){super(...arguments);d(this,"_nearClipPlane",.1);d(this,"_farClipPlane",1e3);d(this,"orthographic",!1);d(this,"orthographicSize",5);d(this,"ARBackgroundAlpha",0);d(this,"_cullingMask",4294967295);d(this,"_backgroundBlurriness");d(this,"_backgroundIntensity");d(this,"_backgroundRotation");d(this,"_environmentIntensity");d(this,"_targetTexture",null);d(this,"_backgroundColor");d(this,"_fov");d(this,"_cam",null);d(this,"_clearFlags",2);d(this,"_skybox");d(this,"_frustum");d(this,"_projScreenMatrix",new he)}get isCamera(){return!0}get aspect(){return this._cam instanceof kt?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(e){this._cam instanceof kt&&this._cam.aspect!==e&&(this._cam.aspect=e,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof kt?this._cam.fov:this._fov}set fieldOfView(e){const t=this.fieldOfView!=e;if(this._fov=e,t&&this._cam&&this._cam instanceof kt){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(e){const t=this._nearClipPlane!=e;this._nearClipPlane=e,this._cam&&(t||this._cam.near!=e)&&(this._cam.near=e,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(e){const t=this._farClipPlane!=e;this._farClipPlane=e,this._cam&&(t||this._cam.far!=e)&&(this._cam.far=e,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(e){e!==this._clearFlags&&(this._clearFlags=e,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(e){this._cullingMask=e,this._cam&&(this._cam.layers.mask=e)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(e){this.cullingMask=(1<<e|0)>>>0}set backgroundBlurriness(e){e!==this._backgroundBlurriness&&(e===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(e,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(e){e!==this._backgroundIntensity&&(e===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(e,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set backgroundRotation(e){e!==this._backgroundRotation&&(e===void 0?this._backgroundRotation=void 0:this._backgroundRotation=e,this.applyClearFlagsIfIsActiveCamera())}get backgroundRotation(){return this._backgroundRotation}set environmentIntensity(e){this._environmentIntensity=e}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(e){if(e){if(this._backgroundColor)this._backgroundColor.copy(e);else{if(!e.clone)return;this._backgroundColor=e.clone()}e.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(e){this._targetTexture=e}get targetTexture(){return this._targetTexture}get cam(){return this.threeCamera}get threeCamera(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(e,t,i){const n=this.threeCamera,r=Fv._origin;r.set(e,t,-1),this.context.input.convertScreenspaceToRaycastSpace(r),m5&&console.log("screenPointToRay",e.toFixed(2),t.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(n);const o=Fv._direction.set(r.x,r.y,r.z),a=zt(n);return o.sub(a),o.normalize(),i?(i.set(a,o),i):new So(a.clone(),o.clone())}getFrustum(){return this._frustum||(this._frustum=new im,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new im),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(e,t){return t&&this._projScreenMatrix.multiplyMatrices(this.threeCamera.projectionMatrix,this.threeCamera.matrixWorldInverse),e===this._projScreenMatrix?e:e.copy(this._projScreenMatrix)}awake(){m5&&window.addEventListener("pointerdown",e=>{const t=e.clientX,i=e.clientY;console.log("touch",t.toFixed(2),i.toFixed(2));const n=this.screenPointToRay(t,i),r="#"+Math.floor(Math.random()*16777215).toString(16);ft.DrawRay(n.origin,n.direction,r,10)})}onEnable(){ud&&console.log(`Camera enabled: "${this.name}". ClearFlags=${Ud[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),q0e(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 e=this.context.renderer;if(e){const t=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,e),t==null||t.applyClearFlags()}}}buildCamera(){if(this._cam)return;const e=this.gameObject.isCamera;let t=null;if(e?(t=this.gameObject,t==null||t.layers.enableAll(),t instanceof kt&&(this._fov=t.fov)):t=this.gameObject.children[0],t&&t.isCamera)t instanceof kt&&(this._fov&&(t.fov=this._fov),t.near=this._nearClipPlane,t.far=this._farClipPlane,t.updateProjectionMatrix());else if(!this.orthographic)t=new kt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(t.fov=this.fieldOfView),this.gameObject.add(t);else{const i=this.orthographicSize*100;t=new eh(window.innerWidth/-i,window.innerWidth/i,window.innerHeight/i,window.innerHeight/-i,this._nearClipPlane,this._farClipPlane),this.gameObject.add(t)}this._cam=t,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(e){this.context.mainCameraComponent===this&&this.applyClearFlags(e)}applyClearFlags(e){var t;if(!this._cam){ud&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,ud){const i=`Camera "${this.name}" clear flags: ${Ud[this._clearFlags]}`;console.debug(i)}switch(this._clearFlags){case 0:return;case 1:if(Fv.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||(e==null?void 0:e.applySkybox)===!0)&&this.applySceneSkybox(),this._backgroundBlurriness!==void 0?this.context.scene.backgroundBlurriness=this._backgroundBlurriness:ud&&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:ud&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let i=this._backgroundColor.alpha;Fv.backgroundShouldBeTransparent(this.context)&&(i=this.ARBackgroundAlpha??0),this.context.scene.background=null,(t=this.context.xr)!=null&&t.isVR?this.context.renderer.setClearColor(F9(this._backgroundColor).convertLinearToSRGB()):this.context.renderer.setClearColor(this._backgroundColor,i)}else ud&&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 J0e(this)),this._skybox.apply()}static backgroundShouldBeTransparent(e){var r,o,a,l;const t=(r=e.renderer.xr)==null?void 0:r.getSession();if(!t)return!1;if(typeof t._transparent=="boolean")return t._transparent;const i=t.environmentBlendMode;ud&&wn("Environment blend mode: "+i+" on "+navigator.userAgent);let n=i==="additive"||i==="alpha-blend";return e.isInAR&&i==="opaque"&&((o=navigator.userAgent)!=null&&o.includes("OculusBrowser")||(a=navigator.userAgent)!=null&&a.includes("Mozilla")&&((l=navigator.userAgent)!=null&&l.includes("Mobile WebXRViewer/v2")))&&(n=!0),t._transparent=n,n}},d(F1,"_origin",new M),d(F1,"_direction",new M),F1);let Xi=Fv;Co([E()],Xi.prototype,"aspect",1);Co([E()],Xi.prototype,"fieldOfView",1);Co([E()],Xi.prototype,"nearClipPlane",1);Co([E()],Xi.prototype,"farClipPlane",1);Co([E()],Xi.prototype,"clearFlags",1);Co([E()],Xi.prototype,"orthographic",2);Co([E()],Xi.prototype,"orthographicSize",2);Co([E()],Xi.prototype,"ARBackgroundAlpha",2);Co([E()],Xi.prototype,"cullingMask",1);Co([E()],Xi.prototype,"backgroundBlurriness",1);Co([E()],Xi.prototype,"backgroundIntensity",1);Co([E(oi)],Xi.prototype,"backgroundRotation",1);Co([E()],Xi.prototype,"environmentIntensity",1);Co([E(Bi)],Xi.prototype,"backgroundColor",1);Co([E(Nd)],Xi.prototype,"targetTexture",1);class J0e{constructor(e){d(this,"_camera");d(this,"_skybox");this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}apply(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(ud&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=vo,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 q0e(s){ie("freecam")&&s.context.mainCameraComponent===s&&ne.getOrAddComponent(s.gameObject,Ii)}class Vd extends Te{constructor(){super(...arguments);d(this,"_listener",null);d(this,"onInteraction",()=>{this.destroyed||this.listener==null||this.addListenerIfItExists()})}get listener(){return this._listener==null&&(this._listener=new v4),this._listener}onEnable(){Ql.registerWaitForInteraction(this.onInteraction),this.addListenerIfItExists()}onDisable(){Ql.unregisterWaitForInteraction(this.onInteraction),this.removeListenerIfItExists()}addListenerIfItExists(){const t=this._listener;if(!t||t!=null&&t.parent)return;const i=this.context.mainCameraComponent||ne.getComponentInParent(this.gameObject,Xi);i!=null&&i.threeCamera?i.threeCamera.add(t):this.gameObject.add(t),t.filter?(t.gain.connect(t.filter),t.filter.connect(t.context.destination)):t.gain.connect(t.context.destination)}removeListenerIfItExists(){const t=this._listener;t&&(t.removeFromParent(),t.filter&&t.filter.disconnect(),t.gain&&t.gain.disconnect())}}var $0e=Object.defineProperty,eye=Object.getOwnPropertyDescriptor,nc=(s,e,t,i)=>{for(var n=i>1?void 0:i?eye(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&$0e(e,t,n),n};const Dr=ie("debugaudio"),dd=class extends Te{constructor(){super(...arguments);d(this,"clip","");d(this,"playOnAwake",!1);d(this,"preload",!1);d(this,"playInBackground",!0);d(this,"_spatialBlend",0);d(this,"_minDistance",1);d(this,"_maxDistance",100);d(this,"_volume",1);d(this,"rollOffMode",0);d(this,"_loop",!1);d(this,"sound",null);d(this,"helper",null);d(this,"wasPlaying",!1);d(this,"audioLoader",null);d(this,"shouldPlay",!1);d(this,"_lastClipStartedLoading",null);d(this,"_audioElement",null);d(this,"onVisibilityChanged",()=>{switch(document.visibilityState){case"hidden":(this.playInBackground===!1||exports.DeviceUtilities.isMobileDevice())&&(this.wasPlaying=this.isPlaying,this.isPlaying&&this.pause());break;case"visible":Dr&&console.log("visible",this.enabled,this.playOnAwake,!this.isPlaying,dd.userInteractionRegistered,this.wasPlaying),this.enabled&&this.playOnAwake&&!this.isPlaying&&dd.userInteractionRegistered&&this.wasPlaying&&this.play();break}});d(this,"onApplicationMuteChanged",()=>{var e,t;this.context.application.muted?(e=this.sound)==null||e.setVolume(0):(t=this.sound)==null||t.setVolume(this.volume)});d(this,"createAudio",e=>{Dr&&console.log("AudioBuffer finished loading",e);const t=this.Sound;if(!t){Dr&&console.warn("Failed getting sound?",this.name);return}t.isPlaying&&t.stop(),e&&t.setBuffer(e),t.loop=this._loop,this.context.application.muted?t.setVolume(0):t.setVolume(this.volume),t.autoplay=this.shouldPlay&&dd.userInteractionRegistered,this.applySpatialDistanceSettings(),t.isPlaying&&t.stop(),dd.registerWaitForAllowAudio(this.__onAllowAudioCallback)});d(this,"__onAllowAudioCallback",()=>{this.shouldPlay&&this.play()});d(this,"_lastContextTime",0);d(this,"_hasEnded",!0);d(this,"_needUpdateSpatialDistanceSettings",!1)}static get userInteractionRegistered(){return Ql.userInteractionRegistered}static registerWaitForAllowAudio(e){Ql.registerWaitForInteraction(e)}get isPlaying(){var e;return((e=this.sound)==null?void 0:e.isPlaying)??!1}get duration(){var e,t;return(t=(e=this.sound)==null?void 0:e.buffer)==null?void 0:t.duration}get time01(){var t;const e=this.duration;return e&&this.sound?((t=this.sound)==null?void 0:t.context.currentTime)/e:0}set time01(e){const t=this.duration;t&&this.sound&&(this.time=e*t)}get time(){var e,t;return(e=this.sound)!=null&&e.source?((t=this.sound.source)==null?void 0:t.context.currentTime)-this._lastContextTime+this.sound.offset:0}set time(e){if(this.sound){if(e===this.sound.offset)return;const t=this.isPlaying;this.stop(),this.sound.offset=e,t&&this.play()}}get loop(){return this.sound&&(this._loop=this.sound.getLoop()),this._loop}set loop(e){this._loop=e,this.sound&&this.sound.setLoop(e)}get spatialBlend(){return this._spatialBlend}set spatialBlend(e){e!==this._spatialBlend&&(this._spatialBlend=e,this._needUpdateSpatialDistanceSettings=!0)}get minDistance(){return this._minDistance}set minDistance(e){this._minDistance!==e&&(this._minDistance=e,this._needUpdateSpatialDistanceSettings=!0)}get maxDistance(){return this._maxDistance}set maxDistance(e){this._maxDistance!==e&&(this._maxDistance=e,this._needUpdateSpatialDistanceSettings=!0)}get volume(){return this._volume}set volume(e){this._volume=e,this.sound&&!this.context.application.muted&&(Dr&&console.log(this.name,"audio set volume",e),this.sound.setVolume(e))}set pitch(e){this.sound&&this.sound.setPlaybackRate(e)}get pitch(){return this.sound?this.sound.getPlaybackRate():1}get Sound(){var e;if(!this.sound&&dd.userInteractionRegistered){let t=ne.getComponent(this.context.mainCamera,Vd)??ne.findObjectOfType(Vd,this.context);!t&&this.context.mainCamera&&(t=ne.addComponent(this.context.mainCamera,Vd)),t!=null&&t.listener?(this.sound=new A4(t.listener),(e=this.gameObject)==null||e.add(this.sound)):Dr&&console.warn("No audio listener found in scene - can not play audio")}return this.sound}get ShouldPlay(){return this.shouldPlay}get audioContext(){var e;return(e=this.sound)==null?void 0:e.context}awake(){Dr&&console.log(this),this.audioLoader=new HC,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),dd.userInteractionRegistered?this.playOnAwake&&this.context.application.isVisible&&this.play():dd.registerWaitForAllowAudio(()=>{this.enabled&&!this.destroyed&&this.shouldPlay&&this.onNewClip(this.clip)}),globalThis.addEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.addEventListener(fM.MuteChanged,this.onApplicationMuteChanged)}onDisable(){globalThis.removeEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.removeEventListener(fM.MuteChanged,this.onApplicationMuteChanged),this.pause()}applySpatialDistanceSettings(){const e=this.sound;if(!e)return;this._needUpdateSpatialDistanceSettings=!1;const t=tt.lerp(10*this._maxDistance/Math.max(1e-4,this.spatialBlend),this._minDistance,this.spatialBlend);switch(Dr&&console.log(this.name,this._minDistance,this._maxDistance,this.spatialBlend,"Ref distance="+t),e.setRefDistance(t),e.setMaxDistance(Math.max(.01,this._maxDistance)),this.rollOffMode){case 0:e.setDistanceModel("exponential");break;case 1:e.setDistanceModel("linear");break;case 2:console.warn("Custom rolloff for AudioSource is not supported: "+this.name);break}this.spatialBlend>0?Dr&&!this.helper&&(this.helper=new u0e(e,e.getRefDistance()),e.add(this.helper)):this.helper&&this.helper.parent&&this.helper.removeFromParent()}async onNewClip(e){if(e&&(this.clip=e),typeof e=="string")if(Dr&&console.log(e),e.endsWith(".mp3")||e.endsWith(".wav")){if(this.audioLoader||(this.audioLoader=new HC),this.shouldPlay=!0,this._lastClipStartedLoading===e){Dr&&console.log("Is currently loading:",this._lastClipStartedLoading,this);return}this._lastClipStartedLoading=e,Dr&&console.log("load audio",e);const t=await this.audioLoader.loadAsync(e).catch(console.error);this._lastClipStartedLoading=null,t&&this.createAudio(t)}else console.warn("Unsupported audio clip type",e);else this.shouldPlay=!0,this.createAudio()}play(e=void 0){var i,n,r;!e&&this.clip&&(e=this.clip),e!==void 0&&typeof e!="string"&&!(e instanceof MediaStream)&&(Ze()&&console.warn("Called play on AudioSource with unknown argument type:",e+`
5956
+ Could not find method ${c.method} on object ${u.name}`,u,typeof u[c.method])};if(typeof u[c.method]!="function"){let b=!1,g=u;for(;g;){const y=Object.getOwnPropertyDescriptor(g,c.method);if(y&&(y.writable===!0||y.set)){b=!0;break}g=Object.getPrototypeOf(g)}!b&&(Ze()||Xs)&&p()}}if(u){let p=c.argument;if(p!==void 0?p=h(p):c.arguments!==void 0&&(p=c.arguments.map(h)),!u[c.method])console.warn(`EventList method not found: "${c.method}" on ${u==null?void 0:u.name}`);else{p!==void 0&&!Array.isArray(p)&&(p=[p]);const b=new Ic(u,c.method,p,c.enabled);o.push(b)}}else Ze()&&console.warn("[Debug] EventList: Could not find event listener in scene",c,t.object,e)}const a=new Yi(o);Xs&&console.log(a);const l=t.target;return l!==void 0&&t.path!==void 0&&a.setEventTarget(t.path,l),a}}}const N0e=new G0e,wM=new WeakMap,z0e=Wt.prototype.clone;Wt.prototype.clone=function(){const s=z0e.call(this);return wM.has(s)||wM.set(s,this),s};class NY extends pl{constructor(){super([Nd,$t])}onSerialize(e,t){}onDeserialize(e,t){if(e instanceof Wt&&t.type===Nd){let i=e;wM.has(i)&&(i=wM.get(i)),i.isRenderTargetTexture=!0,i.flipY=!0,i.offset.y=1,i.repeat.y=-1,i.needsUpdate=!0,i.mipmaps=[],i instanceof Pd&&(i.isCompressedTexture=!1,i.format=Mi);const n=new Nd(i.image.width,i.image.height,{colorSpace:Ui});return n.texture=i,n}}}new NY;class zY extends pl{constructor(){super([URL])}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"&&e.length>0)return lf(t.gltfId,e)}}new zY;var U0e=Object.defineProperty,V0e=Object.getOwnPropertyDescriptor,X0e=(s,e,t,i)=>{for(var n=i>1?void 0:i?V0e(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&U0e(e,t,n),n};class g_ extends Te{awake(){No.createIfNoneExists(this.context)}onEnable(){var e;(e=No.get(this.context))==null||e.register(this)}onDisable(){var e;(e=No.get(this.context))==null||e.unregister(this)}}class La extends g_{constructor(){super(...arguments);d(this,"targets",null);d(this,"raycastHits",[]);d(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(t=null){if(!this.targets)return null;t??(t=new Kc),t.targets=this.targets,t.results=this.raycastHits,t.useAcceleratedRaycast=!0;const i=t.testObject;this.ignoreSkinnedMeshes&&(t.testObject=r=>r instanceof Vo?"continue in children":i?i(r):!0);const n=this.context.physics.raycast(t);return t.testObject=i,n}}X0e([E()],La.prototype,"ignoreSkinnedMeshes",2);class fT extends La{constructor(){super(),this.ignoreSkinnedMeshes=!0}}const zG=class extends g_{performRaycast(e){if(!Et.active||!zG.allow||!(e!=null&&e.ray))return null;const t=e.ray.origin,i=.015;return this.context.physics.sphereOverlap(t,i,!1,!0)}};let zd=zG;d(zd,"allow",!0);class pT{static getObject(e){const t=e[rl];return t&&(t.isComponent===!0?e=t.gameObject:e=t),e}static isInteractable(e,t){if(t&&(t.canvasGroup=void 0,t.graphic=void 0),e==null||!e.visible||(e=this.getObject(e),!e.visible))return!1;const i=this.tryFindCanvasGroup(e);if((i==null?void 0:i.isCanvasGroup)===!0&&(t&&(t.canvasGroup=i),i.blocksRaycasts===!1||i.interactable===!1))return!1;const n=um(e,r=>{if(r.isGraphic===!0)return r},!1);return t&&(n==null?void 0:n.isGraphic)===!0&&(t.graphic=n),!((n==null?void 0:n.raycastTarget)===!1||(n==null?void 0:n.layer)===2)}static tryFindCanvasGroup(e){if(!e)return null;const t=um(e,i=>{const n=i;if(n.blocksRaycasts!==void 0&&n.interactable!==void 0)return n},!1);return t!==void 0?t:this.tryFindCanvasGroup(e.parent)}}function bF(s){const e=s[rl];return e||(s.parent?bF(s.parent):null)}function W0e(s){return s.isUI===!0||typeof s[rl]=="object"}function SM(s,e){if(!s)return;const t=s.material;if((t==null?void 0:t.isMaterial)===!0){const i=s.parent;i&&i.isText,t.side=e.doubleSided??!0?xi:is,t.shadowSide=e.doubleSided?xi:is,s.castShadow=e.castShadows?e.castShadows:!1,s.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const i of s.children)SM(i,e)}function c0(s,e,t){s[e]===void 0&&console.warn("Field",e,"is undefined on",s);const i=Proxy.revocable(s[e],{set(o,a,l,c){const h=o[a],u=Reflect.set(o,a,l,c);return t(l,h),u}}),n=i.revoke,r=s[e];return i.revoke=()=>{s[e]=r,n()},s[e]=i.proxy,i}const p5=Symbol("Scheduled action");function H0e(s,e,t=rn.OnBeforeRender){let i=s[p5];i||(i=s[p5]={});const n=e.name;i[t]||(i[t]={});const r=i[t];if(r[n])return;function*a(){e==null||e.call(s),r[n]=null}const l=s.startCoroutine(a(),t);r[n]=l}const kh=ie("debugeventsystem");var KB=(s=>(s.BeforeHandleInput="BeforeHandleInput",s.AfterHandleInput="AfterHandleInput",s))(KB||{});const _c=class extends Te{constructor(){super();d(this,"raycaster",[]);d(this,"pressedByID",new Map);d(this,"hoveredByID",new Map);d(this,"onPointerEvent",t=>{if(t===void 0||t.propagationStopped||t.defaultPrevented||t.used)return;const i=new Oy(this.context.input,t);this._currentPointerEventName=t.type,i.inputSource=this.context.input,i.isClick=t.isClick,i.isDoubleClick=t.isDoubleClick,i.isDown=t.type==xn.PointerDown,i.isUp=t.type==xn.PointerUp,i.isPressed=this.context.input.getPointerPressed(t.pointerId),kh&&(i.isDown?console.log("DOWN",i.pointerId):i.isUp&&console.log("UP",i.pointerId),i.isClick&&console.log("CLICK",i.pointerId));const n=new Kc;t.hasRay?n.ray=t.ray:n.screenPoint=this.context.input.getPointerPositionRC(t.pointerId);const r=this.performRaycast(n);if(r){for(const a of r)a.event=t,t.intersections.push(a);t.origin.onPointerHits&&t.origin.onPointerHits({sender:this,event:t,hits:r})}kh&&i.isClick&&wn("EventSystem: "+i.pointerId+" - "+this.context.time.frame+" - Up:"+i.isUp+", Down:"+i.isDown);const o={sender:this,args:i,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:o})),this.handleIntersections(r,i),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:o}))});d(this,"_sortedHits",[]);d(this,"_testObjectsCache",new Map);d(this,"_currentlyActiveRaycaster",null);d(this,"_currentPointerEventName",null);d(this,"shouldRaycastObject",t=>{var r;let i=null;if(W0e(t)&&(i=(r=t[rl])==null?void 0:r.gameObject),this._testObjectsCache.has(t)||i&&this._testObjectsCache.has(i))return this._testObjectsCache.get(t)===!1?"continue in children":!0;{let o=_M(t,this._currentPointerEventName);if(!o&&i&&(o=_M(i,this._currentPointerEventName)),o){this._testObjectsCache.set(t,!0);for(const a of t.children)this.shouldRaycastObject_AddToYesCache(a);return!0}return this._testObjectsCache.set(t,!1),"continue in children"}});d(this,"_sortingBuffer",[]);d(this,"_noDepthTestingResults",[]);d(this,"out",{});d(this,"_capturedPointer",{});d(this,"pointerEnterSymbol",Symbol("pointerEnter"));d(this,"pointerExitSymbol",Symbol("pointerExit"));d(this,"currentActiveMeshUIComponents",[]);_c.systems.push(this)}static createIfNoneExists(t){this.didSearchEventSystem||(this.didSearchEventSystem=!0,_c.systems.length<=0&&_c.systems.push(...ne.findObjectsOfType(_c,t)));for(const n of _c.systems)if(n.context===t)return;const i=new me;ne.addComponent(i,_c),t.scene.add(i)}static get systems(){const t=It.Current;return this._eventSystemMap.has(t)||this._eventSystemMap.set(t,[]),this._eventSystemMap.get(t)}static get(t){const i=this._eventSystemMap.get(t);return i&&i.length>0?i[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(t,i,n=!1){Ad.update(t,i,n)}static markUIDirty(t){Ad.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){_c.systems.splice(_c.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!ne.findObjectOfType(g_,this.context)){const i=ne.addComponent(this.context.scene,La);this.raycaster.push(i),(Ze()||kh)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(t){var i;t&&this.raycaster&&!this.raycaster.includes(t)&&((i=this.raycaster)==null||i.push(t))}unregister(t){var n,r;const i=(n=this.raycaster)==null?void 0:n.indexOf(t);i!==void 0&&i!==-1&&((r=this.raycaster)==null||r.splice(i,1))}onEnable(){this.context.input.addEventListener(xn.PointerDown,this.onPointerEvent),this.context.input.addEventListener(xn.PointerUp,this.onPointerEvent),this.context.input.addEventListener(xn.PointerMove,this.onPointerEvent)}onDisable(){this.context.input.removeEventListener(xn.PointerDown,this.onPointerEvent),this.context.input.removeEventListener(xn.PointerUp,this.onPointerEvent),this.context.input.removeEventListener(xn.PointerMove,this.onPointerEvent)}onBeforeRender(){this.resetMeshUIStates()}shouldRaycastObject_AddToYesCache(t){this._testObjectsCache.set(t,!0);for(const i of t.children)this.shouldRaycastObject_AddToYesCache(i)}performRaycast(t){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,t||(t=new Kc),t.testObject=this.shouldRaycastObject;for(const i of this.raycaster){if(!i.activeAndEnabled)continue;this._currentlyActiveRaycaster=i;const n=i.performRaycast(t);this._currentlyActiveRaycaster=null,n&&n.length>0&&this._sortedHits.push(...n)}return this._sortedHits.sort((i,n)=>i.distance-n.distance),this._sortedHits}assignHitInformation(t,i){i?(t.intersection=i,t.point=i.point,t.normal=i.normal,t.face=i.face,t.distance=i.distance,t.instanceId=i.instanceId):(t.intersection=void 0,t.point=void 0,t.normal=void 0,t.face=void 0,t.distance=void 0,t.instanceId=void 0)}handleIntersections(t,i){var r;if(t!=null&&t.length){t=this.sortCandidates(t);for(const o of t){if(i.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(i,o),this.handleEventOnObject(o.object,i))return!0}}this.assignHitInformation(i,t==null?void 0:t[0]),this.invokePointerCapture(i);const n=this.hoveredByID.get(i.pointerId);return n&&this.propagatePointerExit(n.obj,n.data,null),this.hoveredByID.delete(i.pointerId),i.isUp&&((r=this.pressedByID.get(i.pointerId))==null||r.handlers.forEach(o=>this.invokeOnPointerUp(i,o)),this.pressedByID.delete(i.pointerId)),!1}sortCandidates(t){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let i=0;i<t.length;i++){const n=t[i],r=n.object;if(r.material&&r.material.depthTest===!1){this._noDepthTestingResults.push(n);continue}this._sortingBuffer.push(n)}for(const i of this._sortingBuffer)this._noDepthTestingResults.push(i);return this._noDepthTestingResults}handleEventOnObject(t,i){if(!this.testIsVisible(t))return i.isClick&&kh&&console.log("not allowed",t),!1;if(i.pointerId===void 0)return kh&&console.error("Event without pointer can't be handled",i),!1;i.object=t;const n=t.parent,r=i.isClick??!1;let o=null;if(n&&n.isUI){const u=(i.isPressed||i.isClick)??!1;if(n[rl]){const f=n[rl].gameObject;if(f){if(!pT.isInteractable(f,this.out))return!1;o=this.out.canvasGroup??null,this.handleMeshUIIntersection(t,u),t=f}}}r&&kh&&console.log(this.context.time.frame,t);const a=this.hoveredByID.get(i.pointerId),l=a==null?void 0:a.obj;l!==t&&l&&this.propagatePointerExit(l,a.data,t);const h=this.hoveredByID.get(i.pointerId);if(h?(h.obj=t,h.data=i):this.hoveredByID.set(i.pointerId,{obj:t,data:i}),i.isDown){const u=this.pressedByID.get(i.pointerId);u?(u.obj=t,u.data=i):this.pressedByID.set(i.pointerId,{obj:t,data:i,handlers:new Set})}return(o===null||o.interactable)&&this.handleMainInteraction(t,i,l??null),!0}propagate(t,i){for(;t;)ne.foreachComponent(t,n=>{i(n)},!1),t=t.parent}handleMainInteraction(t,i,n){const r=this.pressedByID.get(i.pointerId),o=n!==t;let a=!0;switch(i.event.pointerType){case"mouse":case"touch":const l=this.context.input.getPointerPositionLastFrame(i.pointerId),c=this.context.input.getPointerPosition(i.pointerId);a=l&&!tt.approximately(l,c);break}this.propagate(t,l=>{var h;const c=l;c.interactable!==!1&&(!c.activeAndEnabled||!c.enabled||(c.onPointerEnter&&o&&this.handlePointerEnter(c,i),i.isDown&&c.onPointerDown&&(c.onPointerDown(i),r==null||r.handlers.add(c),this.handlePointerCapture(i,c)),c.onPointerMove&&(a&&c.onPointerMove(i),this.handlePointerCapture(i,c)),i.isUp&&(c.onPointerUp&&(this.invokeOnPointerUp(i,c),r==null||r.handlers.delete(c)),c.onPointerExit&&((h=i.event)==null?void 0:h.pointerType)===KE.Touch&&(this.handlePointerExit(c,i),this.hoveredByID.delete(i.pointerId))),i.isClick&&c.onPointerClick&&c.onPointerClick(i)))}),i.isUp&&(r==null||r.handlers.forEach(l=>{this.invokeOnPointerUp(i,l)}),this.pressedByID.delete(i.pointerId))}propagatePointerExit(t,i,n){this.propagate(t,r=>{if(!r.gameObject||r.destroyed)return;const o=r;if(o.onPointerExit||o.onPointerEnter){if(n&&this.isChild(n,r.gameObject))return;this.handlePointerExit(o,i)}})}invokeOnPointerUp(t,i){var n;(n=i.onPointerUp)==null||n.call(i,t),this.releasePointerCapture(t,i)}handlePointerEnter(t,i){t.onPointerEnter&&this.updatePointerState(t,i.pointerId,this.pointerEnterSymbol,!0)&&t.onPointerEnter(i),this.updatePointerState(t,i.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(t,i){t.onPointerExit&&this.updatePointerState(t,i.pointerId,this.pointerExitSymbol,!0)&&t.onPointerExit(i),this.updatePointerState(t,i.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(t,i,n,r){let o=t[n];if(r)return o&&o.includes(i)?!1:(o=o||[],o.push(i),t[n]=o,!0);{if(!o||!o.includes(i))return!1;const a=o.indexOf(i);return a!==-1&&o.splice(a,1),!0}}handlePointerCapture(t,i){if(t.z__pointer_ctured){t.z__pointer_ctured=!1;const n=t.pointerId;if(i.onPointerMove){const r=this._capturedPointer[n]||[];r.push(i),this._capturedPointer[n]=r}else Ze()&&!i.z__warned_no_pointermove&&(i.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 t.z__pointer_cture_rleased&&(t.z__pointer_cture_rleased=!1,this.releasePointerCapture(t,i))}releasePointerCapture(t,i){const n=t.pointerId;if(this._capturedPointer[n]){const r=this._capturedPointer[n].indexOf(i);r!==-1&&(this._capturedPointer[n].splice(r,1),kh&&console.log("released pointer capture",n,i,this._capturedPointer))}}invokePointerCapture(t){var i;if(t.event.type===xn.PointerMove){const n=t.pointerId,r=this._capturedPointer[n];if(r){kh&&console.log("Captured",n,r);for(let o=0;o<r.length;o++){const a=r[o];if(a.destroyed){r.splice(o,1),o--;continue}(i=a.onPointerMove)==null||i.call(a,t)}}}}isChild(t,i){return!t||!i?!1:t===i?!0:t.parent?this.isChild(t.parent,i):!1}handleMeshUiObjectWithoutShadowDom(t,i){return!t||!t.isUI?!0:this.handleMeshUIIntersection(t,i)}handleMeshUIIntersection(t,i){const n=Ad.updateState(t,i);return n&&this.currentActiveMeshUIComponents.push(n),n!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&Ad.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let t=0;t<this.currentActiveMeshUIComponents.length;t++){const i=this.currentActiveMeshUIComponents[t];Ad.resetState(i)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(t){return t?ne.isActiveSelf(t)?this.testIsVisible(t.parent):!1:!0}};let No=_c;d(No,"_eventSystemMap",new Map),d(No,"didSearchEventSystem",!1);class Ad{static markDirty(){this.needsUpdate=!0}static update(e,t,i=!1){if(i){e.update();return}const n=t.time.frameCount;for(const r of this.lastUpdateFrame)if(r.context===t){if(n===r.frame)return;r.frame=n;let o=this.needsUpdate||n<1;r.nextUpdate<=n&&(o=!0),o&&(kh&&console.log("Update threemeshui"),this.needsUpdate=!1,r.nextUpdate=n+60,e.update());return}this.lastUpdateFrame=[{context:t,frame:n,nextUpdate:n+60}],e.update(),this.needsUpdate=!1}static updateState(e,t){let i=null;if(e&&(i=this.findBlockInParent(e),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}static resetLastSelected(){const e=this.lastSelected;e&&(this.lastSelected=null,this.resetState(e))}static resetState(e){e&&(this.needsUpdate=!0)}static findBlockInParent(e){return e?e.isBlock?e:this.findBlockInParent(e.parent):null}}d(Ad,"lastSelected",null),d(Ad,"lastUpdateFrame",[]),d(Ad,"needsUpdate",!1);var Q0e=Object.defineProperty,Z0e=Object.getOwnPropertyDescriptor,Tn=(s,e,t,i)=>{for(var n=i>1?void 0:i?Z0e(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Q0e(e,t,n),n};const IL=ie("debugorbit"),LL=ie("freecam"),XS=ie("debugcamerafit"),WS=ie("smoothcam"),j0e={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let PL;class fx extends CustomEvent{constructor(e,t){super("target-reached",{detail:{controls:e,type:t}})}}class Ii extends Te{constructor(){super(...arguments);d(this,"autoTarget",!0);d(this,"autoFit",!1);d(this,"enableRotate",!0);d(this,"autoRotate",!1);d(this,"autoRotateSpeed",1);d(this,"minAzimuthAngle",1/0);d(this,"maxAzimuthAngle",1/0);d(this,"minPolarAngle",0);d(this,"maxPolarAngle",Math.PI);d(this,"enableKeys",!1);d(this,"enableDamping",!0);d(this,"dampingFactor",.1);d(this,"enableZoom",!0);d(this,"minZoom",0);d(this,"maxZoom",1/0);d(this,"zoomSpeed",1);d(this,"zoomToCursor",!1);d(this,"enablePan",!0);d(this,"lookAtConstraint",null);d(this,"lookAtConstraint01",1);d(this,"allowInterrupt",!0);d(this,"middleClickToFocus",!0);d(this,"doubleClickToFocus",!0);d(this,"clickBackgroundToFitScene",2);d(this,"debugLog",!1);d(this,"targetLerpDuration",1);d(this,"_controls",null);d(this,"_cameraObject",null);d(this,"_lookTargetLerpActive",!1);d(this,"_lookTargetStartPosition",new M);d(this,"_lookTargetEndPosition",new M);d(this,"_lookTargetLerp01",0);d(this,"_lookTargetLerpDuration",0);d(this,"_cameraLerpActive",!1);d(this,"_cameraStartPosition",new M);d(this,"_cameraEndPosition",new M);d(this,"_cameraLerp01",0);d(this,"_cameraLerpDuration",0);d(this,"_fovLerpActive",!1);d(this,"_fovLerpStartValue",0);d(this,"_fovLerpEndValue",0);d(this,"_fovLerp01",0);d(this,"_fovLerpDuration",0);d(this,"_inputs",0);d(this,"_enableTime",0);d(this,"_startedListeningToKeyEvents",!1);d(this,"_eventSystem");d(this,"_afterHandleInputFn");d(this,"_camera",null);d(this,"_syncedTransform");d(this,"_didSetTarget",0);d(this,"targetElement",null);d(this,"_activePointerEvents");d(this,"_lastTimeClickOnBackground",-1);d(this,"_clickOnBackgroundCount",0);d(this,"_onPointerDown",t=>{this._activePointerEvents.push(t)});d(this,"_onPointerUp",t=>{for(let i=this._activePointerEvents.length-1;i>=0;i--){const n=this._activePointerEvents[i];if(n.pointerId===t.pointerId&&n.button===t.button){this._activePointerEvents.splice(i,1);break}}if(this.clickBackgroundToFitScene>0&&t.isClick&&t.button===0){if(t.hasRay||t.intersections.push(...this.context.physics.raycast()),t.intersections.length<=0){const i=this.context.time.time-this._lastTimeClickOnBackground;this._lastTimeClickOnBackground=this.context.time.time,this.clickBackgroundToFitScene<=1||i<this.clickBackgroundToFitScene*.15?(this._clickOnBackgroundCount+=1,this._clickOnBackgroundCount>=this.clickBackgroundToFitScene-1&&this.fitCamera(this.context.scene.children,{immediate:!1})):this._clickOnBackgroundCount=0}IL&&console.log(this.clickBackgroundToFitScene,t.intersections.length,this._clickOnBackgroundCount)}});d(this,"_onPointerUpLate",t=>{this.doubleClickToFocus&&t.isDoubleClick&&!t.used&&this.setTargetFromRaycast()});d(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});d(this,"_shouldDisable",!1);d(this,"__onPreRender",()=>{const t=this.context.pre_render_callbacks.indexOf(this.__onPreRender);t>=0&&this.context.pre_render_callbacks.splice(t,1),this.autoFit&&(this.autoFit=!1,this.fitCamera({centerCamera:"y",immediate:!0,objects:this.scene.children}))});d(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(t){var i;(i=this.controls)==null||i.addEventListener("start",t)}get targetLerpSpeed(){return 5}set targetLerpSpeed(t){this.targetLerpDuration=1/t}awake(){this._didSetTarget=0,this._startedListeningToKeyEvents=!1}start(){this._eventSystem=No.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(KB.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var t,i;(t=this._controls)==null||t.dispose(),(i=this._eventSystem)==null||i.removeEventListener(KB.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._didSetTarget=0,this._enableTime=this.context.time.time;const t=ne.getComponent(this.gameObject,Xi);this._camera=t;let i=t==null?void 0:t.threeCamera;if(!i&&this.gameObject instanceof kt&&(i=this.gameObject),i&&zP(i,this,!0),!this._controls&&i instanceof kt){this._cameraObject=i;const n=this.targetElement??this.context.renderer.domElement,r=i==null?void 0:i.quaternion.clone();this._controls=new kY(i,n),i==null||i.quaternion.copy(r),PL===void 0&&(PL={...this._controls.keys})}if(this._controls)if(LL&&(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=ne.getComponent(this.gameObject,Jc)??void 0,this.context.pre_render_callbacks.push(this.__onPreRender),this._activePointerEvents=[],this.context.input.addEventListener("pointerdown",this._onPointerDown,{queue:fa.Early}),this.context.input.addEventListener("pointerup",this._onPointerUp,{queue:fa.Early}),this.context.input.addEventListener("pointerup",this._onPointerUpLate,{queue:fa.Late})}onDisable(){var t;if((t=this._camera)!=null&&t.threeCamera&&zP(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(t){t.detail.args.pointerId===0&&(t.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!t.detail.args.isPressed||t.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var i,n,r,o;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)&&((i=this.context.input.getPointerPositionDelta(0))!=null&&i.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 a=ne.getComponent(this.gameObject,Xi);if(a&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const l=zt(a.threeCamera),c=Math.max(.01,l.length()),h=new M(0,0,-c).applyMatrix4(a.threeCamera.matrixWorld);this.setLookTargetPosition(h,!0)}if(!this.setLookTargetFromConstraint()){const l=new Kc;l.screenPoint=new ee(0,0),l.lineThreshold=.1;const c=this.context.physics.raycast(l);c.length>0&&this.setLookTargetPosition(c[0].point,!0),XS&&console.log("OrbitControls hits",...c)}}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 fx(this,"camera"));else{const a=tt.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,a)}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 fx(this,"lookat"));else{const a=tt.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,a)}if(this._fovLerpActive&&this._cameraObject){const a=this._cameraObject;if(this._fovLerp01+=this.context.time.deltaTime/this._fovLerpDuration,this._fovLerp01>=1)a.fov=this._fovLerpEndValue,this._fovLerpActive=!1;else{const l=tt.easeInOutCubic(this._fovLerp01);a.fov=tt.lerp(this._fovLerpStartValue,this._fovLerpEndValue,l)}a.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(a=>a.used),this._controls.keys=this.enableKeys?PL:j0e,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,LL||(((r=(n=this._camera)==null?void 0:n.threeCamera)==null?void 0:r.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 WS=="number"||WS===!0){this._controls.enableDamping=!0;const a=typeof WS=="number"?WS:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,a))}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||(!LL&&((o=this.lookAtConstraint)!=null&&o.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(this.context.time.deltaTime),IL&&ft.DrawWireSphere(this._controls.target,.1,65280))}}setCameraAndLookTarget(t){if(!t||!(t instanceof me))return;const i=zt(t),n=nO(t);this.setTargetFromRaycast(new So(i,n)),this.setCameraTargetPosition(i)}setCameraTargetPosition(t,i=!1){var n;t&&(t instanceof me&&(t=zt(t)),this._cameraEndPosition||(this._cameraEndPosition=new M),this._cameraEndPosition.copy(t),i===!0?(this._cameraLerpActive=!1,this._cameraObject&&this._cameraObject.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((n=this._cameraObject)==null?void 0:n.position),typeof i=="number"?this._cameraLerpDuration=i:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setFieldOfView(t,i=!1){var r;if(!this._controls||typeof t!="number")return;const n=(r=this._camera)==null?void 0:r.threeCamera;n&&(i===!0?n.fov=t:(this._fovLerpActive=!0,this._fovLerp01=0,this._fovLerpStartValue=n.fov,this._fovLerpEndValue=t,typeof i=="number"?this._fovLerpDuration=i:this._fovLerpDuration=this.targetLerpDuration))}setLookTargetPosition(t=null,i=!1){this._controls&&t&&(t instanceof me&&(t=zt(t)),this._lookTargetEndPosition.copy(t),this._didSetTarget++,IL&&(console.warn("OrbitControls: setLookTargetPosition",t,i),ft.DrawWireSphere(this._lookTargetEndPosition,.2,16711680,2)),i===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof i=="number"?this._lookTargetLerpDuration=i:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(t=0,i=1){var r;if(!this._controls)return!1;const n=(r=this.lookAtConstraint)==null?void 0:r.sources;if(n&&n.length>0){const o=n[t];if(o)return o.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,i),!0}return!1}lerpTarget(t,i){return this.lerpLookTarget(t,i)}lerpLookTarget(t,i){this._controls&&(i>=1?this._controls.target.copy(t):this._controls.target.lerp(t,i))}setTargetFromRaycast(t){if(!this.controls)return;const i=t?this.context.physics.raycastFromRay(t):this.context.physics.raycast();for(const n of i)if(n.distance>0&&ne.isActiveInHierarchy(n.object)){const r=bF(n.object);if(r){const o=r.canvas;if(o!=null&&o.screenspace)break}this.setLookTargetPosition(n.point);break}}fitCamera(t,i){var L,k;if(this.context.isInXR)return;let n;if(Array.isArray(t)?n=t:t&&"type"in t?n=t.children:t&&"objects"in t&&(n=t==null?void 0:t.objects,i=t),n&&!Array.isArray(n)&&(n=n.children),(!Array.isArray(n)||n&&n.length<=0)&&(n=this.context.scene.children),!Array.isArray(n)||n.length<=0){console.warn("No objects to fit camera to...");return}const r=this._cameraObject,o=this._controls;if(!r||!o){console.warn("No camera or controls found to fit camera to objects...");return}i||(i={});const{immediate:a=!1,centerCamera:l="y",cameraNearFar:c="auto",fitOffset:h=1.1,fov:u=r==null?void 0:r.fov}=i,f=new M,p=new M,m=Ra(n,void 0,(k=(L=this._camera)==null?void 0:L.threeCamera)==null?void 0:k.layers),b=m.clone();r.updateMatrixWorld(),r.updateProjectionMatrix(),m.getCenter(p);const g=new M;if(m.getSize(g),m.applyMatrix4(r.matrixWorldInverse),m.getSize(f),m.setFromCenterAndSize(p,f),Number.isNaN(f.x)||Number.isNaN(f.y)||Number.isNaN(f.z)){console.warn("Camera fit size resultet in NaN",r,m,[...n]);return}if(f.length()<=1e-10){XS&&console.warn("Camera fit size is zero",m,[...n]);return}const y=i.fov||r.fov,A=2*Math.atan(Math.tan(y*Math.PI/360/2)*r.aspect)/Math.PI*360,v=f.y/(2*Math.atan(Math.PI*y/360)),x=f.x/(2*Math.atan(Math.PI*A/360)),_=h*Math.max(v,x)+f.z/2;XS&&console.log("Fit camera to objects",{fitHeightDistance:v,fitWidthDistance:x,distance:_,verticalFov:y,horizontalFov:A}),this.maxZoom=_*10,this.minZoom=_*.01;const w=.05,C=p.clone();if(C.y-=f.y*w,this.setLookTargetPosition(C,a),this.setFieldOfView(i.fov,a),this.autoTarget=!1,c==null||c=="auto"){const P=ne.findObjectOfType(sh),U=P?P.radius:0,O=Math.max(g.x,g.y,g.z,U);r.near=_/100,r.far=O+_*10,P&&(this.maxZoom=Math.max(Math.min(this.maxZoom,U*.5),_))}const T=o.getDistance();T<this.minZoom&&(this.minZoom=T*.9),T>this.maxZoom&&(this.maxZoom=T*1.1),r.updateMatrixWorld(),r.updateProjectionMatrix();const R=zt(r),S=p.clone();S.sub(R),l==="y"&&(S.y=0),S.normalize(),S.multiplyScalar(_),l==="y"&&(S.y+=-w*4*_);let I=p.clone().sub(S);if(r.parent&&(I=r.parent.worldToLocal(I)),this.setCameraTargetPosition(I,a),XS){const P=new CD(m);this.context.scene.add(P),oO(P,qx(r)),setTimeout(()=>{this.context.scene.remove(P)},1e4),ft.DrawWireBox3(b,65280,10),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",U=>{if(U.code==="KeyF"){let O;this._cameraObject instanceof kt&&(O=Math.random()*Math.random()*170+10),this.fitCamera({objects:n,fitOffset:h,immediate:!1,fov:O})}U.code==="KeyV"&&this._cameraObject instanceof kt&&(this._cameraObject.fov=60)}))}o.update()}}Tn([E()],Ii.prototype,"autoTarget",2);Tn([E()],Ii.prototype,"autoFit",2);Tn([E()],Ii.prototype,"enableRotate",2);Tn([E()],Ii.prototype,"autoRotate",2);Tn([E()],Ii.prototype,"autoRotateSpeed",2);Tn([E()],Ii.prototype,"minAzimuthAngle",2);Tn([E()],Ii.prototype,"maxAzimuthAngle",2);Tn([E()],Ii.prototype,"minPolarAngle",2);Tn([E()],Ii.prototype,"maxPolarAngle",2);Tn([E()],Ii.prototype,"enableKeys",2);Tn([E()],Ii.prototype,"enableDamping",2);Tn([E()],Ii.prototype,"dampingFactor",2);Tn([E()],Ii.prototype,"enableZoom",2);Tn([E()],Ii.prototype,"minZoom",2);Tn([E()],Ii.prototype,"maxZoom",2);Tn([E()],Ii.prototype,"zoomSpeed",2);Tn([E()],Ii.prototype,"enablePan",2);Tn([E(Sm)],Ii.prototype,"lookAtConstraint",2);Tn([E()],Ii.prototype,"lookAtConstraint01",2);Tn([E()],Ii.prototype,"allowInterrupt",2);Tn([E()],Ii.prototype,"middleClickToFocus",2);Tn([E()],Ii.prototype,"doubleClickToFocus",2);Tn([E()],Ii.prototype,"clickBackgroundToFitScene",2);Tn([E()],Ii.prototype,"targetLerpDuration",2);var Y0e=Object.defineProperty,K0e=Object.getOwnPropertyDescriptor,Co=(s,e,t,i)=>{for(var n=i>1?void 0:i?K0e(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Y0e(e,t,n),n},Ud=(s=>(s[s.None=0]="None",s[s.Skybox=1]="Skybox",s[s.SolidColor=2]="SolidColor",s[s.Uninitialized=4]="Uninitialized",s))(Ud||{});const ud=ie("debugcam"),m5=ie("debugscreenpointtoray");var F1;const Fv=(F1=class extends Te{constructor(){super(...arguments);d(this,"_nearClipPlane",.1);d(this,"_farClipPlane",1e3);d(this,"orthographic",!1);d(this,"orthographicSize",5);d(this,"ARBackgroundAlpha",0);d(this,"_cullingMask",4294967295);d(this,"_backgroundBlurriness");d(this,"_backgroundIntensity");d(this,"_backgroundRotation");d(this,"_environmentIntensity");d(this,"_targetTexture",null);d(this,"_backgroundColor");d(this,"_fov");d(this,"_cam",null);d(this,"_clearFlags",2);d(this,"_skybox");d(this,"_frustum");d(this,"_projScreenMatrix",new he)}get isCamera(){return!0}get aspect(){return this._cam instanceof kt?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(e){this._cam instanceof kt&&this._cam.aspect!==e&&(this._cam.aspect=e,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof kt?this._cam.fov:this._fov}set fieldOfView(e){const t=this.fieldOfView!=e;if(this._fov=e,t&&this._cam&&this._cam instanceof kt){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(e){const t=this._nearClipPlane!=e;this._nearClipPlane=e,this._cam&&(t||this._cam.near!=e)&&(this._cam.near=e,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(e){const t=this._farClipPlane!=e;this._farClipPlane=e,this._cam&&(t||this._cam.far!=e)&&(this._cam.far=e,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(e){e!==this._clearFlags&&(this._clearFlags=e,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(e){this._cullingMask=e,this._cam&&(this._cam.layers.mask=e)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(e){this.cullingMask=(1<<e|0)>>>0}set backgroundBlurriness(e){e!==this._backgroundBlurriness&&(e===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(e,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(e){e!==this._backgroundIntensity&&(e===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(e,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set backgroundRotation(e){e!==this._backgroundRotation&&(e===void 0?this._backgroundRotation=void 0:this._backgroundRotation=e,this.applyClearFlagsIfIsActiveCamera())}get backgroundRotation(){return this._backgroundRotation}set environmentIntensity(e){this._environmentIntensity=e}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(e){if(e){if(this._backgroundColor)this._backgroundColor.copy(e);else{if(!e.clone)return;this._backgroundColor=e.clone()}e.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(e){this._targetTexture=e}get targetTexture(){return this._targetTexture}get cam(){return this.threeCamera}get threeCamera(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(e,t,i){const n=this.threeCamera,r=Fv._origin;r.set(e,t,-1),this.context.input.convertScreenspaceToRaycastSpace(r),m5&&console.log("screenPointToRay",e.toFixed(2),t.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(n);const o=Fv._direction.set(r.x,r.y,r.z),a=zt(n);return o.sub(a),o.normalize(),i?(i.set(a,o),i):new So(a.clone(),o.clone())}getFrustum(){return this._frustum||(this._frustum=new im,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new im),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(e,t){return t&&this._projScreenMatrix.multiplyMatrices(this.threeCamera.projectionMatrix,this.threeCamera.matrixWorldInverse),e===this._projScreenMatrix?e:e.copy(this._projScreenMatrix)}awake(){m5&&window.addEventListener("pointerdown",e=>{const t=e.clientX,i=e.clientY;console.log("touch",t.toFixed(2),i.toFixed(2));const n=this.screenPointToRay(t,i),r="#"+Math.floor(Math.random()*16777215).toString(16);ft.DrawRay(n.origin,n.direction,r,10)})}onEnable(){ud&&console.log(`Camera enabled: "${this.name}". ClearFlags=${Ud[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),q0e(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 e=this.context.renderer;if(e){const t=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,e),t==null||t.applyClearFlags()}}}buildCamera(){if(this._cam)return;const e=this.gameObject.isCamera;let t=null;if(e?(t=this.gameObject,t==null||t.layers.enableAll(),t instanceof kt&&(this._fov=t.fov)):t=this.gameObject.children[0],t&&t.isCamera)t instanceof kt&&(this._fov&&(t.fov=this._fov),t.near=this._nearClipPlane,t.far=this._farClipPlane,t.updateProjectionMatrix());else if(!this.orthographic)t=new kt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(t.fov=this.fieldOfView),this.gameObject.add(t);else{const i=this.orthographicSize*100;t=new eh(window.innerWidth/-i,window.innerWidth/i,window.innerHeight/i,window.innerHeight/-i,this._nearClipPlane,this._farClipPlane),this.gameObject.add(t)}this._cam=t,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(e){this.context.mainCameraComponent===this&&this.applyClearFlags(e)}applyClearFlags(e){var t;if(!this._cam){ud&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,ud){const i=`Camera "${this.name}" clear flags: ${Ud[this._clearFlags]}`;console.debug(i)}switch(this._clearFlags){case 0:return;case 1:if(Fv.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||(e==null?void 0:e.applySkybox)===!0)&&this.applySceneSkybox(),this._backgroundBlurriness!==void 0?this.context.scene.backgroundBlurriness=this._backgroundBlurriness:ud&&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:ud&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let i=this._backgroundColor.alpha;Fv.backgroundShouldBeTransparent(this.context)&&(i=this.ARBackgroundAlpha??0),this.context.scene.background=null,(t=this.context.xr)!=null&&t.isVR?this.context.renderer.setClearColor(F9(this._backgroundColor).convertLinearToSRGB()):this.context.renderer.setClearColor(this._backgroundColor,i)}else ud&&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 J0e(this)),this._skybox.apply()}static backgroundShouldBeTransparent(e){var r,o,a,l;const t=(r=e.renderer.xr)==null?void 0:r.getSession();if(!t)return!1;if(typeof t._transparent=="boolean")return t._transparent;const i=t.environmentBlendMode;ud&&wn("Environment blend mode: "+i+" on "+navigator.userAgent);let n=i==="additive"||i==="alpha-blend";return e.isInAR&&i==="opaque"&&((o=navigator.userAgent)!=null&&o.includes("OculusBrowser")||(a=navigator.userAgent)!=null&&a.includes("Mozilla")&&((l=navigator.userAgent)!=null&&l.includes("Mobile WebXRViewer/v2")))&&(n=!0),t._transparent=n,n}},d(F1,"_origin",new M),d(F1,"_direction",new M),F1);let Xi=Fv;Co([E()],Xi.prototype,"aspect",1);Co([E()],Xi.prototype,"fieldOfView",1);Co([E()],Xi.prototype,"nearClipPlane",1);Co([E()],Xi.prototype,"farClipPlane",1);Co([E()],Xi.prototype,"clearFlags",1);Co([E()],Xi.prototype,"orthographic",2);Co([E()],Xi.prototype,"orthographicSize",2);Co([E()],Xi.prototype,"ARBackgroundAlpha",2);Co([E()],Xi.prototype,"cullingMask",1);Co([E()],Xi.prototype,"backgroundBlurriness",1);Co([E()],Xi.prototype,"backgroundIntensity",1);Co([E(oi)],Xi.prototype,"backgroundRotation",1);Co([E()],Xi.prototype,"environmentIntensity",1);Co([E(Bi)],Xi.prototype,"backgroundColor",1);Co([E(Nd)],Xi.prototype,"targetTexture",1);class J0e{constructor(e){d(this,"_camera");d(this,"_skybox");this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}apply(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(ud&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=vo,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 q0e(s){ie("freecam")&&s.context.mainCameraComponent===s&&ne.getOrAddComponent(s.gameObject,Ii)}class Vd extends Te{constructor(){super(...arguments);d(this,"_listener",null);d(this,"onInteraction",()=>{this.destroyed||this.listener==null||this.addListenerIfItExists()})}get listener(){return this._listener==null&&(this._listener=new v4),this._listener}onEnable(){Ql.registerWaitForInteraction(this.onInteraction),this.addListenerIfItExists()}onDisable(){Ql.unregisterWaitForInteraction(this.onInteraction),this.removeListenerIfItExists()}addListenerIfItExists(){const t=this._listener;if(!t||t!=null&&t.parent)return;const i=this.context.mainCameraComponent||ne.getComponentInParent(this.gameObject,Xi);i!=null&&i.threeCamera?i.threeCamera.add(t):this.gameObject.add(t),t.filter?(t.gain.connect(t.filter),t.filter.connect(t.context.destination)):t.gain.connect(t.context.destination)}removeListenerIfItExists(){const t=this._listener;t&&(t.removeFromParent(),t.filter&&t.filter.disconnect(),t.gain&&t.gain.disconnect())}}var $0e=Object.defineProperty,eye=Object.getOwnPropertyDescriptor,nc=(s,e,t,i)=>{for(var n=i>1?void 0:i?eye(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&$0e(e,t,n),n};const Dr=ie("debugaudio"),dd=class extends Te{constructor(){super(...arguments);d(this,"clip","");d(this,"playOnAwake",!1);d(this,"preload",!1);d(this,"playInBackground",!0);d(this,"_spatialBlend",0);d(this,"_minDistance",1);d(this,"_maxDistance",100);d(this,"_volume",1);d(this,"rollOffMode",0);d(this,"_loop",!1);d(this,"sound",null);d(this,"helper",null);d(this,"wasPlaying",!1);d(this,"audioLoader",null);d(this,"shouldPlay",!1);d(this,"_lastClipStartedLoading",null);d(this,"_audioElement",null);d(this,"onVisibilityChanged",()=>{switch(document.visibilityState){case"hidden":(this.playInBackground===!1||exports.DeviceUtilities.isMobileDevice())&&(this.wasPlaying=this.isPlaying,this.isPlaying&&this.pause());break;case"visible":Dr&&console.log("visible",this.enabled,this.playOnAwake,!this.isPlaying,dd.userInteractionRegistered,this.wasPlaying),this.enabled&&this.playOnAwake&&!this.isPlaying&&dd.userInteractionRegistered&&this.wasPlaying&&this.play();break}});d(this,"onApplicationMuteChanged",()=>{var e,t;this.context.application.muted?(e=this.sound)==null||e.setVolume(0):(t=this.sound)==null||t.setVolume(this.volume)});d(this,"createAudio",e=>{Dr&&console.log("AudioBuffer finished loading",e);const t=this.Sound;if(!t){Dr&&console.warn("Failed getting sound?",this.name);return}t.isPlaying&&t.stop(),e&&t.setBuffer(e),t.loop=this._loop,this.context.application.muted?t.setVolume(0):t.setVolume(this.volume),t.autoplay=this.shouldPlay&&dd.userInteractionRegistered,this.applySpatialDistanceSettings(),t.isPlaying&&t.stop(),dd.registerWaitForAllowAudio(this.__onAllowAudioCallback)});d(this,"__onAllowAudioCallback",()=>{this.shouldPlay&&this.play()});d(this,"_lastContextTime",0);d(this,"_hasEnded",!0);d(this,"_needUpdateSpatialDistanceSettings",!1)}static get userInteractionRegistered(){return Ql.userInteractionRegistered}static registerWaitForAllowAudio(e){Ql.registerWaitForInteraction(e)}get isPlaying(){var e;return((e=this.sound)==null?void 0:e.isPlaying)??!1}get duration(){var e,t;return(t=(e=this.sound)==null?void 0:e.buffer)==null?void 0:t.duration}get time01(){var t;const e=this.duration;return e&&this.sound?((t=this.sound)==null?void 0:t.context.currentTime)/e:0}set time01(e){const t=this.duration;t&&this.sound&&(this.time=e*t)}get time(){var e,t;return(e=this.sound)!=null&&e.source?((t=this.sound.source)==null?void 0:t.context.currentTime)-this._lastContextTime+this.sound.offset:0}set time(e){if(this.sound){if(e===this.sound.offset)return;const t=this.isPlaying;this.stop(),this.sound.offset=e,t&&this.play()}}get loop(){return this.sound&&(this._loop=this.sound.getLoop()),this._loop}set loop(e){this._loop=e,this.sound&&this.sound.setLoop(e)}get spatialBlend(){return this._spatialBlend}set spatialBlend(e){e!==this._spatialBlend&&(this._spatialBlend=e,this._needUpdateSpatialDistanceSettings=!0)}get minDistance(){return this._minDistance}set minDistance(e){this._minDistance!==e&&(this._minDistance=e,this._needUpdateSpatialDistanceSettings=!0)}get maxDistance(){return this._maxDistance}set maxDistance(e){this._maxDistance!==e&&(this._maxDistance=e,this._needUpdateSpatialDistanceSettings=!0)}get volume(){return this._volume}set volume(e){this._volume=e,this.sound&&!this.context.application.muted&&(Dr&&console.log(this.name,"audio set volume",e),this.sound.setVolume(e))}set pitch(e){this.sound&&this.sound.setPlaybackRate(e)}get pitch(){return this.sound?this.sound.getPlaybackRate():1}get Sound(){var e;if(!this.sound&&dd.userInteractionRegistered){let t=ne.getComponent(this.context.mainCamera,Vd)??ne.findObjectOfType(Vd,this.context);!t&&this.context.mainCamera&&(t=ne.addComponent(this.context.mainCamera,Vd)),t!=null&&t.listener?(this.sound=new A4(t.listener),(e=this.gameObject)==null||e.add(this.sound)):Dr&&console.warn("No audio listener found in scene - can not play audio")}return this.sound}get ShouldPlay(){return this.shouldPlay}get audioContext(){var e;return(e=this.sound)==null?void 0:e.context}awake(){Dr&&console.log(this),this.audioLoader=new HC,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),dd.userInteractionRegistered?this.playOnAwake&&this.context.application.isVisible&&this.play():dd.registerWaitForAllowAudio(()=>{this.enabled&&!this.destroyed&&this.shouldPlay&&this.onNewClip(this.clip)}),globalThis.addEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.addEventListener(fM.MuteChanged,this.onApplicationMuteChanged)}onDisable(){globalThis.removeEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.removeEventListener(fM.MuteChanged,this.onApplicationMuteChanged),this.pause()}applySpatialDistanceSettings(){const e=this.sound;if(!e)return;this._needUpdateSpatialDistanceSettings=!1;const t=tt.lerp(10*this._maxDistance/Math.max(1e-4,this.spatialBlend),this._minDistance,this.spatialBlend);switch(Dr&&console.log(this.name,this._minDistance,this._maxDistance,this.spatialBlend,"Ref distance="+t),e.setRefDistance(t),e.setMaxDistance(Math.max(.01,this._maxDistance)),this.rollOffMode){case 0:e.setDistanceModel("exponential");break;case 1:e.setDistanceModel("linear");break;case 2:console.warn("Custom rolloff for AudioSource is not supported: "+this.name);break}this.spatialBlend>0?Dr&&!this.helper&&(this.helper=new u0e(e,e.getRefDistance()),e.add(this.helper)):this.helper&&this.helper.parent&&this.helper.removeFromParent()}async onNewClip(e){if(e&&(this.clip=e),typeof e=="string")if(Dr&&console.log(e),e.endsWith(".mp3")||e.endsWith(".wav")){if(this.audioLoader||(this.audioLoader=new HC),this.shouldPlay=!0,this._lastClipStartedLoading===e){Dr&&console.log("Is currently loading:",this._lastClipStartedLoading,this);return}this._lastClipStartedLoading=e,Dr&&console.log("load audio",e);const t=await this.audioLoader.loadAsync(e).catch(console.error);this._lastClipStartedLoading=null,t&&this.createAudio(t)}else console.warn("Unsupported audio clip type",e);else this.shouldPlay=!0,this.createAudio()}play(e=void 0){var i,n,r;!e&&this.clip&&(e=this.clip),e!==void 0&&typeof e!="string"&&!(e instanceof MediaStream)&&(Ze()&&console.warn("Called play on AudioSource with unknown argument type:",e+`
5957
5957
  Using the assigned clip instead:`,this.clip),e=this.clip);let t=!this.sound||e&&e!==this.clip;if(typeof e=="string"&&!this.audioLoader&&(t=!0),(e instanceof MediaStream||typeof e=="string")&&(this.clip=e),t){this.shouldPlay=!0,this.onNewClip(e);return}if(this.shouldPlay=!0,this._hasEnded=!1,Dr&&console.log("play",(i=this.sound)==null?void 0:i.getVolume(),this.sound),this.sound&&!this.sound.isPlaying){const o=this.context.application.muted;o&&this.sound.setVolume(0),(n=this.gameObject)==null||n.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||(r=this.context.domElement.shadowRoot)==null||r.append(this._audioElement),this._audioElement.srcObject=this.clip,this._audioElement.autoplay=!1):(this._audioElement&&this._audioElement.remove(),this.sound.play(o?.1:0))}}pause(){var e,t;Dr&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.isPlaying&&this.sound.source&&(this._lastContextTime=(e=this.sound)==null?void 0:e.context.currentTime,this.sound.pause()),(t=this._audioElement)==null||t.remove()}stop(){var e,t;Dr&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.source&&(this._lastContextTime=(e=this.sound)==null?void 0:e.context.currentTime,Dr&&console.log(this._lastContextTime),this.sound.stop()),(t=this._audioElement)==null||t.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,Dr&&console.log("Audio clip ended",this.clip),this.dispatchEvent(new CustomEvent("ended",{detail:this})))}};let On=dd;nc([E(URL)],On.prototype,"clip",2);nc([E()],On.prototype,"playOnAwake",2);nc([E()],On.prototype,"preload",2);nc([E()],On.prototype,"playInBackground",2);nc([E()],On.prototype,"loop",1);nc([E()],On.prototype,"spatialBlend",1);nc([E()],On.prototype,"minDistance",1);nc([E()],On.prototype,"maxDistance",1);nc([E()],On.prototype,"volume",1);nc([E()],On.prototype,"pitch",1);nc([E()],On.prototype,"rollOffMode",2);var tye=Object.defineProperty,iye=Object.getOwnPropertyDescriptor,mT=(s,e,t,i)=>{for(var n=i>1?void 0:i?iye(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&tye(e,t,n),n};const nye=ie("debugsignals");class y_{constructor(){d(this,"guid")}}mT([E()],y_.prototype,"guid",2);class Fy{constructor(){d(this,"signal");d(this,"reaction")}}mT([E(y_)],Fy.prototype,"signal",2);mT([E(Yi)],Fy.prototype,"reaction",2);var P2;const Dh=(P2=class extends Te{constructor(){super(...arguments);d(this,"events")}static invoke(e){if(Dh.receivers[e]){const t=Dh.receivers[e];if(!t)return;for(const i of t)i.invoke(e)}}awake(){nye&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const e of this.events)Dh.receivers[e.signal.guid]||(Dh.receivers[e.signal.guid]=[]),Dh.receivers[e.signal.guid].push(this)}onDisable(){if(this.events){for(const e of this.events)if(Dh.receivers[e.signal.guid]){const t=Dh.receivers[e.signal.guid].indexOf(this);t>=0&&Dh.receivers[e.signal.guid].splice(t,1)}}}invoke(e){if(!this.events||!Array.isArray(this.events))return;const t=typeof e=="object"?e.guid:e;for(const i of this.events)if(i.signal.guid===t)try{if(i.reaction){if(!i.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",i,this);continue}}else{console.warn("Missing reaction for signal",i,this);continue}i.reaction.invoke()}catch(n){console.error(n)}}},d(P2,"receivers",{}),P2);let Gy=Dh;mT([E(Fy)],Gy.prototype,"events",2);var la=(s=>(s.Activation="ActivationTrack",s.Animation="AnimationTrack",s.Audio="AudioTrack",s.Control="ControlTrack",s.Marker="MarkerTrack",s.Signal="SignalTrack",s))(la||{}),Ac=(s=>(s[s.None=0]="None",s[s.Hold=1]="Hold",s[s.Loop=2]="Loop",s[s.PingPong=3]="PingPong",s[s.Continue=4]="Continue",s))(Ac||{}),vF=(s=>(s.Signal="SignalEmitter",s))(vF||{}),sye=Object.defineProperty,rye=Object.getOwnPropertyDescriptor,UY=(s,e,t,i)=>{for(var n=i>1?void 0:i?rye(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&sye(e,t,n),n};const Rh=ie("debugtimeline");var B2;const JB=(B2=class extends Te{constructor(){super(...arguments);d(this,"playableAsset");d(this,"playOnAwake");d(this,"extrapolationMode",1);d(this,"waitForAudio",!0);d(this,"_visibilityChangeEvt");d(this,"_clonedPlayableAsset",!1);d(this,"_speed",1);d(this,"_guidsMap");d(this,"_isPlaying",!1);d(this,"_internalUpdateRoutine");d(this,"_isPaused",!1);d(this,"_isStopping",!1);d(this,"_time",0);d(this,"_duration",0);d(this,"_weight",1);d(this,"_animationTracks",[]);d(this,"_audioTracks",[]);d(this,"_signalTracks",[]);d(this,"_controlTracks",[]);d(this,"_customTracks",[]);d(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]);d(this,"animationCallbackReceivers",[])}static registerCreateTrack(e,t){this.createTrackFunctions[e]=t}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(e){typeof e=="number"&&!Number.isNaN(e)?this._time=e:(Rh||xo())&&console.error("INVALID TIMELINE.TIME VALUE",e,this.name)}get duration(){return this._duration}set duration(e){this._duration=e}get weight(){return this._weight}set weight(e){this._weight=e}get speed(){return this._speed}set speed(e){this._speed=e}awake(){var e,t,i,n,r;Rh&&console.log(this,(e=this.playableAsset)==null?void 0:e.tracks),this.rebuildGraph(),!this.isValid()&&(Rh||Ze())&&(Rh?console.warn("PlayableDirector is not valid","Asset?",this.playableAsset,"Tracks:",(t=this.playableAsset)==null?void 0:t.tracks,"IsArray?",Array.isArray((i=this.playableAsset)==null?void 0:i.tracks),this):(r=(n=this.playableAsset)==null?void 0:n.tracks)!=null&&r.length?console.warn("PlayableDirector is not valid"):console.warn("PlayableDirector has no tracks"))}onEnable(){var e,t,i;for(const n of this._audioTracks)(e=n.onEnable)==null||e.call(n);for(const n of this._customTracks)(t=n.onEnable)==null||t.call(n);for(const n of this._animationTracks)(i=n.onEnable)==null||i.call(n);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 e,t,i;this.stop();for(const n of this._audioTracks)(e=n.onDisable)==null||e.call(n);for(const n of this._customTracks)(t=n.onDisable)==null||t.call(n);for(const n of this._animationTracks)(i=n.onDisable)==null||i.call(n);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var e;for(const t of this._allTracks)for(const i of t)(e=i.onDestroy)==null||e.call(i)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const e=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,e&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const t=[];for(const i of this._audioTracks){const n=i.loadAudio(this._time,1,0);n&&t.push(n)}if(t.length>0&&(await Promise.all(t),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!On.userInteractionRegistered&&this.waitForAudio;)await Kl(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),rn.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const i of this._audioTracks)i.stop();const e=this._isPaused==!0,t=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),e&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,e&&!t&&this.invokePauseChangedMethodsOnTracks(),t&&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 e of this._allTracks)for(const t of e)yield t}get animationTracks(){return this._animationTracks}get audioTracks(){return this._audioTracks}resolveGuids(e){this._guidsMap=e}invokePauseChangedMethodsOnTracks(){var e;for(const t of this.forEachTrack())(e=t.onPauseChanged)==null||e.call(t)}invokeStateChangedMethodsOnTracks(){var e;for(const t of this.forEachTrack())(e=t.onStateChanged)==null||e.call(t,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(e=!1){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}const i=this._time;for(const n of this.playableAsset.tracks)if(!n.muted)switch(n.type){case la.Activation:if(!e&&!this._isPlaying)continue;for(let r=0;r<n.outputs.length;r++){const o=n.outputs[r];if(typeof o=="object"){let a=!1;if(n.clips)for(const c of n.clips)c.start<=i&&i<=c.end&&(a=!0);const l=o;l.visible!==void 0&&l.visible!==a&&(l.visible=a,Rh&&console.warn(this.name,"set ActivationTrack-"+r,l.name,a,i))}}break}if(!this._isStopping)for(const n of this._animationTracks)n.evaluate(i);for(const n of this._audioTracks)n.evaluate(i);for(const n of this._signalTracks)n.evaluate(i);for(const n of this._controlTracks)n.evaluate(i);for(const n of this._customTracks)n.evaluate(i)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=jx(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const e=this.findRoot(this.gameObject);for(const t of this.playableAsset.tracks){for(let i=t.outputs.length-1;i>=0;i--){let n=t.outputs[i];if(typeof n=="string"){this._guidsMap&&this._guidsMap[n]&&(n=this._guidsMap[n]);const r=ne.findByGuid(n,e);r===null||typeof r!="object"?(t.outputs.splice(i,1),console.warn("Failed to resolve binding",n,t.name,t.type)):(Rh&&console.log("Resolved binding",n,"to",r),t.outputs[i]=r)}else if(n===null){if(t.outputs.splice(i,1),JB.createTrackFunctions[t.type])continue;t.type!==la.Audio&&t.type!==la.Control&&t.type!==la.Marker&&t.type!==la.Signal&&console.warn("Missing binding",n,t.name,t.type,this.name,this.playableAsset.name)}}if(t.type===la.Control&&t.clips)for(let i=0;i<t.clips.length;i++){const n=t.clips[i];let r=n.asset.sourceObject;if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const o=ne.findByGuid(r,e);o===null||typeof o!="object"?console.warn("Failed to resolve sourceObject binding",r,t.name,n):(Rh&&console.log("Resolved binding",r,"to",o),n.asset.sourceObject=o)}}}}findRoot(e){return e.parent?this.findRoot(e.parent):e}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const e of this.playableAsset.tracks)if(e.muted!==!0){if(e.clips)for(const t of e.clips)t.end>this._duration&&(this._duration=t.end);if(e.markers)for(const t of e.markers)t.time>this._duration&&(this._duration=t.time+.001)}}}setupAndCreateTrackHandlers(){var t,i,n;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let e=ne.findObjectOfType(Vd,this.context);for(const r of this.playableAsset.tracks){const o=r.type,a=JB.createTrackFunctions[o];if(a!=null){const l=a(this,r);if(typeof l.evaluate=="function"){l.director=this,l.track=r,this._customTracks.push(l);continue}}if(r.type===la.Animation){if(!r.clips||r.clips.length<=0){Rh&&console.warn("Animation track has no clips",r);continue}for(let l=r.outputs.length-1;l>=0;l--){let c=r.outputs[l];if(c instanceof me){const u=ne.getOrAddComponent(c,Ar);u&&(c=u)}const h=(t=c==null?void 0:c.gameObject)==null?void 0:t.animations;if(h){const u=new gT;u.trackOffset=r.trackOffset,u.director=this,u.track=r;for(let f=0;f<r.clips.length;f++){const p=r.clips[f],m=p.asset;if(!m){console.error(`Timeline ${this.name}: clip #${f} on track "${r.name}" has no animation data`);continue}const b=m.clip;let g=b;if((typeof g=="string"||typeof g=="number")&&(g=h.find(A=>A.name===b)),Rh&&console.log(m,b,"→",g),!g){console.warn("Could not find animationClip for model",p,r.name,this.name,(i=this.playableAsset)==null?void 0:i.name,h,c);continue}c instanceof Ar&&c.runtimeAnimatorController&&(c.__internalDidAwakeAndStart||c.initializeRuntimeAnimatorController(),c.runtimeAnimatorController.mixer||c.runtimeAnimatorController.bind(c),u.mixer=c.runtimeAnimatorController.mixer),u.mixer||(u.mixer=new IE(c.gameObject),this.context.animations.registerAnimationMixer(u.mixer)),u.clips.push(g),u.mixer.uncacheAction(g),u.createHooks(p.asset,g);const y=u.mixer.clipAction(g);u.actions.push(y),u.models.push(p)}this._animationTracks.push(u)}}}else if(r.type===la.Audio){if(!r.clips||r.clips.length<=0)continue;const l=new Qp;l.director=this,l.track=r,l.audioSource=r.outputs.find(c=>c instanceof On),this._audioTracks.push(l),e||(e=(n=this.context.mainCameraComponent)==null?void 0:n.gameObject.addComponent(Vd)),l.listener=e.listener;for(let c=0;c<r.clips.length;c++){const h=r.clips[c];l.addModel(h)}}else if(r.type===la.Marker){const l=new px;if(l.director=this,l.track=r,r.markers)for(const c of r.markers)switch(c.type){case vF.Signal:l.models.push(c),l.didTrigger.push(!1);break}if(l!==null&&l.models.length>0){const c=ne.getComponent(this.gameObject,Gy);c&&(l.receivers.push(c),this._signalTracks.push(l))}}else if(r.type===la.Signal){const l=new px;if(l.director=this,l.track=r,r.markers)for(const c of r.markers)l.models.push(c),l.didTrigger.push(!1);for(const c of r.outputs)l.receivers.push(c);this._signalTracks.push(l)}else if(r.type===la.Control){const l=new yT;if(l.director=this,l.track=r,r.clips)for(const c of r.clips)l.models.push(c);l.resolveSourceObjects(this.context),this._controlTracks.push(l)}}}setAudioTracksAllowPlaying(e){for(const t of this._audioTracks)t.onAllowAudioChanged(e)}registerAnimationCallback(e){this.animationCallbackReceivers.push(e)}unregisterAnimationCallback(e){const t=this.animationCallbackReceivers.indexOf(e);t!==-1&&this.animationCallbackReceivers.splice(t,1)}},d(B2,"createTrackFunctions",{}),B2);let Kd=JB;UY([E()],Kd.prototype,"playOnAwake",2);UY([E()],Kd.prototype,"extrapolationMode",2);const Gc=ie("debugtimeline");class b_{constructor(){d(this,"director");d(this,"track")}get muted(){return this.track.muted}set muted(e){var t;e!==this.track.muted&&(this.track.muted=e,(t=this.onMuteChanged)==null||t.call(this))}*forEachClip(e=!1){var t;if((t=this.track)!=null&&t.clips)if(e)for(let i=this.track.clips.length-1;i>=0;i--)yield this.track.clips[i];else for(const i of this.track.clips)yield i}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,i,n=!0){if(t<0||t>=i.length)return 0;const r=i[t];if(n||e>=r.start&&e<=r.end){let o=1;const a=!1;if(r.easeInDuration>0){const l=Math.min((e-r.start)/r.easeInDuration,1);o*=l}if(r.easeOutDuration>0&&!a){const l=Math.min((r.end-e)/r.easeOutDuration,1);o*=l}return o}return 0}}class oye{constructor(e){d(this,"clip");d(this,"rootPositionOffset");d(this,"rootQuaternionOffset");d(this,"rootStartPosition");d(this,"rootEndPosition");d(this,"rootStartQuaternion");d(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const i=e.getRoot(),n=i.name+".position",r=i.name+".quaternion";Gc&&console.log(t.name,t.tracks,n);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(n))this.rootStartPosition=new M().fromArray(o.values,0),this.rootEndPosition=new M().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Gc&&console.log(this.rootPositionOffset);else if(o.name.endsWith(r)&&(this.rootStartQuaternion=new we().fromArray(o.values,0),this.rootEndQuaternion=new we().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Gc)){const a=new oi().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class gT extends b_{constructor(){super(...arguments);d(this,"models",[]);d(this,"trackOffset");d(this,"target");d(this,"mixer");d(this,"clips",[]);d(this,"actions",[]);d(this,"weight",1);d(this,"_actionOffsets",[]);d(this,"_didBind",!1);d(this,"_animator",null);d(this,"_useclipOffsets",!0);d(this,"_totalOffsetPosition",new M);d(this,"_totalOffsetRotation",new we);d(this,"_totalOffsetPosition2",new M);d(this,"_totalOffsetRotation2",new we);d(this,"_summedPos",new M);d(this,"_tempPos",new M);d(this,"_summedRot",new we);d(this,"_tempRot",new we);d(this,"_clipRotQuat",new we)}onDisable(){var t;(t=this.mixer)==null||t.stopAllAction()}onDestroy(){this.director.context.animations.unregisterAnimationMixer(this.mixer)}onStateChanged(){this._animator&&l5(this._animator.gameObject,this,this.director.isPlaying)}createHooks(t,i){var h,u;if(((h=i.tracks)==null?void 0:h.length)<=0){console.warn("No tracks in AnimationClip",i);return}const n=i.tracks[0].name.split("."),r=n[n.length-2],o=r+".position",a=r+".quaternion";let l=!1,c=!1;for(const f of i.tracks)f.name.endsWith(o)?(l=!0,this.createPositionInterpolant(i,t,f)):f.name.endsWith(a)&&(c=!0,this.createRotationInterpolant(i,t,f));if(!l||!c){const f=(u=this.mixer)==null?void 0:u.getRoot(),p=i.tracks[0],m=p.name.lastIndexOf("."),b=p.name.substring(0,m),g=b.substring(b.lastIndexOf(".")+1),y=f.getObjectByName(g);if(y)if(l){if(!c){const A=i.tracks[0].name.substring(0,m)+".quaternion";Gc&&console.warn("Create quaternion track",g,y);const v=y.quaternion,x=new jl(A,[0,i.duration],[v.x,v.y,v.z,v.w,v.x,v.y,v.z,v.w]);i.tracks.push(x),this.createRotationInterpolant(i,t,x)}}else{const A=b+".position";Gc&&console.warn("Create position track",g,y);const v=y.position,x=new Yc(A,[0,i.duration],[v.x,v.y,v.z,v.x,v.y,v.z]);i.tracks.push(x),this.createPositionInterpolant(i,t,x)}}}bind(){if(!this._didBind){this._didBind=!0,Gc&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const t of this.actions){const i=new oye(t);this._actionOffsets.push(i)}this.target&&(this._animator=ne.getComponent(this.target,Ar)??null,this._animator&&l5(this._animator.gameObject,this,!0));for(const t of this.models){const i=t.asset,n=i.position,r=i.rotation;n&&n.x!==void 0&&(n.isVector3||(i.position=new M(n.x,n.y,n.z)),r.isQuaternion||(i.rotation=new we(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const t=this.trackOffset.position;t&&(t.isVector3||(this.trackOffset.position=new M(t.x,t.y,t.z)));const i=this.trackOffset.rotation;i&&(i.isQuaternion||(this.trackOffset.rotation=new we(i.x,i.y,i.z,i.w)))}}evaluate(t){var l,c,h,u,f,p,m;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 i=0,n=0,r=!1,o=!1,a=0;for(let b=0;b<this.clips.length;b++){const g=this.models[b],y=this.actions[b],A=g.asset;y.weight=0;const v=t>=g.start&&t<=g.end,x=g.preExtrapolationMode,_=g.postExtrapolationMode,w=b<this.clips.length-1?this.models[b+1]:null;let C=v,T=!1;if(!C&&!r&&g.end<t&&_!==Ac.None?(!w||w.start>t)&&(C=!0,r=!0):b==0&&!C&&!o&&g.start>t&&x!==Ac.None&&(!w||w.start<t)&&(C=!0,T=!0,o=!0),C){let R=this.weight;R*=this.evaluateWeight(t,b,this.models,C),R*=this.director.weight;let S=v;if(T)switch(x){case Ac.Hold:break;case Ac.Loop:t+=g.start,S=!0;break;default:t+=g.start,S=!0;break}let I=this.getClipTime(t,g),L=0;const k=A.duration;if(T&&x===Ac.Hold&&(I=0),S){if(A.loop)for(L+=Math.floor(I/(k+1e-6));I>k;)I-=k}else if(!v&&r)switch(_){case Ac.Hold:I=this.getClipTime(g.end,g);break;case Ac.Loop:I%=k;break;case Ac.PingPong:const O=Math.floor(I/k)%2!==0;I%=k,O&&(I=k-I);break}g.reversed===!0?y.time=y.getClip().duration-I:y.time=I,y.timeScale=0;const P=Math.max(0,R);if(y.weight=P,a+=P,y.clampWhenFinished=!1,y.isRunning()||y.play(),this._useclipOffsets){const U=i==0?this._totalOffsetPosition:this._totalOffsetPosition2,O=i==0?this._totalOffsetRotation:this._totalOffsetRotation2;i<1&&(n=1-R),i+=1;const G=this._summedPos.set(0,0,0),N=this._tempPos.set(0,0,0),H=this._summedRot.identity(),J=this._tempRot.identity(),oe=A.rotation;oe&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(oe,R));const ae=this._actionOffsets[b];if(ae.hasOffsets)for(let Ie=0;Ie<L;Ie++)ae.rootPositionOffset?N.copy(ae.rootPositionOffset):N.set(0,0,0),N.applyQuaternion(H),this._clipRotQuat&&N.applyQuaternion(this._clipRotQuat),ae.rootQuaternionOffset&&(J.copy(ae.rootQuaternionOffset),H.multiply(J)),G.add(N);this._clipRotQuat&&O.multiply(this._clipRotQuat),O.multiply(H),A.position&&G.add(A.position),U.add(G)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,n),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,n)),this.__mixerError===void 0&&(Gc||Ze())&&((c=(l=this._animator)==null?void 0:l.runtimeAnimatorController)!=null&&c.mixer)&&this.mixer!==((u=(h=this._animator)==null?void 0:h.runtimeAnimatorController)==null?void 0:u.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)),(f=this._animator)!=null&&f.runtimeAnimatorController){const b=Math.max(0,1-a);(m=(p=this._animator)==null?void 0:p.runtimeAnimatorController)==null||m.update(b)}else this.mixer.update(t)}createRotationInterpolant(t,i,n){var l;const r=n.createInterpolant.bind(n),o=new we;this.ensureTrackOffsets();const a=(l=this.trackOffset)==null?void 0:l.rotation;n.createInterpolant=()=>{const c=r(),h=c.evaluate.bind(c);return c.evaluate=u=>{var p;const f=h(u);if(o.set(f[0],f[1],f[2],f[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),this.director.animationCallbackReceivers)for(const m of this.director.animationCallbackReceivers)(p=m==null?void 0:m.onTimelineRotation)==null||p.call(m,this.director,this.target,u,o);return f[0]=o.x,f[1]=o.y,f[2]=o.z,f[3]=o.w,f},c}}createPositionInterpolant(t,i,n){var h,u;const r=n.createInterpolant.bind(n),o=new M;this.ensureTrackOffsets();const a=(h=this.trackOffset)==null?void 0:h.rotation,l=(u=this.trackOffset)==null?void 0:u.position;let c;n.createInterpolant=()=>{const f=r(),p=f.evaluate.bind(f);return f.evaluate=m=>{var g,y,A;const b=p(m);if(o.set(b[0],b[1],b[2]),i.removeStartOffset&&(c===void 0?(c=null,c=(y=(g=this._actionOffsets.find(v=>v.clip===t))==null?void 0:g.rootStartPosition)==null?void 0:y.clone()):c!=null&&c.isVector3&&o.sub(c)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),a&&o.applyQuaternion(a),l&&(o.x-=l.x,o.y+=l.y,o.z+=l.z),this.director.animationCallbackReceivers)for(const v of this.director.animationCallbackReceivers)(A=v==null?void 0:v.onTimelinePosition)==null||A.call(v,this.director,this.target,m,o);return b[0]=o.x,b[1]=o.y,b[2]=o.z,b},f}}}const aye=ie("mutetimeline"),B0=class extends b_{constructor(){super(...arguments);d(this,"models",[]);d(this,"listener");d(this,"audio",[]);d(this,"audioContextTimeOffset",[]);d(this,"lastTime",0);d(this,"audioSource");d(this,"_audioLoader",null);d(this,"_playableDirectorResumed",!1)}getAudioFilePath(t){const i=this.director.sourceId;return lf(i,t)}onAllowAudioChanged(t){for(let i=0;i<this.models.length;i++){const n=this.models[i];this.audio[i].setVolume(t?n.asset.volume:0)}}addModel(t){const i=new _D(this.listener);this.audio.push(i);const n=t;n._didTriggerPlay=!1,this.models.push(n)}onDisable(){for(const t of this.audio)t.isPlaying&&t.stop();for(const t of this.models)t._didTriggerPlay=!1}onDestroy(){for(const t of this.audio)t.source&&(t==null||t.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}}stop(){for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}for(const t of this.models)t._didTriggerPlay=!1}onPauseChanged(){for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(t){if(aye||this.track.muted||this.director.speed<0)return;const i=this.director.context.application.muted,n=this._playableDirectorResumed;this._playableDirectorResumed=!1;const r=i?.1:0;for(let o=0;o<this.models.length;o++){const a=this.models[o],l=this.audio[o],c=a.asset;if((!l||!l.buffer)&&this.isInTimeRange(a,t-1,t+1)&&this.handleAudioLoading(a,l),On.userInteractionRegistered!==!1&&!(l===null||!l.buffer))if(l.playbackRate=this.director.context.time.timeScale*this.director.speed,l.loop=c.loop,t>=a.start&&t<=a.end&&t<this.director.duration){if(!l.isPlaying||!this.director.isPlaying)(n||!a._didTriggerPlay&&this.lastTime<t)&&(a.duration*a.timeScale>.3?l.offset=a.clipIn+(t-a.start)*a.timeScale:l.offset=0,Gc&&console.log("Timeline Audio ("+this.track.name+") play with offset "+l.offset+" - "+a.asset.clip),l.play(r),a._didTriggerPlay=!0);else{const u=a.clipIn+(t-a.start)*a.timeScale,f=l.context.currentTime-l._startedAt+l.offset;Math.abs(u-f)>.3&&(l.offset=u,l.stop(),l.play(r))}let h=c.volume;if(this.track.volume!==void 0&&(h*=this.track.volume),i&&(h=0),a.easeInDuration>0){const u=Math.min((t-a.start)/a.easeInDuration,1);h*=u}if(a.easeOutDuration>0){const u=Math.min((a.end-t)/a.easeOutDuration,1);h*=u}l.setVolume(h*this.director.weight)}else a._didTriggerPlay=!1,this.director.isPlaying&&l.isPlaying&&l.stop()}this.lastTime=t}loadAudio(t,i=0,n=0){let r=null;const o=t-n,a=t+i;for(const l of this.models)if(this.isInTimeRange(l,o,a)){const c=this.audio[this.models.indexOf(l)],h=this.handleAudioLoading(l,c);h!==null&&(r===null&&(r=[]),r.push(h))}return r!==null?Promise.all(r):null}isInTimeRange(t,i,n){return i<=t.start&&n>=t.end||i>=t.start&&i<=t.end||n>=t.start&&n<=t.end}static dispose(){B0._audioBuffers.clear()}handleAudioLoading(t,i){this._audioLoader||(this._audioLoader=new HC);const n=this.getAudioFilePath(t.asset.clip);if(B0._audioBuffers.get(n)){const o=B0._audioBuffers.get(n);return o.then(a=>{a&&i.setBuffer(a)}),o}Gc&&console.warn("LOAD audio track",n,this.director.sourceId);const r=new Promise((o,a)=>{this._audioLoader.load(n,l=>{i.setBuffer(l),o(l)},void 0,l=>{console.error("Error loading audio",l),o(null)})});return B0._audioBuffers.set(n,r),r}};let Qp=B0;d(Qp,"_audioBuffers",new Map);class px extends b_{constructor(){super(...arguments);d(this,"models",[]);d(this,"didTrigger",[]);d(this,"receivers",[])}evaluate(t){var n;if(this.track.muted)return;const i=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.didTrigger[r],l=o.time-t;let c=!1;if(o.retroActive)c=l<=1e-6;else{const h=Math.abs(l);(h===0||h>=1e-5&&h<i)&&(c=!0)}if(c){if(!a)if(Gc&&console.log("Trigger signal",t,o.time,o),this.didTrigger[r]=!0,((n=this.receivers)==null?void 0:n.length)<=0)Gy.invoke(o.asset);else for(const h of this.receivers)h&&h.invoke(o.asset)}else o.emitOnce||(this.didTrigger[r]=!1)}}}class yT extends b_{constructor(){super(...arguments);d(this,"models",[]);d(this,"timelines",[]);d(this,"_previousActiveModel",null)}resolveSourceObjects(t){for(let i=this.models.length-1;i>=0;i--){const r=this.models[i].asset;if(!r.sourceObject||typeof r.sourceObject!="object"){console.log("no source object, removing model",i,r),this.models.splice(i,1);continue}else{const o=ne.getComponent(r.sourceObject,Kd);this.timelines.push(o),o&&r.updateDirector&&(o.playOnAwake=!1)}}}evaluate(t){var i;this._previousActiveModel=null;for(let n=0;n<this.models.length;n++){const r=this.models[n],o=r.asset;if(t>=r.start&&t<=r.end){this._previousActiveModel=r;const a=this.getClipTime(t,r);if(o.controlActivation){const l=o.sourceObject;l.visible=!0}if(o.updateDirector){const l=this.timelines[n];l&&(l.isPlaying&&l.pause(),l.time=a,l.evaluate())}}else{const a=(i=this._previousActiveModel)==null?void 0:i.asset;if(o.controlActivation){const l=o.sourceObject;(a==null?void 0:a.sourceObject)!==l&&(l.visible=!1)}}}}}const lye=ie("debugpost");let qB=null;function cye(s){qB=s}function VY(s){let e=s.gameObject;for(;e;){for(const t of sT(e))if(t.isPostProcessingManager===!0)return t;e=e.parent}return null}function hye(s){let e=VY(s);if(!e)if(qB){lye&&console.warn("Adding postprocessing manager to the scene.");const t=s.scene;e=Ma(t,qB)}else Ze()&&console.warn("No post processing manager found");return e}var uye=Object.defineProperty,dye=Object.getOwnPropertyDescriptor,XY=(s,e,t,i)=>{for(var n=i>1?void 0:i?dye(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&uye(e,t,n),n};const fye=ie("debugpost");class qe{constructor(e){d(this,"isVolumeParameter",!0);d(this,"_isInitialized",!1);d(this,"_active",!0);d(this,"_value");d(this,"_valueRaw");d(this,"_defaultValue");d(this,"valueProcessor");d(this,"onValueChanged");e!==void 0&&this.initialize(e)}get isInitialized(){return this._isInitialized}initialize(e){e!==void 0&&(this._value=e,this._defaultValue=e,this._valueRaw=e,this._isInitialized=!0)}get overrideState(){return this._active}set overrideState(e){if(this._active===e)return;this._active=e;const t=e?this._valueRaw:this._defaultValue;this.processValue(t,!0)}get value(){return this._valueRaw}set value(e){this.isInitialized||this.initialize(e),this.processValue(e,!1)}set defaultValue(e){this._defaultValue=e}__init(){this.processValue(this._valueRaw,!0)}processValue(e,t){if(e==null||!t&&this.testIfValueChanged(e)===!1)return;const i=this._value;fye&&typeof i=="number"&&typeof e=="number"&&(i==null||i.toFixed(4),e==null||e.toFixed(4)),!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,e=this._defaultValue,this._valueRaw=e):(this._valueRaw=e,this._active&&this.valueProcessor&&(e=this.valueProcessor(e)),this._value=e),this.onValueChanged&&this.onValueChanged(e,i,this)}testIfValueChanged(e){return this._valueRaw!==e}}XY([E()],qe.prototype,"overrideState",1);XY([E()],qe.prototype,"value",1);class pye extends pl{constructor(){super([qe])}onSerialize(e,t){}onDeserialize(e,t){const i=t.target,n=t.path;let r;if(i&&n&&(r=i[n]),(typeof r!="object"||typeof r=="object"&&r.isVolumeParameter!==!0)&&(r=new qe),typeof e=="object"&&"value"in e){const o=e.value;r.initialize(o),r.overrideState=e.overrideState}else r.value=e;return r}}new pye;var mye=Object.defineProperty,gye=Object.getOwnPropertyDescriptor,yye=(s,e,t,i)=>{for(var n=i>1?void 0:i?gye(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&mye(e,t,n),n};const bye=ie("debugpost");class js extends Te{constructor(t=void 0){super();d(this,"active",!0);d(this,"_manager",null);d(this,"_result");d(this,"_postprocessingContext",null);if(t)for(const i of Object.keys(t)){const n=t[i],r=this[i];r instanceof qe?r.initialize(n):r!==void 0&&(this[i]=n)}}get isPostProcessingEffect(){return!0}onEnable(){super.onEnable(),this.onEffectEnabled(),this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){var t;super.onDisable(),(t=this._manager)==null||t.removeEffect(this),this.active=!1}onEffectEnabled(t){var i;t&&t.isPostProcessingManager===!0?this._manager=t:this._manager||(this._manager=hye(this)),(i=this._manager)==null||i.addEffect(this)}init(){}get postprocessingContext(){return this._postprocessingContext}apply(t){var i;return this._postprocessingContext=t,this._result||(this.initParameters(),this._result=(i=this.onCreateEffect)==null?void 0:i.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){bye&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(t=>t.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const t=Object.keys(this);for(const i of t){const n=this[i];n instanceof qe&&n.__init()}}onEditorModification(t){const i=t.propertyName;if(this[i]instanceof qe){const n=t.value;return this[i].value=n,!0}}}yye([E()],js.prototype,"active",2);var vye=Object.defineProperty,Aye=Object.getOwnPropertyDescriptor,xye=(s,e,t,i)=>{for(var n=i>1?void 0:i?Aye(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&vye(e,t,n),n};const _ye=ie("debugpost"),$B={};function ml(s,e){$B[s]=e}function wye(s){return s.__type in $B?$B[s.__type]:(_ye&&s.__type&&console.warn("Unknown postprocessing type",s.__type,s),js)}class v_{constructor(){d(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}addEffect(e){this.components.push(e)}removeEffect(e){const t=this.components.indexOf(e);t>=0&&this.components.splice(t,1)}}xye([Dy([s=>wye(s),js])],v_.prototype,"components",2);var Sye=Object.defineProperty,Cye=Object.getOwnPropertyDescriptor,Mye=(s,e,t,i)=>{for(var n=i>1?void 0:i?Cye(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Sye(e,t,n),n};class A_ extends js{constructor(){super(...arguments);d(this,"preset",new qe(Ap.HIGH))}get typeName(){return"Antialiasing"}onCreateEffect(){const t=new aQ({preset:Ap.HIGH,edgeDetectionMode:pO.DEPTH});return this.preset.onValueChanged=i=>{t.applyPreset(i)},t}}Mye([E(qe)],A_.prototype,"preset",2);ml("Antialiasing",A_);const Eye=ie("debugusdz");class gf{constructor(){d(this,"files",new Array)}static getName(e){var r;const t=e.split(".").pop();let n=(r=e.split(".").slice(0,-1).join(".").split("/").pop())==null?void 0:r.replace(".","_");return n||(n="Audio_"+Math.random().toString(36).substring(2,15)),$l(n)+"."+t}get extensionName(){return"Audio"}onExportObject(e,t,i){const n=ne.getComponents(e,On);if(n.length)for(const r of n){if(!r.clip||typeof r.clip!="string"||!r.playOnAwake)continue;const o=r.clip.split("/").pop()||"Audio",a=gf.getName(r.clip),l=$l(a);if(!this.files.some(c=>c.path===r.clip)){this.files.push({path:r.clip,name:a});const c=a.toLowerCase();i.quickLookCompatible&&!c.endsWith(".mp3")&&!c.endsWith(".wav")&&!c.endsWith(".m4a")&&console.error("Audio file "+r.clip+" from "+r.name+" is not an MP3 or WAV file. QuickLook may not support playing it.")}i.quickLookCompatible||t.addEventListener("serialize",(c,h)=>{c.appendLine(),c.beginBlock(`def SpatialAudio "${l}"`,"(",!1),c.appendLine(`displayName = "${o}"`),c.closeBlock(")"),c.beginBlock(),c.appendLine(`uniform asset filePath = @audio/${a}@`),c.appendLine(`uniform token auralMode = "${r.spatialBlend>0?"spatial":"nonSpatial"}"`),c.appendLine(`uniform token playbackMode = "${r.loop?"loopFromStage":"onceFromStart"}"`),c.appendLine(`uniform float gain = ${r.volume}`),c.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const i="audio/"+t.name;if(e.files[i]){Eye&&console.warn("Audio file with name "+i+" already exists in the context. Skipping.");continue}const o=await(await(await fetch(t.path)).blob()).arrayBuffer(),a=new Uint8Array(o);e.files[i]=a}}}const eu=ie("debugautosync"),BL=Symbol("syncerId");class Tye{constructor(){d(this,"_syncers",{})}getOrCreateSyncer(e){if(!e.guid)return null;if(this._syncers[e.guid])return this._syncers[e.guid];const t=new Rye(e);return t[BL]=e.guid,this._syncers[t[BL]]=t,t}removeSyncer(e){delete this._syncers[e[BL]]}}const AF=new Tye;class Rye{constructor(e){d(this,"comp");d(this,"hasChanges",!1);d(this,"changedProperties",{});d(this,"_isReceiving",!1);d(this,"_isInit",!1);d(this,"onHandleSending",()=>{if(!this.hasChanges)return;this.hasChanges=!1;const e=this.comp.context.connection;if(!e||!e.isConnected||!e.isInRoom){for(const t in this.changedProperties)delete this.changedProperties[t];return}for(const t in this.changedProperties){const i=this.comp.guid+"/"+t,n=this.changedProperties[t];eu&&console.log("SEND",this.comp.name,this.networkingKey),e.send(this.networkingKey,{guid:i,data:n},Fl.Queued)}});d(this,"onHandleReceiving",e=>{if(eu&&console.log("RECEIVE",this.comp.name,this.comp.guid,e),!this._isInit||!this.comp||e.guid.startsWith(this.comp.guid)===!1)return;const[t,i]=e.guid.split("/");eu&&console.log("RECEIVED",this.comp.name,this.comp.guid,e);try{this._isReceiving=!0,this.comp[i]=e.data}catch(n){console.error(n)}finally{this._isReceiving=!1}});this.comp=e}get networkingKey(){return this.comp.guid}init(e){if(this._isInit)return;this._isInit=!0,this.comp=e,this.comp.context.post_render_callbacks.push(this.onHandleSending),this.comp.context.connection.beginListen(this.networkingKey,this.onHandleReceiving);const t=this.comp.context.connection.tryGetState(this.comp.guid);t&&this.onHandleReceiving(t)}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(e,t){this._isReceiving||(eu&&console.log("Property changed: "+e,t),this.hasChanges=!0,this.changedProperties[e]=t)}}function Iye(s,e){let t=e!==s;return!t&&s&&e&&(Array.isArray(s)&&Array.isArray(e)||typeof s=="object"&&typeof e=="object")&&(t=!0),t}const mA=Symbol("AutoSyncHandler");function Lye(s){if(s[mA])return s[mA];const e=AF.getOrCreateSyncer(s);return e==null||e.init(s),s[mA]=e,e}function Pye(s){const e=s[mA];e&&(AF.removeSyncer(e),e.destroy(),delete s[mA])}const xF=function(s=null){return function(e,t){var h;let i="";typeof t=="string"?i=t:i=t.name;let n=null,r;typeof s=="string"?r=e[s]:typeof s=="function"&&(r=s),r==null&&(Ze()||eu)&&s!=null&&console.warn('syncField: no callback function found for property "'+i+'"','"'+s+'"');const o=e,a=o.__internalAwake;if(typeof a!="function"){(eu||Ze())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((h=e==null?void 0:e.constructor)==null?void 0:h.name)+'" is not supported',e);return}eu&&console.log(i);const l=Symbol(i);o.__internalAwake=function(){if(this[l]!==void 0)return;this[l]=this[i],n=AF.getOrCreateSyncer(this);const u=Object.getOwnPropertyDescriptor(this,i);if((u==null?void 0:u.set)===void 0){let f=!1;Object.defineProperty(this,i,{set:function(p){var b;const m=this[l];if(this[l]=p,f){(Ze()||eu)&&console.warn("Recursive call detected",i);return}f=!0;try{const g=Iye(p,m);eu&&console.log("SyncField assignment",i,"changed?",g,p,r),g&&(r==null?void 0:r.call(this,p,m))!==!1&&((b=Lye(this))==null||b.notifyChanged(i,p))}finally{f=!1}},get:function(){return this[l]},configurable:!0,enumerable:!0})}n==null||n.init(this),a.call(this)};const c=o.__internalDestroy;o.__internalDestroy=function(){Pye(this),c.call(this)}}};var Bye=Object.defineProperty,kye=Object.getOwnPropertyDescriptor,bT=(s,e,t,i)=>{for(var n=i>1?void 0:i?kye(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Bye(e,t,n),n};const ua=ie("debugplayersync"),WY=class extends Te{constructor(){super(...arguments);d(this,"autoSync",!0);d(this,"asset");d(this,"onPlayerSpawned");d(this,"_localInstance");d(this,"onJoinedRoom",()=>{ua&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()});d(this,"destroyInstance",()=>{var e;(e=this._localInstance)==null||e.then(t=>{ua&&console.log("PlayerSync.destroyInstance",t),o_(t,this.context.connection,!0,{saveInRoom:!1})}),this._localInstance=void 0})}static async setupFrom(e,t){const i=ti.getOrCreateFromUrl(e);if(!i.asset){const o=await i.loadAssetAsync();ne.getOrAddComponent(o,ba)}const n=new WY;n._internalInit(t),n.asset=i;const r=new me;return r.guid=e,ne.addComponent(r,n),n}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new Yi)}onEnable(){this.context.connection.beginListen(Ht.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(Ht.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Ht.LeftRoom,this.destroyInstance),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(Ht.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(Ht.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Ht.LeftRoom,this.destroyInstance)}async getInstance(){var t,i,n,r,o,a;if(this._localInstance)return this._localInstance;if(ua&&console.log("PlayerSync.createInstance",(t=this.asset)==null?void 0:t.url),!((i=this.asset)!=null&&i.asset)&&!((n=this.asset)!=null&&n.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=(r=this.asset)==null?void 0:r.instantiateSynced({parent:this.gameObject,deleteOnDisconnect:!0},!0);const e=await this._localInstance;if(e){const l=ne.getComponentsInChildren(e,ba);if(l!=null&&l.length){for(const c of l)c.owner=this.context.connection.connectionId;(o=this.onPlayerSpawned)==null||o.invoke(e)}else this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((a=this.asset)==null?void 0:a.url)+"</strong>: please make sure the asset has a PlayerState component!"),ne.destroySynced(e)}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}watchTabVisible(){window.addEventListener("visibilitychange",e=>{if(document.visibilityState==="visible")for(let t=ba.all.length-1;t>=0;t--){const i=ba.all[t];(!i.owner||!this.context.connection.userIsInRoom(i.owner))&&i.doDestroy()}})}};let Ny=WY;bT([E()],Ny.prototype,"autoSync",2);bT([E(ti)],Ny.prototype,"asset",2);bT([E(Yi)],Ny.prototype,"onPlayerSpawned",2);var HY=(s=>(s.OwnerChanged="ownerChanged",s))(HY||{}),gv;const or=(gv=class extends Te{constructor(){super(...arguments);d(this,"onOwnerChangeEvent",new Yi);d(this,"onFirstOwnerChangeEvent",new Yi);d(this,"hasOwner",!1);d(this,"owner");d(this,"dontDestroy",!1);d(this,"onUserLeftRoom",e=>{if(e.userId===this.owner){ua&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return or._all}static get local(){return or._local}static getFor(e){if(e instanceof me)return ne.getComponentInParent(e,or);if(e instanceof Te)return ne.getComponentInParent(e.gameObject,or)}static isLocalPlayer(e){const t=or.getFor(e);return(t==null?void 0:t.isLocalPlayer)??!1}static addEventListener(e,t){return this._callbacks[e]||(this._callbacks[e]=[]),this._callbacks[e].push(t),t}static removeEventListener(e,t){if(!this._callbacks[e])return;const i=this._callbacks[e].indexOf(t);i>=0&&this._callbacks[e].splice(i,1)}static dispatchEvent(e,t){if(this._callbacks[e])for(const i of this._callbacks[e])i(t)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(e,t){var o,a;ua&&console.log("PlayerSync.onOwnerChange",this,"newOwner",e,"oldOwner",t);const i=or._local.indexOf(this);i>=0&&or._local.splice(i,1);const n={playerState:this,oldValue:t,newValue:e};if(this.hasOwner||(this.hasOwner=!0,(o=this.onFirstOwnerChangeEvent)==null||o.invoke(n)),(a=this.onOwnerChangeEvent)==null||a.invoke(n),this.owner===this.context.connection.connectionId){or._local.push(this);const l=new CustomEvent("local-owner-changed",{detail:n});this.dispatchEvent(l)}const r=new CustomEvent("owner-changed",{detail:n});this.dispatchEvent(r),or.dispatchEvent("ownerChanged",r)}awake(){or.all.push(this),ua&&console.log("Registered new PlayerState",this.guid,or.all.length-1,or.all),this.context.connection.beginListen(Ht.UserLeftRoom,this.onUserLeftRoom)}async start(){ua&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await Kl(300),this.context.connection.userIsInRoom(this.owner)==!1&&(ua&&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||(ua&&console.warn("PlayerState.start → owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?ua&&console.warn("PlayerState.start → owner is still undefined but dontDestroy is set to true",this.name):(ua&&console.warn(`PlayerState.start → owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):ua&&console.log("PlayerState.start → owner is assigned",this.owner)},2e3))}doDestroy(){ua&&console.log("PlayerSync.doDestroy → syncDestroy",this.name),o_(this.gameObject,this.context.connection,!0,{saveInRoom:!1})}onDestroy(){if(this.context.connection.stopListen(Ht.UserLeftRoom,this.onUserLeftRoom),or.all.splice(or.all.indexOf(this),1),this.isLocalPlayer){const e=or._local.indexOf(this);e>=0&&or._local.splice(e,1)}}},d(gv,"_all",[]),d(gv,"_local",[]),d(gv,"_callbacks",{}),gv);let ba=or;bT([xF(ba.prototype.onOwnerChange)],ba.prototype,"owner",2);const Dye=ie("debugavatar"),Bl=class extends Te{constructor(){super(...arguments);d(this,"connectionId");d(this,"avatar")}static getAvatar(t){return t>=0&&t<Bl.instances.length?Bl.instances[t]:null}static onAvatarMarkerCreated(t){return Bl._onNewAvatarMarkerAdded.push(t),t}static onAvatarMarkerDestroyed(t){return Bl._onAvatarMarkerDestroyed.push(t),t}awake(){Bl.instances.push(this),Dye&&console.log(this);for(const t of Bl._onNewAvatarMarkerAdded)t({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){Bl.instances.splice(Bl.instances.indexOf(this),1);for(const t of Bl._onAvatarMarkerDestroyed)t({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let Es=Bl;d(Es,"instances",[]),d(Es,"_onNewAvatarMarkerAdded",[]),d(Es,"_onAvatarMarkerDestroyed",[]);var Oye=Object.defineProperty,Fye=Object.getOwnPropertyDescriptor,Gye=(s,e,t,i)=>{for(var n=i>1?void 0:i?Fye(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Oye(e,t,n),n};const h0=ie("debugxrflags"),QY=ie("disablexrflags");QY&&console.warn("XRFlags are disabled");var Lc=(s=>(s[s.Never=0]="Never",s[s.Browser=1]="Browser",s[s.AR=2]="AR",s[s.VR=4]="VR",s[s.FirstPerson=8]="FirstPerson",s[s.ThirdPerson=16]="ThirdPerson",s[s.All=4294967295]="All",s))(Lc||{});const UG=class{constructor(){d(this,"Mask",17)}Has(e){return(this.Mask&e)!==0}Set(e){h0&&console.warn("Set XR flag state to",e),this.Mask=e,pa.Apply()}Enable(e){this.Mask|=e,pa.Apply()}Disable(e){this.Mask&=~e,pa.Apply()}Toggle(e){this.Mask^=e,pa.Apply()}EnableAll(){this.Mask=-1,pa.Apply()}DisableAll(){this.Mask=0,pa.Apply()}};let pr=UG;d(pr,"Global",new UG);var yv;const Oh=(yv=class extends Te{constructor(){super(...arguments);d(this,"visibleIn")}static Apply(){for(const e of this.registry)e.UpdateVisible(pr.Global)}awake(){Oh.registry.push(this)}onEnable(){Oh.firstApply?this.UpdateVisible(pr.Global):(Oh.firstApply=!0,Oh.Apply())}onDestroy(){const e=Oh.registry.indexOf(this);e>=0&&Oh.registry.splice(e,1)}get isOn(){return this.gameObject.visible}UpdateVisible(e=null){if(QY)return;let t;const i=e;if(i&&typeof i=="number"&&(console.assert(typeof i=="number","XRFlag.UpdateVisible: state must be a number",i),h0&&console.log(i),Oh.buffer.Mask=i,e=Oh.buffer),e instanceof pr?(h0&&console.warn(this.name,"use passed in mask",e.Mask,this.visibleIn),t=e.Has(this.visibleIn)):(h0&&console.log(this.name,"use global mask"),pr.Global.Has(this.visibleIn)),t!==void 0)if(t)h0&&console.log(this.name,"is visible",this.gameObject.uuid),ne.setActive(this.gameObject,!0);else{if(h0&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},d(yv,"registry",[]),d(yv,"firstApply"),d(yv,"buffer",new pr),yv);let pa=Oh;Gye([E()],pa.prototype,"visibleIn",2);var Nye=Object.defineProperty,zye=Object.getOwnPropertyDescriptor,_F=(s,e,t,i)=>{for(var n=i>1?void 0:i?zye(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Nye(e,t,n),n};const Kb=ie("debugwebxr"),g5=new we().setFromAxisAngle(new M(0,1,0),Math.PI);class Jd extends Te{constructor(){super(...arguments);d(this,"head");d(this,"leftHand");d(this,"rightHand");d(this,"_leftHandMeshes");d(this,"_rightHandMeshes");d(this,"_syncTransforms")}async onEnterXR(t){if(!this.activeAndEnabled)return;Kb&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const i=ba.getFor(this);if(i!=null&&i.owner){const n=this.gameObject.addComponent(Es);n.avatar=this.gameObject,n.connectionId=i.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):i&&!this.context.connection.isConnected&&(i.dontDestroy=!0)}onLeaveXR(t){const i=this.gameObject.getComponent(Es);i&&i.destroy()}onUpdateXR(t){var c,h;if(!this.activeAndEnabled)return;const i=ba.isLocalPlayer(this);if(!i)return;const n=t.xr;if(n.rig&&n.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),n.rig.gameObject.add(this.gameObject)),this._syncTransforms&&i)for(const u of this._syncTransforms)u.fastMode=!0,u.isOwned()||u.requestOwnership();if(this.head&&this.context.mainCamera){const u=this.head.asset;if(u.position.copy(this.context.mainCamera.position),u.position.x*=-1,u.position.z*=-1,u.quaternion.copy(this.context.mainCamera.quaternion),u.quaternion.x*=-1,this.context.time.frameCount%10===0){const f=ne.getComponentsInChildren(this.head.asset,pa);for(const p of f)p.enabled=!1,p.gameObject.visible=!1}}const r=t.xr.leftController,o=(c=this.leftHand)==null?void 0:c.asset;r&&o?(o.position.copy(r.gripPosition),o.quaternion.copy(r.gripQuaternion),o.quaternion.multiply(g5),o.visible=r.isTracking,this.updateHandVisibility(r,o,this._leftHandMeshes)):o&&o.visible&&(o.visible=!1);const a=t.xr.rightController,l=(h=this.rightHand)==null?void 0:h.asset;a&&l?(l.position.copy(a.gripPosition),l.quaternion.copy(a.gripQuaternion),l.quaternion.multiply(g5),l.visible=a.isTracking,this.updateHandVisibility(a,l,this._rightHandMeshes)):l&&l.visible&&(l.visible=!1)}onBeforeRender(){this.context.xr&&this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateHandVisibility(t,i,n){if(n){const r=t.model&&t.model.visible&&t.model!==i;n.forEach(o=>{qh(o,!r)})}}updateRemoteAvatarVisibility(){var t,i,n;if(this.context.connection.isConnected){const r=ba.getFor(this);if(r&&r.isLocalPlayer==!1){const o=Et.getXRSync(this.context);if(o&&o.hasState(r.owner)){this.tryFindAvatarObjectsIfMissing();const a=(t=this.leftHand)==null?void 0:t.asset;a&&(a.visible=(o==null?void 0:o.isTracking(r.owner,"left"))??!1);const l=(i=this.rightHand)==null?void 0:i.asset;l&&(l.visible=(o==null?void 0:o.isTracking(r.owner,"right"))??!1)}if((n=this.head)!=null&&n.asset){const a=ne.getComponentsInChildren(this.head.asset,pa);for(const l of a)l.enabled=!1,l.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const t={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};ij.tryFindAvatarObjects(this.gameObject,this.sourceId||"",t),t.head&&(this.head=t.head),t.leftHand&&(this.leftHand=t.leftHand),t.rightHand&&(this.rightHand=t.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof me&&(this.head=new ti("",this.sourceId,this.head));else{const t=new me;t.name="Head";const i=pf.createPrimitive(cm.Cube);t.add(i),this.gameObject.add(t),this.head=new ti("",this.sourceId,t),Kb&&console.log("Create head",t)}if(this.rightHand)this.rightHand instanceof me&&(this.rightHand=new ti("",this.sourceId,this.rightHand));else{const t=new me;t.name="Right Hand",this.gameObject.add(t),this.rightHand=new ti("",this.sourceId,t),Kb&&console.log("Create right hand",t)}if(this.leftHand)this.leftHand instanceof me&&(this.leftHand=new ti("",this.sourceId,this.leftHand));else{const t=new me;t.name="Left Hand",this.gameObject.add(t),this.leftHand=new ti("",this.sourceId,t),Kb&&console.log("Create left hand",t)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),this._leftHandMeshes=[],this.leftHand.asset.traverse(t=>{t!=null&&t.isMesh&&this._leftHandMeshes.push(t)}),this._rightHandMeshes=[],this.rightHand.asset.traverse(t=>{t!=null&&t.isMesh&&this._rightHandMeshes.push(t)}),ba.isLocalPlayer(this.gameObject)&&(this._syncTransforms=ne.getComponentsInChildren(this.gameObject,Jc))}async loadAvatarObjects(t,i,n){const r=t.loadAssetAsync(),o=i.loadAssetAsync(),a=n.loadAssetAsync(),l=new Array;r&&l.push(r),o&&l.push(o),a&&l.push(a);const c=await kE(l);Kb&&console.log("Avatar loaded results:",c)}}_F([E(ti)],Jd.prototype,"head",2);_F([E(ti)],Jd.prototype,"leftHand",2);_F([E(ti)],Jd.prototype,"rightHand",2);class Qc{static Add(e,t,i=null){if(t){for(const n of this.Pois)if(n.obj===t)return;this.Pois.push({obj:t,avatar:i}),this.LastChangeTime=e.time.time}}static Remove(e,t){var i;if(t){for(const n of this.Pois)if(n.obj===t){this.Pois.splice(this.Pois.indexOf(n),1),this.LastChangeTime=(e==null?void 0:e.time.time)??((i=It.Current)==null?void 0:i.time.time);return}}}}d(Qc,"Pois",[]),d(Qc,"LastChangeTime",0);class Uye{constructor(){d(this,"guid");d(this,"position",new M)}}class mx extends Te{constructor(){super(...arguments);d(this,"target",null);d(this,"avatar",null);d(this,"_model",null);d(this,"_targetModel",new Uye);d(this,"_currentTargetObject",null);d(this,"_lastUpdateTime",0);d(this,"_lookDuration",0);d(this,"_lastPoiChangedTime",0)}set controlledTarget(t){this.target=t;const i=K.get("MoveRandom");if(i&&this.target){const n=ne.getComponent(this.target,i);n&&n.destroy()}}awake(){if(this.avatar=ne.getComponentInParent(this.gameObject,Es),this.avatar){const t=ne.getComponentInParent(this.gameObject,Es);this._model=new UO(this.context.connection,this.guid),t!=null&&t.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",t=>{var i;this.target&&t&&t.guid===((i=this.avatar)==null?void 0:i.guid)&&Rs(this.target,t.position)})}update(){var i;if((!this.context.connection.isConnected||(i=this._model)!=null&&i.hasOwnership)&&(Qc.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=Qc.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const n=zt(this._currentTargetObject);Rs(this.target,n),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(n))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const i=Qc.Pois;if(i.length>0){const n=i[Math.floor(Math.random()*i.length)];if(n&&n.obj){if(n.avatar&&n.avatar===this.avatar)return;this._currentTargetObject=n.obj}}}}}function ZY(s){return s&&s.isComponent}const Vye=Symbol("object"),kL=new Ta(()=>new M,20);class jY{constructor(e,t,i,n,r,o){d(this,"_point");d(this,"_normal");d(this,"_tangentVelocity");d(this,"distance");d(this,"impulse");d(this,"friction");this._point=e,this.distance=t,this._normal=i,this.impulse=n,this.friction=r,this._tangentVelocity=o}get point(){return kL.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return kL.get().set(this._normal.x,this._normal.y,this._normal.z)}get tangentVelocity(){return kL.get().set(this._tangentVelocity.x,this._tangentVelocity.y,this._tangentVelocity.z)}}class YY{constructor(e,t,i){d(this,"contacts");d(this,"me");d(this,"_collider");d(this,"_gameObject");this.me=e,this._collider=t,this._gameObject=t.gameObject,this.contacts=i}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var e;return(e=this.collider)==null?void 0:e.attachedRigidbody}}class KY{constructor(e,t){d(this,"object");d(this,"collider");this.object=e,this.collider=t}}const Kn=ie("debugnetworkingstreams");var Nc=(s=>(s.Connected="peer-user-connected",s.StreamReceived="receive-stream",s.StreamEnded="call-ended",s.Disconnected="peer-user-disconnected",s.UserJoined="user-joined",s))(Nc||{});class wF{constructor(e,t){d(this,"type","call-ended");d(this,"userId");d(this,"direction");this.userId=e,this.direction=t}}class JY{constructor(e,t,i){d(this,"type","receive-stream");d(this,"userId");d(this,"stream");d(this,"target");this.userId=e,this.stream=t,this.target=i}}class Xye{constructor(e,t){d(this,"guid");d(this,"peerId");d(this,"dontSave",!0);this.guid=e.id,this.peerId=t}}var qY=(s=>(s.Incoming="incoming",s.Outgoing="outgoing",s))(qY||{});class Wye extends Qs{constructor(t,i,n,r=null){super();d(this,"peerId");d(this,"userId");d(this,"direction");d(this,"call");d(this,"_stream",null);d(this,"_isDisposed",!1);this.peerId=i.peer,this.userId=t,this.call=i,this.direction=n,this._stream=r,i.on("stream",o=>{if(Kn&&console.log("Receive stream",`
5958
5958
  Audio:`,o.getAudioTracks(),`
5959
5959
  Video:`,o.getVideoTracks()),this._stream=o,n==="incoming"){const a=new JY(t,o,this);this.dispatchEvent(a)}}),i.on("close",()=>{this.dispatchEvent(new wF(t,n))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),zc(this._stream))}get isOpen(){var t;return((t=this.call.peerConnection)==null?void 0:t.connectionState)==="connected"}get isOpening(){var t;return((t=this.call.peerConnection)==null?void 0:t.connectionState)==="connecting"}get isClosed(){return!this.isOpen||this._isDisposed}}function y5(s){return s=s.replace("a=fmtp:111 minptime=10;useinbandfec=1","a=fmtp:111 ptime=5;useinbandfec=1;stereo=1;maxplaybackrate=48000;maxaveragebitrat=128000;sprop-stereo=1"),s}const k0=class extends Qs{constructor(t,i){super();d(this,"updateCalls",()=>{var t;for(let i=this._incomingCalls.length-1;i>=0;i--){const n=this._incomingCalls[i];n.isClosed&&!n.isOpening&&this._incomingCalls.splice(i,1)}for(let i=this._outgoingCalls.length-1;i>=0;i--){const n=this._outgoingCalls[i];let r=!1;n.isClosed&&!n.isOpening&&((t=n.stream)!=null&&t.active?Kn&&console.warn("!!! Stream is still active, don't remove call",n.userId,"Your id: "+this.context.connection.connectionId):(Kn&&console.warn("!!! Remove closed call",n.userId),r=!0)),this.context.connection.userIsInRoom(n.userId)===!1&&(Kn&&console.warn("!!! User is not in room anymore, remove call",n.userId),r=!0),r&&(n.close(),this._outgoingCalls.splice(i,1))}});d(this,"id");d(this,"context");d(this,"_incomingCalls",[]);d(this,"_outgoingCalls",[]);d(this,"_peer");d(this,"_enabled",!1);d(this,"_enabledPeer",!1);d(this,"onConnectRoomFn",this.onConnectRoom.bind(this));d(this,"onPeerConnect",t=>{if(Kn&&console.log("PEER opened as",t),t===null){console.error("Peer connection failed",t);return}this.context.connection.send("peer-user-connected",new Xye(this,t))});d(this,"onPeerClose",()=>{Kn&&console.log("PEER closed"),this.updateCalls()});d(this,"onPeerDisconnected",()=>{Kn&&console.log("PEER disconnected"),this.updateCalls()});d(this,"onPeerError",t=>{Kn&&console.error("PEER error",t)});d(this,"onPeerReceivingCall",t=>{t.answer(void 0,{sdpTransform:i=>y5(i)}),this.registerCall(t,"incoming",null)});this.context=t,this.id=i,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(t,i){if(k0.instances.has(i))return k0.instances.get(i);const n=new k0(t,i);return k0.instances.set(i,n),n}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(t){return this.id+"-"+t}getUserIdFromPeerId(t){return t.substring(this.id.length+1)}makeCall(t,i){var o;if(!(i!=null&&i.id)){Kn?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 n={metadata:{userId:this.context.connection.connectionId,streamId:i.id},sdpTransform:a=>y5(a)},r=(o=this._peer)==null?void 0:o.call(t,i,n);if(r){const a=this.registerCall(r,"outgoing",i);return Kn&&console.warn(`📞 CALL ${t}`,`