@needle-tools/engine 3.45.2-beta → 3.45.2-beta.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.
@@ -4344,7 +4344,7 @@ Open this page to get the console: `+A.toString())}const i=ls()||T0()&&se();if((
4344
4344
  #__vconsole .vc-mask {
4345
4345
  overflow: hidden;
4346
4346
  }
4347
- `,ws?.prepend(g),i===!0&&WU()<=0&&gH(),console.log("\u{1F335} Debug console has loaded")}},A.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(A)}function JgA(){const i=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),A=()=>document.querySelector("#__vc_plug_"+i._id+" iframe");return i.on("renderTab",function(e){const g=globalThis["needle:codegen_files"];if(!g||g.length===0)return;let I=globalThis["needle:codegen_files"][0];const o=I.indexOf("?");o>-1&&(I=I.substring(0,o));const s=location.protocol+"//"+location.host+location.pathname+"/"+I,n=encodeURIComponent(s);i.fullUrl="https://viewer.needle.tools?inspect&file="+n;var a='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';e(a)}),i.on("show",function(){const e=A();e&&e.src!==i.fullUrl&&(e.src=i.fullUrl)}),i.on("hide",function(){const e=A();e&&(e.src="")}),i.on("addTopBar",function(e){var g=new Array;g.push({name:"Open in new window \u2197",onClick:function(I){window.open(i.fullUrl,"_blank"),Ds?.hide()}}),g.push({name:"Reload",onClick:function(I){const o=A();o&&(o.src=i.fullUrl)}}),g.push({name:"Fullscreen",onClick:function(I){const o=A();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),e(g)}),i}function xgA(){return document.querySelector("#__vconsole .vc-switch")||null}function qgA(){return document.querySelector("#__vconsole")||null}const nH=iA("debugdefines");rc('if(!globalThis[""3.45.2-beta""]) globalThis[""3.45.2-beta""] = "0.0.0";'),rc('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),rc('if(!globalThis[""Wed Jul 17 2024 17:50:05 GMT+0200 (Central European Summer Time)""]) globalThis[""Wed Jul 17 2024 17:50:05 GMT+0200 (Central European Summer Time)""] = "unknown";'),rc('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.45.2-beta";'),rc('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),rc('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Wed Jul 17 2024 17:50:05 GMT+0200 (Central European Summer Time)";');const Bn="3.45.2-beta",nm="undefined",jN="Wed Jul 17 2024 17:50:05 GMT+0200 (Central European Summer Time)";nH&&console.log(`Engine version: ${Bn} (generator: ${nm})
4347
+ `,ws?.prepend(g),i===!0&&WU()<=0&&gH(),console.log("\u{1F335} Debug console has loaded")}},A.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(A)}function JgA(){const i=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),A=()=>document.querySelector("#__vc_plug_"+i._id+" iframe");return i.on("renderTab",function(e){const g=globalThis["needle:codegen_files"];if(!g||g.length===0)return;let I=globalThis["needle:codegen_files"][0];const o=I.indexOf("?");o>-1&&(I=I.substring(0,o));const s=location.protocol+"//"+location.host+location.pathname+"/"+I,n=encodeURIComponent(s);i.fullUrl="https://viewer.needle.tools?inspect&file="+n;var a='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';e(a)}),i.on("show",function(){const e=A();e&&e.src!==i.fullUrl&&(e.src=i.fullUrl)}),i.on("hide",function(){const e=A();e&&(e.src="")}),i.on("addTopBar",function(e){var g=new Array;g.push({name:"Open in new window \u2197",onClick:function(I){window.open(i.fullUrl,"_blank"),Ds?.hide()}}),g.push({name:"Reload",onClick:function(I){const o=A();o&&(o.src=i.fullUrl)}}),g.push({name:"Fullscreen",onClick:function(I){const o=A();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),e(g)}),i}function xgA(){return document.querySelector("#__vconsole .vc-switch")||null}function qgA(){return document.querySelector("#__vconsole")||null}const nH=iA("debugdefines");rc('if(!globalThis[""3.45.2-beta.1""]) globalThis[""3.45.2-beta.1""] = "0.0.0";'),rc('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),rc('if(!globalThis[""Wed Jul 17 2024 19:33:24 GMT+0200 (Central European Summer Time)""]) globalThis[""Wed Jul 17 2024 19:33:24 GMT+0200 (Central European Summer Time)""] = "unknown";'),rc('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.45.2-beta.1";'),rc('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),rc('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Wed Jul 17 2024 19:33:24 GMT+0200 (Central European Summer Time)";');const Bn="3.45.2-beta.1",nm="undefined",jN="Wed Jul 17 2024 19:33:24 GMT+0200 (Central European Summer Time)";nH&&console.log(`Engine version: ${Bn} (generator: ${nm})
4348
4348
  Project built at ${jN}`);const hr="needle_isActiveInHierarchy",HQ="builtin_components",Uu="needle_editor_guid";function rc(i){try{(0,eval)(i)}catch(A){nH&&console.error(A)}}const LgA='<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>',_gA=btoa(LgA),TgA="data:image/svg+xml;base64,"+_gA,YgA=TgA,HgA=`<?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(HgA);const OgA='<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>',PgA=btoa(OgA),jgA="data:image/svg+xml;charset=utf-8;base64,"+PgA,WgA=jgA,ys=iA("debuglicense");let OQ="basic";ys&&console.log("License Type: "+OQ);function RC(){switch(OQ){case"pro":case"enterprise":return!0}return!1}function WN(){switch(OQ){case"indie":return!0}return!1}function Er(){return RC()||WN()}const aH=[];function ZgA(i){if(RC()||WN())return i(!0);aH.push(i)}function zgA(i){for(const A of aH)try{A(i)}catch{}}Qt.registerCallback(Mt.ContextRegistered,i=>{$gA(i.context),eIA(),XgA(i.context)});let PQ,ZN=!1,am="";async function VgA(){if(PQ)return PQ;if(OQ==="basic")try{const i="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+Bn+"&generator="+encodeURIComponent(nm),A=await fetch(i,{method:"GET"}).catch(e=>{ys&&console.error("License check failed",e)});A?.status===200?(ZN=!1,ys&&console.log("License check succeeded"),OQ="pro",zgA(!0)):A?.status===403?(ZN=!0,am=await A.text()):ys&&console.log("License check failed with status "+A?.status)}catch(i){ys&&console.error("License check failed",i)}else ys&&console.log('Runtime license check is skipped because license is already applied as "'+OQ+'"')}PQ=VgA();async function XgA(i){function A(){const I=document.createElement("div");I.className="needle-forbidden",I.style.cssText=`
4349
4349
  position: fixed;
4350
4350
  top: 0;
@@ -5148,7 +5148,7 @@ in script ${o}.ts
5148
5148
  *
5149
5149
  * @author Feross Aboukhadijeh <https://feross.org>
5150
5150
  * @license MIT
5151
- */var KBA=function(i){return i!=null&&(h4(i)||bBA(i)||!!i._isBuffer)};function h4(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function bBA(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&h4(i.slice(0,0))}(function(){var i=vBA,A=Q4.utf8,e=KBA,g=Q4.bin,I=function(o,s){o.constructor==String?s&&s.encoding==="binary"?o=g.stringToBytes(o):o=A.stringToBytes(o):e(o)?o=Array.prototype.slice.call(o,0):!Array.isArray(o)&&o.constructor!==Uint8Array&&(o=o.toString());for(var n=i.bytesToWords(o),a=o.length*8,r=1732584193,C=-271733879,Q=-1732584194,h=271733878,E=0;E<n.length;E++)n[E]=(n[E]<<8|n[E]>>>24)&16711935|(n[E]<<24|n[E]>>>8)&4278255360;n[a>>>5]|=128<<a%32,n[(a+64>>>9<<4)+14]=a;for(var c=I._ff,l=I._gg,d=I._hh,u=I._ii,E=0;E<n.length;E+=16){var D=r,p=C,w=Q,f=h;r=c(r,C,Q,h,n[E+0],7,-680876936),h=c(h,r,C,Q,n[E+1],12,-389564586),Q=c(Q,h,r,C,n[E+2],17,606105819),C=c(C,Q,h,r,n[E+3],22,-1044525330),r=c(r,C,Q,h,n[E+4],7,-176418897),h=c(h,r,C,Q,n[E+5],12,1200080426),Q=c(Q,h,r,C,n[E+6],17,-1473231341),C=c(C,Q,h,r,n[E+7],22,-45705983),r=c(r,C,Q,h,n[E+8],7,1770035416),h=c(h,r,C,Q,n[E+9],12,-1958414417),Q=c(Q,h,r,C,n[E+10],17,-42063),C=c(C,Q,h,r,n[E+11],22,-1990404162),r=c(r,C,Q,h,n[E+12],7,1804603682),h=c(h,r,C,Q,n[E+13],12,-40341101),Q=c(Q,h,r,C,n[E+14],17,-1502002290),C=c(C,Q,h,r,n[E+15],22,1236535329),r=l(r,C,Q,h,n[E+1],5,-165796510),h=l(h,r,C,Q,n[E+6],9,-1069501632),Q=l(Q,h,r,C,n[E+11],14,643717713),C=l(C,Q,h,r,n[E+0],20,-373897302),r=l(r,C,Q,h,n[E+5],5,-701558691),h=l(h,r,C,Q,n[E+10],9,38016083),Q=l(Q,h,r,C,n[E+15],14,-660478335),C=l(C,Q,h,r,n[E+4],20,-405537848),r=l(r,C,Q,h,n[E+9],5,568446438),h=l(h,r,C,Q,n[E+14],9,-1019803690),Q=l(Q,h,r,C,n[E+3],14,-187363961),C=l(C,Q,h,r,n[E+8],20,1163531501),r=l(r,C,Q,h,n[E+13],5,-1444681467),h=l(h,r,C,Q,n[E+2],9,-51403784),Q=l(Q,h,r,C,n[E+7],14,1735328473),C=l(C,Q,h,r,n[E+12],20,-1926607734),r=d(r,C,Q,h,n[E+5],4,-378558),h=d(h,r,C,Q,n[E+8],11,-2022574463),Q=d(Q,h,r,C,n[E+11],16,1839030562),C=d(C,Q,h,r,n[E+14],23,-35309556),r=d(r,C,Q,h,n[E+1],4,-1530992060),h=d(h,r,C,Q,n[E+4],11,1272893353),Q=d(Q,h,r,C,n[E+7],16,-155497632),C=d(C,Q,h,r,n[E+10],23,-1094730640),r=d(r,C,Q,h,n[E+13],4,681279174),h=d(h,r,C,Q,n[E+0],11,-358537222),Q=d(Q,h,r,C,n[E+3],16,-722521979),C=d(C,Q,h,r,n[E+6],23,76029189),r=d(r,C,Q,h,n[E+9],4,-640364487),h=d(h,r,C,Q,n[E+12],11,-421815835),Q=d(Q,h,r,C,n[E+15],16,530742520),C=d(C,Q,h,r,n[E+2],23,-995338651),r=u(r,C,Q,h,n[E+0],6,-198630844),h=u(h,r,C,Q,n[E+7],10,1126891415),Q=u(Q,h,r,C,n[E+14],15,-1416354905),C=u(C,Q,h,r,n[E+5],21,-57434055),r=u(r,C,Q,h,n[E+12],6,1700485571),h=u(h,r,C,Q,n[E+3],10,-1894986606),Q=u(Q,h,r,C,n[E+10],15,-1051523),C=u(C,Q,h,r,n[E+1],21,-2054922799),r=u(r,C,Q,h,n[E+8],6,1873313359),h=u(h,r,C,Q,n[E+15],10,-30611744),Q=u(Q,h,r,C,n[E+6],15,-1560198380),C=u(C,Q,h,r,n[E+13],21,1309151649),r=u(r,C,Q,h,n[E+4],6,-145523070),h=u(h,r,C,Q,n[E+11],10,-1120210379),Q=u(Q,h,r,C,n[E+2],15,718787259),C=u(C,Q,h,r,n[E+9],21,-343485551),r=r+D>>>0,C=C+p>>>0,Q=Q+w>>>0,h=h+f>>>0}return i.endian([r,C,Q,h])};I._ff=function(o,s,n,a,r,C,Q){var h=o+(s&n|~s&a)+(r>>>0)+Q;return(h<<C|h>>>32-C)+s},I._gg=function(o,s,n,a,r,C,Q){var h=o+(s&a|n&~a)+(r>>>0)+Q;return(h<<C|h>>>32-C)+s},I._hh=function(o,s,n,a,r,C,Q){var h=o+(s^n^a)+(r>>>0)+Q;return(h<<C|h>>>32-C)+s},I._ii=function(o,s,n,a,r,C,Q){var h=o+(n^(s|~a))+(r>>>0)+Q;return(h<<C|h>>>32-C)+s},I._blocksize=16,I._digestsize=16,C4.exports=function(o,s){if(o==null)throw new Error("Illegal argument "+o);var n=i.wordsToBytes(I(o,s));return s&&s.asBytes?n:s&&s.asString?g.bytesToString(n):i.bytesToHex(n)}})();var JBA=C4.exports;const xBA=RS(JBA);class yK{constructor(A,e,g,I){B(this,"success"),B(this,"filename"),B(this,"hash"),B(this,"size"),B(this,"url"),this.success=A,this.filename=e,this.hash=g,this.size=I}}async function E4(i,A){const e=await i.arrayBuffer(),g=mK(e),I=i.name.split(".").pop(),o=g+"."+I,s=i.name.split(".").shift();console.assert(s!==void 0);const n={alias:s,filename:o},a=await(await fetch(A+"/exists",{method:"POST",body:JSON.stringify(n)})).json();if(a.success||console.warn("exists check did fail"),a.exists)return console.log("file already exists",g),new yK(!0,o,g,i.size);console.log("begin uploading file",s,i.size);const r=new FormData;r.append("file",i);const C={};C.filesize=i.size,s&&(C.alias=s);const Q=await(await fetch(A+"/upload/file",{method:"POST",body:r,headers:C})).json();if(Q?.success===!1)return Q.message!==void 0?console.error("Upload failed:",Q.message):console.error("Upload failed"),null;console.assert(Q.hash_sum===g,"hash sum did not match","received:",Q.hash_sum,"expected:",g),Q.success&&console.log("successfully uploaded",g,Q.id);const h=new yK(Q.success,o,g,i.size);return h.url=A,h}function mK(i){return xBA(new Uint8Array(i))}async function SK(i,A,e,g,I=!1){try{const o=await fetch(g+"/download/file",{method:"POST",body:i});if(o.status!==200)return console.error("download failed",o),null;const s=await o.blob(),n=await s.arrayBuffer();I||console.assert(s.size===e,"size mismatch","expected:",e,"got:",s.size);const a=mK(n);return I||console.assert(a===A,"hash mismatch, downloaded file is invalid"),s.arrayBuffer()}catch(o){console.error(o)}return null}async function c4(i,A){var e;const g=await fetch(i),I=(e=g.body)==null?void 0:e.getReader(),o=g.headers.get("Content-Length"),s=o?parseInt(o):0;if(!I)return null;let n=0;const a=[];for(;;){const{done:Q,value:h}=await I.read();if(h&&(a.push(h),n+=h.length,A.call(null,new ProgressEvent("progress",{loaded:n,total:s}))),Q)break}const r=new Uint8Array(n);let C=0;for(const Q of a)r.set(Q,C),C+=Q.length;return r}const tB=iA("debugaddressables");class l4{constructor(A){B(this,"_context"),B(this,"_assetReferences",{}),B(this,"preUpdate",()=>{}),this._context=A,this._context.pre_update_callbacks.push(this.preUpdate)}dispose(){const A=this._context.pre_update_callbacks.indexOf(this.preUpdate);A>=0&&this._context.pre_update_callbacks.splice(A,1);for(const e in this._assetReferences){const g=this._assetReferences[e];g?.unload()}this._assetReferences={}}findAssetReference(A){return this._assetReferences[A]||null}registerAssetReference(A){return A.uri&&(this._assetReferences[A.uri]?console.warn("Asset reference already registered",A):this._assetReferences[A.uri]=A),A}unregisterAssetReference(A){A.uri&&delete this._assetReferences[A.uri]}}const fK=Symbol("assetReference"),el=class{constructor(i,A,e=null){B(this,"_loading"),B(this,"_asset"),B(this,"_glbRoot"),B(this,"_url"),B(this,"_progressListeners",[]),B(this,"_hash"),B(this,"_hashedUri"),B(this,"_isLoadingRawBinary",!1),B(this,"_rawBinary"),this._url=i,this._hash=A,i.includes("?v=")?this._hashedUri=i:this._hashedUri=A?i+"?v="+A:i,e!==null&&(this.asset=e),Nj(this._url,this.onResolvePrefab.bind(this))}static getOrCreateFromUrl(i,A){if(!A&&(A=Ke.Current,!A))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.');const e=A.addressables,g=e.findAssetReference(i);if(g)return g;const I=new el(i,A.hash);return e.registerAssetReference(I),I}static getOrCreate(i,A,e){if(typeof i=="string"){if(!e&&(e=Ke.Current,!e))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.')}else e=i.context,i=i.sourceId;const g=MC(i,A);tB&&console.log("GetOrCreate Addressable from",i,A,"FinalPath=",g);const I=e.addressables,o=I.findAssetReference(g);if(o)return o;const s=new el(g,e.hash);return I.registerAssetReference(s),s}get asset(){return this._glbRoot??this._asset}set asset(i){this._asset=i}get uri(){return this._url}get url(){return this._url}get hasUrl(){return this._url!==void 0&&(this._url.startsWith("http")||this._url.startsWith("blob:"))}get rawAsset(){return this._asset}async onResolvePrefab(i){return i===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||lh(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(tB&&console.log("Unload",this.asset),this.asset.scene&&Ks(this.asset.scene,!0,!0),Ks(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,Ke.Current&&Ke.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,tB&&console.log("Preload",this._hashedUri);const i=await c4(this._hashedUri,A=>{this.raiseProgressEvent(A)});return this._rawBinary=i?.buffer??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(i){if(tB&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(i&&this._progressListeners.push(i),this._loading!==void 0)return this._loading.then(g=>this.asset);const A=Ke.Current;this._rawBinary?(this._loading=an().parseSync(A,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(tB&&console.log("Load async",this.uri),this._loading=an().loadSync(A,this._hashedUri,this.uri,null,g=>{this.raiseProgressEvent(g)}));const e=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(e),this._loading=void 0,e)return e[fK]=this,this._glbRoot&&(this._glbRoot[fK]=this),this.asset&&(this.asset[fK]=this),pS(A),e.scene!==void 0&&(this.asset=e),this.asset}async instantiate(i){return this.onInstantiate(i,!1)}async instantiateSynced(i,A=!0){return this.onInstantiate(i,!0,A)}beginListenDownload(i){this._progressListeners.indexOf(i)<0&&this._progressListeners.push(i)}endListenDownload(i){const A=this._progressListeners.indexOf(i);A>=0&&this._progressListeners.splice(A,1)}raiseProgressEvent(i){for(const A of this._progressListeners)A(this,i)}async onInstantiate(i,A=!1,e){const g=Ke.Current,I=new Ln;if(i instanceof wA?I.parent=i:i&&(Object.assign(I,i),I.cloneAssign(i)),I.parent||(I.parent=g.scene),this.mustLoad&&await this.loadAssetAsync(),tB&&console.log("Instantiate",this.uri,"parent:",i),this.asset){tB&&console.log("Add to scene",this.asset);let o=el.currentlyInstantiating.get(this.uri);if(o!==void 0&&o>=1e4)return console.error("Recursive or too many instantiations of "+this.uri+" in the same frame ("+o+")"),null;try{if(o===void 0&&(o=0),o+=1,el.currentlyInstantiating.set(this.uri,o),A){I.context=g;const s=this.asset;s.guid=this.uri;const n=Qb(s,I,void 0,e);if(n)return n}else{const s=Bl(this.asset,I);if(s)return s}}finally{g.post_render_callbacks.push(()=>{o===void 0||o<0?o=0:o-=1,el.currentlyInstantiating.set(this.uri,o)})}}else tB&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(i){if(i&&i.scene){const A=i.scene;return A.isGroup&&A.children.length===1&&A.children[0].name+"glb"===A.name?A.children[0]:A}return null}};let gt=el;B(gt,"currentlyInstantiating",new Map);class qBA extends Fs{constructor(){super([gt],"AssetReferenceSerializer")}onSerialize(A,e){if(A&&A.uri!==void 0&&typeof A.uri=="string")return A.uri}onDeserialize(A,e){if(typeof A=="string")return e.context?e.gltfId?gt.getOrCreate(e.gltfId,A,e.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(A instanceof wA){if(!e.context)return console.error("Missing context"),null;if(!e.gltfId)return console.error("Missing source id"),null;const g=A,I=e.context,o=g.guid??g.uuid,s=I.addressables.findAssetReference(o);if(s)return s;const n=new gt(o,void 0,g);return I.addressables.registerAssetReference(n),n}return null}}new qBA;const LBA=Promise.resolve(null),US=class{constructor(i){B(this,"url"),B(this,"_bitmap"),B(this,"_bitmapObject"),B(this,"loader",null),this.url=i}static getOrCreate(i){let A=US.imageReferences.get(i);return A||(A=new US(i),US.imageReferences.set(i,A)),A}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const i=new Image;return i.src=this.url,i}createTexture(){return this.url?(this.loader||(this.loader=new Zn),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):LBA}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((i,A)=>{const e=document.createElement("img");e.addEventListener("load",()=>{this._bitmap=createImageBitmap(e).then(g=>(this._bitmapObject=g,i(g),g))}),e.addEventListener("error",g=>{console.error("Failed to load image:"+this.url,g),i(null)}),e.src=this.url}),this._bitmap)}};let NS=US;B(NS,"imageReferences",new Map);class d4 extends Fs{constructor(){super([NS],"ImageReferenceSerializer")}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"){const g=MC(e.gltfId,A);return NS.getOrCreate(g)}}}new d4;const FS=class{constructor(i){B(this,"url"),B(this,"res"),this.url=i}static getOrCreate(i){let A=FS.cache.get(i);return A||(A=new FS(i),FS.cache.set(i,A)),A}async loadRaw(){return this.res||(this.res=fetch(this.url)),this.res.then(i=>i.blob())}async loadText(){return this.res||(this.res=fetch(this.url)),this.res.then(i=>i.text())}};let vS=FS;B(vS,"cache",new Map);class u4 extends Fs{constructor(){super([vS],"FileReferenceSerializer")}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"){const g=MC(e.gltfId,A);return vS.getOrCreate(g)}}}new u4;class _BA{constructor(A){B(this,"context"),B(this,"mixers",[]),this.context=A}onDestroy(){this.mixers.forEach(A=>A.stopAllAction()),this.mixers.length=0}registerAnimationMixer(A){if(!A){console.warn("AnimationsRegistry.registerAnimationMixer called with null or undefined mixer");return}this.mixers.includes(A)||this.mixers.push(A)}unregisterAnimationMixer(A){if(!A)return;const e=this.mixers.indexOf(A);e!==-1&&this.mixers.splice(e,1)}}class tl{static tryGetActionsFromMixer(A){return A._actions||null}static tryGetAnimationClipsFromObjectHierarchy(A,e){if(e||(e=new Array),A)A.animations&&e.push(...A.animations);else return e;if(A.children)for(const g of A.children)this.tryGetAnimationClipsFromObjectHierarchy(g,e);return e}static assignAnimationsFromFile(A,e){if(!A||!A.animations)return;for(let I=0;I<A.animations.length;I++){const o=A.animations[I];if(!(!o.tracks||o.tracks.length<=0))for(const s in o.tracks){const n=o.tracks[s],a=Ze.parseTrackName(n.name);let r=Ze.findNode(A.scene,a.nodeName);if(!r){const Q=n.__objectName??n.name.substring(0,n.name.indexOf("."));if(r=A.scene.getObjectByProperty("uuid",Q),!r)continue}let C=g(r);if(!C){if(!(e!=null&&e.createAnimationComponent)){console.warn("No AnimationComponent found in parent hierarchy of object and no 'createAnimationComponent' callback was provided in options.");continue}C=e.createAnimationComponent(A.scene,o)}C.addClip&&C.addClip(o)}}function g(I){var o;if(!I)return null;const s=(o=I.userData)==null?void 0:o.components;if(s&&s.length>0){for(let n=0;n<s.length;n++)if(s[n].isAnimationComponent===!0)return I}return g(I.parent)}}}const il=[];function KS(i){il.indexOf(i)===-1&&il.push(i)}function TBA(i){const A=il.indexOf(i);A!==-1&&il.splice(A,1)}const gl=[];function kK(i){gl.indexOf(i)===-1&&gl.push(i)}function YBA(i){const A=gl.indexOf(i);A!==-1&&gl.splice(A,1)}function p4(i){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-start",{detail:i}));for(let A=0;A<il.length;A++)il[A](i)}function D4(i){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-end",{detail:i}));for(let A=0;A<gl.length;A++)gl[A](i)}const Kg={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function w4(i){const A=await fetch(i);if(A.ok)return A.json();throw new Error(A.statusText)}async function HBA(i){if(!i)throw new Error("No basePath supplied");return await w4(`${i}/profilesList.json`)}async function OBA(i,A,e=null,g=!0){if(!i)throw new Error("No xrInputSource supplied");if(!A)throw new Error("No basePath supplied");const I=await HBA(A);let o;if(i.profiles.some(a=>{const r=I[a];return r&&(o={profileId:a,profilePath:`${A}/${r.path}`,deprecated:!!r.deprecated}),!!o}),!o){if(!e)throw new Error("No matching profile name found");const a=I[e];if(!a)throw new Error(`No matching profile name found and default profile "${e}" missing.`);o={profileId:e,profilePath:`${A}/${a.path}`,deprecated:!!a.deprecated}}const s=await w4(o.profilePath);let n;if(g){let a;if(i.handedness==="any"?a=s.layouts[Object.keys(s.layouts)[0]]:a=s.layouts[i.handedness],!a)throw new Error(`No matching handedness, ${i.handedness}, in profile ${o.profileId}`);a.assetPath&&(n=o.profilePath.replace("profile.json",a.assetPath))}return{profile:s,assetPath:n}}const PBA={xAxis:0,yAxis:0,button:0,state:Kg.ComponentState.DEFAULT};function jBA(i=0,A=0){let e=i,g=A;if(Math.sqrt(i*i+A*A)>1){const I=Math.atan2(A,i);e=Math.cos(I),g=Math.sin(I)}return{normalizedXAxis:e*.5+.5,normalizedYAxis:g*.5+.5}}let WBA=class{constructor(i){this.componentProperty=i.componentProperty,this.states=i.states,this.valueNodeName=i.valueNodeName,this.valueNodeProperty=i.valueNodeProperty,this.valueNodeProperty===Kg.VisualResponseProperty.TRANSFORM&&(this.minNodeName=i.minNodeName,this.maxNodeName=i.maxNodeName),this.value=0,this.updateFromComponent(PBA)}updateFromComponent({xAxis:i,yAxis:A,button:e,state:g}){const{normalizedXAxis:I,normalizedYAxis:o}=jBA(i,A);switch(this.componentProperty){case Kg.ComponentProperty.X_AXIS:this.value=this.states.includes(g)?I:.5;break;case Kg.ComponentProperty.Y_AXIS:this.value=this.states.includes(g)?o:.5;break;case Kg.ComponentProperty.BUTTON:this.value=this.states.includes(g)?e:0;break;case Kg.ComponentProperty.STATE:this.valueNodeProperty===Kg.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(g):this.value=this.states.includes(g)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}},ZBA=class{constructor(i,A){if(!i||!A||!A.visualResponses||!A.gamepadIndices||Object.keys(A.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=i,this.type=A.type,this.rootNodeName=A.rootNodeName,this.touchPointNodeName=A.touchPointNodeName,this.visualResponses={},Object.keys(A.visualResponses).forEach(e=>{const g=new WBA(A.visualResponses[e]);this.visualResponses[e]=g}),this.gamepadIndices=Object.assign({},A.gamepadIndices),this.values={state:Kg.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(i){if(this.values.state=Kg.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&i.buttons.length>this.gamepadIndices.button){const A=i.buttons[this.gamepadIndices.button];this.values.button=A.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,A.pressed||this.values.button===1?this.values.state=Kg.ComponentState.PRESSED:(A.touched||this.values.button>Kg.ButtonTouchThreshold)&&(this.values.state=Kg.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&i.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=i.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===Kg.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Kg.AxisTouchThreshold&&(this.values.state=Kg.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&i.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=i.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===Kg.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Kg.AxisTouchThreshold&&(this.values.state=Kg.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(A=>{A.updateFromComponent(this.values)})}},zBA=class{constructor(i,A,e){if(!i)throw new Error("No xrInputSource supplied");if(!A)throw new Error("No profile supplied");this.xrInputSource=i,this.assetUrl=e,this.id=A.profileId,this.layoutDescription=A.layouts[i.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(g=>{const I=this.layoutDescription.components[g];this.components[g]=new ZBA(g,I)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const i=[];return Object.values(this.components).forEach(A=>{i.push(A.data)}),i}updateFromGamepad(){Object.values(this.components).forEach(i=>{i.updateFromGamepad(this.xrInputSource.gamepad)})}};const Io=new S,y4=new S,m4=new GA,VBA=iA("debuggizmos"),sa=8947848,na=class{constructor(){}static isGizmo(i){return i[GK]!==void 0}static DrawLabel(i,A,e=.05,g=0,I,o,s){var n;if(!na.enabled)return null;I||(I=sa);const a=((n=me.active)==null?void 0:n.rigScale)??1,r=Ki.getTextLabel(g,A,e*a,I,o);return s instanceof wA&&s.add(r),r.position.x=i.x,r.position.y=i.y,r.position.z=i.z,r}static DrawRay(i,A,e=sa,g=0,I=!0){if(!na.enabled)return;const o=Ki.getLine(g),s=o.geometry.getAttribute("position");s.setXYZ(0,i.x,i.y,i.z),Io.set(A.x,A.y,A.z).multiplyScalar(999999999),s.setXYZ(1,i.x+Io.x,i.y+Io.y,i.z+Io.z),s.needsUpdate=!0,o.material.color.set(e),o.material.depthTest=I,o.material.depthWrite=!1}static DrawDirection(i,A,e=sa,g=0,I=!0,o=1){if(!na.enabled)return;const s=Ki.getLine(g),n=s.geometry.getAttribute("position");n.setXYZ(0,i.x,i.y,i.z),A.w!==void 0?(Io.set(0,0,-o),m4.set(A.x,A.y,A.z,A.w),Io.applyQuaternion(m4)):(Io.set(A.x,A.y,A.z),Io.multiplyScalar(o)),n.setXYZ(1,i.x+Io.x,i.y+Io.y,i.z+Io.z),n.needsUpdate=!0,s.material.color.set(e),s.material.depthTest=I,s.material.depthWrite=!1}static DrawLine(i,A,e=sa,g=0,I=!0){if(!na.enabled)return;const o=Ki.getLine(g),s=o.geometry.getAttribute("position");s.setXYZ(0,i.x,i.y,i.z),s.setXYZ(1,A.x,A.y,A.z),s.needsUpdate=!0,o.material.color.set(e),o.material.depthTest=I,o.material.depthWrite=!1,o.material.fog=!1}static DrawWireSphere(i,A,e=sa,g=0,I=!0){if(!na.enabled)return;const o=Ki.getSphere(A,g,!0);TQ(o,i.x,i.y,i.z),o.material.color.set(e),o.material.depthTest=I,o.material.depthWrite=!1,o.material.fog=!1}static DrawSphere(i,A,e=sa,g=0,I=!0){if(!na.enabled)return;const o=Ki.getSphere(A,g,!1);TQ(o,i.x,i.y,i.z),o.material.color.set(e),o.material.depthTest=I,o.material.depthWrite=!1}static DrawWireBox(i,A,e=sa,g=0,I=!0){if(!na.enabled)return;const o=Ki.getBox(g);o.position.set(i.x,i.y,i.z),o.scale.set(A.x,A.y,A.z),o.material.color.set(e),o.material.depthTest=I,o.material.wireframe=!0,o.material.depthWrite=!1,o.material.fog=!1}static DrawWireBox3(i,A=sa,e=0,g=!0){if(!na.enabled)return;const I=Ki.getBox(e);I.position.copy(i.getCenter(Io)),I.scale.copy(i.getSize(Io)),I.material.color.set(A),I.material.depthTest=g,I.material.wireframe=!0,I.material.depthWrite=!1,I.material.fog=!1}static DrawArrow(i,A,e=sa,g=0,I=!0,o=!1){if(!na.enabled)return;const s=Ki.getArrowHead(g);s.position.set(A.x,A.y,A.z),s.quaternion.setFromUnitVectors(this._up.set(0,1,0),Io.set(A.x,A.y,A.z).sub(y4.set(i.x,i.y,i.z)).normalize());const n=Io.set(A.x,A.y,A.z).sub(y4.set(i.x,i.y,i.z)).length()*.1;s.scale.set(n,n,n),s.material.color.set(e),s.material.depthTest=I,s.material.wireframe=o,this.DrawLine(i,A,e,g,I)}static DrawWireMesh(i){const A=Ki.getMesh(i.duration??0);"mesh"in i?(A.geometry=i.mesh.geometry,A.matrix.copy(i.mesh.matrixWorld)):(A.geometry=i.geometry,A.matrix.copy(i.matrix)),A.matrixAutoUpdate=!1,A.matrixWorldAutoUpdate=!1,A.material.color.set(i.color??sa),A.material.depthTest=i.depthTest??!0,A.material.wireframe=!0}};let pe=na;B(pe,"enabled",!0),B(pe,"_up",new S(0,1,0));const XBA=new Ai(1,1,1);function MK(i=null){const A=new fA(i??14540253),e=new EU(XBA);return new kI(e,new Zt({color:A}))}const GK=Symbol("GizmoCache");class Ki{static ensureFont(){let A=Ot.FontLibrary.getFontFamily(this.familyName);if(!A){A=Ot.FontLibrary.addFontFamily(this.familyName);const e=A.addVariant("normal","normal","https://uploads.needle.tools/include/font-msdf.json","https://uploads.needle.tools/include/font.png");e?.addEventListener("ready",()=>{Ot.update()})}}static getTextLabel(A,e,g,I,o){this.ensureFont();let s=this.textLabelCache.pop(),n=1;o&&typeof o=="string"&&o?.length>=8&&o.startsWith("#")?(n=parseInt(o.substring(7),16)/255,o=o.substring(0,7),VBA&&console.log(o,n)):typeof o=="object"&&o.a!==void 0&&(n=o.a);const a={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:g,color:I,lineHeight:1,backgroundColor:o??void 0,backgroundOpacity:n,textContent:e,borderRadius:.5*g,padding:.8*g,whiteSpace:"pre"};if(s)s.set(a);else{s=new MN(a);const r=this,C=s;C.setText=function(Q){this.set({textContent:Q}),r.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(Ke.Current,s,A,this.textLabelCache),s}static getBox(A){let e=this.boxesCache.pop();if(!e){const g=new Ai(1,1,1);e=new dA(g)}return this.registerTimedObject(Ke.Current,e,A,this.boxesCache),e}static getLine(A){let e=this.linesCache.pop();if(!e){e=new Fi;let g=e.geometry.getAttribute("position");g||(g=new Ie(new Float32Array(2*3),3),e.geometry.setAttribute("position",g))}return e.frustumCulled=!1,this.registerTimedObject(Ke.Current,e,A,this.linesCache),e}static getSphere(A,e,g){let I=this.spheresCache.pop();return I||(I=new dA(new Vs(1,8,8))),I.scale.set(A,A,A),I.material.wireframe=g,this.registerTimedObject(Ke.Current,I,e,this.spheresCache),I}static getArrowHead(A){let e=this.arrowHeadsCache.pop();return e||(e=new dA(new Xi(0,.5,1,8))),this.registerTimedObject(Ke.Current,e,A,this.arrowHeadsCache),e}static getMesh(A){let e=this.mesh.pop();return e||(e=new dA,e.material=new tt),this.registerTimedObject(Ke.Current,e,A,this.mesh),e}static registerTimedObject(A,e,g,I){const o=this.contextBeforeRenderCallbacks.get(A),s=this.contextPostRenderCallbacks.get(A);if(o){if(A.pre_render_callbacks[A.pre_render_callbacks.length-1]!==o){const n=A.pre_render_callbacks.indexOf(o);n>=0&&A.pre_render_callbacks.splice(n,1),A.pre_render_callbacks.push(o)}}else{const n=()=>{this.onBeforeRender(A,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(A,n),A.pre_render_callbacks.push(n)}if(s){if(A.post_render_callbacks[A.post_render_callbacks.length-1]!==s){const n=A.post_render_callbacks.indexOf(s);n>=0&&A.post_render_callbacks.splice(n,1),A.post_render_callbacks.push(s)}}else{const n=()=>{this.onPostRender(A,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(A,n),A.post_render_callbacks.push(n)}e.traverse(n=>{n.layers.disableAll(),n.layers.enable(2)}),e.renderOrder=999999,e[GK]=I,e.isGizmo=!0,this.timedObjectsBuffer.push(e),g<=0&&A.currentFrameEvent>=Xt.OnBeforeRender?this.timesBuffer.push(0):this.timesBuffer.push(Ke.Current.time.realtimeSinceStartup+g),A.scene.add(e)}static onBeforeRender(A,e){this.tmuiNeedsUpdate&&Ot.update();for(let g=0;g<e.length;g++){const I=e[g];if(A.mainCamera&&I instanceof Ot.MeshUIBaseElement){if(lh(I))continue;const o=A.isInVR,s=!1,n=!o;Su(I,A.mainCamera,s,n)}}}static onPostRender(A,e,g){const I=A.time.realtimeSinceStartup;for(let o=e.length-1;o>=0;o--){const s=e[o];I>g[o]&&(e.splice(o,1),g.splice(o,1),s.removeFromParent(),lh(s)!=!0&&s[GK].push(s))}}}B(Ki,"familyName","needle-gizmos"),B(Ki,"linesCache",[]),B(Ki,"spheresCache",[]),B(Ki,"boxesCache",[]),B(Ki,"arrowHeadsCache",[]),B(Ki,"mesh",[]),B(Ki,"textLabelCache",[]),B(Ki,"timedObjectsBuffer",new Array),B(Ki,"timesBuffer",new Array),B(Ki,"contextPostRenderCallbacks",new Map),B(Ki,"contextBeforeRenderCallbacks",new Map),B(Ki,"tmuiNeedsUpdate",!1);const Dg=iA("debuginput");var bS=(i=>(i.Mouse="mouse",i.Touch="touch",i.Controller="controller",i.Hand="hand",i))(bS||{}),hi=(i=>(i.PointerDown="pointerdown",i.PointerUp="pointerup",i.PointerMove="pointermove",i.KeyDown="keydown",i.KeyUp="keyup",i.KeyPressed="keypress",i))(hi||{});class Gr extends PointerEvent{constructor(A,e,g){super(A,g),B(this,"deviceIndex"),B(this,"origin"),B(this,"source"),B(this,"mode"),B(this,"_ray"),B(this,"space"),B(this,"isClick",!1),B(this,"isDoubleClick",!1),B(this,"_used",!1),B(this,"_pointerid"),B(this,"_pointerType"),B(this,"_type"),B(this,"metadata",{}),B(this,"intersections",new Array),B(this,"_immediatePropagationStopped",!1),B(this,"_propagationStopped",!1),this._pointerid=g.pointerId,this._pointerType=g.pointerType,this._type=A,this.deviceIndex=g.deviceIndex,this.origin=g.origin,this.source=e,this.mode=g.mode,this._ray=g.ray,this.space=g.device}get ray(){return this._ray||(this._ray=new po(this.space.worldPosition.clone(),this.space.worldForward.clone())),this._ray}set ray(A){this._ray=A}get hasRay(){return this._ray!==void 0}get used(){return this._used}use(){this._used=!0}get pointerId(){return this._pointerid}get pointerType(){return this._pointerType}get type(){return this._type}get immediatePropagationStopped(){return this._immediatePropagationStopped}get propagationStopped(){return this._immediatePropagationStopped||this._propagationStopped}stopImmediatePropagation(){var A;this._immediatePropagationStopped=!0,super.stopImmediatePropagation(),(A=this.source)==null||A.stopImmediatePropagation()}stopPropagation(){var A;this._propagationStopped=!0,super.stopPropagation(),(A=this.source)==null||A.stopPropagation(),Dg&&console.warn("Stop propagation...",this.pointerId,this.pointerType)}}class kp extends KeyboardEvent{constructor(A,e,g){super(A,g),B(this,"source"),this.source=e}stopImmediatePropagation(){var A;super.stopImmediatePropagation(),(A=this.source)==null||A.stopImmediatePropagation()}}class $BA{constructor(A){B(this,"key"),B(this,"keyType"),B(this,"source"),this.key=A.key,this.keyType=A.type,this.source=A}}var aa=(i=>(i[i.Early=-100]="Early",i[i.Default=0]="Default",i[i.Late=100]="Late",i))(aa||{});class S4{constructor(A){B(this,"_eventListeners",{}),B(this,"_doubleClickTimeThreshold",.2),B(this,"_longPressTimeThreshold",1),B(this,"_specialCursorTrigger",0),B(this,"context"),B(this,"_pointerDown",[!1]),B(this,"_pointerUp",[!1]),B(this,"_pointerClick",[!1]),B(this,"_pointerDoubleClick",[!1]),B(this,"_pointerPressed",[!1]),B(this,"_pointerPositions",[new AA]),B(this,"_pointerPositionsLastFrame",[new AA]),B(this,"_pointerPositionsDelta",[new AA]),B(this,"_pointerPositionsRC",[new AA]),B(this,"_pointerPositionDown",[new AA]),B(this,"_pointerDownTime",[]),B(this,"_pointerUpTime",[]),B(this,"_pointerUpTimestamp",[]),B(this,"_pointerIds",[]),B(this,"_pointerTypes",[""]),B(this,"_mouseWheelChanged",[!1]),B(this,"_mouseWheelDeltaY",[0]),B(this,"_pointerEvent",[]),B(this,"_pointerUsed",[]),B(this,"_pointerSpace",[]),B(this,"_pressedStack",new Map),B(this,"_htmlEventSource"),B(this,"onLostFocus",()=>{for(const e in this.keysPressed)this.keysPressed[e].pressed=!1}),B(this,"onEndOfFrame",()=>{for(let e=0;e<this._pointerUp.length;e++)this._pointerUp[e]=!1;for(let e=0;e<this._pointerDown.length;e++)this._pointerDown[e]=!1;for(let e=0;e<this._pointerClick.length;e++)this._pointerClick[e]=!1;for(let e=0;e<this._pointerDoubleClick.length;e++)this._pointerDoubleClick[e]=!1;for(const e of this._pointerPositionsDelta)e.set(0,0);for(let e=0;e<this._mouseWheelChanged.length;e++)this._mouseWheelChanged[e]=!1;for(let e=0;e<this._mouseWheelDeltaY.length;e++)this._mouseWheelDeltaY[e]=0}),B(this,"onContextMenu",e=>{this.canReceiveInput(e)!==!1&&e instanceof PointerEvent&&e.pointerType}),B(this,"keysPressed",{}),B(this,"onKeyDown",e=>{if(Dg&&console.log(`key down ${e.code}, ${this.context.application.hasFocus}`,e),!this.context.application.hasFocus)return;const g=this.keysPressed[e.code];if(g&&g.pressed)return;this.keysPressed[e.code]={pressed:!0,frame:this.context.time.frameCount+1,startFrame:this.context.time.frameCount+1,key:e.key,code:e.code};const I=new kp("keydown",e,e);this.onDispatchEvent(I)}),B(this,"onKeyPressed",e=>{if(!this.context.application.hasFocus)return;const g=this.keysPressed[e.code];if(!g)return;g.pressed=!0,g.frame=this.context.time.frameCount+1;const I=new kp("keypress",e,e);this.onDispatchEvent(I)}),B(this,"onKeyUp",e=>{if(!this.context.application.hasFocus)return;const g=this.keysPressed[e.code];if(!g)return;g.pressed=!1,g.frame=this.context.time.frameCount+1;const I=new kp("keyup",e,e);this.onDispatchEvent(I)}),B(this,"onWheelWindow",e=>{document.pointerLockElement&&this.onMouseWheel(e)}),B(this,"onMouseWheel",e=>{if(this.canReceiveInput(e)===!1)return;this._mouseWheelDeltaY.length<=0&&this._mouseWheelDeltaY.push(0),this._mouseWheelChanged.length<=0&&this._mouseWheelChanged.push(!1),this._mouseWheelChanged[0]=!0;const g=this._mouseWheelDeltaY[0];this._mouseWheelDeltaY[0]=g+e.deltaY}),B(this,"onPointerDown",e=>{if(this.context.isInAR||this.canReceiveInput(e)===!1)return;e.target instanceof HTMLElement&&e.target.setPointerCapture(e.pointerId);const g=this.getPointerId(e);Dg&&Ci(`pointer down #${g}, identifier:${e.pointerId}`);const I=this.getAndUpdateSpatialObjectForScreenPosition(g,e.clientX,e.clientY),o=new Gr("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:g,button:e.button,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:I,pressure:e.pressure});this.onDown(o)}),B(this,"onPointerMove",e=>{if(this.context.isInAR)return;let g=e.button;e.pointerType==="mouse"&&(g=this.getFirstPressedButtonForPointer(0)??0);const I=this.getPointerId(e,g);g===-1&&(g=I);const o=this.getAndUpdateSpatialObjectForScreenPosition(I,e.clientX,e.clientY),s=new Gr("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:I,button:g,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:o,pressure:e.pressure});this.onMove(s)}),B(this,"onPointerCancel",e=>{this.context.isInAR||(Dg&&console.log("Pointer cancel",e),this.onPointerUp(e))}),B(this,"onPointerUp",e=>{if(this.context.isInAR)return;e.target instanceof HTMLElement&&e.target.releasePointerCapture(e.pointerId);const g=this.getPointerId(e),I=new Gr("pointerup",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:g,button:e.button,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:this.getAndUpdateSpatialObjectForScreenPosition(g,e.clientX,e.clientY),pressure:e.pressure});this.onUp(I),this._pointerIds[g]=-1,Dg&&console.log("ID="+g,"PointerId="+e.pointerId,"ALL:",[...this._pointerIds])}),B(this,"onTouchStart",e=>{if(this.context.isInAR)for(let g=0;g<e.changedTouches.length;g++){const I=e.changedTouches[g],o=this.getPointerIndex(I.identifier),s=this.getAndUpdateSpatialObjectForScreenPosition(o,I.clientX,I.clientY),n=new Gr("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:o,button:0,clientX:I.clientX,clientY:I.clientY,pointerType:"touch",buttonName:"unknown",device:s,pressure:I.force});this.onDown(n)}}),B(this,"onTouchMove",e=>{if(this.context.isInAR)for(let g=0;g<e.changedTouches.length;g++){const I=e.changedTouches[g],o=this.getPointerIndex(I.identifier),s=this.getAndUpdateSpatialObjectForScreenPosition(o,I.clientX,I.clientY),n=new Gr("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:o,button:0,clientX:I.clientX,clientY:I.clientY,pointerType:"touch",buttonName:"unknown",device:s,pressure:I.force});this.onMove(n)}}),B(this,"onTouchEnd",e=>{if(this.context.isInAR)for(let g=0;g<e.changedTouches.length;g++){const I=e.changedTouches[g],o=this.getPointerIndex(I.identifier),s=new Gr("pointerup",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:o,button:0,clientX:I.clientX,clientY:I.clientY,pointerType:"touch",buttonName:"unknown",device:this.getAndUpdateSpatialObjectForScreenPosition(o,I.clientX,I.clientY),pressure:I.force});this.onUp(s),this._pointerIds[o]=-1}}),B(this,"tempNearPlaneVector",new S),B(this,"tempFarPlaneVector",new S),B(this,"tempLookMatrix",new DA),this.context=A,this.context.post_render_callbacks.push(this.onEndOfFrame)}addEventListener(A,e,g){if(this._eventListeners[A]||(this._eventListeners[A]=[]),!e||typeof e!="function"){console.error("Invalid call to addEventListener: callback is required and must be a function!");return}g?g={...g}:g={};let I=0;g?.queue!=null&&(I=g.queue);const o=this._eventListeners[A],s=o.find(n=>n.priority===I);s?s.listeners.push({callback:e,options:g}):(o.push({priority:I,listeners:[{callback:e,options:g}]}),o.sort((n,a)=>n.priority-a.priority))}removeEventListener(A,e,g){if(!this._eventListeners[A]||!e)return;const I=this._eventListeners[A];if(g?.queue!=null){const o=I.find(n=>n.priority===g.queue);if(!o)return;const s=o.listeners.findIndex(n=>n.callback===e);s>=0&&o.listeners.splice(s,1)}else for(const o of I){const s=o.listeners.findIndex(n=>n.callback===e);s>=0&&o.listeners.splice(s,1)}}dispatchEvent(A){var e,g,I,o;let s=!1;if(A instanceof kp){const n=this._eventListeners[A.type];if(n)for(const a of n)for(let r=0;r<a.listeners.length;r++){const C=a.listeners[r];if((g=(e=C.options)==null?void 0:e.signal)!=null&&g.aborted){a.listeners.splice(r,1),r--;continue}C.options.once&&(a.listeners.splice(r,1),r--),C.callback(A)}}if(A instanceof Gr){const n=this._eventListeners[A.type];if(n)for(const a of n){if(s)break;for(let r=0;r<a.listeners.length;r++){const C=a.listeners[r];if((o=(I=C.options)==null?void 0:I.signal)!=null&&o.aborted){a.listeners.splice(r,1),r--;continue}if(A.immediatePropagationStopped){s=!0,Dg&&console.log("immediatePropagationStopped",A.type);break}else A.propagationStopped&&(s=!0,Dg&&console.log("propagationStopped",A.type));C.options.once&&(a.listeners.splice(r,1),r--),C.callback(A)}}}}get mousePosition(){return this._pointerPositions[0]}get mousePositionRC(){return this._pointerPositionsRC[0]}get mouseDown(){return this._pointerDown[0]}get mouseUp(){return this._pointerUp[0]}get mouseClick(){return this._pointerClick[0]}get mouseDoubleClick(){return this._pointerDoubleClick[0]}get mousePressed(){return this._pointerPressed[0]}get mouseWheelChanged(){return this.getMouseWheelChanged(0)}setCursorPointer(){this._specialCursorTrigger+=1,this.context.domElement.style.cursor="pointer"}setCursorNormal(){this._specialCursorTrigger-=1,this._specialCursorTrigger=Math.max(0,this._specialCursorTrigger),this._specialCursorTrigger===0&&(this.context.domElement.style.cursor="default")}setPointerUsed(A,e=!0){if(A>=this._pointerUsed.length){if(A>=this._pointerIds.length)return;for(;this._pointerUsed.length<=A;)this._pointerUsed.push(!1)}this._pointerUsed[A]=e}getPointerUsed(A){return A>=this._pointerUsed.length?!1:this._pointerUsed[A]}getPointerPressedCount(){let A=0;for(let e=0;e<this._pointerPressed.length;e++)this._pointerPressed[e]&&A++;return A}getPointerPosition(A){return A>=this._pointerPositions.length?null:this._pointerPositions[A]}getPointerPositionLastFrame(A){return A>=this._pointerPositionsLastFrame.length?null:this._pointerPositionsLastFrame[A]}getPointerPositionDelta(A){return A>=this._pointerPositionsDelta.length?null:this._pointerPositionsDelta[A]}getPointerPositionRC(A){return A>=this._pointerPositionsRC.length?null:this._pointerPositionsRC[A]}getPointerDown(A){return A>=this._pointerDown.length?!1:this._pointerDown[A]}getPointerUp(A){return A>=this._pointerUp.length?!1:this._pointerUp[A]}getPointerPressed(A){return A>=this._pointerPressed.length?!1:this._pointerPressed[A]}getPointerClicked(A){return A>=this._pointerClick.length?!1:this._pointerClick[A]}getPointerDoubleClicked(A){return A>=this._pointerDoubleClick.length?!1:this._pointerDoubleClick[A]}getPointerDownTime(A){return A>=this._pointerDownTime.length?-1:this._pointerDownTime[A]}getPointerUpTime(A){return A>=this._pointerUpTime.length?-1:this._pointerUpTime[A]}getPointerLongPress(A){return A>=this._pointerDownTime.length?!1:this.getPointerPressed(A)&&this.context.time.time-this._pointerDownTime[A]>this._longPressTimeThreshold}getIsMouse(A){return A<0||A>=this._pointerTypes.length?!1:this._pointerTypes[A]==="mouse"}getIsTouch(A){return A<0||A>=this._pointerTypes.length?!1:this._pointerTypes[A]==="touch"}getTouchesPressedCount(){let A=0;for(let e=0;e<this._pointerPressed.length;e++)this._pointerPressed[e]&&this.getIsTouch(e)&&A++;return A}getMouseWheelChanged(A=0){return A>=this._mouseWheelChanged.length?!1:this._mouseWheelChanged[A]}getMouseWheelDeltaY(A=0){return A>=this._mouseWheelDeltaY.length?0:this._mouseWheelDeltaY[A]}getPointerEvent(A){if(!(A>=this._pointerEvent.length))return this._pointerEvent[A]??void 0}*foreachPointerId(A){for(let e=0;e<this._pointerTypes.length;e++)if(this._pointerIsActive(e)){if(A!==void 0){const g=this._pointerTypes[e];if(Array.isArray(A)){let I=!1;for(const o of A)if(g===o){I=!0;break}if(!I)continue}else if(A!==g)continue}yield e}}*foreachTouchId(){for(let A=0;A<this._pointerTypes.length;A++)this._pointerTypes[A]==="touch"&&this._pointerIsActive[A]&&(yield A)}_pointerIsActive(A){return A<0?!1:this._pointerPressed[A]||this._pointerDown[A]||this._pointerUp[A]}onDownButton(A,e){let g=this._pressedStack.get(A);g||(g=[],this._pressedStack.set(A,g)),g.push(e)}onReleaseButton(A,e){const g=this._pressedStack.get(A);if(!g)return;const I=g.indexOf(e);I>=0&&g.splice(I,1)}getFirstPressedButtonForPointer(A){const e=this._pressedStack.get(A);if(e)return e[0]}getLatestPressedButtonForPointer(A){const e=this._pressedStack.get(A);if(e)return e[e.length-1]}getKeyDown(){for(const A in this.keysPressed){const e=this.keysPressed[A];if(e.startFrame===this.context.time.frameCount)return e.key}return null}getKeyPressed(){for(const A in this.keysPressed){const e=this.keysPressed[A];if(e.pressed)return e.key}return null}isKeyDown(A){var e;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const g=this.getCodeForCommonKeyName(A);if(g!==null){for(const I of g)if(this.isKeyDown(I))return!0;return!1}return((e=this.keysPressed[A])==null?void 0:e.startFrame)===this.context.time.frameCount&&this.keysPressed[A].pressed}isKeyUp(A){var e;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const g=this.getCodeForCommonKeyName(A);if(g!==null){for(const I of g)if(this.isKeyUp(I))return!0;return!1}return((e=this.keysPressed[A])==null?void 0:e.frame)===this.context.time.frameCount&&!this.keysPressed[A].pressed}isKeyPressed(A){var e;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const g=this.getCodeForCommonKeyName(A);if(g!==null){for(const I of g)if(this.isKeyPressed(I))return!0;return!1}return(e=this.keysPressed[A])==null?void 0:e.pressed}getCodeForCommonKeyName(A){if(A.length===1){if(A>="0"&&A<="9")return["Digit"+A];if(A>="a"&&A<="z")return["Key"+A.toUpperCase()];if(A==" ")return["Space"]}switch(A){case"shift":case"Shift":return["ShiftLeft","ShiftRight"];case"control":case"Control":return["ControlLeft","ControlRight"];case"alt":case"Alt":return["AltLeft","AltRight"]}return null}createInputEvent(A){switch(A.type){case"pointerdown":Dg&&Ci("Create Pointer down"),this.onDownButton(A.deviceIndex,A.button),this.onDown(A);break;case"pointermove":Dg&&Ci("Create Pointer move"),this.onMove(A);break;case"pointerup":Dg&&Ci("Create Pointer up"),this.onUp(A),this.onReleaseButton(A.deviceIndex,A.button);break}}convertScreenspaceToRaycastSpace(A){return A.x=(A.x-this.context.domX)/this.context.domWidth*2-1,A.y=-((A.y-this.context.domY)/this.context.domHeight)*2+1,A}bindEvents(){this.unbindEvents(),this._htmlEventSource=this.context.renderer.domElement,window.addEventListener("contextmenu",this.onContextMenu),this._htmlEventSource.addEventListener("pointerdown",this.onPointerDown,{passive:!0}),window.addEventListener("pointermove",this.onPointerMove,{passive:!0,capture:!0}),window.addEventListener("pointerup",this.onPointerUp,{passive:!0}),window.addEventListener("pointercancel",this.onPointerCancel,{passive:!0}),window.addEventListener("touchstart",this.onTouchStart,{passive:!0}),window.addEventListener("touchmove",this.onTouchMove,{passive:!0}),window.addEventListener("touchend",this.onTouchEnd,{passive:!0}),this._htmlEventSource.addEventListener("wheel",this.onMouseWheel,{passive:!0}),window.addEventListener("wheel",this.onWheelWindow,{passive:!0}),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keypress",this.onKeyPressed,!1),window.addEventListener("keyup",this.onKeyUp,!1),window.addEventListener("blur",this.onLostFocus)}unbindEvents(){var A,e;window.removeEventListener("contextmenu",this.onContextMenu),(A=this._htmlEventSource)==null||A.removeEventListener("pointerdown",this.onPointerDown),window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerCancel),(e=this._htmlEventSource)==null||e.removeEventListener("wheel",this.onMouseWheel,!1),window.removeEventListener("wheel",this.onWheelWindow,!1),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keypress",this.onKeyPressed,!1),window.removeEventListener("keyup",this.onKeyUp,!1),window.removeEventListener("blur",this.onLostFocus)}dispose(){const A=this.context.post_render_callbacks.indexOf(this.onEndOfFrame);A>=0&&this.context.post_render_callbacks.splice(A,1),this.unbindEvents()}canReceiveInput(A){var e;return A.target===((e=this.context.renderer)==null?void 0:e.domElement)||A.target===this.context.domElement||this.context.isInAR||this.context.isInAR&&A.target===document.body&&JQ()?!0:(Dg&&console.warn("CanReceiveInput:False for",A.target),!1)}getPointerId(A,e){return A.pointerType==="mouse"?0+(e??A.button):this.getPointerIndex(A.pointerId)}getButtonName(A){const e=A.button;if(A.pointerType==="mouse")switch(e){case 0:return"left";case 1:return"middle";case 2:return"right"}return"unknown"}getAndUpdateSpatialObjectForScreenPosition(A,e,g){let I=this._pointerSpace[A];I||(I=new wA,this._pointerSpace[A]=I),this._pointerSpace[A]=I;const o=this.context.mainCamera;if(o){const s=this.tempNearPlaneVector.set(e,g,-1);this.convertScreenspaceToRaycastSpace(s);const n=this.tempFarPlaneVector.set(s.x,s.y,1);s.unproject(o),n.unproject(o);const a=o.worldUp||lt(0,1,0).applyQuaternion(Nt(o));this.tempLookMatrix.lookAt(n,s,a),I.position.set(s.x,s.y,s.z),I.quaternion.setFromRotationMatrix(this.tempLookMatrix)}return I}isInRect(A){if(this.context.isInXR)return!0;const e=this.context.domElement.getBoundingClientRect(),g=A.clientX,I=A.clientY,o=g>=e.x&&g<=e.right&&I>=e.y&&I<=e.bottom;return Dg&&!o&&console.log("Not in rect",e,g,I),o}onDown(A){const e=A.pointerId;if(this.getPointerPressed(e)&&console.warn(`pointerId is already pressed: ${e}`,Dg?A:""),Dg&&console.log(A.pointerType,"DOWN",e),!!this.isInRect(A)){for(this.setPointerState(e,this._pointerPressed,!0),this.setPointerState(e,this._pointerDown,!0),this.setPointerStateT(e,this._pointerEvent,A.source);e>=this._pointerTypes.length;)this._pointerTypes.push(A.pointerType);for(this._pointerTypes[e]=A.pointerType;e>=this._pointerPositionDown.length;)this._pointerPositionDown.push(new AA);for(this._pointerPositionDown[e].set(A.clientX,A.clientY);e>=this._pointerPositions.length;)this._pointerPositions.push(new AA);this._pointerPositions[e].set(A.clientX,A.clientY),e>=this._pointerDownTime.length&&this._pointerDownTime.push(0),this._pointerDownTime[e]=this.context.time.time,this.updatePointerPosition(A),this.onDispatchEvent(A)}}onMove(A){const e=A.pointerId,g=this.getPointerPressed(e);g===!1&&!this.isInRect(A)||A.pointerType==="touch"&&!g||(this.updatePointerPosition(A),this.setPointerStateT(e,this._pointerEvent,A.source),this.onDispatchEvent(A))}onUp(A){const e=A.pointerId;if(!this.getPointerPressed(e)){Dg&&console.log(A.pointerType,"UP",e,"was not down");return}for(Dg&&console.log(A.pointerType,"UP",e),this.setPointerState(e,this._pointerPressed,!1),this.setPointerStateT(e,this._pointerEvent,A.source),this.setPointerState(e,this._pointerUp,!0);e>=this._pointerUsed.length;)this._pointerUsed.push(!1);if(this.setPointerState(e,this._pointerUsed,!1),this.updatePointerPosition(A),!this._pointerPositionDown[e]){Dg&&Lt("Received pointer up event without matching down event for button: "+e),console.warn("Received pointer up event without matching down event for button: "+e);return}const g=A.clientX-this._pointerPositionDown[e].x,I=A.clientY-this._pointerPositionDown[e].y;if(e>=this._pointerUpTime.length&&this._pointerUpTime.push(-99),Math.abs(g)<5&&Math.abs(I)<5){Dg&&console.log("CLICK",e),this.setPointerState(e,this._pointerClick,!0),A.isClick=!0;const o=this._pointerUpTime[e],s=this.context.time.time-o;s<this._doubleClickTimeThreshold&&s>0&&(this.setPointerState(e,this._pointerDoubleClick,!0),A.isDoubleClick=!0)}this._pointerUpTime[e]=this.context.time.time,this.onDispatchEvent(A)}updatePointerPosition(A){const e=A.pointerId;for(;e>=this._pointerPositions.length;)this._pointerPositions.push(new AA);for(;e>=this._pointerPositionsLastFrame.length;)this._pointerPositionsLastFrame.push(new AA);for(;e>=this._pointerPositionsDelta.length;)this._pointerPositionsDelta.push(new AA);const g=this._pointerPositionsLastFrame[e];g.copy(this._pointerPositions[e]);const I=this._pointerPositionsDelta[e];let o=A.clientX-g.x,s=A.clientY-g.y;if(A.source instanceof MouseEvent||A.source instanceof TouchEvent){const C=A.source;o===0&&C.movementX!==0&&(o=C.movementX||0),s===0&&C.movementY!==0&&(s=C.movementY||0)}I.x+=o,I.y+=s,this._pointerPositions[e].x=A.clientX,this._pointerPositions[e].y=A.clientY;const n=A.clientX,a=A.clientY;for(;e>=this._pointerPositionsRC.length;)this._pointerPositionsRC.push(new AA);const r=this._pointerPositionsRC[e];r.set(n,a),this.convertScreenspaceToRaycastSpace(r)}getPointerIndex(A){let e=-1;for(let g=0;g<this._pointerIds.length;g++){if(this._pointerIds[g]===A)return g;e===-1&&this._pointerIds[g]===-1&&(e=g)}return e!==-1?(this._pointerIds[e]=A,e):(Dg&&console.log("PUSH pointerId:",A),this._pointerIds.push(A),this._pointerIds.length-1)}setPointerState(A,e,g){e[A]=g}setPointerStateT(A,e,g){return e[A]=g,g}onDispatchEvent(A){const e=Ke.Current;try{Ke.Current=this.context,this.dispatchEvent(A)}finally{Ke.Current=e}}}const JS=new DA().makeRotationY(Math.PI),vs=new GA().setFromAxisAngle(new S(0,1,0),Math.PI),AQA=iA("debugwebxr");class eQA{constructor(){if(B(this,"priority",-1e5),B(this,"gameObject"),this.gameObject=new wA,this.gameObject.name="Implicit XR Rig",AQA){const A=MK(16733661);A.position.y+=.5,this.gameObject.add(A)}}isXRRig(){return!0}get isActive(){return this.gameObject.visible}}const iB=iA("debugwebxr"),xS=iA("debugcustomgesture"),tQA="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",iQA="generic-trigger";class RK{constructor(A,e,g){B(this,"xr"),B(this,"inputSource"),B(this,"index",0),B(this,"emitEvents",!0),B(this,"_connected",!0),B(this,"_isTracking",!1),B(this,"_hitTestSource"),B(this,"_hasSelectEvent",!1),B(this,"_handJointPoses",new Map),B(this,"_gripPosition",new S),B(this,"_gripQuaternion",new GA),B(this,"_linearVelocity",new S),B(this,"_rayPosition",new S),B(this,"_rayQuaternion",new GA),B(this,"_gripWorldPosition",new S),B(this,"_gripWorldQuaternion",new GA),B(this,"_rayWorldPosition",new S),B(this,"_rayWorldQuaternion",new GA),B(this,"_ray"),B(this,"_object"),B(this,"model",null),B(this,"_debugAxesHelper",new _o(.2)),B(this,"onPointerHits",n=>{}),B(this,"_needleGamepadButtons",{}),B(this,"_buttonMap",new Map),B(this,"_motioncontroller"),B(this,"_layout"),B(this,"getMotionController"),B(this,"_selectButtonIndex"),B(this,"_squeezeButtonIndex"),B(this,"onSelectStart",n=>{var a,r,C,Q;if(this.inputSource!==n.inputSource)return;this.onUpdateFrame(n.frame),this._hasSelectEvent=!0;const h=(a=this._layout)==null?void 0:a.selectComponentId,E=(Q=(C=(r=this._layout)==null?void 0:r.components[h])==null?void 0:C.gamepadIndices)==null?void 0:Q.button;E!==void 0&&(this._selectButtonIndex=E),!xS&&(iB&&pe.DrawDirection(this.rayWorldPosition,lt(0,.01,1).applyQuaternion(this.rayWorldQuaternion),16711680,10),this.emitPointerEvent(hi.PointerDown,this._selectButtonIndex||0,"xr-standard-trigger",!0,n))}),B(this,"onSelectEnd",n=>{xS||this.inputSource===n.inputSource&&this.emitPointerEvent(hi.PointerUp,this._selectButtonIndex||0,"xr-standard-trigger",!0,n)}),B(this,"onSequeezeStart",n=>{var a,r,C;this.inputSource===n.inputSource&&(this._squeezeButtonIndex=(C=(r=(a=this._layout)==null?void 0:a.components["xr-standard-squeeze"])==null?void 0:r.gamepadIndices)==null?void 0:C.button,this._squeezeButtonIndex!==void 0&&(iB&&pe.DrawDirection(this.rayWorldPosition,lt(0,.01,1).applyQuaternion(this.rayWorldQuaternion),255,10),this.emitPointerEvent(hi.PointerDown,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,n)))}),B(this,"onSequeezeEnd",n=>{this.inputSource===n.inputSource&&this._squeezeButtonIndex!==void 0&&this.emitPointerEvent(hi.PointerUp,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,n)}),B(this,"states",{}),B(this,"_didMoveLastFrame",!1),B(this,"_lastPointerMovePosition",new S),B(this,"_lastPointerMoveQuaternion",new GA),B(this,"pointerInit");var I,o,s;this.xr=A,this.inputSource=e,this.index=g,this._object=new wA,iB&&this._object.add(this._debugAxesHelper),this.xr.context.scene.add(this._object),this._ray=new po,this.pointerInit={origin:this,pointerType:this.hand?"hand":"controller",deviceIndex:this.index,pointerId:-1,mode:this.inputSource.targetRayMode,ray:this._ray,device:this._object,buttonName:"none"},this.initialize(),this.subscribeEvents(),this.xr.mode==="immersive-ar"&&this.inputSource.targetRayMode==="tracked-pointer"&&((s=(o=(I=this.xr.session).requestHitTestSourceForTransientInput)==null?void 0:o.call(I,{profile:this.inputSource.profiles[0],offsetRay:new XRRay}))==null||s.then(n=>this._hitTestSource=n))}get context(){return this.xr.context}get connected(){return this._connected}get isTracking(){return this._isTracking}get gamepad(){return this.inputSource.gamepad}get isHand(){return this.inputSource.hand!=null}get hand(){return this.inputSource.hand}get handObject(){return this.context.renderer.xr.getHand(this.index)}get profiles(){return this.inputSource.profiles}get layout(){return this._layout}get targetRayMode(){return this.inputSource.targetRayMode}get targetRaySpace(){return this.inputSource.targetRaySpace}get gripSpace(){return this.inputSource.gripSpace}get side(){return this.inputSource.handedness}get isRight(){return this.side==="right"}get isLeft(){return this.side==="left"}get hitTestSource(){return this._hitTestSource}get hasSelectEvent(){return this._hasSelectEvent}getHitTest(){return this.xr.getHitTest(this)}getHandJointPose(A){var e,g;if(!this.hand||!((e=this.xr.frame)!=null&&e.getJointPose)||!this.xr.referenceSpace)return null;let I=(g=this._handJointPoses)==null?void 0:g.get(A);return I||(I=this.xr.frame.getJointPose(A,this.xr.referenceSpace),I&&this._handJointPoses.set(A,I),I)}get gripPosition(){return lt(this._gripPosition).applyMatrix4(JS)}get gripQuaternion(){return _Q(this._gripQuaternion).premultiply(vs)}get gripLinearVelocity(){return lt(this._linearVelocity).applyQuaternion(vs)}get rayPosition(){return lt(this._rayPosition).applyMatrix4(JS)}get rayQuaternion(){return _Q(this._rayQuaternion).premultiply(vs)}get gripWorldPosition(){return lt(this._gripWorldPosition)}get gripWorldQuaternion(){return _Q(this._gripWorldQuaternion)}get rayWorldPosition(){return lt(this._rayWorldPosition)}updateRayWorldPosition(){var A;const e=(A=this.xr.context.mainCamera)==null?void 0:A.parent;this._rayWorldPosition.copy(this._rayPosition),e&&this._rayWorldPosition.applyMatrix4(e.matrixWorld)}get rayWorldQuaternion(){return _Q(this._rayWorldQuaternion)}updateRayWorldQuaternion(){var A;const e=(A=this.xr.context.mainCamera)==null?void 0:A.parent,g=e?Nt(e):void 0;this._rayWorldQuaternion.copy(this._rayQuaternion).multiply(vs),g&&this._rayWorldQuaternion.premultiply(g)}get ray(){return this._ray.origin.copy(this.rayWorldPosition),this._ray.direction.copy(lt(0,0,1).applyQuaternion(this.rayWorldQuaternion)),this._ray}get object(){return this._object}async getModelUrl(){var A;return(A=this.getMotionController)==null?void 0:A.then(e=>e?.assetUrl||null)}onUpdate(A){this.onUpdateFrame(A),this.updateInputEvents(),this.onUpdateMove()}onRenderDebug(){var A;pe.DrawWireSphere(this.rayWorldPosition,.02),pe.DrawDirection(this.rayWorldPosition,lt(0,0,10).applyQuaternion(this.rayWorldQuaternion));const e=this.gripWorldPosition.sub(this.object.worldForward.multiplyScalar(.1)),g=this.inputSource.profiles.join(`
5151
+ */var KBA=function(i){return i!=null&&(h4(i)||bBA(i)||!!i._isBuffer)};function h4(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function bBA(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&h4(i.slice(0,0))}(function(){var i=vBA,A=Q4.utf8,e=KBA,g=Q4.bin,I=function(o,s){o.constructor==String?s&&s.encoding==="binary"?o=g.stringToBytes(o):o=A.stringToBytes(o):e(o)?o=Array.prototype.slice.call(o,0):!Array.isArray(o)&&o.constructor!==Uint8Array&&(o=o.toString());for(var n=i.bytesToWords(o),a=o.length*8,r=1732584193,C=-271733879,Q=-1732584194,h=271733878,E=0;E<n.length;E++)n[E]=(n[E]<<8|n[E]>>>24)&16711935|(n[E]<<24|n[E]>>>8)&4278255360;n[a>>>5]|=128<<a%32,n[(a+64>>>9<<4)+14]=a;for(var c=I._ff,l=I._gg,d=I._hh,u=I._ii,E=0;E<n.length;E+=16){var D=r,p=C,w=Q,f=h;r=c(r,C,Q,h,n[E+0],7,-680876936),h=c(h,r,C,Q,n[E+1],12,-389564586),Q=c(Q,h,r,C,n[E+2],17,606105819),C=c(C,Q,h,r,n[E+3],22,-1044525330),r=c(r,C,Q,h,n[E+4],7,-176418897),h=c(h,r,C,Q,n[E+5],12,1200080426),Q=c(Q,h,r,C,n[E+6],17,-1473231341),C=c(C,Q,h,r,n[E+7],22,-45705983),r=c(r,C,Q,h,n[E+8],7,1770035416),h=c(h,r,C,Q,n[E+9],12,-1958414417),Q=c(Q,h,r,C,n[E+10],17,-42063),C=c(C,Q,h,r,n[E+11],22,-1990404162),r=c(r,C,Q,h,n[E+12],7,1804603682),h=c(h,r,C,Q,n[E+13],12,-40341101),Q=c(Q,h,r,C,n[E+14],17,-1502002290),C=c(C,Q,h,r,n[E+15],22,1236535329),r=l(r,C,Q,h,n[E+1],5,-165796510),h=l(h,r,C,Q,n[E+6],9,-1069501632),Q=l(Q,h,r,C,n[E+11],14,643717713),C=l(C,Q,h,r,n[E+0],20,-373897302),r=l(r,C,Q,h,n[E+5],5,-701558691),h=l(h,r,C,Q,n[E+10],9,38016083),Q=l(Q,h,r,C,n[E+15],14,-660478335),C=l(C,Q,h,r,n[E+4],20,-405537848),r=l(r,C,Q,h,n[E+9],5,568446438),h=l(h,r,C,Q,n[E+14],9,-1019803690),Q=l(Q,h,r,C,n[E+3],14,-187363961),C=l(C,Q,h,r,n[E+8],20,1163531501),r=l(r,C,Q,h,n[E+13],5,-1444681467),h=l(h,r,C,Q,n[E+2],9,-51403784),Q=l(Q,h,r,C,n[E+7],14,1735328473),C=l(C,Q,h,r,n[E+12],20,-1926607734),r=d(r,C,Q,h,n[E+5],4,-378558),h=d(h,r,C,Q,n[E+8],11,-2022574463),Q=d(Q,h,r,C,n[E+11],16,1839030562),C=d(C,Q,h,r,n[E+14],23,-35309556),r=d(r,C,Q,h,n[E+1],4,-1530992060),h=d(h,r,C,Q,n[E+4],11,1272893353),Q=d(Q,h,r,C,n[E+7],16,-155497632),C=d(C,Q,h,r,n[E+10],23,-1094730640),r=d(r,C,Q,h,n[E+13],4,681279174),h=d(h,r,C,Q,n[E+0],11,-358537222),Q=d(Q,h,r,C,n[E+3],16,-722521979),C=d(C,Q,h,r,n[E+6],23,76029189),r=d(r,C,Q,h,n[E+9],4,-640364487),h=d(h,r,C,Q,n[E+12],11,-421815835),Q=d(Q,h,r,C,n[E+15],16,530742520),C=d(C,Q,h,r,n[E+2],23,-995338651),r=u(r,C,Q,h,n[E+0],6,-198630844),h=u(h,r,C,Q,n[E+7],10,1126891415),Q=u(Q,h,r,C,n[E+14],15,-1416354905),C=u(C,Q,h,r,n[E+5],21,-57434055),r=u(r,C,Q,h,n[E+12],6,1700485571),h=u(h,r,C,Q,n[E+3],10,-1894986606),Q=u(Q,h,r,C,n[E+10],15,-1051523),C=u(C,Q,h,r,n[E+1],21,-2054922799),r=u(r,C,Q,h,n[E+8],6,1873313359),h=u(h,r,C,Q,n[E+15],10,-30611744),Q=u(Q,h,r,C,n[E+6],15,-1560198380),C=u(C,Q,h,r,n[E+13],21,1309151649),r=u(r,C,Q,h,n[E+4],6,-145523070),h=u(h,r,C,Q,n[E+11],10,-1120210379),Q=u(Q,h,r,C,n[E+2],15,718787259),C=u(C,Q,h,r,n[E+9],21,-343485551),r=r+D>>>0,C=C+p>>>0,Q=Q+w>>>0,h=h+f>>>0}return i.endian([r,C,Q,h])};I._ff=function(o,s,n,a,r,C,Q){var h=o+(s&n|~s&a)+(r>>>0)+Q;return(h<<C|h>>>32-C)+s},I._gg=function(o,s,n,a,r,C,Q){var h=o+(s&a|n&~a)+(r>>>0)+Q;return(h<<C|h>>>32-C)+s},I._hh=function(o,s,n,a,r,C,Q){var h=o+(s^n^a)+(r>>>0)+Q;return(h<<C|h>>>32-C)+s},I._ii=function(o,s,n,a,r,C,Q){var h=o+(n^(s|~a))+(r>>>0)+Q;return(h<<C|h>>>32-C)+s},I._blocksize=16,I._digestsize=16,C4.exports=function(o,s){if(o==null)throw new Error("Illegal argument "+o);var n=i.wordsToBytes(I(o,s));return s&&s.asBytes?n:s&&s.asString?g.bytesToString(n):i.bytesToHex(n)}})();var JBA=C4.exports;const xBA=RS(JBA);class yK{constructor(A,e,g,I){B(this,"success"),B(this,"filename"),B(this,"hash"),B(this,"size"),B(this,"url"),this.success=A,this.filename=e,this.hash=g,this.size=I}}async function E4(i,A){const e=await i.arrayBuffer(),g=mK(e),I=i.name.split(".").pop(),o=g+"."+I,s=i.name.split(".").shift();console.assert(s!==void 0);const n={alias:s,filename:o},a=await(await fetch(A+"/exists",{method:"POST",body:JSON.stringify(n)})).json();if(a.success||console.warn("exists check did fail"),a.exists)return console.log("file already exists",g),new yK(!0,o,g,i.size);console.log("begin uploading file",s,i.size);const r=new FormData;r.append("file",i);const C={};C.filesize=i.size,s&&(C.alias=s);const Q=await(await fetch(A+"/upload/file",{method:"POST",body:r,headers:C})).json();if(Q?.success===!1)return Q.message!==void 0?console.error("Upload failed:",Q.message):console.error("Upload failed"),null;console.assert(Q.hash_sum===g,"hash sum did not match","received:",Q.hash_sum,"expected:",g),Q.success&&console.log("successfully uploaded",g,Q.id);const h=new yK(Q.success,o,g,i.size);return h.url=A,h}function mK(i){return xBA(new Uint8Array(i))}async function SK(i,A,e,g,I=!1){try{const o=await fetch(g+"/download/file",{method:"POST",body:i});if(o.status!==200)return console.error("download failed",o),null;const s=await o.blob(),n=await s.arrayBuffer();I||console.assert(s.size===e,"size mismatch","expected:",e,"got:",s.size);const a=mK(n);return I||console.assert(a===A,"hash mismatch, downloaded file is invalid"),s.arrayBuffer()}catch(o){console.error(o)}return null}async function c4(i,A){var e;const g=await fetch(i),I=(e=g.body)==null?void 0:e.getReader(),o=g.headers.get("Content-Length"),s=o?parseInt(o):0;if(!I)return null;let n=0;const a=[];for(;;){const{done:Q,value:h}=await I.read();if(h&&(a.push(h),n+=h.length,A.call(null,new ProgressEvent("progress",{loaded:n,total:s}))),Q)break}const r=new Uint8Array(n);let C=0;for(const Q of a)r.set(Q,C),C+=Q.length;return r}const tB=iA("debugaddressables");class l4{constructor(A){B(this,"_context"),B(this,"_assetReferences",{}),B(this,"preUpdate",()=>{}),this._context=A,this._context.pre_update_callbacks.push(this.preUpdate)}dispose(){const A=this._context.pre_update_callbacks.indexOf(this.preUpdate);A>=0&&this._context.pre_update_callbacks.splice(A,1);for(const e in this._assetReferences){const g=this._assetReferences[e];g?.unload()}this._assetReferences={}}findAssetReference(A){return this._assetReferences[A]||null}registerAssetReference(A){return A.uri&&(this._assetReferences[A.uri]?console.warn("Asset reference already registered",A):this._assetReferences[A.uri]=A),A}unregisterAssetReference(A){A.uri&&delete this._assetReferences[A.uri]}}const fK=Symbol("assetReference"),el=class{constructor(i,A,e=null){B(this,"_loading"),B(this,"_asset"),B(this,"_glbRoot"),B(this,"_url"),B(this,"_progressListeners",[]),B(this,"_hash"),B(this,"_hashedUri"),B(this,"_isLoadingRawBinary",!1),B(this,"_rawBinary"),this._url=i,this._hash=A,i.includes("?v=")?this._hashedUri=i:this._hashedUri=A?i+"?v="+A:i,e!==null&&(this.asset=e),Nj(this._url,this.onResolvePrefab.bind(this))}static getOrCreateFromUrl(i,A){if(!A&&(A=Ke.Current,!A))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.');const e=A.addressables,g=e.findAssetReference(i);if(g)return g;const I=new el(i,A.hash);return e.registerAssetReference(I),I}static getOrCreate(i,A,e){if(typeof i=="string"){if(!e&&(e=Ke.Current,!e))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.')}else e=i.context,i=i.sourceId;const g=MC(i,A);tB&&console.log("GetOrCreate Addressable from",i,A,"FinalPath=",g);const I=e.addressables,o=I.findAssetReference(g);if(o)return o;const s=new el(g,e.hash);return I.registerAssetReference(s),s}get asset(){return this._glbRoot??this._asset}set asset(i){this._asset=i}get uri(){return this._url}get url(){return this._url}get hasUrl(){return this._url!==void 0&&(this._url.startsWith("http")||this._url.startsWith("blob:")||this._url.startsWith("www.")||this._url.includes("/"))}get rawAsset(){return this._asset}async onResolvePrefab(i){return i===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||lh(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(tB&&console.log("Unload",this.asset),this.asset.scene&&Ks(this.asset.scene,!0,!0),Ks(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,Ke.Current&&Ke.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,tB&&console.log("Preload",this._hashedUri);const i=await c4(this._hashedUri,A=>{this.raiseProgressEvent(A)});return this._rawBinary=i?.buffer??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(i){if(tB&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(i&&this._progressListeners.push(i),this._loading!==void 0)return this._loading.then(g=>this.asset);const A=Ke.Current;this._rawBinary?(this._loading=an().parseSync(A,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(tB&&console.log("Load async",this.uri),this._loading=an().loadSync(A,this._hashedUri,this.uri,null,g=>{this.raiseProgressEvent(g)}));const e=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(e),this._loading=void 0,e)return e[fK]=this,this._glbRoot&&(this._glbRoot[fK]=this),this.asset&&(this.asset[fK]=this),pS(A),e.scene!==void 0&&(this.asset=e),this.asset}async instantiate(i){return this.onInstantiate(i,!1)}async instantiateSynced(i,A=!0){return this.onInstantiate(i,!0,A)}beginListenDownload(i){this._progressListeners.indexOf(i)<0&&this._progressListeners.push(i)}endListenDownload(i){const A=this._progressListeners.indexOf(i);A>=0&&this._progressListeners.splice(A,1)}raiseProgressEvent(i){for(const A of this._progressListeners)A(this,i)}async onInstantiate(i,A=!1,e){const g=Ke.Current,I=new Ln;if(i instanceof wA?I.parent=i:i&&(Object.assign(I,i),I.cloneAssign(i)),I.parent||(I.parent=g.scene),this.mustLoad&&await this.loadAssetAsync(),tB&&console.log("Instantiate",this.uri,"parent:",i),this.asset){tB&&console.log("Add to scene",this.asset);let o=el.currentlyInstantiating.get(this.uri);if(o!==void 0&&o>=1e4)return console.error("Recursive or too many instantiations of "+this.uri+" in the same frame ("+o+")"),null;try{if(o===void 0&&(o=0),o+=1,el.currentlyInstantiating.set(this.uri,o),A){I.context=g;const s=this.asset;s.guid=this.uri;const n=Qb(s,I,void 0,e);if(n)return n}else{const s=Bl(this.asset,I);if(s)return s}}finally{g.post_render_callbacks.push(()=>{o===void 0||o<0?o=0:o-=1,el.currentlyInstantiating.set(this.uri,o)})}}else tB&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(i){if(i&&i.scene){const A=i.scene;return A.isGroup&&A.children.length===1&&A.children[0].name+"glb"===A.name?A.children[0]:A}return null}};let gt=el;B(gt,"currentlyInstantiating",new Map);class qBA extends Fs{constructor(){super([gt],"AssetReferenceSerializer")}onSerialize(A,e){if(A&&A.uri!==void 0&&typeof A.uri=="string")return A.uri}onDeserialize(A,e){if(typeof A=="string")return e.context?e.gltfId?gt.getOrCreate(e.gltfId,A,e.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(A instanceof wA){if(!e.context)return console.error("Missing context"),null;if(!e.gltfId)return console.error("Missing source id"),null;const g=A,I=e.context,o=g.guid??g.uuid,s=I.addressables.findAssetReference(o);if(s)return s;const n=new gt(o,void 0,g);return I.addressables.registerAssetReference(n),n}return null}}new qBA;const LBA=Promise.resolve(null),US=class{constructor(i){B(this,"url"),B(this,"_bitmap"),B(this,"_bitmapObject"),B(this,"loader",null),this.url=i}static getOrCreate(i){let A=US.imageReferences.get(i);return A||(A=new US(i),US.imageReferences.set(i,A)),A}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const i=new Image;return i.src=this.url,i}createTexture(){return this.url?(this.loader||(this.loader=new Zn),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):LBA}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((i,A)=>{const e=document.createElement("img");e.addEventListener("load",()=>{this._bitmap=createImageBitmap(e).then(g=>(this._bitmapObject=g,i(g),g))}),e.addEventListener("error",g=>{console.error("Failed to load image:"+this.url,g),i(null)}),e.src=this.url}),this._bitmap)}};let NS=US;B(NS,"imageReferences",new Map);class d4 extends Fs{constructor(){super([NS],"ImageReferenceSerializer")}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"){const g=MC(e.gltfId,A);return NS.getOrCreate(g)}}}new d4;const FS=class{constructor(i){B(this,"url"),B(this,"res"),this.url=i}static getOrCreate(i){let A=FS.cache.get(i);return A||(A=new FS(i),FS.cache.set(i,A)),A}async loadRaw(){return this.res||(this.res=fetch(this.url)),this.res.then(i=>i.blob())}async loadText(){return this.res||(this.res=fetch(this.url)),this.res.then(i=>i.text())}};let vS=FS;B(vS,"cache",new Map);class u4 extends Fs{constructor(){super([vS],"FileReferenceSerializer")}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"){const g=MC(e.gltfId,A);return vS.getOrCreate(g)}}}new u4;class _BA{constructor(A){B(this,"context"),B(this,"mixers",[]),this.context=A}onDestroy(){this.mixers.forEach(A=>A.stopAllAction()),this.mixers.length=0}registerAnimationMixer(A){if(!A){console.warn("AnimationsRegistry.registerAnimationMixer called with null or undefined mixer");return}this.mixers.includes(A)||this.mixers.push(A)}unregisterAnimationMixer(A){if(!A)return;const e=this.mixers.indexOf(A);e!==-1&&this.mixers.splice(e,1)}}class tl{static tryGetActionsFromMixer(A){return A._actions||null}static tryGetAnimationClipsFromObjectHierarchy(A,e){if(e||(e=new Array),A)A.animations&&e.push(...A.animations);else return e;if(A.children)for(const g of A.children)this.tryGetAnimationClipsFromObjectHierarchy(g,e);return e}static assignAnimationsFromFile(A,e){if(!A||!A.animations)return;for(let I=0;I<A.animations.length;I++){const o=A.animations[I];if(!(!o.tracks||o.tracks.length<=0))for(const s in o.tracks){const n=o.tracks[s],a=Ze.parseTrackName(n.name);let r=Ze.findNode(A.scene,a.nodeName);if(!r){const Q=n.__objectName??n.name.substring(0,n.name.indexOf("."));if(r=A.scene.getObjectByProperty("uuid",Q),!r)continue}let C=g(r);if(!C){if(!(e!=null&&e.createAnimationComponent)){console.warn("No AnimationComponent found in parent hierarchy of object and no 'createAnimationComponent' callback was provided in options.");continue}C=e.createAnimationComponent(A.scene,o)}C.addClip&&C.addClip(o)}}function g(I){var o;if(!I)return null;const s=(o=I.userData)==null?void 0:o.components;if(s&&s.length>0){for(let n=0;n<s.length;n++)if(s[n].isAnimationComponent===!0)return I}return g(I.parent)}}}const il=[];function KS(i){il.indexOf(i)===-1&&il.push(i)}function TBA(i){const A=il.indexOf(i);A!==-1&&il.splice(A,1)}const gl=[];function kK(i){gl.indexOf(i)===-1&&gl.push(i)}function YBA(i){const A=gl.indexOf(i);A!==-1&&gl.splice(A,1)}function p4(i){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-start",{detail:i}));for(let A=0;A<il.length;A++)il[A](i)}function D4(i){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-end",{detail:i}));for(let A=0;A<gl.length;A++)gl[A](i)}const Kg={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function w4(i){const A=await fetch(i);if(A.ok)return A.json();throw new Error(A.statusText)}async function HBA(i){if(!i)throw new Error("No basePath supplied");return await w4(`${i}/profilesList.json`)}async function OBA(i,A,e=null,g=!0){if(!i)throw new Error("No xrInputSource supplied");if(!A)throw new Error("No basePath supplied");const I=await HBA(A);let o;if(i.profiles.some(a=>{const r=I[a];return r&&(o={profileId:a,profilePath:`${A}/${r.path}`,deprecated:!!r.deprecated}),!!o}),!o){if(!e)throw new Error("No matching profile name found");const a=I[e];if(!a)throw new Error(`No matching profile name found and default profile "${e}" missing.`);o={profileId:e,profilePath:`${A}/${a.path}`,deprecated:!!a.deprecated}}const s=await w4(o.profilePath);let n;if(g){let a;if(i.handedness==="any"?a=s.layouts[Object.keys(s.layouts)[0]]:a=s.layouts[i.handedness],!a)throw new Error(`No matching handedness, ${i.handedness}, in profile ${o.profileId}`);a.assetPath&&(n=o.profilePath.replace("profile.json",a.assetPath))}return{profile:s,assetPath:n}}const PBA={xAxis:0,yAxis:0,button:0,state:Kg.ComponentState.DEFAULT};function jBA(i=0,A=0){let e=i,g=A;if(Math.sqrt(i*i+A*A)>1){const I=Math.atan2(A,i);e=Math.cos(I),g=Math.sin(I)}return{normalizedXAxis:e*.5+.5,normalizedYAxis:g*.5+.5}}let WBA=class{constructor(i){this.componentProperty=i.componentProperty,this.states=i.states,this.valueNodeName=i.valueNodeName,this.valueNodeProperty=i.valueNodeProperty,this.valueNodeProperty===Kg.VisualResponseProperty.TRANSFORM&&(this.minNodeName=i.minNodeName,this.maxNodeName=i.maxNodeName),this.value=0,this.updateFromComponent(PBA)}updateFromComponent({xAxis:i,yAxis:A,button:e,state:g}){const{normalizedXAxis:I,normalizedYAxis:o}=jBA(i,A);switch(this.componentProperty){case Kg.ComponentProperty.X_AXIS:this.value=this.states.includes(g)?I:.5;break;case Kg.ComponentProperty.Y_AXIS:this.value=this.states.includes(g)?o:.5;break;case Kg.ComponentProperty.BUTTON:this.value=this.states.includes(g)?e:0;break;case Kg.ComponentProperty.STATE:this.valueNodeProperty===Kg.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(g):this.value=this.states.includes(g)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}},ZBA=class{constructor(i,A){if(!i||!A||!A.visualResponses||!A.gamepadIndices||Object.keys(A.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=i,this.type=A.type,this.rootNodeName=A.rootNodeName,this.touchPointNodeName=A.touchPointNodeName,this.visualResponses={},Object.keys(A.visualResponses).forEach(e=>{const g=new WBA(A.visualResponses[e]);this.visualResponses[e]=g}),this.gamepadIndices=Object.assign({},A.gamepadIndices),this.values={state:Kg.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(i){if(this.values.state=Kg.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&i.buttons.length>this.gamepadIndices.button){const A=i.buttons[this.gamepadIndices.button];this.values.button=A.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,A.pressed||this.values.button===1?this.values.state=Kg.ComponentState.PRESSED:(A.touched||this.values.button>Kg.ButtonTouchThreshold)&&(this.values.state=Kg.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&i.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=i.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===Kg.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Kg.AxisTouchThreshold&&(this.values.state=Kg.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&i.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=i.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===Kg.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Kg.AxisTouchThreshold&&(this.values.state=Kg.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(A=>{A.updateFromComponent(this.values)})}},zBA=class{constructor(i,A,e){if(!i)throw new Error("No xrInputSource supplied");if(!A)throw new Error("No profile supplied");this.xrInputSource=i,this.assetUrl=e,this.id=A.profileId,this.layoutDescription=A.layouts[i.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(g=>{const I=this.layoutDescription.components[g];this.components[g]=new ZBA(g,I)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const i=[];return Object.values(this.components).forEach(A=>{i.push(A.data)}),i}updateFromGamepad(){Object.values(this.components).forEach(i=>{i.updateFromGamepad(this.xrInputSource.gamepad)})}};const Io=new S,y4=new S,m4=new GA,VBA=iA("debuggizmos"),sa=8947848,na=class{constructor(){}static isGizmo(i){return i[GK]!==void 0}static DrawLabel(i,A,e=.05,g=0,I,o,s){var n;if(!na.enabled)return null;I||(I=sa);const a=((n=me.active)==null?void 0:n.rigScale)??1,r=Ki.getTextLabel(g,A,e*a,I,o);return s instanceof wA&&s.add(r),r.position.x=i.x,r.position.y=i.y,r.position.z=i.z,r}static DrawRay(i,A,e=sa,g=0,I=!0){if(!na.enabled)return;const o=Ki.getLine(g),s=o.geometry.getAttribute("position");s.setXYZ(0,i.x,i.y,i.z),Io.set(A.x,A.y,A.z).multiplyScalar(999999999),s.setXYZ(1,i.x+Io.x,i.y+Io.y,i.z+Io.z),s.needsUpdate=!0,o.material.color.set(e),o.material.depthTest=I,o.material.depthWrite=!1}static DrawDirection(i,A,e=sa,g=0,I=!0,o=1){if(!na.enabled)return;const s=Ki.getLine(g),n=s.geometry.getAttribute("position");n.setXYZ(0,i.x,i.y,i.z),A.w!==void 0?(Io.set(0,0,-o),m4.set(A.x,A.y,A.z,A.w),Io.applyQuaternion(m4)):(Io.set(A.x,A.y,A.z),Io.multiplyScalar(o)),n.setXYZ(1,i.x+Io.x,i.y+Io.y,i.z+Io.z),n.needsUpdate=!0,s.material.color.set(e),s.material.depthTest=I,s.material.depthWrite=!1}static DrawLine(i,A,e=sa,g=0,I=!0){if(!na.enabled)return;const o=Ki.getLine(g),s=o.geometry.getAttribute("position");s.setXYZ(0,i.x,i.y,i.z),s.setXYZ(1,A.x,A.y,A.z),s.needsUpdate=!0,o.material.color.set(e),o.material.depthTest=I,o.material.depthWrite=!1,o.material.fog=!1}static DrawWireSphere(i,A,e=sa,g=0,I=!0){if(!na.enabled)return;const o=Ki.getSphere(A,g,!0);TQ(o,i.x,i.y,i.z),o.material.color.set(e),o.material.depthTest=I,o.material.depthWrite=!1,o.material.fog=!1}static DrawSphere(i,A,e=sa,g=0,I=!0){if(!na.enabled)return;const o=Ki.getSphere(A,g,!1);TQ(o,i.x,i.y,i.z),o.material.color.set(e),o.material.depthTest=I,o.material.depthWrite=!1}static DrawWireBox(i,A,e=sa,g=0,I=!0){if(!na.enabled)return;const o=Ki.getBox(g);o.position.set(i.x,i.y,i.z),o.scale.set(A.x,A.y,A.z),o.material.color.set(e),o.material.depthTest=I,o.material.wireframe=!0,o.material.depthWrite=!1,o.material.fog=!1}static DrawWireBox3(i,A=sa,e=0,g=!0){if(!na.enabled)return;const I=Ki.getBox(e);I.position.copy(i.getCenter(Io)),I.scale.copy(i.getSize(Io)),I.material.color.set(A),I.material.depthTest=g,I.material.wireframe=!0,I.material.depthWrite=!1,I.material.fog=!1}static DrawArrow(i,A,e=sa,g=0,I=!0,o=!1){if(!na.enabled)return;const s=Ki.getArrowHead(g);s.position.set(A.x,A.y,A.z),s.quaternion.setFromUnitVectors(this._up.set(0,1,0),Io.set(A.x,A.y,A.z).sub(y4.set(i.x,i.y,i.z)).normalize());const n=Io.set(A.x,A.y,A.z).sub(y4.set(i.x,i.y,i.z)).length()*.1;s.scale.set(n,n,n),s.material.color.set(e),s.material.depthTest=I,s.material.wireframe=o,this.DrawLine(i,A,e,g,I)}static DrawWireMesh(i){const A=Ki.getMesh(i.duration??0);"mesh"in i?(A.geometry=i.mesh.geometry,A.matrix.copy(i.mesh.matrixWorld)):(A.geometry=i.geometry,A.matrix.copy(i.matrix)),A.matrixAutoUpdate=!1,A.matrixWorldAutoUpdate=!1,A.material.color.set(i.color??sa),A.material.depthTest=i.depthTest??!0,A.material.wireframe=!0}};let pe=na;B(pe,"enabled",!0),B(pe,"_up",new S(0,1,0));const XBA=new Ai(1,1,1);function MK(i=null){const A=new fA(i??14540253),e=new EU(XBA);return new kI(e,new Zt({color:A}))}const GK=Symbol("GizmoCache");class Ki{static ensureFont(){let A=Ot.FontLibrary.getFontFamily(this.familyName);if(!A){A=Ot.FontLibrary.addFontFamily(this.familyName);const e=A.addVariant("normal","normal","https://uploads.needle.tools/include/font-msdf.json","https://uploads.needle.tools/include/font.png");e?.addEventListener("ready",()=>{Ot.update()})}}static getTextLabel(A,e,g,I,o){this.ensureFont();let s=this.textLabelCache.pop(),n=1;o&&typeof o=="string"&&o?.length>=8&&o.startsWith("#")?(n=parseInt(o.substring(7),16)/255,o=o.substring(0,7),VBA&&console.log(o,n)):typeof o=="object"&&o.a!==void 0&&(n=o.a);const a={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:g,color:I,lineHeight:1,backgroundColor:o??void 0,backgroundOpacity:n,textContent:e,borderRadius:.5*g,padding:.8*g,whiteSpace:"pre"};if(s)s.set(a);else{s=new MN(a);const r=this,C=s;C.setText=function(Q){this.set({textContent:Q}),r.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(Ke.Current,s,A,this.textLabelCache),s}static getBox(A){let e=this.boxesCache.pop();if(!e){const g=new Ai(1,1,1);e=new dA(g)}return this.registerTimedObject(Ke.Current,e,A,this.boxesCache),e}static getLine(A){let e=this.linesCache.pop();if(!e){e=new Fi;let g=e.geometry.getAttribute("position");g||(g=new Ie(new Float32Array(2*3),3),e.geometry.setAttribute("position",g))}return e.frustumCulled=!1,this.registerTimedObject(Ke.Current,e,A,this.linesCache),e}static getSphere(A,e,g){let I=this.spheresCache.pop();return I||(I=new dA(new Vs(1,8,8))),I.scale.set(A,A,A),I.material.wireframe=g,this.registerTimedObject(Ke.Current,I,e,this.spheresCache),I}static getArrowHead(A){let e=this.arrowHeadsCache.pop();return e||(e=new dA(new Xi(0,.5,1,8))),this.registerTimedObject(Ke.Current,e,A,this.arrowHeadsCache),e}static getMesh(A){let e=this.mesh.pop();return e||(e=new dA,e.material=new tt),this.registerTimedObject(Ke.Current,e,A,this.mesh),e}static registerTimedObject(A,e,g,I){const o=this.contextBeforeRenderCallbacks.get(A),s=this.contextPostRenderCallbacks.get(A);if(o){if(A.pre_render_callbacks[A.pre_render_callbacks.length-1]!==o){const n=A.pre_render_callbacks.indexOf(o);n>=0&&A.pre_render_callbacks.splice(n,1),A.pre_render_callbacks.push(o)}}else{const n=()=>{this.onBeforeRender(A,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(A,n),A.pre_render_callbacks.push(n)}if(s){if(A.post_render_callbacks[A.post_render_callbacks.length-1]!==s){const n=A.post_render_callbacks.indexOf(s);n>=0&&A.post_render_callbacks.splice(n,1),A.post_render_callbacks.push(s)}}else{const n=()=>{this.onPostRender(A,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(A,n),A.post_render_callbacks.push(n)}e.traverse(n=>{n.layers.disableAll(),n.layers.enable(2)}),e.renderOrder=999999,e[GK]=I,e.isGizmo=!0,this.timedObjectsBuffer.push(e),g<=0&&A.currentFrameEvent>=Xt.OnBeforeRender?this.timesBuffer.push(0):this.timesBuffer.push(Ke.Current.time.realtimeSinceStartup+g),A.scene.add(e)}static onBeforeRender(A,e){this.tmuiNeedsUpdate&&Ot.update();for(let g=0;g<e.length;g++){const I=e[g];if(A.mainCamera&&I instanceof Ot.MeshUIBaseElement){if(lh(I))continue;const o=A.isInVR,s=!1,n=!o;Su(I,A.mainCamera,s,n)}}}static onPostRender(A,e,g){const I=A.time.realtimeSinceStartup;for(let o=e.length-1;o>=0;o--){const s=e[o];I>g[o]&&(e.splice(o,1),g.splice(o,1),s.removeFromParent(),lh(s)!=!0&&s[GK].push(s))}}}B(Ki,"familyName","needle-gizmos"),B(Ki,"linesCache",[]),B(Ki,"spheresCache",[]),B(Ki,"boxesCache",[]),B(Ki,"arrowHeadsCache",[]),B(Ki,"mesh",[]),B(Ki,"textLabelCache",[]),B(Ki,"timedObjectsBuffer",new Array),B(Ki,"timesBuffer",new Array),B(Ki,"contextPostRenderCallbacks",new Map),B(Ki,"contextBeforeRenderCallbacks",new Map),B(Ki,"tmuiNeedsUpdate",!1);const Dg=iA("debuginput");var bS=(i=>(i.Mouse="mouse",i.Touch="touch",i.Controller="controller",i.Hand="hand",i))(bS||{}),hi=(i=>(i.PointerDown="pointerdown",i.PointerUp="pointerup",i.PointerMove="pointermove",i.KeyDown="keydown",i.KeyUp="keyup",i.KeyPressed="keypress",i))(hi||{});class Gr extends PointerEvent{constructor(A,e,g){super(A,g),B(this,"deviceIndex"),B(this,"origin"),B(this,"source"),B(this,"mode"),B(this,"_ray"),B(this,"space"),B(this,"isClick",!1),B(this,"isDoubleClick",!1),B(this,"_used",!1),B(this,"_pointerid"),B(this,"_pointerType"),B(this,"_type"),B(this,"metadata",{}),B(this,"intersections",new Array),B(this,"_immediatePropagationStopped",!1),B(this,"_propagationStopped",!1),this._pointerid=g.pointerId,this._pointerType=g.pointerType,this._type=A,this.deviceIndex=g.deviceIndex,this.origin=g.origin,this.source=e,this.mode=g.mode,this._ray=g.ray,this.space=g.device}get ray(){return this._ray||(this._ray=new po(this.space.worldPosition.clone(),this.space.worldForward.clone())),this._ray}set ray(A){this._ray=A}get hasRay(){return this._ray!==void 0}get used(){return this._used}use(){this._used=!0}get pointerId(){return this._pointerid}get pointerType(){return this._pointerType}get type(){return this._type}get immediatePropagationStopped(){return this._immediatePropagationStopped}get propagationStopped(){return this._immediatePropagationStopped||this._propagationStopped}stopImmediatePropagation(){var A;this._immediatePropagationStopped=!0,super.stopImmediatePropagation(),(A=this.source)==null||A.stopImmediatePropagation()}stopPropagation(){var A;this._propagationStopped=!0,super.stopPropagation(),(A=this.source)==null||A.stopPropagation(),Dg&&console.warn("Stop propagation...",this.pointerId,this.pointerType)}}class kp extends KeyboardEvent{constructor(A,e,g){super(A,g),B(this,"source"),this.source=e}stopImmediatePropagation(){var A;super.stopImmediatePropagation(),(A=this.source)==null||A.stopImmediatePropagation()}}class $BA{constructor(A){B(this,"key"),B(this,"keyType"),B(this,"source"),this.key=A.key,this.keyType=A.type,this.source=A}}var aa=(i=>(i[i.Early=-100]="Early",i[i.Default=0]="Default",i[i.Late=100]="Late",i))(aa||{});class S4{constructor(A){B(this,"_eventListeners",{}),B(this,"_doubleClickTimeThreshold",.2),B(this,"_longPressTimeThreshold",1),B(this,"_specialCursorTrigger",0),B(this,"context"),B(this,"_pointerDown",[!1]),B(this,"_pointerUp",[!1]),B(this,"_pointerClick",[!1]),B(this,"_pointerDoubleClick",[!1]),B(this,"_pointerPressed",[!1]),B(this,"_pointerPositions",[new AA]),B(this,"_pointerPositionsLastFrame",[new AA]),B(this,"_pointerPositionsDelta",[new AA]),B(this,"_pointerPositionsRC",[new AA]),B(this,"_pointerPositionDown",[new AA]),B(this,"_pointerDownTime",[]),B(this,"_pointerUpTime",[]),B(this,"_pointerUpTimestamp",[]),B(this,"_pointerIds",[]),B(this,"_pointerTypes",[""]),B(this,"_mouseWheelChanged",[!1]),B(this,"_mouseWheelDeltaY",[0]),B(this,"_pointerEvent",[]),B(this,"_pointerUsed",[]),B(this,"_pointerSpace",[]),B(this,"_pressedStack",new Map),B(this,"_htmlEventSource"),B(this,"onLostFocus",()=>{for(const e in this.keysPressed)this.keysPressed[e].pressed=!1}),B(this,"onEndOfFrame",()=>{for(let e=0;e<this._pointerUp.length;e++)this._pointerUp[e]=!1;for(let e=0;e<this._pointerDown.length;e++)this._pointerDown[e]=!1;for(let e=0;e<this._pointerClick.length;e++)this._pointerClick[e]=!1;for(let e=0;e<this._pointerDoubleClick.length;e++)this._pointerDoubleClick[e]=!1;for(const e of this._pointerPositionsDelta)e.set(0,0);for(let e=0;e<this._mouseWheelChanged.length;e++)this._mouseWheelChanged[e]=!1;for(let e=0;e<this._mouseWheelDeltaY.length;e++)this._mouseWheelDeltaY[e]=0}),B(this,"onContextMenu",e=>{this.canReceiveInput(e)!==!1&&e instanceof PointerEvent&&e.pointerType}),B(this,"keysPressed",{}),B(this,"onKeyDown",e=>{if(Dg&&console.log(`key down ${e.code}, ${this.context.application.hasFocus}`,e),!this.context.application.hasFocus)return;const g=this.keysPressed[e.code];if(g&&g.pressed)return;this.keysPressed[e.code]={pressed:!0,frame:this.context.time.frameCount+1,startFrame:this.context.time.frameCount+1,key:e.key,code:e.code};const I=new kp("keydown",e,e);this.onDispatchEvent(I)}),B(this,"onKeyPressed",e=>{if(!this.context.application.hasFocus)return;const g=this.keysPressed[e.code];if(!g)return;g.pressed=!0,g.frame=this.context.time.frameCount+1;const I=new kp("keypress",e,e);this.onDispatchEvent(I)}),B(this,"onKeyUp",e=>{if(!this.context.application.hasFocus)return;const g=this.keysPressed[e.code];if(!g)return;g.pressed=!1,g.frame=this.context.time.frameCount+1;const I=new kp("keyup",e,e);this.onDispatchEvent(I)}),B(this,"onWheelWindow",e=>{document.pointerLockElement&&this.onMouseWheel(e)}),B(this,"onMouseWheel",e=>{if(this.canReceiveInput(e)===!1)return;this._mouseWheelDeltaY.length<=0&&this._mouseWheelDeltaY.push(0),this._mouseWheelChanged.length<=0&&this._mouseWheelChanged.push(!1),this._mouseWheelChanged[0]=!0;const g=this._mouseWheelDeltaY[0];this._mouseWheelDeltaY[0]=g+e.deltaY}),B(this,"onPointerDown",e=>{if(this.context.isInAR||this.canReceiveInput(e)===!1)return;e.target instanceof HTMLElement&&e.target.setPointerCapture(e.pointerId);const g=this.getPointerId(e);Dg&&Ci(`pointer down #${g}, identifier:${e.pointerId}`);const I=this.getAndUpdateSpatialObjectForScreenPosition(g,e.clientX,e.clientY),o=new Gr("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:g,button:e.button,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:I,pressure:e.pressure});this.onDown(o)}),B(this,"onPointerMove",e=>{if(this.context.isInAR)return;let g=e.button;e.pointerType==="mouse"&&(g=this.getFirstPressedButtonForPointer(0)??0);const I=this.getPointerId(e,g);g===-1&&(g=I);const o=this.getAndUpdateSpatialObjectForScreenPosition(I,e.clientX,e.clientY),s=new Gr("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:I,button:g,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:o,pressure:e.pressure});this.onMove(s)}),B(this,"onPointerCancel",e=>{this.context.isInAR||(Dg&&console.log("Pointer cancel",e),this.onPointerUp(e))}),B(this,"onPointerUp",e=>{if(this.context.isInAR)return;e.target instanceof HTMLElement&&e.target.releasePointerCapture(e.pointerId);const g=this.getPointerId(e),I=new Gr("pointerup",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:g,button:e.button,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:this.getAndUpdateSpatialObjectForScreenPosition(g,e.clientX,e.clientY),pressure:e.pressure});this.onUp(I),this._pointerIds[g]=-1,Dg&&console.log("ID="+g,"PointerId="+e.pointerId,"ALL:",[...this._pointerIds])}),B(this,"onTouchStart",e=>{if(this.context.isInAR)for(let g=0;g<e.changedTouches.length;g++){const I=e.changedTouches[g],o=this.getPointerIndex(I.identifier),s=this.getAndUpdateSpatialObjectForScreenPosition(o,I.clientX,I.clientY),n=new Gr("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:o,button:0,clientX:I.clientX,clientY:I.clientY,pointerType:"touch",buttonName:"unknown",device:s,pressure:I.force});this.onDown(n)}}),B(this,"onTouchMove",e=>{if(this.context.isInAR)for(let g=0;g<e.changedTouches.length;g++){const I=e.changedTouches[g],o=this.getPointerIndex(I.identifier),s=this.getAndUpdateSpatialObjectForScreenPosition(o,I.clientX,I.clientY),n=new Gr("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:o,button:0,clientX:I.clientX,clientY:I.clientY,pointerType:"touch",buttonName:"unknown",device:s,pressure:I.force});this.onMove(n)}}),B(this,"onTouchEnd",e=>{if(this.context.isInAR)for(let g=0;g<e.changedTouches.length;g++){const I=e.changedTouches[g],o=this.getPointerIndex(I.identifier),s=new Gr("pointerup",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:o,button:0,clientX:I.clientX,clientY:I.clientY,pointerType:"touch",buttonName:"unknown",device:this.getAndUpdateSpatialObjectForScreenPosition(o,I.clientX,I.clientY),pressure:I.force});this.onUp(s),this._pointerIds[o]=-1}}),B(this,"tempNearPlaneVector",new S),B(this,"tempFarPlaneVector",new S),B(this,"tempLookMatrix",new DA),this.context=A,this.context.post_render_callbacks.push(this.onEndOfFrame)}addEventListener(A,e,g){if(this._eventListeners[A]||(this._eventListeners[A]=[]),!e||typeof e!="function"){console.error("Invalid call to addEventListener: callback is required and must be a function!");return}g?g={...g}:g={};let I=0;g?.queue!=null&&(I=g.queue);const o=this._eventListeners[A],s=o.find(n=>n.priority===I);s?s.listeners.push({callback:e,options:g}):(o.push({priority:I,listeners:[{callback:e,options:g}]}),o.sort((n,a)=>n.priority-a.priority))}removeEventListener(A,e,g){if(!this._eventListeners[A]||!e)return;const I=this._eventListeners[A];if(g?.queue!=null){const o=I.find(n=>n.priority===g.queue);if(!o)return;const s=o.listeners.findIndex(n=>n.callback===e);s>=0&&o.listeners.splice(s,1)}else for(const o of I){const s=o.listeners.findIndex(n=>n.callback===e);s>=0&&o.listeners.splice(s,1)}}dispatchEvent(A){var e,g,I,o;let s=!1;if(A instanceof kp){const n=this._eventListeners[A.type];if(n)for(const a of n)for(let r=0;r<a.listeners.length;r++){const C=a.listeners[r];if((g=(e=C.options)==null?void 0:e.signal)!=null&&g.aborted){a.listeners.splice(r,1),r--;continue}C.options.once&&(a.listeners.splice(r,1),r--),C.callback(A)}}if(A instanceof Gr){const n=this._eventListeners[A.type];if(n)for(const a of n){if(s)break;for(let r=0;r<a.listeners.length;r++){const C=a.listeners[r];if((o=(I=C.options)==null?void 0:I.signal)!=null&&o.aborted){a.listeners.splice(r,1),r--;continue}if(A.immediatePropagationStopped){s=!0,Dg&&console.log("immediatePropagationStopped",A.type);break}else A.propagationStopped&&(s=!0,Dg&&console.log("propagationStopped",A.type));C.options.once&&(a.listeners.splice(r,1),r--),C.callback(A)}}}}get mousePosition(){return this._pointerPositions[0]}get mousePositionRC(){return this._pointerPositionsRC[0]}get mouseDown(){return this._pointerDown[0]}get mouseUp(){return this._pointerUp[0]}get mouseClick(){return this._pointerClick[0]}get mouseDoubleClick(){return this._pointerDoubleClick[0]}get mousePressed(){return this._pointerPressed[0]}get mouseWheelChanged(){return this.getMouseWheelChanged(0)}setCursorPointer(){this._specialCursorTrigger+=1,this.context.domElement.style.cursor="pointer"}setCursorNormal(){this._specialCursorTrigger-=1,this._specialCursorTrigger=Math.max(0,this._specialCursorTrigger),this._specialCursorTrigger===0&&(this.context.domElement.style.cursor="default")}setPointerUsed(A,e=!0){if(A>=this._pointerUsed.length){if(A>=this._pointerIds.length)return;for(;this._pointerUsed.length<=A;)this._pointerUsed.push(!1)}this._pointerUsed[A]=e}getPointerUsed(A){return A>=this._pointerUsed.length?!1:this._pointerUsed[A]}getPointerPressedCount(){let A=0;for(let e=0;e<this._pointerPressed.length;e++)this._pointerPressed[e]&&A++;return A}getPointerPosition(A){return A>=this._pointerPositions.length?null:this._pointerPositions[A]}getPointerPositionLastFrame(A){return A>=this._pointerPositionsLastFrame.length?null:this._pointerPositionsLastFrame[A]}getPointerPositionDelta(A){return A>=this._pointerPositionsDelta.length?null:this._pointerPositionsDelta[A]}getPointerPositionRC(A){return A>=this._pointerPositionsRC.length?null:this._pointerPositionsRC[A]}getPointerDown(A){return A>=this._pointerDown.length?!1:this._pointerDown[A]}getPointerUp(A){return A>=this._pointerUp.length?!1:this._pointerUp[A]}getPointerPressed(A){return A>=this._pointerPressed.length?!1:this._pointerPressed[A]}getPointerClicked(A){return A>=this._pointerClick.length?!1:this._pointerClick[A]}getPointerDoubleClicked(A){return A>=this._pointerDoubleClick.length?!1:this._pointerDoubleClick[A]}getPointerDownTime(A){return A>=this._pointerDownTime.length?-1:this._pointerDownTime[A]}getPointerUpTime(A){return A>=this._pointerUpTime.length?-1:this._pointerUpTime[A]}getPointerLongPress(A){return A>=this._pointerDownTime.length?!1:this.getPointerPressed(A)&&this.context.time.time-this._pointerDownTime[A]>this._longPressTimeThreshold}getIsMouse(A){return A<0||A>=this._pointerTypes.length?!1:this._pointerTypes[A]==="mouse"}getIsTouch(A){return A<0||A>=this._pointerTypes.length?!1:this._pointerTypes[A]==="touch"}getTouchesPressedCount(){let A=0;for(let e=0;e<this._pointerPressed.length;e++)this._pointerPressed[e]&&this.getIsTouch(e)&&A++;return A}getMouseWheelChanged(A=0){return A>=this._mouseWheelChanged.length?!1:this._mouseWheelChanged[A]}getMouseWheelDeltaY(A=0){return A>=this._mouseWheelDeltaY.length?0:this._mouseWheelDeltaY[A]}getPointerEvent(A){if(!(A>=this._pointerEvent.length))return this._pointerEvent[A]??void 0}*foreachPointerId(A){for(let e=0;e<this._pointerTypes.length;e++)if(this._pointerIsActive(e)){if(A!==void 0){const g=this._pointerTypes[e];if(Array.isArray(A)){let I=!1;for(const o of A)if(g===o){I=!0;break}if(!I)continue}else if(A!==g)continue}yield e}}*foreachTouchId(){for(let A=0;A<this._pointerTypes.length;A++)this._pointerTypes[A]==="touch"&&this._pointerIsActive[A]&&(yield A)}_pointerIsActive(A){return A<0?!1:this._pointerPressed[A]||this._pointerDown[A]||this._pointerUp[A]}onDownButton(A,e){let g=this._pressedStack.get(A);g||(g=[],this._pressedStack.set(A,g)),g.push(e)}onReleaseButton(A,e){const g=this._pressedStack.get(A);if(!g)return;const I=g.indexOf(e);I>=0&&g.splice(I,1)}getFirstPressedButtonForPointer(A){const e=this._pressedStack.get(A);if(e)return e[0]}getLatestPressedButtonForPointer(A){const e=this._pressedStack.get(A);if(e)return e[e.length-1]}getKeyDown(){for(const A in this.keysPressed){const e=this.keysPressed[A];if(e.startFrame===this.context.time.frameCount)return e.key}return null}getKeyPressed(){for(const A in this.keysPressed){const e=this.keysPressed[A];if(e.pressed)return e.key}return null}isKeyDown(A){var e;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const g=this.getCodeForCommonKeyName(A);if(g!==null){for(const I of g)if(this.isKeyDown(I))return!0;return!1}return((e=this.keysPressed[A])==null?void 0:e.startFrame)===this.context.time.frameCount&&this.keysPressed[A].pressed}isKeyUp(A){var e;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const g=this.getCodeForCommonKeyName(A);if(g!==null){for(const I of g)if(this.isKeyUp(I))return!0;return!1}return((e=this.keysPressed[A])==null?void 0:e.frame)===this.context.time.frameCount&&!this.keysPressed[A].pressed}isKeyPressed(A){var e;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const g=this.getCodeForCommonKeyName(A);if(g!==null){for(const I of g)if(this.isKeyPressed(I))return!0;return!1}return(e=this.keysPressed[A])==null?void 0:e.pressed}getCodeForCommonKeyName(A){if(A.length===1){if(A>="0"&&A<="9")return["Digit"+A];if(A>="a"&&A<="z")return["Key"+A.toUpperCase()];if(A==" ")return["Space"]}switch(A){case"shift":case"Shift":return["ShiftLeft","ShiftRight"];case"control":case"Control":return["ControlLeft","ControlRight"];case"alt":case"Alt":return["AltLeft","AltRight"]}return null}createInputEvent(A){switch(A.type){case"pointerdown":Dg&&Ci("Create Pointer down"),this.onDownButton(A.deviceIndex,A.button),this.onDown(A);break;case"pointermove":Dg&&Ci("Create Pointer move"),this.onMove(A);break;case"pointerup":Dg&&Ci("Create Pointer up"),this.onUp(A),this.onReleaseButton(A.deviceIndex,A.button);break}}convertScreenspaceToRaycastSpace(A){return A.x=(A.x-this.context.domX)/this.context.domWidth*2-1,A.y=-((A.y-this.context.domY)/this.context.domHeight)*2+1,A}bindEvents(){this.unbindEvents(),this._htmlEventSource=this.context.renderer.domElement,window.addEventListener("contextmenu",this.onContextMenu),this._htmlEventSource.addEventListener("pointerdown",this.onPointerDown,{passive:!0}),window.addEventListener("pointermove",this.onPointerMove,{passive:!0,capture:!0}),window.addEventListener("pointerup",this.onPointerUp,{passive:!0}),window.addEventListener("pointercancel",this.onPointerCancel,{passive:!0}),window.addEventListener("touchstart",this.onTouchStart,{passive:!0}),window.addEventListener("touchmove",this.onTouchMove,{passive:!0}),window.addEventListener("touchend",this.onTouchEnd,{passive:!0}),this._htmlEventSource.addEventListener("wheel",this.onMouseWheel,{passive:!0}),window.addEventListener("wheel",this.onWheelWindow,{passive:!0}),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keypress",this.onKeyPressed,!1),window.addEventListener("keyup",this.onKeyUp,!1),window.addEventListener("blur",this.onLostFocus)}unbindEvents(){var A,e;window.removeEventListener("contextmenu",this.onContextMenu),(A=this._htmlEventSource)==null||A.removeEventListener("pointerdown",this.onPointerDown),window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerCancel),(e=this._htmlEventSource)==null||e.removeEventListener("wheel",this.onMouseWheel,!1),window.removeEventListener("wheel",this.onWheelWindow,!1),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keypress",this.onKeyPressed,!1),window.removeEventListener("keyup",this.onKeyUp,!1),window.removeEventListener("blur",this.onLostFocus)}dispose(){const A=this.context.post_render_callbacks.indexOf(this.onEndOfFrame);A>=0&&this.context.post_render_callbacks.splice(A,1),this.unbindEvents()}canReceiveInput(A){var e;return A.target===((e=this.context.renderer)==null?void 0:e.domElement)||A.target===this.context.domElement||this.context.isInAR||this.context.isInAR&&A.target===document.body&&JQ()?!0:(Dg&&console.warn("CanReceiveInput:False for",A.target),!1)}getPointerId(A,e){return A.pointerType==="mouse"?0+(e??A.button):this.getPointerIndex(A.pointerId)}getButtonName(A){const e=A.button;if(A.pointerType==="mouse")switch(e){case 0:return"left";case 1:return"middle";case 2:return"right"}return"unknown"}getAndUpdateSpatialObjectForScreenPosition(A,e,g){let I=this._pointerSpace[A];I||(I=new wA,this._pointerSpace[A]=I),this._pointerSpace[A]=I;const o=this.context.mainCamera;if(o){const s=this.tempNearPlaneVector.set(e,g,-1);this.convertScreenspaceToRaycastSpace(s);const n=this.tempFarPlaneVector.set(s.x,s.y,1);s.unproject(o),n.unproject(o);const a=o.worldUp||lt(0,1,0).applyQuaternion(Nt(o));this.tempLookMatrix.lookAt(n,s,a),I.position.set(s.x,s.y,s.z),I.quaternion.setFromRotationMatrix(this.tempLookMatrix)}return I}isInRect(A){if(this.context.isInXR)return!0;const e=this.context.domElement.getBoundingClientRect(),g=A.clientX,I=A.clientY,o=g>=e.x&&g<=e.right&&I>=e.y&&I<=e.bottom;return Dg&&!o&&console.log("Not in rect",e,g,I),o}onDown(A){const e=A.pointerId;if(this.getPointerPressed(e)&&console.warn(`pointerId is already pressed: ${e}`,Dg?A:""),Dg&&console.log(A.pointerType,"DOWN",e),!!this.isInRect(A)){for(this.setPointerState(e,this._pointerPressed,!0),this.setPointerState(e,this._pointerDown,!0),this.setPointerStateT(e,this._pointerEvent,A.source);e>=this._pointerTypes.length;)this._pointerTypes.push(A.pointerType);for(this._pointerTypes[e]=A.pointerType;e>=this._pointerPositionDown.length;)this._pointerPositionDown.push(new AA);for(this._pointerPositionDown[e].set(A.clientX,A.clientY);e>=this._pointerPositions.length;)this._pointerPositions.push(new AA);this._pointerPositions[e].set(A.clientX,A.clientY),e>=this._pointerDownTime.length&&this._pointerDownTime.push(0),this._pointerDownTime[e]=this.context.time.time,this.updatePointerPosition(A),this.onDispatchEvent(A)}}onMove(A){const e=A.pointerId,g=this.getPointerPressed(e);g===!1&&!this.isInRect(A)||A.pointerType==="touch"&&!g||(this.updatePointerPosition(A),this.setPointerStateT(e,this._pointerEvent,A.source),this.onDispatchEvent(A))}onUp(A){const e=A.pointerId;if(!this.getPointerPressed(e)){Dg&&console.log(A.pointerType,"UP",e,"was not down");return}for(Dg&&console.log(A.pointerType,"UP",e),this.setPointerState(e,this._pointerPressed,!1),this.setPointerStateT(e,this._pointerEvent,A.source),this.setPointerState(e,this._pointerUp,!0);e>=this._pointerUsed.length;)this._pointerUsed.push(!1);if(this.setPointerState(e,this._pointerUsed,!1),this.updatePointerPosition(A),!this._pointerPositionDown[e]){Dg&&Lt("Received pointer up event without matching down event for button: "+e),console.warn("Received pointer up event without matching down event for button: "+e);return}const g=A.clientX-this._pointerPositionDown[e].x,I=A.clientY-this._pointerPositionDown[e].y;if(e>=this._pointerUpTime.length&&this._pointerUpTime.push(-99),Math.abs(g)<5&&Math.abs(I)<5){Dg&&console.log("CLICK",e),this.setPointerState(e,this._pointerClick,!0),A.isClick=!0;const o=this._pointerUpTime[e],s=this.context.time.time-o;s<this._doubleClickTimeThreshold&&s>0&&(this.setPointerState(e,this._pointerDoubleClick,!0),A.isDoubleClick=!0)}this._pointerUpTime[e]=this.context.time.time,this.onDispatchEvent(A)}updatePointerPosition(A){const e=A.pointerId;for(;e>=this._pointerPositions.length;)this._pointerPositions.push(new AA);for(;e>=this._pointerPositionsLastFrame.length;)this._pointerPositionsLastFrame.push(new AA);for(;e>=this._pointerPositionsDelta.length;)this._pointerPositionsDelta.push(new AA);const g=this._pointerPositionsLastFrame[e];g.copy(this._pointerPositions[e]);const I=this._pointerPositionsDelta[e];let o=A.clientX-g.x,s=A.clientY-g.y;if(A.source instanceof MouseEvent||A.source instanceof TouchEvent){const C=A.source;o===0&&C.movementX!==0&&(o=C.movementX||0),s===0&&C.movementY!==0&&(s=C.movementY||0)}I.x+=o,I.y+=s,this._pointerPositions[e].x=A.clientX,this._pointerPositions[e].y=A.clientY;const n=A.clientX,a=A.clientY;for(;e>=this._pointerPositionsRC.length;)this._pointerPositionsRC.push(new AA);const r=this._pointerPositionsRC[e];r.set(n,a),this.convertScreenspaceToRaycastSpace(r)}getPointerIndex(A){let e=-1;for(let g=0;g<this._pointerIds.length;g++){if(this._pointerIds[g]===A)return g;e===-1&&this._pointerIds[g]===-1&&(e=g)}return e!==-1?(this._pointerIds[e]=A,e):(Dg&&console.log("PUSH pointerId:",A),this._pointerIds.push(A),this._pointerIds.length-1)}setPointerState(A,e,g){e[A]=g}setPointerStateT(A,e,g){return e[A]=g,g}onDispatchEvent(A){const e=Ke.Current;try{Ke.Current=this.context,this.dispatchEvent(A)}finally{Ke.Current=e}}}const JS=new DA().makeRotationY(Math.PI),vs=new GA().setFromAxisAngle(new S(0,1,0),Math.PI),AQA=iA("debugwebxr");class eQA{constructor(){if(B(this,"priority",-1e5),B(this,"gameObject"),this.gameObject=new wA,this.gameObject.name="Implicit XR Rig",AQA){const A=MK(16733661);A.position.y+=.5,this.gameObject.add(A)}}isXRRig(){return!0}get isActive(){return this.gameObject.visible}}const iB=iA("debugwebxr"),xS=iA("debugcustomgesture"),tQA="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",iQA="generic-trigger";class RK{constructor(A,e,g){B(this,"xr"),B(this,"inputSource"),B(this,"index",0),B(this,"emitEvents",!0),B(this,"_connected",!0),B(this,"_isTracking",!1),B(this,"_hitTestSource"),B(this,"_hasSelectEvent",!1),B(this,"_handJointPoses",new Map),B(this,"_gripPosition",new S),B(this,"_gripQuaternion",new GA),B(this,"_linearVelocity",new S),B(this,"_rayPosition",new S),B(this,"_rayQuaternion",new GA),B(this,"_gripWorldPosition",new S),B(this,"_gripWorldQuaternion",new GA),B(this,"_rayWorldPosition",new S),B(this,"_rayWorldQuaternion",new GA),B(this,"_ray"),B(this,"_object"),B(this,"model",null),B(this,"_debugAxesHelper",new _o(.2)),B(this,"onPointerHits",n=>{}),B(this,"_needleGamepadButtons",{}),B(this,"_buttonMap",new Map),B(this,"_motioncontroller"),B(this,"_layout"),B(this,"getMotionController"),B(this,"_selectButtonIndex"),B(this,"_squeezeButtonIndex"),B(this,"onSelectStart",n=>{var a,r,C,Q;if(this.inputSource!==n.inputSource)return;this.onUpdateFrame(n.frame),this._hasSelectEvent=!0;const h=(a=this._layout)==null?void 0:a.selectComponentId,E=(Q=(C=(r=this._layout)==null?void 0:r.components[h])==null?void 0:C.gamepadIndices)==null?void 0:Q.button;E!==void 0&&(this._selectButtonIndex=E),!xS&&(iB&&pe.DrawDirection(this.rayWorldPosition,lt(0,.01,1).applyQuaternion(this.rayWorldQuaternion),16711680,10),this.emitPointerEvent(hi.PointerDown,this._selectButtonIndex||0,"xr-standard-trigger",!0,n))}),B(this,"onSelectEnd",n=>{xS||this.inputSource===n.inputSource&&this.emitPointerEvent(hi.PointerUp,this._selectButtonIndex||0,"xr-standard-trigger",!0,n)}),B(this,"onSequeezeStart",n=>{var a,r,C;this.inputSource===n.inputSource&&(this._squeezeButtonIndex=(C=(r=(a=this._layout)==null?void 0:a.components["xr-standard-squeeze"])==null?void 0:r.gamepadIndices)==null?void 0:C.button,this._squeezeButtonIndex!==void 0&&(iB&&pe.DrawDirection(this.rayWorldPosition,lt(0,.01,1).applyQuaternion(this.rayWorldQuaternion),255,10),this.emitPointerEvent(hi.PointerDown,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,n)))}),B(this,"onSequeezeEnd",n=>{this.inputSource===n.inputSource&&this._squeezeButtonIndex!==void 0&&this.emitPointerEvent(hi.PointerUp,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,n)}),B(this,"states",{}),B(this,"_didMoveLastFrame",!1),B(this,"_lastPointerMovePosition",new S),B(this,"_lastPointerMoveQuaternion",new GA),B(this,"pointerInit");var I,o,s;this.xr=A,this.inputSource=e,this.index=g,this._object=new wA,iB&&this._object.add(this._debugAxesHelper),this.xr.context.scene.add(this._object),this._ray=new po,this.pointerInit={origin:this,pointerType:this.hand?"hand":"controller",deviceIndex:this.index,pointerId:-1,mode:this.inputSource.targetRayMode,ray:this._ray,device:this._object,buttonName:"none"},this.initialize(),this.subscribeEvents(),this.xr.mode==="immersive-ar"&&this.inputSource.targetRayMode==="tracked-pointer"&&((s=(o=(I=this.xr.session).requestHitTestSourceForTransientInput)==null?void 0:o.call(I,{profile:this.inputSource.profiles[0],offsetRay:new XRRay}))==null||s.then(n=>this._hitTestSource=n))}get context(){return this.xr.context}get connected(){return this._connected}get isTracking(){return this._isTracking}get gamepad(){return this.inputSource.gamepad}get isHand(){return this.inputSource.hand!=null}get hand(){return this.inputSource.hand}get handObject(){return this.context.renderer.xr.getHand(this.index)}get profiles(){return this.inputSource.profiles}get layout(){return this._layout}get targetRayMode(){return this.inputSource.targetRayMode}get targetRaySpace(){return this.inputSource.targetRaySpace}get gripSpace(){return this.inputSource.gripSpace}get side(){return this.inputSource.handedness}get isRight(){return this.side==="right"}get isLeft(){return this.side==="left"}get hitTestSource(){return this._hitTestSource}get hasSelectEvent(){return this._hasSelectEvent}getHitTest(){return this.xr.getHitTest(this)}getHandJointPose(A){var e,g;if(!this.hand||!((e=this.xr.frame)!=null&&e.getJointPose)||!this.xr.referenceSpace)return null;let I=(g=this._handJointPoses)==null?void 0:g.get(A);return I||(I=this.xr.frame.getJointPose(A,this.xr.referenceSpace),I&&this._handJointPoses.set(A,I),I)}get gripPosition(){return lt(this._gripPosition).applyMatrix4(JS)}get gripQuaternion(){return _Q(this._gripQuaternion).premultiply(vs)}get gripLinearVelocity(){return lt(this._linearVelocity).applyQuaternion(vs)}get rayPosition(){return lt(this._rayPosition).applyMatrix4(JS)}get rayQuaternion(){return _Q(this._rayQuaternion).premultiply(vs)}get gripWorldPosition(){return lt(this._gripWorldPosition)}get gripWorldQuaternion(){return _Q(this._gripWorldQuaternion)}get rayWorldPosition(){return lt(this._rayWorldPosition)}updateRayWorldPosition(){var A;const e=(A=this.xr.context.mainCamera)==null?void 0:A.parent;this._rayWorldPosition.copy(this._rayPosition),e&&this._rayWorldPosition.applyMatrix4(e.matrixWorld)}get rayWorldQuaternion(){return _Q(this._rayWorldQuaternion)}updateRayWorldQuaternion(){var A;const e=(A=this.xr.context.mainCamera)==null?void 0:A.parent,g=e?Nt(e):void 0;this._rayWorldQuaternion.copy(this._rayQuaternion).multiply(vs),g&&this._rayWorldQuaternion.premultiply(g)}get ray(){return this._ray.origin.copy(this.rayWorldPosition),this._ray.direction.copy(lt(0,0,1).applyQuaternion(this.rayWorldQuaternion)),this._ray}get object(){return this._object}async getModelUrl(){var A;return(A=this.getMotionController)==null?void 0:A.then(e=>e?.assetUrl||null)}onUpdate(A){this.onUpdateFrame(A),this.updateInputEvents(),this.onUpdateMove()}onRenderDebug(){var A;pe.DrawWireSphere(this.rayWorldPosition,.02),pe.DrawDirection(this.rayWorldPosition,lt(0,0,10).applyQuaternion(this.rayWorldQuaternion));const e=this.gripWorldPosition.sub(this.object.worldForward.multiplyScalar(.1)),g=this.inputSource.profiles.join(`
5152
5152
  `);let I=`Controller[${this.index}] ${this.side}
5153
5153
  C:${this.connected?"yes":"no"} T:${this.isTracking?"yes":"no"} Hand:${this.inputSource.hand?"yes":"no"}`;this.inputSource.hand&&(I+=`
5154
5154
  Pinch: ${(A=this.getGesture("pinch"))==null?void 0:A.value.toFixed(3)}`),I+=`
@@ -7586,7 +7586,7 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor)
7586
7586
  outputColor = sharp;
7587
7587
  }
7588
7588
 
7589
- `;class KZ extends go{constructor(){super("Sharpening",swA,{vertexShader:owA,blendFunction:He.NORMAL,uniforms:new Map([["amount",new MA(1)],["radius",new MA(1)]])})}}const AE=iA("debugpost"),yx=Symbol("needle:postprocessing-handler"),mx=Symbol("needle:previous-autoclear-state");class Vk{constructor(A){B(this,"_composer",null),B(this,"_lastVolumeComponents"),B(this,"_effects",[]),B(this,"_isActive",!1),B(this,"context"),this.context=A}get isActive(){return this._isActive}get composer(){return this._composer}apply(A){this._isActive=!0,this.onApply(this.context,A)}unapply(){var A;if(AE&&console.log("Unapplying postprocessing effects"),this._isActive=!1,this._lastVolumeComponents){for(const g of this._lastVolumeComponents)g.unapply();this._lastVolumeComponents.length=0}const e=this.context;e[yx]===this&&delete e[yx],e.composer===this._composer&&((A=e.composer)==null||A.dispose(),e.composer=null),typeof e.renderer[mx]=="boolean"&&(e.renderer.autoClear=e.renderer[mx])}dispose(){this.unapply();for(const A of this._effects)A.dispose();this._effects.length=0,this._composer=null}onApply(A,e){if(!e)return;A[yx]=this,AE&&console.log("refreshing volume profile",e),this._lastVolumeComponents=[...e],this._effects.length=0;const g={handler:this,components:this._lastVolumeComponents};for(let I=0;I<this._lastVolumeComponents.length;I++){const o=this._lastVolumeComponents[I];if(o.context=A,o.apply){if(o.active){if(!A.mainCameraComponent){console.error("No camera in scene found or available yet - can not create postprocessing effects");return}const s=o.apply(g);if(!s)continue;Array.isArray(s)?this._effects.push(...s):this._effects.push(s)}}else o.active&&Lt("Volume component is not a VolumeComponent: "+o.__type)}if(this.context.renderer.toneMapping!=OI&&!this._effects.find(I=>I instanceof fS)){const I=new fS;this._effects.push(I)}this.applyEffects(A)}applyEffects(A){const e=this._effects;if(e.length<=0)return;const g=A.mainCameraComponent,I=A.renderer,o=A.scene,s=g.cam;I[mx]=I.autoClear;const n=I.capabilities.maxSamples;this._composer||(this._composer=new aK(I,{frameBufferType:cg,stencilBuffer:!0,multisampling:Math.min(ls()?4:8,n)})),A.composer&&A.composer!==this._composer&&console.warn("There's already an active EffectComposer in your scene: replacing it with a new one. This might cause unexpected behaviour. Make sure to only use one PostprocessingManager/Volume in your scene."),A.composer=this._composer;const a=A.composer;a.setMainCamera(s),a.setRenderer(I),a.setMainScene(o);for(const C of a.passes)C.dispose();a.removeAllPasses();const r=new SS(o,s);r.name="Render To Screen",r.mainScene=o,a.addPass(r);try{this.orderEffects();const C=[];for(const Q of e)if(Q instanceof go)C.push(Q);else if(Q instanceof AI){const h=new t4(s,...C);h.mainScene=o,h.name=C.map(E=>E.constructor.name).join(", "),h.enabled=!0,C.length=0,a.addPass(Q)}if(C.length>0){const Q=new t4(s,...C);Q.name=C.map(h=>h.name).join(" "),Q.mainScene=o,Q.enabled=!0,a.addPass(Q)}}catch(C){console.error("Error while applying postprocessing effects",C),a.removeAllPasses()}AE&&console.log("PostProcessing Passes",e,"->",a.passes)}orderEffects(){var A;AE&&console.log("Before ordering effects",[...this._effects]);const e=this._effects;e.sort((g,I)=>{const o=Sx.findIndex(n=>g.constructor.name.endsWith(n.name)),s=Sx.findIndex(n=>I.constructor.name.endsWith(n.name));return o<0?(AE&&console.warn("Unknown effect found: ",g.constructor.name),-1):s<0?(AE&&console.warn("Unknown effect found: ",I.constructor.name),1):o<0?1:s<0?-1:o-s}),AE&&console.log("After ordering effects",[...this._effects]);for(let g=0;g<e.length;g++){const I=e[g];if(((A=I?.configuration)==null?void 0:A.gammaCorrection)!==void 0){const o=g===e.length-1;I.configuration.gammaCorrection=o}}}}const Sx=[i4,hK,zP,XP,FZ,$P,HP,_P,BK,jP,A4,PP,fS,OP,LP,KZ];async function fx(i){const{NeedleEngineHTMLElement:A}=await Promise.resolve().then(()=>HyA);A.observedAttributes.includes(i)||A.observedAttributes.push(i)}var nwA=Object.defineProperty,awA=Object.getOwnPropertyDescriptor,Qw=(i,A,e,g)=>{for(var I=g>1?void 0:g?awA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&nwA(A,e,I),I};const Ws=iA("debugskybox");fx("skybox-image"),fx("environment-image");function bZ(i,A,e,g,I){const o=new xa;o.allowDrop=!1,o.allowNetworking=!1,o.background=e,o.environment=g,gA.addComponent(i.scene,o);const s=n=>{typeof n=="string"&&(Ws&&console.log(I,"CHANGED TO",n),o.setSkybox(n))};return F2(i.domElement,I,s),o.addEventListener("destroy",()=>{Ws&&console.log("Destroyed attribute remote skybox",I),v2(i.domElement,I,s)}),o.setSkybox(A)}Qt.addContextCreatedCallback(i=>{var A;const e=i.context,g=e.domElement.getAttribute("skybox-image"),I=e.domElement.getAttribute("environment-image"),o=new Array;if(g){Ws&&console.log("Creating remote skybox to load "+g),((A=e.mainCameraComponent)==null?void 0:A.clearFlags)!==dB.Skybox&&console.warn('"skybox-image" attribute has no effect: camera clearflags are not set to "Skybox"');const s=bZ(e,g,!0,!1,"skybox-image");o.push(s)}if(I){Ws&&console.log("Creating remote environment to load "+I);const s=bZ(e,I,!1,!0,"environment-image");o.push(s)}return o.length>0?Y0(o):Promise.resolve()});function JZ(){return globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES||(globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES=new Array),globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES}function xZ(i){const A=JZ().find(e=>e.src===i);return A?(Ws&&console.log("Skybox: Found previously loaded texture for "+i),A.texture):null}async function rwA(i){const A=await i;Vv(A,!0),Vt(A)}function CwA(i,A){const e=JZ();for(;e.length>5;){const g=e.shift();g&&rwA(g.texture)}A.then(g=>Vv(g,!1)),e.push({src:i,texture:A})}class xa extends bA{constructor(){super(...arguments),B(this,"url"),B(this,"allowDrop",!0),B(this,"background",!0),B(this,"environment",!0),B(this,"allowNetworking",!0),B(this,"_loader"),B(this,"_prevUrl"),B(this,"_prevLoadedEnvironment"),B(this,"_prevEnvironment",null),B(this,"_prevBackground",null),B(this,"validTextureTypes",[".hdr",".exr",".jpg",".jpeg",".png"]),B(this,"onDragOverEvent",A=>{if(this.allowDrop&&A.dataTransfer)for(const e of A.dataTransfer.types)(e==="text/uri-list"||e==="Files")&&A.preventDefault()}),B(this,"onDrop",A=>{var e,g,I,o;if(this.allowDrop&&A.dataTransfer){for(const s of A.dataTransfer.types)if(Ws&&console.log(s),s==="text/uri-list"){const n=A.dataTransfer.getData(s);Ws&&console.log(s,n);let a=(g=(e=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(n))==null?void 0:e.groups)==null?void 0:g.name;if(a||(a=(o=(I=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(n))==null?void 0:I.groups)==null?void 0:o.name),Ws&&console.log(a),a){const r="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+a+"_1k.exr";console.log(`[Remote Skybox] Setting skybox from url: ${r}`),A.preventDefault(),this.setSkybox(r);break}else if(this.isValidTextureType(n)){console.log("[Remote Skybox] Setting skybox from url: "+n),A.preventDefault(),this.setSkybox(n);break}else{console.warn(`[RemoteSkybox] Unknown url ${n}. If you want to load a skybox from a url, make sure it is a valid image url. Url must end with${this.validTextureTypes.join(", ")}.`);const r=new CustomEvent("dropped-unknown-url",{detail:{sender:this,event:A,url:n,apply:C=>{A.preventDefault(),this.setSkybox(C)}}});this.dispatchEvent(r)}}else if(s=="Files"){const n=A.dataTransfer.files.item(0);if(Ws&&console.log(s,n),!n)continue;if(!this.isValidTextureType(n.name)){console.warn(`[RemoteSkybox]: File "${n.name}" is not supported. Supported files are ${this.validTextureTypes.join(", ")}`);return}if(xZ(n.name)===null){const a=new Blob([n]),r=URL.createObjectURL(a);A.preventDefault(),this.setSkybox(r,n.name)}else A.preventDefault(),this.setSkybox(n.name);break}}})}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var A;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Tt.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(A=this.context.mainCameraComponent)==null||A.applyClearFlags()}urlChangedSyncField(){this.allowNetworking&&this.url&&this.isRemoteTexture(this.url)&&this.setSkybox(this.url)}async setSkybox(A,e){var g;if(!this.activeAndEnabled||(A=BwA(A,this.environment,this.background),!A))return!1;if(e??(e=A),this.isValidTextureType(e)||console.warn("Potentially invalid skybox url",e,"on",this.name),Ws&&console.log("Set remote skybox url: "+A),this._prevUrl===A&&this._prevLoadedEnvironment)return this.applySkybox(),!0;(g=this._prevLoadedEnvironment)==null||g.dispose(),this._prevLoadedEnvironment=void 0,this._prevUrl=A;const I=await this.loadTexture(A,e);if(!I||!this.enabled)return!1;this.url=A;const o=A.lastIndexOf("/");return I.name=A.substring(o>=0?o+1:0),this._loader instanceof Zn&&(I.colorSpace=Ee),this._prevLoadedEnvironment=I,this.applySkybox(),!0}async loadTexture(A,e){var g,I,o,s,n;if(!A)return Promise.resolve(null);e??(e=A);const a=xZ(e);if(a){const h=await a;if(((I=(g=h.source)==null?void 0:g.data)==null?void 0:I.length)>0||(n=(s=(o=h.source)==null?void 0:o.data)==null?void 0:s.data)!=null&&n.length)return h}const r=e.endsWith(".exr"),C=e.endsWith(".hdr");r?this._loader instanceof Lp||(this._loader=new Lp):C?this._loader instanceof $S||(this._loader=new $S):this._loader instanceof Zn||(this._loader=new Zn),Ws&&console.log("Loading skybox: "+A);const Q=this._loader.loadAsync(A);return CwA(e,Q),await Q}applySkybox(){var A;const e=this._prevLoadedEnvironment;e&&(e.mapping=pE,e.needsUpdate=!0,this.context.scene.background!==e&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==e&&(this._prevEnvironment=this.context.scene.environment),Ws&&console.log("Set remote skybox",this.url,!Tt.backgroundShouldBeTransparent(this.context)),this.environment&&(this.context.scene.environment=e),this.background&&!Tt.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=e),((A=this.context.mainCameraComponent)==null?void 0:A.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}isRemoteTexture(A){return A.startsWith("http://")||A.startsWith("https://")}isValidTextureType(A){for(const e of this.validTextureTypes)if(A.endsWith(e))return!0;return!1}registerDropEvents(){this.unregisterDropEvents(),this.context.domElement.addEventListener("dragover",this.onDragOverEvent),this.context.domElement.addEventListener("drop",this.onDrop)}unregisterDropEvents(){this.context.domElement.removeEventListener("dragover",this.onDragOverEvent),this.context.domElement.removeEventListener("drop",this.onDrop)}}Qw([qb(xa.prototype.urlChangedSyncField),y(URL)],xa.prototype,"url",2),Qw([y()],xa.prototype,"allowDrop",2),Qw([y()],xa.prototype,"background",2),Qw([y()],xa.prototype,"environment",2),Qw([y()],xa.prototype,"allowNetworking",2);function BwA(i,A,e){const g=A&&!e;switch(i?.toLowerCase()){case"studio":return g?"https://cdn.needle.tools/static/skybox/modelviewer-Neutral-small.hdr":"https://cdn.needle.tools/static/skybox/modelviewer-Neutral.hdr";case"blurred-skybox":return g?"https://cdn.needle.tools/static/skybox/blurred-skybox-small.exr":"https://cdn.needle.tools/static/skybox/blurred-skybox.exr";case"quicklook-ar":return g?"https://cdn.needle.tools/static/skybox/QuickLook-ARMode-small.exr":"https://cdn.needle.tools/static/skybox/QuickLook-ARMode.exr";case"quicklook":return g?"https://cdn.needle.tools/static/skybox/QuickLook-ObjectMode-small.exr":"https://cdn.needle.tools/static/skybox/QuickLook-ObjectMode.exr"}return i===void 0?null:i}var QwA=Object.defineProperty,hwA=Object.getOwnPropertyDescriptor,gs=(i,A,e,g)=>{for(var I=g>1?void 0:g?hwA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&QwA(A,e,I),I};const Is=iA("debugsceneswitcher"),Xk="scene";fx(Xk);const HB=Promise.resolve(!1);class HI extends bA{constructor(){super(...arguments),B(this,"autoLoadFirstScene",!0),B(this,"scenes",[]),B(this,"loadingScene"),B(this,"queryParameterName","scene"),B(this,"useSceneName",!0),B(this,"clamp",!0),B(this,"useHistory",!0),B(this,"useKeyboard",!0),B(this,"useSwipe",!0),B(this,"useSceneLighting",!0),B(this,"preloadNext",1),B(this,"preloadPrevious",1),B(this,"preloadConcurrent",2),B(this,"_currentIndex",-1),B(this,"_currentScene"),B(this,"_engineElementOverserver"),B(this,"_preloadScheduler"),B(this,"onPopState",async A=>{if(!this.useHistory)return;const e=this.useHistory;try{this.useHistory=!1;let g=!1;if(this.queryParameterName&&(g=await this.tryLoadFromQueryParam()),!g){const I=A?.state;if(I&&I.startsWith(this.guid)){const o=I.substr(this.guid.length+2);Is&&console.log("PopState",o),await this.trySelectSceneFromValue(o)}}}finally{this.useHistory=e}}),B(this,"normalizedSwipeThresholdX",.1),B(this,"_didSwipe",!1),B(this,"onInputPointerMove",A=>{if(this.useSwipe&&!this._didSwipe&&A.button===0&&A.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const e=this.context.input.getPointerPositionDelta(A.button);if(e){const g=e.x/this.context.domWidth;g>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):g<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}}),B(this,"onInputPointerUp",A=>{A.button===0&&(this._didSwipe=!1)}),B(this,"onInputKeyDown",A=>{if(!this.useKeyboard||!this.scenes)return;const e=A.key.toLowerCase();if(!e)return;const g=parseInt(e)-1;if(g>=0){this.trySelectSceneFromValue(g);return}switch(e){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}}),B(this,"__lastSwitchScene"),B(this,"__lastSwitchScenePromise"),B(this,"_currentlyLoadingScene"),B(this,"_lastLoadingScene"),B(this,"_loadingScenePromise"),B(this,"_isCurrentlyLoading",!1),B(this,"_currentLoadingProgress")}get currentIndex(){return this._currentIndex}get currentLoadingProgress(){return this._currentLoadingProgress}get currentlyLoadingScene(){return this._currentlyLoadingScene}get currentlyLoadedScene(){return this._currentScene}awake(){this.scenes===void 0&&(this.scenes=[]);for(const A of this.scenes)A&&!A.hasUrl&&A.asset instanceof wA&&A.asset.removeFromParent();Is&&console.log("SceneSwitcher",this)}async onEnable(){if(globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(hi.KeyDown,this.onInputKeyDown),this.context.input.addEventListener(hi.PointerMove,this.onInputPointerMove),this.context.input.addEventListener(hi.PointerUp,this.onInputPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(A=>{for(const e of A)if(e.type==="attributes"&&e.attributeName===Xk){const g=this.context.domElement.getAttribute(Xk);g!==null&&this.trySelectSceneFromValue(g)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new EwA(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin(),this.autoLoadFirstScene&&this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const A=this.context.domElement.getAttribute(Xk);try{(A===null||!await this.trySelectSceneFromValue(A))&&this._currentIndex===-1&&this.select(0)}finally{}}}onDisable(){var A;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(hi.KeyDown,this.onInputKeyDown),this.context.input.removeEventListener(hi.PointerMove,this.onInputPointerMove),this.context.input.removeEventListener(hi.PointerUp,this.onInputPointerUp),(A=this._preloadScheduler)==null||A.stop()}addScene(A){if(typeof A=="string"){let e=this.context.addressables.findAssetReference(A);return e||(e=new gt(A),this.context.addressables.registerAssetReference(e)),this.scenes.push(e),e}return this.scenes.push(A),A}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(A){var e,g,I;if(Is&&console.log("select",A),typeof A=="object"&&console.warn('Switching to "'+A+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof A=="string"){const s=(e=this.scenes)==null?void 0:e.find(n=>n.uri===A);if(!s){const n=gt.getOrCreate(this.sourceId??"",A,this.context);return this.switchScene(n)}if(s)A=(g=this.scenes)==null?void 0:g.indexOf(s);else return HB}if(!((I=this.scenes)!=null&&I.length))return HB;if(A<0){if(this.clamp)return HB;A=this.scenes.length-1}else if(A>=this.scenes.length){if(this.clamp)return HB;A=0}const o=this.scenes[A];return this.switchScene(o)}async switchScene(A){if(!(A instanceof gt)){const e=typeof A;return e==="string"?this.select(A):e==="number"?this.select(A):(console.warn("SceneSwitcher: Can't switch to scene",A,"of type",e),!1)}return A.uri===this.sourceId?(console.warn("SceneSwitcher: can't load own scene - prevent recursive loading",this.sourceId),!1):this.__lastSwitchScene===A&&this.__lastSwitchScenePromise?this.__lastSwitchScenePromise:(this.__lastSwitchScene=A,this.__lastSwitchScenePromise=this.__internalSwitchScene(A),await this.__lastSwitchScenePromise)}async __internalSwitchScene(A){var e,g;if(this._currentScene){Is&&console.log("UNLOAD",A.uri);const o=this.tryGetSceneEventListener(this._currentScene.asset);if(o!=null&&o.sceneClosing){const s=o.sceneClosing();s instanceof Promise&&await s}this._currentScene.hasUrl?this._currentScene.unload():this._currentScene.asset instanceof wA&&this._currentScene.asset.removeFromParent()}this._currentScene=void 0;const I=this._currentIndex=((e=this.scenes)==null?void 0:e.indexOf(A))??-1;try{this._currentlyLoadingScene=A,this._currentLoadingProgress=new ProgressEvent("progress",{loaded:0,total:1});const o=new CustomEvent("loadscene-start",{detail:{scene:A,switcher:this,index:I}});this.dispatchEvent(o),await this.onStartLoading(),await A.loadAssetAsync((n,a)=>{this._currentLoadingProgress=a,this.dispatchEvent(a)}).catch(console.error),await this.onEndLoading();const s=new CustomEvent("loadscene-finished",{detail:{scene:A,switcher:this,index:I}});if(this.dispatchEvent(s),this._currentLoadingProgress=void 0,this._currentlyLoadingScene=void 0,s.defaultPrevented)return Is&&console.warn("Adding loaded scene prevented:",A,s),!1;if(!A.asset)return Is&&console.warn("Failed loading scene:",A),!1;if(this._currentIndex===I){if(Is&&console.log("ADD",A.uri),this._currentScene=A,gA.add(A.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(A),this.useHistory&&I>=0){let r=I.toString();if(this.useSceneName&&(r=qZ(A.uri)),(g=this.queryParameterName)!=null&&g.length)x0(this.queryParameterName,r,this.useHistory);else{const C=history.state,Q=this.guid+"::"+I;C!==Q&&history.pushState(Q,"unused",location.href)}}const n=this.tryGetSceneEventListener(A.asset);if(n!=null&&n.sceneOpened){const r=n.sceneOpened(this);r instanceof Promise&&await r}const a=new CustomEvent("scene-opened",{detail:{scene:A,switcher:this,index:I}});return this.dispatchEvent(a),!0}}catch(o){console.error(o)}return!1}preload(A){if(A>=0&&A<this.scenes.length){const e=this.scenes[A];if(e instanceof gt)return e.preload()}return HB}tryLoadFromQueryParam(){var A;if(!((A=this.queryParameterName)!=null&&A.length))return HB;const e=iA(this.queryParameterName);return typeof e=="boolean"?HB:this.trySelectSceneFromValue(e)}trySelectSceneFromValue(A){if(typeof A=="string"){const e=parseInt(A);if(e>=0&&e<this.scenes.length)return this.select(e);{const g=A.toLowerCase();for(let I=0;I<this.scenes.length;I++){const o=this.scenes[I];if(o&&qZ(o.uri).toLowerCase().includes(g))return this.select(I)}}}else if(typeof A=="number"&&A>=0&&A<this.scenes.length)return this.select(A);return zI()&&console.warn('Can not find scene: "'+A+'"',this),HB}async onStartLoading(){var A,e;if(this._isCurrentlyLoading=!0,this.loadingScene&&(this._lastLoadingScene!==this.loadingScene&&(this._loadingScenePromise=void 0),this._lastLoadingScene=this.loadingScene,this._loadingScenePromise||(this._loadingScenePromise=(A=this.loadingScene)==null?void 0:A.loadAssetAsync()),await this._loadingScenePromise,this._isCurrentlyLoading&&(e=this.loadingScene)!=null&&e.asset)){Is&&console.log("Add loading scene",this.loadingScene.uri,this.loadingScene.asset);const g=this.loadingScene.asset;gA.add(g,this.gameObject);const I=this.tryGetSceneEventListener(g);if(I!=null&&I.sceneOpened){const o=I.sceneOpened(this);o instanceof Promise&&await o}}if(this._isCurrentlyLoading){const g=this.tryGetSceneEventListener(this.gameObject);if(g&&g.sceneOpened){const I=g.sceneOpened(this);I instanceof Promise&&await I}}}async onEndLoading(){var A;if(this._isCurrentlyLoading=!1,(A=this.loadingScene)!=null&&A.asset){Is&&console.log("Remove loading scene",this.loadingScene.uri);const e=this.loadingScene.asset,g=this.tryGetSceneEventListener(e);if(typeof g?.sceneClosing=="function"){const I=g.sceneClosing();I instanceof Promise&&await I}gA.remove(e)}if(!this._isCurrentlyLoading){const e=this.tryGetSceneEventListener(this.gameObject);if(e&&e.sceneClosing){const g=e.sceneClosing();g instanceof Promise&&await g}}}tryGetSceneEventListener(A,e=0){const g=gA.foreachComponent(A,I=>I.sceneClosing?I:void 0);if(e===0&&!g&&A.children.length)for(const I of A.children){const o=this.tryGetSceneEventListener(I,e+1);if(o)return o}return g||null}}gs([y()],HI.prototype,"autoLoadFirstScene",2),gs([y(gt)],HI.prototype,"scenes",2),gs([y(gt)],HI.prototype,"loadingScene",2),gs([y()],HI.prototype,"queryParameterName",2),gs([y()],HI.prototype,"useSceneName",2),gs([y()],HI.prototype,"clamp",2),gs([y()],HI.prototype,"useHistory",2),gs([y()],HI.prototype,"useKeyboard",2),gs([y()],HI.prototype,"useSwipe",2),gs([y()],HI.prototype,"useSceneLighting",2),gs([y()],HI.prototype,"preloadNext",2),gs([y()],HI.prototype,"preloadPrevious",2),gs([y()],HI.prototype,"preloadConcurrent",2);function qZ(i){const A=i.split("/").pop(),e=A?.split(".").shift();return e!=null&&e.length?e:i}class EwA{constructor(A,e=1,g=1,I=2){B(this,"maxLoadAhead"),B(this,"maxLoadBehind"),B(this,"maxConcurrent"),B(this,"_isRunning",!1),B(this,"_switcher"),B(this,"_loadTasks",[]),B(this,"_maxConcurrentLoads",1),this._switcher=A,this.maxLoadAhead=e,this.maxLoadBehind=g,this.maxConcurrent=I}begin(){if(this._isRunning)return;Is&&console.log("Preload begin"),this._isRunning=!0;let A=-1,e,g;const I=this._switcher.scenes,o=setInterval(()=>{if(this.allLoaded()&&(Is&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(o);return}if(this.canLoadNewScene()===!1)return;A!==this._switcher.currentIndex&&(A=this._switcher.currentIndex,g=0,e=0);const s=g%2===0;s&&(e+=1),g+=1;const n=s?this.maxLoadAhead:this.maxLoadBehind;if(e>n)return;const a=s?A+e:A-e;if(a<0||a<0||a>=I.length)return;const r=I[a];new cwA(a,r,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){if(this._switcher.scenes){for(const A of this._switcher.scenes)if(A?.isLoaded()===!1)return!1}return!0}}class cwA{constructor(A,e,g){B(this,"index"),B(this,"asset"),B(this,"tasks"),this.index=A,this.asset=e,this.tasks=g,g.push(this),this.awaitLoading()}async awaitLoading(){this.asset&&!this.asset.isLoaded()&&(Is&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),Is&&console.log("Preload finished: "+this.asset.uri,this.index));const A=this.tasks.indexOf(this);A>=0&&this.tasks.splice(A,1)}}function lwA(){return new Promise((i,A)=>{const e=()=>{e!=null&&(document.removeEventListener("pointerdown",e),document.removeEventListener("click",e),document.removeEventListener("dragstart",e),document.removeEventListener("touchstart",e),i())};document.addEventListener("pointerdown",e),document.addEventListener("click",e),document.addEventListener("dragstart",e),document.addEventListener("touchstart",e)})}async function dwA(i){await lwA(),i()}var uwA=Object.defineProperty,pwA=Object.getOwnPropertyDescriptor,os=(i,A,e,g)=>{for(var I=g>1?void 0:g?pwA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&uwA(A,e,I),I};const Yg=iA("debugvideo");var LZ=(i=>(i[i.None=0]="None",i[i.AdjustHeight=1]="AdjustHeight",i[i.AdjustWidth=2]="AdjustWidth",i))(LZ||{}),_Z=(i=>(i[i.VideoClip=0]="VideoClip",i[i.Url=1]="Url",i))(_Z||{}),TZ=(i=>(i[i.CameraFarPlane=0]="CameraFarPlane",i[i.CameraNearPlane=1]="CameraNearPlane",i[i.RenderTexture=2]="RenderTexture",i[i.MaterialOverride=3]="MaterialOverride",i))(TZ||{});class mg extends bA{constructor(){super(),B(this,"playOnAwake",!0),B(this,"aspectMode",0),B(this,"clip",null),B(this,"source",1),B(this,"_url",null),B(this,"renderMode"),B(this,"targetMaterialProperty"),B(this,"targetMaterialRenderer"),B(this,"targetTexture"),B(this,"time",0),B(this,"_playbackSpeed",1),B(this,"_isLooping",!1),B(this,"_muted",!1),B(this,"_audioOutputMode",2),B(this,"playInBackground",!0),B(this,"_crossOrigin","anonymous"),B(this,"_videoElement",null),B(this,"_videoTexture",null),B(this,"_videoMaterial",null),B(this,"_isPlaying",!1),B(this,"wasPlaying",!1),B(this,"visibilityChanged",A=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}}),B(this,"_receivedInput",!1),B(this,"_overlay",null),B(this,"_targetObjects"),B(this,"_updateAspectRoutineId",-1),B(this,"_hls"),B(this,"onHlsAvailable",()=>{var A;Yg&&console.log("HLS: available",this.clip),!(!this.shouldUseM3U||!this.url)&&(this._hls||(this._hls=new Hls),this.videoElement.autoplay=!0,this._hls.loadSource(this.url),this._hls.attachMedia(this.videoElement),(A=this._videoElement)==null||A.play(),Yg&&console.log("HLS: loaded",this.clip))}),dwA(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],iA("videoscreenspace")&&window.addEventListener("keydown",A=>{A.key==="f"&&(this.screenspace=!this.screenspace)})}get url(){return this._url}set url(A){const e=this._url!==A;this.__didAwake?e&&this.setClipURL(A??""):this._url=A}get playbackSpeed(){var A;return((A=this._videoElement)==null?void 0:A.playbackRate)??this._playbackSpeed}set playbackSpeed(A){this._playbackSpeed=A,this._videoElement&&(this._videoElement.playbackRate=A)}get isLooping(){var A;return((A=this._videoElement)==null?void 0:A.loop)??this._isLooping}set isLooping(A){this._isLooping=A,this._videoElement&&(this._videoElement.loop=A)}get currentTime(){var A;return((A=this._videoElement)==null?void 0:A.currentTime)??this.time}set currentTime(A){this._videoElement?this._videoElement.currentTime=A:this.time=A}get isPlaying(){const A=this._videoElement;return!!(A&&(A.currentTime>0&&!A.paused&&!A.ended&&A.readyState>A.HAVE_CURRENT_DATA||A.srcObject&&A.srcObject.active))}get crossOrigin(){var A;return((A=this._videoElement)==null?void 0:A.crossOrigin)??this._crossOrigin}set crossOrigin(A){this._crossOrigin=A,this._videoElement&&(A!==null?this._videoElement.setAttribute("crossorigin",A):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return!this._videoMaterial&&!this.create(!1)?null:this._videoMaterial}get videoTexture(){return!this._videoTexture&&!this.create(!1)?null:this._videoTexture}get videoElement(){return!this._videoElement&&!this.create(!1)?null:this._videoElement}get muted(){var A;return((A=this._videoElement)==null?void 0:A.muted)??this._muted}set muted(A){this._muted=A,this._videoElement&&(this._videoElement.muted=A)}get currentVideo(){return this.clip}set audioOutputMode(A){A!==this._audioOutputMode&&(A===1&&se()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=A,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}preloadVideo(){Yg&&console.log("Video Preload: "+this.name,this.clip),this.create(!1)}preload(){this.preloadVideo()}setVideo(A){this.clip=A,this.source=0,this._videoElement?(this._videoElement.srcObject=A,this._isPlaying&&this.play(),this.updateAspect()):this.create(this.playOnAwake)}setClipURL(A){this._url!==A&&(this._url=A,this.source=1,Yg&&console.log("set url",A),this._videoElement?A.endsWith(".m3u8")||A.includes(".m3u")?this.ensureM3UCanBePlayed():(this._videoElement.src=A,this._isPlaying&&(this.stop(),this.play())):this.create(this.playOnAwake))}onEnable(){var A,e;Yg&&console.log("VideoPlayer.onEnable",_Z[this.source],this.clip,this.url,this),window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0?this.create(!0):this.preloadVideo(),this.screenspace?(A=this._overlay)==null||A.start():(e=this._overlay)==null||e.stop()}onDisable(){var A;window.removeEventListener("visibilitychange",this.visibilityChanged),(A=this._overlay)==null||A.stop(),this.pause()}onDestroy(){var A;this._videoElement&&((A=this.videoElement)==null||A.remove(),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var A,e;if(this._videoElement||this.create(!1),!this._videoElement){Yg&&console.warn("Can not play: no video element found",this);return}if(!(this._isPlaying&&!((A=this._videoElement)!=null&&A.ended)&&!((e=this._videoElement)!=null&&e.paused))){if(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.handleBeginPlaying(!1),this.shouldUseM3U){this.ensureM3UCanBePlayed();return}Yg&&console.log("Video Play()",this.clip,this._videoElement,this.time),this._videoElement.currentTime=this.time,this._videoElement.play().catch(g=>{var I;console.log(g),Yg&&console.error("Error playing video",g,"CODE="+g.code,(I=this.videoElement)==null?void 0:I.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),Yg&&console.log("play",this._videoElement,this.time)}}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),Yg&&console.log("STOP",this))}pause(){var A,e;this.time=((A=this._videoElement)==null?void 0:A.currentTime)??0,this._isPlaying=!1,(e=this._videoElement)==null||e.pause(),Yg&&console.log("PAUSE",this,this.currentTime)}create(A){let e;switch(this.source){case 0:e=this.clip;break;case 1:e=this.url,!(e!=null&&e.length)&&typeof this.clip=="string"&&(e=this.clip);break}return e?(this._videoElement||(Yg&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),this.context.domElement.shadowRoot.prepend(this._videoElement),this.updateVideoElementStyles()),typeof e=="string"?(Yg&&console.log("Set Video src",e),this._videoElement.src=e):(Yg&&console.log("Set Video srcObject",e),this._videoElement.srcObject=e),this._videoTexture||(this._videoTexture=new pT(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.colorSpace=Ee,A&&this.handleBeginPlaying(A),Yg&&console.log("Video: handle playing done...",e,A),!0):(Yg&&console.warn("No video source set",this),!1)}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var A;return((A=this._overlay)==null?void 0:A.enabled)??!1}set screenspace(A){var e;if(A){if(!this._videoTexture)return;this._overlay||(this._overlay=new DwA(this.context)),this._overlay.add(this._videoTexture)}else(e=this._overlay)==null||e.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=A)}createVideoElement(){const A=document.createElement("video");return this._crossOrigin&&A.setAttribute("crossorigin",this._crossOrigin),Yg&&console.log("created video element",A),A}handleBeginPlaying(A){var e,g;if(!this.activeAndEnabled||!this._videoElement)return;this._targetObjects.length=0;let I=this.gameObject;switch(this.renderMode){case 3:I=(e=this.targetMaterialRenderer)==null?void 0:e.gameObject,I||(I=(g=gA.getComponent(this.gameObject,Ji))==null?void 0:g.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!I){console.error("Missing target for video material renderer",this.name,TZ[this.renderMode],this);return}const o=I.material;if(o){this._targetObjects.push(I),o!==this._videoMaterial&&(this._videoMaterial=o.clone(),I.material=this._videoMaterial);const s="map",n=this._videoMaterial;if(!this.targetMaterialProperty)n[s]=this._videoTexture;else switch(this.targetMaterialProperty){default:n[s]=this._videoTexture;break}}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),A&&(this.shouldUseM3U&&this.ensureM3UCanBePlayed(),this.play())}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let A=!this._receivedInput||this.audioOutputMode===0;!A&&this._muted&&(A=!0),this._videoElement.muted=A,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const A=++this._updateAspectRoutineId,e=void 0,g=this.clip;for(;A===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&g===this.clip&&this._isPlaying;){if(!g||typeof g=="string")return;let I;for(const o of g.getVideoTracks()){const s=o.getSettings();if(s&&s.width&&s.height){I=s.width/s.height;break}else I=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(I===void 0){for(let o=0;o<10;o++)yield;if(!this.isPlaying)break;continue}if(e===I){yield;continue}for(const o of this._targetObjects){let s=1;if(o.parent){const n=zt(o.parent);s=n.x/n.y}switch(this.aspectMode){case 1:o.scale.y=1/I*o.scale.x*s;break;case 2:o.scale.x=I*o.scale.y*s;break}}for(let o=0;o<3;o++)yield}}get shouldUseM3U(){return this.url!=null&&(this.url.endsWith(".m3u8")||this.url.endsWith(".m3u"))&&this.source===1}ensureM3UCanBePlayed(){if(!this.shouldUseM3U)return;let A=document.head.querySelector("script[data-hls_library]");A?globalThis.Hls?this.onHlsAvailable():A.addEventListener("load",this.onHlsAvailable):(Yg&&console.log("HLS: load script"),A=document.createElement("script"),A.dataset.hls_library="hls.js",A.src="https://cdn.jsdelivr.net/npm/hls.js@1",A.addEventListener("load",this.onHlsAvailable),document.head.append(A))}}os([y()],mg.prototype,"playOnAwake",2),os([y()],mg.prototype,"aspectMode",2),os([y(URL)],mg.prototype,"clip",2),os([y()],mg.prototype,"source",2),os([y(URL)],mg.prototype,"url",1),os([y()],mg.prototype,"renderMode",2),os([y()],mg.prototype,"targetMaterialProperty",2),os([y(Ji)],mg.prototype,"targetMaterialRenderer",2),os([y(Te)],mg.prototype,"targetTexture",2),os([y()],mg.prototype,"time",2),os([y()],mg.prototype,"playbackSpeed",1),os([y()],mg.prototype,"isLooping",1),os([y()],mg.prototype,"audioOutputMode",1);class DwA{constructor(A){B(this,"context"),B(this,"_videos",[]),B(this,"_screenspaceModeQuad"),B(this,"_isInScreenspaceMode",!1),B(this,"_input"),this.context=A,this._input=new wwA(this)}get enabled(){return this._isInScreenspaceMode}set enabled(A){A?this.start():this.stop()}add(A){this._videos.indexOf(A)===-1&&this._videos.push(A)}remove(A){if(!A)return;const e=this._videos.indexOf(A);e>=0&&this._videos.splice(e,1)}start(){var A;if(this._isInScreenspaceMode||this._videos.length<0)return;const e=this._videos[this._videos.length-1];if(!e)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=qp.createPrimitive(ch.Quad,{material:new ywA(e)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const g=this._screenspaceModeQuad;this.context.scene.add(g),this.updateScreenspaceMaterialUniforms();const I=g.material;I?.reset(),(A=this._input)==null||A.enable(I)}stop(){var A;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((A=this._input)==null||A.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var A;const e=(A=this._screenspaceModeQuad)==null?void 0:A.material;e&&(e.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class wwA{constructor(A){B(this,"_onResizeScreenFn"),B(this,"_onKeyUpFn"),B(this,"_onMouseWheelFn"),B(this,"context"),B(this,"overlay"),B(this,"_material"),B(this,"_isPinching",!1),B(this,"_lastPinch",0),this.overlay=A,this.context=A.context}enable(A){this._material=A,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=I=>{I.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=I=>{this.overlay.enabled&&(A.zoom+=I.deltaY*5e-4,I.preventDefault())},{passive:!1});const e=new AA;window.addEventListener("mousemove",I=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const o=new AA(I.movementX,I.movementY);o.x/=this.context.domElement.clientWidth,o.y/=this.context.domElement.clientHeight,e.set(o.x,o.y),e.multiplyScalar(A.zoom/-this.context.time.deltaTime*.01),A.offset=A.offset.add(e)}}),window.addEventListener("pointermove",I=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(e.set(I.movementX,I.movementY),e.multiplyScalar(A.zoom*-this.context.time.deltaTime*.05),A.offset=A.offset.add(e))});let g=0;window.addEventListener("touchstart",I=>{if(I.touches.length<2){this.context.time.time-g<.3&&this.overlay.stop(),g=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",I=>{if(!this._isPinching||!this._material)return;const o=I.touches[0],s=I.touches[1],n=o.clientX-s.clientX,a=o.clientY-s.clientY,r=Math.sqrt(n*n+a*a);if(this._lastPinch!==0){const C=r-this._lastPinch;this._material.zoom-=C*.004}this._lastPinch=r}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class ywA extends Ue{constructor(A){super(),B(this,"_offset",new AA),this.uniforms={map:{value:A},screenAspect:{value:1},offsetScale:{value:new VA(0,0,1,1)}},this.vertexShader=`
7589
+ `;class KZ extends go{constructor(){super("Sharpening",swA,{vertexShader:owA,blendFunction:He.NORMAL,uniforms:new Map([["amount",new MA(1)],["radius",new MA(1)]])})}}const AE=iA("debugpost"),yx=Symbol("needle:postprocessing-handler"),mx=Symbol("needle:previous-autoclear-state");class Vk{constructor(A){B(this,"_composer",null),B(this,"_lastVolumeComponents"),B(this,"_effects",[]),B(this,"_isActive",!1),B(this,"context"),this.context=A}get isActive(){return this._isActive}get composer(){return this._composer}apply(A){this._isActive=!0,this.onApply(this.context,A)}unapply(){var A;if(AE&&console.log("Unapplying postprocessing effects"),this._isActive=!1,this._lastVolumeComponents){for(const g of this._lastVolumeComponents)g.unapply();this._lastVolumeComponents.length=0}const e=this.context;e[yx]===this&&delete e[yx],e.composer===this._composer&&((A=e.composer)==null||A.dispose(),e.composer=null),typeof e.renderer[mx]=="boolean"&&(e.renderer.autoClear=e.renderer[mx])}dispose(){this.unapply();for(const A of this._effects)A.dispose();this._effects.length=0,this._composer=null}onApply(A,e){if(!e)return;A[yx]=this,AE&&console.log("refreshing volume profile",e),this._lastVolumeComponents=[...e],this._effects.length=0;const g={handler:this,components:this._lastVolumeComponents};for(let I=0;I<this._lastVolumeComponents.length;I++){const o=this._lastVolumeComponents[I];if(o.context=A,o.apply){if(o.active){if(!A.mainCameraComponent){console.error("No camera in scene found or available yet - can not create postprocessing effects");return}const s=o.apply(g);if(!s)continue;Array.isArray(s)?this._effects.push(...s):this._effects.push(s)}}else o.active&&Lt("Volume component is not a VolumeComponent: "+o.__type)}if(this.context.renderer.toneMapping!=OI&&!this._effects.find(I=>I instanceof fS)){const I=new fS;this._effects.push(I)}this.applyEffects(A)}applyEffects(A){const e=this._effects;if(e.length<=0)return;const g=A.mainCameraComponent,I=A.renderer,o=A.scene,s=g.cam;I[mx]=I.autoClear;const n=I.capabilities.maxSamples;this._composer||(this._composer=new aK(I,{frameBufferType:cg,stencilBuffer:!0,multisampling:Math.min(ls()?4:8,n)})),A.composer&&A.composer!==this._composer&&console.warn("There's already an active EffectComposer in your scene: replacing it with a new one. This might cause unexpected behaviour. Make sure to only use one PostprocessingManager/Volume in your scene."),A.composer=this._composer;const a=A.composer;a.setMainCamera(s),a.setRenderer(I),a.setMainScene(o);for(const C of a.passes)C.dispose();a.removeAllPasses();const r=new SS(o,s);r.name="Render To Screen",r.mainScene=o,a.addPass(r);try{this.orderEffects();const C=[];for(const Q of e)if(Q instanceof go)C.push(Q);else if(Q instanceof AI){const h=new t4(s,...C);h.mainScene=o,h.name=C.map(E=>E.constructor.name).join(", "),h.enabled=!0,C.length=0,a.addPass(Q)}if(C.length>0){const Q=new t4(s,...C);Q.name=C.map(h=>h.name).join(" "),Q.mainScene=o,Q.enabled=!0,a.addPass(Q)}}catch(C){console.error("Error while applying postprocessing effects",C),a.removeAllPasses()}AE&&console.log("PostProcessing Passes",e,"->",a.passes)}orderEffects(){var A;AE&&console.log("Before ordering effects",[...this._effects]);const e=this._effects;e.sort((g,I)=>{const o=Sx.findIndex(n=>g.constructor.name.endsWith(n.name)),s=Sx.findIndex(n=>I.constructor.name.endsWith(n.name));return o<0?(AE&&console.warn("Unknown effect found: ",g.constructor.name),-1):s<0?(AE&&console.warn("Unknown effect found: ",I.constructor.name),1):o<0?1:s<0?-1:o-s}),AE&&console.log("After ordering effects",[...this._effects]);for(let g=0;g<e.length;g++){const I=e[g];if(((A=I?.configuration)==null?void 0:A.gammaCorrection)!==void 0){const o=g===e.length-1;I.configuration.gammaCorrection=o}}}}const Sx=[i4,hK,zP,XP,FZ,$P,HP,_P,BK,jP,A4,PP,fS,OP,LP,KZ];async function fx(i){const{NeedleEngineHTMLElement:A}=await Promise.resolve().then(()=>HyA);A.observedAttributes.includes(i)||A.observedAttributes.push(i)}var nwA=Object.defineProperty,awA=Object.getOwnPropertyDescriptor,Qw=(i,A,e,g)=>{for(var I=g>1?void 0:g?awA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&nwA(A,e,I),I};const Ws=iA("debugskybox");fx("skybox-image"),fx("environment-image");function bZ(i,A,e,g,I){const o=new xa;o.allowDrop=!1,o.allowNetworking=!1,o.background=e,o.environment=g,gA.addComponent(i.scene,o);const s=n=>{typeof n=="string"&&(Ws&&console.log(I,"CHANGED TO",n),o.setSkybox(n))};return F2(i.domElement,I,s),o.addEventListener("destroy",()=>{Ws&&console.log("Destroyed attribute remote skybox",I),v2(i.domElement,I,s)}),o.setSkybox(A)}Qt.addContextCreatedCallback(i=>{var A;const e=i.context,g=e.domElement.getAttribute("skybox-image"),I=e.domElement.getAttribute("environment-image"),o=new Array;if(g){Ws&&console.log("Creating remote skybox to load "+g),((A=e.mainCameraComponent)==null?void 0:A.clearFlags)!==dB.Skybox&&console.warn('"skybox-image" attribute has no effect: camera clearflags are not set to "Skybox"');const s=bZ(e,g,!0,!1,"skybox-image");o.push(s)}if(I){Ws&&console.log("Creating remote environment to load "+I);const s=bZ(e,I,!1,!0,"environment-image");o.push(s)}return o.length>0?Y0(o):Promise.resolve()});function JZ(){return globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES||(globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES=new Array),globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES}function xZ(i){const A=JZ().find(e=>e.src===i);return A?(Ws&&console.log("Skybox: Found previously loaded texture for "+i),A.texture):null}async function rwA(i){const A=await i;Vv(A,!0),Vt(A)}function CwA(i,A){const e=JZ();for(;e.length>5;){const g=e.shift();g&&rwA(g.texture)}A.then(g=>Vv(g,!1)),e.push({src:i,texture:A})}class xa extends bA{constructor(){super(...arguments),B(this,"url"),B(this,"allowDrop",!0),B(this,"background",!0),B(this,"environment",!0),B(this,"allowNetworking",!0),B(this,"_loader"),B(this,"_prevUrl"),B(this,"_prevLoadedEnvironment"),B(this,"_prevEnvironment",null),B(this,"_prevBackground",null),B(this,"validTextureTypes",[".hdr",".exr",".jpg",".jpeg",".png"]),B(this,"onDragOverEvent",A=>{if(this.allowDrop&&A.dataTransfer)for(const e of A.dataTransfer.types)(e==="text/uri-list"||e==="Files")&&A.preventDefault()}),B(this,"onDrop",A=>{var e,g,I,o;if(this.allowDrop&&A.dataTransfer){for(const s of A.dataTransfer.types)if(Ws&&console.log(s),s==="text/uri-list"){const n=A.dataTransfer.getData(s);Ws&&console.log(s,n);let a=(g=(e=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(n))==null?void 0:e.groups)==null?void 0:g.name;if(a||(a=(o=(I=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(n))==null?void 0:I.groups)==null?void 0:o.name),Ws&&console.log(a),a){const r="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+a+"_1k.exr";console.log(`[Remote Skybox] Setting skybox from url: ${r}`),A.preventDefault(),this.setSkybox(r);break}else if(this.isValidTextureType(n)){console.log("[Remote Skybox] Setting skybox from url: "+n),A.preventDefault(),this.setSkybox(n);break}else{console.warn(`[RemoteSkybox] Unknown url ${n}. If you want to load a skybox from a url, make sure it is a valid image url. Url must end with${this.validTextureTypes.join(", ")}.`);const r=new CustomEvent("dropped-unknown-url",{detail:{sender:this,event:A,url:n,apply:C=>{A.preventDefault(),this.setSkybox(C)}}});this.dispatchEvent(r)}}else if(s=="Files"){const n=A.dataTransfer.files.item(0);if(Ws&&console.log(s,n),!n)continue;if(!this.isValidTextureType(n.name)){console.warn(`[RemoteSkybox]: File "${n.name}" is not supported. Supported files are ${this.validTextureTypes.join(", ")}`);return}if(xZ(n.name)===null){const a=new Blob([n]),r=URL.createObjectURL(a);A.preventDefault(),this.setSkybox(r,n.name)}else A.preventDefault(),this.setSkybox(n.name);break}}})}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var A;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Tt.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(A=this.context.mainCameraComponent)==null||A.applyClearFlags()}urlChangedSyncField(){this.allowNetworking&&this.url&&this.isRemoteTexture(this.url)&&this.setSkybox(this.url)}async setSkybox(A,e){var g;if(!this.activeAndEnabled||(A=BwA(A,this.environment,this.background),!A))return!1;if(e??(e=A),this.isValidTextureType(e)||console.warn("Potentially invalid skybox url",e,"on",this.name),Ws&&console.log("Set remote skybox url: "+A),this._prevUrl===A&&this._prevLoadedEnvironment)return this.applySkybox(),!0;(g=this._prevLoadedEnvironment)==null||g.dispose(),this._prevLoadedEnvironment=void 0,this._prevUrl=A;const I=await this.loadTexture(A,e);if(!I||!this.enabled)return!1;this.url=A;const o=A.lastIndexOf("/");return I.name=A.substring(o>=0?o+1:0),this._loader instanceof Zn&&(I.colorSpace=Ee),this._prevLoadedEnvironment=I,this.applySkybox(),!0}async loadTexture(A,e){var g,I,o,s,n;if(!A)return Promise.resolve(null);e??(e=A);const a=xZ(e);if(a){const h=await a;if(((I=(g=h.source)==null?void 0:g.data)==null?void 0:I.length)>0||(n=(s=(o=h.source)==null?void 0:o.data)==null?void 0:s.data)!=null&&n.length)return h}const r=e.endsWith(".exr"),C=e.endsWith(".hdr");r?this._loader instanceof Lp||(this._loader=new Lp):C?this._loader instanceof $S||(this._loader=new $S):this._loader instanceof Zn||(this._loader=new Zn),Ws&&console.log("Loading skybox: "+A);const Q=this._loader.loadAsync(A);return CwA(e,Q),await Q}applySkybox(){var A;const e=this._prevLoadedEnvironment;e&&(e.mapping=pE,e.needsUpdate=!0,this.context.scene.background!==e&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==e&&(this._prevEnvironment=this.context.scene.environment),Ws&&console.log("Set remote skybox",this.url,!Tt.backgroundShouldBeTransparent(this.context)),this.environment&&(this.context.scene.environment=e),this.background&&!Tt.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=e),((A=this.context.mainCameraComponent)==null?void 0:A.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}isRemoteTexture(A){return A.startsWith("http://")||A.startsWith("https://")}isValidTextureType(A){for(const e of this.validTextureTypes)if(A.endsWith(e))return!0;return!1}registerDropEvents(){this.unregisterDropEvents(),this.context.domElement.addEventListener("dragover",this.onDragOverEvent),this.context.domElement.addEventListener("drop",this.onDrop)}unregisterDropEvents(){this.context.domElement.removeEventListener("dragover",this.onDragOverEvent),this.context.domElement.removeEventListener("drop",this.onDrop)}}Qw([qb(xa.prototype.urlChangedSyncField),y(URL)],xa.prototype,"url",2),Qw([y()],xa.prototype,"allowDrop",2),Qw([y()],xa.prototype,"background",2),Qw([y()],xa.prototype,"environment",2),Qw([y()],xa.prototype,"allowNetworking",2);function BwA(i,A,e){const g=A&&!e;switch(i?.toLowerCase()){case"studio":return g?"https://cdn.needle.tools/static/skybox/modelviewer-Neutral-small.hdr":"https://cdn.needle.tools/static/skybox/modelviewer-Neutral.hdr";case"blurred-skybox":return g?"https://cdn.needle.tools/static/skybox/blurred-skybox-small.exr":"https://cdn.needle.tools/static/skybox/blurred-skybox.exr";case"quicklook-ar":return g?"https://cdn.needle.tools/static/skybox/QuickLook-ARMode-small.exr":"https://cdn.needle.tools/static/skybox/QuickLook-ARMode.exr";case"quicklook":return g?"https://cdn.needle.tools/static/skybox/QuickLook-ObjectMode-small.exr":"https://cdn.needle.tools/static/skybox/QuickLook-ObjectMode.exr"}return i===void 0?null:i}var QwA=Object.defineProperty,hwA=Object.getOwnPropertyDescriptor,gs=(i,A,e,g)=>{for(var I=g>1?void 0:g?hwA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&QwA(A,e,I),I};const Is=iA("debugsceneswitcher"),Xk="scene";fx(Xk);const HB=Promise.resolve(!1);class HI extends bA{constructor(){super(...arguments),B(this,"autoLoadFirstScene",!0),B(this,"scenes",[]),B(this,"loadingScene"),B(this,"queryParameterName","scene"),B(this,"useSceneName",!0),B(this,"clamp",!0),B(this,"useHistory",!0),B(this,"useKeyboard",!0),B(this,"useSwipe",!0),B(this,"useSceneLighting",!0),B(this,"preloadNext",1),B(this,"preloadPrevious",1),B(this,"preloadConcurrent",2),B(this,"_currentIndex",-1),B(this,"_currentScene"),B(this,"_engineElementOverserver"),B(this,"_preloadScheduler"),B(this,"onPopState",async A=>{if(!this.useHistory)return;const e=this.useHistory;try{this.useHistory=!1;let g=!1;if(this.queryParameterName&&(g=await this.tryLoadFromQueryParam()),!g){const I=A?.state;if(I&&I.startsWith(this.guid)){const o=I.substr(this.guid.length+2);Is&&console.log("PopState",o),await this.trySelectSceneFromValue(o)}}}finally{this.useHistory=e}}),B(this,"normalizedSwipeThresholdX",.1),B(this,"_didSwipe",!1),B(this,"onInputPointerMove",A=>{if(this.useSwipe&&!this._didSwipe&&A.button===0&&A.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const e=this.context.input.getPointerPositionDelta(A.button);if(e){const g=e.x/this.context.domWidth;g>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):g<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}}),B(this,"onInputPointerUp",A=>{A.button===0&&(this._didSwipe=!1)}),B(this,"onInputKeyDown",A=>{if(!this.useKeyboard||!this.scenes)return;const e=A.key.toLowerCase();if(!e)return;const g=parseInt(e)-1;if(g>=0){this.trySelectSceneFromValue(g);return}switch(e){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}}),B(this,"__lastSwitchScene"),B(this,"__lastSwitchScenePromise"),B(this,"_currentlyLoadingScene"),B(this,"_lastLoadingScene"),B(this,"_loadingScenePromise"),B(this,"_isCurrentlyLoading",!1),B(this,"_currentLoadingProgress")}get currentIndex(){return this._currentIndex}get currentLoadingProgress(){return this._currentLoadingProgress}get currentlyLoadingScene(){return this._currentlyLoadingScene}get currentlyLoadedScene(){return this._currentScene}awake(){this.scenes===void 0&&(this.scenes=[]);for(const A of this.scenes)A&&!A.hasUrl&&A.asset instanceof wA&&A.asset.removeFromParent();Is&&console.log("SceneSwitcher",this)}async onEnable(){if(globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(hi.KeyDown,this.onInputKeyDown),this.context.input.addEventListener(hi.PointerMove,this.onInputPointerMove),this.context.input.addEventListener(hi.PointerUp,this.onInputPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(A=>{for(const e of A)if(e.type==="attributes"&&e.attributeName===Xk){const g=this.context.domElement.getAttribute(Xk);g!==null&&this.trySelectSceneFromValue(g)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new EwA(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin(),this.autoLoadFirstScene&&this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const A=this.context.domElement.getAttribute(Xk);try{(A===null||!await this.trySelectSceneFromValue(A))&&this._currentIndex===-1&&this.select(0)}finally{}}}onDisable(){var A;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(hi.KeyDown,this.onInputKeyDown),this.context.input.removeEventListener(hi.PointerMove,this.onInputPointerMove),this.context.input.removeEventListener(hi.PointerUp,this.onInputPointerUp),(A=this._preloadScheduler)==null||A.stop()}addScene(A){if(typeof A=="string"){let e=this.context.addressables.findAssetReference(A);return e||(e=new gt(A),this.context.addressables.registerAssetReference(e)),this.scenes.push(e),e}return this.scenes.push(A),A}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(A){var e,g,I;if(Is&&console.log("select",A),typeof A=="object"&&console.warn('Switching to "'+A+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof A=="string"){const s=(e=this.scenes)==null?void 0:e.find(n=>n.uri===A);if(!s){const n=gt.getOrCreate(this.sourceId??"",A,this.context);return this.switchScene(n)}if(s)A=(g=this.scenes)==null?void 0:g.indexOf(s);else return HB}if(!((I=this.scenes)!=null&&I.length))return HB;if(A<0){if(this.clamp)return HB;A=this.scenes.length-1}else if(A>=this.scenes.length){if(this.clamp)return HB;A=0}const o=this.scenes[A];return this.switchScene(o)}async switchScene(A){if(!(A instanceof gt)){const e=typeof A;return e==="string"?this.select(A):e==="number"?this.select(A):(console.warn("SceneSwitcher: Can't switch to scene",A,"of type",e),!1)}return A.uri===this.sourceId?(console.warn("SceneSwitcher: can't load own scene - prevent recursive loading",this.sourceId),!1):this.__lastSwitchScene===A&&this.__lastSwitchScenePromise?this.__lastSwitchScenePromise:(this.__lastSwitchScene=A,this.__lastSwitchScenePromise=this.__internalSwitchScene(A),await this.__lastSwitchScenePromise)}async __internalSwitchScene(A){var e,g;if(this._currentScene){Is&&console.log("UNLOAD",this._currentScene.url,"HasURL?: "+this._currentScene.hasUrl);const o=this.tryGetSceneEventListener(this._currentScene.asset);if(o!=null&&o.sceneClosing){const s=o.sceneClosing();s instanceof Promise&&await s}this._currentScene.hasUrl?this._currentScene.unload():this._currentScene.asset instanceof wA&&this._currentScene.asset.removeFromParent()}this._currentScene=void 0;const I=this._currentIndex=((e=this.scenes)==null?void 0:e.indexOf(A))??-1;try{this._currentlyLoadingScene=A,this._currentLoadingProgress=new ProgressEvent("progress",{loaded:0,total:1});const o=new CustomEvent("loadscene-start",{detail:{scene:A,switcher:this,index:I}});this.dispatchEvent(o),await this.onStartLoading(),await A.loadAssetAsync((n,a)=>{this._currentLoadingProgress=a,this.dispatchEvent(a)}).catch(console.error),await this.onEndLoading();const s=new CustomEvent("loadscene-finished",{detail:{scene:A,switcher:this,index:I}});if(this.dispatchEvent(s),this._currentLoadingProgress=void 0,this._currentlyLoadingScene=void 0,s.defaultPrevented)return Is&&console.warn("Adding loaded scene prevented:",A,s),!1;if(!A.asset)return Is&&console.warn("Failed loading scene:",A),!1;if(this._currentIndex===I){if(Is&&console.log("ADD",A.uri),this._currentScene=A,gA.add(A.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(A),this.useHistory&&I>=0){let r=I.toString();if(this.useSceneName&&(r=qZ(A.uri)),(g=this.queryParameterName)!=null&&g.length)x0(this.queryParameterName,r,this.useHistory);else{const C=history.state,Q=this.guid+"::"+I;C!==Q&&history.pushState(Q,"unused",location.href)}}const n=this.tryGetSceneEventListener(A.asset);if(n!=null&&n.sceneOpened){const r=n.sceneOpened(this);r instanceof Promise&&await r}const a=new CustomEvent("scene-opened",{detail:{scene:A,switcher:this,index:I}});return this.dispatchEvent(a),!0}}catch(o){console.error(o)}return!1}preload(A){if(A>=0&&A<this.scenes.length){const e=this.scenes[A];if(e instanceof gt)return e.preload()}return HB}tryLoadFromQueryParam(){var A;if(!((A=this.queryParameterName)!=null&&A.length))return HB;const e=iA(this.queryParameterName);return typeof e=="boolean"?HB:this.trySelectSceneFromValue(e)}trySelectSceneFromValue(A){if(typeof A=="string"){const e=parseInt(A);if(e>=0&&e<this.scenes.length)return this.select(e);{const g=A.toLowerCase();for(let I=0;I<this.scenes.length;I++){const o=this.scenes[I];if(o&&qZ(o.uri).toLowerCase().includes(g))return this.select(I)}}}else if(typeof A=="number"&&A>=0&&A<this.scenes.length)return this.select(A);return zI()&&console.warn('Can not find scene: "'+A+'"',this),HB}async onStartLoading(){var A,e;if(this._isCurrentlyLoading=!0,this.loadingScene&&(this._lastLoadingScene!==this.loadingScene&&(this._loadingScenePromise=void 0),this._lastLoadingScene=this.loadingScene,this._loadingScenePromise||(this._loadingScenePromise=(A=this.loadingScene)==null?void 0:A.loadAssetAsync()),await this._loadingScenePromise,this._isCurrentlyLoading&&(e=this.loadingScene)!=null&&e.asset)){Is&&console.log("Add loading scene",this.loadingScene.uri,this.loadingScene.asset);const g=this.loadingScene.asset;gA.add(g,this.gameObject);const I=this.tryGetSceneEventListener(g);if(I!=null&&I.sceneOpened){const o=I.sceneOpened(this);o instanceof Promise&&await o}}if(this._isCurrentlyLoading){const g=this.tryGetSceneEventListener(this.gameObject);if(g&&g.sceneOpened){const I=g.sceneOpened(this);I instanceof Promise&&await I}}}async onEndLoading(){var A;if(this._isCurrentlyLoading=!1,(A=this.loadingScene)!=null&&A.asset){Is&&console.log("Remove loading scene",this.loadingScene.uri);const e=this.loadingScene.asset,g=this.tryGetSceneEventListener(e);if(typeof g?.sceneClosing=="function"){const I=g.sceneClosing();I instanceof Promise&&await I}gA.remove(e)}if(!this._isCurrentlyLoading){const e=this.tryGetSceneEventListener(this.gameObject);if(e&&e.sceneClosing){const g=e.sceneClosing();g instanceof Promise&&await g}}}tryGetSceneEventListener(A,e=0){const g=gA.foreachComponent(A,I=>I.sceneClosing?I:void 0);if(e===0&&!g&&A.children.length)for(const I of A.children){const o=this.tryGetSceneEventListener(I,e+1);if(o)return o}return g||null}}gs([y()],HI.prototype,"autoLoadFirstScene",2),gs([y(gt)],HI.prototype,"scenes",2),gs([y(gt)],HI.prototype,"loadingScene",2),gs([y()],HI.prototype,"queryParameterName",2),gs([y()],HI.prototype,"useSceneName",2),gs([y()],HI.prototype,"clamp",2),gs([y()],HI.prototype,"useHistory",2),gs([y()],HI.prototype,"useKeyboard",2),gs([y()],HI.prototype,"useSwipe",2),gs([y()],HI.prototype,"useSceneLighting",2),gs([y()],HI.prototype,"preloadNext",2),gs([y()],HI.prototype,"preloadPrevious",2),gs([y()],HI.prototype,"preloadConcurrent",2);function qZ(i){const A=i.split("/").pop(),e=A?.split(".").shift();return e!=null&&e.length?e:i}class EwA{constructor(A,e=1,g=1,I=2){B(this,"maxLoadAhead"),B(this,"maxLoadBehind"),B(this,"maxConcurrent"),B(this,"_isRunning",!1),B(this,"_switcher"),B(this,"_loadTasks",[]),B(this,"_maxConcurrentLoads",1),this._switcher=A,this.maxLoadAhead=e,this.maxLoadBehind=g,this.maxConcurrent=I}begin(){if(this._isRunning)return;Is&&console.log("Preload begin"),this._isRunning=!0;let A=-1,e,g;const I=this._switcher.scenes,o=setInterval(()=>{if(this.allLoaded()&&(Is&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(o);return}if(this.canLoadNewScene()===!1)return;A!==this._switcher.currentIndex&&(A=this._switcher.currentIndex,g=0,e=0);const s=g%2===0;s&&(e+=1),g+=1;const n=s?this.maxLoadAhead:this.maxLoadBehind;if(e>n)return;const a=s?A+e:A-e;if(a<0||a<0||a>=I.length)return;const r=I[a];new cwA(a,r,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){if(this._switcher.scenes){for(const A of this._switcher.scenes)if(A?.isLoaded()===!1)return!1}return!0}}class cwA{constructor(A,e,g){B(this,"index"),B(this,"asset"),B(this,"tasks"),this.index=A,this.asset=e,this.tasks=g,g.push(this),this.awaitLoading()}async awaitLoading(){this.asset&&!this.asset.isLoaded()&&(Is&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),Is&&console.log("Preload finished: "+this.asset.uri,this.index));const A=this.tasks.indexOf(this);A>=0&&this.tasks.splice(A,1)}}function lwA(){return new Promise((i,A)=>{const e=()=>{e!=null&&(document.removeEventListener("pointerdown",e),document.removeEventListener("click",e),document.removeEventListener("dragstart",e),document.removeEventListener("touchstart",e),i())};document.addEventListener("pointerdown",e),document.addEventListener("click",e),document.addEventListener("dragstart",e),document.addEventListener("touchstart",e)})}async function dwA(i){await lwA(),i()}var uwA=Object.defineProperty,pwA=Object.getOwnPropertyDescriptor,os=(i,A,e,g)=>{for(var I=g>1?void 0:g?pwA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&uwA(A,e,I),I};const Yg=iA("debugvideo");var LZ=(i=>(i[i.None=0]="None",i[i.AdjustHeight=1]="AdjustHeight",i[i.AdjustWidth=2]="AdjustWidth",i))(LZ||{}),_Z=(i=>(i[i.VideoClip=0]="VideoClip",i[i.Url=1]="Url",i))(_Z||{}),TZ=(i=>(i[i.CameraFarPlane=0]="CameraFarPlane",i[i.CameraNearPlane=1]="CameraNearPlane",i[i.RenderTexture=2]="RenderTexture",i[i.MaterialOverride=3]="MaterialOverride",i))(TZ||{});class mg extends bA{constructor(){super(),B(this,"playOnAwake",!0),B(this,"aspectMode",0),B(this,"clip",null),B(this,"source",1),B(this,"_url",null),B(this,"renderMode"),B(this,"targetMaterialProperty"),B(this,"targetMaterialRenderer"),B(this,"targetTexture"),B(this,"time",0),B(this,"_playbackSpeed",1),B(this,"_isLooping",!1),B(this,"_muted",!1),B(this,"_audioOutputMode",2),B(this,"playInBackground",!0),B(this,"_crossOrigin","anonymous"),B(this,"_videoElement",null),B(this,"_videoTexture",null),B(this,"_videoMaterial",null),B(this,"_isPlaying",!1),B(this,"wasPlaying",!1),B(this,"visibilityChanged",A=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}}),B(this,"_receivedInput",!1),B(this,"_overlay",null),B(this,"_targetObjects"),B(this,"_updateAspectRoutineId",-1),B(this,"_hls"),B(this,"onHlsAvailable",()=>{var A;Yg&&console.log("HLS: available",this.clip),!(!this.shouldUseM3U||!this.url)&&(this._hls||(this._hls=new Hls),this.videoElement.autoplay=!0,this._hls.loadSource(this.url),this._hls.attachMedia(this.videoElement),(A=this._videoElement)==null||A.play(),Yg&&console.log("HLS: loaded",this.clip))}),dwA(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],iA("videoscreenspace")&&window.addEventListener("keydown",A=>{A.key==="f"&&(this.screenspace=!this.screenspace)})}get url(){return this._url}set url(A){const e=this._url!==A;this.__didAwake?e&&this.setClipURL(A??""):this._url=A}get playbackSpeed(){var A;return((A=this._videoElement)==null?void 0:A.playbackRate)??this._playbackSpeed}set playbackSpeed(A){this._playbackSpeed=A,this._videoElement&&(this._videoElement.playbackRate=A)}get isLooping(){var A;return((A=this._videoElement)==null?void 0:A.loop)??this._isLooping}set isLooping(A){this._isLooping=A,this._videoElement&&(this._videoElement.loop=A)}get currentTime(){var A;return((A=this._videoElement)==null?void 0:A.currentTime)??this.time}set currentTime(A){this._videoElement?this._videoElement.currentTime=A:this.time=A}get isPlaying(){const A=this._videoElement;return!!(A&&(A.currentTime>0&&!A.paused&&!A.ended&&A.readyState>A.HAVE_CURRENT_DATA||A.srcObject&&A.srcObject.active))}get crossOrigin(){var A;return((A=this._videoElement)==null?void 0:A.crossOrigin)??this._crossOrigin}set crossOrigin(A){this._crossOrigin=A,this._videoElement&&(A!==null?this._videoElement.setAttribute("crossorigin",A):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return!this._videoMaterial&&!this.create(!1)?null:this._videoMaterial}get videoTexture(){return!this._videoTexture&&!this.create(!1)?null:this._videoTexture}get videoElement(){return!this._videoElement&&!this.create(!1)?null:this._videoElement}get muted(){var A;return((A=this._videoElement)==null?void 0:A.muted)??this._muted}set muted(A){this._muted=A,this._videoElement&&(this._videoElement.muted=A)}get currentVideo(){return this.clip}set audioOutputMode(A){A!==this._audioOutputMode&&(A===1&&se()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=A,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}preloadVideo(){Yg&&console.log("Video Preload: "+this.name,this.clip),this.create(!1)}preload(){this.preloadVideo()}setVideo(A){this.clip=A,this.source=0,this._videoElement?(this._videoElement.srcObject=A,this._isPlaying&&this.play(),this.updateAspect()):this.create(this.playOnAwake)}setClipURL(A){this._url!==A&&(this._url=A,this.source=1,Yg&&console.log("set url",A),this._videoElement?A.endsWith(".m3u8")||A.includes(".m3u")?this.ensureM3UCanBePlayed():(this._videoElement.src=A,this._isPlaying&&(this.stop(),this.play())):this.create(this.playOnAwake))}onEnable(){var A,e;Yg&&console.log("VideoPlayer.onEnable",_Z[this.source],this.clip,this.url,this),window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0?this.create(!0):this.preloadVideo(),this.screenspace?(A=this._overlay)==null||A.start():(e=this._overlay)==null||e.stop()}onDisable(){var A;window.removeEventListener("visibilitychange",this.visibilityChanged),(A=this._overlay)==null||A.stop(),this.pause()}onDestroy(){var A;this._videoElement&&((A=this.videoElement)==null||A.remove(),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var A,e;if(this._videoElement||this.create(!1),!this._videoElement){Yg&&console.warn("Can not play: no video element found",this);return}if(!(this._isPlaying&&!((A=this._videoElement)!=null&&A.ended)&&!((e=this._videoElement)!=null&&e.paused))){if(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.handleBeginPlaying(!1),this.shouldUseM3U){this.ensureM3UCanBePlayed();return}Yg&&console.log("Video Play()",this.clip,this._videoElement,this.time),this._videoElement.currentTime=this.time,this._videoElement.play().catch(g=>{var I;console.log(g),Yg&&console.error("Error playing video",g,"CODE="+g.code,(I=this.videoElement)==null?void 0:I.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),Yg&&console.log("play",this._videoElement,this.time)}}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),Yg&&console.log("STOP",this))}pause(){var A,e;this.time=((A=this._videoElement)==null?void 0:A.currentTime)??0,this._isPlaying=!1,(e=this._videoElement)==null||e.pause(),Yg&&console.log("PAUSE",this,this.currentTime)}create(A){let e;switch(this.source){case 0:e=this.clip;break;case 1:e=this.url,!(e!=null&&e.length)&&typeof this.clip=="string"&&(e=this.clip);break}return e?(this._videoElement||(Yg&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),this.context.domElement.shadowRoot.prepend(this._videoElement),this.updateVideoElementStyles()),typeof e=="string"?(Yg&&console.log("Set Video src",e),this._videoElement.src=e):(Yg&&console.log("Set Video srcObject",e),this._videoElement.srcObject=e),this._videoTexture||(this._videoTexture=new pT(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.colorSpace=Ee,A&&this.handleBeginPlaying(A),Yg&&console.log("Video: handle playing done...",e,A),!0):(Yg&&console.warn("No video source set",this),!1)}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var A;return((A=this._overlay)==null?void 0:A.enabled)??!1}set screenspace(A){var e;if(A){if(!this._videoTexture)return;this._overlay||(this._overlay=new DwA(this.context)),this._overlay.add(this._videoTexture)}else(e=this._overlay)==null||e.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=A)}createVideoElement(){const A=document.createElement("video");return this._crossOrigin&&A.setAttribute("crossorigin",this._crossOrigin),Yg&&console.log("created video element",A),A}handleBeginPlaying(A){var e,g;if(!this.activeAndEnabled||!this._videoElement)return;this._targetObjects.length=0;let I=this.gameObject;switch(this.renderMode){case 3:I=(e=this.targetMaterialRenderer)==null?void 0:e.gameObject,I||(I=(g=gA.getComponent(this.gameObject,Ji))==null?void 0:g.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!I){console.error("Missing target for video material renderer",this.name,TZ[this.renderMode],this);return}const o=I.material;if(o){this._targetObjects.push(I),o!==this._videoMaterial&&(this._videoMaterial=o.clone(),I.material=this._videoMaterial);const s="map",n=this._videoMaterial;if(!this.targetMaterialProperty)n[s]=this._videoTexture;else switch(this.targetMaterialProperty){default:n[s]=this._videoTexture;break}}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),A&&(this.shouldUseM3U&&this.ensureM3UCanBePlayed(),this.play())}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let A=!this._receivedInput||this.audioOutputMode===0;!A&&this._muted&&(A=!0),this._videoElement.muted=A,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const A=++this._updateAspectRoutineId,e=void 0,g=this.clip;for(;A===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&g===this.clip&&this._isPlaying;){if(!g||typeof g=="string")return;let I;for(const o of g.getVideoTracks()){const s=o.getSettings();if(s&&s.width&&s.height){I=s.width/s.height;break}else I=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(I===void 0){for(let o=0;o<10;o++)yield;if(!this.isPlaying)break;continue}if(e===I){yield;continue}for(const o of this._targetObjects){let s=1;if(o.parent){const n=zt(o.parent);s=n.x/n.y}switch(this.aspectMode){case 1:o.scale.y=1/I*o.scale.x*s;break;case 2:o.scale.x=I*o.scale.y*s;break}}for(let o=0;o<3;o++)yield}}get shouldUseM3U(){return this.url!=null&&(this.url.endsWith(".m3u8")||this.url.endsWith(".m3u"))&&this.source===1}ensureM3UCanBePlayed(){if(!this.shouldUseM3U)return;let A=document.head.querySelector("script[data-hls_library]");A?globalThis.Hls?this.onHlsAvailable():A.addEventListener("load",this.onHlsAvailable):(Yg&&console.log("HLS: load script"),A=document.createElement("script"),A.dataset.hls_library="hls.js",A.src="https://cdn.jsdelivr.net/npm/hls.js@1",A.addEventListener("load",this.onHlsAvailable),document.head.append(A))}}os([y()],mg.prototype,"playOnAwake",2),os([y()],mg.prototype,"aspectMode",2),os([y(URL)],mg.prototype,"clip",2),os([y()],mg.prototype,"source",2),os([y(URL)],mg.prototype,"url",1),os([y()],mg.prototype,"renderMode",2),os([y()],mg.prototype,"targetMaterialProperty",2),os([y(Ji)],mg.prototype,"targetMaterialRenderer",2),os([y(Te)],mg.prototype,"targetTexture",2),os([y()],mg.prototype,"time",2),os([y()],mg.prototype,"playbackSpeed",1),os([y()],mg.prototype,"isLooping",1),os([y()],mg.prototype,"audioOutputMode",1);class DwA{constructor(A){B(this,"context"),B(this,"_videos",[]),B(this,"_screenspaceModeQuad"),B(this,"_isInScreenspaceMode",!1),B(this,"_input"),this.context=A,this._input=new wwA(this)}get enabled(){return this._isInScreenspaceMode}set enabled(A){A?this.start():this.stop()}add(A){this._videos.indexOf(A)===-1&&this._videos.push(A)}remove(A){if(!A)return;const e=this._videos.indexOf(A);e>=0&&this._videos.splice(e,1)}start(){var A;if(this._isInScreenspaceMode||this._videos.length<0)return;const e=this._videos[this._videos.length-1];if(!e)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=qp.createPrimitive(ch.Quad,{material:new ywA(e)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const g=this._screenspaceModeQuad;this.context.scene.add(g),this.updateScreenspaceMaterialUniforms();const I=g.material;I?.reset(),(A=this._input)==null||A.enable(I)}stop(){var A;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((A=this._input)==null||A.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var A;const e=(A=this._screenspaceModeQuad)==null?void 0:A.material;e&&(e.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class wwA{constructor(A){B(this,"_onResizeScreenFn"),B(this,"_onKeyUpFn"),B(this,"_onMouseWheelFn"),B(this,"context"),B(this,"overlay"),B(this,"_material"),B(this,"_isPinching",!1),B(this,"_lastPinch",0),this.overlay=A,this.context=A.context}enable(A){this._material=A,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=I=>{I.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=I=>{this.overlay.enabled&&(A.zoom+=I.deltaY*5e-4,I.preventDefault())},{passive:!1});const e=new AA;window.addEventListener("mousemove",I=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const o=new AA(I.movementX,I.movementY);o.x/=this.context.domElement.clientWidth,o.y/=this.context.domElement.clientHeight,e.set(o.x,o.y),e.multiplyScalar(A.zoom/-this.context.time.deltaTime*.01),A.offset=A.offset.add(e)}}),window.addEventListener("pointermove",I=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(e.set(I.movementX,I.movementY),e.multiplyScalar(A.zoom*-this.context.time.deltaTime*.05),A.offset=A.offset.add(e))});let g=0;window.addEventListener("touchstart",I=>{if(I.touches.length<2){this.context.time.time-g<.3&&this.overlay.stop(),g=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",I=>{if(!this._isPinching||!this._material)return;const o=I.touches[0],s=I.touches[1],n=o.clientX-s.clientX,a=o.clientY-s.clientY,r=Math.sqrt(n*n+a*a);if(this._lastPinch!==0){const C=r-this._lastPinch;this._material.zoom-=C*.004}this._lastPinch=r}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class ywA extends Ue{constructor(A){super(),B(this,"_offset",new AA),this.uniforms={map:{value:A},screenAspect:{value:1},offsetScale:{value:new VA(0,0,1,1)}},this.vertexShader=`
7590
7590
  uniform sampler2D map;
7591
7591
  uniform float screenAspect;
7592
7592
  uniform vec4 offsetScale;